feat(mix): DoS protection integration#3931
Conversation
|
You can find the image built from this PR at Built from fbb612b |
|
Thanks for that PR @chaitanyaprem |
Also it may be possible that some of the work in this PR should be ported to the other bump PR in any case (i.e. if what is done here to bump is preferred over what I did in my PR to bump) |
Makes sense, i was doing this more from a point of validating using single zerokit compiled lib for both rln relay and mix DoS protection. I got stuck and had to do this update, so i thought it would be useful for whoever is doing the bump hence checked it in. The idea is once you guys bump libp2p, i will just rebase onto that and only have mix related changes :) |
I would leave that upto you, i just took shortest and easiest path to make it work in order to test mix DoS protection simulation with zerokit-2.0.2 statless built and reused across rln relay and mix. You may have better idea if some of these changes make sense or not. Let me know once 2.0.0 bump branch is ready so that i can rebase onto it. |
1729a96 to
cc71244
Compare
412d97a to
111f0a3
Compare
|
This PR may contain changes to configuration options of one of the apps. If you are introducing a breaking change (i.e. the set of options in latest release would no longer be applicable) make sure the original option is preserved with a deprecation note for 2 following releases before it is actually removed. Please also make sure the label |
|
This PR may contain changes to database schema of one of the drivers. If you are introducing any changes to the schema, make sure the upgrade from the latest release to this change passes without any errors/issues. Please make sure the label |
111f0a3 to
d529be1
Compare
efe5e1e to
3f0f14c
Compare
…based onto #3935) 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): - d8e6dce feat(mix): integrate mix protocol with extended kademlia + RLN spam protection - fb72f18 refactor(mix): split DoS-protection self-registration into background retry - d8bbef0 feat(mix): bump libp2p stack to v2.0.0 + adopt stateless RLN spam protection - 2f24448 fix(tests): use HmacDrbgContext.new() instead of crypto.newRng() - 5a21455 fix(ci): regen nimble.lock for v2.0.0 + disambiguate rng in wakucore - 03ef02a fix(tests): wrap HmacDrbgContext via newBearSslRng for libp2p v2.0.0 - 167ab1d fix(nix): regenerate deps.nix from updated nimble.lock - 97a2722 fix(tests): wrap or pass Rng correctly for 3-arg PrivateKey.random - 5561fcb fix(tests): replace removed newStandardSwitch with SwitchBuilder - ba39ee4 fix(tests): libp2p v2.0.0 API migrations across test suite - 328e11d fix: gitignore test binaries + remove accidentally-committed binary - cc71244 fix(tests): more v2.0.0 API migrations (rng template, PeerId.random, etc.) - 412d97a 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 (412d97a).
Rename the call site to the typedesc constructor MixRlnSpamProtection.new (was newMixRlnSpamProtection) to match nim-libp2p conventions, and bump the mix-rln-spam-protection-plugin pin to 61ee3e5 which provides the renamed constructor.
Add a generic runServicePeerTopUp loop in waku_node that, while a service's provider count is below target, pulls more peers through the ServicePeersRequest broker; wired for mix in WakuNode.start(). Move the ServicePeersRequest provider registration into the startProvidersAndListeners/stopProvidersAndListeners lifecycle (gated on kademlia) so chat2mix gets it too, keeping WakuKademlia generic. Also fix pre-existing chat2mix build errors (toHashSet, valueOr, std/sets import).
3f0f14c to
eea07b1
Compare
Ivansete-status
left a comment
There was a problem hiding this comment.
Some comments so far. Thanks!
- protocol.nim: use isOkOr in handleMessage/start, drop identity mapErr, drop redundant gcsafe on handleMessage - waku_node.nim: handle relay publish error; simplify runServicePeerTopUp (drop count-getter param, use getMixNodePoolSize directly) - factory/waku.nim: drop redundant explicit service setup calls (the loop over switch.services already sets them up) - peer_manager.nim: drop duplicate waku_switch import - chat2mix.nim: remove redundant echo, simplify async signature, capture spam-protection maintenance future and cancel it on /exit - delete unused waku_mix_coordination.nim (dead duplicate of chat2mix logic)
Adds DoS / spam protection to the mix protocol (RLN-based).
What's in this PR
Mix DoS / spam protection (RLN)
mix-rln-spam-protection-plugininto the mix protocol — mix messages carry an RLN proof, intermediate hops verify it, per-sender rate-limited viauserMessageLimit. (waku_mix/protocol.nim,waku_node.nim)ffi_verify_with_roots; no local Merkle tree).waku_mix_coordination.nim, new).Adaptive mix-peer discovery — generic
runServicePeerTopUploop pulls more mix-service peers via theServicePeersRequestbroker while the pool is below target; keepsWakuKademliageneric.Minor — chat2mix demo + mixnet sim harness (
simulations/mixnet/); dep pins (mix-rln-spam-protection-plugin,libp2p_mix,nim-sds); small build/test fixes.Validation
wakunode2+chat2mixbuild clean;tests/waku_kademlia14/14.