Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const STORAGE_READ_GAS_COST = 24070;
const STORAGE_WRITE_GAS_COST = 59970;
const EMIT_EVENT_GAS_COST = 10000;
const SEND_MESSAGE_TO_L1_GAS_COST = 14470;
const META_TX_V0_GAS_COST = 167950;
const META_TX_V0_GAS_COST = 168550;
const META_TX_V0_CALLDATA_FACTOR_GAS_COST = 4850;

// Note the the following costs include `SYSCALL_BASE_GAS_COST` implicitly.
Expand Down
2 changes: 1 addition & 1 deletion crates/apollo_starknet_os_program/src/program_hash.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"os": "0x7b762f60dc1f9ecb199322522749de4e926c1eee33454764ae8974744ef0c5a",
"os": "0x3b216483cdefd7903a48dd65009f8a02dd5e069419d91e2ea4e5a9f22217cf5",
"virtual_os": "0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0",
"aggregator": "0x700786d51b3854af43d8e12180380bda3029be6c1767e007858de6ca2edac40",
"aggregator_with_prefix": "0xe08d300e3f5996e43d6d7cc5a20068e0e58cf1309089f2348317ac580f6c1f"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
},
"MetaTxV0": {
"constant": {
"n_steps": 1301,
"n_steps": 1307,
"n_memory_holes": 0,
"builtin_instance_counter": {
"range_check_builtin": 20,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
+ /os_constants/allowed_virtual_os_program_hashes/2: "0x28619dbc9767792fb536aaba7a2d55f70faadf808c95ec66b956d33fdee1bc0"
~ /os_resources/execute_syscalls/CallContract/n_steps: 901
~ /os_resources/execute_syscalls/LibraryCall/n_steps: 874
~ /os_resources/execute_syscalls/MetaTxV0/constant/n_steps: 1307
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn test_meta_tx_v0(
assert_eq!(call_info.execution.gas_consumed, 0);
expect![[r#"
DeterministicExecutionResources {
n_steps: 14845,
n_steps: 14851,
n_memory_holes: 10,
builtin_instance_counter: {
"pedersen_builtin": 12,
Expand All @@ -197,7 +197,7 @@ fn test_meta_tx_v0(
l2_to_l1_messages: [],
cairo_native: false,
failed: false,
gas_consumed: 1538250,
gas_consumed: 1538850,
}
"#]]
.assert_debug_eq(&call_info.execution);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod OsResourcesTestContract {
use starknet::{ClassHash, ContractAddress};

const STABLE_EXTERNAL_ENTRY_POINT_SELECTOR: felt252 = selector!("external");
const EXECUTE_FUNCTION_SELECTOR: felt252 = selector!("__execute__");

#[storage]
struct Storage {}
Expand All @@ -24,6 +25,13 @@ mod OsResourcesTestContract {
starknet::VALIDATED
}

extern fn meta_tx_v0_syscall(
address: ContractAddress,
entry_point_selector: felt252,
calldata: Span<felt252>,
signature: Span<felt252>,
) -> starknet::SyscallResult<Span<felt252>> implicits(GasBuiltin, System) nopanic;

// Calls every measured syscall in order.
#[external(v0)]
fn __execute__(
Expand All @@ -41,12 +49,29 @@ mod OsResourcesTestContract {
)
.unwrap_syscall();

// meta_tx_v0 syscall - base.
meta_tx_v0_syscall(
address: stable_address,
entry_point_selector: EXECUTE_FUNCTION_SELECTOR,
calldata: array![0].span(),
signature: array![].span(),
)
.unwrap_syscall();
// meta_tx_v0 syscall - linear factor.
meta_tx_v0_syscall(
address: stable_address,
entry_point_selector: EXECUTE_FUNCTION_SELECTOR,
calldata: array![1, 0].span(),
signature: array![].span(),
)
.unwrap_syscall();

// deploy syscall. The resources this syscall consumes can vary depending on the deployed
// contract address, in a non-trivial way (see `normalize_address` in the cairo0 core). For
// this reason we deploy from zero, and choose a specific salt.
// base (no calldata):
deploy_syscall(stable_class_hash, 3, array![0].span(), true).unwrap_syscall();
deploy_syscall(stable_class_hash, 1, array![0].span(), true).unwrap_syscall();
// linear factor (calldata len = 1):
deploy_syscall(stable_class_hash, 3, array![1, 0].span(), true).unwrap_syscall();
deploy_syscall(stable_class_hash, 1, array![1, 0].span(), true).unwrap_syscall();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod DeployableForResourceMeasurement {
struct Storage {}

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

Expand All @@ -20,8 +20,9 @@ mod DeployableForResourceMeasurement {
starknet::VALIDATED
}

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

/// Constructor accepting variable calldata length.
#[constructor]
Expand Down
Loading
Loading