cmd/geth, core/rawdb: add dbDeleteTrieState #2302
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a feature to convert full node to fast node by introducing a new CLI tool called
delete-trie-state
. The tool will delete all PBSS key-value pairs and ancient state stores from the database.Rationale
This is particularly useful when users want to switch from full node to fast node by deleting the trie state from the database, reducing disk space occupied.
Example
Usage:
./geth --datadir db delete-trie-state
Changes
Also added an additional
NoTries
logic check inSetupGenesisBlockWithOverride
to prevent committing the genesis block again. For custom networks, this will result in an error because!triedb.Initialized(header.Root)
returns true due to an empty trie database, so we need to skip committing if it's a fast node.