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 @@ -69,7 +69,7 @@ const ALLOWED_VIRTUAL_OS_PROGRAM_HASHES_0 = (
0x03e98c2d7703b03a7edb73ed7f075f97f1dcbaa8f717cdf6e1a57bf058265473
);
const ALLOWED_VIRTUAL_OS_PROGRAM_HASHES_1 = (
0x039f55918423cade9e95a6a52286b56bed1c5c9b6fe39aa00301361457a3c604
0x0542f701524219b8333d8a74a7eee00724673d53d1c78915e8f6d241e4ad81b9
);
const ALLOWED_VIRTUAL_OS_PROGRAM_HASHES_LEN = 2;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ from starkware.starknet.common.new_syscalls import (
EMIT_EVENT_SELECTOR,
GET_CLASS_HASH_AT_SELECTOR,
GET_EXECUTION_INFO_SELECTOR,
KECCAK_SELECTOR,
LIBRARY_CALL_SELECTOR,
SECP256K1_ADD_SELECTOR,
SECP256K1_GET_POINT_FROM_X_SELECTOR,
Expand Down Expand Up @@ -39,6 +40,7 @@ from starkware.starknet.core.os.execution.syscall_impls import (
execute_call_contract,
execute_get_class_hash_at,
execute_get_execution_info,
execute_keccak,
execute_library_call,
execute_secp256k1_add,
execute_secp256k1_get_point_from_x,
Expand Down Expand Up @@ -157,6 +159,16 @@ func execute_syscalls{
);
}

if (selector == KECCAK_SELECTOR) {
execute_keccak();
%{ OsLoggerExitSyscall %}
return execute_syscalls(
block_context=block_context,
execution_context=execution_context,
syscall_ptr_end=syscall_ptr_end,
);
}

if (selector == SHA256_PROCESS_BLOCK_SELECTOR) {
execute_sha256_process_block();
%{ OsLoggerExitSyscall %}
Expand Down
4 changes: 2 additions & 2 deletions crates/apollo_starknet_os_program/src/program_hash.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"os": "0x2a4b5650b64c1a13a4d2754353ddd85d4b970766063220253a4f96643ba23f6",
"virtual_os": "0x39f55918423cade9e95a6a52286b56bed1c5c9b6fe39aa00301361457a3c604",
"os": "0x3bd43ee8e972acc8afd825f8254a6e842884591bff817c3e2a7795577054da",
"virtual_os": "0x542f701524219b8333d8a74a7eee00724673d53d1c78915e8f6d241e4ad81b9",
"aggregator": "0x700786d51b3854af43d8e12180380bda3029be6c1767e007858de6ca2edac40",
"aggregator_with_prefix": "0xe08d300e3f5996e43d6d7cc5a20068e0e58cf1309089f2348317ac580f6c1f"
}
2 changes: 1 addition & 1 deletion crates/apollo_starknet_os_program/src/virtual_os_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn test_program_bytecode_lengths() {
"#]]
.assert_debug_eq(&OS_PROGRAM.data_len());
expect![[r#"
10261
10717
"#]]
.assert_debug_eq(&VIRTUAL_OS_PROGRAM.data_len());
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"os_constants": {
"allowed_virtual_os_program_hashes": [
"0x3e98c2d7703b03a7edb73ed7f075f97f1dcbaa8f717cdf6e1a57bf058265473",
"0x39f55918423cade9e95a6a52286b56bed1c5c9b6fe39aa00301361457a3c604"
"0x542f701524219b8333d8a74a7eee00724673d53d1c78915e8f6d241e4ad81b9"
],
"constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
"default_entry_point_selector": "0x0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
~ /enable_casm_hash_migration: true
+ /os_constants/allowed_virtual_os_program_hashes/1: "0x39f55918423cade9e95a6a52286b56bed1c5c9b6fe39aa00301361457a3c604"
+ /os_constants/allowed_virtual_os_program_hashes/1: "0x542f701524219b8333d8a74a7eee00724673d53d1c78915e8f6d241e4ad81b9"
4 changes: 2 additions & 2 deletions crates/blockifier/src/bouncer_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,11 +804,11 @@ fn class_hash_migration_data_from_state(

if should_migrate {
expect![[r#"
110756293
110673392
"#]]
.assert_debug_eq(&migration_sierra_gas.0);
expect![[r#"
272117746
271891610
"#]]
.assert_debug_eq(&migration_proving_gas.0);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1411,8 +1411,7 @@ mod TestContract {

// Tests forbidden syscalls in virtual OS mode.
// Gets valid class_hash and contract_address from the current contract.
// syscall_selector should be one of: 'Deploy', 'GetBlockHash', 'Keccak', 'ReplaceClass',
// 'MetaTxV0'.
// syscall_selector should be one of: 'Deploy', 'GetBlockHash', 'ReplaceClass', 'MetaTxV0'.
#[external(v0)]
fn test_forbidden_syscall_in_virtual_mode(self: @ContractState, syscall_selector: felt252) {
let execution_info = get_execution_info().unbox();
Expand All @@ -1421,11 +1420,6 @@ mod TestContract {

if syscall_selector == 'GetBlockHash' {
syscalls::get_block_hash_syscall(0).unwrap_syscall();
} else if syscall_selector == 'Keccak' {
// Use the high-level keccak function which internally calls the keccak syscall.
let mut input: Array<u256> = Default::default();
input.append(u256 { low: 1, high: 0 });
keccak::keccak_u256s_le_inputs(input.span());
} else if syscall_selector == 'ReplaceClass' {
syscalls::replace_class_syscall(class_hash).unwrap_syscall();
} else if syscall_selector == 'Deploy' {
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
12
14
16 changes: 8 additions & 8 deletions crates/central_systest_blobs/resources/preconfirmed_block.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
},
"execution_status": "SUCCEEDED",
"l2_to_l1_messages": [],
"transaction_hash": "0x4acc6e7cb93683ae3a42ed499788f2d0143e8c3357315e1ecaad4e65f6dd479",
"transaction_hash": "0x3ebeabf232dacea1a37e57e3eb2b31401325d3561036f2312ab795f6bf2e03e",
"transaction_index": 0
}
],
Expand All @@ -74,11 +74,11 @@
"0x6bd1d71a2fb67a567618584ca31da288dbc2e1a8421e4045e05f52c19bfab83": [
{
"key": "0x6fba6554adab51d0272b896b6f41768bd0491e5ad59c39fab38e65767974793",
"value": "0xffffffffffffffffffffffff924412b1"
"value": "0xffffffffffffffffffffffff9268f2b1"
},
{
"key": "0x723973208639b7839ce298f7ffea61e3f9533872defd7abdb91023db4658812",
"value": "0x6dbbed4e"
"value": "0x6d970d4e"
}
]
}
Expand All @@ -89,10 +89,10 @@
"account_deployment_data": [],
"calldata": [
"0x1",
"0x3d275d3e01ff9dca442ca4aa77b00d6581ad890e3df054932a6851a5166e94d",
"0x5933f5e527f83bbc5fe21fbe55b583324732e7808960a09d128adc12a574f33",
"0x4ea6d2b84c4aea3baab8c031143fcd1fdf95debad5f888784f8db17e1c17f4",
"0x2",
"0x4021329459ab2dacdd89c397996da9214211fa2abf2cda1bfb8f4cffe6db51f",
"0x4776a3d5d0902c45f8ed235fd11c848502a42f81077514a45fbd9fd915d9c92",
"0x2000"
],
"fee_data_availability_mode": 0,
Expand All @@ -116,11 +116,11 @@
},
"sender_address": "0xf99e7cdfbcce0bf14ce17e4c57fd2d12ad1bca5fc8e46a9fbafc36b59a9955",
"signature": [
"0x47fc4402ccfebfe5e1a8af95ee4de99932534b43d9161e7024847382c022926",
"0x71c9ccc594f6d54d88b649a51dc167c3df0423d4a3f95a0e1b85f2560e78588"
"0x4fd47ebb559f622a694031be9f12c516c2bd705d25bb3acde01886fa0cb07d6",
"0xf5b44a9d48356253a68127355d9c4c36545bc916e2c4803363c26f3052dc1d"
],
"tip": "0x0",
"transaction_hash": "0x4acc6e7cb93683ae3a42ed499788f2d0143e8c3357315e1ecaad4e65f6dd479",
"transaction_hash": "0x3ebeabf232dacea1a37e57e3eb2b31401325d3561036f2312ab795f6bf2e03e",
"type": "INVOKE_FUNCTION",
"version": "0x3"
}
Expand Down
5 changes: 1 addition & 4 deletions crates/starknet_os_flow_tests/src/virtual_os_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ async fn test_cairo0_contract_os_error() {
#[rstest]
#[case::deploy("Deploy")]
#[case::get_block_hash("GetBlockHash")]
#[case::keccak("Keccak")]
#[case::replace_class("ReplaceClass")]
#[case::meta_tx_v0("MetaTxV0")]
#[tokio::test]
Expand Down Expand Up @@ -299,9 +298,7 @@ async fn prove_and_verify_multicall_tx() {
};

// TODO(Yoni): add more inner calls (e.g. sha256, secp256k1, send_message_to_l1).
// TODO(Yoni): restore the keccak inner call once the keccak syscall is allowed in
// virtual OS mode (added in a follow-up PR stacked on top of this one).
// serialize_call("test_keccak", &[]);
serialize_call("test_keccak", &[]);
serialize_call("test_ec_op", &[]);

// The dummy account's `__execute__(contract_address, selector, calldata)` forwards
Expand Down
Loading