Skip to content

cache recent flashblock sequences #18373

@mattsse

Description

@mattsse

Describe the feature

currently we clear the tracked flashblock:

// Clears the state and broadcasts the blocks produced to subscribers.
fn clear_and_broadcast_blocks(&mut self) {
let flashblocks = mem::take(&mut self.inner);

what we should be doing is also take the local height into account and try caching like 3 blocks, e.g. head is N, and flashblocks are already ticking and N + X
then we should cache the flashblocks if distance X - N is within, let's do 3 blocks for now.

and then pick the proper block when we execute:

fn build_args(
&mut self,
) -> Option<BuildArgs<impl IntoIterator<Item = WithEncoded<Recovered<N::SignedTx>>>>> {
let Some(base) = self.blocks.payload_base() else {
trace!(
flashblock_number = ?self.blocks.block_number(),
count = %self.blocks.count(),
"Missing flashblock payload base"
);
return None
};
// attempt an initial consecutive check
if let Some(latest) = self.builder.provider().latest_header().ok().flatten() {
if latest.hash() != base.parent_hash {
trace!(flashblock_parent=?base.parent_hash, flashblock_number=base.block_number, local_latest=?latest.num_hash(), "Skipping non consecutive build attempt");
return None;
}
}

this requires a smol redesign because then the local header guides flashblock selection
in case local N + 1 is X - 2 for example.

TODO

  • introduce basic cache (like a vecqueue)
  • change selection logic so that local head is used when selecting the flashblock for building

Additional context

No response

Metadata

Metadata

Assignees

Labels

A-op-rethRelated to Optimism and op-rethA-rpcRelated to the RPC implementationC-enhancementNew feature or requestD-good-first-issueNice and easy! A great choice to get started

Type

No type

Projects

Status

Backlog

Relationships

None yet

Development

No branches or pull requests

Issue actions