Skip to content

Fix8725: Do not ask for chain head header when using eth69#8756

Closed
pinges wants to merge 12 commits intobesu-eth:mainfrom
pinges:reworkEthPeersChanges
Closed

Fix8725: Do not ask for chain head header when using eth69#8756
pinges wants to merge 12 commits intobesu-eth:mainfrom
pinges:reworkEthPeersChanges

Conversation

@pinges
Copy link
Copy Markdown
Contributor

@pinges pinges commented Jun 6, 2025

PR description

This PR is a slight optimisation in case we are using eth69 with a peer, where we don't have to ask for their chain head header after receiving their status message.

Fixed Issue(s)

#8725

pinges added 7 commits June 2, 2025 14:04
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes Eth69 peer handling by skipping redundant chain head requests and refactors peer checking logic for clarity and performance.

  • Simplified SnapServerChecker by making its constructor private and streamlining its check method.
  • Added debug logging in ChainHeadTracker#getBestHeaderFromPeerCompletableFuture.
  • Refactored EthPeers.ethPeerStatusExchanged to extract and reuse checkHeadBlock and checkSnapServer, with conditional skipping for Eth69 peers.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/SnapServerChecker.java Made constructor private; simplified check to use thenApply.
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/sync/ChainHeadTracker.java Added debug log before fetching headers from peer.
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java Refactored ethPeerStatusExchanged, extracted helper methods, and skipped chain head fetch for Eth69 peers.

LOG.atTrace()
.setMessage("Checking whether peer {} is a snap server ...")
.addArgument(peer::getLoggableId)
.log();
Copy link

Copilot AI Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing a null headBlockHeader for Eth69-compatible peers will be forwarded to getAccountRangeFromPeer and may cause an NPE or unexpected behavior. Consider handling the null case explicitly (e.g., using the status message header) before calling this method.

Suggested change
.log();
.log();
if (headBlockHeader == null) {
LOG.atWarn()
.setMessage("headBlockHeader is null. Cannot check if peer {} is a snap server.")
.addArgument(peer::getLoggableId)
.log();
return CompletableFuture.completedFuture(false);
}

Copilot uses AI. Check for mistakes.
@pinges pinges changed the title Rework eth peers changes Fix8725: Do not ask for chain head header when using eth69 Jun 6, 2025
pinges and others added 5 commits June 8, 2025 03:29
…anager/EthPeers.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Stefan Pingel <16143240+pinges@users.noreply.github.com>
…anager/EthPeers.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Stefan Pingel <16143240+pinges@users.noreply.github.com>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
@pinges pinges closed this Jun 19, 2025
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