-
Notifications
You must be signed in to change notification settings - Fork 20.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core, eth/downloader: fix genesis state missing due to state sync #28124
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -398,7 +398,14 @@ func (d *Downloader) synchronise(id string, hash common.Hash, td, ttd *big.Int, | |
log.Info("Block synchronisation started") | ||
} | ||
if mode == SnapSync { | ||
// Snap sync uses the snapshot namespace to store potentially flakey data until | ||
// Snap sync will directly modify the persistent state, making the entire | ||
// trie database unusable until the state is fully synced. To prevent any | ||
// subsequent state reads, explicitly disable the trie database and state | ||
// syncer is responsible to address and correct any state missing. | ||
if d.blockchain.TrieDB().Scheme() == rawdb.PathScheme { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trie database and state snapshot are explicitly disabled here, at the beginning of the snap sync procedure. However, this approach may need reconsideration. During a snap sync procedure, we may initiate multiple state sync cycles with different targets, particularly when the pivot point shifts. It is possible that a state has already been sync'd, and we begin synchronizing another one. The enabling and disabling of these components should align more cohesively. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the fix #28126 , we have the guarantee that the committed state won't be resync'd. In another word, for a snap sync process, we either end up with a complete state and re-enable the trie database and state snapshot for single time or exits abnormally. It's safe to invalidate the trie database and state snapshot only at the beginning of snap sync. |
||
d.blockchain.TrieDB().Reset(types.EmptyRootHash) | ||
} | ||
// Snap sync uses the snapshot namespace to store potentially flaky data until | ||
// sync completely heals and finishes. Pause snapshot maintenance in the mean- | ||
// time to prevent access. | ||
if snapshots := d.blockchain.Snapshots(); snapshots != nil { // Only nil in tests | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope to add a log here as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resetState
will print something. But one thing to mention that by disabling the trie database at the beginning of snap sync, the trie database will be in "uninitialized" status until the state is fully sync'd.In the next restart, the missing genesis status will be re-inited in
SetupGenesisBlockWithOverride
. Therefore, this logic is a bit redundant, but still necessary.