Skip to content

fix(cmd/devp2p): skip XDC relay frames instead of panicking, close #3063 - #3066

Open
gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-ethtest-getproto-panic
Open

gzliudan wants to merge 1 commit into
XinFinOrg:dev-upgradefrom
gzliudan:fix-ethtest-getproto-panic

Conversation

@gzliudan

Copy link
Copy Markdown
Collaborator

Summary

 getProto(frameCode)
   code < 16                  -> baseProto
   code < 34                  -> ethProto
   code < 44                  -> snapProto
-  otherwise                  -> panic("unhandled msg code beyond last protocol")
+  otherwise                  -> unknownProto

 ReadEth:      getProto(code) != ethProto  -> continue   (unchanged)
 statusExchange default:
-  getProto(code) == baseProto             -> continue
+  baseProto || unknownProto              -> continue

XDC nodes relay BFT votes/timeouts/sync infos (0xe0-0xe2) and pooled transactions (0xe3-0xe5) to every peer. Those message codes frame at 240-245, past the 16+18+10=44 bound in cmd/devp2p/internal/ethtest/protocol.go, so getProto panicked. utesting recovers panics per case, so a protocol-level fault was reported as a confusing case failure carrying a panic string instead of the real diagnosis.

getProto now returns unknownProto and both readers skip those frames. Protocol lengths stay untouched: they bound the codes the suites read, not the full XDC message space, and raising them would shift protoOffset(snapProto) and break the snap window. isXdc166MsgCode, ReadXdc166, and both decoders are unchanged.

Evidence

  • Before: live-node fixture devnet, main (mining) phase, not ok 35 BlockHashAnnounce / panic: unhandled msg code beyond last protocol / protocol.go:88. With validators stopped (no BFT relay frames) the same case no longer panicked and failed on its own timing assertion. See issue cmd/devp2p: getProto panics on XDC BFT and pooled-transaction frame codes #3063.
  • After: TestGetProtoXdcFrameCodes and TestGetProtoWindowBoundaries cover the whole 0xe0-0xe5 frame range plus window boundaries; TestReadEthSkipsXdcRelayFrames and TestStatusExchangeSkipsXdcRelayFrames feed all six codes through both readers on an in-process RLPx connection and assert the following real eth message / status packet is still received.
  • Mutation probes (4/4 killed): reverting to panic, misclassifying the range as ethProto or snapProto, and dropping the statusExchange skip each fail the new tests.
  • go test ./cmd/devp2p/internal/ethtest/ -count=1 PASS; full branch-workflow chain (make all, make generate, make tidy, clean tree, make lint 0 issues, go vet ./..., make test) PASS (1/1 commit, rc=0, 11:16:21-11:22:09), log /tmp/verify-logs/fix-ethtest-getproto-panic-33f7af6a18-7d9uzr.log.
  • Upstream /home/me/geth master keeps the same panic with ethProtoLen = 22 and has no XDC high message codes; git grep and git log -S find no unknownProto fix upstream, so this is a suite-only local adaptation with no upstream PR to port.

Merge Danger

Door: two-way

Blast Radius: test-suite only

Only the standalone devp2p ethtest client changes. No node, wire protocol, ProtocolLengths, or consensus code is touched; a revert restores the previous behaviour without migration. The one intentional behaviour change is that frames outside the three windows are skipped instead of aborting the reader, which is scoped to this test client.

Close #3063


Proposed changes

cmd/devp2p ethtest suite: stop getProto from panicking on XDC BFT and pooled-transaction frame codes, and add reader-level regression coverage. See Summary / Evidence above.

Types of changes

What types of changes does your code introduce to XDC network?
Put an ✅ in the boxes that apply

  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Changes that don't change source code or tests
  • docs: Documentation only changes
  • feat: A new feature
  • fix: A bug fix
  • perf: A code change that improves performance
  • refactor: A code change that neither fixes a bug nor adds a feature
  • revert: Revert something
  • style: Changes that do not affect the meaning of the code
  • test: Adding missing tests or correcting existing tests

Impacted Components

Which parts of the codebase does this PR touch?
Put an ✅ in the boxes that apply

  • Consensus
  • Account
  • Network
  • Geth
  • Smart Contract
  • External components
  • Not sure (Please specify below)

The devp2p ethtest client is a standalone conformance/test tool under cmd/devp2p, not part of the node binary.

Checklist

Put an ✅ in the boxes once you have confirmed below actions (or provide reasons on not doing so) that

  • This PR has sufficient test coverage (unit/integration test) OR I have provided reason in the PR description for not having test coverage
  • Tested on a private network from the genesis block and monitored the chain operating correctly for multiple epochs.
  • Provide an end-to-end test plan in the PR description on how to manually test it on the devnet/testnet.
  • Tested the backwards compatibility.
  • Tested with XDC nodes running this version co-exist with those running the previous version.
  • Relevant documentation has been updated as part of this PR
  • N/A

Reasons for unchecked items:

  • Private-network multi-epoch run / mixed-version node coexistence: not applicable, the change is confined to the standalone devp2p test client and does not alter node behaviour or the wire protocol. The four-node fixture devnet regression that exposed the panic (issue cmd/devp2p: getProto panics on XDC BFT and pooled-transaction frame codes #3063) is referenced in Evidence.
  • End-to-end plan: build the suite client with make all, then run devp2p rlpx eth-test against a V2 validator devnet with BFT relay traffic active; previously BlockHashAnnounce reported a panic text, now the relay frames are skipped and the case reports its own assertion. Equivalently, run go test ./cmd/devp2p/internal/ethtest/ -run 'TestGetProto|TestReadEthSkips|TestStatusExchangeSkips' -count=1 for the deterministic in-process reproduction.
  • Backwards compatibility: verified by the full existing cmd/devp2p/internal/ethtest/ test suite and the unchanged TestXdc166MsgCodeFilter / decodeEthPayload cases; no production API or wire format changed.
  • Documentation: the stale defect-history comment in protocol.go was replaced with the durable invariant; no user-facing docs describe this internal test helper.

…nFinOrg#3063

V2 nodes relay BFT votes/timeouts/sync infos and pooled transactions to
every peer. Those message codes (0xe0-0xe5) frame at 240-245, past the
suite's protocol windows, so getProto panicked and utesting recovered it
per case. A protocol-level fault therefore surfaced as a confusing case
failure carrying a panic string, masking the real diagnosis.

Return unknownProto for codes outside the windows instead. ReadEth already
skips anything classified outside ethProto, and statusExchange now skips
unknown frames alongside base frames, so both readers continue to the
message they are waiting for. Protocol lengths stay untouched: they bound
the codes the suites read, not the full XDC message space, and changing
them would shift protoOffset(snapProto) and break the snap window.

Add frame-code coverage for the whole 0xe0-0xe5 range through both readers
and at the getProto boundaries; the existing Xdc166 filter and decoders
are unchanged.

Close XinFinOrg#3063
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 49 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 4001230 and 33f7af6.

Files selected for processing: 4

  • cmd/devp2p/internal/ethtest/conn.go
  • cmd/devp2p/internal/ethtest/conn_xdc_frames_test.go
  • cmd/devp2p/internal/ethtest/protocol.go
  • cmd/devp2p/internal/ethtest/protocol_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@gzliudan

Copy link
Copy Markdown
Collaborator Author

No code changes were needed here: the automated review reported Review limit reached (the free OSS review allowance was exhausted), so no review findings or open review threads were produced for this PR. The changes remain scoped to skipping XDC relay frames instead of panicking, with the full per-commit validation chain passing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant