eth/downloader: only roll back light sync if not fully validating #21537
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).