This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
[NC-2233] Randomly perform full validation when fast syncing blocks #770
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.
PR description
During a fast sync, most blocks skip proof of work validation to speed up import. However we randomly select blocks to perform full validation on so we have confidence it really is a valid chain.
There's a slight oddity here because of the way we've modelled header validation - we actually perform header validation in two separate places, when the header is downloaded (detached - parent may not have been imported yet) and when it's about to be imported (attached - it's parent block is already on our chain). This means we have two independent places where we decide on the type of validation. With this implementation, fast sync is randomly selecting light or full separately at both those points. There is actually only ever one rule skipped by using light validation -
ProofOfWorkValidation
when using ethash orIbftCommitSealsValidationRule
when using IBFT.ProofOfWorkValidation
runs with the detached rules,IbftCommitSealsValidationRule
runs with the attached rules. Net result, when using ethash the choice between full or light only makes a difference when running the detached rules and for IBFT it only makes a difference when running the attached rules.