diff --git a/crates/gateway/src/gateway_test.rs b/crates/gateway/src/gateway_test.rs index 4204f0b3bf..0ff0ec93c5 100644 --- a/crates/gateway/src/gateway_test.rs +++ b/crates/gateway/src/gateway_test.rs @@ -67,7 +67,13 @@ async fn test_add_tx() { .with(eq(MempoolInput { // TODO(Arni): Use external_to_executable_tx instead of `create_executable_tx`. Consider // creating a `convertor for testing` that does not do the compilation. - tx: create_executable_tx(sender_address, tx_hash, *tx.tip(), *tx.nonce()), + tx: create_executable_tx( + sender_address, + tx_hash, + *tx.tip(), + *tx.nonce(), + tx.resource_bounds().clone().into(), + ), account: Account { sender_address, state: AccountState { nonce: *tx.nonce() } }, })) .return_once(|_| Ok(())); diff --git a/crates/gateway/src/stateful_transaction_validator_test.rs b/crates/gateway/src/stateful_transaction_validator_test.rs index 4f9354e4c7..c9367544be 100644 --- a/crates/gateway/src/stateful_transaction_validator_test.rs +++ b/crates/gateway/src/stateful_transaction_validator_test.rs @@ -69,7 +69,7 @@ fn stateful_validator(block_context: BlockContext) -> StatefulTransactionValidat invoke_tx(CairoVersion::Cairo1), Ok(ValidateInfo{ tx_hash: TransactionHash(felt!( - "0x152b8dd0c30e95fa3a4ee7a9398fcfc46fb00c048b4fdcfa9958c64d65899b8" + "0x3b93426272b6e281bc9bde29b91a9fb100c2f9689388c62360b2be2f4e7b493" )), sender_address: contract_address!("0xc0020000"), account_nonce: Nonce::default() diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index 94f238fb15..9add6f595a 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -2,7 +2,10 @@ use std::cmp::Reverse; use std::collections::HashMap; use assert_matches::assert_matches; -use mempool_test_utils::starknet_api_test_utils::create_executable_tx; +use mempool_test_utils::starknet_api_test_utils::{ + create_executable_tx, + executable_resource_bounds_mapping, +}; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::core::{ContractAddress, Nonce, PatriciaKey}; @@ -151,7 +154,7 @@ fn add_tx_expect_error(mempool: &mut Mempool, input: &MempoolInput, expected_err /// 5. add_tx_input!(tip: 1, tx_hash: 2) macro_rules! add_tx_input { (tip: $tip:expr, tx_hash: $tx_hash:expr, sender_address: $sender_address:expr, - tx_nonce: $tx_nonce:expr, account_nonce: $account_nonce:expr) => {{ + tx_nonce: $tx_nonce:expr, account_nonce: $account_nonce:expr, resource_bounds: $resource_bounds:expr) => {{ let sender_address = contract_address!($sender_address); let account_nonce = Nonce(felt!($account_nonce)); let account = Account { sender_address, state: AccountState {nonce: account_nonce}}; @@ -161,9 +164,14 @@ macro_rules! add_tx_input { TransactionHash(StarkHash::from($tx_hash)), Tip($tip), Nonce(felt!($tx_nonce)), + $resource_bounds, ); MempoolInput { tx, account } }}; + (tip: $tip:expr, tx_hash: $tx_hash:expr, sender_address: $sender_address:expr, + tx_nonce: $tx_nonce:expr, account_nonce: $account_nonce:expr) => {{ + add_tx_input!(tip: $tip, tx_hash: $tx_hash, sender_address: $sender_address, tx_nonce: $tx_nonce, account_nonce: $account_nonce, resource_bounds: executable_resource_bounds_mapping().into()) + }}; (tx_hash: $tx_hash:expr, sender_address: $sender_address:expr, tx_nonce: $tx_nonce:expr, account_nonce: $account_nonce:expr) => { add_tx_input!(tip: 0, tx_hash: $tx_hash, sender_address: $sender_address, tx_nonce: $tx_nonce, account_nonce: $account_nonce) }; diff --git a/crates/mempool_test_utils/src/starknet_api_test_utils.rs b/crates/mempool_test_utils/src/starknet_api_test_utils.rs index 9352c97b23..78be52b29c 100644 --- a/crates/mempool_test_utils/src/starknet_api_test_utils.rs +++ b/crates/mempool_test_utils/src/starknet_api_test_utils.rs @@ -46,6 +46,8 @@ use crate::{ pub const VALID_L1_GAS_MAX_AMOUNT: u64 = 203484; pub const VALID_L1_GAS_MAX_PRICE_PER_UNIT: u128 = 100000000000; +pub const VALID_L2_GAS_MAX_AMOUNT: u64 = 203484; +pub const VALID_L2_GAS_MAX_PRICE_PER_UNIT: u128 = 100000000000; pub const TEST_SENDER_ADDRESS: u128 = 0x1000; // Utils. @@ -110,7 +112,10 @@ pub fn executable_resource_bounds_mapping() -> ResourceBoundsMapping { max_amount: VALID_L1_GAS_MAX_AMOUNT, max_price_per_unit: VALID_L1_GAS_MAX_PRICE_PER_UNIT, }, - ResourceBounds::default(), + ResourceBounds { + max_amount: VALID_L2_GAS_MAX_AMOUNT, + max_price_per_unit: VALID_L2_GAS_MAX_PRICE_PER_UNIT, + }, ) } @@ -547,6 +552,7 @@ pub fn create_executable_tx( tx_hash: TransactionHash, tip: Tip, nonce: Nonce, + resource_bounds: ExecutableResourceBoundsMapping, ) -> Transaction { Transaction::Invoke(InvokeTransaction { tx: starknet_api::transaction::InvokeTransaction::V3( @@ -554,7 +560,7 @@ pub fn create_executable_tx( sender_address, tip, nonce, - resource_bounds: ExecutableResourceBoundsMapping::default(), + resource_bounds, signature: TransactionSignature::default(), calldata: Calldata::default(), nonce_data_availability_mode: DataAvailabilityMode::L1, diff --git a/crates/starknet_api/src/executable_transaction.rs b/crates/starknet_api/src/executable_transaction.rs index a9380f9db2..ae0e219d54 100644 --- a/crates/starknet_api/src/executable_transaction.rs +++ b/crates/starknet_api/src/executable_transaction.rs @@ -114,7 +114,7 @@ impl Transaction { sender_address, tip: *rpc_tx.tip(), nonce: *rpc_tx.nonce(), - resource_bounds: ResourceBoundsMapping::default(), + resource_bounds: rpc_tx.resource_bounds().clone().into(), signature: TransactionSignature::default(), calldata: Calldata::default(), nonce_data_availability_mode: DataAvailabilityMode::L1,