mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix: check for genesis block on pool validator init (#7699)
This commit is contained in:
@ -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.
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user