Skip to content

feat(flashblocks): add streaming state root calculation infrastructure#635

Open
Farukest wants to merge 3 commits intobase:mainfrom
Farukest:feature/streaming-state-root-622
Open

feat(flashblocks): add streaming state root calculation infrastructure#635
Farukest wants to merge 3 commits intobase:mainfrom
Farukest:feature/streaming-state-root-622

Conversation

@Farukest
Copy link
Contributor

Summary

  • Adds StateRootTask module for streaming state root calculation during transaction execution
  • Introduces --flashblocks.streaming-state-root CLI flag to enable the feature
  • Implements channel-based architecture to stream state updates to a background task
  • Reduces finalization latency by pre-fetching trie nodes incrementally

Test plan

  • Verify build compiles without warnings
  • Test with --flashblocks.streaming-state-root=true flag
  • Benchmark finalization latency with streaming vs synchronous state root

Closes #622

Implement a background task that incrementally computes state root
during transaction execution to reduce finalization latency.

- Add StateRootTask module for streaming state updates
- Add --flashblocks.streaming-state-root CLI flag
- Add finalize_payload_with_streaming and build_block_with_state_root
- Pre-fetch trie nodes and build sparse trie incrementally

Closes base#622
@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Jan 31, 2026

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@mw2000
Copy link
Contributor

mw2000 commented Feb 3, 2026

@Farukest took a first pass at the code, for a complete implementation we'd need to have trie node prefetching implemented.

…e root

This implements trie node prefetching as part of the streaming state root
calculation feature. When state updates arrive during transaction execution,
background tasks are spawned to pre-warm the trie cache by computing storage
roots for touched accounts.

Key changes:
- Add spawn_prefetch_tasks() to handle async prefetch spawning
- Add prefetch_storage_root() for cache warming via storage root computation
- Add max_prefetch_tasks config option (default: 64 concurrent tasks)
- Use Arc-wrapped provider for sharing with prefetch tasks
- Add atomic counter to track and limit active prefetch tasks
- Add tests for prefetch enabled/disabled scenarios

This reduces finalization latency by ensuring trie nodes are already in
memory when the final state root computation happens, rather than waiting
for disk I/O at that critical moment.
@Farukest
Copy link
Contributor Author

Farukest commented Feb 3, 2026

@Farukest took a first pass at the code, for a complete implementation we'd need to have trie node prefetching implemented.

@mw2000 handled 👍
thank you

Resolve merge conflicts after op-rbuilder to builder-core refactoring:
- Resolve config.rs content conflict
- Move state_root_task.rs to new crates/builder/core/src/flashblocks/ location
- Update flashblocks/mod.rs to include state_root_task module
- Update lib.rs to export StateRootTask types
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.

feat(flashblocks): Streaming State Root Calculation

3 participants