fix(lean): reject forward-sync blocks ahead of wall-clock to stop on_tick freeze - #1523
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong?
Ream node freezes when a malicious block is received while syncing.
During forward sync, a ream node receives a structurally valid
SignedBlockbut itsslotis very large (e.g.u64::MAX - 5to match the right proposer slot), the node gets stuck due to theon_tickfunction. Also the tick is advanced to a large number hence it cannot sync, the db needs to be cleared.This bug is similar to the one already fixed in #1501. That PR added check in the
on_blockfunction to deny such malicious block during live sync. However during forward sync, theon_tickfunction is called beforeon_blockthat would have denied such a payload.When having multiple peers, if enough peers are malicious then the malicious payload wins. Also a live synced node can potentially backfill and get frozen.
How was it fixed?
The fix is added in the
ForwardBackgroundSyncer::start()just before theon_tickinvocation. Based on the system time/wall_clock we compute the expected slot and reject any slot that is beyondwall_clock_slot + 1.How is this tested?
Local tests pass. There are no hive tests for forward syncing. I have done bunch of devnet runs.
Master branch
PR branch
To-Do