feat(p2p): new p2p node representation #17643 #17753 #18963 #19131 #19433 #19593 #19661 #19749 #19963#2346
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR migrates the P2P stack from the legacy discover.NodeID / discover.Node representation to ENR-backed enode.Node / enode.ID, aligning node identity, node records, and related utilities (dialing, simulations, bootnode tooling) around the newer node model.
Changes:
- Replace
discover.NodeIDusage withenode.IDacross simulations, p2p core, eth sync bookkeeping, admin APIs, and CLI parsing. - Introduce ENR/enode infrastructure (node URL parsing, node DB, local node record signer, IP endpoint tracker) and refactor discovery v4/v5 integration accordingly.
- Remove Docker-based simulations adapter (code + docs) and relocate WebSocket address parsing utilities into the exec adapter.
Reviewed changes
Copilot reviewed 64 out of 64 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| p2p/simulations/simulation.go | Switch simulation step tracking from discover.NodeID to enode.ID. |
| p2p/simulations/README.md | Reformat service registration snippet; remove DockerAdapter docs. |
| p2p/simulations/network.go | Migrate network node/conn/message identifiers to enode.ID; small log/comment tweaks. |
| p2p/simulations/network_test.go | Update tests to use enode.ID. |
| p2p/simulations/mocker.go | Update mocker ring creation to return []enode.ID. |
| p2p/simulations/mocker_test.go | Update mocker test node map key type to enode.ID. |
| p2p/simulations/http.go | Parse nodeid/peerid path params into enode.ID via UnmarshalText. |
| p2p/simulations/http_test.go | Update test service peer bookkeeping and fixtures to use enode.ID. |
| p2p/simulations/examples/ping-pong.go | Drop docker adapter path; switch IDs to enode.ID. |
| p2p/simulations/adapters/ws.go | Removed WS address scanning helper (moved/handled elsewhere). |
| p2p/simulations/adapters/ws_test.go | Removed tests for WS address scanning helper. |
| p2p/simulations/adapters/types.go | NodeConfig uses enode.ID; add NodeConfig.Node() helper; update ID generation. |
| p2p/simulations/adapters/inproc.go | SimAdapter/SimNode use enode.ID and *enode.Node for dialing/node descriptors. |
| p2p/simulations/adapters/exec.go | Switch exec adapter to enode.ID; move ws addr regex here; reorder init/reexec. |
| p2p/simulations/adapters/docker.go | Remove DockerAdapter implementation. |
| p2p/rlpx.go | Refactor RLPx handshake identity handling away from discover.NodeID toward pubkey-based identity. |
| p2p/rlpx_test.go | Update handshake tests for pubkey identity; adjust hashing/read helpers. |
| p2p/protocols/protocol_test.go | Update protocol test messages to use enode.ID. |
| p2p/protocol.go | Protocol PeerInfo uses enode.ID; add ENR Attributes; add ENR key for caps. |
| p2p/peer.go | Peer identity stored as *enode.Node; events use enode.ID; expose Peer.Node(). |
| p2p/peer_test.go | Update peer tests to construct conns with *enode.Node and new test transport signature. |
| p2p/netutil/iptrack.go | Add external endpoint prediction helper (IPTracker). |
| p2p/netutil/iptrack_test.go | Add unit tests for IPTracker behavior and GC. |
| p2p/nat/nat.go | Replace ExtIP(ip) constructor with ExtIP type implementing nat.Interface. |
| p2p/nat/nat_test.go | Update nat tests to use ExtIP{...}. |
| p2p/metrics.go | Update newMeteredConn comment text. |
| p2p/message.go | Migrate msg eventer peer ID to enode.ID; minor receiver renames and comment tweak. |
| p2p/enr/idscheme.go | Remove identity scheme registry from enr package (moved/reshaped). |
| p2p/enr/idscheme_test.go | Remove tests tied to removed enr identity scheme registry. |
| p2p/enr/entries.go | Remove Secp256k1 entry type from enr package (moved to enode). |
| p2p/enr/enr.go | Refactor ENR signature verification model (verification moved out of DecodeRLP); new scheme registry type. |
| p2p/enr/enr_test.go | Adapt tests to new signature handling and testing identity scheme. |
| p2p/enode/urlv4.go | Add enode v4 URL parsing/formatting and v4 node ID derivation helper. |
| p2p/enode/urlv4_test.go | Add tests for v4 enode URL parsing, encoding, and ID distance helpers. |
| p2p/enode/nodedb.go | Add LevelDB-backed enode DB (record + metadata persistence/expiration). |
| p2p/enode/node.go | Add enode.Node wrapper around ENR record; enode.ID type and distance helpers. |
| p2p/enode/node_test.go | Add Python interop verification test via enode.New(ValidSchemes, ...). |
| p2p/enode/localnode.go | Add LocalNode record manager (sign-on-demand, endpoint prediction integration). |
| p2p/enode/localnode_test.go | Add tests for LocalNode ENR persistence and seq handling. |
| p2p/enode/idscheme.go | Add v4 identity scheme and null scheme; provide ValidSchemes maps and signing helpers. |
| p2p/enode/idscheme_test.go | Add identity scheme tests (sign error immutability, secp256k1 entry roundtrip). |
| p2p/discv5/udp.go | Adjust ListenUDP signature and add small helpers (rpcEndpoint.equal, sendFindnode). |
| p2p/discover/table_util_test.go | Reintroduce discovery table test utilities using enode.Node/enode.ID. |
| p2p/discover/node.go | Replace legacy discover node model with wrapper around enode.Node; update pubkey encoding helpers. |
| p2p/discover/node_test.go | Remove legacy discover node URL/NodeID tests (now covered under enode). |
| p2p/discover/database.go | Remove legacy discover nodeDB implementation (replaced by enode.DB). |
| p2p/discover/database_test.go | Remove tests for legacy discover nodeDB. |
| p2p/dial.go | Migrate dialing to *enode.Node and enode.ID; update discovery table interface and lookup strategy. |
| node/api.go | Admin peer add/remove now parses with enode.ParseV4 and checks allow/deny lists by enode.ID. |
| eth/sync.go | Use enode.ID as txsync pending map key. |
| eth/sync_test.go | Update peer creation to use enode.ID. |
| eth/helper_test.go | Update test peer random ID type to enode.ID. |
| eth/handler.go | Protocol PeerInfo callback now takes enode.ID. |
| cmd/utils/flags.go | Parse allow/deny lists into enode.ID; parse bootnodes via enode.ParseV4; filter denylisted bootstrap nodes by enode.ID. |
| cmd/p2psim/main.go | Update simulation node ID generation to enode.PubkeyToIDV4. |
| cmd/bootnode/main.go | Update bootnode output/notice, discv5 listen signature usage, and discv4 setup with LocalNode/enode DB. |
5297073 to
3dff3ce
Compare
f8f806a to
9624c9a
Compare
75d09c3 to
4d5ae88
Compare
0bdf566 to
9225d1b
Compare
0446349 to
96515fd
Compare
7ef1a4c to
61ae8ff
Compare
cd95be9 to
a711eb3
Compare
c9b90ad to
e2e18f9
Compare
…thereum#18963 ethereum#19131 ethereum#19433 ethereum#19593 ethereum#19661 ethereum#19749 ethereum#19963 Introduce p2p/enode as the generalized node representation for peer and discovery code. The new package becomes the home for node records, local nodes, URL parsing, and the node database, while the v4 identity scheme moves out of p2p/enr to decouple ENR handling from Ethereum-specific crypto. Port discovery, peer management, node APIs, and simulations to enode.Node and enode.ID. The discovery wire protocol stays unchanged, but APIs move away from discover.Node and NodeID and now require explicit record validation. Simulation helpers now track complete nodes and the updated tests cover the new connect and network behavior. These changes align the fork with the upstream geth enode refactor and make later p2p and discovery updates easier to carry. Existing simulation snapshots are incompatible with the new node identifier representation.
e2e18f9 to
5e4f5fc
Compare
Proposed changes
Introduce p2p/enode as the generalized node representation for peer and discovery code. The new package becomes the home for node records, local nodes, URL parsing, and the node database, while the v4 identity scheme moves out of p2p/enr to decouple ENR handling from Ethereum-specific crypto.
Port discovery, peer management, node APIs, and simulations to enode.Node and enode.ID. The discovery wire protocol stays unchanged, but APIs move away from discover.Node and NodeID and now require explicit record validation. Simulation helpers now track complete nodes and the updated tests cover the new connect and network behavior.
These changes align the fork with the upstream geth enode refactor and make later p2p and discovery updates easier to carry. Existing simulation snapshots are incompatible with the new node identifier representation.
Ref:
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which parts of the codebase does this PR touch?
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that