Skip to content

Fixed-10108 : should only advertise snap/1 in handshake if snapsync-server-enabled#10182

Open
sagarkhandagre998 wants to merge 2 commits intobesu-eth:mainfrom
sagarkhandagre998:issue-10108
Open

Fixed-10108 : should only advertise snap/1 in handshake if snapsync-server-enabled#10182
sagarkhandagre998 wants to merge 2 commits intobesu-eth:mainfrom
sagarkhandagre998:issue-10108

Conversation

@sagarkhandagre998
Copy link
Copy Markdown

@sagarkhandagre998 sagarkhandagre998 commented Apr 4, 2026

PR description

p2p: only advertise snap/1 when snap server or snap sync is active

Problem

Besu unconditionally advertised snap/1 in its devp2p handshake regardless of --snapsync-server-enabled. Remote peers probed it, received empty responses, classified it as a non-server, and stopped sending snap requests to it — wasted connections with no operator warning.


Approach Decision

The non-trivial part was that snap/1 serves two roles:

  • Server role — Besu serves snap data to peers doing snap sync (--snapsync-server-enabled)
  • Client role — Besu itself needs snap/1 negotiated to receive snap data from peers while doing snap sync (--sync-mode=SNAP)

In devp2p, both sides must advertise a capability for it to be active on a connection. Blindly removing snap/1 when the server is disabled would silently break snap sync for nodes still catching up.

So the fix gates advertisement on both conditions rather than just snapServerEnabled:

--snapsync-server-enabled --sync-mode Advertise snap/1?
false non-SNAP ❌ — silent, DEBUG log
false SNAP ✅ — WARN log (client-only, won't serve)
true any ✅ — no warning

Changes

  • SnapProtocolManagercalculateCapabilities() now takes snapConfig and syncMode; applies the three-way logic above; logs WARN when advertising for client-only use
  • BesuControllerBuilder — passes syncConfig.getSyncMode() into SnapProtocolManager
  • SnapProtocolManagerTest — adds SyncMode.SNAP to keep the existing test exercising a snap-capable node

Fixed Issue(s)

Fixed #10108

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.
  • 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?

…s active

Signed-off-by: Sagar Khandagre <sagar.khandagre998@gmail.com>
Signed-off-by: Sagar Khandagre <sagar.khandagre998@gmail.com>
@sagarkhandagre998
Copy link
Copy Markdown
Author

@jframe

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.

should only advertise snap/1 in handshake if snapsync-server-enabled

1 participant