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

Commit 887ddc1

Browse files
fmolettajuanbono
authored andcommitted
Fix get_onchain_data_segment_length (#1085)
* Fix get_onchain_data_segment_length * Update test values * Update test values * fmt --------- Co-authored-by: Juan Bono <juanbono94@gmail.com>
1 parent 7863d8f commit 887ddc1

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

src/definitions/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::collections::HashMap;
77

88
pub(crate) const L2_TO_L1_MSG_HEADER_SIZE: usize = 3;
99
pub(crate) const L1_TO_L2_MSG_HEADER_SIZE: usize = 5;
10-
pub(crate) const DEPLOYMENT_INFO_SIZE: usize = 2;
10+
pub(crate) const DEPLOYMENT_INFO_SIZE: usize = 1;
1111
pub(crate) const CONSUMED_MSG_TO_L2_N_TOPICS: usize = 3;
1212
pub(crate) const LOG_MSG_TO_L1_N_TOPICS: usize = 2;
1313
pub(crate) const N_DEFAULT_TOPICS: usize = 1; // Events have one default topic.

src/execution/gas_usage.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub const fn get_onchain_data_segment_length(
110110
n_storage_changes: usize,
111111
n_deployments: usize,
112112
) -> usize {
113-
n_modified_contracts * 2 + n_storage_changes * 2 + n_deployments * DEPLOYMENT_INFO_SIZE
113+
n_modified_contracts * 2 + n_deployments * DEPLOYMENT_INFO_SIZE + n_storage_changes * 2
114114
}
115115

116116
/// Calculates the cost of ConsumedMessageToL2 event emissions caused by an L1 handler with the given
@@ -262,7 +262,7 @@ mod test {
262262

263263
assert_eq!(
264264
calculate_tx_gas_usage(vec![message1, message2], 2, 2, Some(2), 1),
265-
77051
265+
76439
266266
)
267267
}
268268
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ mod test {
10241024

10251025
assert_eq!(
10261026
estimate_fee(&[deploy, invoke_tx], state, block_context,).unwrap(),
1027-
[(0, 2448), (0, 2448)]
1027+
[(0, 1836), (0, 2448)]
10281028
);
10291029
}
10301030

tests/deploy_account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn internal_deploy_account() {
104104
("n_steps", 3612),
105105
("pedersen_builtin", 23),
106106
("range_check_builtin", 83),
107-
("l1_gas_usage", 3672)
107+
("l1_gas_usage", 3060)
108108
]
109109
.into_iter()
110110
.map(|(k, v)| (k.to_string(), v))
@@ -270,7 +270,7 @@ fn internal_deploy_account_cairo1() {
270270
("n_steps", n_steps),
271271
("pedersen_builtin", 23),
272272
("range_check_builtin", 87),
273-
("l1_gas_usage", 4896)
273+
("l1_gas_usage", 4284)
274274
]
275275
.into_iter()
276276
.map(|(k, v)| (k.to_string(), v))

tests/internals.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ fn test_invoke_with_declarev2_tx() {
14901490
fn test_deploy_account() {
14911491
let (block_context, mut state) = create_account_tx_test_state().unwrap();
14921492

1493-
let expected_fee = 3709;
1493+
let expected_fee = 3097;
14941494

14951495
let deploy_account_tx = DeployAccount::new(
14961496
felt_to_hash(&TEST_ACCOUNT_CONTRACT_CLASS_HASH),
@@ -1561,7 +1561,7 @@ fn test_deploy_account() {
15611561
("n_steps".to_string(), 3625),
15621562
("range_check_builtin".to_string(), 83),
15631563
("pedersen_builtin".to_string(), 23),
1564-
("l1_gas_usage".to_string(), 3672),
1564+
("l1_gas_usage".to_string(), 3060),
15651565
]);
15661566

15671567
let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap();
@@ -1706,12 +1706,12 @@ fn test_deploy_account_revert() {
17061706
("n_steps".to_string(), 3625),
17071707
("range_check_builtin".to_string(), 83),
17081708
("pedersen_builtin".to_string(), 23),
1709-
("l1_gas_usage".to_string(), 3672),
1709+
("l1_gas_usage".to_string(), 3060),
17101710
]);
17111711

17121712
let fee = calculate_tx_fee(&resources, *GAS_PRICE, &block_context).unwrap();
17131713

1714-
assert_eq!(fee, 3709);
1714+
assert_eq!(fee, 3097);
17151715

17161716
let mut expected_execution_info = TransactionExecutionInfo::new(
17171717
None,
@@ -1749,7 +1749,7 @@ fn expected_deploy_account_states() -> (
17491749
CachedState<InMemoryStateReader>,
17501750
CachedState<InMemoryStateReader>,
17511751
) {
1752-
let fee = Felt252::from(3709);
1752+
let fee = Felt252::from(3097);
17531753
let mut state_before = CachedState::new(
17541754
Arc::new(InMemoryStateReader::new(
17551755
HashMap::from([

0 commit comments

Comments
 (0)