Squash of 13 commits from feat/mix-dos-protection-libp2p-v2.0.0 onto the logos_delivery/ folder-restructure base from #3935 (build-messaging-folder). Original commit history (squashed): - d8e6dcef feat(mix): integrate mix protocol with extended kademlia + RLN spam protection - fb72f18d refactor(mix): split DoS-protection self-registration into background retry - d8bbef0c feat(mix): bump libp2p stack to v2.0.0 + adopt stateless RLN spam protection - 2f24448a fix(tests): use HmacDrbgContext.new() instead of crypto.newRng() - 5a21455c fix(ci): regen nimble.lock for v2.0.0 + disambiguate rng in wakucore - 03ef02a2 fix(tests): wrap HmacDrbgContext via newBearSslRng for libp2p v2.0.0 - 167ab1df fix(nix): regenerate deps.nix from updated nimble.lock - 97a27222 fix(tests): wrap or pass Rng correctly for 3-arg PrivateKey.random - 5561fcb5 fix(tests): replace removed newStandardSwitch with SwitchBuilder - ba39ee4a fix(tests): libp2p v2.0.0 API migrations across test suite - 328e11df fix: gitignore test binaries + remove accidentally-committed binary - cc712444 fix(tests): more v2.0.0 API migrations (rng template, PeerId.random, etc.) - 412d97a9 fix(tests): unblock CI — nph, excise orphan waku_noise, complete v2.0.0 Rng migration Conflict resolutions (#3935 → ours): - 11 import-path migrations: waku/X → logos_delivery/waku/X - waku_node/waku_node/relay.nim: dropped our `registerRelayHandler` proc (relocated to subscription_manager.nim by #3935; see cascade fix below) - factory/builder.nim: combined both sides' new imports (net_config + waku_switch) - factory/conf_builder/mix_conf_builder.nim: libp2p_mix package (not libp2p/protocols/mix) - waku_mix/protocol.nim: combined paths + our mix_rln_spam_protection/relay/nimchronos imports - 3 test files: dropped noise_utils import (replicates noise excision from original PR) - 2 UA file moves: option_shims.nim and waku_mix_coordination.nim added at new paths Cascade fixes (#3935 lost our work, restored): - subscription_manager.nim: added `mixHandler` to #3935's `registerRelayHandler`, and added `waku_mix` to its imports. Without this, mix messages were silently dropped from the relay handler chain. - config.nims: option_shims auto-import path migrated to logos_delivery/... Validation: - nph check on all 82 staged .nim files: clean (0 reformats needed) - wakunode2 build: exit 0, 38 MB binary - (sim PASS confirmed in earlier identical-state run: 5/5 mix init, 5 RLN proofs gen/verify, 0 errors) Backup tag at original tip: backup/3931-pre-3935-rebase (412d97a9).
Mixnet simulation
Aim
Simulate a local mixnet along with a chat app to publish using mix. This is helpful to test any changes during development.
Simulation Details
The simulation includes:
- A 5-node mixnet where
run_mix_node.shis the bootstrap node for the other 4 nodes - Two chat app instances that publish messages using lightpush protocol over the mixnet
Available Scripts
| Script | Description |
|---|---|
run_mix_node.sh |
Bootstrap mix node (must be started first) |
run_mix_node1.sh |
Mix node 1 |
run_mix_node2.sh |
Mix node 2 |
run_mix_node3.sh |
Mix node 3 |
run_mix_node4.sh |
Mix node 4 |
run_chat_mix.sh |
Chat app instance 1 |
run_chat_mix1.sh |
Chat app instance 2 |
build_setup.sh |
Build and generate RLN credentials |
Prerequisites
Before running the simulation, build wakunode2 and chat2mix:
cd <repo-root-dir>
source env.sh
make wakunode2 chat2mix
RLN Spam Protection Setup
Generate RLN credentials and the shared Merkle tree for all nodes:
cd simulations/mixnet
./build_setup.sh
This script will:
- Build and run the
setup_credentialstool - Generate RLN credentials for all nodes (5 mix nodes + 2 chat clients)
- Create
rln_tree.db- the shared Merkle tree with all members - Create keystore files (
rln_keystore_{peerId}.json) for each node
Important: All scripts must be run from this directory (simulations/mixnet/) so they can access their credentials and tree file.
To regenerate credentials (e.g., after adding new nodes), run ./build_setup.sh again - it will clean up old files first.
Usage
Step 1: Start the Mix Nodes
Start the bootstrap node first (in a separate terminal):
./run_mix_node.sh
Look for the following log lines to ensure the node started successfully:
INF mounting mix protocol topics="waku node"
INF Node setup complete topics="wakunode main"
Verify RLN spam protection initialized correctly by checking for these logs:
INF Initializing MixRlnSpamProtection
INF MixRlnSpamProtection initialized, waiting for sync
DBG Tree loaded from file
INF MixRlnSpamProtection started
Then start the remaining mix nodes in separate terminals:
./run_mix_node1.sh
./run_mix_node2.sh
./run_mix_node3.sh
./run_mix_node4.sh
Step 2: Start the Chat Applications
Once all 5 mix nodes are running, start the first chat app:
./run_chat_mix.sh
Enter a nickname when prompted:
pubsub topic is: /waku/2/rs/2/0
Choose a nickname >>
Once you see the following log, the app is ready to publish messages over the mixnet:
Welcome, test!
Listening on
/ip4/<local-network-ip>/tcp/60000/p2p/16Uiu2HAkxDGqix1ifY3wF1ZzojQWRAQEdKP75wn1LJMfoHhfHz57
ready to publish messages now
Start the second chat app in another terminal:
./run_chat_mix1.sh
Step 3: Test Messaging
Once both chat apps are running, send a message from one and verify it is received by the other.
To exit the chat apps, enter /exit:
>> /exit
quitting...