Skip to content

cmd/geth, core/rawdb: add dbDeleteTrieState#2302

Merged
buddh0 merged 2 commits intobnb-chain:developfrom
weiihann:develop/full-to-fast
Mar 20, 2024
Merged

cmd/geth, core/rawdb: add dbDeleteTrieState#2302
buddh0 merged 2 commits intobnb-chain:developfrom
weiihann:develop/full-to-fast

Conversation

@weiihann
Copy link
Copy Markdown
Contributor

@weiihann weiihann commented Mar 18, 2024

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

...
INFO [03-18|16:06:39.783] Opened ancient database                  database=/datadir_test/geth/chaindata/ancient/chain readonly=false frozen=909,979
INFO [03-18|16:06:43.759] Deleted trie state                       count=1,683,851 elapsed=3.971s
INFO [03-18|16:06:43.759] Removing ancient state database          path=/datadir_test/geth/chaindata/ancient/state
INFO [03-18|16:06:43.862] State database successfully deleted      path=/datadir_test/geth/chaindata/ancient/state elapsed=103.202ms

Changes

Also added an additional NoTries logic check in SetupGenesisBlockWithOverride 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.

@weiihann weiihann marked this pull request as draft March 18, 2024 08:13
@weiihann weiihann marked this pull request as ready for review March 18, 2024 08:25
@weiihann weiihann force-pushed the develop/full-to-fast branch from 77519ac to a36842f Compare March 19, 2024 07:24
@weiihann weiihann requested a review from flywukong March 19, 2024 07:27
@weiihann weiihann requested a review from fynnss March 19, 2024 10:36
@weiihann weiihann force-pushed the develop/full-to-fast branch from 62129f1 to 6a6de14 Compare March 19, 2024 10:38
Copy link
Copy Markdown
Contributor

@flywukong flywukong left a comment

Choose a reason for hiding this comment

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

LGTM

@buddh0 buddh0 merged commit 6978f00 into bnb-chain:develop Mar 20, 2024
@Pjrich1313 Pjrich1313 mentioned this pull request Mar 27, 2024
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.

5 participants