Skip to content
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

netsync: don't ask for blocks from peers on the same block height #2304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kcalvinalvin
Copy link
Collaborator

When we're all caught up and we have a new peer, we'll ask for blocks from peers that we're on the same height. Since these peers don't have any blocks to send us, they don't reply and we disconnect from them as they timeout.

To prevent this, we don't ask for blocks if the chain thinks we're current and do not have a peer that reports having a higher block.

@coveralls
Copy link

coveralls commented Jan 16, 2025

Pull Request Test Coverage Report for Build 12803849581

Details

  • 0 of 4 (0.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 57.269%

Changes Missing Coverage Covered Lines Changed/Added Lines %
netsync/manager.go 0 4 0.0%
Files with Coverage Reduction New Missed Lines %
mempool/mempool.go 1 66.67%
Totals Coverage Status
Change from base Build 12775873016: 0.01%
Covered Lines: 29950
Relevant Lines: 52297

💛 - Coveralls

When we're all caught up and we have a new peer, we'll ask for blocks
from peers that we're on the same height. Since these peers don't have
any blocks to send us, they don't reply and we disconnect from them as
they timeout.

To prevent this, we don't ask for blocks if the chain thinks we're
current and do not have a peer that reports having a higher block.
@kcalvinalvin kcalvinalvin force-pushed the 2025-01-16-dont-ask-for-blocks-from-same-height-peers branch from fb9121d to aace7a9 Compare January 16, 2025 07:09
@yyforyongyu yyforyongyu self-requested a review January 16, 2025 15:29
@saubyk saubyk added this to the v0.25 milestone Feb 18, 2025
@saubyk saubyk added the log label Feb 18, 2025
@saubyk
Copy link
Collaborator

saubyk commented Feb 18, 2025

cc: @ziggie1984 for review

@@ -309,6 +309,11 @@ func (sm *SyncManager) startSync() {
higherPeers = append(higherPeers, peer)
}

if sm.chain.IsCurrent() && len(higherPeers) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it matter if we are current or not? I think as long as we have no higherPeers there's no need to sync? As these peers don't have any blocks to send us, they don't reply and we disconnect from them as they timeout.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't matter but if the node is getting eclipse attacked, then it may be that it's not current and it doesn't have any higher peers. Thought it might be good to differentiate because of this

Copy link
Collaborator

@yyforyongyu yyforyongyu left a comment

Choose a reason for hiding this comment

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

LGTM❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants