Purpose and Scope
This document describes thedevp2p command-line tool, a developer utility for interacting with and testing the StableNet peer-to-peer networking layer.devp2p provides commands for DNS-based node discovery management, node discovery protocol testing (Discovery v4 and v5), node key management, network crawling, and protocol conformance testing.
For instructions on building the tool itself, see Build and CI/CD.
For broader information on testing frameworks and debugging, see Testing Framework.
Command Structure Overview
Thedevp2p CLI consists of multiple top-level commands, each providing a related set of operations for network development and testing.
Command Hierarchy
dns
DNS-based node discovery (EIP-1459) tree managementdiscv4
Discovery v4 (UDP-based) protocol testing and diagnosticsdiscv5
Discovery v5 (encrypted, topic-based) protocol testing and diagnosticskey
Node key generation and conversion, enode URL generationcrawl
Network crawling and node set maintenancetest
Execution of Discovery protocol conformance test suites
DNS Discovery Management
Thedns command group provides tools for managing DNS-based node discovery trees as defined in EIP-1459.DNS discovery is used in environments where node lists are distributed and updated via DNS TXT records.
DNS Command Architecture
A DNS discovery tree consists of the following elements:- Root TXT record (
enrtree-root) - Signed tree nodes
- Child TXT records pointing to ENR records
- Sequence numbers and signatures
devp2p dns commands manage this entire structure using a local directory-based representation.
DNS Sync Command
dns sync downloads a DNS discovery tree from a remote URL and stores it in a local directory.
| Flag | Description | Default |
|---|---|---|
--timeout | DNS query timeout | None |
- Fetch the DNS tree root from the URL
- Traverse the entire tree by following TXT records
- Verify signatures for each node
- Store the complete tree as local files
DNS Sign Command
dns sign signs an existing DNS discovery tree with a private key, updating the sequence number and root signature.
| Flag | Description | Required |
|---|---|---|
--domain | Tree domain name | Yes |
--seq | Sequence number | No (auto-incremented) |
- Load the local tree
- Load the private key
- Update the sequence number
- Sign the root node
- Save the updated tree
DNS TXT Export
Theto-txt subcommand exports a signed DNS discovery tree into a text file containing standard DNS TXT record entries.This file can be used for manual deployment or inspection.
Automated deployment to external DNS providers such as Cloudflare or Route53 is not supported by StableNet and is therefore out of scope for this document.
Node Discovery v4 Tools
Thediscv4 command group provides tools for testing and diagnosing the Discovery v4 protocol (UDP-based node discovery).
Discovery v4 Ping
Sends a PING packet to a remote node and waits for a PONG response to verify connectivity. Key Flags (discoveryNodeFlags):--bootnodes: Bootstrap node list--nodekeyhex: Hex-encoded node private key--nodekey: Path to node key file--listen: Local UDP listen address--extip: External IP to record in the ENR
- Create a UDP listener
- Initialize a
discover.UDPv4instance - Send a PING to the target node
- Wait for a PONG response
- Calculate and print round-trip time (RTT)
Discovery v4 ENR Request
Requests a node’s ENR (Ethereum Node Record) using the EIP-868ENRRequest message.
Execution Flow:
- Verify connectivity via PING
- Send an ENRRequest
- Receive an ENRResponse
- Validate and display the ENR
Discovery v4 Resolve
Performs a Kademlia-style lookup to locate a specific node in the DHT. Execution Flow:- Connect to bootstrap nodes
- Repeatedly send FINDNODE requests
- Return the ENR when the target node is found
Discovery v4 Crawl
Crawls the DHT to discover reachable nodes and updates thenodes.json file.
| Flag | Description | Default |
|---|---|---|
--timeout | Crawl time limit | 30 minutes |
--parallel | Number of parallel queries | 16 |
- Load existing
nodes.jsonas the seed set - Repeatedly query random nodes
- Validate nodes via PING
- Retain only responsive nodes in the result set
- Perform periodic revalidation
- Nodes are re-pinged after
revalidateInterval - Unresponsive nodes are removed from the result set
Discovery v4 Test Suite
Runs Discovery v4 protocol conformance tests against a target node. Test Categories:- Ping tests
- FindNode tests
- Amplification tests
- Spoofing tests
Node Discovery v5 Tools
Thediscv5 command group provides tools for testing and diagnosing the Discovery v5 protocol.
Discovery v5 Operations
Ping
Verifies node connectivity through Discovery v5 PING/PONG exchanges.Resolve
Searches for nodes using Discovery v5 DHT lookups.Crawl
Crawls the network using the Discovery v5 protocol.Node Key Management
Thekey command group provides utilities for node key generation and conversion.
Key Generation
Generates a new ECDSA private key used for node identity.Enode URL Generation
Generates an enode URL from a private key.File Formats
Node Key File Format
Integration with the P2P Stack
Thedevp2p CLI tool uses the same networking components as the full node.
p2p/discoverp2p/enodep2p/dnsdisccrypto

