Skip to content
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

Feature/rebuild trie from flat #7969

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

garyschulte
Copy link
Contributor

@garyschulte garyschulte commented Dec 2, 2024

PR description

Implement a storage subcommand to rebuild the bonsai state trie from flat db. This subcommand can be used to fix a broken state trie by re-inserting all of the elements from the flat database into the state trie.

usage:

besu --config-file=<config_toml> storage rebuild-bonsai-state-trie

This is a destructive action, but has appropriate safeguards to ensure the state trie reconstruction will be successful.

Fixed Issue(s)

fixes #7934

Thanks for sending a pull request! Have you done the following?

  • Checked out our contribution guidelines?
  • Considered documentation and added the doc-change-required label to this PR if updates are required.
  • Considered the changelog and included an update if required.
  • For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests

Locally, you can run these tests to catch failures early:

  • unit tests: ./gradlew build
  • acceptance tests: ./gradlew acceptanceTest
  • integration tests: ./gradlew integrationTest
  • reference tests: ./gradlew ethereum:referenceTests:referenceTests

@garyschulte garyschulte force-pushed the feature/rebuild-trie-from-flat branch 4 times, most recently from 14437fc to 2cd2b8f Compare December 5, 2024 18:19
Copy link

github-actions bot commented Jan 5, 2025

This pr is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the Stale label Jan 5, 2025
Copy link

This pr was closed because it has been inactive for 14 days since being marked as stale.

@github-actions github-actions bot closed this Jan 20, 2025
@garyschulte
Copy link
Contributor Author

reopening

@garyschulte garyschulte reopened this Jan 22, 2025
@garyschulte garyschulte force-pushed the feature/rebuild-trie-from-flat branch 3 times, most recently from 25ae3ac to 294f98b Compare January 22, 2025 21:01
Signed-off-by: garyschulte <[email protected]>
Signed-off-by: garyschulte <[email protected]>
@garyschulte garyschulte force-pushed the feature/rebuild-trie-from-flat branch from 8a3ad52 to 11194a8 Compare January 22, 2025 22:20
@garyschulte garyschulte marked this pull request as ready for review January 22, 2025 22:21
Copy link
Contributor

@pinges pinges left a comment

Choose a reason for hiding this comment

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

Under what circumstances do we have a "good" flat DB that can be used to rebuild a broken trie? And how do we know that the flat DB is "good"?

@garyschulte
Copy link
Contributor Author

Under what circumstances do we have a "good" flat DB that can be used to rebuild a broken trie? And how do we know that the flat DB is "good"?

In its current incarnation, this is a 'repair' type command. If for example besu ends up with a corrupted worldstate, this will rebuild the state trie from the flat db.

I had this happen on a long running node yesterday where trielog, blockchain and worldstate all ended up at different places on restart due to a kill. When Besu started it attempted to "heal" the worldstate it wrote garbage to the trie. Using this PR I was able to salvage an archive node that had been syncing for quite some time.

Longer term, this subcommand would be useful to rebuild the trie from a state-trie-less full sync strategy, where we can trust the chain head either via static checkpoints we have in the code or from finalized blocks from the CL. That sync method is still a WIP though.

@github-actions github-actions bot removed the Stale label Jan 23, 2025
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.

Subcommand to recreate state trie from flat db
2 participants