Skip to content

Ensure flashblocks build on parent block and pending flashblock is cleared when a new chain is committed #18102

@mattsse

Description

@mattsse

Describe the feature

currently we always use the latest state

pub fn execute(&mut self) -> eyre::Result<PendingBlock<N>> {
let latest = self
.provider
.latest_header()?
.ok_or(EthApiError::HeaderNotFound(BlockNumberOrTag::Latest.into()))?;

however this might not be

/// The parent hash of the block.
pub parent_hash: B256,

so we should not build the block if parent_hash != latest

we also must clear the block when a new block was mined,

for this we can install a Canonstatesubscription via the provider and remove the pending block on tick

Additional context

Checklist:

  • Prevent old pending flashblock from being returned from pending_flashblock
  • State check to ensure we only keep and return a pending flashblock if it is still valid

Metadata

Metadata

Assignees

Labels

A-op-rethRelated to Optimism and op-rethC-bugAn unexpected or incorrect behaviorC-enhancementNew feature or request

Type

No type

Projects

Status

Completed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions