fix: check for genesis block on pool validator init (#7699)

This commit is contained in:
Matthias Seitz
2024-04-17 15:21:25 +02:00
committed by GitHub
parent 4911febe6f
commit dc39fd68f4
2 changed files with 13 additions and 3 deletions

View File

@ -52,7 +52,14 @@ where
if let Ok(Some(block)) =
this.inner.client().block_by_number_or_tag(reth_primitives::BlockNumberOrTag::Latest)
{
this.update_l1_block_info(&block);
// genesis block has no txs, so we can't extract L1 info, we set the block info to empty
// so that we will accept txs into the pool before the first block
if block.number == 0 {
this.block_info.timestamp.store(block.timestamp, Ordering::Relaxed);
*this.block_info.l1_block_info.write() = Some(Default::default())
} else {
this.update_l1_block_info(&block);
}
}
this
@ -69,8 +76,9 @@ where
/// Update the L1 block info.
fn update_l1_block_info(&self, block: &Block) {
self.block_info.timestamp.store(block.timestamp, Ordering::Relaxed);
let cost_addition = reth_revm::optimism::extract_l1_info(block).ok();
*self.block_info.l1_block_info.write() = cost_addition;
if let Ok(cost_addition) = reth_revm::optimism::extract_l1_info(block) {
*self.block_info.l1_block_info.write() = Some(cost_addition);
}
}
/// Validates a single transaction.

View File

@ -26,6 +26,8 @@ const L1_BLOCK_ECOTONE_SELECTOR: [u8; 4] = hex!("440a5e20");
/// Extracts the [L1BlockInfo] from the L2 block. The L1 info transaction is always the first
/// transaction in the L2 block.
///
/// Returns an error if the L1 info transaction is not found, if the block is empty.
pub fn extract_l1_info(block: &Block) -> Result<L1BlockInfo, BlockExecutionError> {
let l1_info_tx_data = block
.body