Repository navigation
fix(discovery): start the ENR's seq at the clock so a restart replaces the record peers hold - #954
Open
pablodeymo wants to merge 1 commit into
Open
pablodeymo wants to merge 1 commit into
pablodeymo wants to merge 1 commit into
Conversation
…s the record peers hold The record was signed at ethrex's INITIAL_ENR_SEQ (1) on every boot. A discv5 peer takes a replacement record only at a strictly higher seq, so after a restart peers kept the copy they had cached from the previous run. That copy carries the previous run's `eth2` entry, and the served record cannot be edited at runtime (#932), so a restart is the only way a node publishes its fork digest after a boundary: at a fixed seq even that did not reach peers that already knew the node. The record now starts at the current time in milliseconds, as geth's does. This is the seq part of #735, which needs no ethrex change. The boundary warning now tells the operator to restart. Related to #932
This branch has not been deployed
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.
🗒️ Description / Motivation
Intended for
release/v2.0.0by cherry-pick once merged here. It is the part of the "Decide on #735" item on #943's checklist that can ship in v2.0.0.The ENR this node serves over discv5 keeps the fork digest it started with across a fork boundary (#932): ethrex's
DiscoveryServercannot replace its record at runtime. #735 fixes that, but it depends on three unmerged ethrex PRs (lambdaclass/ethrex#7488, on #7574, on #7217), so it cannot be in v2.0.0, which pins ethrex to a release tag. The plan for v2.0.0 is to state the gap in the release notes and tell operators to restart after Hoodi's Glamsterdam boundary (epoch 143616, 2026-12-15 19:12:24 UTC).That restart does not reliably work today. The record is signed at ethrex's
INITIAL_ENR_SEQ(1) on every boot, and a discv5 peer takes a replacement record only at a strictly higherseq. So after a restart, peers that already hold the node's record keep their copy, previous fork digest included, and hand it on in their NODES answers.docs/discovery.mdlisted this as a known limitation for upgrades ("An upgrade's new ENR entries are invisible to peers that stayed up").This PR takes the
seqpart of #735 on its own: it needs no ethrex change and no lockfile change.What Changed
crates/net/p2p/src/discovery/enr.rs:build_local_enrsigns the record atstarting_seq(), the current time in milliseconds (never belowINITIAL_ENR_SEQ), as geth does. Code and test are feat(discovery): republish the ENR's eth2 entry at fork boundaries #735's.crates/net/p2p/src/discovery/mod.rs: the warning logged at a boundary (update_served_enr) now ends with "Restart the node to publish the new fork digest".docs/discovery.md,docs/beacon_wire.md,CLAUDE.md: describe the startingseqand what a restart does; the closed known limitation is removed.Correctness / Behavior Guarantees
seqthe previous run reached. Nothing is persisted: the only edits to a running record are discv5 IP voting's, oneseqeach, so the previous run would have had to edit more than once per millisecond of uptime to pass the clock. A clock stepped back past the previous run's last edit is the one case not covered.seq = 1record peers hold from an earlier version.ethlambda nodewith--discovery.enabletoo: same function.Tests Added / Run
the_record_starts_at_the_clock_not_at_a_fixed_seq(theseqis inside the clock readings taken around the build, and the signature verifies).cargo test -p ethlambda-p2p --profile release-fast --lib: 567 passed, 1 ignored.cargo clippy -p ethlambda-p2p --all-targets -- -D warningsandcargo fmt --all -- --check: clean.make lintandmake test.pong_message.enr_seq > cached_seq; the handshake sends the record only whenseqdiffers from the requester's); for other clients it is the ENR spec's rule.Related Issues / PRs
nfdremain)enr.rsanddocs/discovery.md(same code)✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — clean (onlyethlambda-p2p)make test(test-consensus,test-nodeandtest-ethrex, atrelease-fast) — all passing (onlyethlambda-p2p --lib)