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

fix: ban peer when Merkle roots mismatch #3162

Merged

Conversation

sdbondi
Copy link
Member

@sdbondi sdbondi commented Aug 5, 2021

Description

Ban peer if block validation fails during block body sync

Motivation and Context

When this error is encountered, the peer sent an invalid block body given the current header chain.
DEBUG Block sync failed: Block validation failed: Block validation error: Mismatched MMR roots
The node should ban the peer. Previously, the node would encounter this, then retry the same peer,
rinse and repeat - preventing the node from syncing.

How Has This Been Tested?

Not explicitly tested - fairly basic change.

Checklist:

  • I'm merging against the development branch.
  • I have squashed my commits into a single commit.

Copy link
Contributor

@philipr-za philipr-za left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@SWvheerden SWvheerden left a comment

Choose a reason for hiding this comment

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

Looks good, this was much needed. Just one question

Comment on lines +286 to +292
if self.config.sync_peers.contains(&node_id) {
debug!(
target: LOG_TARGET,
"Not banning peer that is allowlisted for sync. Ban reason = {}", reason
);
return Ok(());
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this logic rather not live in the connectivity manager? Here we don't ban a peer because it is allow listed, but I don't think we have the same logic with propagation, there that peer will get banned.

Copy link
Member Author

@sdbondi sdbondi Aug 6, 2021

Choose a reason for hiding this comment

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

This is the force sync peer setting specific to sync, not the seed peers. By default it's empty. So seed peers can get banned, but if you explicitly say "I want to force a sync only from peer X" we never ban them.

@aviator-app
Copy link
Contributor

aviator-app bot commented Aug 6, 2021

Waiting for approval before queuing

@aviator-app
Copy link
Contributor

aviator-app bot commented Aug 6, 2021

PR queued successfully. Your position in queue is: 2

@aviator-app
Copy link
Contributor

aviator-app bot commented Aug 6, 2021

PR is on top of the queue now

@aviator-app aviator-app bot merged commit 92e6bb1 into tari-project:development Aug 6, 2021
@sdbondi sdbondi deleted the core-block-sync-peer-ban branch August 8, 2021 06:18
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.

4 participants