perf(store): precompute account state forest mutations during block application#2341
Open
kkovaacs wants to merge 17 commits into
Open
perf(store): precompute account state forest mutations during block application#2341kkovaacs wants to merge 17 commits into
kkovaacs wants to merge 17 commits into
Conversation
Forest preparation now returns typed errors for duplicate lineages, missing roots, and underlying forest failures instead of panicking.
…updates Full-state database updates now consume precomputed vault and storage roots instead of reconstructing Account and repeating SMT work.
kkovaacs
marked this pull request as ready for review
July 15, 2026 14:08
sergerad
reviewed
Jul 15, 2026
| // The DB is now committed. Keep both write locks held while advancing the forest and | ||
| // canonical in-memory state so readers cannot observe different block heights. | ||
| let InnerState { nullifier_tree, blockchain, account_tree } = inner; | ||
| Self::finalize_committed_state( |
Collaborator
There was a problem hiding this comment.
nit: this fn name and complete_post_commit_update could maybe indicate failure is fatal. Ignore if you can't think of better fn names.
sergerad
reviewed
Jul 15, 2026
| ) where | ||
| ForestError: Display, | ||
| NullifierError: Display, | ||
| AccountError: Display, |
Collaborator
There was a problem hiding this comment.
This function is quite awkward (taking closures, Display trait bound, the PostCommiteStateComponent enum) and AFAICT its really only to support the tests. Is there another way we could factor this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #2111.
Precompute account-state forest mutations before applying a block to SQLite. This allows the database layer to reuse the vault and storage-map roots produced by the forest instead of reconstructing the same SMTs from persisted account data.
Changes
Store
Createreplacement semantics, including empty maps.Commit consistency
Benchmarks and stress testing
seed-storeto:Benchmark results show that a single update to a storage map with 500k entries now takes about 50ms.
Changelog