-
Couldn't load subscription status.
- Fork 21.5k
cmd, core/state: implement state pruner #21042
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
Conversation
1296d66 to
f465511
Compare
363e3b5 to
afc4043
Compare
cmd/geth/snapshot.go
Outdated
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.
Wouldn't it be better to return an error instead of just exiting on errors? (re this location and all others)
|
Running the pruning on the benchmark machine 01;
|
accad99 to
3fe484c
Compare
|
As I understand it, this is the current scheme:
This scheme basically empties most of leveldb out, and writes everything back again, which is very heavy IO.
Size of state-keys, if EDIT: the key size is really the size of to-be-kept, so not the unpruned size. It won't be 1G keys, but somewhere on the order of 600M on mainnet right now However, we don't actually have to be fully accurate. If we use a bloom, which has As far as I can tell, a bloom filter of ~1.84Gb, with 11 filter functions, would give us an So we'd wind up with:
It's a very different approach, I'd be curioous to see the performance difference between these two ways if doing it. |
This PR offers two commands
geth snapshot prune-stateandgeth snapshot verify-state.All these two commands require a live snapshot. If you want to use it, generate the snapshot
first with
--snapshotenabled.State pruner
It's a very simple state pruner. The idea is quite straightforward. Whenever we have a live snapshot, we can re-generate the whole state trie from it. Users can pick a specific version snapshot for state regeneration and then wipe all other trie nodes for pruning.
The procedure of pruning can be the following steps:
These following scenarios can happen:
Something important:
State verifier
Verifier is a simple tool to verify whether the regenerated state trie hash is equal with the original one. Now it's mainly used for testing.
What's more?
Except these two commands, we can offer more functionalities based on the snapshot. One idea is the snapshot can be used to generate arbitrary range trie nodes. If so, we can use it for state repairing. Whenever we hit the
trie node missingerror, we can just regenerate it instead of throwing out the whole db.