From 6d3f1ab98ea2a3b8e3b5a80048ccd2c930f11772 Mon Sep 17 00:00:00 2001 From: refcell Date: Fri, 31 Jan 2025 18:50:57 -0500 Subject: [PATCH] fix(executor): removed eips --- Cargo.lock | 4 +- crates/executor/src/executor/mod.rs | 21 +----- crates/executor/src/syscalls/eip7002.rs | 92 ------------------------- crates/executor/src/syscalls/eip7251.rs | 91 ------------------------ crates/executor/src/syscalls/mod.rs | 6 -- 5 files changed, 3 insertions(+), 211 deletions(-) delete mode 100644 crates/executor/src/syscalls/eip7002.rs delete mode 100644 crates/executor/src/syscalls/eip7251.rs diff --git a/Cargo.lock b/Cargo.lock index 7ad1b115e..3aa27d5a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1158,9 +1158,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.10" +version = "1.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" +checksum = "e4730490333d58093109dc02c23174c3f4d490998c3fed3cc8e82d57afedb9cf" dependencies = [ "jobserver", "libc", diff --git a/crates/executor/src/executor/mod.rs b/crates/executor/src/executor/mod.rs index 1b061797c..842dd2ef4 100644 --- a/crates/executor/src/executor/mod.rs +++ b/crates/executor/src/executor/mod.rs @@ -6,8 +6,7 @@ use crate::{ errors::TrieDBError, syscalls::{ ensure_create2_deployer_canyon, pre_block_beacon_root_contract_call, - pre_block_block_hash_contract_call, pre_block_consolidation_requests_contract_call, - pre_block_withdrawals_request_contract_call, + pre_block_block_hash_contract_call, }, ExecutorError, ExecutorResult, TrieDBProvider, }; @@ -164,24 +163,6 @@ where &payload, )?; - // Apply the pre-block EIP-7002 contract call. - pre_block_withdrawals_request_contract_call( - &mut state, - self.config, - &initialized_cfg, - &initialized_block_env, - &payload, - )?; - - // Apply the pre-block EIP-7251 contract call. - pre_block_consolidation_requests_contract_call( - &mut state, - self.config, - &initialized_cfg, - &initialized_block_env, - &payload, - )?; - // Ensure that the create2 contract is deployed upon transition to the Canyon hardfork. ensure_create2_deployer_canyon( &mut state, diff --git a/crates/executor/src/syscalls/eip7002.rs b/crates/executor/src/syscalls/eip7002.rs deleted file mode 100644 index c75432502..000000000 --- a/crates/executor/src/syscalls/eip7002.rs +++ /dev/null @@ -1,92 +0,0 @@ -//! Contains the logic for executing the pre-block withdrawals request call. - -use crate::{ - db::TrieDB, - errors::{ExecutorError, ExecutorResult}, - syscalls::fill_tx_env_for_contract_call, - TrieDBProvider, -}; -use alloc::boxed::Box; -use alloy_primitives::Bytes; -use kona_mpt::TrieHinter; -use maili_genesis::RollupConfig; -use op_alloy_rpc_types_engine::OpPayloadAttributes; -use revm::{ - db::State, - primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg}, - DatabaseCommit, Evm, -}; - -/// Execute the EIP-7002 pre-block withdrawals request contract call. -pub(crate) fn pre_block_withdrawals_request_contract_call( - db: &mut State<&mut TrieDB>, - config: &RollupConfig, - initialized_cfg: &CfgEnvWithHandlerCfg, - initialized_block_env: &BlockEnv, - payload: &OpPayloadAttributes, -) -> ExecutorResult<()> -where - F: TrieDBProvider, - H: TrieHinter, -{ - // apply pre-block EIP-4788 contract call - let mut evm_pre_block = Evm::builder() - .with_db(db) - .with_env_with_handler_cfg(EnvWithHandlerCfg::new_with_cfg_env( - initialized_cfg.clone(), - initialized_block_env.clone(), - Default::default(), - )) - .build(); - - // initialize a block from the env, because the pre block call needs the block itself - apply_withdrawals_request_contract_call( - config, - payload.payload_attributes.timestamp, - &mut evm_pre_block, - ) -} - -/// Apply the EIP-7002 pre-block withdrawals request contract call to a given EVM instance. -fn apply_withdrawals_request_contract_call( - config: &RollupConfig, - timestamp: u64, - evm: &mut Evm<'_, (), &mut State<&mut TrieDB>>, -) -> ExecutorResult<()> -where - F: TrieDBProvider, - H: TrieHinter, -{ - if !config.is_isthmus_active(timestamp) { - return Ok(()); - } - - // Get the previous environment - let previous_env = Box::new(evm.context.evm.env().clone()); - - // modify env for pre block call - fill_tx_env_for_contract_call( - &mut evm.context.evm.env, - alloy_eips::eip7002::SYSTEM_ADDRESS, - alloy_eips::eip7002::WITHDRAWAL_REQUEST_PREDEPLOY_ADDRESS, - Bytes::new(), - ); - - let mut state = match evm.transact() { - Ok(res) => res.state, - Err(e) => { - evm.context.evm.env = previous_env; - return Err(ExecutorError::ExecutionError(e)); - } - }; - - state.remove(&alloy_eips::eip7002::SYSTEM_ADDRESS); - state.remove(&evm.block().coinbase); - - evm.context.evm.db.commit(state); - - // re-set the previous env - evm.context.evm.env = previous_env; - - Ok(()) -} diff --git a/crates/executor/src/syscalls/eip7251.rs b/crates/executor/src/syscalls/eip7251.rs deleted file mode 100644 index 19041e00a..000000000 --- a/crates/executor/src/syscalls/eip7251.rs +++ /dev/null @@ -1,91 +0,0 @@ -//! Contains the logic for the EIP-7251 syscall. - -use crate::{ - db::TrieDB, - errors::{ExecutorError, ExecutorResult}, - syscalls::fill_tx_env_for_contract_call, - TrieDBProvider, -}; -use alloc::boxed::Box; -use alloy_primitives::Bytes; -use kona_mpt::TrieHinter; -use maili_genesis::RollupConfig; -use op_alloy_rpc_types_engine::OpPayloadAttributes; -use revm::{ - db::State, - primitives::{BlockEnv, CfgEnvWithHandlerCfg, EnvWithHandlerCfg}, - DatabaseCommit, Evm, -}; - -/// Execute the EIP-7251 pre-block beacon root contract call. -pub(crate) fn pre_block_consolidation_requests_contract_call( - db: &mut State<&mut TrieDB>, - config: &RollupConfig, - initialized_cfg: &CfgEnvWithHandlerCfg, - initialized_block_env: &BlockEnv, - payload: &OpPayloadAttributes, -) -> ExecutorResult<()> -where - F: TrieDBProvider, - H: TrieHinter, -{ - let mut evm_pre_block = Evm::builder() - .with_db(db) - .with_env_with_handler_cfg(EnvWithHandlerCfg::new_with_cfg_env( - initialized_cfg.clone(), - initialized_block_env.clone(), - Default::default(), - )) - .build(); - - // initialize a block from the env, because the pre block call needs the block itself - apply_consolidation_requests_contract_call( - config, - payload.payload_attributes.timestamp, - &mut evm_pre_block, - ) -} - -/// Apply the EIP-7251 pre-block consolidation requests contract call to a given EVM instance. -fn apply_consolidation_requests_contract_call( - config: &RollupConfig, - timestamp: u64, - evm: &mut Evm<'_, (), &mut State<&mut TrieDB>>, -) -> ExecutorResult<()> -where - F: TrieDBProvider, - H: TrieHinter, -{ - if !config.is_isthmus_active(timestamp) { - return Ok(()); - } - - // Get the previous environment - let previous_env = Box::new(evm.context.evm.env().clone()); - - // modify env for pre block call - fill_tx_env_for_contract_call( - &mut evm.context.evm.env, - alloy_eips::eip7002::SYSTEM_ADDRESS, - alloy_eips::eip7251::CONSOLIDATION_REQUEST_PREDEPLOY_ADDRESS, - Bytes::new(), - ); - - let mut state = match evm.transact() { - Ok(res) => res.state, - Err(e) => { - evm.context.evm.env = previous_env; - return Err(ExecutorError::ExecutionError(e)); - } - }; - - state.remove(&alloy_eips::eip7002::SYSTEM_ADDRESS); - state.remove(&evm.block().coinbase); - - evm.context.evm.db.commit(state); - - // re-set the previous env - evm.context.evm.env = previous_env; - - Ok(()) -} diff --git a/crates/executor/src/syscalls/mod.rs b/crates/executor/src/syscalls/mod.rs index 64163a2db..2071a2e10 100644 --- a/crates/executor/src/syscalls/mod.rs +++ b/crates/executor/src/syscalls/mod.rs @@ -3,12 +3,6 @@ mod eip2935; pub(crate) use eip2935::pre_block_block_hash_contract_call; -mod eip7002; -pub(crate) use eip7002::pre_block_withdrawals_request_contract_call; - -mod eip7251; -pub(crate) use eip7251::pre_block_consolidation_requests_contract_call; - mod eip4788; pub(crate) use eip4788::pre_block_beacon_root_contract_call;