diff --git a/crates/blockifier/src/blockifier/stateful_validator.rs b/crates/blockifier/src/blockifier/stateful_validator.rs index 3c6a8606dd..7453e1bd16 100644 --- a/crates/blockifier/src/blockifier/stateful_validator.rs +++ b/crates/blockifier/src/blockifier/stateful_validator.rs @@ -84,7 +84,7 @@ impl StatefulValidator { } fn execute(&mut self, tx: AccountTransaction) -> StatefulValidatorResult<()> { - self.tx_executor.execute(&Transaction::AccountTransaction(tx))?; + self.tx_executor.execute(&Transaction::Account(tx))?; Ok(()) } diff --git a/crates/blockifier/src/blockifier/transaction_executor_test.rs b/crates/blockifier/src/blockifier/transaction_executor_test.rs index b3f649d5c4..d09b0d62e2 100644 --- a/crates/blockifier/src/blockifier/transaction_executor_test.rs +++ b/crates/blockifier/src/blockifier/transaction_executor_test.rs @@ -114,7 +114,7 @@ fn test_declare( let declared_contract = FeatureContract::Empty(cairo_version); let state = test_state(&block_context.chain_info, BALANCE, &[(account_contract, 1)]); - let tx = Transaction::AccountTransaction(declare_tx( + let tx = Transaction::Account(declare_tx( declare_tx_args! { sender_address: account_contract.get_instance_address(0), class_hash: declared_contract.get_class_hash(), @@ -136,7 +136,7 @@ fn test_deploy_account( let account_contract = FeatureContract::AccountWithoutValidations(cairo_version); let state = test_state(&block_context.chain_info, BALANCE, &[(account_contract, 0)]); - let tx = Transaction::AccountTransaction(AccountTransaction::DeployAccount(deploy_account_tx( + let tx = Transaction::Account(AccountTransaction::DeployAccount(deploy_account_tx( deploy_account_tx_args! { class_hash: account_contract.get_class_hash(), resource_bounds: l1_resource_bounds(0, DEFAULT_STRK_L1_GAS_PRICE), @@ -209,7 +209,7 @@ fn test_invoke( let calldata = create_calldata(test_contract.get_instance_address(0), entry_point_name, &entry_point_args); - let tx = Transaction::AccountTransaction(account_invoke_tx(invoke_tx_args! { + let tx = Transaction::Account(account_invoke_tx(invoke_tx_args! { sender_address: account_contract.get_instance_address(0), calldata, version, @@ -222,7 +222,7 @@ fn test_l1_handler(block_context: BlockContext) { let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); let state = test_state(&block_context.chain_info, BALANCE, &[(test_contract, 1)]); - let tx = Transaction::L1HandlerTransaction(L1HandlerTransaction::create_for_testing( + let tx = Transaction::L1Handler(L1HandlerTransaction::create_for_testing( Fee(1908000000000000), test_contract.get_instance_address(0), )); @@ -264,7 +264,7 @@ fn test_bouncing(#[case] initial_bouncer_weights: BouncerWeights, #[case] n_even tx_executor.bouncer.set_accumulated_weights(initial_bouncer_weights); tx_executor - .execute(&Transaction::AccountTransaction(emit_n_events_tx( + .execute(&Transaction::Account(emit_n_events_tx( n_events, account_address, contract_address, @@ -301,7 +301,7 @@ fn test_execute_txs_bouncing() { emit_n_events_tx(1, account_address, contract_address, nonce!(3_u32)), ] .into_iter() - .map(Transaction::AccountTransaction) + .map(Transaction::Account) .collect(); // Run. diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index 0962f914ee..5053c047f1 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -104,7 +104,7 @@ pub fn test_commit_tx() { trivial_calldata_invoke_tx(account_address, test_contract_address, nonce!(10_u8)), ] .into_iter() - .map(Transaction::AccountTransaction) + .map(Transaction::Account) .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); let cached_state = @@ -200,7 +200,7 @@ fn test_commit_tx_when_sender_is_sequencer() { let (sequencer_balance_key_low, sequencer_balance_key_high) = get_sequencer_balance_keys(&block_context); - let sequencer_tx = [Transaction::AccountTransaction(trivial_calldata_invoke_tx( + let sequencer_tx = [Transaction::Account(trivial_calldata_invoke_tx( account_address, test_contract_address, nonce!(0_u8), @@ -313,7 +313,7 @@ fn test_worker_execute(max_resource_bounds: ResourceBoundsMapping) { let txs = [tx_success, tx_failure, tx_revert] .into_iter() - .map(Transaction::AccountTransaction) + .map(Transaction::Account) .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); @@ -475,7 +475,7 @@ fn test_worker_validate(max_resource_bounds: ResourceBoundsMapping) { let txs = [account_tx0, account_tx1] .into_iter() - .map(Transaction::AccountTransaction) + .map(Transaction::Account) .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); @@ -586,10 +586,8 @@ fn test_deploy_before_declare( nonce: nonce!(0_u8) }); - let txs = [declare_tx, invoke_tx] - .into_iter() - .map(Transaction::AccountTransaction) - .collect::>(); + let txs = + [declare_tx, invoke_tx].into_iter().map(Transaction::Account).collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); let worker_executor = @@ -654,7 +652,7 @@ fn test_worker_commit_phase(max_resource_bounds: ResourceBoundsMapping) { let txs = (0..3) .map(|_| { - Transaction::AccountTransaction(account_invoke_tx(invoke_tx_args! { + Transaction::Account(account_invoke_tx(invoke_tx_args! { sender_address, calldata: calldata.clone(), resource_bounds: max_resource_bounds.clone(), @@ -744,7 +742,7 @@ fn test_worker_commit_phase_with_halt() { let txs = (0..2) .map(|_| { - Transaction::AccountTransaction(emit_n_events_tx( + Transaction::Account(emit_n_events_tx( n_events, sender_address, test_contract_address, diff --git a/crates/blockifier/src/test_utils/transfers_generator.rs b/crates/blockifier/src/test_utils/transfers_generator.rs index 3d3a6a911d..6651de655c 100644 --- a/crates/blockifier/src/test_utils/transfers_generator.rs +++ b/crates/blockifier/src/test_utils/transfers_generator.rs @@ -153,7 +153,7 @@ impl TransfersGenerator { self.sender_index = (self.sender_index + 1) % self.account_addresses.len(); let account_tx = self.generate_transfer(sender_address, recipient_address); - txs.push(Transaction::AccountTransaction(account_tx)); + txs.push(Transaction::Account(account_tx)); } let results = self.executor.execute_txs(&txs); assert_eq!(results.len(), self.config.n_txs); diff --git a/crates/blockifier/src/transaction/transaction_execution.rs b/crates/blockifier/src/transaction/transaction_execution.rs index a2f6bf263d..4108fab774 100644 --- a/crates/blockifier/src/transaction/transaction_execution.rs +++ b/crates/blockifier/src/transaction/transaction_execution.rs @@ -32,8 +32,8 @@ use crate::transaction::transactions::{ // TODO: Move into transaction.rs, makes more sense to be defined there. #[derive(Clone, Debug, derive_more::From)] pub enum Transaction { - AccountTransaction(AccountTransaction), - L1HandlerTransaction(L1HandlerTransaction), + Account(AccountTransaction), + L1Handler(L1HandlerTransaction), } impl Transaction { @@ -47,7 +47,7 @@ impl Transaction { ) -> TransactionExecutionResult { match tx { StarknetApiTransaction::L1Handler(l1_handler) => { - Ok(Self::L1HandlerTransaction(L1HandlerTransaction { + Ok(Self::L1Handler(L1HandlerTransaction { tx: l1_handler, tx_hash, paid_fee_on_l1: paid_fee_on_l1 @@ -63,7 +63,7 @@ impl Transaction { } false => DeclareTransaction::new(declare, tx_hash, non_optional_class_info), }; - Ok(Self::AccountTransaction(AccountTransaction::Declare(declare_tx?))) + Ok(Self::Account(AccountTransaction::Declare(declare_tx?))) } StarknetApiTransaction::DeployAccount(deploy_account) => { let contract_address = match deployed_contract_address { @@ -85,14 +85,14 @@ impl Transaction { DeployAccountTransaction::new(deploy_account, tx_hash, contract_address) } }; - Ok(Self::AccountTransaction(AccountTransaction::DeployAccount(deploy_account_tx))) + Ok(Self::Account(AccountTransaction::DeployAccount(deploy_account_tx))) } StarknetApiTransaction::Invoke(invoke) => { let invoke_tx = match only_query { true => InvokeTransaction::new_for_query(invoke, tx_hash), false => InvokeTransaction::new(invoke, tx_hash), }; - Ok(Self::AccountTransaction(AccountTransaction::Invoke(invoke_tx))) + Ok(Self::Account(AccountTransaction::Invoke(invoke_tx))) } _ => unimplemented!(), } @@ -102,8 +102,8 @@ impl Transaction { impl TransactionInfoCreator for Transaction { fn create_tx_info(&self) -> TransactionInfo { match self { - Self::AccountTransaction(account_tx) => account_tx.create_tx_info(), - Self::L1HandlerTransaction(l1_handler_tx) => l1_handler_tx.create_tx_info(), + Self::Account(account_tx) => account_tx.create_tx_info(), + Self::L1Handler(l1_handler_tx) => l1_handler_tx.create_tx_info(), } } } @@ -171,12 +171,10 @@ impl ExecutableTransaction for Transaction { // AccountTransaction::execute_raw. let concurrency_mode = execution_flags.concurrency_mode; let tx_execution_info = match self { - Self::AccountTransaction(account_tx) => { + Self::Account(account_tx) => { account_tx.execute_raw(state, block_context, execution_flags)? } - Self::L1HandlerTransaction(tx) => { - tx.execute_raw(state, block_context, execution_flags)? - } + Self::L1Handler(tx) => tx.execute_raw(state, block_context, execution_flags)?, }; // Check if the transaction is too large to fit any block. diff --git a/crates/native_blockifier/src/py_transaction.rs b/crates/native_blockifier/src/py_transaction.rs index 7b84d89d71..413a22ff00 100644 --- a/crates/native_blockifier/src/py_transaction.rs +++ b/crates/native_blockifier/src/py_transaction.rs @@ -116,7 +116,7 @@ pub fn py_account_tx( tx: &PyAny, optional_py_class_info: Option, ) -> NativeBlockifierResult { - let Transaction::AccountTransaction(account_tx) = py_tx(tx, optional_py_class_info)? else { + let Transaction::Account(account_tx) = py_tx(tx, optional_py_class_info)? else { panic!("Not an account transaction."); };