Skip to content

Commit e970e02

Browse files
starknet_os: os resources test - add meta tx
1 parent 1bfcc05 commit e970e02

9 files changed

Lines changed: 976 additions & 414 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 = 173400;
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": "0x765f8dfbd1ba21a2381a20e92688112bb3633377c11448a2167a230d0b339f0",
2+
"os": "0x6c751043e73e061179e08b9bc608ad2abcc46df4e4b552b05ed7ad6915ace0b",
33
"virtual_os": "0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0",
44
"aggregator": "0x700786d51b3854af43d8e12180380bda3029be6c1767e007858de6ca2edac40",
55
"aggregator_with_prefix": "0xe08d300e3f5996e43d6d7cc5a20068e0e58cf1309089f2348317ac580f6c1f"

crates/blockifier/resources/blockifier_versioned_constants_0_14_4.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,11 @@
361361
},
362362
"MetaTxV0": {
363363
"constant": {
364-
"n_steps": 1301,
364+
"n_steps": 1315,
365365
"n_memory_holes": 0,
366366
"builtin_instance_counter": {
367367
"range_check_builtin": 20,
368-
"pedersen_builtin": 9
368+
"pedersen_builtin": 10
369369
}
370370
},
371371
"calldata_factor": {

crates/blockifier/resources/versioned_constants_diff_regression/0.14.3_0.14.4.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
~ /os_resources/execute_syscalls/Deploy/constant/builtin_instance_counter/pedersen_builtin: 8
44
~ /os_resources/execute_syscalls/Deploy/constant/n_steps: 1183
55
~ /os_resources/execute_syscalls/LibraryCall/n_steps: 874
6+
~ /os_resources/execute_syscalls/MetaTxV0/constant/builtin_instance_counter/pedersen_builtin: 13
7+
~ /os_resources/execute_syscalls/MetaTxV0/constant/n_steps: 1333

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Contract for measuring per-syscall OS resource costs.
22
#[starknet::contract(account)]
33
mod OsResourcesTestContract {
4+
use starknet::class_hash::ClassHashZero;
45
use starknet::info::SyscallResultTrait;
56
use starknet::syscalls::{call_contract_syscall, deploy_syscall, library_call_syscall};
67
use starknet::{ClassHash, ContractAddress};
78

89
const STABLE_EXTERNAL_ENTRY_POINT_SELECTOR: felt252 = selector!("external");
10+
const EXECUTE_FUNCTION_SELECTOR: felt252 = selector!("__execute__");
911

1012
#[storage]
1113
struct Storage {}
@@ -24,6 +26,13 @@ mod OsResourcesTestContract {
2426
starknet::VALIDATED
2527
}
2628

29+
extern fn meta_tx_v0_syscall(
30+
address: ContractAddress,
31+
entry_point_selector: felt252,
32+
calldata: Span<felt252>,
33+
signature: Span<felt252>,
34+
) -> starknet::SyscallResult<Span<felt252>> implicits(GasBuiltin, System) nopanic;
35+
2736
// Calls every measured syscall in order.
2837
#[external(v0)]
2938
fn __execute__(
@@ -41,12 +50,29 @@ mod OsResourcesTestContract {
4150
)
4251
.unwrap_syscall();
4352

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

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)