feat(eth): implement EIP-2364 - xdc/164 handshake with fork ID #20140#2470
feat(eth): implement EIP-2364 - xdc/164 handshake with fork ID #20140#2470gzliudan wants to merge 1 commit into
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 ports go-ethereum’s EIP-2364 handshake extension to add ForkID negotiation for eth/64 and xdc/164, enabling early rejection of incompatible peers during the status handshake while preserving legacy compatibility for eth/63 and xdc/100.
Changes:
- Add protocol versions
eth64andxdc164, updating the supported-version negotiation order. - Introduce a ForkID-carrying status packet for
eth/64+(andxdc/164) alongside a legacy status packet foreth/63andxdc/100, plus corresponding handshake read helpers. - Add/adjust tests for status-handshake error cases and ForkID-based chain splitting behavior; expand existing handler tests to cover
eth/64.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| eth/protocol.go | Adds new protocol versions and defines legacy vs ForkID status packet types and new error codes. |
| eth/peer.go | Extends handshake to send/validate ForkID for eth/64 & xdc/164 while keeping legacy status for older versions. |
| eth/handler.go | Stores a long-lived forkid.Filter on ProtocolManager and wires ForkID + filter into peer handshakes. |
| eth/protocol_test.go | Adds/updates status handshake error tests for 63/64/100 and introduces ForkID split tests. |
| eth/helper_test.go | Updates test handshake helpers to emit the correct status packet per protocol version. |
| eth/handler_test.go | Adds eth/64 variants of existing protocol handler tests. |
| core/forkid/forkid.go | Introduces a forkid.Filter type alias and tweaks filter head/fork boundary logic. |
Comments suppressed due to low confidence (1)
eth/helper_test.go:268
- testPeer.handshake is called with t == nil from newTestPeer (when shake==true), but the function unconditionally calls t.Fatalf, which will panic with a nil pointer dereference and break any tests that use implicit handshakes. Handle the nil case explicitly (or refactor handshake to return an error).
if err := p2p.ExpectMsg(p.app, StatusMsg, msg); err != nil {
t.Fatalf("status recv: %v", err)
}
if err := p2p.Send(p.app, StatusMsg, msg); err != nil {
t.Fatalf("status send: %v", err)
5c467df to
963c40a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
eth/helper_test.go:266
- testPeer.handshake is called with a nil *testing.T (see newTestPeer), but this method calls t.Fatalf on send/receive errors. If the handshake ever fails, this will panic with a nil pointer dereference and hide the real failure cause. Handle the nil case explicitly (panic with a helpful message) so failures remain diagnosable.
panic(fmt.Sprintf("unsupported eth protocol version: %d", p.version))
}
if err := p2p.ExpectMsg(p.app, StatusMsg, msg); err != nil {
t.Fatalf("status recv: %v", err)
}
| chainNoFork, _ = core.NewBlockChain(dbNoFork, nil, gspecNoFork, engine, vm.Config{}) | ||
| chainProFork, _ = core.NewBlockChain(dbProFork, nil, gspecProFork, engine, vm.Config{}) |
| chainNoFork.InsertChain(blocksNoFork[:1]) | ||
| chainProFork.InsertChain(blocksProFork[:1]) |
| chainNoFork.InsertChain(blocksNoFork[1:2]) | ||
| chainProFork.InsertChain(blocksProFork[1:2]) |
7325260 to
49b0324
Compare
…um#20140 Adapt go-ethereum PR ethereum#20140 (EIP-2364) to extend the Status handshake for xdc/164 with ForkID-based compatibility checks. - Keep runtime protocol negotiation as [xdc164, xdc100, eth63]. - Use statusData (with ForkID) for xdc164 and statusData63 (legacy, no ForkID) for xdc100/eth63. - Split status decoding into readStatus/readStatusLegacy and validate ForkID through the ProtocolManager fork filter. - Align status error naming with upstream and include ErrForkIDRejected. Tests: - Move the newly added 64-path coverage to 164-path coverage to match runtime protocol support. - Add status error coverage for protocol 63/100/164. - Validate fork split behavior with protocol 164. - Add 164 variants for header/body/node-data/receipt and tx send/receive tests. Compatibility note: xdc100 keeps the legacy statusData63 layout for peers that still run older xdpos2/100 implementations without ForkID. Refs: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2364.md
Proposed changes
Adapt go-ethereum PR ethereum#20140 (EIP-2364) to extend the Status handshake
for xdc/164 with ForkID-based compatibility checks.
for xdc100/eth63.
through the ProtocolManager fork filter.
Tests:
protocol support.
Compatibility note: xdc100 keeps the legacy statusData63 layout for peers that
still run older xdpos2/100 implementations without ForkID.
Refs:
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