Skip to content

feat(sync): Add badBlocks support#3214

Closed
dimartiro wants to merge 2 commits intoeclesio/fix-bootstrap-syncfrom
diego/bad-blocks-handling
Closed

feat(sync): Add badBlocks support#3214
dimartiro wants to merge 2 commits intoeclesio/fix-bootstrap-syncfrom
diego/bad-blocks-handling

Conversation

@dimartiro
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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