Skip to content

Advertise snap in the local ENR when the snap server is enabled - #11565

Open
MysticRyuujin wants to merge 4 commits into
besu-eth:mainfrom
MysticRyuujin:enr-snap-entry
Open

MysticRyuujin wants to merge 4 commits into
besu-eth:mainfrom
MysticRyuujin:enr-snap-entry

Conversation

@MysticRyuujin

@MysticRyuujin MysticRyuujin commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

PR description

With --snapsync-server-enabled on Bonsai full flat or archive storage, write the snap entry 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-enabled is also set. The node then offers snap/2 in Hello and answers GetBlockAccessLists.
  • [] 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 -snap and the snap.* trees of EIP-1459. The Besu ENR does not carry the entry, so these lists cannot include Besu nodes that serve snap.

Changes:

  • NodeRecordManager adds the snap field 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.
  • Two flags go from BesuCommand through RunnerBuilder and DiscoveryConfiguration to the two discovery factories: snapServerEnabled and snap2ServerEnabled.
  • BesuCommand sets the flags only for storage that SnapServer.start() can serve from: X_BONSAI_ARCHIVE, or BONSAI with 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-enabled option.

Note: an existing Bonsai database in PARTIAL flat 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?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required in the Besu documentation.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • spotless: ./gradlew spotlessApply
  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests
  • hive tests: Engine or other RPCs modified?

Tests run:

  • NodeRecordManagerTest (33). New cases: the field is absent when snap is not served; the wire bytes are 84736e6170c0 for snap/1 only and 84736e6170c20102 for [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) and CompositePeerDiscoveryAgentFactoryTest (9).
  • BesuCommandTest (234). New cases cover the storage gate and the snap/2 flag.

Signed-off-by: Chase Wright <chase.wright@ethereum.org>
Signed-off-by: Chase Wright <chase.wright@ethereum.org>
Signed-off-by: Chase Wright <chase.wright@ethereum.org>

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.

2 participants