diff --git a/execution/src/evm.rs b/execution/src/evm.rs index 311ba2c..77ecb3d 100644 --- a/execution/src/evm.rs +++ b/execution/src/evm.rs @@ -36,7 +36,7 @@ impl Evm { } pub fn call(&mut self, opts: &CallOpts) -> Result> { - let account_map = self.batch_fetch_accounts(opts); + let account_map = self.batch_fetch_accounts(opts)?; self.evm.db.as_mut().unwrap().set_accounts(account_map); self.evm.env = self.get_env(opts); @@ -54,7 +54,7 @@ impl Evm { } pub fn estimate_gas(&mut self, opts: &CallOpts) -> Result { - let account_map = self.batch_fetch_accounts(opts); + let account_map = self.batch_fetch_accounts(opts)?; self.evm.db.as_mut().unwrap().set_accounts(account_map); self.evm.env = self.get_env(opts); @@ -68,7 +68,7 @@ impl Evm { Ok(gas_scaled) } - fn batch_fetch_accounts(&self, opts: &CallOpts) -> HashMap { + fn batch_fetch_accounts(&self, opts: &CallOpts) -> Result> { let db = self.evm.db.as_ref().unwrap(); let rpc = db.execution.rpc.clone(); let payload = db.payload.clone(); @@ -124,7 +124,7 @@ impl Evm { Ok::<_, eyre::Error>(accounts) }); - let accounts = handle.join().unwrap().unwrap(); + let accounts = handle.join().unwrap()?; let mut account_map = HashMap::new(); accounts.iter().for_each(|account| { let addr = account.0; @@ -132,7 +132,7 @@ impl Evm { account_map.insert(addr, account); }); - account_map + Ok(account_map) } fn get_env(&self, opts: &CallOpts) -> Env { diff --git a/execution/src/rpc/http_rpc.rs b/execution/src/rpc/http_rpc.rs index a7f50d6..57091dd 100644 --- a/execution/src/rpc/http_rpc.rs +++ b/execution/src/rpc/http_rpc.rs @@ -58,18 +58,19 @@ impl Rpc for HttpRpc { async fn create_access_list(&self, opts: &CallOpts, block: u64) -> Result { let block = Some(BlockId::from(block)); - let mut tx = Eip1559TransactionRequest::new(); - tx.to = Some(opts.to.into()); - tx.from = opts.from; - tx.value = opts.value; - // TODO: better way to set gas limit - tx.gas = Some(U256::from(10_000_000)); - tx.data = opts + let mut raw_tx = Eip1559TransactionRequest::new(); + raw_tx.to = Some(opts.to.into()); + raw_tx.from = opts.from; + raw_tx.value = opts.value; + raw_tx.gas = Some(opts.gas.unwrap_or(U256::from(100_000_000))); + raw_tx.max_fee_per_gas = Some(U256::zero()); + raw_tx.max_priority_fee_per_gas = Some(U256::zero()); + raw_tx.data = opts .data .as_ref() .map(|data| Bytes::from(data.as_slice().to_owned())); - let tx = TypedTransaction::Eip1559(tx); + let tx = TypedTransaction::Eip1559(raw_tx); let list = self.provider.create_access_list(&tx, block).await?; Ok(list.access_list) diff --git a/execution/tests/execution.rs b/execution/tests/execution.rs index 0409146..555eac9 100644 --- a/execution/tests/execution.rs +++ b/execution/tests/execution.rs @@ -2,7 +2,6 @@ use std::collections::BTreeMap; use std::str::FromStr; use ethers::types::{Address, H256, U256}; -use ethers::utils::keccak256; use ssz_rs::{List, Vector}; use common::utils::hex_str_to_bytes;