Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Disconnect peers where the common ancestor is before our fast sync pivot #862

Merged

Conversation

ajsutton
Copy link
Contributor

PR description

This is the simplest possible handling of missing world states when finding a sync target. If we don't have a world state for common ancestor block, then it must be before the fast sync pivot block and we'll either have to start again from genesis (opening up significant potential for griefing) or refuse to sync to the peer. So we refuse to sync to the peer and disconnect them.

This behaviour will need to be more nuanced when state pruning is adding as in that case we may want to search back from the common ancestor some number of blocks to find a world state we do have. The details of how that behaviour would depend on the state pruning implementation though so going to keep it simple for now.

…vot block as we will be unable to sync with them anyway.
return Optional.of(syncTarget);
} else {
LOG.warn(
"Disconnecting {} because common ancestor at block {} is prior to our fast sync pivot block",
Copy link
Contributor

Choose a reason for hiding this comment

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

For future-proofing, might be better to have a more generic message. Something like "Disconnecting {} because world state is unavailable at common ancestor block {}"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I went back and forth on how specific to be. I suspect this area needs reworking as soon as we have a different way to wind up with blocks without state (e.g. pruning) anyway but probably better to be a bit generic.

@ajsutton ajsutton merged commit 4470a92 into PegaSysEng:master Feb 14, 2019
@ajsutton ajsutton deleted the common-ancestor-needs-world-state branch February 14, 2019 19:44
rain-on pushed a commit to rain-on/pantheon that referenced this pull request Feb 14, 2019
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