diff --git a/docs/tutorials/rln.md b/docs/tutorials/rln.md index 46404895..2404c8d7 100644 --- a/docs/tutorials/rln.md +++ b/docs/tutorials/rln.md @@ -56,25 +56,25 @@ make chat2 Run the following command to set up your chat2 client. ``` -./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --eth-mem-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --eth-account-privatekey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --eth-client-address=xxxx +./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --rln-relay-eth-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --rln-relay-eth-account-private-key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --rln-relay-eth-client-address=xxxx ``` In this command -- the `--fleet:test` indicates that the chat2 app gets connected to the test fleets. -- the `toy-chat/2/luzhou/proto` passed to the `content-topic` option indicates the content topic on which the chat2 application is going to run. -- the `rln-relay` flag is set to `true` to enable the Waku-RLN-Relay protocol for spam protection. +- the `--fleet=test` indicates that the chat2 app gets connected to the test fleets. +- the `toy-chat/2/luzhou/proto` passed to the `--content-topic` option indicates the content topic on which the chat2 application is going to run. +- the `--rln-relay` flag is set to `true` to enable the Waku-RLN-Relay protocol for spam protection. - the `--rln-relay-dynamic` flag is set to `true` to enable the on-chain mode of Waku-RLN-Relay protocol with dynamic group management. -- the `--eth-mem-contract-address` option gets the address of the membership contract. +- the `--rln-relay-eth-contract-address` option gets the address of the membership contract. The current address of the contract is `0x4252105670fe33d2947e8ead304969849e64f2a6`. You may check the state of the contract on the [Goerli testnet](https://goerli.etherscan.io/address/0x4252105670fe33d2947e8ead304969849e64f2a6). -- the `eth-account-privatekey` option is for your account private key on the Goerli testnet. +- the `--rln-relay-eth-account-private-key` option is for your account private key on the Goerli testnet. It is made up of 64 hex characters (not sensitive to the `0x` prefix). -- the `eth-client-address` should be assigned with the address of a websocket endpoint of the hosted node on the Goerli testnet. +- the `--rln-relay-eth-client-address` should be assigned with the address of a websocket endpoint of the hosted node on the Goerli testnet. You need to replace the `xxxx` with the actual node's websocket endpoint. -For the last two config options i.e., `eth-account-privatekey`, and `eth-client-address`, if you do not know how to obtain those, you may use the following tutorial on the [prerequisites of running on-chain spam-protected chat2](https://github.com/status-im/nwaku/blob/master/docs/tutorial/pre-requisites-of-running-on-chain-spam-protected-chat2.md). +For the last two config options i.e., `--rln-relay-eth-account-private-key`, and `--rln-relay-eth-client-address`, if you do not know how to obtain those, you may use the following tutorial on the [prerequisites of running on-chain spam-protected chat2](https://github.com/status-im/nwaku/blob/master/docs/tutorial/pre-requisites-of-running-on-chain-spam-protected-chat2.md). -> You may set up more than one chat client, using the `--rln-relay-membership-credentials-file` flag, specifying in each client a different path to store the credentials. +> You may set up more than one chat client, using the `--rln-relay-cred-path` flag, specifying in each client a different path to store the credentials. Once you run the command, you will see the following message: ``` @@ -155,7 +155,7 @@ Bye! ## How to reuse RLN credential -You may reuse your old RLN credential using `rln-relay-membership-index`, `rln-relay-id` and `rln-relay-id-commitment` options. +You may reuse your old RLN credential using `--rln-relay-membership-index`, `--rln-relay-id` and `--rln-relay-id-commitment` options. For instance, if the previously generated credential are ``` INFO: RLN config: @@ -165,13 +165,13 @@ INFO: RLN config: ``` Then, the execution command will look like this (inspect the last three config options): ``` -./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --eth-mem-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --eth-account-privatekey=your_eth_private_key --eth-client-address=your_goerli_node --rln-relay-membership-index=63 --rln-relay-id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --rln-relay-id-commitment:6c6598126ba10d1b70100893b76d7f8d7343eeb8f5ecfd48371b421c5aa6f012 +./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --rln-relay-eth-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --rln-relay-eth-account-private-key=your_eth_private_key --rln-relay-eth-client-address=your_goerli_node --rln-relay-membership-index=63 --rln-relay-id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --rln-relay-id-commitment:6c6598126ba10d1b70100893b76d7f8d7343eeb8f5ecfd48371b421c5aa6f012 ``` # Sample test output In this section, a sample test of running two chat clients is provided. -Note that the values used for `eth-account-privatekey`, and `eth-client-address` in the following code snippets are junk and not valid. +Note that the values used for `--rln-relay-eth-account-private-key`, and `--rln-relay-eth-client-address` in the following code snippets are junk and not valid. The two chat clients namely `Alice` and `Bob` are connected to the test fleets. `Alice` sends 4 messages i.e., `message1`, `message2`, `message3`, and `message4`. @@ -182,7 +182,7 @@ You can check this fact by looking at `Bob`'s console, where `message3` is missi **Alice** ``` -./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --eth-mem-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --eth-account-privatekey=your_eth_private_key --eth-client-address=your_goerli_node --rln-relay-membership-credentials-file=rlnCredentialsAlice.txt --nickname=Alice +./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --rln-relay-eth-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --rln-relay-eth-account-private-key=your_eth_private_key --rln-relay-eth-client-address=your_goerli_node --rln-relay-cred-path=./path/to/alice/folder --nickname=Alice Seting up dynamic rln INFO: Welcome, Alice! @@ -230,7 +230,7 @@ INFO RLN Epoch: 165886593 **Bob** ``` -./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --eth-mem-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --eth-account-privatekey=your_eth_private_key --eth-client-address=your_goerli_node --rln-relay-membership-credentials-file=rlnCredentialsBob.txt --nickname=Bob +./build/chat2 --fleet=test --content-topic=/toy-chat/2/luzhou/proto --rln-relay=true --rln-relay-dynamic=true --rln-relay-eth-contract-address=0x4252105670fe33d2947e8ead304969849e64f2a6 --rln-relay-eth-account-private-key=your_eth_private_key --rln-relay-eth-client-address=your_goerli_node --rln-relay-cred-path=./path/to/bob/folder --nickname=Bob Seting up dynamic rln INFO: Welcome, Bob! diff --git a/examples/chat2/flags.go b/examples/chat2/flags.go index b00e4ca7..488d0bb0 100644 --- a/examples/chat2/flags.go +++ b/examples/chat2/flags.go @@ -34,6 +34,20 @@ func getFlags() []cli.Flag { options.Fleet = fleetProd return []cli.Flag{ + &cli.GenericFlag{ + Name: "nodekey", + Usage: "P2P node private key as hex. (default random)", + Value: &wcli.PrivateKeyValue{ + Value: &options.NodeKey, + }, + }, + &cli.StringFlag{ + Name: "listen-address", + Aliases: []string{"host", "address"}, + Value: "0.0.0.0", + Usage: "Listening address", + Destination: &options.Address, + }, &cli.IntFlag{ Name: "tcp-port", Aliases: []string{"port", "p"}, @@ -41,19 +55,11 @@ func getFlags() []cli.Flag { Usage: "Libp2p TCP listening port (0 for random)", Destination: &options.Port, }, - &cli.StringFlag{ - Name: "address", - Aliases: []string{"host", "listen-address"}, - Value: "0.0.0.0", - Usage: "Listening address", - Destination: &options.Address, - }, - &cli.GenericFlag{ - Name: "nodekey", - Usage: "P2P node private key as hex. (default random)", - Value: &wcli.PrivateKeyValue{ - Value: &options.NodeKey, - }, + &cli.IntFlag{ + Name: "udp-port", + Value: 60000, + Usage: "Listening UDP port for Node Discovery v5.", + Destination: &options.DiscV5.Port, }, &cli.StringFlag{ Name: "content-topic", @@ -82,7 +88,6 @@ func getFlags() []cli.Flag { Destination: &options.Nickname, Value: "Anonymous", }, - &cli.BoolFlag{ Name: "relay", Value: true, @@ -147,12 +152,6 @@ func getFlags() []cli.Flag { Usage: "Text-encoded ENR for bootstrap node. Used when connecting to the network. Option may be repeated", Destination: &options.DiscV5.Nodes, }, - &cli.IntFlag{ - Name: "discv5-udp-port", - Value: 9000, - Usage: "Listening UDP port for Node Discovery v5.", - Destination: &options.DiscV5.Port, - }, &cli.BoolFlag{ Name: "discv5-enr-auto-update", Usage: "Discovery can automatically update its ENR with the IP address as seen by other nodes it communicates with.", @@ -204,12 +203,12 @@ func getFlags() []cli.Flag { Destination: &options.RLNRelay.Dynamic, }, &cli.StringFlag{ - Name: "rln-relay-id", + Name: "rln-relay-id-key", Usage: "Rln relay identity secret key as a Hex string", Destination: &options.RLNRelay.IDKey, }, &cli.StringFlag{ - Name: "rln-relay-id-commitment", + Name: "rln-relay-id-commitment-key", Usage: "Rln relay identity commitment key as a Hex string", Destination: &options.RLNRelay.IDCommitment, }, @@ -222,20 +221,20 @@ func getFlags() []cli.Flag { // TODO: this is a good candidate option for subcommands // TODO: consider accepting a private key file and passwd &cli.GenericFlag{ - Name: "eth-account-privatekey", + Name: "rln-relay-eth-account-private-key", Usage: "Ethereum Goerli testnet account private key used for registering in member contract", Value: &wcli.PrivateKeyValue{ Value: &options.RLNRelay.ETHPrivateKey, }, }, &cli.StringFlag{ - Name: "eth-client-address", + Name: "rln-relay-eth-client-address", Usage: "Ethereum testnet client address", Value: "ws://localhost:8545", Destination: &options.RLNRelay.ETHClientAddress, }, &cli.GenericFlag{ - Name: "eth-mem-contract-address", + Name: "rln-relay-eth-contract-address", Usage: "Address of membership contract on an Ethereum testnet", Value: &wcli.AddressValue{ Value: &options.RLNRelay.MembershipContractAddress, diff --git a/examples/chat2/go.mod b/examples/chat2/go.mod index 5df43e5e..b90ae3e4 100644 --- a/examples/chat2/go.mod +++ b/examples/chat2/go.mod @@ -20,7 +20,7 @@ require ( github.com/multiformats/go-multiaddr v0.6.0 github.com/status-im/go-waku v0.0.0-00010101000000-000000000000 github.com/status-im/go-zerokit-rln v0.1.5 - github.com/urfave/cli/v2 v2.11.2 + github.com/urfave/cli/v2 v2.20.2 golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 google.golang.org/protobuf v1.28.0 diff --git a/examples/chat2/go.sum b/examples/chat2/go.sum index e119122e..3fdcd0ce 100644 --- a/examples/chat2/go.sum +++ b/examples/chat2/go.sum @@ -1709,6 +1709,8 @@ github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.11.2 h1:FVfNg4m3vbjbBpLYxW//WjxUoHvJ9TlppXcqY9Q9ZfA= github.com/urfave/cli/v2 v2.11.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= +github.com/urfave/cli/v2 v2.20.2 h1:dKA0LUjznZpwmmbrc0pOgcLTEilnHeM8Av9Yng77gHM= +github.com/urfave/cli/v2 v2.20.2/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= diff --git a/go.mod b/go.mod index 84737bef..08980e25 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/status-im/go-waku-rendezvous v0.0.0-20220817210730-9b9b02b1e880 github.com/stretchr/testify v1.8.0 github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a - github.com/urfave/cli/v2 v2.11.2 + github.com/urfave/cli/v2 v2.20.2 go.opencensus.io v0.23.0 go.uber.org/zap v1.22.0 golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 diff --git a/go.sum b/go.sum index ca3f2848..31fa952e 100644 --- a/go.sum +++ b/go.sum @@ -1704,6 +1704,8 @@ github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.11.2 h1:FVfNg4m3vbjbBpLYxW//WjxUoHvJ9TlppXcqY9Q9ZfA= github.com/urfave/cli/v2 v2.11.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= +github.com/urfave/cli/v2 v2.20.2 h1:dKA0LUjznZpwmmbrc0pOgcLTEilnHeM8Av9Yng77gHM= +github.com/urfave/cli/v2 v2.20.2/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= diff --git a/waku_rln.go b/waku_rln.go index 1597db44..4ce7a643 100644 --- a/waku_rln.go +++ b/waku_rln.go @@ -40,17 +40,17 @@ func rlnFlags() []cli.Flag { Destination: &options.RLNRelay.Dynamic, }, &cli.StringFlag{ - Name: "rln-relay-id", + Name: "rln-relay-id-key", Usage: "Rln relay identity secret key as a Hex string", Destination: &options.RLNRelay.IDKey, }, &cli.StringFlag{ - Name: "rln-relay-id-commitment", + Name: "rln-relay-id-commitment-key", Usage: "Rln relay identity commitment key as a Hex string", Destination: &options.RLNRelay.IDCommitment, }, &cli.PathFlag{ - Name: "rln-relay-membership-credentials-file", + Name: "rln-relay-cred-path", Usage: "RLN relay membership credentials file", Value: "", Destination: &options.RLNRelay.CredentialsPath, @@ -58,20 +58,20 @@ func rlnFlags() []cli.Flag { // TODO: this is a good candidate option for subcommands // TODO: consider accepting a private key file and passwd &cli.GenericFlag{ - Name: "eth-private-key", + Name: "rln-relay-eth-account-private-key", Usage: "Ethereum account private key used for registering in member contract", Value: &wcli.PrivateKeyValue{ Value: &options.RLNRelay.ETHPrivateKey, }, }, &cli.StringFlag{ - Name: "eth-client-address", + Name: "rln-relay-eth-client-address", Usage: "Ethereum testnet client address", Value: "ws://localhost:8545", Destination: &options.RLNRelay.ETHClientAddress, }, &cli.GenericFlag{ - Name: "eth-mem-contract-address", + Name: "rln-relay-eth-contract-address", Usage: "Address of membership contract ", Value: &wcli.AddressValue{ Value: &options.RLNRelay.MembershipContractAddress,