From bd1181a8c66be5f5daa49401b9338fcf73cd6b3d Mon Sep 17 00:00:00 2001 From: Nimrod Weiss Date: Wed, 21 Aug 2024 11:26:41 +0300 Subject: [PATCH] build(fee): remove more occurnces of resource mapping --- .../syscall_tests/get_execution_info.rs | 26 ++++--------------- .../src/serialization/serializers.rs | 2 -- crates/papyrus_test_utils/src/lib.rs | 2 -- .../src/writer/objects/transaction.rs | 8 +++--- 4 files changed, 9 insertions(+), 29 deletions(-) diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs index 7e505bd03de..f891bbfabec 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs @@ -1,5 +1,3 @@ -use std::collections::BTreeMap; - use cairo_vm::Felt252; use num_traits::Pow; use starknet_api::core::ChainId; @@ -8,14 +6,13 @@ use starknet_api::felt; use starknet_api::transaction::{ AccountDeploymentData, Calldata, - DeprecatedResourceBoundsMapping, Fee, PaymasterData, - Resource, ResourceBounds, Tip, TransactionHash, TransactionVersion, + ValidResourceBounds, }; use starknet_types_core::felt::Felt; use test_case::test_case; @@ -213,23 +210,10 @@ fn test_get_execution_info( only_query, ..Default::default() }, - resource_bounds: DeprecatedResourceBoundsMapping(BTreeMap::from([ - ( - Resource::L1Gas, - // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why - // the convertion works. - ResourceBounds { - max_amount: max_amount - .0 - .try_into() - .expect("Failed to convert u128 to u64."), - max_price_per_unit: max_price_per_unit.0, - }, - ), - (Resource::L2Gas, ResourceBounds { max_amount: 0, max_price_per_unit: 0 }), - ])) - .try_into() - .unwrap(), + resource_bounds: ValidResourceBounds::L1Gas(ResourceBounds { + max_amount: max_amount.0.try_into().expect("Failed to convert u128 to u64."), + max_price_per_unit: max_price_per_unit.0, + }), tip: Tip::default(), nonce_data_availability_mode: DataAvailabilityMode::L1, fee_data_availability_mode: DataAvailabilityMode::L1, diff --git a/crates/papyrus_storage/src/serialization/serializers.rs b/crates/papyrus_storage/src/serialization/serializers.rs index e58e5366be8..f707da82ac4 100644 --- a/crates/papyrus_storage/src/serialization/serializers.rs +++ b/crates/papyrus_storage/src/serialization/serializers.rs @@ -90,7 +90,6 @@ use starknet_api::transaction::{ DeployAccountTransactionV3, DeployTransaction, DeployTransactionOutput, - DeprecatedResourceBoundsMapping, Event, EventContent, EventData, @@ -368,7 +367,6 @@ auto_storage_serde! { pub max_amount: u64, pub max_price_per_unit: u128, } - pub struct DeprecatedResourceBoundsMapping(pub BTreeMap); pub struct SequencerContractAddress(pub ContractAddress); pub struct Signature { pub r: Felt, diff --git a/crates/papyrus_test_utils/src/lib.rs b/crates/papyrus_test_utils/src/lib.rs index d62893e0451..9fc0455039e 100644 --- a/crates/papyrus_test_utils/src/lib.rs +++ b/crates/papyrus_test_utils/src/lib.rs @@ -113,7 +113,6 @@ use starknet_api::transaction::{ DeployAccountTransactionV3, DeployTransaction, DeployTransactionOutput, - DeprecatedResourceBoundsMapping, Event, EventContent, EventData, @@ -729,7 +728,6 @@ auto_impl_get_test_instance! { pub max_amount: u64, pub max_price_per_unit: u128, } - pub struct DeprecatedResourceBoundsMapping(pub BTreeMap); pub struct SequencerContractAddress(pub ContractAddress); pub struct Signature { pub r: Felt, diff --git a/crates/starknet_client/src/writer/objects/transaction.rs b/crates/starknet_client/src/writer/objects/transaction.rs index 50adae8afdc..c9f68ecdde4 100644 --- a/crates/starknet_client/src/writer/objects/transaction.rs +++ b/crates/starknet_client/src/writer/objects/transaction.rs @@ -31,12 +31,12 @@ use starknet_api::transaction::{ AccountDeploymentData, Calldata, ContractAddressSalt, - DeprecatedResourceBoundsMapping, Fee, PaymasterData, Tip, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; // Each transaction type has a field called `type`. This field needs to be of a type that @@ -104,7 +104,7 @@ pub struct DeployAccountV1Transaction { #[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq)] #[serde(deny_unknown_fields)] pub struct DeployAccountV3Transaction { - pub resource_bounds: DeprecatedResourceBoundsMapping, + pub resource_bounds: ValidResourceBounds, pub tip: Tip, pub contract_address_salt: ContractAddressSalt, pub class_hash: ClassHash, @@ -169,7 +169,7 @@ pub struct InvokeV1Transaction { #[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq)] #[serde(deny_unknown_fields)] pub struct InvokeV3Transaction { - pub resource_bounds: DeprecatedResourceBoundsMapping, + pub resource_bounds: ValidResourceBounds, pub tip: Tip, pub calldata: Calldata, pub sender_address: ContractAddress, @@ -235,7 +235,7 @@ pub struct DeclareV2Transaction { #[serde(deny_unknown_fields)] pub struct DeclareV3Transaction { pub contract_class: ContractClass, - pub resource_bounds: DeprecatedResourceBoundsMapping, + pub resource_bounds: ValidResourceBounds, pub tip: Tip, pub signature: TransactionSignature, pub nonce: Nonce,