Skip to content
Open
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 @@ -10,7 +10,8 @@ from starkware.starknet.core.os.constants import (
)
from starkware.starknet.core.os.execution.syscall_impls import read_block_hash_from_storage
from starkware.starknet.core.os.virtual_os_output import (
PROOF_VERSION,
PROOF_VERSION_V0,
PROOF_VERSION_V1,
VIRTUAL_OS_OUTPUT_VERSION,
VIRTUAL_SNOS,
ProofHeader,
Expand Down Expand Up @@ -44,14 +45,15 @@ func check_proof_facts{range_check_ptr, contract_state_changes: DictAccess*}(
assert_le(ProofHeader.SIZE + VirtualOsOutputHeader.SIZE, proof_facts_size);

// Validate the proof header.
static_assert ProofHeader.SIZE == 3;
let proof_header = cast(proof_facts, ProofHeader*);
assert proof_header.proof_variant = VIRTUAL_SNOS;
assert is_program_hash_allowed(proof_header.program_hash) = TRUE;
// Proof version and variant are for future compatibility.
assert [proof_header] = ProofHeader(
proof_version=PROOF_VERSION,
proof_variant=VIRTUAL_SNOS,
program_hash=proof_header.program_hash,
);
// Proof version may be V0 (legacy) or V1 (current).
with_attr error_message("Unsupported proof version") {
tempvar proof_version = proof_header.proof_version;
assert (proof_version - PROOF_VERSION_V0) * (proof_version - PROOF_VERSION_V1) = 0;
}

// Validate the virtual OS output header.
let os_output_header = cast(&proof_facts[ProofHeader.SIZE], VirtualOsOutputHeader*);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
const VIRTUAL_SNOS = 'VIRTUAL_SNOS';

// Marker indicating proof facts format version 0.
const PROOF_VERSION = 'PROOF0';
const PROOF_VERSION_V0 = 'PROOF0';

// Marker indicating proof facts format version 1.
const PROOF_VERSION_V1 = 'PROOF1';

// The version of the virtual OS output.
//
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": "0xb0134eed363da4094afca019a74939b4c17f238a4f7411798813f55905cd7",
"os": "0x4f1294d5ec8c98bfb01a26af215a8d15f5f3530bb7bac8342ee72334ebcec6d",
"virtual_os": "0x3e98c2d7703b03a7edb73ed7f075f97f1dcbaa8f717cdf6e1a57bf058265473",
"aggregator": "0x43666b81f964bcdedf0098d2791b061d61f3098ff1429a754d0b97eeeae9489",
"aggregator_with_prefix": "0x68072c8f5ff5ae133060e12cfad3a38362dbb6d667abd4f7e1fac6f37febe46"
Expand Down
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 @@ -19,7 +19,7 @@ fn test_virtual_os_swapped_files() {
#[test]
fn test_program_bytecode_lengths() {
expect![[r#"
15610
15613
"#]]
.assert_debug_eq(&OS_PROGRAM.data_len());
expect![[r#"
Expand Down
7 changes: 5 additions & 2 deletions crates/starknet_os/src/constants_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use starknet_api::core::{
};
use starknet_api::transaction::fields::{
PROOF_VERSION_V0,
PROOF_VERSION_V1,
VIRTUAL_OS_OUTPUT_VERSION,
VIRTUAL_SNOS,
};
Expand Down Expand Up @@ -82,10 +83,12 @@ fn test_virtual_snos() {
assert_eq!(Const::VirtualSnos.fetch_from_os_program().unwrap(), VIRTUAL_SNOS);
}

/// Asserts that the Rust PROOF_VERSION_V0 constant matches the Cairo constant.
/// Asserts that the Rust PROOF_VERSION_V0 and PROOF_VERSION_V1 constants match their Cairo
/// counterparts.
#[test]
fn test_proof_version() {
assert_eq!(Const::ProofVersion.fetch_from_os_program().unwrap(), PROOF_VERSION_V0);
assert_eq!(Const::ProofVersionV0.fetch_from_os_program().unwrap(), PROOF_VERSION_V0);
assert_eq!(Const::ProofVersionV1.fetch_from_os_program().unwrap(), PROOF_VERSION_V1);
}

/// Asserts that the Rust STARKNET_OS_CONFIG_HASH_VERSION constant matches the Cairo constant.
Expand Down
3 changes: 2 additions & 1 deletion crates/starknet_os/src/hints/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ define_string_enum! {
"starkware.starknet.core.os.virtual_os_output.VIRTUAL_OS_OUTPUT_VERSION"
),
(VirtualSnos, "starkware.starknet.core.os.virtual_os_output.VIRTUAL_SNOS"),
(ProofVersion, "starkware.starknet.core.os.virtual_os_output.PROOF_VERSION"),
(ProofVersionV0, "starkware.starknet.core.os.virtual_os_output.PROOF_VERSION_V0"),
(ProofVersionV1, "starkware.starknet.core.os.virtual_os_output.PROOF_VERSION_V1"),
}
}

Expand Down
Loading