Skip to content

feat(net): optimize disconnectRandom by tracking block receive time p…#12

Open
xxo1shine wants to merge 1 commit intobase-codefrom
feature/net-random-disconnect-optimization
Open

feat(net): optimize disconnectRandom by tracking block receive time p…#12
xxo1shine wants to merge 1 commit intobase-codefrom
feature/net-random-disconnect-optimization

Conversation

@xxo1shine
Copy link
Copy Markdown
Owner

…er peer

  • Add blockRcvTime/blockRcvTimeCmp fields to PeerConnection to track when a peer last delivered a valid block
  • Set blockRcvTime in BlockMsgHandler after each block is received
  • Fix lastInteractiveTime update in InventoryMsgHandler: only update for block inventories above current head block num, preventing attackers from forging activity via stale block hashes
  • Add getRandomDisconnectionPeers() to ResilienceService: narrows the disconnect candidate pool to the oldest half by blockRcvTime, so peers that recently delivered blocks are protected from random eviction

What does this PR do?

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

…er peer

- Add blockRcvTime/blockRcvTimeCmp fields to PeerConnection to track when
  a peer last delivered a valid block
- Set blockRcvTime in BlockMsgHandler after each block is received
- Fix lastInteractiveTime update in InventoryMsgHandler: only update for
  block inventories above current head block num, preventing attackers from
  forging activity via stale block hashes
- Add getRandomDisconnectionPeers() to ResilienceService: narrows the
  disconnect candidate pool to the oldest half by blockRcvTime, so peers
  that recently delivered blocks are protected from random eviction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant