nwaku/apps/wakunode2/config.nim

550 lines
16 KiB
Nim
Raw Normal View History

import
std/strutils,
stew/results,
chronos,
regex,
confutils,
confutils/defs,
confutils/std/net,
confutils/toml/defs as confTomlDefs,
confutils/toml/std/net as confTomlNet,
libp2p/crypto/crypto,
libp2p/crypto/secp,
nimcrypto/utils
import
../../waku/common/confutils/envvar/defs as confEnvvarDefs,
../../waku/common/confutils/envvar/std/net as confEnvvarNet,
../../waku/common/logging
export
confTomlDefs,
confTomlNet,
confEnvvarDefs,
confEnvvarNet
type ConfResult*[T] = Result[T, string]
type
WakuNodeConf* = object
configFile* {.
desc: "Loads configuration from a TOML file (cmd-line parameters take precedence)"
name: "config-file" }: Option[InputFile]
## Log configuration
logLevel* {.
desc: "Sets the log level for process. Supported levels: TRACE, DEBUG, INFO, NOTICE, WARN, ERROR or FATAL",
defaultValue: logging.LogLevel.INFO,
name: "log-level" .}: logging.LogLevel
logFormat* {.
desc: "Specifies what kind of logs should be written to stdout. Suported formats: TEXT, JSON",
defaultValue: logging.LogFormat.TEXT,
name: "log-format" .}: logging.LogFormat
## General node config
agentString* {.
defaultValue: "nwaku",
desc: "Node agent string which is used as identifier in network"
name: "agent-string" .}: string
nodekey* {.
desc: "P2P node private key as 64 char hex string.",
defaultValue: defaultPrivateKey()
name: "nodekey" }: PrivateKey
2020-10-22 15:04:17 +00:00
listenAddress* {.
defaultValue: defaultListenAddress()
2021-11-01 18:02:39 +00:00
desc: "Listening address for LibP2P (and Discovery v5, if enabled) traffic."
name: "listen-address"}: ValidIpAddress
tcpPort* {.
desc: "TCP listening port."
defaultValue: 60000
name: "tcp-port" }: Port
portsShift* {.
desc: "Add a shift to all port numbers."
defaultValue: 0
name: "ports-shift" }: uint16
nat* {.
desc: "Specify method to use for determining public address. " &
"Must be one of: any, none, upnp, pmp, extip:<IP>."
defaultValue: "any" }: string
maxConnections* {.
desc: "Maximum allowed number of libp2p connections."
defaultValue: 50
name: "max-connections" }: uint16
peerStoreCapacity* {.
desc: "Maximum stored peers in the peerstore."
defaultValue: 100
name: "peer-store-capacity" }: int
peerPersistence* {.
desc: "Enable peer persistence.",
defaultValue: false,
name: "peer-persistence" }: bool
## DNS addrs config
dnsAddrs* {.
desc: "Enable resolution of `dnsaddr`, `dns4` or `dns6` multiaddrs"
defaultValue: true
name: "dns-addrs" }: bool
dnsAddrsNameServers* {.
desc: "DNS name server IPs to query for DNS multiaddrs resolution. Argument may be repeated."
defaultValue: @[ValidIpAddress.init("1.1.1.1"), ValidIpAddress.init("1.0.0.1")]
name: "dns-addrs-name-server" }: seq[ValidIpAddress]
dns4DomainName* {.
desc: "The domain name resolving to the node's public IPv4 address",
defaultValue: ""
name: "dns4-domain-name" }: string
## Relay config
relay* {.
desc: "Enable relay protocol: true|false",
defaultValue: true
name: "relay" }: bool
relayPeerExchange* {.
desc: "Enable gossipsub peer exchange in relay protocol: true|false",
2022-05-13 16:18:09 +00:00
defaultValue: false
name: "relay-peer-exchange" }: bool
rlnRelay* {.
desc: "Enable spam protection through rln-relay: true|false",
defaultValue: false
name: "rln-relay" }: bool
rlnRelayCredPath* {.
desc: "The path for peristing rln-relay credential",
defaultValue: ""
name: "rln-relay-cred-path" }: string
rlnRelayMembershipIndex* {.
desc: "(experimental) the index of node in the rln-relay group: a value between 0-99 inclusive",
defaultValue: 0
name: "rln-relay-membership-index" }: uint
rlnRelayPubsubTopic* {.
desc: "the pubsub topic for which rln-relay gets enabled",
Rln-relay integration into chat2 (#835) * adds ProofMetadata * adds EPOCH_INTERVAL * adds messageLog field * adds updateLog, toEpoch, fromEpoch, getEpoch, compareTo * adds unit test for toEpoch and fromEpoch * adds unit test for Epoch comparison * adds result codes for updateLog * adds unit test for update log * renames epoch related consts * modifies updateLog with new return type and new logic of spam detection * adds unit text for the modified updateLog * changes max epoch gap type size * splits updateLog into two procs isSpam and updateLog * updates unittests * fixes a bug, returns false when the message is not spam * renames messageLog to nullifierLog * renames isSpam to hasDuplicate * updates the rln validator, adds comments * adds appendRLNProof proc plus some code beatification * unit test for validate message * adds unhappy test to validateMessage unit test * renames EPOCH_UNIT_SECONDS * renames MAX_CLOCK_GAP_SECONDS * WIP: integration test * fixes compile errors * sets a real epoch value * updates on old unittests * adds comments to the rln relay tests * adds more comments * makes rln import conditional * adds todos * adds more todos * adds rln-relay mount process into chat2 * further todos * logs contentTopic * introduces rln relay configs * changes default pubsub topic * adds contentTopic config * imports rln relay dependencies * consolidates imports * removes module identifier from ContentTopic * adds contentTopic field * adds contentTopic argument to mountRlnRelay calls * appends rln proof to chat2 messages * changes the default chat2 contentTopic * adds missing content topic fields * fixes a bug * adds a new logic about empty content topics * appends proof only when rln flag is active * removes unnecessary todos * fixes an indentation issue * adds log messages * verifies the proof against the concatenation of msg payload and content topic * a bug fix * removes duplicate epoch time calculation * updates log level to trace * updates default rln-relay content topic * adds support for empty content topics * updates changelog * changelog updates * removes a commented code block * updates addRLNRelayValidator string doc
2022-02-04 23:58:27 +00:00
defaultValue: "/waku/2/default-waku/proto"
name: "rln-relay-pubsub-topic" }: string
Rln-relay integration into chat2 (#835) * adds ProofMetadata * adds EPOCH_INTERVAL * adds messageLog field * adds updateLog, toEpoch, fromEpoch, getEpoch, compareTo * adds unit test for toEpoch and fromEpoch * adds unit test for Epoch comparison * adds result codes for updateLog * adds unit test for update log * renames epoch related consts * modifies updateLog with new return type and new logic of spam detection * adds unit text for the modified updateLog * changes max epoch gap type size * splits updateLog into two procs isSpam and updateLog * updates unittests * fixes a bug, returns false when the message is not spam * renames messageLog to nullifierLog * renames isSpam to hasDuplicate * updates the rln validator, adds comments * adds appendRLNProof proc plus some code beatification * unit test for validate message * adds unhappy test to validateMessage unit test * renames EPOCH_UNIT_SECONDS * renames MAX_CLOCK_GAP_SECONDS * WIP: integration test * fixes compile errors * sets a real epoch value * updates on old unittests * adds comments to the rln relay tests * adds more comments * makes rln import conditional * adds todos * adds more todos * adds rln-relay mount process into chat2 * further todos * logs contentTopic * introduces rln relay configs * changes default pubsub topic * adds contentTopic config * imports rln relay dependencies * consolidates imports * removes module identifier from ContentTopic * adds contentTopic field * adds contentTopic argument to mountRlnRelay calls * appends rln proof to chat2 messages * changes the default chat2 contentTopic * adds missing content topic fields * fixes a bug * adds a new logic about empty content topics * appends proof only when rln flag is active * removes unnecessary todos * fixes an indentation issue * adds log messages * verifies the proof against the concatenation of msg payload and content topic * a bug fix * removes duplicate epoch time calculation * updates log level to trace * updates default rln-relay content topic * adds support for empty content topics * updates changelog * changelog updates * removes a commented code block * updates addRLNRelayValidator string doc
2022-02-04 23:58:27 +00:00
rlnRelayContentTopic* {.
desc: "the pubsub topic for which rln-relay gets enabled",
defaultValue: "/toy-chat/2/luzhou/proto"
name: "rln-relay-content-topic" }: string
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
rlnRelayDynamic* {.
desc: "Enable waku-rln-relay with on-chain dynamic group management: true|false",
defaultValue: false
name: "rln-relay-dynamic" }: bool
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
rlnRelayIdKey* {.
desc: "Rln relay identity secret key as a Hex string",
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
defaultValue: ""
name: "rln-relay-id-key" }: string
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
rlnRelayIdCommitmentKey* {.
desc: "Rln relay identity commitment key as a Hex string",
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
defaultValue: ""
name: "rln-relay-id-commitment-key" }: string
# NOTE: This can be derived from the private key, but kept for future use
rlnRelayEthAccountAddress* {.
desc: "Account address for the Ethereum testnet Goerli",
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
defaultValue: ""
name: "rln-relay-eth-account-address" }: string
rlnRelayEthAccountPrivateKey* {.
desc: "Account private key for the Ethereum testnet Goerli",
defaultValue: ""
name: "rln-relay-eth-account-private-key" }: string
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
rlnRelayEthClientAddress* {.
desc: "WebSocket address of an Ethereum testnet client e.g., ws://localhost:8540/",
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
defaultValue: "ws://localhost:8540/"
name: "rln-relay-eth-client-address" }: string
rlnRelayEthContractAddress* {.
desc: "Address of membership contract on an Ethereum testnet",
Feat(rln-relay): enables two modes of onchain and offchain (#992) * adds the contract handler file * adds integration test for the group listening * adds groupManagement proc * deletes rln relay contract handler file * brings back all the tests * replaces toUINT256 with getIdCommitment proc * replaces individual futures with an array of futures * adds code documentation * asyncSpawn instead of await * adds untitest for toIDCommitment and toUInt256 * reorganizes the test and add rlnInstance * mounts handleGroupUpdates on the rln peer * asyncSpawn to await * implements toIDCommitment * updates the unittest * improves the code documentation * removes unused tests * WIP * uncomments the tests * defines a new mountRlnRelayStatic proc * splits mountRlnRelay into two procs for dynamic and static group management * adds a config for off-chain and on-chain rln-relay * runs dynamic or static mode of rln-relay based on the input config * adds Eth private key and account configs * reads Eth private key and account the configs * comments put the second register proc * add proper call to the rlnrelay dynamic mode * adds todo * adds new rln relay configs * splits register into two procs * makes eth account private key non-optional * removes getIdCommitment and edits the register proc * removes getIdCommitment calls * uncomments the commented tests * fixes a bug * removes contract deployment for the offchain test * fixes a bug, edits comments * removes custom types without proper parsing and serialization routines from the configs * fixes a bug * switches to stew byte utils * removes log decoding * WIP * updates register proc * edits test titles * removes eth private key config * changes the output of register proc to return the registered index * integrates the registration process into mountRlnRelayDynamic * integration test for the register proc * brings back the onchain tests * updates comments * cleans up * disambiguates the Address type namespace * fixes type ambiguities * adds default values for rln key and index * updates config descriptions * adds type conversion from hex to MembershipKeyPair * adds more code documentation * passed the group value instead of option to the mount proc * fix a bug * a minor input type fix for rln chat2 * groups let declarations * adds default values for addresses * logs registered keys
2022-06-17 22:00:19 +00:00
defaultValue: ""
name: "rln-relay-eth-contract-address" }: string
rlnRelayCredentialsPassword* {.
desc: "Password for encrypting RLN credentials",
defaultValue: ""
name: "rln-relay-cred-password" }: string
staticnodes* {.
desc: "Peer multiaddr to directly connect with. Argument may be repeated."
name: "staticnode" }: seq[string]
keepAlive* {.
desc: "Enable keep-alive for idle connections: true|false",
defaultValue: false
name: "keep-alive" }: bool
topics* {.
desc: "Default topics to subscribe to (space separated list)."
defaultValue: "/waku/2/default-waku/proto"
name: "topics" .}: string
## Store and message store config
store* {.
desc: "Enable/disable waku store protocol",
defaultValue: false,
name: "store" }: bool
storenode* {.
desc: "Peer multiaddress to query for storage",
defaultValue: "",
name: "storenode" }: string
storeMessageRetentionPolicy* {.
desc: "Message store retention policy. Time retention policy: 'time:<seconds>'. Capacity retention policy: 'capacity:<count>'. Set to 'none' to disable.",
defaultValue: "time:" & $2.days.seconds,
name: "store-message-retention-policy" }: string
storeMessageDbUrl* {.
desc: "The database connection URL for peristent storage.",
defaultValue: "sqlite://store.sqlite3",
name: "store-message-db-url" }: string
storeMessageDbVacuum* {.
desc: "Enable database vacuuming at start. Only supported by SQLite database engine.",
defaultValue: false,
name: "store-message-db-vacuum" }: bool
storeMessageDbMigration* {.
desc: "Enable database migration at start.",
defaultValue: true,
name: "store-message-db-migration" }: bool
storeResumePeer* {.
desc: "Peer multiaddress to resume the message store at boot.",
defaultValue: "",
name: "store-resume-peer" }: string
## Filter config
filter* {.
desc: "Enable filter protocol: true|false",
defaultValue: false
name: "filter" }: bool
filternode* {.
desc: "Peer multiaddr to request content filtering of messages.",
defaultValue: ""
name: "filternode" }: string
filterTimeout* {.
desc: "Timeout for filter node in seconds.",
defaultValue: 14400 # 4 hours
name: "filter-timeout" }: int64
## Swap config
swap* {.
desc: "Enable swap protocol: true|false",
2022-06-08 07:16:45 +00:00
defaultValue: false
name: "swap" }: bool
## Lightpush config
lightpush* {.
desc: "Enable lightpush protocol: true|false",
defaultValue: false
name: "lightpush" }: bool
lightpushnode* {.
desc: "Peer multiaddr to request lightpush of published messages.",
defaultValue: ""
name: "lightpushnode" }: string
## JSON-RPC config
rpc* {.
desc: "Enable Waku JSON-RPC server: true|false",
2020-04-29 05:19:48 +00:00
defaultValue: true
name: "rpc" }: bool
rpcAddress* {.
2020-12-24 08:02:30 +00:00
desc: "Listening address of the JSON-RPC server.",
defaultValue: ValidIpAddress.init("127.0.0.1")
name: "rpc-address" }: ValidIpAddress
rpcPort* {.
2020-12-24 08:02:30 +00:00
desc: "Listening port of the JSON-RPC server.",
defaultValue: 8545
name: "rpc-port" }: uint16
2020-12-24 08:02:30 +00:00
rpcAdmin* {.
desc: "Enable access to JSON-RPC Admin API: true|false",
2020-12-24 08:02:30 +00:00
defaultValue: false
name: "rpc-admin" }: bool
2020-12-24 08:02:30 +00:00
rpcPrivate* {.
desc: "Enable access to JSON-RPC Private API: true|false",
2020-12-24 08:02:30 +00:00
defaultValue: false
name: "rpc-private" }: bool
## REST HTTP config
rest* {.
desc: "Enable Waku REST HTTP server: true|false",
defaultValue: false
name: "rest" }: bool
restAddress* {.
desc: "Listening address of the REST HTTP server.",
defaultValue: ValidIpAddress.init("127.0.0.1")
name: "rest-address" }: ValidIpAddress
restPort* {.
desc: "Listening port of the REST HTTP server.",
defaultValue: 8645
name: "rest-port" }: uint16
restRelayCacheCapacity* {.
desc: "Capacity of the Relay REST API message cache.",
defaultValue: 30
name: "rest-relay-cache-capacity" }: uint32
restAdmin* {.
desc: "Enable access to REST HTTP Admin API: true|false",
defaultValue: false
name: "rest-admin" }: bool
restPrivate* {.
desc: "Enable access to REST HTTP Private API: true|false",
defaultValue: false
name: "rest-private" }: bool
## Metrics config
metricsServer* {.
desc: "Enable the metrics server: true|false"
defaultValue: false
name: "metrics-server" }: bool
metricsServerAddress* {.
desc: "Listening address of the metrics server."
defaultValue: ValidIpAddress.init("127.0.0.1")
name: "metrics-server-address" }: ValidIpAddress
metricsServerPort* {.
desc: "Listening HTTP port of the metrics server."
defaultValue: 8008
name: "metrics-server-port" }: uint16
metricsLogging* {.
desc: "Enable metrics logging: true|false"
defaultValue: true
name: "metrics-logging" }: bool
## DNS discovery config
dnsDiscovery* {.
desc: "Enable discovering nodes via DNS"
defaultValue: false
name: "dns-discovery" }: bool
dnsDiscoveryUrl* {.
desc: "URL for DNS node list in format 'enrtree://<key>@<fqdn>'",
defaultValue: ""
name: "dns-discovery-url" }: string
dnsDiscoveryNameServers* {.
desc: "DNS name server IPs to query. Argument may be repeated."
defaultValue: @[ValidIpAddress.init("1.1.1.1"), ValidIpAddress.init("1.0.0.1")]
name: "dns-discovery-name-server" }: seq[ValidIpAddress]
2021-11-01 18:02:39 +00:00
## Discovery v5 config
2021-11-01 18:02:39 +00:00
discv5Discovery* {.
desc: "Enable discovering nodes via Node Discovery v5"
defaultValue: false
name: "discv5-discovery" }: bool
2021-11-01 18:02:39 +00:00
discv5UdpPort* {.
desc: "Listening UDP port for Node Discovery v5."
defaultValue: 9000
name: "discv5-udp-port" }: Port
2021-11-01 18:02:39 +00:00
discv5BootstrapNodes* {.
desc: "Text-encoded ENR for bootstrap node. Used when connecting to the network. Argument may be repeated."
name: "discv5-bootstrap-node" }: seq[string]
2021-11-01 18:02:39 +00:00
discv5EnrAutoUpdate* {.
desc: "Discovery can automatically update its ENR with the IP address " &
"and UDP port as seen by other nodes it communicates with. " &
"This option allows to enable/disable this functionality"
defaultValue: false
name: "discv5-enr-auto-update" .}: bool
discv5TableIpLimit* {.
hidden
desc: "Maximum amount of nodes with the same IP in discv5 routing tables"
defaultValue: 10
name: "discv5-table-ip-limit" .}: uint
discv5BucketIpLimit* {.
hidden
desc: "Maximum amount of nodes with the same IP in discv5 routing table buckets"
defaultValue: 2
name: "discv5-bucket-ip-limit" .}: uint
discv5BitsPerHop* {.
hidden
desc: "Kademlia's b variable, increase for less hops per lookup"
defaultValue: 1
name: "discv5-bits-per-hop" .}: int
## waku peer exchange config
peerExchange* {.
desc: "Enable waku peer exchange protocol (responder side): true|false",
defaultValue: false
name: "peer-exchange" }: bool
peerExchangeNode* {.
desc: "Peer multiaddr to send peer exchange requests to. (enables peer exchange protocol requester side)",
defaultValue: ""
name: "peer-exchange-node" }: string
## websocket config
websocketSupport* {.
desc: "Enable websocket: true|false",
defaultValue: false
name: "websocket-support"}: bool
websocketPort* {.
desc: "WebSocket listening port."
defaultValue: 8000
name: "websocket-port" }: Port
Secure websocket (#759) * add config Signed-off-by: rshiv <reeshav96@gmail.com> * secure websocket integration Signed-off-by: rshiv <reeshav96@gmail.com> * secure websocket debug Signed-off-by: rshiv <reeshav96@gmail.com> * config change Signed-off-by: rshiv <reeshav96@gmail.com> * working secure websocket changes Signed-off-by: rshiv <reeshav96@gmail.com> * Update submodules (#761) * Release v0.6 (#760) * Read from path Signed-off-by: rshiv <reeshav96@gmail.com> * Tests for secure websockets Signed-off-by: rshiv <reeshav96@gmail.com> * CI failure fix Signed-off-by: rshiv <reeshav96@gmail.com> * path resolver CI Signed-off-by: rshiv <reeshav96@gmail.com> * self review fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update examples/v2/config_chat2.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update waku/v2/utils/peers.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/node/wakunode2.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update tests/v2/test_wakunode.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * handle review comments Signed-off-by: rshiv <reeshav96@gmail.com> Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com>
2021-11-10 12:05:36 +00:00
websocketSecureSupport* {.
desc: "Enable secure websocket: true|false",
defaultValue: false
name: "websocket-secure-support"}: bool
Secure websocket (#759) * add config Signed-off-by: rshiv <reeshav96@gmail.com> * secure websocket integration Signed-off-by: rshiv <reeshav96@gmail.com> * secure websocket debug Signed-off-by: rshiv <reeshav96@gmail.com> * config change Signed-off-by: rshiv <reeshav96@gmail.com> * working secure websocket changes Signed-off-by: rshiv <reeshav96@gmail.com> * Update submodules (#761) * Release v0.6 (#760) * Read from path Signed-off-by: rshiv <reeshav96@gmail.com> * Tests for secure websockets Signed-off-by: rshiv <reeshav96@gmail.com> * CI failure fix Signed-off-by: rshiv <reeshav96@gmail.com> * path resolver CI Signed-off-by: rshiv <reeshav96@gmail.com> * self review fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update examples/v2/config_chat2.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update waku/v2/utils/peers.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/node/wakunode2.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update tests/v2/test_wakunode.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * handle review comments Signed-off-by: rshiv <reeshav96@gmail.com> Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com>
2021-11-10 12:05:36 +00:00
websocketSecureKeyPath* {.
desc: "Secure websocket key path: '/path/to/key.txt' ",
defaultValue: ""
name: "websocket-secure-key-path"}: string
Secure websocket (#759) * add config Signed-off-by: rshiv <reeshav96@gmail.com> * secure websocket integration Signed-off-by: rshiv <reeshav96@gmail.com> * secure websocket debug Signed-off-by: rshiv <reeshav96@gmail.com> * config change Signed-off-by: rshiv <reeshav96@gmail.com> * working secure websocket changes Signed-off-by: rshiv <reeshav96@gmail.com> * Update submodules (#761) * Release v0.6 (#760) * Read from path Signed-off-by: rshiv <reeshav96@gmail.com> * Tests for secure websockets Signed-off-by: rshiv <reeshav96@gmail.com> * CI failure fix Signed-off-by: rshiv <reeshav96@gmail.com> * path resolver CI Signed-off-by: rshiv <reeshav96@gmail.com> * self review fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update examples/v2/config_chat2.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update waku/v2/utils/peers.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * Update waku/v2/node/wakunode2.nim Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> * review comment fix Signed-off-by: rshiv <reeshav96@gmail.com> * Update tests/v2/test_wakunode.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * Update waku/v2/utils/wakuswitch.nim Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com> * handle review comments Signed-off-by: rshiv <reeshav96@gmail.com> Co-authored-by: Hanno Cornelius <68783915+jm-clius@users.noreply.github.com> Co-authored-by: Sanaz Taheri Boshrooyeh <35961250+staheri14@users.noreply.github.com>
2021-11-10 12:05:36 +00:00
websocketSecureCertPath* {.
desc: "Secure websocket Certificate path: '/path/to/cert.txt' ",
defaultValue: ""
name: "websocket-secure-cert-path"}: string
## Parsing
# NOTE: Keys are different in nim-libp2p
proc parseCmdArg*(T: type crypto.PrivateKey, p: string): T =
try:
let key = SkPrivateKey.init(utils.fromHex(p)).tryGet()
crypto.PrivateKey(scheme: Secp256k1, skkey: key)
except:
raise newException(ConfigurationError, "Invalid private key")
proc completeCmdArg*(T: type crypto.PrivateKey, val: string): seq[string] =
return @[]
proc defaultPrivateKey*(): PrivateKey =
crypto.PrivateKey.random(Secp256k1, crypto.newRng()[]).value
proc parseCmdArg*(T: type ValidIpAddress, p: string): T =
try:
ValidIpAddress.init(p)
except:
raise newException(ConfigurationError, "Invalid IP address")
proc completeCmdArg*(T: type ValidIpAddress, val: string): seq[string] =
return @[]
proc defaultListenAddress*(): ValidIpAddress =
# TODO: How should we select between IPv4 and IPv6
# Maybe there should be a config option for this.
(static ValidIpAddress.init("0.0.0.0"))
proc parseCmdArg*(T: type Port, p: string): T =
try:
Port(parseInt(p))
except:
raise newException(ConfigurationError, "Invalid Port number")
proc completeCmdArg*(T: type Port, val: string): seq[string] =
return @[]
## Configuration validation
let DbUrlRegex = re"^[\w\+]+:\/\/[\w\/\\\.\:\@]+$"
proc validateDbUrl*(val: string): ConfResult[string] =
let val = val.strip()
if val == "" or val == "none" or val.match(DbUrlRegex):
ok(val)
else:
err("invalid 'db url' option format: " & val)
let StoreMessageRetentionPolicyRegex = re"^\w+:\w+$"
proc validateStoreMessageRetentionPolicy*(val: string): ConfResult[string] =
let val = val.strip()
if val == "" or val == "none" or val.match(StoreMessageRetentionPolicyRegex):
ok(val)
else:
err("invalid 'store message retention policy' option format: " & val)
## Load
proc readValue*(r: var TomlReader, value: var crypto.PrivateKey) {.raises: [SerializationError].} =
try:
value = parseCmdArg(crypto.PrivateKey, r.readValue(string))
except CatchableError:
raise newException(SerializationError, getCurrentExceptionMsg())
proc readValue*(r: var EnvvarReader, value: var crypto.PrivateKey) {.raises: [SerializationError].} =
try:
value = parseCmdArg(crypto.PrivateKey, r.readValue(string))
except CatchableError:
raise newException(SerializationError, getCurrentExceptionMsg())
{.push warning[ProveInit]: off.}
proc load*(T: type WakuNodeConf, version=""): ConfResult[T] =
try:
let conf = WakuNodeConf.load(
version=version,
secondarySources = proc (conf: WakuNodeConf, sources: auto) =
sources.addConfigFile(Envvar, InputFile("wakunode2"))
if conf.configFile.isSome():
sources.addConfigFile(Toml, conf.configFile.get())
)
ok(conf)
except CatchableError:
err(getCurrentExceptionMsg())
{.pop.}