discv4/discv5 wire fixes + hardening: ENRRESPONSE, NEIGHBORS/NODES, ENR size, bond & flood - #44
Draft
pk910 wants to merge 6 commits into
Draft
discv4/discv5 wire fixes + hardening: ENRRESPONSE, NEIGHBORS/NODES, ENR size, bond & flood#44pk910 wants to merge 6 commits into
pk910 wants to merge 6 commits into
Conversation
pk910
force-pushed
the
followup/discv-gaps
branch
2 times, most recently
from
July 29, 2026 13:58
578eb93 to
187ad8b
Compare
The ENRResponse packet embedded an enr.Record whose EncodeRLP has signature ([]byte, error) and so does not satisfy rlp.Encoder; with no exported fields the record was serialized as an empty list (c0). go-ethereum rejects the reply with 'record contains less than two list elements', so discv4 ENR requests against the bootnode time out and clients cannot resolve its EIP-2124 eth fork id. Implement rlp.Encoder on ENRResponse to serialize the record via its own RLP encoding. Add a regression test that decodes the packet with go-ethereum's v4wire type, plus discv5 official wire test vectors.
go-ethereum honours only the first NODES packet's total and reads at most 5 packets; sigp/discv5 caps at 16 nodes. Cap the served set at 15 nodes / <=5 packets so no served node is silently dropped by a requester.
Matches go-ethereum and sigp/discv5. Without it an oversized but validly-signed ENR received in NODES/handshake could be stored and re-served, and a single oversized record makes real clients discard the whole NODES message.
An empty routing table previously produced a silent (zero-packet) response, so go-ethereum's querier waited out its full request timeout instead of returning early on the first reply. Always send >=1 NEIGHBORS packet. Also advertise the node's real TCP port from its ENR instead of copying the UDP port.
Bonding on a received PING alone let a spoofed-source PING coax a large NEIGHBORS reply to a victim (amplification), and granted FINDNODE/ENRRequest access without endpoint proof. Establish the bond only when the peer answers our ping-back with a PONG, matching go-ethereum. The ping-back is unchanged, so real peers still bond.
… is full The node-map cap previously returned a non-retained node once full, so under a flood of distinct signed IDs a genuinely new peer's inbound PING marked bond state on a discarded object and could never bond (memory-growth DoS turned into a bonding-lockout DoS). When full, evict one unbonded entry to admit the new node; bonded, endpoint-proven peers are never evicted this way.
pk910
force-pushed
the
followup/discv-gaps
branch
from
July 29, 2026 14:11
187ad8b to
1431576
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Follow-up to #43. Fixes a set of discv4/discv5 wire-compatibility and hardening gaps found by an audit against go-ethereum (devp2p) and sigp/discv5, and validated with a full multi-client glamsterdam-devnet-7 e2e (bootnodoor as the sole bootnode).
Each fix is its own commit so they can be cherry-picked independently. All CI checks pass (
go mod verify,go vet,gofmt,staticcheck,go test -race,make build).Commits (one fix each)
enr.Record.EncodeRLP()has signature([]byte, error), which does not satisfy go-ethereum'srlp.Encoder; with no exported fields the embedded record serialized as an empty list (c0), so go-ethereum rejected the reply ("record contains less than two list elements") and discv4 ENR requests against the bootnode timed out. Implementrlp.EncoderonENRResponse. Verified end-to-end against geth:discv4 RequestENR ok(wasRPC timeout).totaland reads at most 5 NODES packets; beyond that nodes were silently dropped.discv4 RequestENR ok).E2E validation (glamsterdam-devnet-7)
All EL (geth, reth, nethermind, besu, erigon) + CL (lighthouse, prysm, teku, lodestar, nimbus, grandine) clients, bootnodoor as the only bootnode, discv5 enabled where supported.
v4=false v5=true) and bootstrapped cleanly — the gloas full-discv5 scenario.Out of scope
besu discv5 needs an ENR bootnode ("ENR bootnodes must start with 'enr:'"). Not a bootnodoor bug — orchestrators must hand besu bootnodoor's
/enr(not its enode). Tracked as a separate ethereum-package change.