Repository navigation
Conversation
Sansh2356
requested review from
mcelrath,
priyashuu and
zaidmstrr
as code owners
September 1, 2026 10:26
Sansh2356
marked this pull request as draft
September 1, 2026 10:28
There was a problem hiding this comment.
Pull request overview
This PR addresses cross-network contamination by scoping Braidpool’s libp2p protocol identifiers and on-disk state to the selected --network, preventing peers from different networks from negotiating substreams and sharing persistence under the same paths.
Changes:
- Scope libp2p protocol IDs (kademlia + bead-sync) and floodsub topic by
PoolNetwork, and only admit peers into the mesh/peer manager after Identify confirms expected protocols. - Make persistence network-specific by creating/using
<datadir>/<network>/as the root for the DB and keystore, and thread the network-scoped path through DB initialization. - Add a multiaddr routability filter for DHT insertion and expand tests/docs to cover the new isolation model.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| node/src/utils/mod.rs | Adds is_routable_multiaddr plus unit tests for filtering unroutable listen addrs before DHT insertion. |
| node/src/stratum.rs | Updates a test to use DBHandler::new_in_memory to avoid persistent DB usage. |
| node/src/peer_manager/mod.rs | Introduces PendingPeer and pending tracking to defer peer registration until protocol negotiation succeeds. |
| node/src/main.rs | Implements network-scoped datadir setup, network-scoped topics/protocol checks on Identify, and pending→promoted peer flow. |
| node/src/db/init_db.rs | Changes DB init to accept a network-scoped directory and warns if a legacy unscoped DB exists. |
| node/src/db/db_handlers.rs | Threads network-scoped datadir into persistent DB handler initialization. |
| node/src/db/audit_db_handlers.rs | Threads network-scoped datadir into audit DB handler initialization. |
| node/src/behaviour/tests.rs | Adds tests asserting protocol/topic names differ across networks and updates swarm construction. |
| node/src/behaviour/mod.rs | Replaces global protocol constants with network-scoped protocol/topic generators and updates behaviour construction. |
| node/src/audit.rs | Updates audit DAG initialization to accept the network-scoped datadir. |
| docs/braidpool_setup.md | Documents the per-network datadir layout and network-scoped on-wire protocol/topic naming. |
| Cargo.lock | Updates locked dependencies as a result of the build/dependency graph changes in the workspace. |
Suppressed comments (1)
node/src/main.rs:133
- If the per-network data path (
<datadir>/<network>) already exists but is not a directory, the code logs and continues. That can lead to confusing failures when creating the DB/keystore inside it; returning an error here makes the failure immediate and actionable.
match fs::metadata(&network_datadir) {
Ok(m) => {
if !m.is_dir() {
error!(path = %network_datadir.display(), "Network data path exists but is not a directory");
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sansh2356
marked this pull request as ready for review
September 5, 2026 08:13
…uring negotiation Earlier there was no bifurcation on the basis of network current node is interacting with during protocol exchange and handshake which could allow nodes on different `PoolNetwork` to establish connection. This scopes each protocol versioning according to network and add a fail case in which incoming connection maybe from different node .
Sansh2356
force-pushed
the
multi-network-persistance
branch
from
September 7, 2026 19:49
9c46fc0 to
83d1bcc
Compare
This adds to the network bifurcated functioning of braidpool involving protocol negotiation between peers during Identify Event and updating the filtering during DHT addition in local peer. Each protocol id is based on network on which that braidpool node is operating and it avoids the addition of peer in DHT as well as connection if protocols are not matching preventing peers on different networks from operating on same mesh leading to invalid hashes. This also updates the DHT checks for filtering out unroutable peer addresses received during the Identify even received from the peer and changing the addition of DHT insertion from ConnectionEstablished event to Identify event. Changing the directory structure for network wise bead persistance as well as peer Ids stored in key-store.
Sansh2356
force-pushed
the
multi-network-persistance
branch
from
September 7, 2026 19:57
83d1bcc to
6e28829
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
substreamsagainst each other. That silently produced bead/hash divergence leading to breakdown of entire network mesh.ConnectionEstablishmentand adding peers only when negotiation passes as well as persistence in network specific sub-directories having--datadiras parent directory.Networktype #462 and--datadirhas no effect insideinit_db()#533 .