diff --git a/.github/workflows/apollo_storage_os_input_ci.yml b/.github/workflows/apollo_storage_os_input_ci.yml deleted file mode 100644 index fd8ba975100..00000000000 --- a/.github/workflows/apollo_storage_os_input_ci.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Apollo-Storage-OS-Input-CI - -on: - pull_request: - types: - - opened - - reopened - - edited - - synchronize - paths: - - ".github/actions/bootstrap/action.yml" - - ".github/workflows/apollo_storage_os_input_ci.yml" - - "Cargo.lock" - - "Cargo.toml" - - "crates/apollo_batcher/**" - - "crates/apollo_batcher_types/**" - - "crates/apollo_committer/**" - - "crates/apollo_committer_types/**" - - "crates/apollo_consensus_orchestrator/**" - - "crates/apollo_storage/**" - - "crates/apollo_config/**" - - "crates/apollo_infra_utils/**" - - "crates/apollo_metrics/**" - - "crates/apollo_proc_macros/**" - - "crates/apollo_test_utils/**" - - "crates/blockifier/**" - - "crates/starknet_api/**" - - "crates/starknet_committer/**" - -env: - RUSTFLAGS: "-D warnings" - -# On PR events, cancel existing CI runs on this same PR for this workflow. -# Also, create different concurrency groups for different pushed commits, on push events. -concurrency: - group: > - ${{ github.workflow }}- - ${{ github.ref }}- - ${{ github.event_name == 'pull_request' && 'PR' || github.sha }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - # https://graphite.com/docs/stacking-and-ci - optimize_ci: - runs-on: ubuntu-24.04 - timeout-minutes: 60 - outputs: - skip: ${{ steps.check_skip.outputs.skip }} - steps: - - name: Optimize CI - id: check_skip - uses: withgraphite/graphite-ci-action@9bc969adfd43bb790da3b64b543c78c75cef9689 # v0.0.9 - with: - graphite_token: ${{ secrets.GRAPHITE_CI_OPTIMIZER_TOKEN }} - - test-with-os-input-feature: - runs-on: namespace-profile-medium-ubuntu-24-04-amd64 - needs: optimize_ci - if: needs.optimize_ci.outputs.skip == 'false' - timeout-minutes: 60 - steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - - uses: ./.github/actions/bootstrap - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - run: cargo test -p starknet_committer --features os_input - - run: cargo test -p apollo_committer_types --features os_input - - run: cargo test -p apollo_committer --features os_input - - run: cargo build -p blockifier --features os_input - - run: cargo build -p apollo_batcher --features os_input - - run: cargo test -p apollo_batcher --features os_input - - run: cargo test -p apollo_consensus_orchestrator --features os_input,testing - - run: cargo test -p apollo_reverts --features os_input - - run: cargo test -p apollo_storage --features os_input diff --git a/crates/apollo_batcher/Cargo.toml b/crates/apollo_batcher/Cargo.toml index 7ef6b483bcc..62f907dafb1 100644 --- a/crates/apollo_batcher/Cargo.toml +++ b/crates/apollo_batcher/Cargo.toml @@ -8,13 +8,6 @@ description = "Block building and transaction batching component for the Starkne [features] cairo_native = ["blockifier/cairo_native"] -os_input = [ - "apollo_batcher_types/os_input", - "apollo_committer_types/os_input", - "apollo_reverts/os_input", - "apollo_storage/os_input", - "blockifier/os_input", -] testing = [] [lints] diff --git a/crates/apollo_batcher/src/batcher.rs b/crates/apollo_batcher/src/batcher.rs index 896dc61584d..b43191865bd 100644 --- a/crates/apollo_batcher/src/batcher.rs +++ b/crates/apollo_batcher/src/batcher.rs @@ -46,7 +46,6 @@ use apollo_proof_manager_types::SharedProofManagerClient; use apollo_reverts::revert_block; use apollo_state_reader::apollo_state::ApolloReader; use apollo_state_sync_types::state_sync_types::SyncBlock; -#[cfg(feature = "os_input")] use apollo_storage::accessed_keys::{ AccessedKeys, AccessedKeysStorageReader, @@ -65,7 +64,6 @@ use apollo_storage::partial_block_hash::{ PartialBlockHashComponentsStorageWriter, }; use apollo_storage::state::{StateStorageReader, StateStorageWriter}; -#[cfg(feature = "os_input")] use apollo_storage::state_commitment_infos::{ CompressedStateCommitmentInfos, StateCommitmentInfosStorageReader, @@ -924,7 +922,6 @@ impl Batcher { l1_transaction_hashes.iter().copied().collect(), Default::default(), storage_commitment_block_hash, - #[cfg(feature = "os_input")] None, ) .await?; @@ -933,7 +930,6 @@ impl Batcher { height, state_diff, optional_state_diff_commitment, - #[cfg(feature = "os_input")] None, ) .await?; @@ -980,8 +976,6 @@ impl Batcher { let state_diff_commitment = partial_block_hash_components.header_commitments.state_diff_commitment; let parent_proposal_commitment = self.get_parent_proposal_commitment(height)?; - - #[cfg(feature = "os_input")] let accessed_keys = self.build_block_accessed_keys(&block_execution_artifacts); self.commit_proposal_and_block( @@ -991,7 +985,6 @@ impl Batcher { block_execution_artifacts.execution_data.consumed_l1_handler_tx_hashes, block_execution_artifacts.execution_data.rejected_tx_hashes, StorageCommitmentBlockHash::Partial(partial_block_hash_components), - #[cfg(feature = "os_input")] Some(accessed_keys.clone()), ) .await?; @@ -1006,7 +999,6 @@ impl Batcher { // The OS only needs the read values for the keys it accesses; drop the extra reads (e.g. // reverted-tx reads). - #[cfg(feature = "os_input")] let initial_reads = { let mut initial_reads = block_execution_artifacts.initial_reads; initial_reads.trim_to_accessed_keys(&accessed_keys); @@ -1017,7 +1009,6 @@ impl Batcher { height, state_diff.clone(), // TODO(Nimrod): Remove the clone here. Some(state_diff_commitment), - #[cfg(feature = "os_input")] Some(accessed_keys), ) .await?; @@ -1047,14 +1038,12 @@ impl Batcher { compiled_class_hashes_for_migration: block_execution_artifacts .compiled_class_hashes_for_migration, parent_proposal_commitment, - #[cfg(feature = "os_input")] initial_reads, }, }) } /// Builds the accessed keys for the block. - #[cfg(feature = "os_input")] fn build_block_accessed_keys( &self, block_execution_artifacts: &BlockExecutionArtifacts, @@ -1080,7 +1069,7 @@ impl Batcher { consumed_l1_handler_tx_hashes: IndexSet, rejected_tx_hashes: IndexSet, storage_commitment_block_hash: StorageCommitmentBlockHash, - #[cfg(feature = "os_input")] accessed_keys: Option, + accessed_keys: Option, ) -> BatcherResult<()> { info!( "Committing block at height {} and notifying mempool & L1 event provider of the block.", @@ -1110,13 +1099,7 @@ impl Batcher { // Commit the proposal to the storage. self.storage_writer - .commit_proposal( - height, - state_diff, - storage_commitment_block_hash, - #[cfg(feature = "os_input")] - accessed_keys, - ) + .commit_proposal(height, state_diff, storage_commitment_block_hash, accessed_keys) .map_err(|err| { error!("Failed to commit proposal to storage: {}", err); BatcherError::InternalError @@ -1542,7 +1525,6 @@ impl Batcher { Ok(block_hash) } - #[cfg(feature = "os_input")] pub fn get_state_commitment_infos( &self, block_number: BlockNumber, @@ -1572,7 +1554,7 @@ impl Batcher { height: BlockNumber, state_diff: ThinStateDiff, optional_state_diff_commitment: Option, - #[cfg(feature = "os_input")] accessed_keys: Option, + accessed_keys: Option, ) -> BatcherResult<()> { self.get_commitment_results_and_write_to_storage()?; self.commitment_manager @@ -1583,7 +1565,6 @@ impl Batcher { &self.config.static_config.first_block_with_partial_block_hash, self.storage_reader.clone(), &mut self.storage_writer, - #[cfg(feature = "os_input")] accessed_keys, ) .await @@ -1752,7 +1733,6 @@ pub trait BatcherStorageReader: Send + Sync { fn get_block_hash(&self, height: BlockNumber) -> StorageResult>; - #[cfg(feature = "os_input")] fn get_state_commitment_infos( &self, height: BlockNumber, @@ -1765,7 +1745,6 @@ pub trait BatcherStorageReader: Send + Sync { fn get_block_header(&self, block_number: BlockNumber) -> StorageResult; - #[cfg(feature = "os_input")] fn get_accessed_keys(&self, height: BlockNumber) -> StorageResult>; } @@ -1852,7 +1831,6 @@ impl BatcherStorageReader for StorageReader { self.begin_ro_txn()?.get_block_hash(&height) } - #[cfg(feature = "os_input")] fn get_state_commitment_infos( &self, height: BlockNumber, @@ -1883,7 +1861,6 @@ impl BatcherStorageReader for StorageReader { }) } - #[cfg(feature = "os_input")] fn get_accessed_keys(&self, height: BlockNumber) -> StorageResult> { self.begin_ro_txn()?.get_accessed_keys(height) } @@ -1891,15 +1868,6 @@ impl BatcherStorageReader for StorageReader { #[cfg_attr(test, automock)] pub trait BatcherStorageWriter: Send + Sync { - #[cfg(not(feature = "os_input"))] - fn commit_proposal( - &mut self, - height: BlockNumber, - state_diff: ThinStateDiff, - storage_commitment_block_hash: StorageCommitmentBlockHash, - ) -> StorageResult<()>; - - #[cfg(feature = "os_input")] fn commit_proposal( &mut self, height: BlockNumber, @@ -1910,23 +1878,11 @@ pub trait BatcherStorageWriter: Send + Sync { fn revert_block(&mut self, height: BlockNumber); - /// Sets the global root and block hash (unless it's None) for the given height. - /// Increments the block hash marker by 1. - /// Block hash is optional because for old blocks, the block hash was set separately. - #[cfg(not(feature = "os_input"))] - fn set_global_root_and_block_hash( - &mut self, - height: BlockNumber, - global_root: GlobalRoot, - block_hash: Option, - ) -> StorageResult<()>; - /// Sets the global root and block hash (unless it's None) for the given height, and persists /// the commitment infos (when present) in the same transaction. /// Increments the block hash marker by 1. /// Block hash is optional because for old blocks, the block hash was set separately. /// Commitment infos are optional for blocks that doesn't come from decision_reached flow. - #[cfg(feature = "os_input")] fn set_global_root_and_block_hash( &mut self, height: BlockNumber, @@ -1944,7 +1900,7 @@ impl BatcherStorageWriter for StorageWriter { height: BlockNumber, state_diff: ThinStateDiff, storage_commitment_block_hash: StorageCommitmentBlockHash, - #[cfg(feature = "os_input")] accessed_keys: Option, + accessed_keys: Option, ) -> StorageResult<()> { // TODO(AlonH): write casms. let mut txn = self.begin_rw_txn()?.append_state_diff(height, state_diff)?; @@ -1959,7 +1915,6 @@ impl BatcherStorageWriter for StorageWriter { txn.set_partial_block_hash_components(&height, &partial_block_hash_components)? } } - #[cfg(feature = "os_input")] if let Some(accessed_keys) = accessed_keys { txn = txn.append_accessed_keys(height, &accessed_keys)?; } @@ -1976,14 +1931,8 @@ impl BatcherStorageWriter for StorageWriter { height: BlockNumber, global_root: GlobalRoot, block_hash: Option, - #[cfg(feature = "os_input")] state_commitment_infos: Option, + state_commitment_infos: Option, ) -> StorageResult<()> { - #[cfg(not(feature = "os_input"))] - info!( - "Setting global root and block hash for height {height}. Root: {global_root:?}, Block \ - hash: {block_hash:?}." - ); - #[cfg(feature = "os_input")] info!( "Setting global root and block hash for height {height}. Root: {global_root:?}, Block \ hash: {block_hash:?}, compressed commitment infos byte length: {:?}.", @@ -1998,7 +1947,6 @@ impl BatcherStorageWriter for StorageWriter { if let Some(block_hash) = block_hash { txn = txn.set_block_hash(&height, block_hash)?; } - #[cfg(feature = "os_input")] if let Some(state_commitment_infos) = state_commitment_infos { txn = txn.append_state_commitment_infos(height, &state_commitment_infos)?; } diff --git a/crates/apollo_batcher/src/batcher_test.rs b/crates/apollo_batcher/src/batcher_test.rs index 2a3ac70b161..781b262bcdf 100644 --- a/crates/apollo_batcher/src/batcher_test.rs +++ b/crates/apollo_batcher/src/batcher_test.rs @@ -196,10 +196,8 @@ fn get_overlapping_state_diffs(n_state_diffs: u64) -> Vec { state_diffs } -/// Expects a single `commit_proposal` call with the given arguments. Under `os_input`, -/// `expect_accessed_keys` states whether accessed keys should be written with the state diff -/// (ignored otherwise). -#[cfg_attr(not(feature = "os_input"), allow(unused_variables))] +/// Expects a single `commit_proposal` call with the given arguments; `expect_accessed_keys` +/// states whether accessed keys should be written with the state diff. fn expect_commit_proposal_once( storage_writer: &mut MockBatcherStorageWriter, expected_height: BlockNumber, @@ -207,17 +205,6 @@ fn expect_commit_proposal_once( expected_storage_commitment_block_hash: StorageCommitmentBlockHash, expect_accessed_keys: bool, ) { - #[cfg(not(feature = "os_input"))] - storage_writer - .expect_commit_proposal() - .times(1) - .with( - eq(expected_height), - eq(expected_state_diff), - eq(expected_storage_commitment_block_hash), - ) - .returning(|_, _, _| Ok(())); - #[cfg(feature = "os_input")] storage_writer .expect_commit_proposal() .times(1) @@ -231,9 +218,6 @@ fn expect_commit_proposal_once( } fn expect_commit_proposal_success(storage_writer: &mut MockBatcherStorageWriter) { - #[cfg(not(feature = "os_input"))] - storage_writer.expect_commit_proposal().returning(|_, _, _| Ok(())); - #[cfg(feature = "os_input")] storage_writer.expect_commit_proposal().returning(|_, _, _, _| Ok(())); } @@ -244,7 +228,6 @@ fn write_state_diff(batcher: &mut Batcher, height: BlockNumber, state_diff: &Thi height, state_diff.clone(), StorageCommitmentBlockHash::Partial(PartialBlockHashComponents::default()), - #[cfg(feature = "os_input")] None, ) .expect("set_state_diff failed"); @@ -1861,11 +1844,6 @@ async fn get_block_hash_after_reading_commitment_results() { let set_global_root_expectation = mock_dependencies.storage_writer.expect_set_global_root_and_block_hash(); set_global_root_expectation.times(1); - #[cfg(not(feature = "os_input"))] - set_global_root_expectation - .with(eq(INITIAL_HEIGHT), eq(global_root), always()) - .returning(|_, _, _| Ok(())); - #[cfg(feature = "os_input")] set_global_root_expectation .with(eq(INITIAL_HEIGHT), eq(global_root), always(), always()) .returning(|_, _, _, _| Ok(())); diff --git a/crates/apollo_batcher/src/block_builder.rs b/crates/apollo_batcher/src/block_builder.rs index 363daec48d2..283ae2ca126 100644 --- a/crates/apollo_batcher/src/block_builder.rs +++ b/crates/apollo_batcher/src/block_builder.rs @@ -30,9 +30,7 @@ use blockifier::blockifier_versioned_constants::VersionedConstants; use blockifier::bouncer::{BouncerWeights, CasmHashComputationData}; use blockifier::concurrency::worker_pool::WorkerPool; use blockifier::context::BlockContext; -#[cfg(feature = "os_input")] -use blockifier::state::cached_state::StateMaps; -use blockifier::state::cached_state::{CachedState, CommitmentStateDiff}; +use blockifier::state::cached_state::{CachedState, CommitmentStateDiff, StateMaps}; use blockifier::state::contract_class_manager::ContractClassManager; use blockifier::state::errors::StateError; use blockifier::state::state_reader_and_contract_manager::StateReaderAndContractManager; @@ -133,7 +131,6 @@ pub struct BlockExecutionArtifacts { pub execution_data: BlockTransactionExecutionData, pub commitment_state_diff: CommitmentStateDiff, pub compressed_state_diff: Option, - #[cfg(feature = "os_input")] pub initial_reads: StateMaps, pub bouncer_weights: BouncerWeights, pub l2_gas_used: GasAmount, @@ -152,18 +149,15 @@ impl BlockExecutionArtifacts { execution_data: BlockTransactionExecutionData, final_n_executed_txs: usize, ) -> Self { - #[cfg(feature = "os_input")] - let initial_reads = block_summary.initial_reads; let BlockExecutionSummary { state_diff: commitment_state_diff, compressed_state_diff, + initial_reads, bouncer_weights, casm_hash_computation_data_sierra_gas, casm_hash_computation_data_proving_gas, compiled_class_hashes_for_migration, block_info, - // TODO(Yoav): Remove the ".." when the os_input feature is removed. - .. } = block_summary; let l1_da_mode = L1DataAvailabilityMode::from_use_kzg_da(block_info.use_kzg_da); let transactions_data = @@ -184,7 +178,6 @@ impl BlockExecutionArtifacts { execution_data, commitment_state_diff, compressed_state_diff, - #[cfg(feature = "os_input")] initial_reads, bouncer_weights, l2_gas_used, diff --git a/crates/apollo_batcher/src/block_builder_test.rs b/crates/apollo_batcher/src/block_builder_test.rs index 2b3bdd4a1ea..37c3d283eb4 100644 --- a/crates/apollo_batcher/src/block_builder_test.rs +++ b/crates/apollo_batcher/src/block_builder_test.rs @@ -45,10 +45,7 @@ use starknet_api::transaction::fields::{ VIRTUAL_SNOS, }; use starknet_api::transaction::TransactionHash; -#[cfg(feature = "os_input")] use starknet_api::{contract_address, felt, nonce, proof_facts, storage_key, tx_hash}; -#[cfg(not(feature = "os_input"))] -use starknet_api::{proof_facts, tx_hash}; use starknet_types_core::felt::Felt; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; @@ -104,7 +101,6 @@ async fn block_execution_artifacts( let block_summary = BlockExecutionSummary { state_diff: Default::default(), compressed_state_diff: Default::default(), - #[cfg(feature = "os_input")] initial_reads: test_initial_reads(), bouncer_weights: BouncerWeights { l1_gas: 100, ..BouncerWeights::empty() }, casm_hash_computation_data_sierra_gas: CasmHashComputationData::default(), @@ -141,7 +137,6 @@ fn execution_info() -> TransactionExecutionInfo { } } -#[cfg(feature = "os_input")] fn test_initial_reads() -> StateMaps { let mut initial_reads = StateMaps::default(); initial_reads.nonces.insert(contract_address!("0x1"), nonce!(7_u64)); @@ -459,7 +454,6 @@ async fn transaction_failed_test_expectations() -> TestExpectations { Ok(BlockExecutionSummary { state_diff: expected_block_artifacts_copy.commitment_state_diff, compressed_state_diff: None, - #[cfg(feature = "os_input")] initial_reads: test_initial_reads(), bouncer_weights: expected_block_artifacts_copy.bouncer_weights, casm_hash_computation_data_sierra_gas: expected_block_artifacts_copy @@ -559,7 +553,6 @@ async fn set_close_block_expectations( Ok(BlockExecutionSummary { state_diff: output_block_artifacts.commitment_state_diff, compressed_state_diff: None, - #[cfg(feature = "os_input")] initial_reads: test_initial_reads(), bouncer_weights: output_block_artifacts.bouncer_weights, casm_hash_computation_data_sierra_gas: output_block_artifacts @@ -1099,7 +1092,6 @@ async fn failed_l1_handler_transaction_consumed() { Ok(BlockExecutionSummary { state_diff: Default::default(), compressed_state_diff: None, - #[cfg(feature = "os_input")] initial_reads: test_initial_reads(), bouncer_weights: BouncerWeights::empty(), casm_hash_computation_data_sierra_gas: CasmHashComputationData::default(), @@ -1162,7 +1154,6 @@ async fn partial_chunk_execution_proposer() { Ok(BlockExecutionSummary { state_diff: expected_block_artifacts.commitment_state_diff, compressed_state_diff: None, - #[cfg(feature = "os_input")] initial_reads: test_initial_reads(), bouncer_weights: expected_block_artifacts.bouncer_weights, casm_hash_computation_data_sierra_gas: expected_block_artifacts diff --git a/crates/apollo_batcher/src/commitment_manager/commitment_manager_impl.rs b/crates/apollo_batcher/src/commitment_manager/commitment_manager_impl.rs index 71fe8cd8354..1070d7ae48c 100644 --- a/crates/apollo_batcher/src/commitment_manager/commitment_manager_impl.rs +++ b/crates/apollo_batcher/src/commitment_manager/commitment_manager_impl.rs @@ -6,15 +6,13 @@ use apollo_batcher_config::config::{ CommitmentManagerConfig, FirstBlockWithPartialBlockHash, }; -#[cfg(feature = "os_input")] -use apollo_committer_types::committer_types::ReadPathsAndCommitBlockRequest; use apollo_committer_types::committer_types::{ CommitBlockRequest, CommitBlockResponse, + ReadPathsAndCommitBlockRequest, RevertBlockRequest, }; use apollo_committer_types::communication::{CommitterRequestLabelValue, SharedCommitterClient}; -#[cfg(feature = "os_input")] use apollo_storage::accessed_keys::AccessedKeys as StorageAccessedKeys; use lru::LruCache; use starknet_api::block::{BlockHash, BlockNumber}; @@ -109,7 +107,7 @@ impl CommitmentManager { storage_writer: &mut Box, // When present, the task issues `ReadPathsAndCommitBlock` to also fetch the Patricia // witnesses; otherwise it falls back to `CommitBlock`. - #[cfg(feature = "os_input")] accessed_keys: Option, + accessed_keys: Option, ) -> CommitmentManagerResult<()> { if height != self.commitment_task_offset { return Err(CommitmentManagerError::WrongCommitmentTaskHeight { @@ -119,7 +117,6 @@ impl CommitmentManager { }); } let commit_request = CommitBlockRequest { height, state_diff, state_diff_commitment }; - #[cfg(feature = "os_input")] let task_input = match accessed_keys { Some(accessed_keys) => { CommitterTaskInput::ReadPathsAndCommitBlock(ReadPathsAndCommitBlockRequest { @@ -129,8 +126,6 @@ impl CommitmentManager { } None => CommitterTaskInput::Commit(commit_request), }; - #[cfg(not(feature = "os_input"))] - let task_input = CommitterTaskInput::Commit(commit_request); let commit_label = task_input.task_type(); self.add_task_with_retries( task_input, @@ -237,7 +232,6 @@ impl CommitmentManager { CommitterTaskOutput::Commit(commitment_task_result) => { commitment_results.push(commitment_task_result) } - #[cfg(feature = "os_input")] CommitterTaskOutput::ReadPathsAndCommitBlock(read_path_and_commit_task_result) => { commitment_results.push(read_path_and_commit_task_result) } @@ -271,17 +265,12 @@ impl CommitmentManager { }; // Get the final commitment. - let FinalBlockCommitment { - height, - block_hash, - global_root, - #[cfg(feature = "os_input")] - state_commitment_infos, - } = Self::finalize_commitment_output( - storage_reader.clone(), - commitment_task_output, - should_finalize_block_hash, - )?; + let FinalBlockCommitment { height, block_hash, global_root, state_commitment_infos } = + Self::finalize_commitment_output( + storage_reader.clone(), + commitment_task_output, + should_finalize_block_hash, + )?; // Verify the first new block hash matches the configured block hash. if let Some(FirstBlockWithPartialBlockHash { @@ -313,7 +302,6 @@ impl CommitmentManager { height, global_root, block_hash, - #[cfg(feature = "os_input")] state_commitment_infos, )?; GLOBAL_ROOT_HEIGHT.increment(1); @@ -430,7 +418,6 @@ impl CommitmentManager { }; // If accessed keys were persisted for this height, the task fetches the Patricia witnesses // via `ReadPathsAndCommitBlock`; otherwise it falls back to `CommitBlock`. - #[cfg(feature = "os_input")] let accessed_keys = batcher_storage_reader.get_accessed_keys(height).unwrap_or_else(|err| { panic!("Failed to read accessed keys for height {height}: {err}") @@ -442,7 +429,6 @@ impl CommitmentManager { &batcher_config.static_config.first_block_with_partial_block_hash, batcher_storage_reader, storage_writer, - #[cfg(feature = "os_input")] accessed_keys, ) .await @@ -529,7 +515,6 @@ impl CommitmentManager { CommitmentTaskOutput { response: CommitBlockResponse { global_root }, height, - #[cfg(feature = "os_input")] state_commitment_infos, }: CommitmentTaskOutput, should_finalize_block_hash: bool, @@ -565,13 +550,7 @@ impl CommitmentManager { )?) } }; - Ok(FinalBlockCommitment { - height, - block_hash, - global_root, - #[cfg(feature = "os_input")] - state_commitment_infos, - }) + Ok(FinalBlockCommitment { height, block_hash, global_root, state_commitment_infos }) } fn update_task_duration_metric( @@ -581,9 +560,10 @@ impl CommitmentManager { ) { if let Some(task_duration) = self.task_timer.stop_timer(task_type, height) { match task_type { - // Both commit endpoints (`CommitBlock` and, under `os_input`, - // `ReadPathsAndCommitBlock`) share the commit metric. - CommitterRequestLabelValue::CommitBlock => { + // Both commit endpoints share the commit metric; per-endpoint latency is + // observable via the `request_variant`-labeled infra metrics. + CommitterRequestLabelValue::CommitBlock + | CommitterRequestLabelValue::ReadPathsAndCommitBlock => { record_commit_block_metric(task_duration, height, task_type) } CommitterRequestLabelValue::RevertBlock => { @@ -593,11 +573,6 @@ impl CommitmentManager { COMMITMENT_MANAGER_REVERT_BLOCK_LATENCY.increment(task_duration); COMMITMENT_MANAGER_REVERT_BLOCK_COUNT.increment(1); } - #[cfg(feature = "os_input")] - CommitterRequestLabelValue::ReadPathsAndCommitBlock => { - // TODO(Ariel): Add dedicated metrics once we use os_input in prod. - record_commit_block_metric(task_duration, height, task_type) - } } } } diff --git a/crates/apollo_batcher/src/commitment_manager/commitment_manager_test.rs b/crates/apollo_batcher/src/commitment_manager/commitment_manager_test.rs index 597b95b9e25..5d75634534e 100644 --- a/crates/apollo_batcher/src/commitment_manager/commitment_manager_test.rs +++ b/crates/apollo_batcher/src/commitment_manager/commitment_manager_test.rs @@ -7,13 +7,13 @@ use apollo_batcher_config::config::{ CommitmentManagerConfig, FirstBlockWithPartialBlockHash, }; -#[cfg(feature = "os_input")] -use apollo_committer_types::committer_types::ReadPathsAndCommitBlockResponse; -use apollo_committer_types::committer_types::{CommitBlockResponse, RevertBlockResponse}; +use apollo_committer_types::committer_types::{ + CommitBlockResponse, + ReadPathsAndCommitBlockResponse, + RevertBlockResponse, +}; use apollo_committer_types::communication::MockCommitterClient; -#[cfg(feature = "os_input")] use apollo_storage::accessed_keys::AccessedKeys; -#[cfg(feature = "os_input")] use apollo_storage::state_commitment_infos::CompressedStateCommitmentInfos; use apollo_storage::StorageResult; use assert_matches::assert_matches; @@ -65,7 +65,6 @@ fn mock_dependencies() -> MockDependencies { committer_client.expect_revert_block().returning(|_| { Box::pin(async { Ok(RevertBlockResponse::RevertedTo(GlobalRoot::default())) }) }); - #[cfg(feature = "os_input")] committer_client.expect_read_paths_and_commit_block().returning(|_| { Box::pin(async { Ok(ReadPathsAndCommitBlockResponse { @@ -74,9 +73,6 @@ fn mock_dependencies() -> MockDependencies { }) }) }); - #[cfg(not(feature = "os_input"))] - let storage_reader = MockBatcherStorageReader::new(); - #[cfg(feature = "os_input")] let storage_reader = { let mut storage_reader = MockBatcherStorageReader::new(); storage_reader.expect_get_accessed_keys().returning(|_| Ok(Some(AccessedKeys::default()))); @@ -164,7 +160,6 @@ async fn fill_channels( first_block_with_partial_block_hash, storage_reader.clone(), storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -184,7 +179,6 @@ async fn fill_channels( first_block_with_partial_block_hash, storage_reader.clone(), storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -198,7 +192,6 @@ async fn fill_channels( first_block_with_partial_block_hash, storage_reader.clone(), storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -271,7 +264,6 @@ async fn test_add_missing_commitment_tasks(mut mock_dependencies: MockDependenci /// When no accessed keys are stored for a height, the catch-up flow must fall back to `CommitBlock` /// (not `ReadPathsAndCommitBlock`), and the resulting commitment carries no Patricia witnesses. -#[cfg(feature = "os_input")] #[rstest] #[tokio::test] async fn test_add_missing_commitment_tasks_without_accessed_keys( @@ -351,7 +343,6 @@ async fn test_add_commitment_task(mut mock_dependencies: MockDependencies) { &None, storage_reader.clone(), &mut storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await; @@ -375,7 +366,6 @@ async fn test_add_commitment_task(mut mock_dependencies: MockDependencies) { &None, storage_reader.clone(), &mut storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -403,9 +393,6 @@ async fn test_add_task_wait_for_full_channel(mut mock_dependencies: MockDependen let set_global_root_expectation = mock_dependencies.storage_writer.expect_set_global_root_and_block_hash(); set_global_root_expectation.times(expected_n_calls); - #[cfg(not(feature = "os_input"))] - set_global_root_expectation.withf(move |h, _, _| *h == height).returning(|_, _, _| Ok(())); - #[cfg(feature = "os_input")] set_global_root_expectation .withf(move |h, _, _, _| *h == height) .returning(|_, _, _, _| Ok(())); @@ -428,7 +415,6 @@ async fn test_add_task_wait_for_full_channel(mut mock_dependencies: MockDependen &None, storage_reader.clone(), &mut storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -488,7 +474,6 @@ async fn test_add_task_panic_on_full_channel(mut mock_dependencies: MockDependen &None, storage_reader.clone(), &mut storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -524,7 +509,6 @@ async fn test_get_commitment_results(mut mock_dependencies: MockDependencies) { &None, storage_reader.clone(), &mut storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -537,7 +521,6 @@ async fn test_get_commitment_results(mut mock_dependencies: MockDependencies) { &None, storage_reader, &mut storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await @@ -567,7 +550,6 @@ async fn add_commitments_and_revert_tasks( &None, storage_reader.clone(), storage_writer, - #[cfg(feature = "os_input")] Some(AccessedKeys::default()), ) .await diff --git a/crates/apollo_batcher/src/commitment_manager/state_committer.rs b/crates/apollo_batcher/src/commitment_manager/state_committer.rs index d53e35a07cb..1cda2d2a3b8 100644 --- a/crates/apollo_batcher/src/commitment_manager/state_committer.rs +++ b/crates/apollo_batcher/src/commitment_manager/state_committer.rs @@ -1,11 +1,11 @@ use std::time::Duration; -use apollo_committer_types::committer_types::{CommitBlockRequest, RevertBlockRequest}; -#[cfg(feature = "os_input")] use apollo_committer_types::committer_types::{ + CommitBlockRequest, CommitBlockResponse, ReadPathsAndCommitBlockRequest, ReadPathsAndCommitBlockResponse, + RevertBlockRequest, }; use apollo_committer_types::communication::SharedCommitterClient; use apollo_committer_types::errors::CommitterClientResult; @@ -96,7 +96,6 @@ async fn perform_task( CommitterTaskInput::Commit(commit_block_request) => { perform_commit_block_task(commit_block_request.clone(), committer_client).await } - #[cfg(feature = "os_input")] CommitterTaskInput::ReadPathsAndCommitBlock(read_paths_and_commit_block_request) => { perform_read_paths_and_commit_block_task( read_paths_and_commit_block_request.clone(), @@ -128,14 +127,12 @@ async fn perform_commit_block_task( Ok(CommitterTaskOutput::Commit(CommitmentTaskOutput { response, height, - #[cfg(feature = "os_input")] state_commitment_infos: None, })) } /// Commits the block and fetches the Patricia witnesses for the accessed keys via /// `ReadPathsAndCommitBlock`. -#[cfg(feature = "os_input")] async fn perform_read_paths_and_commit_block_task( request: ReadPathsAndCommitBlockRequest, committer_client: &SharedCommitterClient, diff --git a/crates/apollo_batcher/src/commitment_manager/types.rs b/crates/apollo_batcher/src/commitment_manager/types.rs index b1fe3f44e4b..6e79e960a77 100644 --- a/crates/apollo_batcher/src/commitment_manager/types.rs +++ b/crates/apollo_batcher/src/commitment_manager/types.rs @@ -4,16 +4,14 @@ use std::collections::HashMap; use std::fmt::Display; use std::time::Instant; -#[cfg(feature = "os_input")] -use apollo_committer_types::committer_types::ReadPathsAndCommitBlockRequest; use apollo_committer_types::committer_types::{ CommitBlockRequest, CommitBlockResponse, + ReadPathsAndCommitBlockRequest, RevertBlockRequest, RevertBlockResponse, }; use apollo_committer_types::communication::CommitterRequestLabelValue; -#[cfg(feature = "os_input")] use apollo_storage::state_commitment_infos::CompressedStateCommitmentInfos; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::core::GlobalRoot; @@ -24,7 +22,6 @@ use tracing::warn; #[cfg_attr(test, derive(Clone))] pub(crate) enum CommitterTaskInput { Commit(CommitBlockRequest), - #[cfg(feature = "os_input")] ReadPathsAndCommitBlock(ReadPathsAndCommitBlockRequest), Revert(RevertBlockRequest), } @@ -33,7 +30,6 @@ impl CommitterTaskInput { pub(crate) fn height(&self) -> BlockNumber { match self { Self::Commit(request) => request.height, - #[cfg(feature = "os_input")] Self::ReadPathsAndCommitBlock(request) => request.commit.height, Self::Revert(request) => request.height, } @@ -43,7 +39,6 @@ impl CommitterTaskInput { pub(crate) fn task_type(&self) -> CommitterRequestLabelValue { match self { Self::Commit(_) => CommitterRequestLabelValue::CommitBlock, - #[cfg(feature = "os_input")] Self::ReadPathsAndCommitBlock(_) => CommitterRequestLabelValue::ReadPathsAndCommitBlock, Self::Revert(_) => CommitterRequestLabelValue::RevertBlock, } @@ -58,7 +53,6 @@ impl Display for CommitterTaskInput { "Commit(height={}, state_diff_commitment={:?})", request.height, request.state_diff_commitment ), - #[cfg(feature = "os_input")] Self::ReadPathsAndCommitBlock(request) => write!( f, "ReadPathsAndCommitBlock(height={}, state_diff_commitment={:?}, \ @@ -78,7 +72,6 @@ pub(crate) struct CommitmentTaskOutput { pub(crate) height: BlockNumber, // Compressed commitment infos from the committer. `None` when the block was committed via // `CommitBlock` (no accessed keys to request the Patricia witnesses). - #[cfg(feature = "os_input")] pub(crate) state_commitment_infos: Option, } @@ -91,7 +84,6 @@ pub(crate) struct RevertTaskOutput { #[derive(Clone, Debug)] pub(crate) enum CommitterTaskOutput { Commit(CommitmentTaskOutput), - #[cfg(feature = "os_input")] ReadPathsAndCommitBlock(CommitmentTaskOutput), Revert(RevertTaskOutput), } @@ -100,7 +92,6 @@ impl CommitterTaskOutput { pub(crate) fn expect_commitment(self) -> CommitmentTaskOutput { match self { Self::Commit(commitment_task_output) => commitment_task_output, - #[cfg(feature = "os_input")] Self::ReadPathsAndCommitBlock(commitment_task_output) => commitment_task_output, Self::Revert(_) => panic!("Got revert output: {self:?}"), } @@ -109,7 +100,6 @@ impl CommitterTaskOutput { pub(crate) fn height(&self) -> BlockNumber { match self { Self::Commit(output) => output.height, - #[cfg(feature = "os_input")] Self::ReadPathsAndCommitBlock(output) => output.height, Self::Revert(output) => output.height, } @@ -118,7 +108,6 @@ impl CommitterTaskOutput { pub(crate) fn task_label(&self) -> CommitterRequestLabelValue { match self { Self::Commit(_) => CommitterRequestLabelValue::CommitBlock, - #[cfg(feature = "os_input")] Self::ReadPathsAndCommitBlock(_) => CommitterRequestLabelValue::ReadPathsAndCommitBlock, Self::Revert(_) => CommitterRequestLabelValue::RevertBlock, } @@ -133,13 +122,11 @@ pub(crate) struct FinalBlockCommitment { pub(crate) global_root: GlobalRoot, // Compressed commitment infos from the committer. `None` when the block was committed via // `CommitBlock` (no accessed keys to request the Patricia witnesses). - #[cfg(feature = "os_input")] pub(crate) state_commitment_infos: Option, } pub(crate) struct TaskTimer { pub(crate) commit: HashMap, - #[cfg(feature = "os_input")] pub(crate) read_paths_and_commit_block: HashMap, pub(crate) revert: HashMap, } @@ -148,7 +135,6 @@ impl TaskTimer { pub(crate) fn new() -> Self { Self { commit: HashMap::new(), - #[cfg(feature = "os_input")] read_paths_and_commit_block: HashMap::new(), revert: HashMap::new(), } @@ -161,7 +147,6 @@ impl TaskTimer { ) -> &mut HashMap { match task { CommitterRequestLabelValue::CommitBlock => &mut self.commit, - #[cfg(feature = "os_input")] CommitterRequestLabelValue::ReadPathsAndCommitBlock => { &mut self.read_paths_and_commit_block } diff --git a/crates/apollo_batcher/src/communication.rs b/crates/apollo_batcher/src/communication.rs index 08502d3ccbe..7410ad47bd0 100644 --- a/crates/apollo_batcher/src/communication.rs +++ b/crates/apollo_batcher/src/communication.rs @@ -25,7 +25,6 @@ impl ComponentRequestHandler for Batcher { BatcherRequest::GetBlockHash(block_number) => { BatcherResponse::GetBlockHash(self.get_block_hash(block_number)) } - #[cfg(feature = "os_input")] BatcherRequest::GetStateCommitmentInfos(block_number) => { BatcherResponse::GetStateCommitmentInfos( self.get_state_commitment_infos(block_number), diff --git a/crates/apollo_batcher/src/test_utils.rs b/crates/apollo_batcher/src/test_utils.rs index 75895318fbe..e20e1c524e1 100644 --- a/crates/apollo_batcher/src/test_utils.rs +++ b/crates/apollo_batcher/src/test_utils.rs @@ -8,25 +8,23 @@ use apollo_batcher_config::config::{ FirstBlockWithPartialBlockHash, }; use apollo_batcher_types::batcher_types::{ProposalId, ProposeBlockInput}; -#[cfg(feature = "os_input")] -use apollo_committer_types::committer_types::ReadPathsAndCommitBlockResponse; -use apollo_committer_types::committer_types::{CommitBlockResponse, RevertBlockResponse}; +use apollo_committer_types::committer_types::{ + CommitBlockResponse, + ReadPathsAndCommitBlockResponse, + RevertBlockResponse, +}; use apollo_committer_types::communication::MockCommitterClient; use apollo_committer_types::test_utils::MockCommitterClientWithOffset; use apollo_l1_events_types::MockL1EventsProviderClient; use apollo_mempool_types::communication::MockMempoolClient; use apollo_mempool_types::mempool_types::CommitBlockArgs; -#[cfg(feature = "os_input")] use apollo_storage::accessed_keys::AccessedKeys; -#[cfg(feature = "os_input")] use apollo_storage::state_commitment_infos::CompressedStateCommitmentInfos; use async_trait::async_trait; use blockifier::blockifier::transaction_executor::BlockExecutionSummary; use blockifier::bouncer::{BouncerWeights, CasmHashComputationData}; use blockifier::fee::receipt::TransactionReceipt; -use blockifier::state::cached_state::CommitmentStateDiff; -#[cfg(feature = "os_input")] -use blockifier::state::cached_state::StateMaps; +use blockifier::state::cached_state::{CommitmentStateDiff, StateMaps}; use blockifier::transaction::objects::TransactionExecutionInfo; use indexmap::{indexmap, IndexMap}; use mockall::predicate::eq; @@ -215,7 +213,6 @@ impl BlockExecutionArtifacts { address_to_nonce: IndexMap::from_iter([(contract_address!("0x7"), nonce!(1_u64))]), }, compressed_state_diff: Default::default(), - #[cfg(feature = "os_input")] initial_reads: StateMaps::default(), bouncer_weights: BouncerWeights::empty(), casm_hash_computation_data_sierra_gas: CasmHashComputationData::empty(), @@ -304,7 +301,6 @@ impl Default for MockClients { committer_client_inner.expect_revert_block().returning(|_| { Box::pin(async { Ok(RevertBlockResponse::RevertedTo(GlobalRoot::default())) }) }); - #[cfg(feature = "os_input")] committer_client_inner.expect_read_paths_and_commit_block().returning(|_| { Box::pin(async { Ok(ReadPathsAndCommitBlockResponse { @@ -348,7 +344,6 @@ impl Default for MockDependencies { .returning(|_| { Ok((Some(BlockHash::default()), Some(PartialBlockHashComponents::default()))) }); - #[cfg(feature = "os_input")] storage_reader.expect_get_accessed_keys().returning(|_| Ok(Some(AccessedKeys::default()))); let batcher_config = BatcherConfig { diff --git a/crates/apollo_batcher_types/Cargo.toml b/crates/apollo_batcher_types/Cargo.toml index 311f96f36dd..cef20cb8a71 100644 --- a/crates/apollo_batcher_types/Cargo.toml +++ b/crates/apollo_batcher_types/Cargo.toml @@ -7,7 +7,6 @@ repository.workspace = true description = "Type definitions and interfaces for the Apollo batcher component." [features] -os_input = ["dep:starknet_committer"] testing = ["mockall"] [lints] @@ -26,7 +25,7 @@ mockall = { workspace = true, optional = true } serde = { workspace = true, features = ["derive"] } starknet-types-core.workspace = true starknet_api.workspace = true -starknet_committer = { workspace = true, optional = true } +starknet_committer.workspace = true strum = { workspace = true, features = ["derive"] } thiserror.workspace = true diff --git a/crates/apollo_batcher_types/src/batcher_types.rs b/crates/apollo_batcher_types/src/batcher_types.rs index d6f8dfc5a10..0ab56a8b5ff 100644 --- a/crates/apollo_batcher_types/src/batcher_types.rs +++ b/crates/apollo_batcher_types/src/batcher_types.rs @@ -3,9 +3,7 @@ use std::ops::Deref; use blockifier::blockifier::transaction_executor::CompiledClassHashesForMigration; use blockifier::bouncer::{BouncerWeights, CasmHashComputationData}; -use blockifier::state::cached_state::CommitmentStateDiff; -#[cfg(feature = "os_input")] -use blockifier::state::cached_state::StateMaps; +use blockifier::state::cached_state::{CommitmentStateDiff, StateMaps}; use blockifier::transaction::objects::TransactionExecutionInfo; use chrono::prelude::*; use indexmap::IndexMap; @@ -161,7 +159,6 @@ pub struct CentralObjects { pub compiled_class_hashes_for_migration: CompiledClassHashesForMigration, pub parent_proposal_commitment: Option, /// Pre-block read values the OS needs to replay the block. - #[cfg(feature = "os_input")] pub initial_reads: StateMaps, } diff --git a/crates/apollo_batcher_types/src/communication.rs b/crates/apollo_batcher_types/src/communication.rs index a79b7e0c764..6acb7da568a 100644 --- a/crates/apollo_batcher_types/src/communication.rs +++ b/crates/apollo_batcher_types/src/communication.rs @@ -15,7 +15,6 @@ use async_trait::async_trait; use mockall::automock; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockHash, BlockNumber, ReplayBlockMetadata}; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::types::CompressedStateCommitmentInfos; use strum::{AsRefStr, EnumDiscriminants, EnumIter, IntoStaticStr, VariantNames}; use thiserror::Error; @@ -58,7 +57,6 @@ pub trait BatcherClient: Send + Sync { async fn get_block_hash(&self, block_number: BlockNumber) -> BatcherClientResult; /// Gets the compressed state commitment infos for a block. Returns `Ok(None)` when the block /// is not committed yet. - #[cfg(feature = "os_input")] async fn get_state_commitment_infos( &self, block_number: BlockNumber, @@ -120,7 +118,6 @@ pub trait BatcherClient: Send + Sync { pub enum BatcherRequest { ProposeBlock(ProposeBlockInput), GetBlockHash(BlockNumber), - #[cfg(feature = "os_input")] GetStateCommitmentInfos(BlockNumber), GetProposalContent(GetProposalContentInput), ValidateBlock(ValidateBlockInput), @@ -148,7 +145,6 @@ generate_permutation_labels! { pub enum BatcherResponse { ProposeBlock(BatcherResult<()>), GetBlockHash(BatcherResult), - #[cfg(feature = "os_input")] GetStateCommitmentInfos(BatcherResult>), GetCurrentHeight(BatcherResult), GetProposalContent(BatcherResult), @@ -204,7 +200,6 @@ where ) } - #[cfg(feature = "os_input")] async fn get_state_commitment_infos( &self, block_number: BlockNumber, diff --git a/crates/apollo_committer/Cargo.toml b/crates/apollo_committer/Cargo.toml index e1be0e50374..f9258a9774a 100644 --- a/crates/apollo_committer/Cargo.toml +++ b/crates/apollo_committer/Cargo.toml @@ -7,7 +7,6 @@ license.workspace = true description = "State root commitment computation component for the Starknet sequencer." [features] -os_input = ["apollo_committer_types/os_input", "starknet_committer/os_input"] testing = [] [dependencies] diff --git a/crates/apollo_committer/src/committer.rs b/crates/apollo_committer/src/committer.rs index e79eff05735..19d04a5f6b4 100644 --- a/crates/apollo_committer/src/committer.rs +++ b/crates/apollo_committer/src/committer.rs @@ -7,13 +7,10 @@ use apollo_committer_config::config::{ApolloStorage, CommitterConfig}; use apollo_committer_types::committer_types::{ CommitBlockRequest, CommitBlockResponse, - RevertBlockRequest, - RevertBlockResponse, -}; -#[cfg(feature = "os_input")] -use apollo_committer_types::committer_types::{ ReadPathsAndCommitBlockRequest, ReadPathsAndCommitBlockResponse, + RevertBlockRequest, + RevertBlockResponse, }; use apollo_committer_types::errors::{CommitterError, CommitterResult}; use apollo_infra::component_definitions::{default_component_start_fn, ComponentStarter}; @@ -23,9 +20,8 @@ use starknet_api::block_hash::state_diff_hash::calculate_state_diff_hash; use starknet_api::core::{GlobalRoot, StateDiffCommitment}; use starknet_api::hash::PoseidonHash; use starknet_api::state::ThinStateDiff; -use starknet_committer::block_committer::commit::commit_block; -#[cfg(feature = "os_input")] use starknet_committer::block_committer::commit::{ + commit_block, commit_block_with_witnesses, CommitBlockWithWitnessesOutput, }; @@ -38,7 +34,6 @@ use starknet_committer::block_committer::measurements_util::{ MeasurementsTrait, SingleBlockMeasurements, }; -#[cfg(feature = "os_input")] use starknet_committer::db::forest_trait::forest_trait_witnesses::{ CommitmentInfosUpdate, CommitmentInfosWrite, @@ -50,24 +45,19 @@ use starknet_committer::db::forest_trait::{ ForestStorageWithEmptyReadContext, }; use starknet_committer::db::index_db::IndexDb; -#[cfg(feature = "os_input")] -use starknet_committer::db::serde_db_utils::accessed_keys_digest; use starknet_committer::db::serde_db_utils::{ + accessed_keys_digest, deserialize_felt_no_packing, serialize_felt_no_packing, DbBlockNumber, }; use starknet_committer::forest::deleted_nodes::DeletedNodes; use starknet_committer::forest::filled_forest::FilledForest; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::tree::LeavesRequest; -#[cfg(feature = "os_input")] use starknet_patricia_storage::errors::SerializationError; use starknet_patricia_storage::map_storage::CachedStorage; use starknet_patricia_storage::rocksdb_storage::RocksDbStorage; -#[cfg(feature = "os_input")] -use starknet_patricia_storage::storage_trait::ImmutableReadOnlyStorage; -use starknet_patricia_storage::storage_trait::{DbValue, Storage}; +use starknet_patricia_storage::storage_trait::{DbValue, ImmutableReadOnlyStorage, Storage}; use tracing::{debug, error, info, warn}; use crate::metrics::{ @@ -165,8 +155,9 @@ where impl Committer where - S: StorageConstructor, - ForestDB: ForestStorageWithEmptyReadContext, + S: StorageConstructor + ImmutableReadOnlyStorage + 'static, + ForestDB: + ForestStorageWithEmptyReadContext + ForestStorageWithWitnesses, { pub async fn new(config: CommitterConfig) -> Self { let storage = S::create_storage(config.db_path.clone(), config.storage_config.clone()); @@ -404,26 +395,16 @@ where to {last_committed_block}" ); block_measurements.start_measurement(Action::Write); - let n_write_entries = { - #[cfg(not(feature = "os_input"))] - { - self.forest_storage - .write_with_metadata(&filled_forest, metadata, deleted_nodes) - .await - } - #[cfg(feature = "os_input")] - { - self.forest_storage - .write_with_metadata_and_commitment_infos( - &filled_forest, - metadata, - deleted_nodes, - CommitmentInfosUpdate::Delete(height), - ) - .await - } - } - .map_err(|err| self.map_internal_error(err))?; + let n_write_entries = self + .forest_storage + .write_with_metadata_and_commitment_infos( + &filled_forest, + metadata, + deleted_nodes, + CommitmentInfosUpdate::Delete(height), + ) + .await + .map_err(|err| self.map_internal_error(err))?; block_measurements.attempt_to_stop_measurement(Action::Write, n_write_entries).ok(); block_measurements.attempt_to_stop_measurement(Action::EndToEnd, 0).ok(); update_metrics( @@ -508,14 +489,7 @@ where error!("Error committing block number {height}. {error_message}."); CommitterError::Internal { height, message: error_message } } -} -#[cfg(feature = "os_input")] -impl Committer -where - S: StorageConstructor + ImmutableReadOnlyStorage + 'static, - ForestDB: ForestStorageWithWitnesses, -{ /// Commits the next block and returns merged Patricia witness facts for OS input, persisting /// digest + payload for idempotent replay. pub async fn read_paths_and_commit_block( @@ -669,13 +643,7 @@ fn update_metrics( n_writes, durations, modifications_counts, - #[cfg(feature = "os_input")] fetched_witnesses_count, - // TODO(Yoav): Remove the ".." where os_input becomes default. - // It is needed now for including `BlockMeasurement::fetched_witnesses_count` where - // `starknet_committer/os_input` is enabled by other crates, while - // `apollo_committer/os_input` is disabled. - .. }: &BlockMeasurement, commit_duration_warn_threshold: Duration, ) { @@ -744,7 +712,6 @@ fn update_metrics( modifications_counts, emptied_leaves_percentage, commit_duration_warn_threshold, - #[cfg(feature = "os_input")] *fetched_witnesses_count, ); } @@ -760,17 +727,14 @@ fn log_block_measurements( modifications_counts: &BlockModificationsCounts, emptied_leaves_percentage: Option, commit_duration_warn_threshold: Duration, - #[cfg(feature = "os_input")] fetched_witnesses_count: usize, + fetched_witnesses_count: usize, ) { - #[cfg(feature = "os_input")] let witness_log = format!( "witness fetch ms (pre-commit/post-commit): {:.0}/{:.0}, witness entries: {}", durations.fetch_witnesses_first_pass * 1000.0, durations.fetch_witnesses_second_pass * 1000.0, fetched_witnesses_count, ); - #[cfg(not(feature = "os_input"))] - let witness_log = String::new(); let stats = format!( "Block {height} stats: durations in ms (total/read/compute/write): \ diff --git a/crates/apollo_committer/src/committer_test.rs b/crates/apollo_committer/src/committer_test.rs index 34880f8c561..8df5d2b6ba4 100644 --- a/crates/apollo_committer/src/committer_test.rs +++ b/crates/apollo_committer/src/committer_test.rs @@ -24,7 +24,6 @@ use super::Committer; use crate::committer::StorageConstructor; use crate::metrics::{register_metrics, COMMITTER_BLOCK_COMMIT_LATENCY}; -#[cfg(feature = "os_input")] #[path = "request_paths_and_commit_block_tests.rs"] mod request_paths_and_commit_block_tests; diff --git a/crates/apollo_committer/src/communication.rs b/crates/apollo_committer/src/communication.rs index 2f9ffcbc54e..703da59b77a 100644 --- a/crates/apollo_committer/src/communication.rs +++ b/crates/apollo_committer/src/communication.rs @@ -2,11 +2,7 @@ use apollo_committer_types::communication::{CommitterRequest, CommitterResponse} use apollo_infra::component_definitions::ComponentRequestHandler; use apollo_infra::component_server::{LocalComponentServer, RemoteComponentServer}; use async_trait::async_trait; -#[cfg(feature = "os_input")] use starknet_committer::db::forest_trait::forest_trait_witnesses::ForestStorageWithWitnesses; -#[cfg(not(feature = "os_input"))] -use starknet_committer::db::forest_trait::ForestStorageWithEmptyReadContext; -#[cfg(feature = "os_input")] use starknet_patricia_storage::storage_trait::ImmutableReadOnlyStorage; use crate::committer::{ApolloCommitter, Committer, StorageConstructor}; @@ -15,25 +11,6 @@ pub type LocalCommitterServer = LocalComponentServer; pub type RemoteCommitterServer = RemoteComponentServer; -// `CommitterRequest` without variant `ReadPathsAndCommitBlock` for `os_input` feature. -#[cfg(not(feature = "os_input"))] -#[async_trait] -impl> - ComponentRequestHandler for Committer -{ - async fn handle_request(&mut self, request: CommitterRequest) -> CommitterResponse { - match request { - CommitterRequest::CommitBlock(commit_block_request) => { - CommitterResponse::CommitBlock(self.commit_block(commit_block_request).await) - } - CommitterRequest::RevertBlock(revert_block_request) => { - CommitterResponse::RevertBlock(self.revert_block(revert_block_request).await) - } - } - } -} - -#[cfg(feature = "os_input")] #[async_trait] impl ComponentRequestHandler for Committer diff --git a/crates/apollo_committer_types/Cargo.toml b/crates/apollo_committer_types/Cargo.toml index 2fbbe8d44d5..c5461c49f46 100644 --- a/crates/apollo_committer_types/Cargo.toml +++ b/crates/apollo_committer_types/Cargo.toml @@ -7,14 +7,13 @@ license.workspace = true description = "Type definitions and interfaces for the Apollo committer component." [features] -os_input = ["dep:blockifier", "starknet_committer/os_input"] testing = ["mockall", "tokio"] [dependencies] apollo_infra.workspace = true apollo_metrics.workspace = true async-trait.workspace = true -blockifier = { workspace = true, features = ["transaction_serde"], optional = true } +blockifier = { workspace = true, features = ["transaction_serde"] } mockall = { workspace = true, optional = true } serde.workspace = true starknet_api.workspace = true diff --git a/crates/apollo_committer_types/src/committer_types.rs b/crates/apollo_committer_types/src/committer_types.rs index 8b879c786d8..6ace57dc5ff 100644 --- a/crates/apollo_committer_types/src/committer_types.rs +++ b/crates/apollo_committer_types/src/committer_types.rs @@ -1,10 +1,8 @@ -#[cfg(feature = "os_input")] pub use blockifier::state::accessed_keys::AccessedKeys; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use starknet_api::core::{GlobalRoot, StateDiffCommitment}; use starknet_api::state::ThinStateDiff; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::types::CompressedStateCommitmentInfos; #[derive(Clone, Debug, Serialize, Deserialize)] @@ -39,14 +37,12 @@ pub enum RevertBlockResponse { /// Commit a block and return merged Patricia witness proofs for OS input (pre- and post-commit /// paths). -#[cfg(feature = "os_input")] #[derive(Clone, Debug, Serialize, Deserialize)] pub struct ReadPathsAndCommitBlockRequest { pub commit: CommitBlockRequest, pub accessed_keys: AccessedKeys, } -#[cfg(feature = "os_input")] #[derive(Clone, Debug, Serialize, Deserialize)] pub struct ReadPathsAndCommitBlockResponse { pub global_root: GlobalRoot, diff --git a/crates/apollo_committer_types/src/communication.rs b/crates/apollo_committer_types/src/communication.rs index 9b1f1af30a4..446cfa7a62b 100644 --- a/crates/apollo_committer_types/src/communication.rs +++ b/crates/apollo_committer_types/src/communication.rs @@ -18,11 +18,11 @@ use strum::{AsRefStr, EnumDiscriminants, EnumIter, IntoStaticStr, VariantNames}; use crate::committer_types::{ CommitBlockRequest, CommitBlockResponse, + ReadPathsAndCommitBlockRequest, + ReadPathsAndCommitBlockResponse, RevertBlockRequest, RevertBlockResponse, }; -#[cfg(feature = "os_input")] -use crate::committer_types::{ReadPathsAndCommitBlockRequest, ReadPathsAndCommitBlockResponse}; use crate::errors::{CommitterClientError, CommitterClientResult, CommitterResult}; pub type LocalCommitterClient = LocalComponentClient; @@ -46,7 +46,6 @@ pub trait CommitterClient: Send + Sync { input: RevertBlockRequest, ) -> CommitterClientResult; - #[cfg(feature = "os_input")] /// Applies the state diff, collects merged Patricia witnesses for OS input, and persists replay /// data (digest + payload). async fn read_paths_and_commit_block( @@ -64,7 +63,6 @@ pub trait CommitterClient: Send + Sync { pub enum CommitterRequest { CommitBlock(CommitBlockRequest), RevertBlock(RevertBlockRequest), - #[cfg(feature = "os_input")] ReadPathsAndCommitBlock(ReadPathsAndCommitBlockRequest), } @@ -76,7 +74,6 @@ impl PrioritizedRequest for CommitterRequest {} pub enum CommitterResponse { CommitBlock(CommitterResult), RevertBlock(CommitterResult), - #[cfg(feature = "os_input")] ReadPathsAndCommitBlock(CommitterResult), } @@ -124,7 +121,6 @@ where ) } - #[cfg(feature = "os_input")] async fn read_paths_and_commit_block( &self, input: ReadPathsAndCommitBlockRequest, diff --git a/crates/apollo_committer_types/src/errors.rs b/crates/apollo_committer_types/src/errors.rs index f440c492e72..f56a25f5240 100644 --- a/crates/apollo_committer_types/src/errors.rs +++ b/crates/apollo_committer_types/src/errors.rs @@ -3,7 +3,6 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use starknet_api::core::{GlobalRoot, StateDiffCommitment}; use starknet_committer::db::forest_trait::ForestMetadataType; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::types::StateCommitmentInfosCodecError; use thiserror::Error; @@ -51,25 +50,19 @@ pub enum CommitterError { height: BlockNumber, }, /// Patricia trie path collection for OS input failed. - #[cfg(feature = "os_input")] #[error("Failed Patricia paths collection at block {height}: {message}")] PatriciaPathsCollectionFailed { height: BlockNumber, message: String }, /// Stored accessed-keys digest does not match the request (or no digest was stored). - #[cfg(feature = "os_input")] #[error( "Accessed-keys digest mismatch at block {height}: expected {expected:?}, stored {stored:?}" )] AccessedKeysDigestMismatch { height: BlockNumber, stored: Option<[u8; 32]>, expected: [u8; 32] }, /// Merged Patricia witness paths are missing for replay. - #[cfg(feature = "os_input")] #[error("Missing Patricia paths for block {height}")] MissingPatriciaPaths { height: BlockNumber }, - #[cfg(feature = "os_input")] #[error("Failed to compress state commitment infos: {0}")] StateCommitmentInfosCompression(String), } - -#[cfg(feature = "os_input")] impl From for CommitterError { fn from(error: StateCommitmentInfosCodecError) -> Self { CommitterError::StateCommitmentInfosCompression(error.to_string()) diff --git a/crates/apollo_committer_types/src/test_utils.rs b/crates/apollo_committer_types/src/test_utils.rs index 3c33c681aaa..917c90a2d86 100644 --- a/crates/apollo_committer_types/src/test_utils.rs +++ b/crates/apollo_committer_types/src/test_utils.rs @@ -7,11 +7,11 @@ use tokio::sync::Mutex; use crate::committer_types::{ CommitBlockRequest, CommitBlockResponse, + ReadPathsAndCommitBlockRequest, + ReadPathsAndCommitBlockResponse, RevertBlockRequest, RevertBlockResponse, }; -#[cfg(feature = "os_input")] -use crate::committer_types::{ReadPathsAndCommitBlockRequest, ReadPathsAndCommitBlockResponse}; use crate::communication::{CommitterClient, MockCommitterClient}; use crate::errors::CommitterClientResult; @@ -42,7 +42,6 @@ impl CommitterClient for MockCommitterClientWithOffset { self.inner.revert_block(input).await } - #[cfg(feature = "os_input")] async fn read_paths_and_commit_block( &self, input: ReadPathsAndCommitBlockRequest, diff --git a/crates/apollo_consensus_manager/Cargo.toml b/crates/apollo_consensus_manager/Cargo.toml index 844c64b3fe8..1f795fc912b 100644 --- a/crates/apollo_consensus_manager/Cargo.toml +++ b/crates/apollo_consensus_manager/Cargo.toml @@ -7,7 +7,6 @@ repository.workspace = true description = "Manages consensus operations and coordinates between consensus and other node components." [features] -os_input = ["apollo_consensus_orchestrator/os_input"] testing = [] [lints] diff --git a/crates/apollo_consensus_orchestrator/Cargo.toml b/crates/apollo_consensus_orchestrator/Cargo.toml index 4264429dc07..b6f6f7c8ea9 100644 --- a/crates/apollo_consensus_orchestrator/Cargo.toml +++ b/crates/apollo_consensus_orchestrator/Cargo.toml @@ -43,7 +43,7 @@ serde_json = { workspace = true, features = ["arbitrary_precision"] } shared_execution_objects.workspace = true starknet-types-core.workspace = true starknet_api.workspace = true -starknet_committer = { workspace = true, optional = true } +starknet_committer.workspace = true strum = { workspace = true, features = ["derive"] } thiserror.workspace = true tokio = { workspace = true, features = ["full"] } @@ -89,5 +89,4 @@ shared_execution_objects = { workspace = true, features = ["deserialize", "testi workspace = true [features] -os_input = ["apollo_batcher/os_input", "dep:starknet_committer"] testing = ["shared_execution_objects/deserialize", "shared_execution_objects/testing"] diff --git a/crates/apollo_consensus_orchestrator/src/build_proposal.rs b/crates/apollo_consensus_orchestrator/src/build_proposal.rs index 9818cf2c22b..bd66788ea9c 100644 --- a/crates/apollo_consensus_orchestrator/src/build_proposal.rs +++ b/crates/apollo_consensus_orchestrator/src/build_proposal.rs @@ -48,18 +48,15 @@ use crate::utils::{ expected_version_constant_commitment, get_l1_prices_in_fri_and_wei, truncate_to_executed_txs, + verify_retrospective_state_commitment_infos, wait_for_retrospective_block_hash, GasPriceParams, L1PricesInFri, L1PricesInWei, PreviousProposalInitInfo, RetrospectiveBlockHashError, - StreamSender, -}; -#[cfg(feature = "os_input")] -use crate::utils::{ - verify_retrospective_state_commitment_infos, RetrospectiveStateCommitmentInfosError, + StreamSender, }; // Minimal wait time that avoids an immediate timeout. @@ -106,7 +103,6 @@ pub(crate) enum BuildProposalError { Batcher(String, BatcherClientError), #[error(transparent)] RetrospectiveBlockHashError(#[from] RetrospectiveBlockHashError), - #[cfg(feature = "os_input")] #[error(transparent)] RetrospectiveStateCommitmentInfosError(#[from] RetrospectiveStateCommitmentInfosError), #[error("Failed to send proposal part: {0}")] @@ -235,7 +231,6 @@ async fn initiate_build(args: &mut ProposalBuildArguments) -> BuildProposalResul // Make sure the blob of this height will carry the next height's retrospective commitment // infos. - #[cfg(feature = "os_input")] verify_retrospective_state_commitment_infos( args.deps.batcher.as_ref(), args.deps.cende_ambassador.as_ref(), diff --git a/crates/apollo_consensus_orchestrator/src/cende/central_objects_test.rs b/crates/apollo_consensus_orchestrator/src/cende/central_objects_test.rs index bb320f517c7..32a79f823e1 100644 --- a/crates/apollo_consensus_orchestrator/src/cende/central_objects_test.rs +++ b/crates/apollo_consensus_orchestrator/src/cende/central_objects_test.rs @@ -45,12 +45,11 @@ use blockifier::fee::resources::{ StateResources, TransactionResources, }; -#[cfg(feature = "os_input")] -use blockifier::state::cached_state::StateMaps; use blockifier::state::cached_state::{ CommitmentStateDiff, StateChangesCount, StateChangesCountForFee, + StateMaps, }; use blockifier::transaction::objects::{RevertError, TransactionExecutionInfo}; use cairo_lang_casm::hints::{CoreHint, CoreHintBase, Hint}; @@ -131,7 +130,6 @@ use starknet_api::transaction::{ TransactionVersion, }; use starknet_api::{contract_address, felt, nonce, storage_key}; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::types::CompressedStateCommitmentInfos; use starknet_types_core::felt::Felt; @@ -151,9 +149,12 @@ use super::{ CentralTransactionWritten, }; use crate::cende::central_objects::CentralCasmContractClass; -#[cfg(feature = "os_input")] -use crate::cende::StateCommitmentInfosAndNumber; -use crate::cende::{AerospikeBlob, BlobParameters, InternalTransactionWithReceipt}; +use crate::cende::{ + AerospikeBlob, + BlobParameters, + InternalTransactionWithReceipt, + StateCommitmentInfosAndNumber, +}; // TODO(yael, dvir): add default object serialization tests. @@ -737,7 +738,6 @@ fn input_txs_and_mock_class_manager() -> (Vec, Moc (transactions, mock_class_manager) } -#[cfg(feature = "os_input")] fn recent_state_commitment_infos() -> Vec { [BlockNumber(1), BlockNumber(2)] .into_iter() @@ -780,9 +780,7 @@ fn central_blob() -> AerospikeBlob { BlockHashAndNumber { number: BlockNumber(1), hash: BlockHash(felt!("0x1")) }, BlockHashAndNumber { number: BlockNumber(2), hash: BlockHash(felt!("0x2")) }, ], - #[cfg(feature = "os_input")] recent_state_commitment_infos: recent_state_commitment_infos(), - #[cfg(feature = "os_input")] initial_reads: StateMaps::default(), }; @@ -814,9 +812,7 @@ fn central_blob_with_empty_or_none_fields() -> AerospikeBlob { proposal_commitment: ProposalCommitment(felt!("0x80020000")), parent_proposal_commitment: None, recent_block_hashes: vec![], - #[cfg(feature = "os_input")] recent_state_commitment_infos: vec![], - #[cfg(feature = "os_input")] initial_reads: StateMaps::default(), }; @@ -1173,10 +1169,9 @@ fn serialize_central_objects(#[case] rust_obj: impl Serialize, #[case] python_js let python_json: serde_json::Value = read_json_file(python_json_path); let rust_json = serde_json::to_value(rust_obj).unwrap(); - // `recent_state_commitment_infos` and `initial_reads` are os_input-only and absent from the - // central (python) blob, so strip them before comparing. + // `recent_state_commitment_infos` and `initial_reads` are not yet included in the central + // (python) blob fixture, so strip them before comparing. // TODO(Itamar): Remove this stripping once the python blob includes the fields. - #[cfg(feature = "os_input")] let rust_json = { let mut rust_json = rust_json; if let Some(object) = rust_json.as_object_mut() { diff --git a/crates/apollo_consensus_orchestrator/src/cende/mod.rs b/crates/apollo_consensus_orchestrator/src/cende/mod.rs index 8ddf7eb0ce9..cd8a621e7cf 100644 --- a/crates/apollo_consensus_orchestrator/src/cende/mod.rs +++ b/crates/apollo_consensus_orchestrator/src/cende/mod.rs @@ -12,9 +12,7 @@ use async_trait::async_trait; use blockifier::abi::constants::STORED_BLOCK_HASH_BUFFER; use blockifier::blockifier::transaction_executor::CompiledClassHashesForMigration; use blockifier::bouncer::{BouncerWeights, CasmHashComputationData}; -use blockifier::state::cached_state::CommitmentStateDiff; -#[cfg(feature = "os_input")] -use blockifier::state::cached_state::StateMaps; +use blockifier::state::cached_state::{CommitmentStateDiff, StateMaps}; use blockifier::transaction::objects::TransactionExecutionInfo; use central_objects::{ process_transactions, @@ -43,7 +41,6 @@ use starknet_api::block::{BlockHashAndNumber, BlockInfo, BlockNumber, StarknetVe use starknet_api::consensus_transaction::InternalConsensusTransaction; use starknet_api::core::ClassHash; use starknet_api::state::ThinStateDiff; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::types::CompressedStateCommitmentInfos; use tokio::sync::Mutex; use tokio::task::{self, JoinHandle}; @@ -52,12 +49,11 @@ use url::Url; use crate::dynamic_gas_price::FeeProposalInfo; use crate::fee_market::FeeMarketInfo; -#[cfg(feature = "os_input")] -use crate::metrics::CENDE_LAST_STATE_COMMITMENT_INFOS_BLOCK_NUMBER; use crate::metrics::{ record_write_failure, CendeWriteFailureReason, CENDE_LAST_PREPARED_BLOB_BLOCK_NUMBER, + CENDE_LAST_STATE_COMMITMENT_INFOS_BLOCK_NUMBER, CENDE_PREPARE_BLOB_FOR_NEXT_HEIGHT_LATENCY, CENDE_WRITE_BLOB_SUCCESS, CENDE_WRITE_PREV_HEIGHT_BLOB_LATENCY, @@ -80,7 +76,6 @@ pub(crate) const N_BLOCK_HASHES_BACK_IN_BLOB: u64 = STORED_BLOCK_HASH_BUFFER; pub type CendeAmbassadorResult = Result; -#[cfg(feature = "os_input")] #[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] pub struct StateCommitmentInfosAndNumber { pub state_commitment_infos: CompressedStateCommitmentInfos, @@ -109,9 +104,12 @@ pub struct AerospikeBlob { proposal_commitment: ProposalCommitment, parent_proposal_commitment: Option, recent_block_hashes: Vec, - #[cfg(feature = "os_input")] + // Production only serializes blobs, so these defaults affect nothing outside tests: the sole + // deserializer is the blob-regression test, whose pinned fixture predates these fields. + // TODO(Itamar): Remove once the pinned regression blobs are regenerated with witness fields. + #[cfg_attr(any(feature = "testing", test), serde(default))] recent_state_commitment_infos: Vec, - #[cfg(feature = "os_input")] + #[cfg_attr(any(feature = "testing", test), serde(default))] initial_reads: StateMaps, } @@ -133,7 +131,6 @@ pub trait CendeContext: Send + Sync { /// The recorder's commitment infos height offset: the first height whose commitment infos the /// recorder has not stored yet. /// `Ok(None)` when the recorder has stored nothing; `Err` on query failure. - #[cfg(feature = "os_input")] async fn commitment_infos_height_offset(&self) -> CendeAmbassadorResult>; } @@ -145,7 +142,6 @@ pub struct CendeAmbassador { prev_height_blob: Arc>>>, write_blob_url: Url, get_latest_received_block_url: Url, - #[cfg(feature = "os_input")] commitment_infos_height_offset_url: Url, client: ClientWithMiddleware, class_manager: SharedClassManagerClient, @@ -161,7 +157,6 @@ pub const RECORDER_GET_LATEST_RECEIVED_BLOCK_PATH: &str = concatcp!(RECORDER_PREFIX, "/get_latest_received_block"); /// The path to get the recorder's commitment infos height offset (the first height whose commitment /// infos the recorder has not stored yet). Returns null when the recorder has stored nothing. -#[cfg(feature = "os_input")] pub const RECORDER_GET_COMMITMENT_INFOS_HEIGHT_OFFSET_PATH: &str = concatcp!(RECORDER_PREFIX, "/get_witness_height_offset"); @@ -187,7 +182,6 @@ impl CendeAmbassador { .recorder_url .join(RECORDER_GET_LATEST_RECEIVED_BLOCK_PATH) .expect("Failed to construct get latest received block URL"), - #[cfg(feature = "os_input")] commitment_infos_height_offset_url: cende_config .recorder_url .join(RECORDER_GET_COMMITMENT_INFOS_HEIGHT_OFFSET_PATH) @@ -364,8 +358,6 @@ impl CendeContext for CendeAmbassador { CENDE_LAST_PREPARED_BLOB_BLOCK_NUMBER.set_lossy(block_number.0); Ok(()) } - - #[cfg(feature = "os_input")] async fn commitment_infos_height_offset(&self) -> CendeAmbassadorResult> { fetch_block_number( &self.client, @@ -390,7 +382,6 @@ async fn send_write_blob(request_builder: RequestBuilder, blob: &AerospikeBlob) ); print_write_blob_response(response).await; CENDE_WRITE_BLOB_SUCCESS.increment(1); - #[cfg(feature = "os_input")] if let Some(last_state_commitment_infos) = blob.recent_state_commitment_infos.last() { CENDE_LAST_STATE_COMMITMENT_INFOS_BLOCK_NUMBER @@ -452,9 +443,7 @@ pub struct BlobParameters { pub proposal_commitment: ProposalCommitment, pub parent_proposal_commitment: Option, pub recent_block_hashes: Vec, - #[cfg(feature = "os_input")] pub recent_state_commitment_infos: Vec, - #[cfg(feature = "os_input")] pub initial_reads: StateMaps, } @@ -511,9 +500,7 @@ impl AerospikeBlob { proposal_commitment: blob_parameters.proposal_commitment, parent_proposal_commitment: blob_parameters.parent_proposal_commitment, recent_block_hashes: blob_parameters.recent_block_hashes, - #[cfg(feature = "os_input")] recent_state_commitment_infos: blob_parameters.recent_state_commitment_infos, - #[cfg(feature = "os_input")] initial_reads: blob_parameters.initial_reads, }) } diff --git a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs index 028b7e13f31..55981ba6e2f 100644 --- a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -80,12 +80,12 @@ use tracing::{debug, error, error_span, info, instrument, trace, warn, Instrumen use crate::build_proposal::{build_proposal, BuildProposalError, ProposalBuildArguments}; use crate::cende::{ BlobParameters, + CendeAmbassadorResult, CendeContext, InternalTransactionWithReceipt, + StateCommitmentInfosAndNumber, N_BLOCK_HASHES_BACK_IN_BLOB, }; -#[cfg(feature = "os_input")] -use crate::cende::{CendeAmbassadorResult, StateCommitmentInfosAndNumber}; use crate::dynamic_gas_price::{ compute_fee_actual, compute_fee_proposal, @@ -592,8 +592,6 @@ impl SequencerConsensusContext { .prev() .and_then(|parent_height| self.fee_proposals_window.get(&parent_height).copied()) .flatten(); - - #[cfg(feature = "os_input")] let recent_state_commitment_infos = self.collect_recent_state_commitment_infos(height).await.unwrap_or_else(|e| { // `finalize_decision` must not fail, so continue with an empty vector. @@ -631,9 +629,7 @@ impl SequencerConsensusContext { .parent_proposal_commitment .map(|c| proposal_commitment_from(c.partial_block_hash, parent_fee_proposal)), recent_block_hashes: self.collect_recent_block_hashes(height).await, - #[cfg(feature = "os_input")] recent_state_commitment_infos, - #[cfg(feature = "os_input")] initial_reads: central_objects.initial_reads, }) .await @@ -703,7 +699,6 @@ impl SequencerConsensusContext { recent_block_hashes } - #[cfg(feature = "os_input")] async fn collect_recent_state_commitment_infos( &self, height: BlockNumber, diff --git a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs index 2d9f5ac493e..a59cf8e1855 100644 --- a/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs +++ b/crates/apollo_consensus_orchestrator/src/sequencer_consensus_context_test.rs @@ -61,12 +61,14 @@ use starknet_api::execution_resources::GasAmount; use starknet_api::hash::StarkHash; use starknet_api::state::ThinStateDiff; use starknet_api::versioned_constants_logic::VersionedConstantsTrait; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::types::CompressedStateCommitmentInfos; -#[cfg(feature = "os_input")] -use crate::cende::{CendeAmbassadorError, StateCommitmentInfosAndNumber}; -use crate::cende::{MockCendeContext, N_BLOCK_HASHES_BACK_IN_BLOB}; +use crate::cende::{ + CendeAmbassadorError, + MockCendeContext, + StateCommitmentInfosAndNumber, + N_BLOCK_HASHES_BACK_IN_BLOB, +}; use crate::dynamic_gas_price::proposal_commitment_from; use crate::metrics::{CONSENSUS_L2_GAS_PRICE, CONSENSUS_L2_GAS_PRICE_AT_MINIMUM}; use crate::sequencer_consensus_context::{ @@ -916,7 +918,6 @@ async fn blob_parent_proposal_commitment_binds_parent_fee_proposal() { context.decision_reached(HEIGHT_1, ROUND_0, *TEST_PROPOSAL_COMMITMENT, false).await.unwrap(); } -#[cfg(feature = "os_input")] #[tokio::test] async fn decision_reached_attaches_state_commitment_infos_to_blob() { let (mut deps, _network) = create_test_and_network_deps(); @@ -954,8 +955,6 @@ async fn decision_reached_attaches_state_commitment_infos_to_blob() { let _fin = context.build_proposal(BuildParam::default(), TIMEOUT).await.unwrap().await; context.decision_reached(HEIGHT_0, ROUND_0, *TEST_PROPOSAL_COMMITMENT, false).await.unwrap(); } - -#[cfg(feature = "os_input")] fn default_state_commitment_infos() -> CompressedStateCommitmentInfos { CompressedStateCommitmentInfos(b"compressed-state-commitment-infos".to_vec()) } @@ -963,7 +962,6 @@ fn default_state_commitment_infos() -> CompressedStateCommitmentInfos { /// Returns the block numbers `collect_recent_state_commitment_infos` sends for `height` when the /// cende recorder reports `offset` and the batcher only has stored commitment infos for heights /// in `committed_heights` (reporting `None` for the rest). -#[cfg(feature = "os_input")] async fn collected_heights_for( height: BlockNumber, cende_offset: Option, @@ -991,7 +989,6 @@ async fn collected_heights_for( // `height` is fixed at 100; each case sets the cende recorder's reported offset (its next // produced block), the heights the batcher has stored commitment infos for (a `None` from the // batcher marks a gap in the stored witnesses), and the block numbers we expect to send. -#[cfg(feature = "os_input")] #[rstest] #[case::delta_above_cende_recorder(Some(BlockNumber(98)), (90..=100).collect(), vec![98, 99, 100])] #[case::single_new_block(Some(BlockNumber(100)), (90..=100).collect(), vec![100])] @@ -1012,8 +1009,6 @@ async fn collect_recent_state_commitment_infos_sends_expected_delta( let heights = collected_heights_for(height, cende_offset, committed_heights).await; assert_eq!(heights, expected); } - -#[cfg(feature = "os_input")] #[tokio::test] async fn collect_recent_state_commitment_infos_errors_on_offset_query_failure() { // A failed offset query must propagate, not silently fall back to genesis. diff --git a/crates/apollo_consensus_orchestrator/src/test_utils.rs b/crates/apollo_consensus_orchestrator/src/test_utils.rs index 7937ccc0893..dbbba3fc539 100644 --- a/crates/apollo_consensus_orchestrator/src/test_utils.rs +++ b/crates/apollo_consensus_orchestrator/src/test_utils.rs @@ -320,7 +320,6 @@ impl TestDeps { .return_once(|_height| tokio::spawn(ready(true))); // Default: cende recorder reports nothing stored → send from genesis. Delta tests // override this. - #[cfg(feature = "os_input")] self.cende_ambassador.expect_commitment_infos_height_offset().returning(|| Ok(None)); } @@ -343,7 +342,6 @@ impl TestDeps { self.batcher.expect_get_block_hash().returning(|block_number| { Err(BatcherClientError::BatcherError(BatcherError::BlockHashNotFound(block_number))) }); - #[cfg(feature = "os_input")] self.batcher.expect_get_state_commitment_infos().returning(|_block_number| Ok(None)); } diff --git a/crates/apollo_consensus_orchestrator/src/utils.rs b/crates/apollo_consensus_orchestrator/src/utils.rs index 8ae8dced805..354ad7ea7d6 100644 --- a/crates/apollo_consensus_orchestrator/src/utils.rs +++ b/crates/apollo_consensus_orchestrator/src/utils.rs @@ -35,7 +35,6 @@ use starknet_api::hash::StarkHash; use starknet_api::StarknetApiError; use tracing::{info, warn}; -#[cfg(feature = "os_input")] use crate::cende::{CendeAmbassadorError, CendeContext}; use crate::metrics::{ CONSENSUS_L1_GAS_PRICE_PROVIDER_ERROR, @@ -71,7 +70,6 @@ pub(crate) enum RetrospectiveBlockHashError { pub(crate) type RetrospectiveBlockHashResult = Result; -#[cfg(feature = "os_input")] #[derive(Debug, thiserror::Error)] pub(crate) enum RetrospectiveStateCommitmentInfosError { #[error(transparent)] @@ -89,7 +87,6 @@ pub(crate) enum RetrospectiveStateCommitmentInfosError { }, } -#[cfg(feature = "os_input")] pub(crate) type RetrospectiveStateCommitmentInfosResult = Result; @@ -490,7 +487,6 @@ pub(crate) async fn wait_for_retrospective_block_hash( /// Verifies that the batcher or the cende recorder has stored the state commitment infos of the /// next height's retrospective block. Skipped when the batcher doesn't have them and the recorder /// has stored none at all, for pre-feature activation. -#[cfg(feature = "os_input")] pub(crate) async fn verify_retrospective_state_commitment_infos( batcher_client: &dyn BatcherClient, cende_ambassador: &dyn CendeContext, diff --git a/crates/apollo_consensus_orchestrator/src/utils_test.rs b/crates/apollo_consensus_orchestrator/src/utils_test.rs index 3c892378fcd..9807bf63ca8 100644 --- a/crates/apollo_consensus_orchestrator/src/utils_test.rs +++ b/crates/apollo_consensus_orchestrator/src/utils_test.rs @@ -1,46 +1,35 @@ -use apollo_batcher_types::communication::BatcherClientError; -#[cfg(feature = "os_input")] -use apollo_batcher_types::communication::MockBatcherClient; +use apollo_batcher_types::communication::{BatcherClientError, MockBatcherClient}; use apollo_batcher_types::errors::BatcherError; use apollo_protobuf::consensus::ProposalInit; use apollo_state_sync_types::communication::StateSyncClientError; use apollo_state_sync_types::errors::StateSyncError; use assert_matches::assert_matches; use blockifier::abi::constants::STORED_BLOCK_HASH_BUFFER; -#[cfg(feature = "os_input")] use rstest::rstest; use starknet_api::block::{BlockHash, BlockHashAndNumber, BlockNumber}; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::types::CompressedStateCommitmentInfos; use starknet_types_core::felt::Felt; use crate::build_proposal::ProposalBuildArguments; -#[cfg(feature = "os_input")] use crate::cende::MockCendeContext; use crate::test_utils::create_proposal_build_arguments; use crate::utils::{ get_l1_prices_in_fri_and_wei, retrospective_block_hash, + verify_retrospective_state_commitment_infos, wait_for_retrospective_block_hash, RetrospectiveBlockHashError, -}; -#[cfg(feature = "os_input")] -use crate::utils::{ - verify_retrospective_state_commitment_infos, RetrospectiveStateCommitmentInfosError, }; const CURRENT_BLOCK_NUMBER: BlockNumber = BlockNumber(STORED_BLOCK_HASH_BUFFER); const RETRO_BLOCK_NUMBER: BlockNumber = BlockNumber(0); -#[cfg(feature = "os_input")] const NEXT_HEIGHT_RETRO_BLOCK_NUMBER: BlockNumber = BlockNumber(CURRENT_BLOCK_NUMBER.0 + 1 - STORED_BLOCK_HASH_BUFFER); // A recorder offset above the next height's retrospective block number means its commitment infos // are stored; an offset equal to it means they are missing. -#[cfg(feature = "os_input")] const STORED_HEIGHT_OFFSET: Option = Some(BlockNumber(NEXT_HEIGHT_RETRO_BLOCK_NUMBER.0 + 1)); -#[cfg(feature = "os_input")] const BEHIND_HEIGHT_OFFSET: Option = Some(NEXT_HEIGHT_RETRO_BLOCK_NUMBER); const MUST_HAVE_BLOCK_HASH_FOR: BlockNumber = BlockNumber(1); const RETRO_BLOCK_HASH: BlockHash = BlockHash(Felt::from_hex_unchecked("0x1234567890abcdef")); @@ -355,7 +344,6 @@ async fn wait_for_retrospective_block_hash_batcher_ready_after_a_while() { ); } -#[cfg(feature = "os_input")] fn mock_batcher_commitment_infos(batcher_has_infos: bool) -> MockBatcherClient { let mut batcher = MockBatcherClient::new(); batcher.expect_get_state_commitment_infos().times(1).returning(move |block_number| { @@ -366,7 +354,6 @@ fn mock_batcher_commitment_infos(batcher_has_infos: bool) -> MockBatcherClient { batcher } -#[cfg(feature = "os_input")] fn mock_cende_recorder_height_offset(height_offset: Option) -> MockCendeContext { let mut cende_ambassador = MockCendeContext::new(); cende_ambassador @@ -376,7 +363,6 @@ fn mock_cende_recorder_height_offset(height_offset: Option) -> Mock cende_ambassador } -#[cfg(feature = "os_input")] #[rstest] #[case::stored_on_batcher(true, None, true)] #[case::stored_only_on_cende(false, STORED_HEIGHT_OFFSET, true)] @@ -408,7 +394,6 @@ async fn retrospective_state_commitment_infos( } } -#[cfg(feature = "os_input")] #[tokio::test] async fn retrospective_state_commitment_infos_next_height_below_buffer() { // No queries are expected: heights whose next height is below the buffer have no diff --git a/crates/apollo_dashboard/Cargo.toml b/crates/apollo_dashboard/Cargo.toml index 04efe02ba0f..5555fd53646 100644 --- a/crates/apollo_dashboard/Cargo.toml +++ b/crates/apollo_dashboard/Cargo.toml @@ -8,7 +8,6 @@ description = "Dashboard and monitoring interface for the Starknet sequencer." [features] -os_input = ["apollo_batcher/os_input", "apollo_committer/os_input"] testing = [] [lints] diff --git a/crates/apollo_dashboard/resources/dev_grafana.json b/crates/apollo_dashboard/resources/dev_grafana.json index 00379ea91d6..5a5fd13cc9c 100644 --- a/crates/apollo_dashboard/resources/dev_grafana.json +++ b/crates/apollo_dashboard/resources/dev_grafana.json @@ -2593,6 +2593,32 @@ ], "extra_params": {} }, + { + "title": "get_state_commitment_infos (client-side)", + "description": "client-side infra metrics for request type get_state_commitment_infos", + "type": "timeseries", + "exprs": [ + "histogram_quantile(0.50,label_replace(sum by (le) (rate(batcher_local_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.50 batcher_local_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(batcher_local_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.95 batcher_local_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.50,label_replace(sum by (le) (rate(batcher_remote_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.50 batcher_remote_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(batcher_remote_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.95 batcher_remote_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.50,label_replace(sum by (le) (rate(batcher_remote_client_communication_failure_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.50 batcher_remote_client_communication_failure_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(batcher_remote_client_communication_failure_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.95 batcher_remote_client_communication_failure_times_secs\", \"le\", \".*\"))" + ], + "extra_params": {} + }, + { + "title": "get_state_commitment_infos (server-side)", + "description": "server-side infra metrics for request type get_state_commitment_infos", + "type": "timeseries", + "exprs": [ + "histogram_quantile(0.50,label_replace(sum by (le) (rate(batcher_processing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.50 batcher_processing_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(batcher_processing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.95 batcher_processing_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.50,label_replace(sum by (le) (rate(batcher_queueing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.50 batcher_queueing_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(batcher_queueing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"get_state_commitment_infos\"}[5m])), \"label_name\", \"0.95 batcher_queueing_times_secs\", \"le\", \".*\"))" + ], + "extra_params": {} + }, { "title": "propose_block (client-side)", "description": "client-side infra metrics for request type propose_block", @@ -3015,6 +3041,32 @@ ], "extra_params": {} }, + { + "title": "read_paths_and_commit_block (client-side)", + "description": "client-side infra metrics for request type read_paths_and_commit_block", + "type": "timeseries", + "exprs": [ + "histogram_quantile(0.50,label_replace(sum by (le) (rate(committer_local_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.50 committer_local_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(committer_local_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.95 committer_local_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.50,label_replace(sum by (le) (rate(committer_remote_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.50 committer_remote_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(committer_remote_response_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.95 committer_remote_response_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.50,label_replace(sum by (le) (rate(committer_remote_client_communication_failure_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.50 committer_remote_client_communication_failure_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(committer_remote_client_communication_failure_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.95 committer_remote_client_communication_failure_times_secs\", \"le\", \".*\"))" + ], + "extra_params": {} + }, + { + "title": "read_paths_and_commit_block (server-side)", + "description": "server-side infra metrics for request type read_paths_and_commit_block", + "type": "timeseries", + "exprs": [ + "histogram_quantile(0.50,label_replace(sum by (le) (rate(committer_processing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.50 committer_processing_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(committer_processing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.95 committer_processing_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.50,label_replace(sum by (le) (rate(committer_queueing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.50 committer_queueing_times_secs\", \"le\", \".*\"))", + "histogram_quantile(0.95,label_replace(sum by (le) (rate(committer_queueing_times_secs_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\", pod=~\"$pod\", request_variant=\"read_paths_and_commit_block\"}[5m])), \"label_name\", \"0.95 committer_queueing_times_secs\", \"le\", \".*\"))" + ], + "extra_params": {} + }, { "title": "revert_block (client-side)", "description": "client-side infra metrics for request type revert_block", diff --git a/crates/apollo_integration_tests/Cargo.toml b/crates/apollo_integration_tests/Cargo.toml index 6edde633607..b977d947ab3 100644 --- a/crates/apollo_integration_tests/Cargo.toml +++ b/crates/apollo_integration_tests/Cargo.toml @@ -8,12 +8,6 @@ description = "End-to-end integration tests for the Starknet sequencer." [features] cairo_native = ["apollo_node/cairo_native"] -os_input = [ - "apollo_batcher/os_input", - "apollo_committer/os_input", - "blockifier/os_input", - "starknet_committer/os_input", -] [lints] workspace = true diff --git a/crates/apollo_integration_tests/src/utils.rs b/crates/apollo_integration_tests/src/utils.rs index 2e597bceb93..e28b8d93037 100644 --- a/crates/apollo_integration_tests/src/utils.rs +++ b/crates/apollo_integration_tests/src/utils.rs @@ -35,6 +35,7 @@ use apollo_consensus_config::config::{ use apollo_consensus_config::ValidatorId; use apollo_consensus_manager_config::config::ConsensusManagerConfig; use apollo_consensus_orchestrator::cende::{ + RECORDER_GET_COMMITMENT_INFOS_HEIGHT_OFFSET_PATH, RECORDER_GET_LATEST_RECEIVED_BLOCK_PATH, RECORDER_WRITE_BLOB_PATH, }; @@ -611,6 +612,20 @@ pub fn spawn_success_recorder(socket_address: SocketAddr) -> JoinHandle<()> { } .instrument(tracing::debug_span!("success recorder get_latest_received_block")) }), + ) + .route( + RECORDER_GET_COMMITMENT_INFOS_HEIGHT_OFFSET_PATH, + get(|| { + async { + debug!("Received a request for commitment_infos_height_offset."); + // `null` marks an empty recorder, letting proposals pass the + // retrospective commitment-infos check before any blob is stored. + Json(serde_json::json!({ "block_number": null })) + } + .instrument(tracing::debug_span!( + "success recorder commitment_infos_height_offset" + )) + }), ); let listener = TcpListener::bind(socket_address).await.unwrap(); serve(listener, router).await.unwrap(); diff --git a/crates/apollo_node/Cargo.toml b/crates/apollo_node/Cargo.toml index b2e4e59e9e9..deb3aea2d78 100644 --- a/crates/apollo_node/Cargo.toml +++ b/crates/apollo_node/Cargo.toml @@ -8,12 +8,6 @@ description = "Main Starknet sequencer node orchestrating all components." [features] cairo_native = ["apollo_batcher/cairo_native", "apollo_gateway/cairo_native"] -os_input = [ - "apollo_batcher/os_input", - "apollo_committer/os_input", - "apollo_committer_types/os_input", - "apollo_consensus_manager/os_input", -] testing = ["tokio-util"] [lints] diff --git a/crates/apollo_reverts/Cargo.toml b/crates/apollo_reverts/Cargo.toml index 97a17037932..60ac474b406 100644 --- a/crates/apollo_reverts/Cargo.toml +++ b/crates/apollo_reverts/Cargo.toml @@ -6,9 +6,6 @@ license.workspace = true repository.workspace = true description = "Handles blockchain revert detection and management." -[features] -os_input = ["apollo_storage/os_input"] - [lints] workspace = true diff --git a/crates/apollo_reverts/src/lib.rs b/crates/apollo_reverts/src/lib.rs index c9935fc2474..8577ca7af8e 100644 --- a/crates/apollo_reverts/src/lib.rs +++ b/crates/apollo_reverts/src/lib.rs @@ -4,7 +4,6 @@ use std::future::Future; use apollo_config::dumping::{ser_param, SerializeConfig}; use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use apollo_metrics::metrics::MetricGauge; -#[cfg(feature = "os_input")] use apollo_storage::accessed_keys::AccessedKeysStorageWriter; use apollo_storage::base_layer::BaseLayerStorageWriter; use apollo_storage::block_hash::BlockHashStorageWriter; @@ -14,7 +13,6 @@ use apollo_storage::global_root::GlobalRootStorageWriter; use apollo_storage::header::HeaderStorageWriter; use apollo_storage::partial_block_hash::PartialBlockHashComponentsStorageWriter; use apollo_storage::state::StateStorageWriter; -#[cfg(feature = "os_input")] use apollo_storage::state_commitment_infos::StateCommitmentInfosStorageWriter; use apollo_storage::StorageWriter; use futures::future::pending; @@ -148,7 +146,6 @@ pub fn revert_block(storage_writer: &mut StorageWriter, target_block_marker: Blo .revert_global_root(&target_block_marker) .unwrap(); - #[cfg(feature = "os_input")] let txn = txn .revert_accessed_keys(target_block_marker) .unwrap() diff --git a/crates/apollo_storage/Cargo.toml b/crates/apollo_storage/Cargo.toml index 40452ef1a1a..f21d2d7e9d4 100644 --- a/crates/apollo_storage/Cargo.toml +++ b/crates/apollo_storage/Cargo.toml @@ -7,7 +7,6 @@ license-file.workspace = true description = "A storage implementation for a Starknet node." [features] -os_input = ["dep:blockifier", "dep:starknet_committer", "starknet_committer/os_input"] storage_cli = ["clap", "reqwest"] storage_validation = ["clap"] testing = ["reqwest", "starknet_api/testing", "tempfile", "tower"] @@ -19,7 +18,7 @@ apollo_proc_macros.workspace = true async-trait.workspace = true axum.workspace = true bincode.workspace = true -blockifier = { workspace = true, features = ["transaction_serde"], optional = true } +blockifier = { workspace = true, features = ["transaction_serde"] } byteorder.workspace = true cairo-lang-casm = { workspace = true, features = ["parity-scale-codec"] } cairo-lang-starknet-classes.workspace = true @@ -42,7 +41,7 @@ serde = { workspace = true, features = ["derive"] } serde_json = { workspace = true, features = ["arbitrary_precision"] } starknet-types-core = { workspace = true, features = ["papyrus-serialization"] } starknet_api.workspace = true -starknet_committer = { workspace = true, optional = true } +starknet_committer.workspace = true tempfile = { workspace = true, optional = true } thiserror.workspace = true tokio = { workspace = true, features = ["rt-multi-thread"] } diff --git a/crates/apollo_storage/src/db/mod.rs b/crates/apollo_storage/src/db/mod.rs index 2fb62dbbf23..4ad236e9720 100644 --- a/crates/apollo_storage/src/db/mod.rs +++ b/crates/apollo_storage/src/db/mod.rs @@ -43,9 +43,6 @@ use self::table_types::{DbCursor, DbCursorTrait}; use crate::db::table_types::TableType; // Maximum number of Sub-Databases. -#[cfg(not(feature = "os_input"))] -const MAX_DBS: u64 = 25; -#[cfg(feature = "os_input")] const MAX_DBS: u64 = 27; // Note that NO_TLS mode is used by default. diff --git a/crates/apollo_storage/src/lib.rs b/crates/apollo_storage/src/lib.rs index bdb850f9717..cbda807f528 100644 --- a/crates/apollo_storage/src/lib.rs +++ b/crates/apollo_storage/src/lib.rs @@ -76,7 +76,6 @@ //! [`Starknet`]: https://starknet.io/ //! [`libmdbx`]: https://docs.rs/libmdbx/latest/libmdbx/ -#[cfg(feature = "os_input")] pub mod accessed_keys; pub mod base_layer; pub mod block_hash; @@ -91,7 +90,6 @@ pub mod global_root_marker; #[allow(missing_docs)] pub mod metrics; pub mod partial_block_hash; -#[cfg(feature = "os_input")] pub mod state_commitment_infos; pub mod storage_metrics; // TODO(yair): Make the compression_utils module pub(crate) or extract it from the crate. @@ -165,7 +163,6 @@ use tracing::{debug, info, warn}; use validator::Validate; use version::{StorageVersionError, Version}; -#[cfg(feature = "os_input")] use crate::accessed_keys::AccessedKeys; use crate::body::TransactionIndex; use crate::consensus::LastVotedMarker; @@ -188,7 +185,6 @@ use crate::header::StorageBlockHeader; use crate::metrics::{register_metrics, STORAGE_COMMIT_LATENCY}; use crate::mmap_file::MMapFileStats; use crate::state::data::IndexedDeprecatedContractClass; -#[cfg(feature = "os_input")] use crate::state_commitment_infos::CompressedStateCommitmentInfos; use crate::storage_reader_server::{ create_storage_reader_server, @@ -282,9 +278,7 @@ fn open_storage_internal( compiled_class_hash: db_writer.create_common_prefix_table("compiled_class_hash")?, stateless_compiled_class_hash_v2: db_writer .create_simple_table("stateless_compiled_class_hash_v2")?, - #[cfg(feature = "os_input")] accessed_keys: db_writer.create_simple_table("accessed_keys")?, - #[cfg(feature = "os_input")] state_commitment_infos: db_writer.create_simple_table("state_commitment_infos")?, }); let (file_writers, file_readers) = open_storage_files( @@ -998,9 +992,7 @@ struct_field_names! { compiled_class_hash: TableIdentifier<(ClassHash, BlockNumber), VersionZeroWrapper, CommonPrefix>, stateless_compiled_class_hash_v2: TableIdentifier, SimpleTable>, - #[cfg(feature = "os_input")] accessed_keys: TableIdentifier, SimpleTable>, - #[cfg(feature = "os_input")] state_commitment_infos: TableIdentifier, SimpleTable> } } @@ -1170,9 +1162,7 @@ struct FileHandlers { deprecated_contract_class: FileHandler, Mode>, transaction_output: FileHandler, Mode>, transaction: FileHandler, Mode>, - #[cfg(feature = "os_input")] accessed_keys: FileHandler, Mode>, - #[cfg(feature = "os_input")] state_commitment_infos: FileHandler, Mode>, } @@ -1211,12 +1201,10 @@ impl FileHandlers { self.clone().transaction.append(transaction) } - #[cfg(feature = "os_input")] fn append_accessed_keys(&self, accessed_keys: &AccessedKeys) -> LocationInFile { self.clone().accessed_keys.append(accessed_keys) } - #[cfg(feature = "os_input")] fn append_state_commitment_infos( &self, state_commitment_infos: &CompressedStateCommitmentInfos, @@ -1234,9 +1222,7 @@ impl FileHandlers { self.deprecated_contract_class.flush(); self.transaction_output.flush(); self.transaction.flush(); - #[cfg(feature = "os_input")] self.accessed_keys.flush(); - #[cfg(feature = "os_input")] self.state_commitment_infos.flush(); } } @@ -1251,9 +1237,7 @@ impl FileHandlers { ("deprecated_contract_class".to_string(), self.deprecated_contract_class.stats()), ("transaction_output".to_string(), self.transaction_output.stats()), ("transaction".to_string(), self.transaction.stats()), - #[cfg(feature = "os_input")] ("accessed_keys".to_string(), self.accessed_keys.stats()), - #[cfg(feature = "os_input")] ("state_commitment_infos".to_string(), self.state_commitment_infos.stats()), ]) } @@ -1314,7 +1298,6 @@ impl FileHandlers { }) } - #[cfg(feature = "os_input")] // Returns the accessed-key set at the given location or an error in case it doesn't exist. pub(crate) fn get_accessed_keys_unchecked( &self, @@ -1325,7 +1308,6 @@ impl FileHandlers { }) } - #[cfg(feature = "os_input")] // Returns the compressed commitment infos at the given location or an error in case they don't // exist. pub(crate) fn get_state_commitment_infos_unchecked( @@ -1371,10 +1353,8 @@ fn open_storage_files( let (transaction_output_writer, transaction_output_reader) = open_storage_file!("transaction_output", TransactionOutput)?; let (transaction_writer, transaction_reader) = open_storage_file!("transaction", Transaction)?; - #[cfg(feature = "os_input")] let (accessed_keys_writer, accessed_keys_reader) = open_storage_file!("accessed_keys", AccessedKeys)?; - #[cfg(feature = "os_input")] let (state_commitment_infos_writer, state_commitment_infos_reader) = open_storage_file!("state_commitment_infos", StateCommitmentInfos)?; @@ -1386,9 +1366,7 @@ fn open_storage_files( deprecated_contract_class: deprecated_contract_class_writer, transaction_output: transaction_output_writer, transaction: transaction_writer, - #[cfg(feature = "os_input")] accessed_keys: accessed_keys_writer, - #[cfg(feature = "os_input")] state_commitment_infos: state_commitment_infos_writer, }, FileHandlers { @@ -1398,9 +1376,7 @@ fn open_storage_files( deprecated_contract_class: deprecated_contract_class_reader, transaction_output: transaction_output_reader, transaction: transaction_reader, - #[cfg(feature = "os_input")] accessed_keys: accessed_keys_reader, - #[cfg(feature = "os_input")] state_commitment_infos: state_commitment_infos_reader, }, )) @@ -1422,9 +1398,7 @@ pub enum OffsetKind { /// A transaction file. Transaction, /// An accessed-keys file. - #[cfg(feature = "os_input")] AccessedKeys, /// A state-commitment-infos file. - #[cfg(feature = "os_input")] StateCommitmentInfos, } diff --git a/crates/apollo_storage/src/serialization/serializers.rs b/crates/apollo_storage/src/serialization/serializers.rs index f7b73a728b5..08f30e5ca9a 100644 --- a/crates/apollo_storage/src/serialization/serializers.rs +++ b/crates/apollo_storage/src/serialization/serializers.rs @@ -370,9 +370,7 @@ auto_storage_serde! { DeprecatedContractClass = 3, TransactionOutput = 4, Transaction = 5, - #[cfg(feature = "os_input")] AccessedKeys = 6, - #[cfg(feature = "os_input")] StateCommitmentInfos = 7, } pub struct PartialBlockHashComponents { diff --git a/crates/blockifier/Cargo.toml b/crates/blockifier/Cargo.toml index 61f79dbf1c5..77a7cea5d57 100644 --- a/crates/blockifier/Cargo.toml +++ b/crates/blockifier/Cargo.toml @@ -21,7 +21,6 @@ mocks = [] native_blockifier = [] node_api = [] only-native = ["cairo_native"] -os_input = [] reexecution = ["transaction_serde"] testing = [ "blockifier_test_utils", diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index 634bab5edf3..9cc94fc2302 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -55,8 +55,8 @@ pub type CompiledClassHashesForMigration = Vec; #[derive(Clone, Copy, Debug)] pub enum OsInitialReadsCollection { Collect, - /// Skips collection, leaving `BlockExecutionSummary::initial_reads` empty. Required when the - /// state reader serves a read-set pre os_input feature. + /// Skips collection, leaving `BlockExecutionSummary::initial_reads` empty. Required when + /// reexecuting blocks. #[cfg(feature = "reexecution")] Skip, } @@ -66,7 +66,6 @@ pub enum OsInitialReadsCollection { pub struct BlockExecutionSummary { pub state_diff: CommitmentStateDiff, pub compressed_state_diff: Option, - #[cfg(feature = "os_input")] pub initial_reads: StateMaps, pub bouncer_weights: BouncerWeights, pub casm_hash_computation_data_sierra_gas: CasmHashComputationData, @@ -292,14 +291,11 @@ pub(crate) fn finalize_block( let state_diff = block_state.to_state_diff()?.state_maps; - #[cfg(feature = "os_input")] let initial_reads = match os_initial_reads_collection { OsInitialReadsCollection::Collect => block_state.get_os_initial_reads()?, #[cfg(feature = "reexecution")] OsInitialReadsCollection::Skip => StateMaps::default(), }; - #[cfg(not(feature = "os_input"))] - let _ = os_initial_reads_collection; let compressed_state_diff = if block_context.versioned_constants.enable_stateful_compression { Some(compress(&state_diff, block_state, alias_contract_address)?.into()) @@ -328,7 +324,6 @@ pub(crate) fn finalize_block( Ok(BlockExecutionSummary { state_diff: state_diff.into(), compressed_state_diff, - #[cfg(feature = "os_input")] initial_reads, bouncer_weights: *bouncer.get_bouncer_weights(), casm_hash_computation_data_sierra_gas, diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index d3fde53a8ad..88ce7d9cea4 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -289,7 +289,6 @@ impl Default for CachedState CachedState { pub fn get_initial_reads(&self) -> StateResult { Ok(self.cache.borrow().initial_reads.clone()) diff --git a/crates/central_systest_blobs/Cargo.toml b/crates/central_systest_blobs/Cargo.toml index 17d381536a0..2926d000b56 100644 --- a/crates/central_systest_blobs/Cargo.toml +++ b/crates/central_systest_blobs/Cargo.toml @@ -6,9 +6,6 @@ repository.workspace = true license-file.workspace = true description = "Keeps blob JSONs for centralized system test, and tests for regression" -[features] -os_input = ["apollo_consensus_orchestrator/os_input"] - [dev-dependencies] apollo_batcher = { workspace = true, features = ["testing"] } apollo_batcher_types.workspace = true diff --git a/crates/central_systest_blobs/src/cende_blob_regression_test.rs b/crates/central_systest_blobs/src/cende_blob_regression_test.rs index bed510bb4ab..2c4d4ec2e89 100644 --- a/crates/central_systest_blobs/src/cende_blob_regression_test.rs +++ b/crates/central_systest_blobs/src/cende_blob_regression_test.rs @@ -245,9 +245,7 @@ impl From for BlobParameters { proposal_commitment, parent_proposal_commitment, recent_block_hashes, - #[cfg(feature = "os_input")] recent_state_commitment_infos: vec![], - #[cfg(feature = "os_input")] initial_reads: Default::default(), } } diff --git a/crates/starknet_committer/Cargo.toml b/crates/starknet_committer/Cargo.toml index 5f5d81c208a..e419703167a 100644 --- a/crates/starknet_committer/Cargo.toml +++ b/crates/starknet_committer/Cargo.toml @@ -7,18 +7,17 @@ license.workspace = true description = "Computes and manages Starknet state." [features] -os_input = ["dep:bincode", "dep:blake2", "dep:digest", "dep:zstd"] testing = ["starknet_patricia/testing"] [dependencies] apollo_config.workspace = true async-trait.workspace = true base64.workspace = true -bincode = { workspace = true, optional = true } -blake2 = { workspace = true, optional = true } +bincode.workspace = true +blake2.workspace = true blockifier.workspace = true derive_more = { workspace = true, features = ["as_ref", "from", "into"] } -digest = { workspace = true, optional = true } +digest.workspace = true ethnum.workspace = true pretty_assertions.workspace = true rand.workspace = true @@ -34,7 +33,7 @@ strum.workspace = true thiserror.workspace = true tokio = { workspace = true, features = ["macros", "rt"] } tracing.workspace = true -zstd = { workspace = true, optional = true } +zstd.workspace = true [dev-dependencies] async-recursion.workspace = true diff --git a/crates/starknet_committer/src/block_committer/commit.rs b/crates/starknet_committer/src/block_committer/commit.rs index 24930510df7..413a68ba0f1 100644 --- a/crates/starknet_committer/src/block_committer/commit.rs +++ b/crates/starknet_committer/src/block_committer/commit.rs @@ -1,20 +1,14 @@ use std::collections::HashMap; -#[cfg(feature = "os_input")] use std::time::Instant; -#[cfg(feature = "os_input")] -use starknet_api::core::GlobalRoot; -use starknet_api::core::{ClassHash, ContractAddress, Nonce}; -#[cfg(feature = "os_input")] +use starknet_api::core::{ClassHash, ContractAddress, GlobalRoot, Nonce}; use starknet_api::hash::HashOutput; use starknet_patricia::patricia_merkle_tree::node_data::leaf::LeafModifications; use starknet_patricia::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices}; use starknet_types_core::felt::Felt; use tracing::{debug, warn}; -use crate::block_committer::errors::BlockCommitmentError; -#[cfg(feature = "os_input")] -use crate::block_committer::errors::CommitBlockWithWitnessesError; +use crate::block_committer::errors::{BlockCommitmentError, CommitBlockWithWitnessesError}; use crate::block_committer::input::{ contract_address_into_node_index, skeleton_storage_updates, @@ -28,11 +22,8 @@ use crate::block_committer::measurements_util::{ BlockModificationsCounts, MeasurementsTrait, }; -#[cfg(feature = "os_input")] use crate::db::forest_trait::forest_trait_witnesses::ForestStorageWithWitnesses; -use crate::db::forest_trait::ForestReader; -#[cfg(feature = "os_input")] -use crate::db::forest_trait::ForestWriter; +use crate::db::forest_trait::{ForestReader, ForestWriter}; use crate::forest::deleted_nodes::{find_deleted_nodes, DeletedNodes}; use crate::forest::filled_forest::FilledForest; use crate::forest::forest_errors::ForestError; @@ -40,11 +31,12 @@ use crate::forest::original_skeleton_forest::{ForestSortedIndices, OriginalSkele use crate::forest::updated_skeleton_forest::UpdatedSkeletonForest; use crate::hash_function::hash::TreeHashFunctionImpl; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -#[cfg(feature = "os_input")] use crate::patricia_merkle_tree::tree::SortedLeavesRequest; -#[cfg(feature = "os_input")] -use crate::patricia_merkle_tree::types::StateCommitmentInfos; -use crate::patricia_merkle_tree::types::{class_hash_into_node_index, CompiledClassHash}; +use crate::patricia_merkle_tree::types::{ + class_hash_into_node_index, + CompiledClassHash, + StateCommitmentInfos, +}; pub type BlockCommitmentResult = Result; @@ -77,11 +69,9 @@ pub async fn commit_block = Result; /// Output of [`commit_block_with_witnesses`]. -#[cfg(feature = "os_input")] pub struct CommitBlockWithWitnessesOutput { pub filled_forest: FilledForest, pub deleted_nodes: DeletedNodes, @@ -100,7 +90,6 @@ pub struct CommitBlockWithWitnessesOutput { /// Does not persist the updated forest — the caller is responsible for writing /// `filled_forest`/`deleted_nodes` (together with any metadata bundle and the returned /// `patricia_proofs`) atomically. -#[cfg(feature = "os_input")] pub async fn commit_block_with_witnesses( input: Input, sorted_leaves: &SortedLeavesRequest<'_>, diff --git a/crates/starknet_committer/src/block_committer/errors.rs b/crates/starknet_committer/src/block_committer/errors.rs index ce47c465a3d..6bd92131844 100644 --- a/crates/starknet_committer/src/block_committer/errors.rs +++ b/crates/starknet_committer/src/block_committer/errors.rs @@ -1,5 +1,4 @@ use starknet_patricia::patricia_merkle_tree::traversal::TraversalError; -#[cfg(feature = "os_input")] use starknet_patricia_storage::errors::SerializationError; use thiserror::Error; @@ -13,7 +12,6 @@ pub enum BlockCommitmentError { Traversal(#[from] TraversalError), } -#[cfg(feature = "os_input")] #[derive(Debug, Error)] pub enum CommitBlockWithWitnessesError { #[error(transparent)] diff --git a/crates/starknet_committer/src/block_committer/measurements_util.rs b/crates/starknet_committer/src/block_committer/measurements_util.rs index c46d7c850cf..db7a5fa36bb 100644 --- a/crates/starknet_committer/src/block_committer/measurements_util.rs +++ b/crates/starknet_committer/src/block_committer/measurements_util.rs @@ -11,9 +11,7 @@ pub enum Action { Read, Compute, Write, - #[cfg(feature = "os_input")] FetchWitnessesFirstPass, - #[cfg(feature = "os_input")] FetchWitnessesSecondPass, } @@ -23,9 +21,7 @@ pub struct BlockTimers { pub read_timer: Option, pub compute_timer: Option, pub writer_timer: Option, - #[cfg(feature = "os_input")] pub fetch_witnesses_first_pass_timer: Option, - #[cfg(feature = "os_input")] pub fetch_witnesses_second_pass_timer: Option, } @@ -36,9 +32,7 @@ impl BlockTimers { Action::Read => &mut self.read_timer, Action::Compute => &mut self.compute_timer, Action::Write => &mut self.writer_timer, - #[cfg(feature = "os_input")] Action::FetchWitnessesFirstPass => &mut self.fetch_witnesses_first_pass_timer, - #[cfg(feature = "os_input")] Action::FetchWitnessesSecondPass => &mut self.fetch_witnesses_second_pass_timer, } } @@ -120,10 +114,8 @@ pub struct BlockDurations { pub read: f64, // Duration of a read phase (seconds). pub compute: f64, // Duration of a computation phase (seconds). pub write: f64, // Duration of a write phase (seconds). - #[cfg(feature = "os_input")] // Duration of fetching witnesses w.r.t the old root (seconds). pub fetch_witnesses_first_pass: f64, - #[cfg(feature = "os_input")] // Duration of fetching witnesses w.r.t the new root (seconds). pub fetch_witnesses_second_pass: f64, } @@ -148,7 +140,6 @@ pub struct BlockMeasurement { pub n_reads: usize, pub durations: BlockDurations, pub modifications_counts: BlockModificationsCounts, - #[cfg(feature = "os_input")] // Number of witnesses fetched in the first pass (pre-commit). pub fetched_witnesses_count: usize, } @@ -175,12 +166,10 @@ impl BlockMeasurement { Action::EndToEnd => { self.durations.block = duration_in_seconds; } - #[cfg(feature = "os_input")] Action::FetchWitnessesFirstPass => { self.durations.fetch_witnesses_first_pass = duration_in_seconds; self.fetched_witnesses_count += entries_count; } - #[cfg(feature = "os_input")] Action::FetchWitnessesSecondPass => { self.durations.fetch_witnesses_second_pass = duration_in_seconds; } diff --git a/crates/starknet_committer/src/db/forest_trait.rs b/crates/starknet_committer/src/db/forest_trait.rs index 61ad9505649..70722c5b5c3 100644 --- a/crates/starknet_committer/src/db/forest_trait.rs +++ b/crates/starknet_committer/src/db/forest_trait.rs @@ -30,7 +30,6 @@ use crate::forest::original_skeleton_forest::{ForestSortedIndices, OriginalSkele use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; use crate::patricia_merkle_tree::types::CompiledClassHash; -#[cfg(feature = "os_input")] #[path = "forest_trait_witnesses.rs"] pub mod forest_trait_witnesses; @@ -40,7 +39,6 @@ pub enum ForestMetadataType { StateDiffHash(DbBlockNumber), StateRoot(DbBlockNumber), /// BLAKE2s digest of the canonical accessed-keys set for the block. - #[cfg(feature = "os_input")] AccessedKeysDigest(DbBlockNumber), } @@ -265,19 +263,6 @@ impl ForestReaderWithEmptyContext for T where /// /// Types that require external context (e.g., `FactsDb` which needs roots provided externally as /// they are not part of the committer storage) should NOT implement this trait. -#[cfg(not(feature = "os_input"))] -pub trait ForestStorageWithEmptyReadContext: - ForestReaderWithEmptyContext + ForestWriterWithMetadata + StorageInitializer -{ -} - -#[cfg(not(feature = "os_input"))] -impl ForestStorageWithEmptyReadContext for T where - T: ForestReaderWithEmptyContext + ForestWriterWithMetadata + StorageInitializer -{ -} - -#[cfg(feature = "os_input")] pub trait ForestStorageWithEmptyReadContext: ForestReaderWithEmptyContext + forest_trait_witnesses::ForestWriterWithMetadataAndWitnesses @@ -285,7 +270,6 @@ pub trait ForestStorageWithEmptyReadContext: { } -#[cfg(feature = "os_input")] impl ForestStorageWithEmptyReadContext for T where T: ForestReaderWithEmptyContext + forest_trait_witnesses::ForestWriterWithMetadataAndWitnesses diff --git a/crates/starknet_committer/src/db/index_db/db.rs b/crates/starknet_committer/src/db/index_db/db.rs index 2565b9e0b7e..d66a7a87eab 100644 --- a/crates/starknet_committer/src/db/index_db/db.rs +++ b/crates/starknet_committer/src/db/index_db/db.rs @@ -3,44 +3,36 @@ use std::marker::PhantomData; use std::sync::LazyLock; use async_trait::async_trait; -#[cfg(feature = "os_input")] use starknet_api::block::BlockNumber; use starknet_api::core::{ContractAddress, PATRICIA_KEY_UPPER_BOUND_FELT}; use starknet_api::hash::{HashOutput, StateRoots}; use starknet_patricia::db_layout::{NodeLayout, NodeLayoutFor}; use starknet_patricia::patricia_merkle_tree::filled_tree::node::FilledNode; use starknet_patricia::patricia_merkle_tree::node_data::leaf::{Leaf, LeafModifications}; -#[cfg(feature = "os_input")] use starknet_patricia::patricia_merkle_tree::traversal::TraversalResult; use starknet_patricia::patricia_merkle_tree::types::NodeIndex; use starknet_patricia::patricia_merkle_tree::updated_skeleton_tree::hash_function::TreeHashFunction; use starknet_patricia_storage::db_object::{DBObject, EmptyKeyContext, HasStaticPrefix}; use starknet_patricia_storage::errors::{DeserializationError, SerializationResult}; -#[cfg(feature = "os_input")] use starknet_patricia_storage::map_storage::MapStorage; #[cfg(any(feature = "testing", test))] use starknet_patricia_storage::storage_trait::AsyncStorage; -#[cfg(feature = "os_input")] -use starknet_patricia_storage::storage_trait::DbOperation; -#[cfg(feature = "os_input")] -use starknet_patricia_storage::storage_trait::ImmutableReadOnlyStorage; -#[cfg(feature = "os_input")] -use starknet_patricia_storage::storage_trait::PatriciaStorageError; use starknet_patricia_storage::storage_trait::{ DbHashMap, DbKey, + DbOperation, DbOperationMap, DbValue, + ImmutableReadOnlyStorage, + PatriciaStorageError, PatriciaStorageResult, Storage, }; -#[cfg(feature = "os_input")] use starknet_patricia_storage::two_layer_storage::TwoLayerStorage; use starknet_types_core::felt::Felt; use crate::block_committer::input::{InputContext, ReaderConfig, StarknetStorageValue}; use crate::db::db_layout::DbLayout; -#[cfg(feature = "os_input")] use crate::db::forest_trait::forest_trait_witnesses::{ CommitmentInfosUpdate, CommitmentInfosWrite, @@ -74,17 +66,13 @@ use crate::db::index_db::types::{ use crate::db::serde_db_utils::DbBlockNumber; use crate::forest::deleted_nodes::DeletedNodes; use crate::forest::filled_forest::FilledForest; -#[cfg(feature = "os_input")] -use crate::forest::forest_errors::ForestError; -use crate::forest::forest_errors::ForestResult; +use crate::forest::forest_errors::{ForestError, ForestResult}; use crate::forest::original_skeleton_forest::{ForestSortedIndices, OriginalSkeletonForest}; use crate::hash_function::hash::TreeHashFunctionImpl; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; -#[cfg(feature = "os_input")] use crate::patricia_merkle_tree::tree::{fetch_all_patricia_paths, SortedLeafIndices}; -use crate::patricia_merkle_tree::types::CompiledClassHash; -#[cfg(feature = "os_input")] use crate::patricia_merkle_tree::types::{ + CompiledClassHash, CompressedStateCommitmentInfos, StarknetForestProofs, StateCommitmentInfos, @@ -121,7 +109,6 @@ pub(crate) static ACCESSED_KEYS_DIGEST_METADATA_PREFIX: LazyLock<[u8; 32]> = LazyLock::new(|| (Felt::from_bytes_be(&STATE_ROOT_METADATA_PREFIX) + Felt::ONE).to_bytes_be()); /// Prefix for Patricia proofs payload (per block). -#[cfg_attr(not(feature = "os_input"), expect(dead_code))] pub(crate) static PATRICIA_PATHS_PREFIX: LazyLock<[u8; 32]> = LazyLock::new(|| { (Felt::from_bytes_be(&ACCESSED_KEYS_DIGEST_METADATA_PREFIX) + Felt::ONE).to_bytes_be() }); @@ -324,7 +311,6 @@ impl ForestMetadata for IndexDb { ForestMetadataType::StateRoot(block_number) => { block_number_based_key(&STATE_ROOT_METADATA_PREFIX, block_number) } - #[cfg(feature = "os_input")] ForestMetadataType::AccessedKeysDigest(block_number) => { block_number_based_key(&ACCESSED_KEYS_DIGEST_METADATA_PREFIX, block_number) } @@ -368,7 +354,6 @@ fn block_number_based_key(prefix: &[u8; 32], block_number: DbBlockNumber) -> Vec key } -#[cfg(feature = "os_input")] #[async_trait] impl ForestReaderWithWitnesses for IndexDb @@ -430,7 +415,6 @@ impl ForestReader } } -#[cfg(feature = "os_input")] #[async_trait] impl ForestWriterWithMetadataAndWitnesses for IndexDb { async fn write_with_metadata_and_commitment_infos( @@ -496,7 +480,7 @@ where } } -#[cfg(all(feature = "os_input", any(test, feature = "testing")))] +#[cfg(any(test, feature = "testing"))] impl IndexDb { /// Removes Patricia trie node keys while keeping commitment metadata and stored witness /// payloads. Tests can call this before replaying `read_paths_and_commit_block` to ensure diff --git a/crates/starknet_committer/src/db/serde_db_utils.rs b/crates/starknet_committer/src/db/serde_db_utils.rs index 613ef870d60..bbf03a40362 100644 --- a/crates/starknet_committer/src/db/serde_db_utils.rs +++ b/crates/starknet_committer/src/db/serde_db_utils.rs @@ -1,15 +1,11 @@ -#[cfg(feature = "os_input")] use blake2::Blake2s256; -#[cfg(feature = "os_input")] use digest::Digest; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; -#[cfg(feature = "os_input")] use starknet_patricia::patricia_merkle_tree::types::NodeIndex; use starknet_patricia_storage::storage_trait::DbValue; use starknet_types_core::felt::Felt; -#[cfg(feature = "os_input")] use crate::patricia_merkle_tree::tree::SortedLeavesRequest; #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Hash, Serialize)] @@ -43,7 +39,6 @@ pub fn deserialize_felt_no_packing(value: &DbValue) -> Felt { /// 3. Storage tries — `len(storage_sorted)` then, for each contract index in ascending order: the /// contract index, `len(storage slot indices)` for that contract, then each storage slot index /// (already sorted within the contract). -#[cfg(feature = "os_input")] pub fn accessed_keys_digest(sorted: &SortedLeavesRequest<'_>) -> [u8; 32] { let mut payload = Vec::new(); @@ -76,7 +71,6 @@ pub fn accessed_keys_digest(sorted: &SortedLeavesRequest<'_>) -> [u8; 32] { Blake2s256::digest(&payload).into() } -#[cfg(feature = "os_input")] fn encode_usize(n: usize) -> [u8; 8] { u64::try_from(n).expect("accessed leaf count exceeds u64::MAX").to_be_bytes() } diff --git a/crates/starknet_committer/src/patricia_merkle_tree.rs b/crates/starknet_committer/src/patricia_merkle_tree.rs index 837416b7f19..1b908681212 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree.rs @@ -1,7 +1,6 @@ pub mod leaf; -#[cfg(feature = "os_input")] mod starknet_forest_proofs_serde; -#[cfg(all(test, feature = "os_input"))] +#[cfg(test)] mod starknet_forest_proofs_serialization_test; pub mod tree; pub mod types; diff --git a/crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs b/crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs index 63a398d72dc..52278654733 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/starknet_forest_proofs_serde.rs @@ -35,8 +35,9 @@ impl StarknetForestProofs { /// 3. Contract trie leaves — `ContractTrieLeaves`. /// 4. Storage tries inner nodes — `StorageTrieProofs`. /// - /// Each `commitment_facts` entry uses the same encoding as [`CommitmentInfo::commitment_facts`] - /// and OS Patricia hints: + /// Each `commitment_facts` entry uses the same encoding as + /// [`crate::patricia_merkle_tree::types::CommitmentInfo::commitment_facts`] and OS Patricia + /// hints: /// /// - Binary node — `[left: Felt, right: Felt]`. /// - Edge node — `[length: Felt, path: Felt, bottom: Felt]`. diff --git a/crates/starknet_committer/src/patricia_merkle_tree/types.rs b/crates/starknet_committer/src/patricia_merkle_tree/types.rs index 6c71c9bc8c0..a016802b2d6 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/types.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/types.rs @@ -11,7 +11,6 @@ use starknet_patricia::patricia_merkle_tree::node_data::inner_node::{ }; use starknet_patricia::patricia_merkle_tree::node_data::leaf::SkeletonLeaf; use starknet_patricia::patricia_merkle_tree::types::{NodeIndex, SubTreeHeight}; -#[cfg(feature = "os_input")] use starknet_patricia_storage::errors::SerializationError; use starknet_types_core::felt::{Felt, FromStrError}; @@ -97,7 +96,6 @@ pub struct StateCommitmentInfos { pub storage_tries_commitment_infos: HashMap, } -#[cfg(feature = "os_input")] #[derive(Debug, thiserror::Error)] pub enum StateCommitmentInfosCodecError { #[error(transparent)] @@ -106,7 +104,6 @@ pub enum StateCommitmentInfosCodecError { Io(#[from] std::io::Error), } -#[cfg(feature = "os_input")] impl From for SerializationError { fn from(error: StateCommitmentInfosCodecError) -> Self { match error { @@ -136,8 +133,6 @@ impl<'de> Deserialize<'de> for CompressedStateCommitmentInfos { base64::decode(&base64_payload).map(Self).map_err(serde::de::Error::custom) } } - -#[cfg(feature = "os_input")] impl CompressedStateCommitmentInfos { /// Reverses [`StateCommitmentInfos::compress`]: zstd-decompresses then bincode-deserializes. pub fn decompress(&self) -> Result { @@ -155,7 +150,6 @@ impl StateCommitmentInfos { /// Bincode encodes each hash-map as an 8-byte length followed by its entries, and each `Felt` /// as an 8-byte length followed by its value, so the payload is dominated by leading zeros /// that zstd compresses efficiently. - #[cfg(feature = "os_input")] pub fn compress( &self, ) -> Result { @@ -229,7 +223,6 @@ impl StateCommitmentInfos { } /// Total number of `commitment_facts` entries across all tries (for logging/metrics). - #[cfg(feature = "os_input")] pub fn n_commitment_facts(&self) -> usize { self.contracts_trie_commitment_info.commitment_facts.len() + self.classes_trie_commitment_info.commitment_facts.len() diff --git a/crates/starknet_committer/src/patricia_merkle_tree/types_test.rs b/crates/starknet_committer/src/patricia_merkle_tree/types_test.rs index c4c023cce0a..f8d0d08da4e 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/types_test.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/types_test.rs @@ -4,11 +4,10 @@ use starknet_patricia::patricia_merkle_tree::types::NodeIndex; use starknet_types_core::felt::Felt; use crate::block_committer::input::{contract_address_into_node_index, StarknetStorageKey}; -#[cfg(feature = "os_input")] -use crate::patricia_merkle_tree::types::StateCommitmentInfos; use crate::patricia_merkle_tree::types::{ fixed_hex_string_no_prefix, CompressedStateCommitmentInfos, + StateCommitmentInfos, }; #[rstest] @@ -38,7 +37,6 @@ fn test_fixed_hex_string_no_prefix( /// Consumers one-shot decompress the payload, which requires the decompressed size to be readable /// from the frame header rather than only by streaming the frame to its end. -#[cfg(feature = "os_input")] #[test] fn test_compressed_state_commitment_infos_frame_header_declares_decompressed_size() { let commitment_infos = StateCommitmentInfos::default(); diff --git a/crates/starknet_committer_and_os_cli/Cargo.toml b/crates/starknet_committer_and_os_cli/Cargo.toml index ee72991734b..be97d5adf15 100644 --- a/crates/starknet_committer_and_os_cli/Cargo.toml +++ b/crates/starknet_committer_and_os_cli/Cargo.toml @@ -6,9 +6,6 @@ repository.workspace = true license-file.workspace = true description = "Cli for the committer package." -[features] -os_input = ["apollo_committer/os_input"] - [lints] workspace = true diff --git a/crates/starknet_os_flow_tests/Cargo.toml b/crates/starknet_os_flow_tests/Cargo.toml index d63cfa2bced..fba02febe50 100644 --- a/crates/starknet_os_flow_tests/Cargo.toml +++ b/crates/starknet_os_flow_tests/Cargo.toml @@ -10,7 +10,6 @@ description = "Integration tests for Starknet OS execution and state commitment exhaustive_fuzz_test = [] fuzz_test_debug = [] long_fuzz_test = [] -os_input = ["apollo_integration_tests/os_input", "blockifier/os_input"] [dev-dependencies] apollo_integration_tests.workspace = true @@ -38,7 +37,7 @@ starknet_os = { workspace = true, features = ["include_program_output", "testing starknet_patricia = { workspace = true, features = ["testing"] } starknet_patricia_storage = { workspace = true, features = ["testing"] } starknet_proof_verifier.workspace = true -starknet_transaction_prover = { workspace = true, features = ["os_input"] } +starknet_transaction_prover.workspace = true strum.workspace = true tokio.workspace = true diff --git a/crates/starknet_transaction_prover/Cargo.toml b/crates/starknet_transaction_prover/Cargo.toml index c6a74f49430..4de5f83ca1f 100644 --- a/crates/starknet_transaction_prover/Cargo.toml +++ b/crates/starknet_transaction_prover/Cargo.toml @@ -8,7 +8,6 @@ description = "Standalone service that proves individual Starknet transactions u [features] cairo_native = ["blockifier/cairo_native"] -os_input = ["starknet_committer/os_input"] # Enables in-memory stwo proving. Requires a nightly Rust toolchain because the # stwo prover crate uses unstable features (array_chunks, portable_simd, …). stwo_proving = ["dep:privacy-prove"] diff --git a/crates/starknet_transaction_prover/src/running/committer_utils.rs b/crates/starknet_transaction_prover/src/running/committer_utils.rs index 801a41883ce..bc524392366 100644 --- a/crates/starknet_transaction_prover/src/running/committer_utils.rs +++ b/crates/starknet_transaction_prover/src/running/committer_utils.rs @@ -1,15 +1,13 @@ use std::collections::HashSet; use std::hash::BuildHasher; -#[cfg(feature = "os_input")] use blockifier::state::accessed_keys::AccessedKeys; use blockifier::state::cached_state::{CommitmentStateDiff, StateMaps, StorageDiff, StorageView}; use indexmap::IndexMap; use starknet_api::core::{ClassHash, Nonce}; use starknet_api::hash::{HashOutput, StateRoots}; -use starknet_committer::block_committer::commit::commit_block; -#[cfg(feature = "os_input")] use starknet_committer::block_committer::commit::{ + commit_block, commit_block_with_witnesses, CommitBlockWithWitnessesOutput, }; @@ -25,15 +23,11 @@ use starknet_committer::db::facts_db::db::{FactDbFilledNode, FactsDb}; use starknet_committer::db::facts_db::node_serde::{PatriciaPrefix, FACT_LAYOUT_DB_KEY_SEPARATOR}; use starknet_committer::db::facts_db::types::FactsDbInitialRead; use starknet_committer::db::forest_trait::{ForestWriter, StorageInitializer}; -#[cfg(feature = "os_input")] use starknet_committer::db::index_db::{IndexDb, IndexDbReadContext}; use starknet_committer::hash_function::hash::TreeHashFunctionImpl; use starknet_committer::patricia_merkle_tree::leaf::leaf_impl::ContractState; -#[cfg(feature = "os_input")] use starknet_committer::patricia_merkle_tree::tree::LeavesRequest; -use starknet_committer::patricia_merkle_tree::types::CompiledClassHash; -#[cfg(feature = "os_input")] -use starknet_committer::patricia_merkle_tree::types::StateCommitmentInfos; +use starknet_committer::patricia_merkle_tree::types::{CompiledClassHash, StateCommitmentInfos}; use starknet_patricia::patricia_merkle_tree::filled_tree::node::FilledNode; use starknet_patricia::patricia_merkle_tree::node_data::inner_node::{BinaryData, NodeData}; use starknet_patricia::patricia_merkle_tree::node_data::leaf::Leaf; @@ -350,7 +344,6 @@ pub async fn commit_state_diff( /// Commits the state diff, collects the OS-input Patricia witness paths, and returns the new state /// roots together with the [`StateCommitmentInfos`] needed by the OS. -#[cfg(feature = "os_input")] pub async fn commit_state_diff_with_witnesses( index_db: &mut IndexDb, state_diff: StateDiff, @@ -383,7 +376,6 @@ pub async fn commit_state_diff_with_witnesses( /// Commits the state diff (without collecting witnesses), persists the new forest, and returns the /// new state roots. -#[cfg(feature = "os_input")] pub async fn commit_state_diff_to_index_db( index_db: &mut IndexDb, state_diff: StateDiff, diff --git a/echonet/echonet_types.py b/echonet/echonet_types.py index 8055144e66a..2cf709128e4 100644 --- a/echonet/echonet_types.py +++ b/echonet/echonet_types.py @@ -178,8 +178,7 @@ class PathsConfig: class OsRunnerConfig: """ Configuration for running the Starknet OS over each received blob, via the - block-hash CLI binary's `os run-os-stateless` subcommand (which must be - built with the `os_input` and `transaction_serde` features). + block-hash CLI binary's `os run-os-stateless` subcommand. """ enabled: bool = True