Skip to content
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

Merged
merged 6 commits into from
Feb 5, 2019

Conversation

ajsutton
Copy link
Contributor

@ajsutton ajsutton commented Feb 5, 2019

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 or IbftCommitSealsValidationRule 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.

@ajsutton ajsutton force-pushed the fast-sync-extra-validation branch from 89dfb74 to 3d403bb Compare February 5, 2019 03:49

import tech.pegasys.pantheon.ethereum.mainnet.HeaderValidationMode;

public interface ValidationPolicy {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth adding @FunctionalInterface here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea.

boolean seenLight = false;
boolean seenFull = false;
// It's theoretically possible to flip a coin 2^31-1 times and only ever get heads but
// we're probably more likely to get intermittent failures from the hard drive failing...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂

@ajsutton ajsutton merged commit 700237b into PegaSysEng:master Feb 5, 2019
@ajsutton ajsutton deleted the fast-sync-extra-validation branch February 5, 2019 20:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants