From 8fd4e8f719d8448794618afdafa14a5f8cfab50f Mon Sep 17 00:00:00 2001 From: refcell Date: Mon, 13 Jan 2025 12:09:47 -0700 Subject: [PATCH] fix: fmts --- crates/optimism/src/evm.rs | 2 +- crates/optimism/src/handler.rs | 10 ++++---- crates/optimism/src/l1block.rs | 42 ++++++++++++++++++---------------- crates/optimism/src/lib.rs | 4 ++-- 4 files changed, 30 insertions(+), 28 deletions(-) diff --git a/crates/optimism/src/evm.rs b/crates/optimism/src/evm.rs index 0c29e2f7860..4b1270eda7f 100644 --- a/crates/optimism/src/evm.rs +++ b/crates/optimism/src/evm.rs @@ -8,8 +8,8 @@ use inspector::{inspector_context::InspectorContext, InspectorEthFrame}; use maili_protocol::L1BlockInfoTx; use revm::{ context::{block::BlockEnv, tx::TxEnv, CfgEnv, Context}, - context_interface::Journal, context_interface::result::{EVMError, InvalidTransaction}, + context_interface::Journal, database_interface::Database, Evm, JournaledState, }; diff --git a/crates/optimism/src/handler.rs b/crates/optimism/src/handler.rs index 3604cfcffb1..91934ee5350 100644 --- a/crates/optimism/src/handler.rs +++ b/crates/optimism/src/handler.rs @@ -3,13 +3,13 @@ pub mod precompiles; use crate::{ + calculate_tx_l1_cost, transaction::{ abstraction::OpTxGetter, deposit::{DepositTransaction, DEPOSIT_TRANSACTION_TYPE}, OpTransactionError, OpTxTrait, }, - calculate_tx_l1_cost, - L1BlockInfoGetter, OpSpec, OpSpecId, OptimismHaltReason, L1_FEE_RECIPIENT, BASE_FEE_RECIPIENT, + L1BlockInfoGetter, OpSpec, OpSpecId, OptimismHaltReason, BASE_FEE_RECIPIENT, L1_FEE_RECIPIENT, }; use maili_protocol::L1BlockInfoTx; use precompiles::OpPrecompileProvider; @@ -114,8 +114,7 @@ where // The L1-cost fee is only computed for Optimism non-deposit transactions. let spec = context.cfg().spec(); if context.tx().tx_type() != DEPOSIT_TRANSACTION_TYPE { - let l1_block_info: L1BlockInfoTx = - crate::l1block::try_fetch(context.db(), spec)?; + let l1_block_info: L1BlockInfoTx = crate::l1block::try_fetch(context.db(), spec)?; // Storage L1 block info for later use. *context.l1_block_info_mut() = l1_block_info; @@ -149,7 +148,8 @@ where .expect("all not deposit tx have enveloped tx") .clone(); - tx_l1_cost = calculate_tx_l1_cost(context.l1_block_info(), &enveloped_tx, context.cfg().spec()); + tx_l1_cost = + calculate_tx_l1_cost(context.l1_block_info(), &enveloped_tx, context.cfg().spec()); } // We deduct caller max balance after minting and before deducing the diff --git a/crates/optimism/src/l1block.rs b/crates/optimism/src/l1block.rs index 4e4280e38cd..76a1528bcf3 100644 --- a/crates/optimism/src/l1block.rs +++ b/crates/optimism/src/l1block.rs @@ -1,14 +1,14 @@ use crate::OpSpecId; +use maili_protocol::{ + calculate_tx_l1_cost_bedrock, calculate_tx_l1_cost_bedrock_empty_scalars, + calculate_tx_l1_cost_ecotone, calculate_tx_l1_cost_fjord, calculate_tx_l1_cost_regolith, + L1BlockInfoBedrock, L1BlockInfoEcotone, L1BlockInfoTx, +}; use revm::{ database_interface::Database, - primitives::{address, Bytes, Address, U256}, + primitives::{address, Address, Bytes, U256}, specification::hardfork::SpecId, }; -use maili_protocol::{ - L1BlockInfoEcotone, L1BlockInfoBedrock, L1BlockInfoTx, calculate_tx_l1_cost_bedrock, calculate_tx_l1_cost_ecotone, calculate_tx_l1_cost_fjord, - calculate_tx_l1_cost_bedrock_empty_scalars, - calculate_tx_l1_cost_regolith, -}; use super::OpSpec; @@ -96,9 +96,8 @@ pub fn try_fetch(db: &mut DB, spec_id: OpSpec) -> Result::try_into( - db.storage(L1_BLOCK_CONTRACT, L1_BASE_FEE_SLOT)?, - ).unwrap(); + let l1_base_fee = + TryInto::::try_into(db.storage(L1_BLOCK_CONTRACT, L1_BASE_FEE_SLOT)?).unwrap(); if !spec_id.is_enabled_in(OpSpecId::ECOTONE) { let l1_fee_overhead = db.storage(L1_BLOCK_CONTRACT, L1_OVERHEAD_SLOT)?; @@ -111,20 +110,22 @@ pub fn try_fetch(db: &mut DB, spec_id: OpSpec) -> Result::try_into(db.storage(L1_BLOCK_CONTRACT, ECOTONE_L1_BLOB_BASE_FEE_SLOT)?).unwrap(); + let l1_blob_base_fee = TryInto::::try_into( + db.storage(L1_BLOCK_CONTRACT, ECOTONE_L1_BLOB_BASE_FEE_SLOT)?, + ) + .unwrap(); let l1_fee_scalars = db .storage(L1_BLOCK_CONTRACT, ECOTONE_L1_FEE_SCALARS_SLOT)? .to_be_bytes::<32>(); - let l1_base_fee_scalar = TryInto::::try_into(U256::from_be_slice( - l1_fee_scalars[BASE_FEE_SCALAR_OFFSET..BASE_FEE_SCALAR_OFFSET + 4] - .as_ref(), - )).unwrap(); + l1_fee_scalars[BASE_FEE_SCALAR_OFFSET..BASE_FEE_SCALAR_OFFSET + 4].as_ref(), + )) + .unwrap(); let l1_blob_base_fee_scalar = TryInto::::try_into(U256::from_be_slice( - l1_fee_scalars[BLOB_BASE_FEE_SCALAR_OFFSET..BLOB_BASE_FEE_SCALAR_OFFSET + 4] - .as_ref(), - )).unwrap(); + l1_fee_scalars[BLOB_BASE_FEE_SCALAR_OFFSET..BLOB_BASE_FEE_SCALAR_OFFSET + 4].as_ref(), + )) + .unwrap(); // Check if the L1 fee scalars are empty. If so, we use the Bedrock cost function. // The L1 fee overhead is only necessary if `empty_scalars` is true, as it was deprecated in Ecotone. @@ -150,8 +151,8 @@ pub fn try_fetch(db: &mut DB, spec_id: OpSpec) -> Result