Skip to content

Commit f879389

Browse files
starknet_os: test that the most recent virtual os program hash is
allowed
1 parent b92c14d commit f879389

File tree

9 files changed

+31
-9
lines changed

9 files changed

+31
-9
lines changed

crates/apollo_consensus_orchestrator/resources/central_invoke_tx_client_side_proving.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"proof_facts": [
3636
"0x50524f4f4630",
3737
"0x5649525455414c5f534e4f53",
38-
"0x130206a40921880628605041292e995870334451179c63090221210893986a2",
38+
"0x56cb82807b5af2736cee1da0919bc265b499836623bd32265eacc8c8dc98421",
3939
"0x5649525455414c5f534e4f5330",
4040
"0x7a0",
4141
"0x2fa80",

crates/apollo_consensus_orchestrator/resources/central_preconfirmed_block.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"proof_facts": [
6161
"0x50524f4f4630",
6262
"0x5649525455414c5f534e4f53",
63-
"0x130206a40921880628605041292e995870334451179c63090221210893986a2",
63+
"0x56cb82807b5af2736cee1da0919bc265b499836623bd32265eacc8c8dc98421",
6464
"0x5649525455414c5f534e4f5330",
6565
"0x7a0",
6666
"0x2fa80",

crates/apollo_http_server/resources/deprecated_gateway/invoke_tx_client_side_proving.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"proof_facts": [
3030
"0x50524f4f4630",
3131
"0x5649525455414c5f534e4f53",
32-
"0x130206a40921880628605041292e995870334451179c63090221210893986a2",
32+
"0x56cb82807b5af2736cee1da0919bc265b499836623bd32265eacc8c8dc98421",
3333
"0x5649525455414c5f534e4f5330",
3434
"0x7a0",
3535
"0x2fa80",

crates/apollo_starknet_client/resources/reader/invoke_v3_client_side_proving.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"proof_facts": [
3636
"0x50524f4f4630",
3737
"0x5649525455414c5f534e4f53",
38-
"0x130206a40921880628605041292e995870334451179c63090221210893986a2",
38+
"0x56cb82807b5af2736cee1da0919bc265b499836623bd32265eacc8c8dc98421",
3939
"0x5649525455414c5f534e4f5330",
4040
"0x7a0",
4141
"0x2fa80",

crates/blockifier/resources/blockifier_versioned_constants_0_14_2.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"segment_arena_cells": false,
7171
"os_constants": {
7272
"allowed_virtual_os_program_hashes": [
73-
"0x130206a40921880628605041292e995870334451179c63090221210893986a2"
73+
"0x56cb82807b5af2736cee1da0919bc265b499836623bd32265eacc8c8dc98421"
7474
],
7575
"constructor_entry_point_selector": "0x28ffe4ff0f226a9107253e17a904099aa4f63a02a5621de0576e5aa71bc5194",
7676
"default_entry_point_selector": "0x0",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
~ /archival_data_gas_costs/gas_per_proof/0: 1000000000
22
~ /deprecated_l2_resource_gas_costs/gas_per_proof/0: 1000000000
33
~ /enable_casm_hash_migration: false
4-
+ /os_constants/allowed_virtual_os_program_hashes/0: "0x130206a40921880628605041292e995870334451179c63090221210893986a2"
4+
+ /os_constants/allowed_virtual_os_program_hashes/0: "0x56cb82807b5af2736cee1da0919bc265b499836623bd32265eacc8c8dc98421"

crates/blockifier/src/blockifier_versioned_constants.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ pub struct RawVersionedConstants {
9999
#[serde(deny_unknown_fields)]
100100
pub struct RawOsConstants {
101101
// Allowed virtual OS program hashes for client-side proving.
102-
// TODO(Meshi): Add a test that the latest virtual OS program hash is in this list.
103102
pub allowed_virtual_os_program_hashes: Vec<StarkHash>,
104103

105104
// Selectors.

crates/starknet_api/src/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub const MAX_FEE: Fee = DEFAULT_L1_GAS_AMOUNT.nonzero_saturating_mul(DEFAULT_ET
232232
// Virtual OS program hash for testing. Should match one of the allowed virtual OS program hashes in
233233
// the current versioned constants.
234234
pub const VIRTUAL_OS_PROGRAM_HASH: StarkHash = StarkHash::from_hex_unchecked(
235-
"0x130206a40921880628605041292e995870334451179c63090221210893986a2",
235+
"0x56cb82807b5af2736cee1da0919bc265b499836623bd32265eacc8c8dc98421",
236236
);
237237

238238
/// Computes a deterministic block hash for testing purposes.

crates/starknet_os/src/constants_test.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
use apollo_starknet_os_program::OS_PROGRAM;
1+
use apollo_starknet_os_program::{OS_PROGRAM, PROGRAM_HASHES};
22
use blockifier::abi::constants::{L1_TO_L2_MSG_HEADER_SIZE, L2_TO_L1_MSG_HEADER_SIZE};
3+
use blockifier::blockifier_versioned_constants::VersionedConstants;
4+
use starknet_api::block::StarknetVersion;
35
use starknet_api::contract_class::compiled_class_hash::COMPILED_CLASS_V1;
46
use starknet_api::core::{
57
GLOBAL_STATE_VERSION,
68
L2_ADDRESS_UPPER_BOUND,
79
STARKNET_OS_CONFIG_HASH_VERSION,
810
};
911
use starknet_api::transaction::fields::{PROOF_VERSION, VIRTUAL_OS_OUTPUT_VERSION, VIRTUAL_SNOS};
12+
use starknet_api::versioned_constants_logic::VersionedConstantsTrait;
1013
use starknet_committer::hash_function::hash::CONTRACT_CLASS_LEAF_V0;
1114
use starknet_types_core::felt::Felt;
1215

@@ -90,3 +93,23 @@ fn test_starknet_os_config_hash_version() {
9093
STARKNET_OS_CONFIG_HASH_VERSION
9194
);
9295
}
96+
97+
/// Verifies that the virtual OS program hash from PROGRAM_HASHES is in the list of
98+
/// allowed virtual OS program hashes in the latest versioned constants.
99+
#[test]
100+
fn test_virtual_os_program_hash_is_allowed() {
101+
let virtual_os_hash = PROGRAM_HASHES.virtual_os;
102+
103+
// Get the latest versioned constants
104+
let latest_constants = VersionedConstants::get(&StarknetVersion::LATEST).unwrap();
105+
106+
// Check if the virtual OS program hash is in the allowed list
107+
let allowed_hashes = &latest_constants.os_constants.allowed_virtual_os_program_hashes;
108+
109+
assert!(
110+
allowed_hashes.contains(&virtual_os_hash),
111+
"Virtual OS program hash {:#x} is not in the allowed list: {:?}",
112+
virtual_os_hash,
113+
allowed_hashes.iter().map(|h| format!("{:#x}", h)).collect::<Vec<_>>()
114+
);
115+
}

0 commit comments

Comments
 (0)