-
Notifications
You must be signed in to change notification settings - Fork 929
Fix8725: Do not ask for chain head header when using eth69 #8756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
Signed-off-by: [email protected] <[email protected]>
There was a problem hiding this 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 reusecheckHeadBlock
andcheckSnapServer
, 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. |
@@ -46,34 +46,30 @@ public static void createAndSetSnapServerChecker( | |||
ethContext.getEthPeers().setSnapServerChecker(checker); | |||
} | |||
|
|||
public CompletableFuture<Boolean> check(final EthPeer peer, final BlockHeader peersHeadHeader) { | |||
public CompletableFuture<Boolean> check(final EthPeer peer, final BlockHeader headBlockHeader) { | |||
LOG.atTrace() | |||
.setMessage("Checking whether peer {} is a snap server ...") | |||
.addArgument(peer::getLoggableId) | |||
.log(); |
There was a problem hiding this comment.
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.
.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.
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java
Outdated
Show resolved
Hide resolved
ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthPeers.java
Outdated
Show resolved
Hide resolved
…anager/EthPeers.java Co-authored-by: Copilot <[email protected]> Signed-off-by: Stefan Pingel <[email protected]>
…anager/EthPeers.java Co-authored-by: Copilot <[email protected]> Signed-off-by: Stefan Pingel <[email protected]>
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