From 7015026af64603e0de5fab45ae8c8635d42a3710 Mon Sep 17 00:00:00 2001 From: refcell Date: Fri, 3 Jan 2025 17:49:41 -0500 Subject: [PATCH] chore: Isthmus Withdrawals Root (#881) * chore: isthmus withdrawals root * chore: isthmus withdrawals root --- crates/executor/src/executor/mod.rs | 40 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/crates/executor/src/executor/mod.rs b/crates/executor/src/executor/mod.rs index 2a92d6dc0..bb5ba7440 100644 --- a/crates/executor/src/executor/mod.rs +++ b/crates/executor/src/executor/mod.rs @@ -59,6 +59,19 @@ where StatelessL2BlockExecutorBuilder::new(config, provider, hinter) } + /// Fetches the L2 to L1 message passer account from the cache or underlying trie. + fn message_passer_account(db: &mut TrieDB) -> Result { + match db.storage_roots().get(&L2_TO_L1_BRIDGE) { + Some(storage_root) => { + storage_root.blinded_commitment().ok_or(TrieDBError::RootNotBlinded) + } + None => Ok(db + .get_trie_account(&L2_TO_L1_BRIDGE)? + .ok_or(TrieDBError::MissingAccountInfo)? + .storage_root), + } + } + /// Executes the given block, returning the resulting state root. /// /// ## Steps @@ -260,11 +273,17 @@ where // The withdrawals root on OP Stack chains, after Canyon activation, is always the empty // root hash. - let withdrawals_root = self + let mut withdrawals_root = self .config .is_canyon_active(payload.payload_attributes.timestamp) .then_some(EMPTY_ROOT_HASH); + // If the Isthmus hardfork is active, the withdrawals root is the L2 to L1 message passer + // account. + if self.config.is_isthmus_active(payload.payload_attributes.timestamp) { + withdrawals_root = Some(Self::message_passer_account(state.database)?); + } + // Compute logs bloom filter for the block. let logs_bloom = logs_bloom(receipts.iter().flat_map(|receipt| receipt.logs())); @@ -299,9 +318,12 @@ where .transpose()? .unwrap_or_default(); + // Compute the parent hash. + let parent_hash = state.database.parent_block_header().seal(); + // Construct the new header. let header = Header { - parent_hash: state.database.parent_block_header().seal(), + parent_hash, ommers_hash: EMPTY_OMMER_ROOT_HASH, beneficiary: payload.payload_attributes.suggested_fee_recipient, state_root, @@ -353,19 +375,7 @@ where /// - `Ok(output_root)`: The computed output root. /// - `Err(_)`: If an error occurred while computing the output root. pub fn compute_output_root(&mut self) -> ExecutorResult { - // Fetch the L2 to L1 message passer account from the cache or underlying trie. - let storage_root = match self.trie_db.storage_roots().get(&L2_TO_L1_BRIDGE) { - Some(storage_root) => { - storage_root.blinded_commitment().ok_or(TrieDBError::RootNotBlinded)? - } - None => { - self.trie_db - .get_trie_account(&L2_TO_L1_BRIDGE)? - .ok_or(TrieDBError::MissingAccountInfo)? - .storage_root - } - }; - + let storage_root = Self::message_passer_account(&mut self.trie_db)?; let parent_header = self.trie_db.parent_block_header(); info!(