Loading...
Loading...
Midnight P2P networking — Polkadot SDK libp2p, peer discovery (bootstrap, mDNS, Kademlia DHT), transport (TCP/WebSocket/DNS), Noise encryption, Yamux multiplexing, and substream protocols. Use when configuring nodes, debugging connectivity, or explaining how validators exchange blocks and gossip.
npx skill4agent add kali-decoder/midnight-skills midnight-p2p-networkingflowchart TB
subgraph Discovery["Peer discovery"]
BS["Bootstrap nodes"]
MDNS["mDNS (LAN)"]
KDHT["Kademlia DHT random walk"]
end
subgraph Transport["Connection"]
TCP["TCP/IP"]
WS["WebSockets"]
DNS["DNS resolution"]
end
subgraph Security["Upgrade"]
Noise["Noise Protocol — encryption"]
Yamux["Yamux — multiplexing"]
MS["Multistream-Select negotiation"]
end
subgraph Protocols["Substream protocols"]
Ping["Ping — liveness"]
RR["Request-Response — block/tx queries"]
Notif["Notifications — gossip, finality, sync"]
end
Discovery --> Transport
Transport --> Security
Security --> ProtocolsFIND_NODEflowchart LR
Start["Node starts"] --> Boot["Connect to bootstrap"]
Boot --> Learn["Learn peer addresses"]
Learn --> Walk["Kademlia random walk"]
Walk --> More["More peers discovered"]
More --> Walk
MDNS["mDNS on LAN"] -.-> Learn| Transport | Description |
|---|---|
| TCP/IP | Traditional IPv4/IPv6 sockets |
| WebSockets | TCP + WebSocket framing (browser/proxy friendly) |
| DNS | Domain names resolved to IPs during connection |
| Protocol | Purpose |
|---|---|
| Noise | End-to-end confidentiality and integrity |
| Yamux | Multiple logical streams over one physical connection |
| Multistream-Select | Choose compatible encryption and multiplexing options |
sequenceDiagram
participant A as Alice
participant B as Bob
A->>B: TCP / WebSocket connect
A->>B: Multistream-Select (Noise)
Note over A,B: Encrypted channel
A->>B: Multistream-Select (Yamux)
Note over A,B: Multiplexed substreams
A->>B: Open Ping / Request-Response / Notifications| Protocol | Purpose |
|---|---|
| Ping | Liveness checks and latency measurement |
| Request-Response | Structured exchange (block queries, transaction queries) |
| Notifications | Broadcast: new transactions, block announcements, finality updates, light-client state sync |
midnight-cryptography/midnight-consensus/midnight-cryptography/midnight-rpc/