diff --git a/crates/bin/prove_block/tests/prove_block.rs b/crates/bin/prove_block/tests/prove_block.rs index 0b94a3e9..d3bdf672 100644 --- a/crates/bin/prove_block/tests/prove_block.rs +++ b/crates/bin/prove_block/tests/prove_block.rs @@ -68,6 +68,10 @@ const DEFAULT_COMPILED_OS: &[u8] = include_bytes!("../../../../build/os_latest.j #[case::peekable_peek_is_none(174156)] #[case::no_more_storage_reads_available(161884)] #[case::no_more_storage_reads_available(174027)] +#[case::memory_addresses_must_be_relocatable(202083)] +#[case::memory_invalid_signature(216914)] +#[case::diff_assert_values(218624)] +#[case::could_nt_compute_operand_op1(204337)] // The following ten tests were added due key not found in preimage (verify_game contract function related) #[case::key_not_found_in_preimage_0(237025)] #[case::key_not_found_in_preimage_1(237030)] diff --git a/crates/starknet-os/src/hints/execute_transactions.rs b/crates/starknet-os/src/hints/execute_transactions.rs index e9a13966..6477e851 100644 --- a/crates/starknet-os/src/hints/execute_transactions.rs +++ b/crates/starknet-os/src/hints/execute_transactions.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::{ - get_integer_from_var_name, get_ptr_from_var_name, get_relocatable_from_var_name, insert_value_from_var_name, + get_integer_from_var_name, get_ptr_from_var_name, insert_value_from_var_name, }; use cairo_vm::hint_processor::builtin_hint_processor::sha256_utils::sha256_finalize; use cairo_vm::hint_processor::hint_processor_definition::HintReference; @@ -38,8 +38,9 @@ where { let execution_helper: ExecutionHelperWrapper = exec_scopes.get(vars::scopes::EXECUTION_HELPER)?; let execution_context_ptr = - get_relocatable_from_var_name(vars::ids::VALIDATE_DECLARE_EXECUTION_CONTEXT, vm, ids_data, ap_tracking)?; - let deprecated_tx_info_ptr = (execution_context_ptr + ExecutionContext::deprecated_tx_info_offset())?; + get_ptr_from_var_name(vars::ids::VALIDATE_DECLARE_EXECUTION_CONTEXT, vm, ids_data, ap_tracking)?; + let deprecated_tx_info_ptr = + vm.get_relocatable((execution_context_ptr + ExecutionContext::deprecated_tx_info_offset())?)?; execution_helper.start_tx(Some(deprecated_tx_info_ptr)).await; diff --git a/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/account_with_syscall_checks.cairo b/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/account_with_syscall_checks.cairo new file mode 100644 index 00000000..591339d1 --- /dev/null +++ b/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/account_with_syscall_checks.cairo @@ -0,0 +1,90 @@ +// A dummy account contract to replicate a get_tx_info bug. +// This is added to specifically check `get_tx_info` call that had a buggy implementation +%lang starknet + +from starkware.cairo.common.bool import FALSE +from starkware.cairo.common.cairo_builtins import HashBuiltin +from starkware.starknet.common.syscalls import ( + call_contract, + deploy, + emit_event, + get_block_number, + get_block_timestamp, + get_caller_address, + get_contract_address, + get_tx_info, + get_tx_signature, + library_call, + library_call_l1_handler, + replace_class, + storage_read, + storage_write, +) + +// This attempts to check all relevant syscalls in account contracts +// which have been buggy esp on `get_tx_info` +func check_all{syscall_ptr: felt*}() { + let (tx_info) = get_tx_info(); + with_attr error_message("tx_info.signature_len failed") { + assert tx_info.signature_len = 0; + } + + let (block_number) = get_block_number(); + assert block_number = 2000; + + let (block_timestamp) = get_block_timestamp(); + assert block_timestamp = 1069200; + + let (contract_address) = get_contract_address(); + + let (caller_address) = get_caller_address(); + assert caller_address = 0; + + let (prev_value) = storage_read(address=contract_address); + storage_write(contract_address, value=prev_value + 1); + + + let (signature_len: felt, signature: felt*) = get_tx_signature(); + assert signature_len = 0; + + storage_write(address=contract_address, value=1); + + let (res) = storage_read(address=contract_address); + assert res = 1; + + return (); +} + +@external +func __validate_declare__{syscall_ptr: felt*}(class_hash: felt) { + check_all(); + return (); +} + +// The hint implementation was using get_relocatable_from_var_name instead of get_ptr_from_var_name +@external +func __validate_deploy__{syscall_ptr: felt*}(class_hash: felt, contract_address_salt: felt) { + check_all(); + return (); +} + +@external +func __validate__{syscall_ptr: felt*}(contract_address, selector: felt, calldata_len: felt, calldata: felt*) { + check_all(); + return (); +} + +@external +@raw_output +func __execute__{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( + contract_address, selector: felt, calldata_len: felt, calldata: felt* +) -> (retdata_size: felt, retdata: felt*) { + check_all(); + let (retdata_size: felt, retdata: felt*) = call_contract( + contract_address=contract_address, + function_selector=selector, + calldata_size=calldata_len, + calldata=calldata, + ); + return (retdata_size=retdata_size, retdata=retdata); +} diff --git a/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/account_with_tx_info_check.cairo b/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/account_with_tx_info_check.cairo deleted file mode 100644 index e38c3ffa..00000000 --- a/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/account_with_tx_info_check.cairo +++ /dev/null @@ -1,44 +0,0 @@ -// A dummy account contract to replicate a get_tx_info bug. -// This is added to specifically check `get_tx_info` call that had a buggy implementation -%lang starknet - -from starkware.cairo.common.bool import FALSE -from starkware.cairo.common.cairo_builtins import HashBuiltin -from starkware.starknet.common.syscalls import ( - call_contract, - get_tx_info -) - -@external -func __validate_declare__(class_hash: felt) { - return (); -} - -// The hint implementation was using get_relocatable_from_var_name instead of get_ptr_from_var_name -@external -func __validate_deploy__{syscall_ptr: felt*}(class_hash: felt, contract_address_salt: felt) { - let (tx_info) = get_tx_info(); - with_attr error_message("assertion failed") { - assert tx_info.signature_len = 0; - } - return (); -} - -@external -func __validate__(contract_address, selector: felt, calldata_len: felt, calldata: felt*) { - return (); -} - -@external -@raw_output -func __execute__{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( - contract_address, selector: felt, calldata_len: felt, calldata: felt* -) -> (retdata_size: felt, retdata: felt*) { - let (retdata_size: felt, retdata: felt*) = call_contract( - contract_address=contract_address, - function_selector=selector, - calldata_size=calldata_len, - calldata=calldata, - ); - return (retdata_size=retdata_size, retdata=retdata); -} diff --git a/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/compiled/account_with_tx_info_check_compiled.json b/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/compiled/account_with_syscall_checks_compiled.json similarity index 56% rename from tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/compiled/account_with_tx_info_check_compiled.json rename to tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/compiled/account_with_syscall_checks_compiled.json index 11c5ab90..3c41a643 100644 --- a/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/compiled/account_with_tx_info_check_compiled.json +++ b/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo0/compiled/account_with_syscall_checks_compiled.json @@ -86,19 +86,19 @@ "CONSTRUCTOR": [], "EXTERNAL": [ { - "offset": 100, + "offset": 262, "selector": "0x15d40a3d6ca2ac30f4031e42be28da9b056fef9bb7357ac5e85627ee876e5ad" }, { - "offset": 61, + "offset": 220, "selector": "0x162da33a4585851fe8d3af3c2a9c60b557814e221e0d4f30ff0b2189d9c7775" }, { - "offset": 20, + "offset": 179, "selector": "0x289da278a8dc833409cabfdad1581e8e7d40e42dcaed693fa4008dcdb4963b3" }, { - "offset": 43, + "offset": 199, "selector": "0x36fcbf06cd96843058359e1a75928beacfac10727dab22a3972f0af8aa92895" } ], @@ -109,20 +109,19 @@ { "accessible_scopes": [ "__main__", - "__main__", - "__main__.__validate_deploy__" + "__main__.check_all" ], - "end_pc": 41, + "end_pc": 130, "flow_tracking_data": { "ap_tracking": { - "group": 4, + "group": 14, "offset": 6 }, "reference_ids": {} }, "name": "error_message", - "start_pc": 38, - "value": "assertion failed" + "start_pc": 127, + "value": "tx_info.signature_len failed" } ], "builtins": [ @@ -144,22 +143,182 @@ "0x480280067ff98000", "0x208b7fff7fff7ffe", "0x480680017fff8000", + "0x4c69627261727943616c6c", + "0x400280007ff97fff", + "0x400380017ff97ffa", + "0x400380027ff97ffb", + "0x400380037ff97ffc", + "0x400380047ff97ffd", + "0x482680017ff98000", + "0x7", + "0x480280057ff98000", + "0x480280067ff98000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x4c69627261727943616c6c4c3148616e646c6572", + "0x400280007ff97fff", + "0x400380017ff97ffa", + "0x400380027ff97ffb", + "0x400380037ff97ffc", + "0x400380047ff97ffd", + "0x482680017ff98000", + "0x7", + "0x480280057ff98000", + "0x480280067ff98000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x4465706c6f79", + "0x400280007ff87fff", + "0x400380017ff87ff9", + "0x400380027ff87ffa", + "0x400380037ff87ffb", + "0x400380047ff87ffc", + "0x400380057ff87ffd", + "0x482680017ff88000", + "0x9", + "0x480280067ff88000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x47657443616c6c657241646472657373", + "0x400280007ffd7fff", + "0x482680017ffd8000", + "0x2", + "0x480280017ffd8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x476574426c6f636b4e756d626572", + "0x400280007ffd7fff", + "0x482680017ffd8000", + "0x2", + "0x480280017ffd8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x476574436f6e747261637441646472657373", + "0x400280007ffd7fff", + "0x482680017ffd8000", + "0x2", + "0x480280017ffd8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x476574426c6f636b54696d657374616d70", + "0x400280007ffd7fff", + "0x482680017ffd8000", + "0x2", + "0x480280017ffd8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x47657454785369676e6174757265", + "0x400280007ffd7fff", + "0x482680017ffd8000", + "0x3", + "0x480280017ffd8000", + "0x480280027ffd8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x53746f7261676552656164", + "0x400280007ffc7fff", + "0x400380017ffc7ffd", + "0x482680017ffc8000", + "0x3", + "0x480280027ffc8000", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x53746f726167655772697465", + "0x400280007ffb7fff", + "0x400380017ffb7ffc", + "0x400380027ffb7ffd", + "0x482680017ffb8000", + "0x3", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x456d69744576656e74", + "0x400280007ff97fff", + "0x400380017ff97ffa", + "0x400380027ff97ffb", + "0x400380037ff97ffc", + "0x400380047ff97ffd", + "0x482680017ff98000", + "0x5", + "0x208b7fff7fff7ffe", + "0x480680017fff8000", "0x4765745478496e666f", "0x400280007ffd7fff", "0x482680017ffd8000", "0x2", "0x480280017ffd8000", "0x208b7fff7fff7ffe", + "0x480680017fff8000", + "0x5265706c616365436c617373", + "0x400280007ffc7fff", + "0x400380017ffc7ffd", + "0x482680017ffc8000", + "0x2", + "0x208b7fff7fff7ffe", + "0x480a7ffd7fff8000", + "0x1104800180018000", + "0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffff2", + "0x480680017fff8000", + "0x0", + "0x400080037ffe7fff", + "0x48127ffd7fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffb5", + "0x400680017fff7fff", + "0x7d0", + "0x48127ffe7fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffbe", + "0x400680017fff7fff", + "0x105090", + "0x48127ffe7fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffb2", + "0x48127ffe7fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffa1", + "0x400680017fff7fff", + "0x0", + "0x48127ffe7fff8000", + "0x48127ff87fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffbf", + "0x48127ffe7fff8000", + "0x48127ff17fff8000", + "0x482480017ffd8000", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffc1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffaf", + "0x400680017fff7ffe", + "0x0", + "0x48127ffd7fff8000", + "0x48127fe47fff8000", + "0x480680017fff8000", + "0x1", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffb7", + "0x48127fde7fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffac", + "0x400680017fff7fff", + "0x1", + "0x48127ffe7fff8000", + "0x208b7fff7fff7ffe", + "0x480a7ffc7fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffcd", "0x208b7fff7fff7ffe", "0x482680017ffd8000", "0x1", "0x402a7ffd7ffc7fff", + "0x480280007ffb8000", "0x480280007ffd8000", "0x1104800180018000", - "0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffffc", + "0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffff8", "0x40780017fff7fff", "0x1", - "0x480280007ffb8000", + "0x48127ffe7fff8000", "0x480280017ffb8000", "0x480280027ffb8000", "0x480680017fff8000", @@ -168,11 +327,7 @@ "0x208b7fff7fff7ffe", "0x480a7ffb7fff8000", "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe9", - "0x480680017fff8000", - "0x0", - "0x400080037ffe7fff", - "0x48127ffd7fff8000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffb9", "0x208b7fff7fff7ffe", "0x482680017ffd8000", "0x2", @@ -181,7 +336,7 @@ "0x480280007ffd8000", "0x480280017ffd8000", "0x1104800180018000", - "0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffff3", + "0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffff7", "0x40780017fff7fff", "0x1", "0x48127ffe7fff8000", @@ -191,6 +346,9 @@ "0x0", "0x48127ffb7fff8000", "0x208b7fff7fff7ffe", + "0x480a7ff97fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffa4", "0x208b7fff7fff7ffe", "0x480280027ffb8000", "0x480280027ffd8000", @@ -200,17 +358,18 @@ "0x480280027ffd8000", "0x48307fff7ffe8000", "0x402a7ffd7ffc7fff", + "0x480280007ffb8000", "0x480280007ffd8000", "0x480280017ffd8000", "0x480280027ffd8000", "0x482680017ffd8000", "0x3", "0x1104800180018000", - "0x800000000000010fffffffffffffffffffffffffffffffffffffffffffffff3", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffef", "0x40780017fff7fff", "0x1", "0x480280027ffb8000", - "0x480280007ffb8000", + "0x48127ffd7fff8000", "0x480280017ffb8000", "0x482480017ffd8000", "0x1", @@ -219,12 +378,14 @@ "0x48127ffa7fff8000", "0x208b7fff7fff7ffe", "0x480a7ff77fff8000", + "0x1104800180018000", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffff85", "0x480a7ffa7fff8000", "0x480a7ffb7fff8000", "0x480a7ffc7fff8000", "0x480a7ffd7fff8000", "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffa5", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffff03", "0x48127ffd7fff8000", "0x480a7ff87fff8000", "0x480a7ff97fff8000", @@ -250,7 +411,7 @@ "0x482680017ffd8000", "0x3", "0x1104800180018000", - "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe2", + "0x800000000000010ffffffffffffffffffffffffffffffffffffffffffffffe0", "0x208b7fff7fff7ffe" ], "debug_info": null, @@ -273,133 +434,349 @@ } } ], - "15": [ + "19": [ { "accessible_scopes": [ "starkware.starknet.common.syscalls", - "starkware.starknet.common.syscalls.get_tx_info" + "starkware.starknet.common.syscalls.library_call" ], - "code": "syscall_handler.get_tx_info(segments=segments, syscall_ptr=ids.syscall_ptr)", + "code": "syscall_handler.library_call(segments=segments, syscall_ptr=ids.syscall_ptr)", "flow_tracking_data": { "ap_tracking": { "group": 1, "offset": 1 }, "reference_ids": { - "starkware.starknet.common.syscalls.get_tx_info.syscall_ptr": 1 + "starkware.starknet.common.syscalls.library_call.syscall_ptr": 1 } } } ], - "26": [ + "31": [ { "accessible_scopes": [ - "__main__", - "__main__", - "__wrappers__", - "__wrappers__.__validate_declare__" + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.library_call_l1_handler" ], - "code": "memory[ap] = segments.add()", + "code": "syscall_handler.library_call_l1_handler(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 2, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.library_call_l1_handler.syscall_ptr": 2 + } + } + } + ], + "44": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.deploy" + ], + "code": "syscall_handler.deploy(segments=segments, syscall_ptr=ids.syscall_ptr)", "flow_tracking_data": { "ap_tracking": { "group": 3, - "offset": 4 + "offset": 1 }, - "reference_ids": {} + "reference_ids": { + "starkware.starknet.common.syscalls.deploy.syscall_ptr": 3 + } } } ], "51": [ { "accessible_scopes": [ - "__main__", - "__main__", - "__wrappers__", - "__wrappers__.__validate_deploy__" + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.get_caller_address" ], - "code": "memory[ap] = segments.add()", + "code": "syscall_handler.get_caller_address(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 4, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.get_caller_address.syscall_ptr": 4 + } + } + } + ], + "58": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.get_block_number" + ], + "code": "syscall_handler.get_block_number(segments=segments, syscall_ptr=ids.syscall_ptr)", "flow_tracking_data": { "ap_tracking": { "group": 5, - "offset": 14 + "offset": 1 }, - "reference_ids": {} + "reference_ids": { + "starkware.starknet.common.syscalls.get_block_number.syscall_ptr": 5 + } } } ], - "76": [ + "65": [ { "accessible_scopes": [ - "__main__", - "__main__", - "__wrappers__", - "__wrappers__.__validate__" + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.get_contract_address" ], - "code": "memory[ap] = segments.add()", + "code": "syscall_handler.get_contract_address(segments=segments, syscall_ptr=ids.syscall_ptr)", "flow_tracking_data": { "ap_tracking": { - "group": 7, - "offset": 11 + "group": 6, + "offset": 1 }, - "reference_ids": {} + "reference_ids": { + "starkware.starknet.common.syscalls.get_contract_address.syscall_ptr": 6 + } } } - ] - }, - "identifiers": { - "__main__.FALSE": { - "destination": "starkware.cairo.common.bool.FALSE", - "type": "alias" - }, - "__main__.HashBuiltin": { - "destination": "starkware.cairo.common.cairo_builtins.HashBuiltin", - "type": "alias" - }, - "__main__.__execute__": { - "decorators": [ - "external", - "raw_output" - ], - "pc": 87, - "type": "function" - }, - "__main__.__execute__.Args": { - "full_name": "__main__.__execute__.Args", - "members": { - "calldata": { - "cairo_type": "felt*", - "offset": 3 - }, - "calldata_len": { - "cairo_type": "felt", - "offset": 2 - }, - "contract_address": { - "cairo_type": "felt", - "offset": 0 - }, - "selector": { - "cairo_type": "felt", - "offset": 1 + ], + "72": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.get_block_timestamp" + ], + "code": "syscall_handler.get_block_timestamp(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 7, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.get_block_timestamp.syscall_ptr": 7 + } } - }, - "size": 4, - "type": "struct" - }, - "__main__.__execute__.ImplicitArgs": { - "full_name": "__main__.__execute__.ImplicitArgs", - "members": { - "pedersen_ptr": { - "cairo_type": "starkware.cairo.common.cairo_builtins.HashBuiltin*", - "offset": 1 - }, - "range_check_ptr": { - "cairo_type": "felt", - "offset": 2 - }, - "syscall_ptr": { - "cairo_type": "felt*", - "offset": 0 + } + ], + "79": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.get_tx_signature" + ], + "code": "syscall_handler.get_tx_signature(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 8, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.get_tx_signature.syscall_ptr": 8 + } + } + } + ], + "88": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.storage_read" + ], + "code": "syscall_handler.storage_read(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 9, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.storage_read.syscall_ptr": 9 + } + } + } + ], + "97": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.storage_write" + ], + "code": "syscall_handler.storage_write(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 10, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.storage_write.syscall_ptr": 10 + } + } + } + ], + "107": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.emit_event" + ], + "code": "syscall_handler.emit_event(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 11, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.emit_event.syscall_ptr": 11 + } + } + } + ], + "113": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.get_tx_info" + ], + "code": "syscall_handler.get_tx_info(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 12, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.get_tx_info.syscall_ptr": 12 + } + } + } + ], + "121": [ + { + "accessible_scopes": [ + "starkware.starknet.common.syscalls", + "starkware.starknet.common.syscalls.replace_class" + ], + "code": "syscall_handler.replace_class(segments=segments, syscall_ptr=ids.syscall_ptr)", + "flow_tracking_data": { + "ap_tracking": { + "group": 13, + "offset": 1 + }, + "reference_ids": { + "starkware.starknet.common.syscalls.replace_class.syscall_ptr": 13 + } + } + } + ], + "186": [ + { + "accessible_scopes": [ + "__main__", + "__main__", + "__wrappers__", + "__wrappers__.__validate_declare__" + ], + "code": "memory[ap] = segments.add()", + "flow_tracking_data": { + "ap_tracking": { + "group": 16, + "offset": 73 + }, + "reference_ids": {} + } + } + ], + "207": [ + { + "accessible_scopes": [ + "__main__", + "__main__", + "__wrappers__", + "__wrappers__.__validate_deploy__" + ], + "code": "memory[ap] = segments.add()", + "flow_tracking_data": { + "ap_tracking": { + "group": 18, + "offset": 74 + }, + "reference_ids": {} + } + } + ], + "236": [ + { + "accessible_scopes": [ + "__main__", + "__main__", + "__wrappers__", + "__wrappers__.__validate__" + ], + "code": "memory[ap] = segments.add()", + "flow_tracking_data": { + "ap_tracking": { + "group": 20, + "offset": 80 + }, + "reference_ids": {} + } + } + ] + }, + "identifiers": { + "__main__.FALSE": { + "destination": "starkware.cairo.common.bool.FALSE", + "type": "alias" + }, + "__main__.HashBuiltin": { + "destination": "starkware.cairo.common.cairo_builtins.HashBuiltin", + "type": "alias" + }, + "__main__.__execute__": { + "decorators": [ + "external", + "raw_output" + ], + "pc": 247, + "type": "function" + }, + "__main__.__execute__.Args": { + "full_name": "__main__.__execute__.Args", + "members": { + "calldata": { + "cairo_type": "felt*", + "offset": 3 + }, + "calldata_len": { + "cairo_type": "felt", + "offset": 2 + }, + "contract_address": { + "cairo_type": "felt", + "offset": 0 + }, + "selector": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 4, + "type": "struct" + }, + "__main__.__execute__.ImplicitArgs": { + "full_name": "__main__.__execute__.ImplicitArgs", + "members": { + "pedersen_ptr": { + "cairo_type": "starkware.cairo.common.cairo_builtins.HashBuiltin*", + "offset": 1 + }, + "range_check_ptr": { + "cairo_type": "felt", + "offset": 2 + }, + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 } }, "size": 3, @@ -417,7 +794,7 @@ "decorators": [ "external" ], - "pc": 60, + "pc": 216, "type": "function" }, "__main__.__validate__.Args": { @@ -445,8 +822,13 @@ }, "__main__.__validate__.ImplicitArgs": { "full_name": "__main__.__validate__.ImplicitArgs", - "members": {}, - "size": 0, + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, "type": "struct" }, "__main__.__validate__.Return": { @@ -461,7 +843,7 @@ "decorators": [ "external" ], - "pc": 19, + "pc": 175, "type": "function" }, "__main__.__validate_declare__.Args": { @@ -477,8 +859,13 @@ }, "__main__.__validate_declare__.ImplicitArgs": { "full_name": "__main__.__validate_declare__.ImplicitArgs", - "members": {}, - "size": 0, + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, "type": "struct" }, "__main__.__validate_declare__.Return": { @@ -493,7 +880,7 @@ "decorators": [ "external" ], - "pc": 35, + "pc": 195, "type": "function" }, "__main__.__validate_deploy__.Args": { @@ -534,16 +921,94 @@ "destination": "starkware.starknet.common.syscalls.call_contract", "type": "alias" }, + "__main__.check_all": { + "decorators": [], + "pc": 124, + "type": "function" + }, + "__main__.check_all.Args": { + "full_name": "__main__.check_all.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "__main__.check_all.ImplicitArgs": { + "full_name": "__main__.check_all.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "__main__.check_all.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "__main__.check_all.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "__main__.deploy": { + "destination": "starkware.starknet.common.syscalls.deploy", + "type": "alias" + }, + "__main__.emit_event": { + "destination": "starkware.starknet.common.syscalls.emit_event", + "type": "alias" + }, + "__main__.get_block_number": { + "destination": "starkware.starknet.common.syscalls.get_block_number", + "type": "alias" + }, + "__main__.get_block_timestamp": { + "destination": "starkware.starknet.common.syscalls.get_block_timestamp", + "type": "alias" + }, + "__main__.get_caller_address": { + "destination": "starkware.starknet.common.syscalls.get_caller_address", + "type": "alias" + }, + "__main__.get_contract_address": { + "destination": "starkware.starknet.common.syscalls.get_contract_address", + "type": "alias" + }, "__main__.get_tx_info": { "destination": "starkware.starknet.common.syscalls.get_tx_info", "type": "alias" }, + "__main__.get_tx_signature": { + "destination": "starkware.starknet.common.syscalls.get_tx_signature", + "type": "alias" + }, + "__main__.library_call": { + "destination": "starkware.starknet.common.syscalls.library_call", + "type": "alias" + }, + "__main__.library_call_l1_handler": { + "destination": "starkware.starknet.common.syscalls.library_call_l1_handler", + "type": "alias" + }, + "__main__.replace_class": { + "destination": "starkware.starknet.common.syscalls.replace_class", + "type": "alias" + }, + "__main__.storage_read": { + "destination": "starkware.starknet.common.syscalls.storage_read", + "type": "alias" + }, + "__main__.storage_write": { + "destination": "starkware.starknet.common.syscalls.storage_write", + "type": "alias" + }, "__wrappers__.__execute__": { "decorators": [ "external", "raw_output" ], - "pc": 100, + "pc": 262, "type": "function" }, "__wrappers__.__execute__.Args": { @@ -578,7 +1043,7 @@ "decorators": [ "external" ], - "pc": 61, + "pc": 220, "type": "function" }, "__wrappers__.__validate__.Args": { @@ -594,7 +1059,7 @@ "type": "struct" }, "__wrappers__.__validate__.Return": { - "cairo_type": "(syscall_ptr: felt, pedersen_ptr: felt, range_check_ptr: felt, size: felt, retdata: felt*)", + "cairo_type": "(syscall_ptr: felt*, pedersen_ptr: felt, range_check_ptr: felt, size: felt, retdata: felt*)", "type": "type_definition" }, "__wrappers__.__validate__.SIZEOF_LOCALS": { @@ -613,7 +1078,7 @@ "decorators": [ "external" ], - "pc": 20, + "pc": 179, "type": "function" }, "__wrappers__.__validate_declare__.Args": { @@ -629,7 +1094,7 @@ "type": "struct" }, "__wrappers__.__validate_declare__.Return": { - "cairo_type": "(syscall_ptr: felt, pedersen_ptr: felt, range_check_ptr: felt, size: felt, retdata: felt*)", + "cairo_type": "(syscall_ptr: felt*, pedersen_ptr: felt, range_check_ptr: felt, size: felt, retdata: felt*)", "type": "type_definition" }, "__wrappers__.__validate_declare__.SIZEOF_LOCALS": { @@ -648,7 +1113,7 @@ "decorators": [ "external" ], - "pc": 43, + "pc": 199, "type": "function" }, "__wrappers__.__validate_deploy__.Args": { @@ -1712,55 +2177,782 @@ ], "type": "reference" }, - "starkware.starknet.common.syscalls.get_tx_info": { + "starkware.starknet.common.syscalls.deploy": { "decorators": [], - "pc": 12, + "pc": 36, "type": "function" }, - "starkware.starknet.common.syscalls.get_tx_info.Args": { - "full_name": "starkware.starknet.common.syscalls.get_tx_info.Args", - "members": {}, - "size": 0, - "type": "struct" - }, - "starkware.starknet.common.syscalls.get_tx_info.ImplicitArgs": { - "full_name": "starkware.starknet.common.syscalls.get_tx_info.ImplicitArgs", + "starkware.starknet.common.syscalls.deploy.Args": { + "full_name": "starkware.starknet.common.syscalls.deploy.Args", "members": { - "syscall_ptr": { - "cairo_type": "felt*", + "class_hash": { + "cairo_type": "felt", "offset": 0 - } - }, - "size": 1, - "type": "struct" - }, - "starkware.starknet.common.syscalls.get_tx_info.Return": { + }, + "constructor_calldata": { + "cairo_type": "felt*", + "offset": 3 + }, + "constructor_calldata_size": { + "cairo_type": "felt", + "offset": 2 + }, + "contract_address_salt": { + "cairo_type": "felt", + "offset": 1 + }, + "deploy_from_zero": { + "cairo_type": "felt", + "offset": 4 + } + }, + "size": 5, + "type": "struct" + }, + "starkware.starknet.common.syscalls.deploy.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.deploy.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.deploy.Return": { + "cairo_type": "(contract_address: felt)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.deploy.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.deploy.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.deploy.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 3, + "offset": 0 + }, + "pc": 36, + "value": "[cast(fp + (-8), felt**)]" + }, + { + "ap_tracking_data": { + "group": 3, + "offset": 1 + }, + "pc": 44, + "value": "cast([fp + (-8)] + 9, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.emit_event": { + "decorators": [], + "pc": 100, + "type": "function" + }, + "starkware.starknet.common.syscalls.emit_event.Args": { + "full_name": "starkware.starknet.common.syscalls.emit_event.Args", + "members": { + "data": { + "cairo_type": "felt*", + "offset": 3 + }, + "data_len": { + "cairo_type": "felt", + "offset": 2 + }, + "keys": { + "cairo_type": "felt*", + "offset": 1 + }, + "keys_len": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 4, + "type": "struct" + }, + "starkware.starknet.common.syscalls.emit_event.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.emit_event.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.emit_event.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.emit_event.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.emit_event.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.emit_event.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 11, + "offset": 0 + }, + "pc": 100, + "value": "[cast(fp + (-7), felt**)]" + }, + { + "ap_tracking_data": { + "group": 11, + "offset": 1 + }, + "pc": 107, + "value": "cast([fp + (-7)] + 5, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.get_block_number": { + "decorators": [], + "pc": 55, + "type": "function" + }, + "starkware.starknet.common.syscalls.get_block_number.Args": { + "full_name": "starkware.starknet.common.syscalls.get_block_number.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_block_number.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.get_block_number.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_block_number.Return": { + "cairo_type": "(block_number: felt)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.get_block_number.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.get_block_number.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.get_block_number.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 5, + "offset": 0 + }, + "pc": 55, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 5, + "offset": 1 + }, + "pc": 58, + "value": "cast([fp + (-3)] + 2, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.get_block_timestamp": { + "decorators": [], + "pc": 69, + "type": "function" + }, + "starkware.starknet.common.syscalls.get_block_timestamp.Args": { + "full_name": "starkware.starknet.common.syscalls.get_block_timestamp.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_block_timestamp.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.get_block_timestamp.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_block_timestamp.Return": { + "cairo_type": "(block_timestamp: felt)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.get_block_timestamp.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.get_block_timestamp.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.get_block_timestamp.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 7, + "offset": 0 + }, + "pc": 69, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 7, + "offset": 1 + }, + "pc": 72, + "value": "cast([fp + (-3)] + 2, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.get_caller_address": { + "decorators": [], + "pc": 48, + "type": "function" + }, + "starkware.starknet.common.syscalls.get_caller_address.Args": { + "full_name": "starkware.starknet.common.syscalls.get_caller_address.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_caller_address.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.get_caller_address.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_caller_address.Return": { + "cairo_type": "(caller_address: felt)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.get_caller_address.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.get_caller_address.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.get_caller_address.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 4, + "offset": 0 + }, + "pc": 48, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 4, + "offset": 1 + }, + "pc": 51, + "value": "cast([fp + (-3)] + 2, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.get_contract_address": { + "decorators": [], + "pc": 62, + "type": "function" + }, + "starkware.starknet.common.syscalls.get_contract_address.Args": { + "full_name": "starkware.starknet.common.syscalls.get_contract_address.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_contract_address.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.get_contract_address.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_contract_address.Return": { + "cairo_type": "(contract_address: felt)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.get_contract_address.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.get_contract_address.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.get_contract_address.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 6, + "offset": 0 + }, + "pc": 62, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 6, + "offset": 1 + }, + "pc": 65, + "value": "cast([fp + (-3)] + 2, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.get_tx_info": { + "decorators": [], + "pc": 110, + "type": "function" + }, + "starkware.starknet.common.syscalls.get_tx_info.Args": { + "full_name": "starkware.starknet.common.syscalls.get_tx_info.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_tx_info.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.get_tx_info.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_tx_info.Return": { "cairo_type": "(tx_info: starkware.starknet.common.syscalls.TxInfo*)", "type": "type_definition" }, - "starkware.starknet.common.syscalls.get_tx_info.SIZEOF_LOCALS": { + "starkware.starknet.common.syscalls.get_tx_info.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.get_tx_info.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.get_tx_info.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 12, + "offset": 0 + }, + "pc": 110, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 12, + "offset": 1 + }, + "pc": 113, + "value": "cast([fp + (-3)] + 2, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.get_tx_signature": { + "decorators": [], + "pc": 76, + "type": "function" + }, + "starkware.starknet.common.syscalls.get_tx_signature.Args": { + "full_name": "starkware.starknet.common.syscalls.get_tx_signature.Args", + "members": {}, + "size": 0, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_tx_signature.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.get_tx_signature.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.get_tx_signature.Return": { + "cairo_type": "(signature_len: felt, signature: felt*)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.get_tx_signature.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.get_tx_signature.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.get_tx_signature.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 8, + "offset": 0 + }, + "pc": 76, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 8, + "offset": 1 + }, + "pc": 79, + "value": "cast([fp + (-3)] + 3, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.library_call": { + "decorators": [], + "pc": 12, + "type": "function" + }, + "starkware.starknet.common.syscalls.library_call.Args": { + "full_name": "starkware.starknet.common.syscalls.library_call.Args", + "members": { + "calldata": { + "cairo_type": "felt*", + "offset": 3 + }, + "calldata_size": { + "cairo_type": "felt", + "offset": 2 + }, + "class_hash": { + "cairo_type": "felt", + "offset": 0 + }, + "function_selector": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 4, + "type": "struct" + }, + "starkware.starknet.common.syscalls.library_call.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.library_call.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.library_call.Return": { + "cairo_type": "(retdata_size: felt, retdata: felt*)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.library_call.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.library_call.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.library_call.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 1, + "offset": 0 + }, + "pc": 12, + "value": "[cast(fp + (-7), felt**)]" + }, + { + "ap_tracking_data": { + "group": 1, + "offset": 1 + }, + "pc": 19, + "value": "cast([fp + (-7)] + 7, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.library_call_l1_handler": { + "decorators": [], + "pc": 24, + "type": "function" + }, + "starkware.starknet.common.syscalls.library_call_l1_handler.Args": { + "full_name": "starkware.starknet.common.syscalls.library_call_l1_handler.Args", + "members": { + "calldata": { + "cairo_type": "felt*", + "offset": 3 + }, + "calldata_size": { + "cairo_type": "felt", + "offset": 2 + }, + "class_hash": { + "cairo_type": "felt", + "offset": 0 + }, + "function_selector": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 4, + "type": "struct" + }, + "starkware.starknet.common.syscalls.library_call_l1_handler.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.library_call_l1_handler.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.library_call_l1_handler.Return": { + "cairo_type": "(retdata_size: felt, retdata: felt*)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.library_call_l1_handler.SIZEOF_LOCALS": { "type": "const", "value": 0 }, - "starkware.starknet.common.syscalls.get_tx_info.syscall_ptr": { + "starkware.starknet.common.syscalls.library_call_l1_handler.syscall_ptr": { "cairo_type": "felt*", - "full_name": "starkware.starknet.common.syscalls.get_tx_info.syscall_ptr", + "full_name": "starkware.starknet.common.syscalls.library_call_l1_handler.syscall_ptr", "references": [ { "ap_tracking_data": { - "group": 1, + "group": 2, "offset": 0 }, - "pc": 12, - "value": "[cast(fp + (-3), felt**)]" + "pc": 24, + "value": "[cast(fp + (-7), felt**)]" }, { "ap_tracking_data": { - "group": 1, + "group": 2, "offset": 1 }, - "pc": 15, - "value": "cast([fp + (-3)] + 2, felt*)" + "pc": 31, + "value": "cast([fp + (-7)] + 7, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.replace_class": { + "decorators": [], + "pc": 117, + "type": "function" + }, + "starkware.starknet.common.syscalls.replace_class.Args": { + "full_name": "starkware.starknet.common.syscalls.replace_class.Args", + "members": { + "class_hash": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.replace_class.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.replace_class.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.replace_class.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.replace_class.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.replace_class.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.replace_class.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 13, + "offset": 0 + }, + "pc": 117, + "value": "[cast(fp + (-4), felt**)]" + }, + { + "ap_tracking_data": { + "group": 13, + "offset": 1 + }, + "pc": 121, + "value": "cast([fp + (-4)] + 2, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.storage_read": { + "decorators": [], + "pc": 84, + "type": "function" + }, + "starkware.starknet.common.syscalls.storage_read.Args": { + "full_name": "starkware.starknet.common.syscalls.storage_read.Args", + "members": { + "address": { + "cairo_type": "felt", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.storage_read.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.storage_read.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.storage_read.Return": { + "cairo_type": "(value: felt)", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.storage_read.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.storage_read.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.storage_read.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 9, + "offset": 0 + }, + "pc": 84, + "value": "[cast(fp + (-4), felt**)]" + }, + { + "ap_tracking_data": { + "group": 9, + "offset": 1 + }, + "pc": 88, + "value": "cast([fp + (-4)] + 3, felt*)" + } + ], + "type": "reference" + }, + "starkware.starknet.common.syscalls.storage_write": { + "decorators": [], + "pc": 92, + "type": "function" + }, + "starkware.starknet.common.syscalls.storage_write.Args": { + "full_name": "starkware.starknet.common.syscalls.storage_write.Args", + "members": { + "address": { + "cairo_type": "felt", + "offset": 0 + }, + "value": { + "cairo_type": "felt", + "offset": 1 + } + }, + "size": 2, + "type": "struct" + }, + "starkware.starknet.common.syscalls.storage_write.ImplicitArgs": { + "full_name": "starkware.starknet.common.syscalls.storage_write.ImplicitArgs", + "members": { + "syscall_ptr": { + "cairo_type": "felt*", + "offset": 0 + } + }, + "size": 1, + "type": "struct" + }, + "starkware.starknet.common.syscalls.storage_write.Return": { + "cairo_type": "()", + "type": "type_definition" + }, + "starkware.starknet.common.syscalls.storage_write.SIZEOF_LOCALS": { + "type": "const", + "value": 0 + }, + "starkware.starknet.common.syscalls.storage_write.syscall_ptr": { + "cairo_type": "felt*", + "full_name": "starkware.starknet.common.syscalls.storage_write.syscall_ptr", + "references": [ + { + "ap_tracking_data": { + "group": 10, + "offset": 0 + }, + "pc": 92, + "value": "[cast(fp + (-5), felt**)]" + }, + { + "ap_tracking_data": { + "group": 10, + "offset": 1 + }, + "pc": 97, + "value": "cast([fp + (-5)] + 3, felt*)" } ], "type": "reference" @@ -1784,7 +2976,103 @@ "offset": 0 }, "pc": 12, + "value": "[cast(fp + (-7), felt**)]" + }, + { + "ap_tracking_data": { + "group": 2, + "offset": 0 + }, + "pc": 24, + "value": "[cast(fp + (-7), felt**)]" + }, + { + "ap_tracking_data": { + "group": 3, + "offset": 0 + }, + "pc": 36, + "value": "[cast(fp + (-8), felt**)]" + }, + { + "ap_tracking_data": { + "group": 4, + "offset": 0 + }, + "pc": 48, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 5, + "offset": 0 + }, + "pc": 55, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 6, + "offset": 0 + }, + "pc": 62, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 7, + "offset": 0 + }, + "pc": 69, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 8, + "offset": 0 + }, + "pc": 76, + "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 9, + "offset": 0 + }, + "pc": 84, + "value": "[cast(fp + (-4), felt**)]" + }, + { + "ap_tracking_data": { + "group": 10, + "offset": 0 + }, + "pc": 92, + "value": "[cast(fp + (-5), felt**)]" + }, + { + "ap_tracking_data": { + "group": 11, + "offset": 0 + }, + "pc": 100, + "value": "[cast(fp + (-7), felt**)]" + }, + { + "ap_tracking_data": { + "group": 12, + "offset": 0 + }, + "pc": 110, "value": "[cast(fp + (-3), felt**)]" + }, + { + "ap_tracking_data": { + "group": 13, + "offset": 0 + }, + "pc": 117, + "value": "[cast(fp + (-4), felt**)]" } ] } diff --git a/tests/integration/declare_txn_tests.rs b/tests/integration/declare_txn_tests.rs index f766a362..f39a3226 100644 --- a/tests/integration/declare_txn_tests.rs +++ b/tests/integration/declare_txn_tests.rs @@ -168,9 +168,11 @@ async fn initial_state_declare_cairo0( #[from(init_logging)] _logging: (), ) -> StarknetTestState { let account_with_dummy_validate = load_cairo0_feature_contract("account_with_dummy_validate"); + let account_with_syscall_checks = load_cairo0_feature_contract("account_with_syscall_checks"); StarknetStateBuilder::new(&block_context) .deploy_cairo0_contract(account_with_dummy_validate.0, account_with_dummy_validate.1) + .deploy_cairo0_contract(account_with_syscall_checks.0, account_with_syscall_checks.1) .set_default_balance(BALANCE, BALANCE) .build() .await @@ -220,3 +222,69 @@ async fn declare_v1_cairo0_account( .await .expect("OS run failed"); } + +#[rstest] +// We need to use the multi_thread runtime to use task::block_in_place for sync -> async calls. +#[tokio::test(flavor = "multi_thread", worker_threads = 1)] +async fn declare_cairo0_with_tx_info( + #[future] initial_state_declare_cairo0: StarknetTestState, + block_context: BlockContext, + max_fee: Fee, +) { + let tx_version = TransactionVersion::THREE; + + let mut nonce_manager = NonceManager::default(); + + let initial_state = initial_state_declare_cairo0.await; + let sender_address = initial_state.deployed_cairo0_contracts.get("account_with_syscall_checks").unwrap().address; + + // We want to declare a fresh (never-before-declared) contract, so we don't want to reuse + // anything from the test fixtures, and we need to do it "by hand". The transaction will + // error if the class trie already contains the class we are trying to deploy. + let (_, sierra_class, casm_class) = load_cairo1_feature_contract("test_contract"); + + // We also need to write the class and compiled class facts so that the FFC will contain them + // during block re-execution. + let mut ffc = initial_state.clone_ffc::(); + let (contract_class_hash, compiled_class_hash) = + write_class_facts(sierra_class.clone().into(), casm_class.clone(), &mut ffc).await.unwrap(); + + let contract_class = casm_class.to_blockifier_contract_class().unwrap(); + let class_hash = starknet_api::core::ClassHash::from(contract_class_hash); + let compiled_class_hash = CompiledClassHash::from(compiled_class_hash); + + let sierra_program_len = sierra_class.sierra_program.len(); + let generic_sierra_class = GenericSierraContractClass::from(sierra_class); + let flattened_sierra_class = generic_sierra_class.to_starknet_core_contract_class().unwrap(); + + let class_hash_component_hashes = + HashMap::from([(class_hash, ContractClassComponentHashes::from(flattened_sierra_class))]); + + let class_info = ClassInfo::new(&contract_class.into(), sierra_program_len, 0).unwrap(); + + let declare_tx = blockifier::test_utils::declare::declare_tx( + declare_tx_args! { + max_fee, + sender_address, + version: tx_version, + nonce: nonce_manager.next(sender_address), + class_hash: class_hash, + compiled_class_hash, + resource_bounds: default_testing_resource_bounds(), + }, + class_info, + ); + + let txs = vec![declare_tx].into_iter().map(Into::into).collect(); + let _result = execute_txs_and_run_os( + crate::common::DEFAULT_COMPILED_OS, + initial_state.cached_state, + block_context, + txs, + initial_state.cairo0_compiled_classes, + initial_state.cairo1_compiled_classes, + class_hash_component_hashes, + ) + .await + .expect("OS run failed"); +} diff --git a/tests/integration/deploy_txn_tests.rs b/tests/integration/deploy_txn_tests.rs index 2b78c4fa..ed67958f 100644 --- a/tests/integration/deploy_txn_tests.rs +++ b/tests/integration/deploy_txn_tests.rs @@ -362,8 +362,8 @@ async fn deploy_via_invoke_no_calldata_cairo1_account( #[rstest] #[tokio::test(flavor = "multi_thread", worker_threads = 1)] async fn deploy_cairo0_check_get_info_call(block_context: BlockContext, max_fee: Fee) { - let account_with_tx_info_check = load_cairo0_feature_contract("account_with_tx_info_check"); - let class_hash = class_hash!("0x6c8903651a5f89ffc304621a7d8106a0324cc28aca04934fcbbb4398d5c8bc8"); + let account_with_syscall_checks = load_cairo0_feature_contract("account_with_syscall_checks"); + let class_hash = class_hash!("0xc70ea92037ef300241a3ffac81d36324200ed3350bf51a2a4bc0149e8fb6a1"); let ctor_calldata = Calldata::default(); let deployed_contract_address = calculate_contract_address( @@ -375,7 +375,7 @@ async fn deploy_cairo0_check_get_info_call(block_context: BlockContext, max_fee: .expect("Failed to calculate the contract address"); let initial_state = StarknetStateBuilder::new(&block_context) - .deploy_cairo0_contract(account_with_tx_info_check.0, account_with_tx_info_check.1) + .deploy_cairo0_contract(account_with_syscall_checks.0, account_with_syscall_checks.1) .fund_account(deployed_contract_address, BALANCE, BALANCE) .set_default_balance(BALANCE, BALANCE) .build() @@ -384,9 +384,10 @@ async fn deploy_cairo0_check_get_info_call(block_context: BlockContext, max_fee: let tx_version = TransactionVersion::ONE; let mut nonce_manager = NonceManager::default(); - let account_with_tx_info_check = initial_state.deployed_cairo0_contracts.get("account_with_tx_info_check").unwrap(); + let account_with_syscall_checks = + initial_state.deployed_cairo0_contracts.get("account_with_syscall_checks").unwrap(); - let deployed_account_class_hash = account_with_tx_info_check.declaration.class_hash; + let deployed_account_class_hash = account_with_syscall_checks.declaration.class_hash; // Sanity check, as we hardcode the class hash in the fixture we verify that we have // the right one. assert_eq!(class_hash, deployed_account_class_hash);