eth/downloader: only roll back light sync if not fully validating#21537
Merged
karalabe merged 1 commit intoethereum:masterfrom Sep 9, 2020
karalabe:les-reorg-fix
Merged
eth/downloader: only roll back light sync if not fully validating#21537karalabe merged 1 commit intoethereum:masterfrom karalabe:les-reorg-fix
karalabe merged 1 commit intoethereum:masterfrom
karalabe:les-reorg-fix
Conversation
holiman
reviewed
Sep 9, 2020
|
|
||
| // If some headers were inserted, track them as uncertain | ||
| if n > 0 && rollback == 0 { | ||
| if (mode == FastSync || frequency > 1) && n > 0 && rollback == 0 { |
Contributor
There was a problem hiding this comment.
Shouldn't it be frequency==1 ? Why do we add rollbacks only when the header check is every N:th block, but not when it's every block?
Member
Author
There was a problem hiding this comment.
Well, if it checked every block, there's nothing to roll back. We should only roll back if we checked every 24th block for PoW, since we don't know if the previous ones were valid or not
Member
There was a problem hiding this comment.
If we pass the pivot point, the frequency is 1. In this case, we don't need to rollback?
what about this:
if frequency > 1 && n > 0 && rollback == 0 {
Closed
10 tasks
This was referenced Jun 15, 2021
9 tasks
19 tasks
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.
Fixes #21505.
There is a notion of rollbacks during fast sync, where recent blocks that might not be clean are deleted from the database on a sync failure. This is needed to avoid attacks on fast sync since we're not running transactions.
For light sync however, rollbacks are pointless because there's no batch of full blocks imported on top to validate them. As long as the PoW checks out, light clients will take the node's word for it.
This PR disables the rollback mechanism for light syncs, which was causing crashes in the light txpool due to deleting headers that it imported before. Interestingly, the issue was that the rollback mechanism wasn't disabled after initial sync (opposed to fast sync switching to full sync).