feat(flashblock): improve state root calculation condition#19667
feat(flashblock): improve state root calculation condition#19667mattsse merged 5 commits intoparadigmxyz:mainfrom
Conversation
b7cc010 to
6546187
Compare
6546187 to
a679ba1
Compare
mattsse
left a comment
There was a problem hiding this comment.
this is great, only have two last nits
| /// 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, | ||
| } |
crates/optimism/rpc/src/eth/mod.rs
Outdated
| 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())); |
There was a problem hiding this comment.
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
reth/crates/optimism/rpc/src/eth/mod.rs
Line 390 in 7a599dc
like we do with flashblocks url:
reth/crates/optimism/node/src/node.rs
Line 196 in 7a599dc
reth/crates/optimism/node/src/node.rs
Line 838 in 7a599dc
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
I see, so we do want to use this entirely without op-node. In that case, I'll add back the tracking feature
|
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 |
* 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)
Towards: #18255
Improve flashblock state_root calculation condition