What Networking Stack Does the 3DPass Node Use? libp2p and Substrate Integration Explained

The 3DPass node uses libp2p as its core networking stack, wrapped by Substrate's sc-network crate to enable decentralized peer discovery, block propagation, and the Proof-of-Scan consensus mechanism.

The 3DPass blockchain relies on a robust peer-to-peer (P2P) infrastructure to maintain its decentralized Proof-of-Scan consensus. At the heart of this infrastructure lies a specific networking stack that handles all node communication. According to the 3dpass/3dp source code, the node implements libp2p through Substrate's networking layers, creating a modular and extensible P2P mesh.

Core Networking Architecture

The 3DPass node leverages libp2p, the modular peer-to-peer networking library developed by Protocol Labs. This stack is not invoked directly; instead, the node utilizes Substrate's sc-network crate, which internally constructs and manages a libp2p swarm. This architecture enables nodes to discover peers via mDNS or Kademlia DHT, negotiate transport protocols (TCP, WebSockets), and maintain persistent connections required for the consensus algorithm.

Implementation in the Source Code

The integration of libp2p appears throughout the node's codebase, from the service initialization to the RPC layer.

Network Initialization in service.rs

The primary instantiation occurs in nodes/poscan-consensus/src/service.rs at line 386. Here, the sc_service::build_network function constructs the libp2p-backed network service:

// nodes/poscan-consensus/src/service.rs
let network = sc_service::build_network(sc_service::BuildNetworkParams {
    // … omitted configuration …
    // Substrate's `sc_network` creates a libp2p swarm internally.
})?;

This call configures the transport layer, registers the node's protocols, and initializes the peer discovery mechanisms that allow the node to join the 3DPass network.

Dependency Declaration in Cargo.toml

The networking capabilities are declared as dependencies in nodes/poscan-consensus/Cargo.toml (lines 51-56). The sc-network crate serves as the Substrate abstraction over libp2p, providing the high-level API while internally managing the libp2p swarm behavior and transport encryption.

RPC Access to the Network Service

RPC handlers interact with the underlying libp2p layer through the NetworkService type. In nodes/poscan-consensus/src/rpc.rs (lines 60-109), the code exposes this service to allow querying peer counts and network state:

// nodes/poscan-consensus/src/rpc.rs
use sc_network::NetworkService;
use std::sync::Arc;

pub struct RpcHandlers {
    /// Network service (libp2p based)
    pub network: Arc<NetworkService<Block, Hash>>,
}

The NetworkService acts as the bridge between the node's business logic and the libp2p transport layer.

Running the Node with libp2p

When you launch the 3DPass node binary, the libp2p networking stack initializes automatically, handling peer discovery and connection management. You can start a validator node with configurable networking parameters:


# Build and launch the node – the networking stack (libp2p) starts automatically

cargo build --release
./target/release/poscan-consensus --base-path ~/3dp-chain/ \
    --chain mainnetSpecRaw.json \
    --name MyNode \
    --validator \
    --telemetry-url "wss://submit.3dpass.network/submit 0" \
    --author <mining-key> \
    --threads 2 \
    --no-mdns   # optional: disable mDNS discovery

The --no-mdns flag specifically controls libp2p's multicast DNS discovery feature, demonstrating direct control over the networking stack's behavior.

Summary

  • The 3DPass node uses libp2p as its core networking stack, as explicitly documented in the README.md at line 34 and implemented throughout the source code.
  • Substrate's sc-network crate wraps libp2p, handling swarm creation and protocol management in nodes/poscan-consensus/src/service.rs.
  • The NetworkService type in nodes/poscan-consensus/src/rpc.rs provides the primary interface for components to interact with the P2P layer.
  • Runtime configuration allows operators to tune libp2p behaviors such as mDNS discovery via command-line flags.

Frequently Asked Questions

Does the 3DPass node use TCP or UDP for peer connections?

The node uses libp2p's transport abstraction, which primarily leverages TCP for reliable connections, often with Noise or TLS encryption protocols. The specific transport implementation is handled internally by the sc-network crate, allowing the node to negotiate the best available protocol with each peer while maintaining the blockchain's networking requirements.

Can I disable peer discovery in the 3DPass node?

Yes, you can disable specific discovery mechanisms. The command-line flag --no-mdns disables the mDNS (multicast DNS) discovery protocol, preventing the node from broadcasting its presence on the local network. However, the node will still attempt to discover peers through other configured methods such as bootnodes or the Kademlia DHT maintained by the libp2p stack.

What is the relationship between Substrate's sc-network and libp2p?

sc-network is a Substrate crate that wraps libp2p, providing a blockchain-specific API while internally managing the libp2p swarm. It translates high-level blockchain networking requests—such as block propagation or transaction gossiping—into the corresponding libp2p protocol operations, abstracting away the complexity of direct libp2p management for the 3DPass developers.

Where is the libp2p networking stack explicitly mentioned in the documentation?

The primary documentation stating that "CORE Networking – the libp2p is used as networking stack for the Nodes" appears in the project's README.md at line 34. This confirms the architectural choice to use libp2p for all peer-to-peer communications within the 3DPass network.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →