Skip to content

Conversation

@karalabe
Copy link
Member

@karalabe karalabe commented Mar 18, 2020

This PR fixes a regression introduced in v1.9.0 by the freezer, unfortunately that regression was completely silent and was surfaced only by b9c90c5.

The symptom is when a miner is started against an empty database, instantly mines a block, and then fast syncs... crashing. Since the node mined a block, it's current head block is 1, with hashA. Fast sync will start and dump a whole lot of data into the freezer/ancient database (including block 1, with hashB). Later on, any code that accesses the currentBlock, will want data belonging to hashA, but the freezer only has data belonging to hashB.

The crash is due to the sync code accessing the current block and then it's TD, which is returned as nil, since the hash doesn't match (the crash is due to b9c90c5 actually validating the hash, previously we trusted it blindly).

The fix is to change the sync code to base it's TD retrieval on the head header, instead of the head block. This is actually the correct behavior as throughout fast sync the current block is the genesis, we've been doing it wrong for 4 years. This will also solve the panic because the head header is either the actual one from the ancient db, or if it's newer than the ancient limit then we'll always have it.

Fixes #20770, #20614

@karalabe karalabe added this to the 1.9.13 milestone Mar 18, 2020
Copy link
Contributor

@holiman holiman left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clique miner + fresh start + fast sync = panic

2 participants