Skip to content

Commit 3a3e4b1

Browse files
apollo_integration_tests: add regression tests for matching the proof generation
1 parent 4e73a75 commit 3a3e4b1

4 files changed

Lines changed: 62 additions & 4 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_integration_tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ blockifier = { workspace = true, features = ["testing"] }
6464
blockifier_test_utils.workspace = true
6565
cairo-lang-starknet-classes.workspace = true
6666
clap = { workspace = true, features = ["derive"] }
67+
expect-test.workspace = true
6768
futures.workspace = true
6869
hex.workspace = true
6970
http.workspace = true

crates/apollo_integration_tests/src/state_reader.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use blockifier::context::ChainInfo;
2222
use blockifier_test_utils::cairo_versions::{CairoVersion, RunnableCairo1};
2323
use blockifier_test_utils::contracts::FeatureContract;
2424
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
25+
use expect_test::{expect, Expect};
2526
use indexmap::IndexMap;
2627
use mempool_test_utils::starknet_api_test_utils::{AccountTransactionGenerator, Contract};
2728
use starknet_api::abi::abi_utils::get_fee_token_var_address;
@@ -376,8 +377,14 @@ fn initialize_papyrus_test_state(
376377
}
377378

378379
/// Global root that matches the proof flow fixtures.
379-
fn integration_test_genesis_global_root() -> GlobalRoot {
380-
GlobalRoot(felt!("0x68fed6a062d385db8d1dd9096060e822196feb311fc3bb4f0018635461ca85e"))
380+
/// Any change to this value requires regenerating the proof fixtures by running
381+
/// `cargo +nightly-2025-07-14 test -p starknet_os_flow_tests --features
382+
/// starknet_transaction_prover/stwo_proving --release generate_proof_fixtures -- --ignored`.
383+
pub const EXPECTED_PROOF_FLOW_GENESIS_GLOBAL_ROOT: Expect =
384+
expect!["0x68fed6a062d385db8d1dd9096060e822196feb311fc3bb4f0018635461ca85e"];
385+
386+
pub fn integration_test_genesis_global_root() -> GlobalRoot {
387+
GlobalRoot(Felt::from_hex_unchecked(EXPECTED_PROOF_FLOW_GENESIS_GLOBAL_ROOT.data()))
381388
}
382389

383390
fn prepare_state_diff(
@@ -664,9 +671,18 @@ impl<'a> ThinStateDiffBuilder<'a> {
664671
}
665672
}
666673

674+
/// STRK fee token address that matches the proof flow fixtures.
675+
/// Any change to this value requires regenerating the proof fixtures by running
676+
/// `cargo +nightly-2025-07-14 test -p starknet_os_flow_tests --features
677+
/// starknet_transaction_prover/stwo_proving --release generate_proof_fixtures -- --ignored`.
678+
pub const EXPECTED_PROOF_FLOW_STRK_FEE_TOKEN_ADDRESS: Expect =
679+
expect!["0x4ff17bf76a1c6cebb82601a43bcab4f9650aea543c44f28e8863f8b624e4b58"];
680+
667681
pub fn proof_flow_chain_info() -> ChainInfo {
668682
let mut chain_info = ChainInfo::create_for_testing();
669-
chain_info.fee_token_addresses.strk_fee_token_address =
670-
contract_address!("0x4ff17bf76a1c6cebb82601a43bcab4f9650aea543c44f28e8863f8b624e4b58");
683+
chain_info.fee_token_addresses.strk_fee_token_address = ContractAddress::try_from(
684+
Felt::from_hex_unchecked(EXPECTED_PROOF_FLOW_STRK_FEE_TOKEN_ADDRESS.data()),
685+
)
686+
.unwrap();
671687
chain_info
672688
}

crates/starknet_os_flow_tests/src/virtual_os_test.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
use std::path::Path;
22

3+
use apollo_integration_tests::state_reader::{
4+
EXPECTED_PROOF_FLOW_GENESIS_GLOBAL_ROOT,
5+
EXPECTED_PROOF_FLOW_STRK_FEE_TOKEN_ADDRESS,
6+
};
37
use blockifier::execution::contract_class::TrackedResource;
48
use blockifier::test_utils::dict_state_reader::DictStateReader;
59
use blockifier::test_utils::get_valid_virtual_os_program_hash;
@@ -11,6 +15,7 @@ use rstest::rstest;
1115
use starknet_api::abi::abi_utils::selector_from_name;
1216
use starknet_api::block::{BlockInfo, BlockNumber, BlockTimestamp};
1317
use starknet_api::core::EthAddress;
18+
use starknet_api::hash::StateRoots;
1419
use starknet_api::test_utils::{CURRENT_BLOCK_TIMESTAMP, TEST_SEQUENCER_ADDRESS};
1520
use starknet_api::transaction::fields::{ProofFacts, TransactionSignature};
1621
use starknet_api::transaction::{
@@ -22,7 +27,9 @@ use starknet_api::transaction::{
2227
use starknet_api::{calldata, contract_address, invoke_tx_args};
2328
use starknet_types_core::felt::Felt;
2429

30+
use crate::initial_state::create_default_initial_state_data;
2531
use crate::test_manager::{
32+
block_context_for_flow_tests,
2633
EventPredicateExpectation,
2734
TestBuilder,
2835
TestBuilderConfig,
@@ -308,3 +315,36 @@ async fn generate_proof_fixtures() {
308315
.expect("write proof_facts.json");
309316
std::fs::write(&proof_path, output.proof.0.as_slice()).expect("write proof.bin");
310317
}
318+
319+
/// Guards against drift between the STRK fee token address used by the proof-flow integration
320+
/// test and the one produced by the virtual OS test pipeline. Run with `UPDATE_EXPECT=1` to refresh
321+
/// the constant in `apollo_integration_tests::state_reader`, then regenerate the proof fixtures by
322+
/// running `cargo +nightly-2025-07-14 test -p starknet_os_flow_tests --features
323+
/// starknet_transaction_prover/stwo_proving --release generate_proof_fixtures -- --ignored`.
324+
#[test]
325+
fn proof_flow_chain_info_matches_virtual_os_test() {
326+
let virtual_os_strk_fee_token_address = block_context_for_flow_tests(BlockNumber(0), false)
327+
.chain_info()
328+
.fee_token_addresses
329+
.strk_fee_token_address;
330+
EXPECTED_PROOF_FLOW_STRK_FEE_TOKEN_ADDRESS
331+
.assert_eq(&virtual_os_strk_fee_token_address.to_hex_string());
332+
}
333+
334+
/// Guards against drift between the genesis global root the proof-flow integration test seeds into
335+
/// storage and the initial global root produced by the virtual OS test pipeline. Run with
336+
/// `UPDATE_EXPECT=1` to refresh the constant in `apollo_integration_tests::state_reader`, then
337+
/// regenerate the proof fixtures by running `cargo +nightly-2025-07-14 test -p
338+
/// starknet_os_flow_tests --features starknet_transaction_prover/stwo_proving --release
339+
/// generate_proof_fixtures -- --ignored`.
340+
#[tokio::test(flavor = "multi_thread")]
341+
async fn proof_flow_global_root_matches_virtual_os_test() {
342+
let (initial_state_data, []) =
343+
create_default_initial_state_data::<DictStateReader, 0>([]).await;
344+
let virtual_os_global_root = StateRoots {
345+
contracts_trie_root_hash: initial_state_data.initial_state.contracts_trie_root_hash,
346+
classes_trie_root_hash: initial_state_data.initial_state.classes_trie_root_hash,
347+
}
348+
.global_root();
349+
EXPECTED_PROOF_FLOW_GENESIS_GLOBAL_ROOT.assert_eq(&virtual_os_global_root.0.to_hex_string());
350+
}

0 commit comments

Comments
 (0)