fix: sync peer ordering#6802
Conversation
WalkthroughThe changes modify the peer sorting logic in the header synchronization state by using claimed difficulty as the primary criterion (with a fallback to latency when equal). A new method to retrieve claimed difficulty is added to the sync peer module. Additionally, an update is made to the median timestamp test, correcting the expected value for inputs that include zero. Changes
Sequence Diagram(s)sequenceDiagram
participant HS as HeaderSyncState::new
participant Peer1 as SyncPeer (Peer 1)
participant Peer2 as SyncPeer (Peer 2)
HS->>Peer1: Retrieve claimed_difficulty()
HS->>Peer2: Retrieve claimed_difficulty()
alt Claimed difficulties differ
HS->>Peer1: Compare claimed_difficulty values
HS->>Peer2: Order based on claimed_difficulty
else Claimed difficulties equal
HS->>Peer1: Compare latency values
HS->>Peer2: Order based on latency
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Test Results (CI) 3 files 129 suites 37m 13s ⏱️ Results for commit c89b253. |
Test Results (Integration tests) 2 files + 2 11 suites +11 32m 57s ⏱️ + 32m 57s For more details on these failures, see this check. Results for commit c89b253. ± Comparison against base commit 11d9926. |
Description
Fixes peer sync order.
Currently, the syncing peers are ordered by latency. This is important, but we also need to sync to the highest node tip.
This changes the order for the sync peers to first order by higher, then by latency.
Summary by CodeRabbit
New Features
Tests