Skip to content
Draft
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
1 change: 1 addition & 0 deletions crates/apollo_compile_to_casm/src/allowed_libfuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"coupon_call": null,
"coupon_refund": null,
"deploy_syscall": null,
"deploy_v2_syscall": null,
"disable_ap_tracking": null,
"downcast": null,
"drop": null,
Expand Down
8 changes: 6 additions & 2 deletions crates/apollo_compile_to_casm/src/compile_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ const SIERRA_COMPILATION_CONFIG: SierraCompilationConfig = SierraCompilationConf

// Libfuncs in allowed_libfuncs.json but not yet in Cairo's audited list.
// Remove entries once they're added to the audited list.
const PENDING_LIBFUNCS: &[&str] =
&["sha512_process_block_syscall", "sha512_state_handle_digest", "sha512_state_handle_init"];
const PENDING_LIBFUNCS: &[&str] = &[
"deploy_v2_syscall",
"sha512_process_block_syscall",
"sha512_state_handle_digest",
"sha512_state_handle_init",
];

fn compiler() -> SierraToCasmCompiler {
SierraToCasmCompiler::new(SIERRA_COMPILATION_CONFIG)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ const SYSCALL_BASE_GAS_COST = 10000;
const CALL_CONTRACT_GAS_COST = 91360;
const DEPLOY_GAS_COST = 147120;
const DEPLOY_CALLDATA_FACTOR_GAS_COST = 4850;
const DEPLOY_V2_GAS_COST = 147120;
const DEPLOY_V2_CALLDATA_FACTOR_GAS_COST = 4850;
const DEPLOY_V2_GAS_COST = 175510;
const DEPLOY_V2_CALLDATA_FACTOR_GAS_COST = 1670;
const GET_BLOCK_HASH_GAS_COST = 10810;
const GET_CLASS_HASH_AT_GAS_COST = 10000;
const GET_EXECUTION_INFO_GAS_COST = 11240;
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": "0x270d10aed5049dc32cd2aa4f85e4eb4c3bc386b6ed4459a0f7bf7a6284750e0",
"os": "0x5b6660359cf03bffa4f574d9205b7421ac2c8fb0196afafbf108e01a6a6f425",
"virtual_os": "0xfedbf2b6504b9217026ba2bf9b2a33e8e28ed38e5b0f84eef59075b02174b8",
"aggregator": "0x3e4ce8340259e374200ed856e597a0c0b268d1021119d33573d7c759c5320f9",
"aggregator_with_prefix": "0x2526c12112a2d7f57f7ae74af7be1fe1b2766e4c34b0c88ceda16b70ed2d6c2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,18 +267,17 @@
},
"DeployV2": {
"constant": {
"n_steps": 1173,
"n_steps": 1725,
"n_memory_holes": 0,
"builtin_instance_counter": {
"range_check_builtin": 21,
"pedersen_builtin": 7
"range_check_builtin": 43
}
},
"calldata_factor": {
"n_steps": 8,
"n_steps": 16,
"n_memory_holes": 0,
"builtin_instance_counter": {
"pedersen_builtin": 1
"range_check_builtin": 1
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
~ /os_constants/allowed_virtual_os_program_hashes/0: "0xfedbf2b6504b9217026ba2bf9b2a33e8e28ed38e5b0f84eef59075b02174b8"
+ /os_resources/execute_syscalls/DeployV2/calldata_factor: {"builtin_instance_counter":{"pedersen_builtin":1},"n_memory_holes":0,"n_steps":8}
+ /os_resources/execute_syscalls/DeployV2/constant: {"builtin_instance_counter":{"pedersen_builtin":7,"range_check_builtin":21},"n_memory_holes":0,"n_steps":1173}
+ /os_resources/execute_syscalls/DeployV2/calldata_factor: {"builtin_instance_counter":{"range_check_builtin":1},"n_memory_holes":0,"n_steps":16}
+ /os_resources/execute_syscalls/DeployV2/constant: {"builtin_instance_counter":{"range_check_builtin":43},"n_memory_holes":0,"n_steps":1725}
- /os_resources/execute_syscalls/DeployV2/builtin_instance_counter
- /os_resources/execute_syscalls/DeployV2/n_memory_holes
- /os_resources/execute_syscalls/DeployV2/n_steps
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"allowed_libfuncs":["add_circuit_input","alloc_local","array_append","array_get","array_len","array_new","array_pop_front","array_pop_front_consume","array_slice","array_snapshot_multi_pop_back","array_snapshot_multi_pop_front","array_snapshot_pop_back","array_snapshot_pop_front","bitwise","blake2s_compress","blake2s_finalize","bool_and_impl","bool_not_impl","bool_or_impl","bool_to_felt252","bool_xor_impl","bounded_int_add","bounded_int_constrain","bounded_int_div_rem","bounded_int_is_zero","bounded_int_mul","bounded_int_sub","bounded_int_trim_max","bounded_int_trim_min","bounded_int_wrap_non_zero","box_forward_snapshot","branch_align","bytes31_const","bytes31_to_felt252","bytes31_try_from_felt252","call_contract_syscall","circuit_failure_guarantee_verify","class_hash_const","class_hash_to_felt252","class_hash_try_from_felt252","const_as_box","const_as_immediate","contract_address_const","contract_address_to_felt252","contract_address_try_from_felt252","coupon_buy","coupon_call","coupon_refund","deploy_syscall","disable_ap_tracking","downcast","drop","dup","ec_neg","ec_neg_nz","ec_point_from_x_nz","ec_point_is_zero","ec_point_try_new_nz","ec_point_unwrap","ec_point_zero","ec_state_add","ec_state_add_mul","ec_state_init","ec_state_try_finalize_nz","emit_event_syscall","enable_ap_tracking","enum_boxed_match","enum_from_bounded_int","enum_init","enum_match","enum_snapshot_match","eval_circuit","felt252_add","felt252_const","felt252_dict_entry_finalize","felt252_dict_entry_get","felt252_dict_new","felt252_dict_squash","felt252_div","felt252_is_zero","felt252_mul","felt252_sub","finalize_locals","function_call","gas_reserve_create","gas_reserve_utilize","get_block_hash_syscall","get_builtin_costs","get_circuit_descriptor","get_circuit_output","get_class_hash_at_syscall","get_execution_info_syscall","get_execution_info_v2_syscall","get_execution_info_v3_syscall","hades_permutation","i128_const","i128_diff","i128_eq","i128_overflowing_add_impl","i128_overflowing_sub_impl","i128_to_felt252","i128_try_from_felt252","i16_const","i16_diff","i16_eq","i16_overflowing_add_impl","i16_overflowing_sub_impl","i16_to_felt252","i16_try_from_felt252","i16_wide_mul","i32_const","i32_diff","i32_eq","i32_overflowing_add_impl","i32_overflowing_sub_impl","i32_to_felt252","i32_try_from_felt252","i32_wide_mul","i64_const","i64_diff","i64_eq","i64_overflowing_add_impl","i64_overflowing_sub_impl","i64_to_felt252","i64_try_from_felt252","i64_wide_mul","i8_const","i8_diff","i8_eq","i8_overflowing_add_impl","i8_overflowing_sub_impl","i8_to_felt252","i8_try_from_felt252","i8_wide_mul","init_circuit_data","int_range_pop_front","int_range_try_new","into_box","into_u96_guarantee","jump","keccak_syscall","library_call_syscall","local_into_box","match_nullable","meta_tx_v0_syscall","null","nullable_forward_snapshot","nullable_from_box","pedersen","redeposit_gas","rename","replace_class_syscall","revoke_ap_tracking","secp256k1_add_syscall","secp256k1_get_point_from_x_syscall","secp256k1_get_xy_syscall","secp256k1_mul_syscall","secp256k1_new_syscall","secp256r1_add_syscall","secp256r1_get_point_from_x_syscall","secp256r1_get_xy_syscall","secp256r1_mul_syscall","secp256r1_new_syscall","send_message_to_l1_syscall","sha256_process_block_syscall","sha256_state_handle_digest","sha256_state_handle_init","sha512_process_block_syscall","sha512_state_handle_digest","sha512_state_handle_init","snapshot_take","span_from_tuple","squashed_felt252_dict_entries","storage_address_from_base","storage_address_from_base_and_offset","storage_address_to_felt252","storage_address_try_from_felt252","storage_base_address_const","storage_base_address_from_felt252","storage_read_syscall","storage_write_syscall","store_local","store_temp","struct_boxed_deconstruct","struct_construct","struct_deconstruct","struct_snapshot_deconstruct","try_into_circuit_modulus","tuple_from_span","u128_byte_reverse","u128_const","u128_eq","u128_guarantee_mul","u128_is_zero","u128_mul_guarantee_verify","u128_overflowing_add","u128_overflowing_sub","u128_safe_divmod","u128_sqrt","u128_to_felt252","u128s_from_felt252","u16_bitwise","u16_const","u16_eq","u16_is_zero","u16_overflowing_add","u16_overflowing_sub","u16_safe_divmod","u16_sqrt","u16_to_felt252","u16_try_from_felt252","u16_wide_mul","u256_guarantee_inv_mod_n","u256_is_zero","u256_safe_divmod","u256_sqrt","u32_bitwise","u32_const","u32_eq","u32_is_zero","u32_overflowing_add","u32_overflowing_sub","u32_safe_divmod","u32_sqrt","u32_to_felt252","u32_try_from_felt252","u32_wide_mul","u512_safe_divmod_by_u256","u64_bitwise","u64_const","u64_eq","u64_is_zero","u64_overflowing_add","u64_overflowing_sub","u64_safe_divmod","u64_sqrt","u64_to_felt252","u64_try_from_felt252","u64_wide_mul","u8_bitwise","u8_const","u8_eq","u8_is_zero","u8_overflowing_add","u8_overflowing_sub","u8_safe_divmod","u8_sqrt","u8_to_felt252","u8_try_from_felt252","u8_wide_mul","u96_guarantee_verify","u96_limbs_less_than_guarantee_verify","u96_single_limb_less_than_guarantee_verify","unbox","unwrap_non_zero","upcast","withdraw_gas","withdraw_gas_all"]}
{"allowed_libfuncs":["add_circuit_input","alloc_local","array_append","array_get","array_len","array_new","array_pop_front","array_pop_front_consume","array_slice","array_snapshot_multi_pop_back","array_snapshot_multi_pop_front","array_snapshot_pop_back","array_snapshot_pop_front","bitwise","blake2s_compress","blake2s_finalize","bool_and_impl","bool_not_impl","bool_or_impl","bool_to_felt252","bool_xor_impl","bounded_int_add","bounded_int_constrain","bounded_int_div_rem","bounded_int_is_zero","bounded_int_mul","bounded_int_sub","bounded_int_trim_max","bounded_int_trim_min","bounded_int_wrap_non_zero","box_forward_snapshot","branch_align","bytes31_const","bytes31_to_felt252","bytes31_try_from_felt252","call_contract_syscall","circuit_failure_guarantee_verify","class_hash_const","class_hash_to_felt252","class_hash_try_from_felt252","const_as_box","const_as_immediate","contract_address_const","contract_address_to_felt252","contract_address_try_from_felt252","coupon_buy","coupon_call","coupon_refund","deploy_syscall","deploy_v2_syscall","disable_ap_tracking","downcast","drop","dup","ec_neg","ec_neg_nz","ec_point_from_x_nz","ec_point_is_zero","ec_point_try_new_nz","ec_point_unwrap","ec_point_zero","ec_state_add","ec_state_add_mul","ec_state_init","ec_state_try_finalize_nz","emit_event_syscall","enable_ap_tracking","enum_boxed_match","enum_from_bounded_int","enum_init","enum_match","enum_snapshot_match","eval_circuit","felt252_add","felt252_const","felt252_dict_entry_finalize","felt252_dict_entry_get","felt252_dict_new","felt252_dict_squash","felt252_div","felt252_is_zero","felt252_mul","felt252_sub","finalize_locals","function_call","gas_reserve_create","gas_reserve_utilize","get_block_hash_syscall","get_builtin_costs","get_circuit_descriptor","get_circuit_output","get_class_hash_at_syscall","get_execution_info_syscall","get_execution_info_v2_syscall","get_execution_info_v3_syscall","hades_permutation","i128_const","i128_diff","i128_eq","i128_overflowing_add_impl","i128_overflowing_sub_impl","i128_to_felt252","i128_try_from_felt252","i16_const","i16_diff","i16_eq","i16_overflowing_add_impl","i16_overflowing_sub_impl","i16_to_felt252","i16_try_from_felt252","i16_wide_mul","i32_const","i32_diff","i32_eq","i32_overflowing_add_impl","i32_overflowing_sub_impl","i32_to_felt252","i32_try_from_felt252","i32_wide_mul","i64_const","i64_diff","i64_eq","i64_overflowing_add_impl","i64_overflowing_sub_impl","i64_to_felt252","i64_try_from_felt252","i64_wide_mul","i8_const","i8_diff","i8_eq","i8_overflowing_add_impl","i8_overflowing_sub_impl","i8_to_felt252","i8_try_from_felt252","i8_wide_mul","init_circuit_data","int_range_pop_front","int_range_try_new","into_box","into_u96_guarantee","jump","keccak_syscall","library_call_syscall","local_into_box","match_nullable","meta_tx_v0_syscall","null","nullable_forward_snapshot","nullable_from_box","pedersen","redeposit_gas","rename","replace_class_syscall","revoke_ap_tracking","secp256k1_add_syscall","secp256k1_get_point_from_x_syscall","secp256k1_get_xy_syscall","secp256k1_mul_syscall","secp256k1_new_syscall","secp256r1_add_syscall","secp256r1_get_point_from_x_syscall","secp256r1_get_xy_syscall","secp256r1_mul_syscall","secp256r1_new_syscall","send_message_to_l1_syscall","sha256_process_block_syscall","sha256_state_handle_digest","sha256_state_handle_init","sha512_process_block_syscall","sha512_state_handle_digest","sha512_state_handle_init","snapshot_take","span_from_tuple","squashed_felt252_dict_entries","storage_address_from_base","storage_address_from_base_and_offset","storage_address_to_felt252","storage_address_try_from_felt252","storage_base_address_const","storage_base_address_from_felt252","storage_read_syscall","storage_write_syscall","store_local","store_temp","struct_boxed_deconstruct","struct_construct","struct_deconstruct","struct_snapshot_deconstruct","try_into_circuit_modulus","tuple_from_span","u128_byte_reverse","u128_const","u128_eq","u128_guarantee_mul","u128_is_zero","u128_mul_guarantee_verify","u128_overflowing_add","u128_overflowing_sub","u128_safe_divmod","u128_sqrt","u128_to_felt252","u128s_from_felt252","u16_bitwise","u16_const","u16_eq","u16_is_zero","u16_overflowing_add","u16_overflowing_sub","u16_safe_divmod","u16_sqrt","u16_to_felt252","u16_try_from_felt252","u16_wide_mul","u256_guarantee_inv_mod_n","u256_is_zero","u256_safe_divmod","u256_sqrt","u32_bitwise","u32_const","u32_eq","u32_is_zero","u32_overflowing_add","u32_overflowing_sub","u32_safe_divmod","u32_sqrt","u32_to_felt252","u32_try_from_felt252","u32_wide_mul","u512_safe_divmod_by_u256","u64_bitwise","u64_const","u64_eq","u64_is_zero","u64_overflowing_add","u64_overflowing_sub","u64_safe_divmod","u64_sqrt","u64_to_felt252","u64_try_from_felt252","u64_wide_mul","u8_bitwise","u8_const","u8_eq","u8_is_zero","u8_overflowing_add","u8_overflowing_sub","u8_safe_divmod","u8_sqrt","u8_to_felt252","u8_try_from_felt252","u8_wide_mul","u96_guarantee_verify","u96_limbs_less_than_guarantee_verify","u96_single_limb_less_than_guarantee_verify","unbox","unwrap_non_zero","upcast","withdraw_gas","withdraw_gas_all"]}
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,26 @@ mod OsResourcesTestContract {
starknet::VALIDATED
}

#[allow(extern_outside_corelib)]
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;

// Declared inline (not yet re-exported by the pinned compiler's corelib), same as
// `meta_tx_v0_syscall` above.
#[allow(extern_outside_corelib)]
extern fn deploy_v2_syscall(
class_hash: ClassHash,
contract_address_salt: felt252,
calldata: Span<felt252>,
deploy_from_zero: bool,
) -> starknet::SyscallResult<(ContractAddress, Span<felt252>)> implicits(
GasBuiltin, System,
) nopanic;

// Calls every measured syscall in order.
#[external(v0)]
fn __execute__(
Expand Down Expand Up @@ -116,6 +129,15 @@ mod OsResourcesTestContract {
// linear factor:
deploy_syscall(stable_class_hash, 3, large_input.span(), true).unwrap_syscall();

// deploy_v2 syscall (Blake-escaped address derivation; same request/response as deploy).
// Measured base + linear like deploy. A distinct salt is used so the derived addresses don't
// collide with the deploy calls above (the Blake and Pedersen address spaces are disjoint
// regardless, but keeping the salt distinct is clearer).
// base:
deploy_v2_syscall(stable_class_hash, 4, array![0].span(), true).unwrap_syscall();
// linear factor:
deploy_v2_syscall(stable_class_hash, 4, large_input.span(), true).unwrap_syscall();

// emit event syscall.
emit_event_syscall(array![5].span(), array![7].span()).unwrap_syscall();

Expand Down
6 changes: 2 additions & 4 deletions crates/starknet_os_flow_tests/src/os_resources_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,9 @@ use crate::test_manager::{
use crate::tests::NON_TRIVIAL_RESOURCE_BOUNDS;

// TODO(Dori): Delete this, or at least reduce it to a minimal set of unmeasurable syscalls.
const UNMEASURABLE_SYSCALLS: [Selector; 13] = [
const UNMEASURABLE_SYSCALLS: [Selector; 12] = [
Selector::DelegateCall,
Selector::DelegateL1Handler,
// TODO(Ron): measure deploy_v2 once the Cairo compiler exposes it (its versioned-constants
// profile is a provisional copy of Deploy's until then).
Selector::DeployV2,
Selector::GetBlockNumber,
Selector::GetBlockTimestamp,
Selector::GetCallerAddress,
Expand Down Expand Up @@ -101,6 +98,7 @@ const UNMEASURABLE_SYSCALLS: [Selector; 13] = [
static SYSCALLS_WITH_LINEAR_FACTOR: LazyLock<HashMap<Selector, usize>> = LazyLock::new(|| {
HashMap::from([
(Selector::Deploy, 1),
(Selector::DeployV2, 1),
(Selector::Keccak, 0),
(Selector::MetaTxV0, 1),
(Selector::SendMessageToL1, 0),
Expand Down
Loading