Repository navigation
Advertise snap in the local ENR when the snap server is enabled - #11565
Open
MysticRyuujin wants to merge 4 commits into
Open
MysticRyuujin wants to merge 4 commits into
MysticRyuujin wants to merge 4 commits into
Conversation
Signed-off-by: Chase Wright <chase.wright@ethereum.org>
Signed-off-by: Chase Wright <chase.wright@ethereum.org>
MysticRyuujin
marked this pull request as ready for review
October 12, 2026 18:07
Signed-off-by: Chase Wright <chase.wright@ethereum.org>
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.
PR description
With
--snapsync-server-enabledon Bonsai full flat or archive storage, write thesnapentry into the local ENR. The value is the list of snap versions that the node serves, as proposed for EIP-8189 in ethereum/EIPs#12493 (discussion: ethereum/devp2p#286):[1, 2]when--Xsnap2-enabledis also set. The node then offers snap/2 in Hello and answersGetBlockAccessLists.[]otherwise. An empty list means snap/1 only. Go-ethereum writes this value today.DNS discovery lists select snap servers by this ENR entry. Examples are
devp2p nodeset filter -snapand thesnap.*trees of EIP-1459. The Besu ENR does not carry the entry, so these lists cannot include Besu nodes that serve snap.Changes:
NodeRecordManageradds thesnapfield when the node serves snap. The reuse check for the persisted ENR compares the field value, so a change of the served versions rewrites the ENR with a new sequence number.BesuCommandthroughRunnerBuilderandDiscoveryConfigurationto the two discovery factories:snapServerEnabledandsnap2ServerEnabled.BesuCommandsets the flags only for storage thatSnapServer.start()can serve from:X_BONSAI_ARCHIVE, orBONSAIwith full flat DB. On other storage, every snap request gets an empty response, so the node must not advertise.SynchronizerOptions.isSnap2Enabled()exposes the existing--Xsnap2-enabledoption.Note: an existing Bonsai database in
PARTIALflat mode still advertises when full flat DB is enabled in the configuration. The flat mode is known only after the database opens. Go-ethereum also advertises from configuration, not from serving state.Fixed Issue(s)
Thanks for sending a pull request! Have you done the following?
doc-change-requiredlabel to this PR if updates are required in the Besu documentation.Locally, you can run these tests to catch failures early:
./gradlew spotlessApply./gradlew build./gradlew acceptanceTest./gradlew integrationTest./gradlew ethereum:referenceTests:referenceTestsTests run:
NodeRecordManagerTest(33). New cases: the field is absent when snap is not served; the wire bytes are84736e6170c0for snap/1 only and84736e6170c20102for[1, 2]; a restart keeps the sequence number for both values; a change of the served versions or of snap serving rewrites the ENR.PeerDiscoveryAgentFactoryV5Test(14) andCompositePeerDiscoveryAgentFactoryTest(9).BesuCommandTest(234). New cases cover the storage gate and the snap/2 flag.