Skip to content

Commit

Permalink
moved snos import to tests or binary
Browse files Browse the repository at this point in the history
  • Loading branch information
matzayonc committed Oct 15, 2024
1 parent b60b2cb commit 198b6a4
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 5 deletions.
4 changes: 3 additions & 1 deletion crates/bin/prove_block/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ mod state_utils;
mod types;
mod utils;

pub const DEFAULT_COMPILED_OS: &[u8] = include_bytes!("../../../../build/os_latest.json");

#[derive(Debug, Error)]
pub enum ProveBlockError {
#[error("RPC Error: {0}")]
Expand Down Expand Up @@ -324,7 +326,7 @@ pub async fn prove_block(
(old_block_number, old_block_hash),
);

Ok(run_os(config::DEFAULT_COMPILED_OS, layout, os_input, block_context, execution_helper)?)
Ok(run_os(DEFAULT_COMPILED_OS, layout, os_input, block_context, execution_helper)?)
}

pub fn debug_prove_error(err: ProveBlockError) -> ProveBlockError {
Expand Down
2 changes: 0 additions & 2 deletions crates/starknet-os/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub const fn default_layout() -> LayoutName {
// https://github.com/starkware-libs/blockifier/blob/8da582b285bfbc7d4c21178609bbd43f80a69240/crates/native_blockifier/src/py_block_executor.rs#L44
const MAX_STEPS_PER_TX: u32 = 4_000_000;

pub const DEFAULT_COMPILED_OS: &[u8] = include_bytes!("../../../build/os_latest.json");

const DEFAULT_CONFIG_PATH: &str = "../../cairo-lang/src/starkware/starknet/definitions/general_config.yml";
pub const STORED_BLOCK_HASH_BUFFER: u64 = 10;
pub const BLOCK_HASH_CONTRACT_ADDRESS: u64 = 1;
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub mod state;
pub mod transaction_utils;
pub mod utils;

pub const DEFAULT_COMPILED_OS: &[u8] = include_bytes!("../../../build/os_latest.json");

#[fixture]
pub fn setup_runner() -> CairoRunner {
let program_content = fs::read("../build/programs/fact.json").unwrap();
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/common/transaction_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ where
}

pub async fn execute_txs_and_run_os<S>(
compiled_os: &[u8],
state: CachedState<SharedState<S, PedersenHash>>,
block_context: BlockContext,
txs: Vec<Transaction>,
Expand All @@ -905,7 +906,7 @@ where
.await;

let layout = config::default_layout();
let result = run_os(config::DEFAULT_COMPILED_OS, layout, os_input, block_context, execution_helper);
let result = run_os(compiled_os, layout, os_input, block_context, execution_helper);

match &result {
Err(Runner(VmException(vme))) => {
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/declare_txn_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ async fn declare_v3_cairo1_account(

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,
Expand Down Expand Up @@ -149,6 +150,7 @@ async fn declare_cairo1_account(

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,
Expand Down Expand Up @@ -207,6 +209,7 @@ async fn declare_v1_cairo0_account(

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,
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/deploy_txn_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async fn deploy_cairo0_account(

let txs = vec![deploy_account_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,
Expand Down Expand Up @@ -194,6 +195,7 @@ async fn deploy_cairo1_account(

let txs = vec![AccountTransaction::DeployAccount(deploy_account_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,
Expand Down
11 changes: 11 additions & 0 deletions tests/integration/deprecated_syscalls_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async fn test_syscall_library_call_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -110,6 +111,7 @@ async fn test_syscall_get_block_number_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -151,6 +153,7 @@ async fn test_syscall_get_block_timestamp_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -212,6 +215,7 @@ async fn test_syscall_get_tx_info_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -270,6 +274,7 @@ async fn test_syscall_get_tx_signature_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -315,6 +320,7 @@ async fn test_syscall_replace_class_cairo0(

// TODO: use a different class hash and check that it is reflected in the OS output.
let (_pie, _os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -374,6 +380,7 @@ async fn test_syscall_deploy_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -426,6 +433,7 @@ async fn test_syscall_get_sequencer_address_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -482,6 +490,7 @@ async fn test_syscall_get_contract_address_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -534,6 +543,7 @@ async fn test_syscall_emit_event_cairo0(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, _os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -581,6 +591,7 @@ async fn test_syscall_send_message_to_l1_cairo0(

let txs = vec![Transaction::AccountTransaction(tx)];
let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/kzg_da_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async fn test_kzg_da_cairo_1(#[future] initial_state_cairo1: StarknetTestState,
};
let txs = vec![l1_tx].into_iter().map(Into::into).collect();
let (_, output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
BlockContext::create_for_account_testing_with_kzg(true),
txs,
Expand Down Expand Up @@ -64,6 +65,7 @@ async fn test_kzg_da_cairo_0(#[future] initial_state_cairo0: StarknetTestState,
};
let txs = vec![l1_tx].into_iter().map(Into::into).collect();
let (_, output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
BlockContext::create_for_account_testing_with_kzg(true),
txs,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/l1_handler_txn_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async fn l1_handler<F>(
tx_hash: Default::default(),
};
let txs = vec![l1_tx].into_iter().map(Into::into).collect();
let _result = execute_txs_and_run_os(
let _result = execute_txs_and_run_os(crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context,
txs,
Expand Down
3 changes: 3 additions & 0 deletions tests/integration/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async fn return_result_cairo0_account(

let txs = vec![return_result_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,
Expand Down Expand Up @@ -86,6 +87,7 @@ async fn return_result_cairo1_account(

let txs = vec![return_result_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,
Expand Down Expand Up @@ -196,6 +198,7 @@ async fn syscalls_cairo1(
.collect();

let _result = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context,
txs,
Expand Down
1 change: 1 addition & 0 deletions tests/integration/run_os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ async fn run_os_tests(#[future] initial_state_full_itests: StarknetTestState) {
let cached_state = CachedState::from(shared_state);

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
cached_state,
block_context,
txs,
Expand Down
1 change: 1 addition & 0 deletions tests/integration/segments_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async fn test_segment_arena(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, _os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context,
txs,
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/syscalls_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ async fn test_syscall_library_call_cairo1(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -99,6 +100,7 @@ async fn test_syscall_replace_class_cairo1(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, _os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -138,6 +140,7 @@ async fn test_syscall_keccak_cairo1(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, _os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down Expand Up @@ -180,6 +183,7 @@ async fn test_syscall_test_secp_cairo1(
let txs = vec![Transaction::AccountTransaction(tx)];

let (_pie, os_output) = execute_txs_and_run_os(
crate::common::DEFAULT_COMPILED_OS,
initial_state.cached_state,
block_context.clone(),
txs,
Expand Down

0 comments on commit 198b6a4

Please sign in to comment.