2022-10-31 15:37:15 +00:00
# How to run spam prevention on your nwaku node (RLN)
This guide explains how to run a nwaku node with RLN (Rate Limiting Nullifier) enabled.
2023-09-26 10:09:20 +00:00
[RLN ](https://rfc.vac.dev/spec/32/ ) is a protocol integrated into waku v2,
2022-10-31 15:37:15 +00:00
which prevents spam-based attacks on the network.
For further background on the research for RLN tailored to waku, refer
to [this ](https://rfc.vac.dev/spec/17/ ) RFC.
Registering to the membership group has been left out for brevity.
If you would like to register to the membership group and send messages with RLN,
refer to the [on-chain chat2 tutorial ](../../tutorial/onchain-rln-relay-chat2.md ).
2023-09-26 10:09:20 +00:00
This guide specifically allows a node to participate in RLN testnet 2.
2022-10-31 15:37:15 +00:00
You may alter the rln-specific arguments as required.
## Prerequisites
1. Follow the [droplet quickstart ](../droplet-quickstart.md ) or the [build guide ](./build.md ) till the `make` command for the wakunode2 binary.
> Note: If you would like to run a nwaku node with RLN enabled within a docker container, skip ahead to step 2.
2023-09-11 06:32:31 +00:00
## 1. Build wakunode2
2022-10-31 15:37:15 +00:00
2023-09-11 06:32:31 +00:00
Run -
2022-10-31 15:37:15 +00:00
```bash
make wakunode2
```
## 2. Update the runtime arguments
Follow [Step 10 ](../droplet-quickstart.md#10-run-nwaku ) of the [droplet quickstart ](../droplet-quickstart.md ) guide, while replacing the run command with -
```bash
2023-05-19 12:52:01 +00:00
export SEPOLIA_WS_NODE_ADDRESS=< WS RPC URL to a Sepolia Node >
2023-09-11 05:40:41 +00:00
export RLN_RELAY_CONTRACT_ADDRESS="0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4" # Replace this with any compatible implementation
2022-10-31 15:37:15 +00:00
$WAKUNODE_DIR/wakunode2 \
--store:true \
--persist-messages \
--dns-discovery \
--dns-discovery-url:"$WAKU_FLEET" \
--discv5-discovery:true \
--rln-relay:true \
--rln-relay-dynamic:true \
--rln-relay-eth-contract-address:"$RLN_RELAY_CONTRACT_ADDRESS" \
2023-05-19 12:52:01 +00:00
--rln-relay-eth-client-address:"$SEPOLIA_WS_NODE_ADDRESS"
2022-10-31 15:37:15 +00:00
```
OR
If you are running the nwaku node within docker, follow [Step 2 ](../docker-quickstart.md#step-2-run ) while replacing the run command with -
```bash
export WAKU_FLEET=< entree of the fleet >
2023-05-19 12:52:01 +00:00
export SEPOLIA_WS_NODE_ADDRESS=< WS RPC URL to a Sepolia Node >
2023-09-11 05:40:41 +00:00
export RLN_RELAY_CONTRACT_ADDRESS="0xF471d71E9b1455bBF4b85d475afb9BB0954A29c4" # Replace this with any compatible implementation
2023-09-26 10:09:20 +00:00
docker run -i -t -p 60000:60000 -p 9000:9000/udp wakuorg/nwaku:v0.20.0 \
2022-10-31 15:37:15 +00:00
--dns-discovery:true \
--dns-discovery-url:"$WAKU_FLEET" \
--discv5-discovery \
--nat:extip:[yourpublicip] \ # or, if you are behind a nat: --nat=any
--rln-relay:true \
--rln-relay-dynamic:true \
--rln-relay-eth-contract-address:"$RLN_RELAY_CONTRACT_ADDRESS" \
2023-05-19 12:52:01 +00:00
--rln-relay-eth-client-address:"$SEPOLIA_WS_NODE_ADDRESS"
2022-10-31 15:37:15 +00:00
```
> Note: You can choose to keep connections to other nodes alive by adding the `--keep-alive` flag.
Following is the list of additional fields that have been added to the
runtime arguments -
1. `--rln-relay` : Allows waku-rln-relay to be mounted into the setup of the nwaku node
2. `--rln-relay-dynamic` : Enables waku-rln-relay to connect to an ethereum node to fetch the membership group
3. `--rln-relay-eth-contract-address` : The contract address of an RLN membership group
2023-05-19 12:52:01 +00:00
4. `--rln-relay-eth-client-address` : The websocket url to a Sepolia ethereum node
2022-10-31 15:37:15 +00:00
You should now have nwaku running, with RLN enabled!
To see metrics related to the functioning of RLN, refer to this [guide ](./todo ).
You can also refer to the periodic logging, for a few metrics like -
- number of spam messages
- number of valid messages
- number of invalid messages
2023-09-26 10:09:20 +00:00
> Note: This guide will be updated in the future to include features like slashing.