diff --git a/crates/blockifier/src/abi/constants.rs b/crates/blockifier/src/abi/constants.rs index 7b2ed4b240..3ee51f4575 100644 --- a/crates/blockifier/src/abi/constants.rs +++ b/crates/blockifier/src/abi/constants.rs @@ -1,9 +1,3 @@ -use starknet_api::transaction::TransactionVersion; -use starknet_types_core::felt::Felt; - -// The version is considered 0 for L1-Handler transaction hash calculation purposes. -pub const L1_HANDLER_VERSION: TransactionVersion = TransactionVersion(Felt::ZERO); - // OS-related constants. pub const L1_TO_L2_MSG_HEADER_SIZE: usize = 5; pub const L2_TO_L1_MSG_HEADER_SIZE: usize = 3; diff --git a/crates/blockifier/src/test_utils/l1_handler.rs b/crates/blockifier/src/test_utils/l1_handler.rs index a57d08b8b6..0aa5513a38 100644 --- a/crates/blockifier/src/test_utils/l1_handler.rs +++ b/crates/blockifier/src/test_utils/l1_handler.rs @@ -4,7 +4,6 @@ use starknet_api::core::ContractAddress; use starknet_api::executable_transaction::L1HandlerTransaction; use starknet_api::test_utils::l1_handler::{executable_l1_handler_tx, L1HandlerTxArgs}; use starknet_api::transaction::fields::Fee; -use starknet_api::transaction::TransactionVersion; use starknet_types_core::felt::Felt; pub fn l1handler_tx(l1_fee: Fee, contract_address: ContractAddress) -> L1HandlerTransaction { @@ -15,7 +14,7 @@ pub fn l1handler_tx(l1_fee: Fee, contract_address: ContractAddress) -> L1Handler ]; executable_l1_handler_tx(L1HandlerTxArgs { - version: TransactionVersion::ZERO, + version: starknet_api::transaction::L1HandlerTransaction::VERSION, contract_address, entry_point_selector: selector_from_name("l1_handler_set_value"), calldata, diff --git a/crates/native_blockifier/src/py_l1_handler.rs b/crates/native_blockifier/src/py_l1_handler.rs index df90b9642e..1816e42a7c 100644 --- a/crates/native_blockifier/src/py_l1_handler.rs +++ b/crates/native_blockifier/src/py_l1_handler.rs @@ -1,6 +1,5 @@ use std::sync::Arc; -use blockifier::abi::constants; use pyo3::prelude::*; use starknet_api::core::{ContractAddress, EntryPointSelector, Nonce}; use starknet_api::executable_transaction::L1HandlerTransaction; @@ -22,7 +21,7 @@ impl TryFrom for starknet_api::transaction::L1HandlerTra type Error = NativeBlockifierInputError; fn try_from(tx: PyL1HandlerTransaction) -> Result { Ok(Self { - version: constants::L1_HANDLER_VERSION, + version: starknet_api::transaction::L1HandlerTransaction::VERSION, nonce: Nonce(tx.nonce.0), contract_address: ContractAddress::try_from(tx.contract_address.0)?, entry_point_selector: EntryPointSelector(tx.entry_point_selector.0), diff --git a/crates/papyrus_protobuf/src/converters/transaction.rs b/crates/papyrus_protobuf/src/converters/transaction.rs index 2e43b8ccf6..f035c4a02f 100644 --- a/crates/papyrus_protobuf/src/converters/transaction.rs +++ b/crates/papyrus_protobuf/src/converters/transaction.rs @@ -1253,7 +1253,7 @@ impl From for protobuf::transaction::Deploy { impl TryFrom for L1HandlerTransaction { type Error = ProtobufConversionError; fn try_from(value: protobuf::transaction::L1HandlerV0) -> Result { - let version = TransactionVersion(Felt::ZERO); + let version = L1HandlerTransaction::VERSION; let nonce = Nonce( value diff --git a/crates/papyrus_rpc/src/v0_8/transaction_test.rs b/crates/papyrus_rpc/src/v0_8/transaction_test.rs index 965656b6f8..de2b5dece3 100644 --- a/crates/papyrus_rpc/src/v0_8/transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_8/transaction_test.rs @@ -16,7 +16,7 @@ use starknet_api::transaction::fields::{ Tip, TransactionSignature, }; -use starknet_api::transaction::{L1HandlerTransaction, Transaction, TransactionVersion}; +use starknet_api::transaction::{L1HandlerTransaction, Transaction}; use starknet_api::{calldata, contract_address, felt, nonce}; use starknet_client::writer::objects::transaction as client_transaction; @@ -38,7 +38,7 @@ use super::{ lazy_static::lazy_static! { // A transaction from MAINNET with tx hash 0x439e12f67962c353182d72b4af12c3f11eaba4b36e552aebcdcd6db66971bdb. static ref L1_HANDLER_TX: L1HandlerTransaction = L1HandlerTransaction { - version: TransactionVersion::ZERO, + version: L1HandlerTransaction::VERSION, nonce: nonce!(0x18e94d), contract_address: contract_address!( "0x73314940630fd6dcda0d772d4c972c4e0a9946bef9dabf4ef84eda8ef542b82" diff --git a/crates/starknet_api/src/transaction.rs b/crates/starknet_api/src/transaction.rs index b2bf7e3808..36980ca362 100644 --- a/crates/starknet_api/src/transaction.rs +++ b/crates/starknet_api/src/transaction.rs @@ -685,6 +685,12 @@ pub struct L1HandlerTransaction { pub calldata: Calldata, } +impl L1HandlerTransaction { + /// The transaction version is considered 0 for L1-Handler transaction for hash calculation + /// purposes. + pub const VERSION: TransactionVersion = TransactionVersion::ZERO; +} + impl TransactionHasher for L1HandlerTransaction { fn calculate_transaction_hash( &self,