Repository navigation
Conversation
Retain one materialized trie per StateStorage and update only changed paths using immutable nodes. Preserve state-view validation and fallback behavior for custom encoders and unsupported inputs. Add coverage for fork isolation, external writes, mutable buffers, rollback, finalization and historical roots. Validation: 129 focused tests and 11 subtests passed; 1,000 traces passed with 2,000 root comparisons against the existing builder.
This branch has not been deployed
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
State-root calculation rebuilds the entire trie even when only a few entries change. This PR retains an immutable, incremental Merkle trie and updates only the affected paths.
StateStorage, shared bystate_root()andstate_root_at().Each root calculation still materializes the selected state and compares its contents. This preserves detection of external database writes, fork switches, rollback, finalization and independent trace pre-state reloads.
State materialization and comparison remain O(number of entries); the optimization reduces trie reconstruction and hashing work.
Validation
Performance
Local median total trace execution time from three alternating runs per implementation:
Results depend on state size and how many entries change between root calculations. These are local measurements with run-to-run variation.