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

feat(sync): Add badBlocks support #3214

Closed

Conversation

dimartiro
Copy link
Contributor

Changes

Change sync process to reject bad blocks and disconnect from that peer

Tests

make test

Issues

#3202

Primary Reviewer

@EclesioMeloJunior

Comment on lines 1024 to 1030
for _, badBlockHash := range cs.badBlocks {
if bd.Hash.String() == badBlockHash {
logger.Errorf("Rejecting known bad block Number: %d Hash: %s", bd.Number(), bd.Hash)
return errBadBlock
}
}

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
for _, badBlockHash := range cs.badBlocks {
if bd.Hash.String() == badBlockHash {
logger.Errorf("Rejecting known bad block Number: %d Hash: %s", bd.Number(), bd.Hash)
return errBadBlock
}
}
if slices.Contains(cs.badBlocks, bd.Hash.String) {
logger.Errorf("Rejecting known bad block Number: %d Hash: %s", bd.Number(), bd.Hash)
return errBadBlock
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Thks for the suggestion

@dimartiro
Copy link
Contributor Author

I'll close this PR cause I splitted it in two, this is one and the second one will be using Eclesio's branch with the new sync to use this validation there

@dimartiro dimartiro closed this Apr 19, 2023
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.

2 participants