Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 2c87e91

Browse files
authored
[0.13] Update transaction hash calculation (#1214)
* Add GasPricess & FeeTokenAddresses structs * Update code * RpcStateReader::get_gas_price fetch both * Update code * Clippy * Fix comment * Add VersionSpecificAccountTxFields struct * Integrate into TransactionExecutionContext * Replace max_fee field with account_tx_fields for InvokeFunction tx * Check tx account fields version when creating Invoke tx * Replace max_fee field with account_tx_fields for DeclareV3 tx * Replace max_fee field with account_tx_fields for DeployAccount tx * Update get_transaction_context for Txs not affected by this change * Fixes * Fixes * Fixes * Fix handling of ignore_max_fee * Improve placeholder method * Handle TODOs * Implement get_onchain_data_cost * Refactor * Generalize fn * Start implementing check_fee_bounds * Finish implementing check_fee_bounds * Replace old code * Fixes * Implement FeeType for VersionSpecificAccountTxFields * Update other txs * Clippy * Add test * Simplify * Move test * Implement hash_fee_related_fields * Finish hash impl * Simplify logic * Rename current tx hash functions to deprecated * Refactor comments * Fix fn name * refactor transaction_hash module * Use constants for hash prefixes * Implement calculate_deploy_account_transaction_hash * Add a general calculate_deploy_account_transaction_hash for use in DeployAccount * Implement calculate_declare_v2_transaction_hash * Refactor code * Implement calculate_invoke_transaction_hash * Move code * Clippy * Handle possible overflow * Clippy * Fix constants * Fix tx prefix * Fix constants * Add test for invoke hash calculation * Add test * Use default value instead of ignoring if resource bounds are missing * Clippy * fmt
1 parent 2894313 commit 2c87e91

File tree

11 files changed

+896
-344
lines changed

11 files changed

+896
-344
lines changed

cli/src/main.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ use starknet_in_rust::{
77
contract_address::compute_deprecated_class_hash,
88
errors::{contract_address_errors::ContractAddressError, state_errors::StateError},
99
transaction_hash::{
10-
calculate_declare_transaction_hash, calculate_deploy_transaction_hash,
11-
calculate_transaction_hash_common, TransactionHashPrefix,
10+
deprecated::{
11+
deprecated_calculate_declare_transaction_hash,
12+
deprecated_calculate_deploy_transaction_hash,
13+
deprecated_calculate_transaction_hash_common,
14+
},
15+
TransactionHashPrefix,
1216
},
1317
},
1418
definitions::{
@@ -118,7 +122,7 @@ fn declare_parser(
118122
&CompiledClass::Deprecated(Arc::new(contract_class.clone())),
119123
)?;
120124

121-
let tx_hash = calculate_declare_transaction_hash(
125+
let tx_hash = deprecated_calculate_declare_transaction_hash(
122126
&contract_class,
123127
Felt252::ZERO,
124128
&Address(0.into()),
@@ -146,7 +150,7 @@ fn deploy_parser(
146150
)?;
147151

148152
cached_state.deploy_contract(Address(address), string_to_hash(&args.class_hash))?;
149-
let tx_hash = calculate_deploy_transaction_hash(
153+
let tx_hash = deprecated_calculate_deploy_transaction_hash(
150154
0.into(),
151155
&Address(address),
152156
&constructor_calldata,
@@ -210,7 +214,7 @@ fn invoke_parser(
210214
)?;
211215
cached_state.apply_state_update(&StateDiff::from_cached_state(transactional_state.cache())?)?;
212216

213-
let tx_hash = calculate_transaction_hash_common(
217+
let tx_hash = deprecated_calculate_transaction_hash_common(
214218
TransactionHashPrefix::Invoke,
215219
*TRANSACTION_VERSION,
216220
&contract_address,

0 commit comments

Comments
 (0)