diff --git a/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs b/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs index 959a7bcd..047ae6e6 100644 --- a/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs +++ b/crates/ef-testing/src/evm_sequencer/sequencer/mod.rs @@ -30,7 +30,7 @@ use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use cairo_vm::types::errors::program_errors::ProgramError; use sequencer::{sequencer::Sequencer, state::State}; use starknet::core::types::contract::{legacy::LegacyContractClass, CompiledClass}; -use starknet_api::block::{BlockInfo, GasPriceVector, GasPrices}; +use starknet_api::block::BlockInfo; use starknet_api::{ block::{BlockNumber, BlockTimestamp}, core::{ChainId, ClassHash, ContractAddress}, @@ -109,18 +109,7 @@ impl KakarotSequencer { ) .try_into() .expect("Failed to convert to ContractAddress"), - gas_prices: GasPrices { - eth_gas_prices: GasPriceVector { - l1_gas_price: Default::default(), - l1_data_gas_price: Default::default(), - l2_gas_price: Default::default(), - }, - strk_gas_prices: GasPriceVector { - l1_gas_price: Default::default(), - l1_data_gas_price: Default::default(), - l2_gas_price: Default::default(), - }, - }, + gas_prices: Default::default(), use_kzg_da: false, }; @@ -185,11 +174,10 @@ impl DerefMut for KakarotSequencer { pub fn convert_contract_class_v0( class: &LegacyContractClass, ) -> Result { - Result::::Ok(RunnableCompiledClass::V0( - CompiledClassV0::try_from_json_string( - &serde_json::to_string(class).map_err(ProgramError::Parse)?, - )?, - )) + Ok(CompiledClassV0::try_from_json_string( + &serde_json::to_string(class).map_err(ProgramError::Parse)?, + )? + .into()) } pub fn convert_contract_class_v1( @@ -197,9 +185,7 @@ pub fn convert_contract_class_v1( ) -> Result { let casm_contract_class = CasmContractClassWrapper::try_from(class)?; let casm_contract_class: CasmContractClass = casm_contract_class.into(); - Ok(RunnableCompiledClass::V1(CompiledClassV1::try_from( - casm_contract_class, - )?)) + Ok(CompiledClassV1::try_from(casm_contract_class)?.into()) } lazy_static! { diff --git a/crates/ef-testing/src/test_utils/mod.rs b/crates/ef-testing/src/test_utils/mod.rs index efc6c347..518d082d 100644 --- a/crates/ef-testing/src/test_utils/mod.rs +++ b/crates/ef-testing/src/test_utils/mod.rs @@ -22,7 +22,8 @@ pub fn setup() { } pub struct TestMonitor { - thresholds: Vec, // thresholds in seconds + /// thresholds in seconds + thresholds: Vec, } impl TestMonitor { diff --git a/crates/sequencer/src/native.rs b/crates/sequencer/src/native.rs index 7bbdb53f..ae6f9125 100644 --- a/crates/sequencer/src/native.rs +++ b/crates/sequencer/src/native.rs @@ -15,21 +15,14 @@ lazy_static! { } fn generate_library_path(class_hash: ClassHash) -> PathBuf { - let mut path = NATIVE_CACHE_DIR.clone(); - path.push(class_hash.to_string().trim_start_matches("0x")); - path + NATIVE_CACHE_DIR.join(class_hash.to_string().trim_start_matches("0x")) } fn setup_native_cache_dir() -> PathBuf { - let path: PathBuf = match std::env::var("NATIVE_CACHE_DIR") { - Ok(path) => path.into(), - Err(_err) => { - let mut path = std::env::current_dir().unwrap(); - path.push("native_cache"); - path - } - }; - let _ = fs::create_dir_all(&path); + let path = std::env::var("NATIVE_CACHE_DIR") + .map(PathBuf::from) + .unwrap_or_else(|_| std::env::current_dir().unwrap().join("native_cache")); + fs::create_dir_all(&path).ok(); path } diff --git a/crates/sequencer/src/sequencer.rs b/crates/sequencer/src/sequencer.rs index 499f7195..b3c69ac2 100644 --- a/crates/sequencer/src/sequencer.rs +++ b/crates/sequencer/src/sequencer.rs @@ -12,6 +12,7 @@ use blockifier::{ }, }; use starknet_api::core::ContractAddress; +use starknet_api::executable_transaction::AccountTransaction; /// Sequencer is the main struct of the sequencer crate. #[derive(Clone)] @@ -75,15 +76,9 @@ where Transaction::Account(account_tx) => { let tx = &account_tx.tx; match tx { - starknet_api::executable_transaction::AccountTransaction::Invoke(tx) => { - tx.sender_address() - } - starknet_api::executable_transaction::AccountTransaction::Declare(tx) => { - tx.sender_address() - } - starknet_api::executable_transaction::AccountTransaction::DeployAccount(tx) => { - tx.contract_address() - } + AccountTransaction::Invoke(tx) => tx.sender_address(), + AccountTransaction::Declare(tx) => tx.sender_address(), + AccountTransaction::DeployAccount(tx) => tx.contract_address(), } } Transaction::L1Handler(_) => ContractAddress::from(0u8), @@ -132,13 +127,13 @@ mod tests { use starknet::core::types::Felt; use starknet::macros::selector; use starknet_api::abi::abi_utils::get_storage_var_address; - use starknet_api::block::{BlockInfo, GasPriceVector, GasPrices}; + use starknet_api::block::BlockInfo; use starknet_api::block::{BlockNumber, BlockTimestamp}; - use starknet_api::core::{ChainId, ClassHash, ContractAddress, Nonce}; + use starknet_api::core::{ChainId, ClassHash, ContractAddress}; use starknet_api::executable_transaction::{ AccountTransaction as AccountTransactionEnum, InvokeTransaction, }; - use starknet_api::transaction::fields::{Calldata, Fee, TransactionSignature}; + use starknet_api::transaction::fields::{Calldata, Fee}; use starknet_api::transaction::{ InvokeTransaction as InvokeTransactionTypes, InvokeTransactionV1, }; @@ -260,18 +255,7 @@ mod tests { block_number: BlockNumber(1), block_timestamp: BlockTimestamp(1), sequencer_address: *SEQUENCER_ADDRESS, - gas_prices: GasPrices { - eth_gas_prices: GasPriceVector { - l1_gas_price: Default::default(), - l1_data_gas_price: Default::default(), - l2_gas_price: Default::default(), - }, - strk_gas_prices: GasPriceVector { - l1_gas_price: Default::default(), - l1_data_gas_price: Default::default(), - l2_gas_price: Default::default(), - }, - }, + gas_prices: Default::default(), use_kzg_da: false, }; @@ -304,8 +288,7 @@ mod tests { .into(), ), max_fee: Fee(1_000_000), - signature: TransactionSignature(vec![]), - nonce: Nonce(Felt::ZERO), + ..Default::default() }; let transaction = InvokeTransaction::create( InvokeTransactionTypes::V1(invoke_tx), diff --git a/crates/sequencer/src/state.rs b/crates/sequencer/src/state.rs index 45b67515..12c58fb9 100644 --- a/crates/sequencer/src/state.rs +++ b/crates/sequencer/src/state.rs @@ -247,10 +247,7 @@ mod tests { // When state - .set_contract_class( - ClassHash(Felt::ONE), - RunnableCompiledClass::V0(CompiledClassV0::default()), - ) + .set_contract_class(ClassHash(Felt::ONE), CompiledClassV0::default().into()) .unwrap(); // Then