Skip to content

Add incremental trie cache optimization for flashblocks state root calculation#427

Merged
julio4 merged 8 commits intomainfrom
feature/cliff/optimize-stateroot-calculation
Mar 5, 2026
Merged

Add incremental trie cache optimization for flashblocks state root calculation#427
julio4 merged 8 commits intomainfrom
feature/cliff/optimize-stateroot-calculation

Conversation

@julio4
Copy link
Member

@julio4 julio4 commented Mar 5, 2026

Rebased from #385 with slight trie updates allocation improvements.
@cliff0412

cliff0412 and others added 8 commits March 5, 2026 12:56
Apply trie updates to FlashblocksState via a local cache instead of
mutating through Option in the state-root block. Cache trie updates in
trie_updates_to_cache and set prev_trie_updates when consuming
fb_state later, so the signature can stay fb_state: Option<&mut FlashblocksState>
without requiring mut on the parameter.

Made-with: Cursor
@julio4 julio4 merged commit 47b04f5 into main Mar 5, 2026
4 checks passed
@julio4 julio4 deleted the feature/cliff/optimize-stateroot-calculation branch March 5, 2026 12:49
Vui-Chee added a commit to okx/xlayer-reth that referenced this pull request Mar 9, 2026
Align with upstream flashbots/op-rbuilder#427:
- Wrap trie_output in Arc once upfront instead of cloning then wrapping
- Reuse same Arc allocation for both executed block and fb_state cache
- Remove trie cache benchmark and related dev dependencies (criterion, reth-trie-db)
louisliu2048 pushed a commit to okx/xlayer-reth that referenced this pull request Mar 10, 2026
…ate root (#163)

* feat(builder): port incremental trie cache optimization for flashblocks state root

Port flashbots/op-rbuilder#385 - caches TrieUpdates after each flashblock
state root calculation so subsequent flashblocks reuse cached trie nodes
instead of recomputing from the database each time, achieving ~2.4-2.5x
speedup in state root calculation.

Changes:
- Add `prev_trie_updates: Option<Arc<TrieUpdates>>` field to FlashblocksState
- Use `state_root_from_nodes_with_updates` with cached trie on subsequent flashblocks
- Cache trie updates after each calculation and propagate to next flashblock
- Add criterion benchmark: bench_flashblocks_state_root
- Add reth-trie-db and criterion workspace dependencies

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* perf: remove trie updates clone and allocation, remove benchmarks

Align with upstream flashbots/op-rbuilder#427:
- Wrap trie_output in Arc once upfront instead of cloning then wrapping
- Reuse same Arc allocation for both executed block and fb_state cache
- Remove trie cache benchmark and related dev dependencies (criterion, reth-trie-db)

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

3 participants