Skip to content

Commit c1043a3

Browse files
starknet_os: os resources test - add meta tx
1 parent 2d7d8df commit c1043a3

10 files changed

Lines changed: 974 additions & 415 deletions

File tree

crates/apollo_starknet_os_program/src/cairo/starkware/starknet/core/os/constants.cairo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ const STORAGE_READ_GAS_COST = 24070;
120120
const STORAGE_WRITE_GAS_COST = 59970;
121121
const EMIT_EVENT_GAS_COST = 10000;
122122
const SEND_MESSAGE_TO_L1_GAS_COST = 14470;
123-
const META_TX_V0_GAS_COST = 167950;
123+
const META_TX_V0_GAS_COST = 168550;
124124
const META_TX_V0_CALLDATA_FACTOR_GAS_COST = 4850;
125125

126126
// Note the the following costs include `SYSCALL_BASE_GAS_COST` implicitly.

crates/apollo_starknet_os_program/src/program_hash.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"os": "0x7b762f60dc1f9ecb199322522749de4e926c1eee33454764ae8974744ef0c5a",
2+
"os": "0x3b216483cdefd7903a48dd65009f8a02dd5e069419d91e2ea4e5a9f22217cf5",
33
"virtual_os": "0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0",
44
"aggregator": "0x700786d51b3854af43d8e12180380bda3029be6c1767e007858de6ca2edac40",
55
"aggregator_with_prefix": "0xe08d300e3f5996e43d6d7cc5a20068e0e58cf1309089f2348317ac580f6c1f"

crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@
362362
},
363363
"MetaTxV0": {
364364
"constant": {
365-
"n_steps": 1301,
365+
"n_steps": 1307,
366366
"n_memory_holes": 0,
367367
"builtin_instance_counter": {
368368
"range_check_builtin": 20,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
+ /os_constants/allowed_virtual_os_program_hashes/2: "0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0"
22
~ /os_resources/execute_syscalls/CallContract/n_steps: 901
33
~ /os_resources/execute_syscalls/LibraryCall/n_steps: 874
4+
~ /os_resources/execute_syscalls/MetaTxV0/constant/n_steps: 1307

crates/blockifier/src/execution/syscalls/syscall_tests/meta_tx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ fn test_meta_tx_v0(
176176
assert_eq!(call_info.execution.gas_consumed, 0);
177177
expect![[r#"
178178
DeterministicExecutionResources {
179-
n_steps: 14845,
179+
n_steps: 14851,
180180
n_memory_holes: 10,
181181
builtin_instance_counter: {
182182
"pedersen_builtin": 12,
@@ -197,7 +197,7 @@ fn test_meta_tx_v0(
197197
l2_to_l1_messages: [],
198198
cairo_native: false,
199199
failed: false,
200-
gas_consumed: 1538250,
200+
gas_consumed: 1538850,
201201
}
202202
"#]]
203203
.assert_debug_eq(&call_info.execution);

crates/blockifier_test_utils/resources/feature_contracts/cairo1/os_resources_test_contract.cairo

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ mod OsResourcesTestContract {
66
use starknet::{ClassHash, ContractAddress};
77

88
const STABLE_EXTERNAL_ENTRY_POINT_SELECTOR: felt252 = selector!("external");
9+
const EXECUTE_FUNCTION_SELECTOR: felt252 = selector!("__execute__");
910

1011
#[storage]
1112
struct Storage {}
@@ -24,6 +25,13 @@ mod OsResourcesTestContract {
2425
starknet::VALIDATED
2526
}
2627

28+
extern fn meta_tx_v0_syscall(
29+
address: ContractAddress,
30+
entry_point_selector: felt252,
31+
calldata: Span<felt252>,
32+
signature: Span<felt252>,
33+
) -> starknet::SyscallResult<Span<felt252>> implicits(GasBuiltin, System) nopanic;
34+
2735
// Calls every measured syscall in order.
2836
#[external(v0)]
2937
fn __execute__(
@@ -41,12 +49,29 @@ mod OsResourcesTestContract {
4149
)
4250
.unwrap_syscall();
4351

52+
// meta_tx_v0 syscall - base.
53+
meta_tx_v0_syscall(
54+
address: stable_address,
55+
entry_point_selector: EXECUTE_FUNCTION_SELECTOR,
56+
calldata: array![0].span(),
57+
signature: array![].span(),
58+
)
59+
.unwrap_syscall();
60+
// meta_tx_v0 syscall - linear factor.
61+
meta_tx_v0_syscall(
62+
address: stable_address,
63+
entry_point_selector: EXECUTE_FUNCTION_SELECTOR,
64+
calldata: array![1, 0].span(),
65+
signature: array![].span(),
66+
)
67+
.unwrap_syscall();
68+
4469
// deploy syscall. The resources this syscall consumes can vary depending on the deployed
4570
// contract address, in a non-trivial way (see `normalize_address` in the cairo0 core). For
4671
// this reason we deploy from zero, and choose a specific salt.
4772
// base (no calldata):
48-
deploy_syscall(stable_class_hash, 3, array![0].span(), true).unwrap_syscall();
73+
deploy_syscall(stable_class_hash, 1, array![0].span(), true).unwrap_syscall();
4974
// linear factor (calldata len = 1):
50-
deploy_syscall(stable_class_hash, 3, array![1, 0].span(), true).unwrap_syscall();
75+
deploy_syscall(stable_class_hash, 1, array![1, 0].span(), true).unwrap_syscall();
5176
}
5277
}

crates/starknet_os_flow_tests/resources/deployable_for_resource_measurement.cairo

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod DeployableForResourceMeasurement {
66
struct Storage {}
77

88
#[external(v0)]
9-
fn __validate__(self: @ContractState) -> felt252 {
9+
fn __validate__(self: @ContractState, some_args: Span<felt252>) -> felt252 {
1010
starknet::VALIDATED
1111
}
1212

@@ -20,8 +20,9 @@ mod DeployableForResourceMeasurement {
2020
starknet::VALIDATED
2121
}
2222

23+
/// Main execute entry point should have variable input length to measure meta-tx linear factor.
2324
#[external(v0)]
24-
fn __execute__(ref self: ContractState) {}
25+
fn __execute__(ref self: ContractState, some_args: Span<felt252>) {}
2526

2627
/// Constructor accepting variable calldata length.
2728
#[constructor]

0 commit comments

Comments
 (0)