Skip to content

feat(flashblock): improve state root calculation condition#19667

Merged
mattsse merged 5 commits intoparadigmxyz:mainfrom
0x00101010:state-root-calc-cond
Nov 16, 2025
Merged

feat(flashblock): improve state root calculation condition#19667
mattsse merged 5 commits intoparadigmxyz:mainfrom
0x00101010:state-root-calc-cond

Conversation

@0x00101010
Copy link
Contributor

@0x00101010 0x00101010 commented Nov 12, 2025

Towards: #18255

Improve flashblock state_root calculation condition

@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Nov 12, 2025
@0x00101010 0x00101010 force-pushed the state-root-calc-cond branch 2 times, most recently from b7cc010 to 6546187 Compare November 12, 2025 05:06
@0x00101010 0x00101010 marked this pull request as ready for review November 12, 2025 18:40
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

this is great, only have two last nits

Comment on lines +16 to +23
/// Outcome from executing a flashblock sequence.
#[derive(Debug, Clone, Copy)]
pub struct SequenceExecutionOutcome {
/// The block hash of the executed pending block
pub block_hash: B256,
/// Properly computed state root
pub state_root: B256,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is better, yes

Comment on lines 520 to 525
info!(target: "reth::cli", "Launching FlashBlockConsensusClient");
let flashblock_client = FlashBlockConsensusClient::new(
ctx.engine_handle.clone(),
flashblocks_sequence.subscribe(),
)?;
ctx.components.task_executor().spawn(Box::pin(flashblock_client.run()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need one more setting for this

maybe we call this --flashblock-consensus or --flashblock-engine ?

the we wire from cli to Opethapibuilder

pub struct OpEthApiBuilder<NetworkT = Optimism> {

like we do with flashblocks url:

.with_flashblocks(self.args.flashblocks_url.clone())

.with_flashblocks(flashblocks_url),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, also reworked FlashblockConsensusClient a little

let fcu_state = alloy_rpc_types_engine::ForkchoiceState {
head_block_hash: block_hash,
safe_block_hash: B256::ZERO,
finalized_block_hash: B256::ZERO,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this works once the node caught up, but if you want to sync a new node via flashblocks then we also need to choose a finalized block so we can kick off p2p backfill sync

I think we could simply use the parent block here for now?

ideally we track the some recent blocks based on 32slots*6secs blocks here and assume that new blocks are being built on the canonical chain

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see, so we do want to use this entirely without op-node. In that case, I'll add back the tracking feature

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Nov 13, 2025
@mattsse mattsse added C-enhancement New feature or request A-op-reth Related to Optimism and op-reth labels Nov 13, 2025
@0x00101010 0x00101010 requested a review from mattsse November 14, 2025 02:37
@0x00101010
Copy link
Contributor Author

However there is one major bug with Base (or any chain that does not send state root from builder), currently consensus client is setup to only compute state root when latest header = base.parent, that makes sense because you can't otherwise.

However if we're purely using flashblocks information to drive chain forward, we need a way to cache the flashblocks information until chain catches up to the parent of first complete flashblock sequence we have to be able to compute the state_root

That might be very memory heavy or not possible if we're syncing from genesis or even a long distance away.

One way to address this is to have another url pointing to a public rpc to get the latest head continuously and call FCU to drive the chain forward until flashblock was able to compute / catch up.

Seems kinda weird, but this might be the best way to completely avoid op-node. Let me know if this is some feature that we really want, if so, I can go ahead and implement it.

Other ideas welcome

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

last nit

@mattsse mattsse added this pull request to the merge queue Nov 16, 2025
@mattsse mattsse added the M-changelog This change should be included in the changelog label Nov 16, 2025
Merged via the queue into paradigmxyz:main with commit 5866a82 Nov 16, 2025
42 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Nov 16, 2025
Vui-Chee added a commit to okx/reth that referenced this pull request Dec 11, 2025
* dev:
  chore: Update cargo deps (#65)
  feat(flashblock): Enable eth_getTransactionByHash support for flashblock (paradigmxyz#19954)
  feat(flashblocks): Cache recent flashblocks (paradigmxyz#19786)
  feat(flashblock): improve state root calculation condition (paradigmxyz#19667)
  feat(flashblocks): add metrics for current block and index (paradigmxyz#19712)
  refactor(flashblock): Move all flashblocks related data structure to op-alloy (paradigmxyz#19608)
  chore: add target: flashblock for all flashblock related traces (paradigmxyz#19656)
  feat(metrics): implement RAII-based block timing with Prometheus support (#60)
  Fix fmt (#62)
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Jan 22, 2026
theochap pushed a commit to ethereum-optimism/optimism that referenced this pull request Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-op-reth Related to Optimism and op-reth C-enhancement New feature or request M-changelog This change should be included in the changelog

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants