discv4/discv5 remainders on develop: NEIGHBORS, NODES cap, node-map flood eviction - #45
Merged
Merged
Conversation
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.
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.
… is full lookupOrCreateNode previously returned a non-retained node once the map was 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. Adds regression tests for this and the two preceding NEIGHBORS fixes.
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
Targets
develop. Adds the three discv4/discv5 fixes thatdevelopwas still missing after its independent rework — the remainders from the #44 audit set thatdevelopdid not already cover (BUG1 ENRRESPONSE, G9 ingest size, BUG5 bond,--serve-allare all already indevelop).Each fix is its own commit. All CI checks pass locally (
go mod verify,go vet,gofmt,staticcheck,go test -race,make build), and each fix is verified against a full glamsterdam-devnet-7 devnet (all EL+CL clients, bootnodoor as sole bootnode) with no regression.Commits
totaland reads at most 5 packets; a dual-serve response could emit 6, silently dropping nodes. sigp/discv5 caps at 16.lookupOrCreateNodereturned a non-retained node once atMaxNodes, 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 → bonding-lockout DoS). When full, evict one unbonded entry to admit the new node; bonded, endpoint-proven peers are never evicted this way.Verification (glamsterdam-devnet-7, all clients, bootnodoor as sole bootnode)
No regression vs
develop: all 12 nodes discovered, 11 discv5 sessions, 0 EL fork rejections, 0 bootnodoor errors/warnings, storm-free (≤17 packets to any single peer over the run), CL 5/5 mesh, EL 5/5 (besu/erigon 4/5, unchanged — that gap is the besu-v4-only vs erigon-v5-only artifact, not bootnodoor), 0 client-side bans.Each fix addresses a real concern:
developdelivered 0 NEIGHBORS packets (geth waits out its timeout on every FINDNODE); this branch delivered 10 (immediate empty replies). A fresh bootnode now answers FINDNODE instead of going silent.TestSendNeighborsAdvertisesEnrTCPPort: a peer with ENR tcp=40404/udp=30303 is advertised as TCP=40404 (was the UDP port).TestFloodDoesNotEvictBondedPeers: under a flood pastMaxNodes, a bonded peer is retained and a fresh peer is still admitted; the map stays bounded and no genuine peer is locked out.Note
Opening against
developsince that is where the parallel rework lives. If you'd rather I retarget oncedevelopmerges tomaster, happy to.