diff --git a/Cargo.toml b/Cargo.toml index a6e14eae7..5f1325091 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -112,7 +112,7 @@ r2d2_sqlite = "0.24.0" rand = "0.8.5" reth-ipc = { tag = "v0.2.0-beta.5", git = "https://github.com/paradigmxyz/reth.git"} reth-rpc-types = { tag = "v1.0.6", git = "https://github.com/paradigmxyz/reth.git"} -revm = { version = "14.0.1", default-features = false, features = ["std", "secp256k1", "serde-json", "optional_block_gas_limit"] } +revm = { version = "14.0.1", default-features = false, features = ["std", "secp256k1", "serde-json"] } revm-primitives = { version = "9.0.1", default-features = false, features = ["std", "serde"] } rpc = { path = "rpc"} rstest = "0.18.2" diff --git a/rpc/src/eth_rpc.rs b/rpc/src/eth_rpc.rs index 1e5060b52..b3cf79b0b 100644 --- a/rpc/src/eth_rpc.rs +++ b/rpc/src/eth_rpc.rs @@ -14,7 +14,7 @@ use ethportal_api::{ ContentValue, EthApiServer, Header, HistoryContentKey, HistoryContentValue, }; use trin_execution::evm::{ - async_db::{execute_transaction_with_evm_modifier, AsyncDatabase}, + async_db::{execute_transaction, AsyncDatabase}, create_block_env, }; use trin_validation::constants::CHAIN_ID; @@ -94,6 +94,7 @@ impl EthApiServer for EthApi { }; Ok(account_info.balance) } + async fn get_storage_at( &self, address: Address, @@ -128,17 +129,18 @@ impl EthApiServer for EthApi { Ok(bytecode.original_bytes()) } - async fn call(&self, transaction: TransactionRequest, block: BlockId) -> RpcResult { + async fn call(&self, mut transaction: TransactionRequest, block: BlockId) -> RpcResult { let evm_block_state = self.evm_block_state(block).await?; - let result_and_state = execute_transaction_with_evm_modifier( + // If gas limit is not set, set it to block's limit + if transaction.gas.is_none() { + transaction.gas = Some(evm_block_state.block_header().gas_limit.to()); + } + + let result_and_state = execute_transaction( create_block_env(evm_block_state.block_header()), transaction, evm_block_state, - |evm| { - // Allow unlimited gas - evm.cfg_mut().disable_block_gas_limit = true; - }, ) .await .map_err(|err| RpcServeError::Message(err.to_string()))?; diff --git a/trin-execution/src/evm/async_db.rs b/trin-execution/src/evm/async_db.rs index 5ff14d70f..b0d5a8cce 100644 --- a/trin-execution/src/evm/async_db.rs +++ b/trin-execution/src/evm/async_db.rs @@ -1,6 +1,6 @@ use std::future::Future; -use revm::{Database, Evm}; +use revm::Database; use revm_primitives::{AccountInfo, Address, BlockEnv, Bytecode, EVMError, EVMResult, B256, U256}; use tokio::{runtime, task}; @@ -76,20 +76,6 @@ pub async fn execute_transaction( tx: Tx, db: DB, ) -> EVMResult -where - DB: AsyncDatabase + Send + 'static, - DBError: Send + 'static, - Tx: TxEnvModifier + Send + 'static, -{ - execute_transaction_with_evm_modifier(block_env, tx, db, |_| {}).await -} - -pub async fn execute_transaction_with_evm_modifier( - block_env: BlockEnv, - tx: Tx, - db: DB, - evm_modifier: impl FnOnce(&mut Evm<'_, (), &mut WrapAsyncDatabase>) + Send + 'static, -) -> EVMResult where DB: AsyncDatabase + Send + 'static, DBError: Send + 'static, @@ -99,7 +85,6 @@ where let rt = runtime::Runtime::new().expect("to create Runtime within spawn_blocking"); let mut db = WrapAsyncDatabase::new(db, rt); let mut evm = create_evm(block_env, &tx, &mut db); - evm_modifier(&mut evm); evm.transact() }) .await