diff --git a/.config/nextest.toml b/.config/nextest.toml index d2ff6eda7f..0bd0e72cc7 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -29,12 +29,25 @@ filter = 'package(sov-sequencer) & test(/flaky_test_archival_state_is_immediatel priority = 95 threads-required = 3 +[[profile.default.overrides]] +filter = 'package(sov-sequencer) & test(/seq_behind_deferred_slots_count|test_no_crashes_on_resync|sequencer_back_pressure|heavy_blob_submission/)' +test-group = 'heavy-sequencer-tests' +threads-required = 4 # Limit parallelism when these tests run +slow-timeout = { period = "60s", terminate-after = 10 } # These tests need up to 10 minutes under load + +# This test has a race condition in archival state queries under load - needs full isolation +[[profile.default.overrides]] +filter = 'package(sov-sequencer)' +threads-required = 'num-cpus' + +[test-groups.heavy-sequencer-tests] +max-threads = 2 + [[profile.default.overrides]] filter = 'package(sov-demo-rollup) & test(/replica::/)' priority = 90 # try to run it first, so it doesn't add up at the end threads-required = 3 - [profile.ci] default-filter = 'all()' diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d0122ab36..1c1bc1e3df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2026-01-14 +- #2329 Changes default storage in sov-test-utils's TestRollup to be NOMT. No impact for regular customers +# 2026-01-16 # 2026-01-29 - #2415 Non-breaking, but **important**. Config for MockDa rollup now stricter and prevents unknown fields. Previously there was incorrect `finalization` field instead of `finalization_blocks` diff --git a/Cargo.lock b/Cargo.lock index 8ae394d0fd..93d5635b97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10876,6 +10876,7 @@ dependencies = [ "serde", "sov-address", "sov-capabilities", + "sov-db", "sov-metrics", "sov-mock-da", "sov-modules-api", @@ -11974,6 +11975,7 @@ dependencies = [ "sov-revenue-share", "sov-rollup-interface", "sov-sequencer-registry", + "sov-state", "sov-test-utils", "strum 0.26.3", "thiserror 1.0.69", diff --git a/crates/full-node/sov-db/src/config.rs b/crates/full-node/sov-db/src/config.rs index a5d9e61522..93461acb75 100644 --- a/crates/full-node/sov-db/src/config.rs +++ b/crates/full-node/sov-db/src/config.rs @@ -63,29 +63,21 @@ impl RollupDbConfig { Self { path, state_cache_size: Some(1_000_000), // Use a 1MB state cache for tests - user_commit_concurrency: Some(4), + user_commit_concurrency: Some(2), user_hashtable_buckets: Some(if cfg!(debug_assertions) { - 2_500 // 9.77MB + 500 } else { - 15_000_000 + 1_000_000 }), - user_preallocate_ht: if cfg!(debug_assertions) { - Some(false) - } else { - None - }, - user_page_cache_size: None, - user_leaf_cache_size: None, + user_preallocate_ht: Some(false), + user_page_cache_size: Some(16), + user_leaf_cache_size: Some(16), kernel_commit_concurrency: Some(2), kernel_hashtable_buckets: None, - kernel_preallocate_ht: if cfg!(debug_assertions) { - Some(false) - } else { - None - }, - kernel_page_cache_size: None, - kernel_leaf_cache_size: None, - pruner_block_interval: Some(100), + kernel_preallocate_ht: Some(false), + kernel_page_cache_size: Some(16), + kernel_leaf_cache_size: Some(16), + pruner_block_interval: None, pruner_versions_to_keep: Some(20), pruner_max_batch_size: None, } @@ -102,13 +94,16 @@ impl RollupDbConfig { self.kernel_commit_concurrency .expect("`kernel_commit_concurrency` concurrency must be set"), ); - if cfg!(debug_assertions) { - // 9.77MB - opts.hashtable_buckets(2_500); + if let Some(hashtable_buckets) = self.kernel_hashtable_buckets { + opts.hashtable_buckets(hashtable_buckets); + } else if cfg!(debug_assertions) { + // 2MB + opts.hashtable_buckets(500); } else { // 1000MB opts.hashtable_buckets(self.kernel_hashtable_buckets.unwrap_or(256_000)); } + if let Some(preallocate_ht) = self.kernel_preallocate_ht { opts.preallocate_ht(preallocate_ht); } @@ -119,6 +114,7 @@ impl RollupDbConfig { if let Some(leaf_cache_size) = self.kernel_leaf_cache_size { opts.leaf_cache_size(leaf_cache_size); } + opts.path(self.path.join("kernel_nomt_db")); opts @@ -146,6 +142,7 @@ impl RollupDbConfig { if let Some(leaf_cache_size) = self.user_leaf_cache_size { opts.leaf_cache_size(leaf_cache_size); } + opts.path(self.path.join("user_nomt_db")); opts } diff --git a/crates/full-node/sov-sequencer/src/preferred/state_root_compute.rs b/crates/full-node/sov-sequencer/src/preferred/state_root_compute.rs index edcfffb133..c2e9f9bdba 100644 --- a/crates/full-node/sov-sequencer/src/preferred/state_root_compute.rs +++ b/crates/full-node/sov-sequencer/src/preferred/state_root_compute.rs @@ -198,7 +198,7 @@ async fn compute_state_root>( impl StateRootTask { pub(super) fn create>( - mut block_excutors_shutdown_receiver: mpsc::Receiver<()>, + mut block_executors_shutdown_receiver: mpsc::Receiver<()>, check_state_roots: bool, ) -> (JoinHandle<()>, StateRootTask) { let span = span!(Level::DEBUG, "state_root_compute_background_task"); @@ -222,7 +222,7 @@ impl StateRootTask { } } } - _ = block_excutors_shutdown_receiver.recv() => { + _ = block_executors_shutdown_receiver.recv() => { info!( "Sequencer state root background task shutdown in response to signal", ); @@ -353,10 +353,10 @@ mod tests { use sov_state::SlotKey; use sov_state::StateUpdate; use sov_test_utils::storage::{ - ForklessStorageManager, SimpleNomtStorageManager, SimpleStorageManager, + ForklessStorageManager, SimpleJmtStorageManager, SimpleStorageManager, }; use sov_test_utils::{ - generate_optimistic_runtime, TestHasher, TestNomtSpec, TestSpec, TestStorageSpec, + generate_optimistic_runtime, TestHasher, TestJmtSpec, TestSpec, TestStorageSpec, }; use tokio::task::JoinHandle; @@ -366,8 +366,8 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn test_jmt_new_rollup_height_state_root_on_stale_storage() { - let storage_manager = SimpleStorageManager::::new(); - new_rollup_height_state_root_on_stale_storage::>( + let storage_manager = SimpleJmtStorageManager::::new(); + new_rollup_height_state_root_on_stale_storage::>( storage_manager, ) .await; @@ -375,8 +375,8 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn test_jmt_known_rollup_height_state_root_on_stale_storage() { - let storage_manager = SimpleStorageManager::::new(); - known_rollup_height_state_root_on_stale_storage::>( + let storage_manager = SimpleJmtStorageManager::::new(); + known_rollup_height_state_root_on_stale_storage::>( storage_manager, ) .await; @@ -384,14 +384,20 @@ mod tests { #[tokio::test(flavor = "multi_thread")] async fn test_nomt_new_rollup_height_state_root_on_stale_storage() { - let storage_manager = SimpleNomtStorageManager::::new(); - new_rollup_height_state_root_on_stale_storage::>(storage_manager).await; + let storage_manager = SimpleStorageManager::::new(); + new_rollup_height_state_root_on_stale_storage::>( + storage_manager, + ) + .await; } #[tokio::test(flavor = "multi_thread")] async fn test_nomt_known_rollup_height_state_root_on_stale_storage() { - let storage_manager = SimpleNomtStorageManager::::new(); - known_rollup_height_state_root_on_stale_storage::>(storage_manager).await; + let storage_manager = SimpleStorageManager::::new(); + known_rollup_height_state_root_on_stale_storage::>( + storage_manager, + ) + .await; } // Helpers go below @@ -625,9 +631,9 @@ mod tests { ) .unwrap(); known_rollup_height_state_root_on_stale_storage_with_deep_jumps::< - TestNomtSpec, + TestSpec, _, - TestRuntime, + TestRuntime, >(storage_manager) .await; } @@ -777,7 +783,7 @@ mod tests { // Now we'll run a loop of... // - Commit the next block info, making one more set of sequencer storages become stale. - // - Iterate over all of the seqeuncer storages and compute the state root for each one. Make sure that they get the correct value + // - Iterate over all of the sequencer storages and compute the state root for each one. Make sure that they get the correct value // // This checks that stale storage is handled correctly, even when it becomes *very* stale. (For example, the storage we created for block 1 should still compute the correct root after block 10 has been written to disk.) for i in 0..block_infos.len() { diff --git a/crates/full-node/sov-sequencer/tests/integration/pinned_cache.rs b/crates/full-node/sov-sequencer/tests/integration/pinned_cache.rs index 85e1537e82..2fa9c08a15 100644 --- a/crates/full-node/sov-sequencer/tests/integration/pinned_cache.rs +++ b/crates/full-node/sov-sequencer/tests/integration/pinned_cache.rs @@ -3,19 +3,13 @@ use crate::utils::tempdir_inside_codebase_dir; use base64::prelude::BASE64_STANDARD; use base64::Engine; use sov_api_spec::types as api_types; -use sov_db::storage_manager::NomtStorageManager; use sov_mock_da::BlockProducingConfig; -use sov_mock_da::MockHash; use sov_mock_zkvm::crypto::private_key::Ed25519PrivateKey; -use sov_modules_api::CryptoSpec; use sov_modules_api::RawTx; -use sov_modules_api::Spec; use sov_modules_api::{DispatchCall, HexHash, HexString}; use sov_modules_stf_blueprint::Runtime; use sov_sequencer::SequencerKindConfig; -use sov_state::nomt::prover_storage::NomtProverStorage; use sov_state::pinned_cache::PinnedCache; -use sov_state::DefaultStorageSpec; use sov_test_modules::pinned_cache::CallMessage as PinnedCacheCallMessage; use sov_test_modules::pinned_cache::PinnedCacheTester; use sov_test_modules::pinned_cache::ValueRange; @@ -26,25 +20,14 @@ use sov_test_utils::test_rollup::GenesisSource; use sov_test_utils::test_rollup::RollupBuilder; use sov_test_utils::test_rollup::StoragePath; use sov_test_utils::test_rollup::TestRollup; -use sov_test_utils::MockDaSpec; use sov_test_utils::RtAgnosticBlueprint; -use sov_test_utils::TestNomtSpec as TestSpec; +use sov_test_utils::TestSpec; +use sov_test_utils::TestStorageManager; use sov_test_utils::TestUser; use sov_test_utils::{default_test_signed_transaction, TEST_DEFAULT_MOCK_DA_BLOCK_TIME_MS}; use tokio_stream::StreamExt; -type TestNomtBlueprint = RtAgnosticBlueprint< - TestSpec, - TestRuntime, - NomtStorageManager< - MockDaSpec, - <::CryptoSpec as CryptoSpec>::Hasher, - NomtProverStorage< - DefaultStorageSpec<<::CryptoSpec as CryptoSpec>::Hasher>, - MockHash, - >, - >, ->; +type TestNomtBlueprint = RtAgnosticBlueprint, TestStorageManager>; const PINNED_ADDRESS: HexHash = HexString([1u8; 32]); diff --git a/crates/full-node/sov-sequencer/tests/integration/preferred_end_to_end.rs b/crates/full-node/sov-sequencer/tests/integration/preferred_end_to_end.rs index a3a56d2449..fa51b1b239 100644 --- a/crates/full-node/sov-sequencer/tests/integration/preferred_end_to_end.rs +++ b/crates/full-node/sov-sequencer/tests/integration/preferred_end_to_end.rs @@ -55,6 +55,7 @@ use tokio_stream::StreamExt; use tracing::{debug, info}; const DELAYED_TX_DELAY_MS: u64 = 2500; +const NOTIFICATION_TIMEOUT: Duration = Duration::from_secs(30); generate_optimistic_runtime_with_kernel!( TestRuntime <= @@ -141,11 +142,19 @@ impl DaLayerWithSubscription { let subscription = self.slot_subscription.as_mut().unwrap(); while self.back_slot_notifications > 1 { self.back_slot_notifications -= 1; - subscription.next().await.unwrap().unwrap(); + tokio::time::timeout(NOTIFICATION_TIMEOUT, subscription.next()) + .await + .expect("timeout waiting for slot notification") + .unwrap() + .unwrap(); } self.back_slot_notifications -= 1; - subscription.next().await.unwrap().unwrap() + tokio::time::timeout(NOTIFICATION_TIMEOUT, subscription.next()) + .await + .expect("timeout waiting for slot notification") + .unwrap() + .unwrap() } /// Gets the next state update notification, clearing any *known* updates from the queue first. @@ -154,7 +163,11 @@ impl DaLayerWithSubscription { /// how many state update notifications we should ultimately be receiving. pub async fn next_state_update_notification(&mut self) -> StateUpdateNotification { let subscription = self.state_update_subscription.as_mut().unwrap(); - subscription.next().await.unwrap().unwrap() + tokio::time::timeout(NOTIFICATION_TIMEOUT, subscription.next()) + .await + .expect("timeout waiting for state update notification") + .unwrap() + .unwrap() } /// Produces a slot and waits for the state update and slot notifications. @@ -545,7 +558,7 @@ async fn test_tx_ws_submission() { } #[tokio::test(flavor = "multi_thread")] -#[ignore = "This test covers pruning behavior, which is only relevant for NOMT. Enable it when we switch to NOMT for the sequencer tests."] +#[ignore = "This test covers pruning behavior, which is currently disabled."] async fn test_archival_state_with_pruning() { let (test_rollup, admin) = create_test_rollup( 0, @@ -2335,9 +2348,24 @@ async fn test_no_crashes_on_resync_with_transactions() { let rollup_storage_path = builder.storage_path(); // Next, delete everything except the preferred sequencer DB. Resync again to verify that this - // doesn't interfere - for path in ["state", "accessory", "ledger", "blob_sender"] { - std::fs::remove_dir_all(rollup_storage_path.path().join(path)).unwrap(); + // doesn't interfere. + // NOMT uses different directories than JMT: + // - user_nomt_db, kernel_nomt_db (NOMT state) + // - state-db, archival-state-db (FlatStateDb) + // - accessory, ledger, blob_sender (common to both) + for path in [ + "user_nomt_db", + "kernel_nomt_db", + "state-db", + "archival-state-db", + "accessory", + "ledger", + "blob_sender", + ] { + let full_path = rollup_storage_path.path().join(path); + if full_path.exists() { + std::fs::remove_dir_all(full_path).unwrap(); + } } let test_rollup = builder.start().await.unwrap(); diff --git a/crates/full-node/sov-sequencer/tests/integration/upgradability/mod.rs b/crates/full-node/sov-sequencer/tests/integration/upgradability/mod.rs index 11345a3e3a..07d8c1a514 100644 --- a/crates/full-node/sov-sequencer/tests/integration/upgradability/mod.rs +++ b/crates/full-node/sov-sequencer/tests/integration/upgradability/mod.rs @@ -86,7 +86,7 @@ async fn sequencer_stops_if_stop_at_height_too_small(finalization_blocks: u32) { let stop_at_height = RollupHeight::new(3); - let (test_rollup, _) = create_test_rollup( + let (test_rollup, admin) = create_test_rollup( 0, TEST_MAX_BATCH_SIZE, TEST_BLOB_PROCESSING_TIMEOUT, @@ -95,21 +95,28 @@ async fn sequencer_stops_if_stop_at_height_too_small(finalization_blocks: u32) { ) .await; - // Produce a few blocks to DA blocks to make sure there's a finalized slot after genesis. - // This is for make rollup operational, so rollup will give out slot notifications. - test_rollup - .tenderly_produce_blocks((finalization_blocks + 1) as usize) - .await - .unwrap(); - let mut slot_subscription = test_rollup.client.client.subscribe_slots().await.unwrap(); - let padding_to_shutdown = 20; - test_rollup - .tenderly_produce_blocks(padding_to_shutdown) - .await - .unwrap(); - for _ in 0..padding_to_shutdown { - let _slot = slot_subscription.next().await.unwrap().unwrap(); + let api_client = test_rollup.api_client().clone(); + + // Produce enough finalized DA blocks so the sequencer can start accepting transactions. + let da = test_rollup.da_service.clone(); + let mut da_sub = da.subscribe_finalized_header().await.unwrap(); + for _ in 0..finalization_blocks + 3 { + test_rollup.da_service.produce_block_now().await.unwrap(); + tokio::time::sleep(Duration::from_millis(300)).await; + } + da_sub.next().await; + + // Produce enough blocks with transactions to advance rollup height past stop_at_height. + // Transactions are required to trigger batch production and increment rollup height. + let target_height = stop_at_height.get() + finalization_blocks as u64 + 2; + let mut nonce = 0; + while test_rollup.height().await.get() < target_height { + send_tx(&admin, nonce, &api_client).await.unwrap(); + nonce += 1; + test_rollup.da_service.produce_block_now().await.unwrap(); + slot_subscription.next().await; + tokio::time::sleep(Duration::from_millis(100)).await; } let slot_height = test_rollup.height().await; @@ -117,6 +124,11 @@ async fn sequencer_stops_if_stop_at_height_too_small(finalization_blocks: u32) { // Assert the condition that triggers an early return. assert!(stop_at_height < slot_height); + // Ensure that state up to at least `stop_at_height` is finalized and persisted to disk. + // Without this, non-finalized blocks' state changes are lost on shutdown, causing the + // restart to see a lower height than expected. + test_rollup.produce_enough_finalized_slots().await; + let Err(err) = test_rollup .restart_with_heights(None, Some(stop_at_height)) .await diff --git a/crates/full-node/sov-stf-runner/proptest-regressions/state_manager/tests.txt b/crates/full-node/sov-stf-runner/proptest-regressions/state_manager/tests.txt index 443f20e909..7ee58ce9d0 100644 --- a/crates/full-node/sov-stf-runner/proptest-regressions/state_manager/tests.txt +++ b/crates/full-node/sov-stf-runner/proptest-regressions/state_manager/tests.txt @@ -10,3 +10,4 @@ cc d37cc28df7615393e7842f3a881120ac2aa9027d1efff7562894d946f7dbc90b # shrinks to cc da5788a9f42ff779f8dc98c5a993738b5d4b20d1c0f41902ad5cab46b6e09aef # shrinks to finality = 5, loop_blocks = 8, batches = 2, reshuffle_after = 3, seed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] cc c02ebc43f6c54d86c065e7a608fa4bb59a12f3682bab263095e22dcb9902955d # shrinks to finality = 1, loop_blocks = 9, batches = 0, reshuffle_after = 5, seed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] cc 96929355129adb31d14027bfcd889e545448a56b1072ad2445e53e1eccc6d302 # shrinks to finality = 5, loop_blocks = 3, batches = 2, reshuffle_after = 1, seed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] +cc 33519192141d90a6faa0b98080a71c47ddff97d43516fa18089dbd812b985214 # shrinks to finality = 0, loop_blocks = 18, batches = 0, reshuffle_after = 3, seed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2] diff --git a/crates/full-node/sov-stf-runner/tests/integration/helpers/hash_stf.rs b/crates/full-node/sov-stf-runner/tests/integration/helpers/hash_stf.rs index 3bad52bd24..0a2e72f088 100644 --- a/crates/full-node/sov-stf-runner/tests/integration/helpers/hash_stf.rs +++ b/crates/full-node/sov-stf-runner/tests/integration/helpers/hash_stf.rs @@ -1,6 +1,6 @@ use sha2::Digest; -use sov_db::storage_manager::NativeChangeSet; -use sov_mock_da::MockAddress; +use sov_db::storage_manager::NomtChangeSet; +use sov_mock_da::{MockAddress, MockHash}; use sov_mock_zkvm::{MockCodeCommitment, MockZkVerifier}; use sov_modules_api::{ AggregatedProofPublicData, ProofOutcome, ProofReceipt, ProofReceiptContents, Storage, @@ -11,10 +11,10 @@ use sov_rollup_interface::stf::{ApplySlotOutput, GenesisParams, StateTransitionF use sov_rollup_interface::zk::aggregated_proof::SerializedAggregatedProof; use sov_rollup_interface::zk::{ZkVerifier, Zkvm}; use sov_state::namespaces::User; +use sov_state::nomt::prover_storage::NomtProverStorage; use sov_state::storage::{NativeStorage, SlotKey, SlotValue}; use sov_state::{ - ArrayWitness, DefaultStorageSpec, OrderedReadsAndWrites, Prefix, ProverStorage, StateAccesses, - StorageRoot, + ArrayWitness, DefaultStorageSpec, OrderedReadsAndWrites, Prefix, StateAccesses, StorageRoot, }; pub type S = DefaultStorageSpec; @@ -32,24 +32,36 @@ impl HashStf { SlotKey::singleton(&prefix) } + fn kernel_key() -> SlotKey { + let prefix = Prefix::new(1, 0); + SlotKey::singleton(&prefix) + } + fn save_from_hasher( hasher: sha2::Sha256, - storage: ProverStorage, + storage: NomtProverStorage, witness: &ArrayWitness, root: StorageRoot, - ) -> (StorageRoot, NativeChangeSet) { + ) -> (StorageRoot, NomtChangeSet) { let result = hasher.finalize(); let hash_key = HashStf::hash_key(); let hash_value = SlotValue::from(result.as_slice().to_vec()); - let ordered_reads_writes = OrderedReadsAndWrites { + let kernel_key = HashStf::kernel_key(); + let kernel_value = SlotValue::from(vec![0u8]); // Minimal kernel state marker + + let user_reads_writes = OrderedReadsAndWrites { ordered_reads: Vec::default(), ordered_writes: vec![(hash_key, Some(hash_value))], }; + let kernel_reads_writes = OrderedReadsAndWrites { + ordered_reads: Vec::default(), + ordered_writes: vec![(kernel_key, Some(kernel_value))], + }; let state_accesses = StateAccesses { - user: ordered_reads_writes, - kernel: Default::default(), + user: user_reads_writes, + kernel: kernel_reads_writes, }; let (jmt_root_hash, state_update) = storage @@ -85,8 +97,8 @@ impl StateTransitionFunction; type GenesisParams = HashStfGenesisParams; - type PreState = ProverStorage; - type ChangeSet = NativeChangeSet; + type PreState = NomtProverStorage; + type ChangeSet = NomtChangeSet; type TxReceiptContents = (); type StorageProof = (); type GasPrice = (); @@ -107,7 +119,7 @@ impl StateTransitionFunction as Storage>::PRE_GENESIS_ROOT, + as Storage>::PRE_GENESIS_ROOT, ) } diff --git a/crates/full-node/sov-stf-runner/tests/integration/helpers/runner_init.rs b/crates/full-node/sov-stf-runner/tests/integration/helpers/runner_init.rs index 699a42740e..d9f59988c4 100644 --- a/crates/full-node/sov-stf-runner/tests/integration/helpers/runner_init.rs +++ b/crates/full-node/sov-stf-runner/tests/integration/helpers/runner_init.rs @@ -1,18 +1,18 @@ use std::num::NonZero; use std::sync::Arc; +use crate::helpers::hash_stf::HashStf; use axum::async_trait; use futures::stream::BoxStream; use futures::{Stream, StreamExt}; use rockbound::SchemaBatch; -use sha2::Sha256; use sov_db::config::RollupDbConfig; use sov_db::ledger_db::LedgerDb; use sov_db::schema::DeltaReader; -use sov_db::storage_manager::NativeStorageManager; +use sov_db::storage_manager::NomtStorageManager; use sov_metrics::MonitoringConfig; use sov_mock_da::{ - BlockProducingConfig, MockAddress, MockBlockHeader, MockDaConfig, MockDaService, MockDaSpec, + BlockProducingConfig, MockAddress, MockBlockHeader, MockDaConfig, MockDaService, MockDaVerifier, MockHash, }; use sov_mock_zkvm::{MockZkvm, MockZkvmHost}; @@ -29,7 +29,7 @@ use sov_rollup_interface::zk::aggregated_proof::SerializedAggregatedProof; use sov_rollup_interface::zk::Zkvm; use sov_sequencer::standard::StdSequencerConfig; use sov_sequencer::{react_to_state_updates, SequencerConfig, SequencerKindConfig}; -use sov_state::{DefaultStorageSpec, NativeStorage, ProverStorage}; +use sov_state::NativeStorage; use sov_stf_runner::processes::{ start_zk_workflow_in_background, ParallelProverService, RollupProverConfigDiscriminants, }; @@ -39,21 +39,18 @@ use sov_stf_runner::{ }; use sov_stf_runner::{make_da_sync_state, DaServiceWithCachedFinalizedHeaders}; use sov_test_utils::{ - TestSpec, TEST_BLOB_PROCESSING_TIMEOUT, TEST_MAX_BATCH_SIZE, TEST_MAX_CONCURRENT_BLOBS, - TEST_MOCK_DA_POLLING_INTERVAL, + TestSpec, TestStorage, TestStorageManager, TEST_BLOB_PROCESSING_TIMEOUT, TEST_MAX_BATCH_SIZE, + TEST_MAX_CONCURRENT_BLOBS, TEST_MOCK_DA_POLLING_INTERVAL, }; use tokio::net::TcpListener; use tokio::sync::broadcast::Receiver; use tokio::sync::watch; use tokio::task::JoinSet; -use crate::helpers::hash_stf::HashStf; - type MockInitVariant = InitVariant; -pub type S = DefaultStorageSpec; -pub type StorageManager = NativeStorageManager>; -pub type HashStfRunner = StateTransitionRunner; +pub type HashStfRunner = + StateTransitionRunner; /// TestNode simulates a full-node. pub struct TestNode { @@ -151,9 +148,9 @@ impl ProofSender for MockProofSender { // Returns genesis state root, prev state root for given init variant and initial value for state update info. pub async fn bootstrap_state_update_info( - storage_manager: &mut StorageManager, + storage_manager: &mut TestStorageManager, da_sync_state: &DaSyncState, -) -> anyhow::Result>> { +) -> anyhow::Result> { let genesis_block_header = MockBlockHeader::from_height(0); let (stf_storage, ledger_state) = storage_manager.create_state_after(&genesis_block_header)?; let ledger_db = LedgerDb::with_reader(ledger_state)?; @@ -161,7 +158,7 @@ pub async fn bootstrap_state_update_info( query_state_update_info(&ledger_db, stf_storage, da_sync_state).await } -pub type StateRoot = as sov_state::Storage>::Root; +pub type StateRoot = ::Root; // TODO: extract similarities into helper for rollup blueprint, a lot of duplication /// Returns (runner, state_root_after_init, test_node) @@ -203,7 +200,8 @@ pub async fn initialize_runner( }; }); - let mut storage_manager: StorageManager = NativeStorageManager::new(path).unwrap(); + let db_config = RollupDbConfig::default_in_path(path.to_path_buf()); + let mut storage_manager: TestStorageManager = NomtStorageManager::new(db_config).unwrap(); let finalized_header = da_service.get_last_finalized_block_header().await.unwrap(); let (_, ledger_state) = storage_manager diff --git a/crates/full-node/sov-stf-runner/tests/integration/runner_reorg_tests.rs b/crates/full-node/sov-stf-runner/tests/integration/runner_reorg_tests.rs index b4d6fba3f8..330310967d 100644 --- a/crates/full-node/sov-stf-runner/tests/integration/runner_reorg_tests.rs +++ b/crates/full-node/sov-stf-runner/tests/integration/runner_reorg_tests.rs @@ -5,8 +5,9 @@ use crate::helpers::runner_init::{ bootstrap_state_update_info, initialize_runner, HashStfRunner, InitVariant, }; use anyhow::Context; +use sov_db::config::RollupDbConfig; use sov_db::ledger_db::LedgerDb; -use sov_db::storage_manager::NativeStorageManager; +use sov_db::storage_manager::NomtStorageManager; use sov_metrics::MonitoringConfig; use sov_mock_da::storable::StorableMockDaService; use sov_mock_da::{ @@ -19,12 +20,11 @@ use sov_modules_api::{FullyBakedTx, StateTransitionFunction}; use sov_rollup_interface::node::da::{DaService, SlotData}; use sov_rollup_interface::node::SyncStatus; use sov_rollup_interface::storage::HierarchicalStorageManager; -use sov_state::storage::NativeStorage; -use sov_state::{ArrayWitness, ProverStorage, Storage, StorageRoot}; +use sov_state::{ArrayWitness, NativeStorage, Storage, StorageRoot}; use sov_stf_runner::StateTransitionRunner; use sov_stf_runner::{make_da_sync_state, DaServiceWithCachedFinalizedHeaders}; use sov_test_utils::storage::SimpleStorageManager; -use sov_test_utils::TEST_MOCK_DA_POLLING_INTERVAL; +use sov_test_utils::{TestStorage, TestStorageManager, TEST_MOCK_DA_POLLING_INTERVAL}; use tempfile::TempDir; use tokio::net::TcpListener; use tokio::sync::watch; @@ -65,8 +65,9 @@ async fn test_runner_with_background_da_service( let stf = HashStf::new(); - let mut storage_manager: crate::helpers::runner_init::StorageManager = - NativeStorageManager::new(tempdir.path())?; + let mut storage_manager = NomtStorageManager::new(RollupDbConfig::default_in_path( + tempdir.path().to_path_buf(), + ))?; let block = da_service.get_block_at(0).await?; let genesis_header = block.header().clone(); @@ -394,13 +395,13 @@ async fn check_runner( fn get_saved_root_hash( path: &std::path::Path, -) -> anyhow::Result as Storage>::Root>> { - let mut storage_manager = - NativeStorageManager::>::new(path).unwrap(); +) -> anyhow::Result::Root>> { + let config = RollupDbConfig::default_in_path(path.to_path_buf()); + let mut storage_manager = TestStorageManager::new(config)?; let mock_block_header = MockBlockHeader::from_height(1000000); let (stf_state, ledger_state) = storage_manager.create_state_for(&mock_block_header)?; - let ledger_db = LedgerDb::with_reader(ledger_state).unwrap(); + let ledger_db = LedgerDb::with_reader(ledger_state)?; ledger_db .get_head_slot()? @@ -411,7 +412,7 @@ fn get_saved_root_hash( fn get_expected_execution_hash_from( genesis_params: &[u8], blobs: Vec>, -) -> (StorageRoot, as Storage>::Root) { +) -> (StorageRoot, ::Root) { let blocks: Vec = blobs .into_iter() .enumerate() @@ -433,7 +434,7 @@ fn get_expected_execution_hash_from( fn get_result_from_blocks( genesis_params: &[u8], blocks: &[MockBlock], -) -> (StorageRoot, as Storage>::Root) { +) -> (StorageRoot, ::Root) { let mut storage_manager = SimpleStorageManager::new(); let storage = storage_manager.create_storage(); diff --git a/crates/fuzz/fuzz_targets/accounts_call.rs b/crates/fuzz/fuzz_targets/accounts_call.rs index 397ccc7039..617ed752aa 100644 --- a/crates/fuzz/fuzz_targets/accounts_call.rs +++ b/crates/fuzz/fuzz_targets/accounts_call.rs @@ -14,7 +14,7 @@ use sov_modules_api::{ Spec, StateCheckpoint, WorkingSet, }; use sov_test_utils::storage::SimpleStorageManager; -use sov_test_utils::TestPrivateKey; +use sov_test_utils::{TestPrivateKey, TestStorageSpec}; type S = sov_test_utils::TestSpec; // Check well-formed calls @@ -42,7 +42,7 @@ fuzz_target!( let rng = &mut StdRng::from_seed(seed); let mut seed = [0u8; 32]; - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleStorageManager::::new(); let storage = storage_manager.create_storage(); let mut state = StateCheckpoint::::new(storage, &MockKernel::::default(), None); diff --git a/crates/fuzz/fuzz_targets/accounts_call_random.rs b/crates/fuzz/fuzz_targets/accounts_call_random.rs index d93ea3e4a0..f6cfa6498c 100644 --- a/crates/fuzz/fuzz_targets/accounts_call_random.rs +++ b/crates/fuzz/fuzz_targets/accounts_call_random.rs @@ -6,12 +6,13 @@ use sov_accounts::{Accounts, CallMessage}; use sov_modules_api::capabilities::mocks::MockKernel; use sov_modules_api::{Context, Module, StateCheckpoint, WorkingSet}; use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::TestStorageSpec; type S = sov_test_utils::TestSpec; // Check arbitrary, random calls fuzz_target!(|input: (&[u8], Vec<(Context, CallMessage)>)| { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleStorageManager::::new(); let storage = storage_manager.create_storage(); let mut state = StateCheckpoint::new(storage, &MockKernel::::default(), None); diff --git a/crates/module-system/module-implementations/extern/hyperlane-solana-register/tests/integration/setup.rs b/crates/module-system/module-implementations/extern/hyperlane-solana-register/tests/integration/setup.rs index be68c62fea..6a1376eee6 100644 --- a/crates/module-system/module-implementations/extern/hyperlane-solana-register/tests/integration/setup.rs +++ b/crates/module-system/module-implementations/extern/hyperlane-solana-register/tests/integration/setup.rs @@ -16,11 +16,20 @@ use sov_modules_api::{ use sov_test_utils::runtime::genesis::zk::config::HighLevelZkGenesisConfig; use sov_test_utils::runtime::TestRunner; use sov_test_utils::{ - generate_runtime, AsUser, MockDaSpec, MockZkvm, TestUser, TransactionTestCase, + generate_runtime, AsUser, MockDaSpec, MockZkvm, MockZkvmCryptoSpec, TestStorage, TestUser, + TransactionTestCase, }; pub type Mailbox = RawMailbox>; -pub type S = ConfigurableSpec; +pub type S = ConfigurableSpec< + MockDaSpec, + MockZkvm, + MockZkvm, + Base58Address, + Native, + MockZkvmCryptoSpec, + TestStorage, +>; pub type RT = TestRuntime; type WarpRouteId = HexHash; diff --git a/crates/module-system/module-implementations/integration-tests/tests/concurrent_prover_storages.rs b/crates/module-system/module-implementations/integration-tests/tests/concurrent_prover_storages.rs index bc77869c21..9bae787b48 100644 --- a/crates/module-system/module-implementations/integration-tests/tests/concurrent_prover_storages.rs +++ b/crates/module-system/module-implementations/integration-tests/tests/concurrent_prover_storages.rs @@ -7,62 +7,62 @@ use sov_state::{ }; use sov_test_utils::storage::{ ForklessStorageManager, NativeStorageManager, NomtStorageManager, NonCommitingStorageManager, - SimpleNomtStorageManager, SimpleStorageManager, + SimpleJmtStorageManager, SimpleStorageManager, }; -use sov_test_utils::{TestHasher, TestNomtSpec, TestSpec}; +use sov_test_utils::{TestHasher, TestJmtSpec, TestSpec}; #[test] fn jmt_concurrent_prover_storages() { - let storage_manager = SimpleStorageManager::new(); - concurrent_prover_storages::(storage_manager); + let storage_manager = SimpleJmtStorageManager::new(); + concurrent_prover_storages::(storage_manager); } #[test] fn jmt_concurrent_prover_in_memory_storages() { let storage_manager = NonCommitingStorageManager::, _>::new(); - concurrent_prover_storages::(storage_manager); + concurrent_prover_storages::(storage_manager); } #[test] fn nomt_concurrent_prover_storages() { - let mut storage_manager = SimpleNomtStorageManager::new(); + let mut storage_manager = SimpleStorageManager::new(); storage_manager.set_strict_mode(false); - concurrent_prover_storages::(storage_manager); + concurrent_prover_storages::(storage_manager); } #[test] fn nomt_concurrent_prover_in_memory_storages() { let storage_manager = NonCommitingStorageManager::, _>::new(); - concurrent_prover_storages::(storage_manager); + concurrent_prover_storages::(storage_manager); } #[test] fn jmt_node_sequencer_concurrent_state_update() { - let storage_manager = SimpleStorageManager::new(); - node_sequencer_compute_state_update_concurrency::(storage_manager); + let storage_manager = SimpleJmtStorageManager::new(); + node_sequencer_compute_state_update_concurrency::(storage_manager); } #[test] fn jmt_node_sequencer_concurrent_state_update_in_memory() { let storage_manager = NonCommitingStorageManager::, _>::new(); - node_sequencer_compute_state_update_concurrency::(storage_manager); + node_sequencer_compute_state_update_concurrency::(storage_manager); } #[test] fn nomt_node_sequencer_concurrent_state_update() { - let mut storage_manager = SimpleNomtStorageManager::new(); + let mut storage_manager = SimpleStorageManager::new(); storage_manager.set_strict_mode(false); - node_sequencer_compute_state_update_concurrency::(storage_manager); + node_sequencer_compute_state_update_concurrency::(storage_manager); } #[test] fn nomt_node_sequencer_concurrent_state_update_in_memory() { let storage_manager = NonCommitingStorageManager::, _>::new(); - node_sequencer_compute_state_update_concurrency::(storage_manager); + node_sequencer_compute_state_update_concurrency::(storage_manager); } /// # Description diff --git a/crates/module-system/module-implementations/integration-tests/tests/stf_blueprint/operator/auth_eip712.rs b/crates/module-system/module-implementations/integration-tests/tests/stf_blueprint/operator/auth_eip712.rs index 891c77bd91..cfdeedc999 100644 --- a/crates/module-system/module-implementations/integration-tests/tests/stf_blueprint/operator/auth_eip712.rs +++ b/crates/module-system/module-implementations/integration-tests/tests/stf_blueprint/operator/auth_eip712.rs @@ -21,11 +21,18 @@ use sov_rollup_interface::stf::{TxEffect, TxReceiptContents}; use sov_test_utils::runtime::genesis::optimistic::HighLevelOptimisticGenesisConfig; use sov_test_utils::runtime::{TestRunner, ValueSetter}; use sov_test_utils::TransactionTestCase; -use sov_test_utils::{generate_runtime, EncodeCall, TestUser, TEST_DEFAULT_MAX_FEE}; +use sov_test_utils::{generate_runtime, EncodeCall, TestStorage, TestUser, TEST_DEFAULT_MAX_FEE}; use sov_value_setter::CallMessage; -type TestSpec = - ConfigurableSpec; +type TestSpec = ConfigurableSpec< + MockDaSpec, + MockZkvm, + MockZkvm, + EthereumAddress, + Native, + EvmCryptoSpec, + TestStorage, +>; type S = TestSpec; type TestPrivateKey = <::CryptoSpec as CryptoSpec>::PrivateKey; diff --git a/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/attestation_processing.rs b/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/attestation_processing.rs index 5c269832e6..9d7753b517 100644 --- a/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/attestation_processing.rs +++ b/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/attestation_processing.rs @@ -16,6 +16,7 @@ use crate::helpers::{ }; #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_process_valid_attestation() { let nb_tests = 3; let (mut runner, genesis_attester, _, other_user) = setup(); @@ -63,6 +64,7 @@ fn test_process_valid_attestation() { } #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_burn_on_invalid_attestation() { let (mut runner, genesis_attester, _, other_user) = setup(); diff --git a/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/challenger.rs b/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/challenger.rs index 1d49afb0e4..ef37430316 100644 --- a/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/challenger.rs +++ b/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/challenger.rs @@ -145,6 +145,7 @@ fn setup_with_wrong_attestation() -> ( /// This tests the happy path of challenge processing. #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_valid_challenge() -> Result<(), Infallible> { let (mut runner, _, bonded_challenger, expected_reward) = setup_with_wrong_attestation(); let bonded_challenger_address = bonded_challenger.user_info.address(); @@ -257,6 +258,7 @@ fn test_invalid_challenge_helper( } #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_invalid_challenge_initial_state_root() { let (mut runner, _, bonded_challenger, expected_reward) = setup_with_wrong_attestation(); let bonded_challenger_address = bonded_challenger.user_info.address(); @@ -283,7 +285,7 @@ fn test_invalid_challenge_initial_state_root() { } #[test] - +#[ignore = "NOMT does not support opening proof for archival state"] fn test_invalid_challenge_transition() { let (mut runner, _, bonded_challenger, expected_reward) = setup_with_wrong_attestation(); let bonded_challenger_address = bonded_challenger.user_info.address(); @@ -310,6 +312,7 @@ fn test_invalid_challenge_transition() { } #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_invalid_challenge_proof() { let (mut runner, _, bonded_challenger, expected_reward) = setup_with_wrong_attestation(); let bonded_challenger_address = bonded_challenger.user_info.address(); diff --git a/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/invariant.rs b/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/invariant.rs index cb2f3151a0..53bdfb0ecc 100644 --- a/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/invariant.rs +++ b/crates/module-system/module-implementations/sov-attester-incentives/tests/integration/invariant.rs @@ -88,6 +88,7 @@ fn setup_invariant_tests() -> (TestRunner, TestAttester, u64) { /// The attesters need to publish attestations for slots above `MAX_ATTESTED_HEIGHT - ROLLUP_FINALITY_PERIOD`. #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_cannot_attest_below_max_attested_height() { let (mut runner, genesis_attester, expected_max_attested_height) = setup_invariant_tests(); @@ -133,6 +134,7 @@ fn test_cannot_attest_below_max_attested_height() { /// The attesters need to publish attestations for slots below `MAX_ATTESTED_HEIGHT + 1`. #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_cannot_attest_above_max_attested_height_plus_one() { let (mut runner, genesis_attester, expected_max_attested_height) = setup_invariant_tests(); @@ -166,6 +168,7 @@ fn test_cannot_attest_above_max_attested_height_plus_one() { /// Test that the attesters can publish attestations for slots within the range `MAX_ATTESTED_HEIGHT - ROLLUP_FINALITY_PERIOD` to `MAX_ATTESTED_HEIGHT + 1`. /// If attesters publish attestations in the range `MAX_ATTESTED_HEIGHT - ROLLUP_FINALITY_PERIOD + 1` to `MAX_ATTESTED_HEIGHT`, the attestations are valid but the max attested height is not updated. #[test] +#[ignore = "NOMT does not support opening proof for archival state"] fn test_can_attest_within_allowed_range() { let (mut runner, genesis_attester, max_attested_height) = setup_invariant_tests(); // Now try to attest every non-finalized slot again, diff --git a/crates/module-system/module-implementations/sov-evm/tests/integration/runtime.rs b/crates/module-system/module-implementations/sov-evm/tests/integration/runtime.rs index 15e7cae93f..8fc0dc3ef4 100644 --- a/crates/module-system/module-implementations/sov-evm/tests/integration/runtime.rs +++ b/crates/module-system/module-implementations/sov-evm/tests/integration/runtime.rs @@ -6,9 +6,17 @@ use sov_modules_api::sov_universal_wallet::schema::UniversalWallet; use sov_modules_api::transaction::Transaction; use sov_modules_api::{RawTx, Spec}; use sov_rollup_interface::execution_mode::Native; -use sov_test_utils::{generate_runtime, MockDaSpec, MockZkvm}; +use sov_test_utils::{generate_runtime, MockDaSpec, MockZkvm, MockZkvmCryptoSpec, TestStorage}; -type EvmTestSpec = ConfigurableSpec; +type EvmTestSpec = ConfigurableSpec< + MockDaSpec, + MockZkvm, + MockZkvm, + MultiAddressEvm, + Native, + MockZkvmCryptoSpec, + TestStorage, +>; generate_runtime! { name: TestRuntime, diff --git a/crates/module-system/module-implementations/sov-paymaster/tests/integration/utils.rs b/crates/module-system/module-implementations/sov-paymaster/tests/integration/utils.rs index 4e91eec1ac..7e4741e545 100644 --- a/crates/module-system/module-implementations/sov-paymaster/tests/integration/utils.rs +++ b/crates/module-system/module-implementations/sov-paymaster/tests/integration/utils.rs @@ -2,14 +2,16 @@ use std::collections::HashMap; use sov_modules_api::{Amount, CryptoSpec, PrivateKey, SafeVec, Spec}; use sov_paymaster::{PayeePolicy, PayerGenesisConfig, PaymasterConfig, PaymasterPolicyInitializer}; -use sov_state::{DefaultStorageSpec, ProverStorage}; +use sov_state::nomt::prover_storage::NomtProverStorage; +use sov_state::DefaultStorageSpec; use sov_test_utils::runtime::genesis::optimistic::HighLevelOptimisticGenesisConfig; use sov_test_utils::runtime::traits::MinimalGenesis; use sov_test_utils::runtime::{ Runtime, TestRunner, ValueSetter, ValueSetterCallMessage, ValueSetterConfig, }; use sov_test_utils::{ - AsUser, EncodeCall, MockDaSpec, TestSequencer, TestUser, TransactionTestCase, TransactionType, + AsUser, EncodeCall, MockDaSpec, MockHash, TestSequencer, TestUser, TransactionTestCase, + TransactionType, }; use crate::runtime::{GenesisConfig, PaymasterRuntime}; @@ -54,8 +56,9 @@ impl, S: Spec> DoValueSetterTx for TestRunner where RT: 'static + Runtime + MinimalGenesis + EncodeCall>, S: Spec< - Storage = ProverStorage< + Storage = NomtProverStorage< DefaultStorageSpec<<::CryptoSpec as CryptoSpec>::Hasher>, + MockHash, >, Da = MockDaSpec, >, diff --git a/crates/module-system/module-implementations/sov-revenue-share/Cargo.toml b/crates/module-system/module-implementations/sov-revenue-share/Cargo.toml index c7b09e5da6..6e1d6bf0a5 100644 --- a/crates/module-system/module-implementations/sov-revenue-share/Cargo.toml +++ b/crates/module-system/module-implementations/sov-revenue-share/Cargo.toml @@ -30,6 +30,7 @@ sov-rollup-interface = { workspace = true } sov-revenue-share = { path = ".", features = ["native"] } sov-test-utils = { workspace = true } sov-bank = { workspace = true, features = ["native"] } +sov-state = { workspace = true, features = ["native"] } strum = { workspace = true } serde_json = { workspace = true } sov-mock-da = { workspace = true } @@ -48,5 +49,6 @@ native = [ "sov-mock-da/native", "sov-mock-zkvm/native", "sov-rollup-interface/native", - "sov-sequencer-registry/native" + "sov-sequencer-registry/native", + "sov-state/native" ] diff --git a/crates/module-system/module-implementations/sov-revenue-share/tests/integration/revenue_share_tests.rs b/crates/module-system/module-implementations/sov-revenue-share/tests/integration/revenue_share_tests.rs index a0c8276f1c..03f34f9fc3 100644 --- a/crates/module-system/module-implementations/sov-revenue-share/tests/integration/revenue_share_tests.rs +++ b/crates/module-system/module-implementations/sov-revenue-share/tests/integration/revenue_share_tests.rs @@ -10,12 +10,21 @@ use sov_modules_api::{Context, CryptoSpec, Module, ModuleInfo, SequencerType, Sp use sov_revenue_share::{CallMessage as RevenueShareCallMessage, RevenueShare}; use sov_test_utils::runtime::genesis::optimistic::HighLevelOptimisticGenesisConfig; use sov_test_utils::runtime::TestRunner; -use sov_test_utils::{generate_optimistic_runtime, AsUser, TestUser, TransactionTestCase}; +use sov_test_utils::{ + generate_optimistic_runtime, AsUser, TestStorage, TestUser, TransactionTestCase, +}; use crate::test_helpers::TestCryptoSpec; -type TestSpec = - ConfigurableSpec; +type TestSpec = ConfigurableSpec< + MockDaSpec, + MockZkvm, + MockZkvm, + EthereumAddress, + Native, + TestCryptoSpec, + TestStorage, +>; type S = TestSpec; diff --git a/crates/module-system/module-implementations/sov-uniqueness/tests/integration/runtime.rs b/crates/module-system/module-implementations/sov-uniqueness/tests/integration/runtime.rs index 036b1e8dfc..65c73d2d6e 100644 --- a/crates/module-system/module-implementations/sov-uniqueness/tests/integration/runtime.rs +++ b/crates/module-system/module-implementations/sov-uniqueness/tests/integration/runtime.rs @@ -6,10 +6,18 @@ use sov_modules_api::sov_universal_wallet::schema::UniversalWallet; use sov_modules_api::transaction::Transaction; use sov_modules_api::{RawTx, Spec}; use sov_rollup_interface::execution_mode::Native; -use sov_test_utils::{generate_runtime, MockDaSpec, MockZkvm}; +use sov_test_utils::{generate_runtime, MockDaSpec, MockZkvm, MockZkvmCryptoSpec, TestStorage}; use sov_value_setter::ValueSetter; -type EvmTestSpec = ConfigurableSpec; +type EvmTestSpec = ConfigurableSpec< + MockDaSpec, + MockZkvm, + MockZkvm, + MultiAddressEvm, + Native, + MockZkvmCryptoSpec, + TestStorage, +>; generate_runtime! { name: TestNonceRuntime, diff --git a/crates/module-system/sov-modules-api/src/containers/mod.rs b/crates/module-system/sov-modules-api/src/containers/mod.rs index 878f6f5186..cf4ee82f3f 100644 --- a/crates/module-system/sov-modules-api/src/containers/mod.rs +++ b/crates/module-system/sov-modules-api/src/containers/mod.rs @@ -238,7 +238,7 @@ mod test { use sov_state::{ DefaultStorageSpec, NativeStorage, ProverStorage, SlotKey, SlotValue, Storage, }; - use sov_test_utils::storage::SimpleStorageManager; + use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::validate_and_materialize; use crate::capabilities::mocks::MockKernel; @@ -283,7 +283,7 @@ mod test { #[test] fn test_jmt_storage() -> anyhow::Result<()> { - let mut storage_manager = SimpleStorageManager::::new(); + let mut storage_manager = SimpleJmtStorageManager::::new(); let mut prev_root = as Storage>::PRE_GENESIS_ROOT; let tests = create_tests(); { @@ -332,7 +332,7 @@ mod test { #[test] fn test_restart_lifecycle() -> anyhow::Result<()> { - let mut storage_manager = SimpleStorageManager::new(); + let mut storage_manager = SimpleJmtStorageManager::new(); { let storage = storage_manager.create_storage(); assert!(storage.is_empty()); diff --git a/crates/module-system/sov-modules-api/src/containers/vec.rs b/crates/module-system/sov-modules-api/src/containers/vec.rs index 2ec1160311..2dcd1fc64f 100644 --- a/crates/module-system/sov-modules-api/src/containers/vec.rs +++ b/crates/module-system/sov-modules-api/src/containers/vec.rs @@ -453,7 +453,7 @@ mod test { use sov_rollup_interface::execution_mode::Native; use sov_state::codec::BorshCodec; use sov_state::Prefix; - use sov_test_utils::storage::SimpleStorageManager; + use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::MockDaSpec; use unwrap_infallible::UnwrapInfallible; @@ -465,7 +465,7 @@ mod test { #[test] fn double_ended_iterator_from_back() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let mut state: StateCheckpoint = StateCheckpoint::new(storage, &MockKernel::::default(), None); @@ -487,7 +487,7 @@ mod test { #[test] // FIXME: this test should not panic. This is a repro for . fn double_ended_iterator_meet_in_the_middle() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let mut state: StateCheckpoint = StateCheckpoint::new(storage, &MockKernel::::default(), None); @@ -510,7 +510,7 @@ mod test { #[test] fn test_state_vec() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let mut state: StateCheckpoint = StateCheckpoint::new(storage, &MockKernel::::default(), None); diff --git a/crates/module-system/sov-modules-api/src/containers/versioned_value.rs b/crates/module-system/sov-modules-api/src/containers/versioned_value.rs index 32a3031aa5..05955fa241 100644 --- a/crates/module-system/sov-modules-api/src/containers/versioned_value.rs +++ b/crates/module-system/sov-modules-api/src/containers/versioned_value.rs @@ -129,7 +129,7 @@ mod tests { use sov_rollup_interface::common::IntoSlotNumber; use sov_rollup_interface::execution_mode::Native; use sov_state::{BorshCodec, Prefix}; - use sov_test_utils::storage::SimpleStorageManager; + use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::MockDaSpec; use unwrap_infallible::UnwrapInfallible; @@ -142,7 +142,7 @@ mod tests { #[test] fn test_kernel_state_value_as_value() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let kernel = MockKernel::::new(4, 1); @@ -176,7 +176,7 @@ mod tests { #[test] fn test_kernel_state_value_as_map() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let kernel = MockKernel::::new(4, 1); diff --git a/crates/module-system/sov-modules-api/src/default_spec.rs b/crates/module-system/sov-modules-api/src/default_spec.rs index 1b071c60cf..163d21b4db 100644 --- a/crates/module-system/sov-modules-api/src/default_spec.rs +++ b/crates/module-system/sov-modules-api/src/default_spec.rs @@ -3,6 +3,8 @@ use sov_rollup_interface::da::DaSpec; #[cfg(feature = "native")] use sov_rollup_interface::execution_mode::{Native, WitnessGeneration}; use sov_rollup_interface::zk::{CryptoSpec, ZkVerifier, Zkvm}; +#[cfg(feature = "native")] +use sov_state::nomt::prover_storage::NomtProverStorage; use sov_state::DefaultStorageSpec; use crate::higher_kinded_types::{Generic, HigherKindedHelper}; @@ -133,3 +135,132 @@ where type CryptoSpec = ::CryptoSpec; } + +/// A default implementation of the [`Spec`] trait using NOMT storage. +/// Similar to [`DefaultSpec`] but uses [`NomtProverStorage`] instead of [`sov_state::ProverStorage`]. +#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))] +#[derive( + Default, + serde::Serialize, + serde::Deserialize, + BorshDeserialize, + BorshSerialize, + schemars::JsonSchema, +)] +#[serde(bound = "")] +pub struct DefaultNomtSpec( + std::marker::PhantomData<(Da, InnerZkvm, OuterZkvm, Mode)>, +); + +impl Generic + for DefaultNomtSpec +{ + type With = DefaultNomtSpec; +} + +impl HigherKindedHelper + for DefaultNomtSpec +{ + type Inner = M; +} + +mod nomt_default_impls { + use sov_rollup_interface::execution_mode::ExecutionMode; + + use super::DefaultNomtSpec; + + impl Clone + for DefaultNomtSpec + { + fn clone(&self) -> Self { + Self(std::marker::PhantomData) + } + } + + impl PartialEq + for DefaultNomtSpec + { + fn eq(&self, _other: &Self) -> bool { + true + } + } + + impl Eq + for DefaultNomtSpec + { + } + + impl core::fmt::Debug + for DefaultNomtSpec + { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + write!( + f, + "DefaultNomtSpec<{}>", + std::any::type_name::<(Da, InnerZkvm, OuterZkvm, Mode)>() + ) + } + } +} + +#[cfg(feature = "native")] +impl Spec + for DefaultNomtSpec +where + ::CryptoSpec: crate::CryptoSpecExt, +{ + type Da = Da; + type Address = Address; + type Gas = GasUnit<2>; + + type Storage = NomtProverStorage< + DefaultStorageSpec<::Hasher>, + Da::SlotHash, + >; + + type InnerZkvm = InnerZkvm; + type OuterZkvm = OuterZkvm; + + type CryptoSpec = ::CryptoSpec; +} + +#[cfg(feature = "native")] +impl Spec + for DefaultNomtSpec +where + ::CryptoSpec: crate::CryptoSpecExt, +{ + type Da = Da; + type Address = Address; + type Gas = GasUnit<2>; + + type Storage = NomtProverStorage< + DefaultStorageSpec<::Hasher>, + Da::SlotHash, + >; + + type InnerZkvm = InnerZkvm; + type OuterZkvm = OuterZkvm; + + type CryptoSpec = ::CryptoSpec; +} + +#[cfg(any(not(feature = "native"), feature = "test-utils"))] +impl Spec + for DefaultNomtSpec +where + ::CryptoSpec: crate::CryptoSpecExt, +{ + type Da = Da; + type Address = Address; + type Gas = GasUnit<2>; + + type Storage = sov_state::nomt::zk_storage::NomtVerifierStorage< + DefaultStorageSpec<::Hasher>, + >; + + type InnerZkvm = InnerZkvm; + type OuterZkvm = OuterZkvm; + + type CryptoSpec = ::CryptoSpec; +} diff --git a/crates/module-system/sov-modules-api/src/gas/tests/metered_utils.rs b/crates/module-system/sov-modules-api/src/gas/tests/metered_utils.rs index 2bbca12b9f..90a0ac8cba 100644 --- a/crates/module-system/sov-modules-api/src/gas/tests/metered_utils.rs +++ b/crates/module-system/sov-modules-api/src/gas/tests/metered_utils.rs @@ -5,7 +5,7 @@ use sov_mock_zkvm::crypto::Ed25519Signature; use sov_mock_zkvm::MockZkvm; use sov_rollup_interface::crypto::PrivateKey; use sov_rollup_interface::execution_mode::Native; -use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::MockDaSpec; use crate::default_spec::DefaultSpec; @@ -30,7 +30,7 @@ fn create_working_set( remaining_funds: Amount, gas_price: &<::Gas as Gas>::Price, ) -> WorkingSet> { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); WorkingSet::new_with_gas_meter(storage, remaining_funds, gas_price) } diff --git a/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/pre_exec_working_set.rs b/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/pre_exec_working_set.rs index c9b513c491..afbb0a32aa 100644 --- a/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/pre_exec_working_set.rs +++ b/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/pre_exec_working_set.rs @@ -129,7 +129,7 @@ mod tests { use sov_state::namespaces::User; use sov_state::SlotValueFromCodec; use sov_state::{SlotKey, SlotValue}; - use sov_test_utils::storage::SimpleStorageManager; + use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::{MockDaSpec, MockZkvm}; use crate::capabilities::mocks::MockKernel; @@ -152,7 +152,7 @@ mod tests { #[test] fn test_pre_exec_ws() { let codec = BcsCodec {}; - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let kernel: MockKernel = MockKernel::new(4, 1); diff --git a/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/tx_scratchpad.rs b/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/tx_scratchpad.rs index 0b9771dcf1..f7bd4e69b1 100644 --- a/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/tx_scratchpad.rs +++ b/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/tx_scratchpad.rs @@ -187,7 +187,7 @@ mod tests { use sov_state::codec::BcsCodec; use sov_state::SlotValueFromCodec; use sov_state::{Namespace, NodeLeafAndMaybeValue, SlotKey, SlotValue}; - use sov_test_utils::storage::SimpleStorageManager; + use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::TestHasher; use sov_test_utils::{MockDaSpec, MockZkvm}; @@ -207,7 +207,7 @@ mod tests { } fn test_cache_warmup_changeset_with_namespace(namespace: Namespace) { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let mut worker_scratchpad = create_srcratchpad::(storage.clone()); @@ -248,7 +248,7 @@ mod tests { } fn test_cache_warmup_overrides_with_namespace(namespace: Namespace) { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let mut worker_scratchpad = create_srcratchpad::(storage.clone()); diff --git a/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/working_set.rs b/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/working_set.rs index 8b941c98d1..3c48040f51 100644 --- a/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/working_set.rs +++ b/crates/module-system/sov-modules-api/src/state/accessors/scratchpad/working_set.rs @@ -321,7 +321,7 @@ mod tests { use sov_state::namespaces::User; use sov_state::{Kernel, SlotKey, SlotValue}; use sov_state::{SlotKeyFromCodec, SlotValueFromCodec}; - use sov_test_utils::storage::SimpleStorageManager; + use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::{MockDaSpec, MockZkvm}; use crate::capabilities::mocks::MockKernel; @@ -334,7 +334,7 @@ mod tests { #[test] fn test_workingset_get() { let codec = BcsCodec {}; - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let prefix = sov_state::Prefix::new(1, 2); @@ -352,7 +352,7 @@ mod tests { #[test] fn test_kernel_workingset_get() { let codec = BcsCodec {}; - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let prefix = sov_state::Prefix::new(1, 2); diff --git a/crates/module-system/sov-modules-api/src/state/accessors/tests.rs b/crates/module-system/sov-modules-api/src/state/accessors/tests.rs index e0b5801794..747b77a6ae 100644 --- a/crates/module-system/sov-modules-api/src/state/accessors/tests.rs +++ b/crates/module-system/sov-modules-api/src/state/accessors/tests.rs @@ -5,7 +5,7 @@ use sov_state::{ AccessSize, ArrayWitness, BorshCodec, IsValueCached, Namespace, OrderedReadsAndWrites, Prefix, StateAccesses, Storage, ZkStorage, }; -use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::{validate_and_materialize, MockDaSpec, TestStorageSpec}; use super::seal::UniversalStateAccessor; @@ -25,11 +25,11 @@ const NAMESPACE: Namespace = Namespace::User; fn create_storage_manager( initial_values: Vec<(Vec, u64)>, ) -> ( - SimpleStorageManager, + SimpleJmtStorageManager, <::Storage as Storage>::Root, ) /*ProverStorage>*/ { - let mut storage_manager = SimpleStorageManager::new(); + let mut storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let (root, genesis_change_set) = validate_and_materialize( diff --git a/crates/module-system/sov-modules-api/src/state/tests.rs b/crates/module-system/sov-modules-api/src/state/tests.rs index 247675e60f..275d0784ab 100644 --- a/crates/module-system/sov-modules-api/src/state/tests.rs +++ b/crates/module-system/sov-modules-api/src/state/tests.rs @@ -1,7 +1,7 @@ use sov_mock_zkvm::MockZkvm; use sov_rollup_interface::execution_mode::Native; use sov_state::{SlotKey, SlotValue, User}; -use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::MockDaSpec; use super::traits::StateWriter; @@ -14,7 +14,7 @@ fn create_working_set( remaining_funds: Amount, gas_price: &<::Gas as Gas>::Price, ) -> WorkingSet { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); WorkingSet::new_with_gas_meter(storage, remaining_funds, gas_price) } diff --git a/crates/module-system/sov-modules-api/tests/integration/proof_tests.rs b/crates/module-system/sov-modules-api/tests/integration/proof_tests.rs index e18bc969d5..fbf9a7d0bf 100644 --- a/crates/module-system/sov-modules-api/tests/integration/proof_tests.rs +++ b/crates/module-system/sov-modules-api/tests/integration/proof_tests.rs @@ -8,6 +8,14 @@ use sov_test_utils::storage::SimpleStorageManager; use sov_test_utils::validate_and_materialize; use unwrap_infallible::UnwrapInfallible; +/// Helper to write a dummy value to the kernel namespace. +/// NOMT requires both user and kernel namespaces to be written together. +fn write_kernel_marker(state: &mut StateCheckpoint) { + let mut kernel_val: KernelStateValue = + KernelStateValue::with_codec(Prefix::new(255, 0), BorshCodec); + kernel_val.set(&0u8, state).unwrap_infallible(); +} + type S = sov_test_utils::TestSpec; #[allow(clippy::type_complexity)] @@ -25,6 +33,7 @@ fn make_user_map_proof( let mut state = StateCheckpoint::::new(storage.clone(), &kernel, None); let mut map = StateMap::with_codec(Prefix::new(0, 0), BorshCodec); map.set(&key, &value, &mut state).unwrap_infallible(); + write_kernel_marker(&mut state); let (cache_log, _, witness) = state.freeze(); @@ -64,6 +73,7 @@ fn make_user_value_proof( let mut state = StateCheckpoint::::new(storage.clone(), &MockKernel::::default(), None); let mut state_val = StateValue::with_codec(Prefix::new(0, 0), BorshCodec); state_val.set(&value, &mut state).unwrap_infallible(); + write_kernel_marker(&mut state); let (cache_log, _, witness) = state.freeze(); @@ -175,6 +185,7 @@ mod value { } #[test] +#[ignore = "NOMT does not support archival proof generation - proofs are always generated against the current state"] fn test_archival_proof_gen() { let mut kernel = MockKernel::::default(); let mut storage_manager = SimpleStorageManager::new(); @@ -200,6 +211,7 @@ fn test_archival_proof_gen() { } else { state_val.delete(&mut state).unwrap_infallible(); } + write_kernel_marker(&mut state); let (cache_log, _, witness) = state.freeze(); diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/archival.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/archival.rs index f2107eba7f..d63b4dc160 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/archival.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/archival.rs @@ -7,21 +7,21 @@ use sov_modules_api::{ ApiStateAccessor, ConcurrentStateCheckpoint, KernelStateValue, StateCheckpoint, }; use sov_state::{BorshCodec, Prefix}; -use sov_test_utils::storage::{SimpleNomtStorageManager, SimpleStorageManager}; -use sov_test_utils::TestNomtSpec; +use sov_test_utils::storage::{SimpleJmtStorageManager, SimpleStorageManager}; +use sov_test_utils::{TestJmtSpec, TestSpec}; use crate::state_tests::*; #[test] fn test_jmt_archival_state_updates_correctly() -> Result<(), Infallible> { - let storage_manager = SimpleStorageManager::new(); - archival_state_updates_correctly::(storage_manager) + let storage_manager = SimpleJmtStorageManager::new(); + archival_state_updates_correctly::(storage_manager) } #[test] fn test_nomt_archival_state_updates_correctly() -> Result<(), Infallible> { - let storage_manager = SimpleNomtStorageManager::new(); - archival_state_updates_correctly::(storage_manager) + let storage_manager = SimpleStorageManager::new(); + archival_state_updates_correctly::(storage_manager) } /// Tests that the archival state is correctly retrieved from the DB and updates to the head state don't interfere diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/jmt.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/jmt.rs index 0550642a95..6080b23777 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/jmt.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/jmt.rs @@ -1,13 +1,13 @@ // This is a reference point to validate that there are no errors in test use sov_state::ZkStorage; -use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::storage::SimpleJmtStorageManager; use crate::state_tests::compute_state_update::{run_test, TestCase}; use crate::state_tests::StorageSpec; fn run_jmt_test(test_case: TestCase) { - let mut sm = SimpleStorageManager::new(); + let mut sm = SimpleJmtStorageManager::new(); sm.genesis(); run_test(test_case, sm, ZkStorage::::new()); } diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/nomt.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/nomt.rs index 88ca768c33..44ab7af92c 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/nomt.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/compute_state_update/nomt.rs @@ -1,13 +1,13 @@ use sov_state::nomt::zk_storage::NomtVerifierStorage; use sov_state::{ArrayWitness, NodeLeaf, SlotKey, SlotValue, Storage}; -use sov_test_utils::storage::SimpleNomtStorageManager; +use sov_test_utils::storage::SimpleStorageManager; use sov_test_utils::TestHasher; use crate::state_tests::compute_state_update::{run_test, ForklessStorageManager, TestCase}; use crate::state_tests::StorageSpec; fn run_nomt_test(test_case: TestCase) { - let sm = SimpleNomtStorageManager::new(); + let sm = SimpleStorageManager::new(); run_test(test_case, sm, NomtVerifierStorage::::new()); } @@ -90,7 +90,7 @@ fn test_modified_read_to_none() { /// - we don't test extra or missing writes, because all writes originate from within ZKVM /// - we don't test extra proof for reads, because zk guest only cares about reads it made. fn check_malicious_case(native_case: TestCase, zk_case: TestCase, expected_error: &str) { - let mut sm = SimpleNomtStorageManager::new(); + let mut sm = SimpleStorageManager::new(); for (native_state_accesses, zk_state_accesses) in native_case .rounds diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/mod.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/mod.rs index 04d80a9b8f..9bae4f3b23 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/mod.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/mod.rs @@ -10,17 +10,18 @@ mod structs; use sov_mock_da::MockDaSpec; use sov_mock_zkvm::MockZkvm; use sov_modules_api::capabilities::mocks::MockKernel; -use sov_modules_api::{ - execution_mode, CryptoSpec, KernelStateValue, Spec, StateCheckpoint, Storage, -}; -use sov_test_utils::storage::{ForklessStorageManager, SimpleStorageManager}; -use sov_test_utils::{validate_and_materialize, TestSpec}; +use sov_modules_api::{execution_mode, KernelStateValue, Spec, StateCheckpoint, Storage}; +use sov_test_utils::storage::ForklessStorageManager; +use sov_test_utils::{validate_and_materialize, TestSpec, TestStorageSpec}; use unwrap_infallible::UnwrapInfallible; -pub type Zk = - sov_modules_api::default_spec::DefaultSpec; -pub type TestHasher = <::CryptoSpec as CryptoSpec>::Hasher; -pub type StorageSpec = sov_state::DefaultStorageSpec; +pub type Zk = sov_modules_api::default_spec::DefaultNomtSpec< + MockDaSpec, + MockZkvm, + MockZkvm, + execution_mode::Zk, +>; +pub type StorageSpec = TestStorageSpec; pub fn commit_to_storage( state: StateCheckpoint, diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/namespaces.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/namespaces.rs index e53432da20..1d8e36146a 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/namespaces.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/namespaces.rs @@ -6,16 +6,16 @@ use sov_modules_api::{ KernelStateValue, Spec, StateCheckpoint, StateMap, StateValue, VersionedStateValue, }; use sov_state::{BorshCodec, Prefix, ProvableNamespace, StateRoot}; -use sov_test_utils::storage::{SimpleNomtStorageManager, SimpleStorageManager}; -use sov_test_utils::{TestNomtSpec, TestSpec}; +use sov_test_utils::storage::{SimpleJmtStorageManager, SimpleStorageManager}; +use sov_test_utils::{TestJmtSpec, TestSpec}; use crate::state_tests::{commit_to_storage, ForklessStorageManager}; #[test] fn test_jmt_state_value_user_namespace() -> Result<(), Infallible> { - let mut storage_manager = SimpleStorageManager::new(); + let mut storage_manager = SimpleJmtStorageManager::new(); storage_manager.genesis(); - test_state_value_user_namespace::(storage_manager) + test_state_value_user_namespace::(storage_manager) } // TODO: Do we want to unify these 2 tests? The only differ by value passed. Probably @@ -60,14 +60,14 @@ where #[test] fn test_jmt_state_value_kernel_namespace() -> Result<(), Infallible> { - let storage_manager = SimpleStorageManager::new(); - test_state_value_kernel_namespace::(storage_manager) + let storage_manager = SimpleJmtStorageManager::new(); + test_state_value_kernel_namespace::(storage_manager) } #[test] fn test_nomt_state_value_kernel_namespace() -> Result<(), Infallible> { - let storage_manager = SimpleNomtStorageManager::new(); - test_state_value_kernel_namespace::(storage_manager) + let storage_manager = SimpleStorageManager::new(); + test_state_value_kernel_namespace::(storage_manager) } /// Test that the state values with a kernel working set get written to the kernel space @@ -113,8 +113,8 @@ where #[test] fn test_jmt_state_map_user_namespace() -> Result<(), Infallible> { - let storage_manager = SimpleStorageManager::new(); - test_state_map_user_namespace::(storage_manager) + let storage_manager = SimpleJmtStorageManager::new(); + test_state_map_user_namespace::(storage_manager) } /// Test that the state maps with a standard working set get written to the user space @@ -160,14 +160,14 @@ where #[test] fn test_jmt_versioned_state_value_kernel_namespace() -> Result<(), Infallible> { - let storage_manager = SimpleStorageManager::new(); - test_versioned_state_value_kernel_namespace::(storage_manager) + let storage_manager = SimpleJmtStorageManager::new(); + test_versioned_state_value_kernel_namespace::(storage_manager) } #[test] fn test_nomt_versioned_state_value_kernel_namespace() -> Result<(), Infallible> { - let storage_manager = SimpleNomtStorageManager::new(); - test_versioned_state_value_kernel_namespace::(storage_manager) + let storage_manager = SimpleStorageManager::new(); + test_versioned_state_value_kernel_namespace::(storage_manager) } /// Test that the kernel state maps with a kernel working set get written to the kernel space diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/structs.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/structs.rs index 436251ac48..64b0ca16d5 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/structs.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/structs.rs @@ -1,13 +1,21 @@ use std::convert::Infallible; +use crate::state_tests::*; use capabilities::mocks::MockKernel; use sov_modules_api::*; -use sov_state::{ - ArrayWitness, BorshCodec, Prefix, ProverStorage, StateAccesses, Storage, ZkStorage, -}; +use sov_state::nomt::zk_storage::NomtVerifierStorage; +use sov_state::{ArrayWitness, BorshCodec, Prefix, StateAccesses, Storage}; +use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::TestStorage; use unwrap_infallible::UnwrapInfallible; -use crate::state_tests::*; +/// Helper to write a dummy value to the kernel namespace. +/// NOMT requires both user and kernel namespaces to be written together. +fn write_kernel_marker(state: &mut StateCheckpoint) { + let mut kernel_val: KernelStateValue = + KernelStateValue::with_codec(Prefix::new(255, 0), BorshCodec); + kernel_val.set(&0u8, state).unwrap_infallible(); +} pub trait StateThing { type Value: core::fmt::Debug + Eq + PartialEq; @@ -180,11 +188,9 @@ const CONDITIONS: [Condition; 8] = [ ]; /// Creates thing and checks it with all condition combinations -pub fn test_state_thing>, St: StateThing>( - conditions: &[Condition], -) { +pub fn test_state_thing, St: StateThing>(conditions: &[Condition]) { let simple_storage_manager = SimpleStorageManager::new(); - let storage: ProverStorage = simple_storage_manager.create_storage(); + let storage = simple_storage_manager.create_storage(); let mut state = StateCheckpoint::::new(storage, &MockKernel::::default(), None); let mut thing = St::create(&mut state); let mut working_set = state.to_working_set_unmetered(); @@ -246,6 +252,7 @@ fn test_witness_round_trip() -> Result<(), Infallible> { state_value.set(&11, &mut state)?; let _ = state_value.get(&mut state); state_value.set(&22, &mut state)?; + write_kernel_marker(&mut state); let (cache_log, _, witness) = state.freeze(); let _ = validate_and_materialize(storage, cache_log, &witness, root) @@ -254,7 +261,7 @@ fn test_witness_round_trip() -> Result<(), Infallible> { }; { - let storage = ZkStorage::::new(); + let storage = NomtVerifierStorage::::new(); let mut state_checkpoint: StateCheckpoint = StateCheckpoint::with_witness( storage.clone(), witness, @@ -264,6 +271,7 @@ fn test_witness_round_trip() -> Result<(), Infallible> { state_value.set(&11, &mut state_checkpoint)?; let _ = state_value.get(&mut state_checkpoint); state_value.set(&22, &mut state_checkpoint)?; + write_kernel_marker(&mut state_checkpoint); let (cache_log, _, witness) = state_checkpoint.freeze(); let _ = validate_and_materialize(storage, cache_log, &witness, root) diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_mut_twice.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_mut_twice.rs index 992b515eeb..4cae082201 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_mut_twice.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_mut_twice.rs @@ -4,14 +4,14 @@ use sov_modules_api::capabilities::RollupHeight; use sov_modules_api::{StateCheckpoint, StateValue}; use sov_rollup_interface::execution_mode::Native; use sov_state::{BorshCodec, Prefix}; -use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::MockDaSpec; use unwrap_infallible::UnwrapInfallible; type TestSpec = sov_modules_api::default_spec::DefaultSpec; fn main() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let kernel = MockKernel::::new(4, 1); let mut state = StateCheckpoint::new(storage, &kernel, None); diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_while_borrowed_mut.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_while_borrowed_mut.rs index 24c8bc69a9..e012b16024 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_while_borrowed_mut.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_borrow_while_borrowed_mut.rs @@ -4,14 +4,14 @@ use sov_modules_api::capabilities::RollupHeight; use sov_modules_api::{StateCheckpoint, StateValue}; use sov_rollup_interface::execution_mode::Native; use sov_state::{BorshCodec, Prefix}; -use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::MockDaSpec; use unwrap_infallible::UnwrapInfallible; type TestSpec = sov_modules_api::default_spec::DefaultSpec; fn main() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let kernel = MockKernel::::new(4, 1); let mut state = StateCheckpoint::new(storage, &kernel, None); diff --git a/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_mutate_while_borrowed.rs b/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_mutate_while_borrowed.rs index 69e5513283..10a4c109a5 100644 --- a/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_mutate_while_borrowed.rs +++ b/crates/module-system/sov-modules-api/tests/integration/state_tests/trybuild/state_cannot_mutate_while_borrowed.rs @@ -4,14 +4,14 @@ use sov_modules_api::capabilities::RollupHeight; use sov_modules_api::{StateCheckpoint, StateValue}; use sov_rollup_interface::execution_mode::Native; use sov_state::{BorshCodec, Prefix}; -use sov_test_utils::storage::SimpleStorageManager; +use sov_test_utils::storage::SimpleJmtStorageManager; use sov_test_utils::MockDaSpec; use unwrap_infallible::UnwrapInfallible; type TestSpec = sov_modules_api::default_spec::DefaultSpec; fn main() { - let storage_manager = SimpleStorageManager::new(); + let storage_manager = SimpleJmtStorageManager::new(); let storage = storage_manager.create_storage(); let kernel = MockKernel::::new(4, 1); let mut state = StateCheckpoint::new(storage, &kernel, None); diff --git a/crates/module-system/sov-solana-offchain-auth/tests/integration/main.rs b/crates/module-system/sov-solana-offchain-auth/tests/integration/main.rs index 72b2ecd190..d7dcfd9f40 100644 --- a/crates/module-system/sov-solana-offchain-auth/tests/integration/main.rs +++ b/crates/module-system/sov-solana-offchain-auth/tests/integration/main.rs @@ -31,16 +31,15 @@ use sov_solana_offchain_auth::utils::make_preamble_for_message; use sov_solana_offchain_auth::{ SolanaOffchainAuthenticator, SolanaOffchainAuthenticatorInput, SolanaOffchainAuthenticatorTrait, }; -use sov_state::{DefaultStorageSpec, ProverStorage}; use sov_test_utils::runtime::genesis::optimistic::HighLevelOptimisticGenesisConfig; use sov_test_utils::runtime::{BankConfig, Runtime as _}; use sov_test_utils::test_rollup::StoragePath; use sov_test_utils::test_rollup::{GenesisSource, RollupBuilder, TestRollup}; use sov_test_utils::{ - generate_runtime, RtAgnosticBlueprint, TestUser, TEST_DEFAULT_GAS_LIMIT, TEST_DEFAULT_MAX_FEE, - TEST_DEFAULT_MAX_PRIORITY_FEE, + generate_runtime, RtAgnosticBlueprint, TestStorage, TestUser, TEST_DEFAULT_GAS_LIMIT, + TEST_DEFAULT_MAX_FEE, TEST_DEFAULT_MAX_PRIORITY_FEE, }; -use sov_test_utils::{MockDaSpec, MockZkvm, MockZkvmCryptoSpec, TestHasher, TestStorageSpec}; +use sov_test_utils::{MockDaSpec, MockZkvm, MockZkvmCryptoSpec}; use sov_value_setter::ValueSetterConfig; use tempfile::tempdir; @@ -55,7 +54,7 @@ pub type SolanaTestSpec = ConfigurableSpec< Base58Address, // Use Base58Address instead of the default Address Native, MockZkvmCryptoSpec, - ProverStorage>, + TestStorage, >; /// An arbitrary base58 address. diff --git a/crates/module-system/sov-state/src/nomt/mod.rs b/crates/module-system/sov-state/src/nomt/mod.rs index 10c3f40ac4..8e63589474 100644 --- a/crates/module-system/sov-state/src/nomt/mod.rs +++ b/crates/module-system/sov-state/src/nomt/mod.rs @@ -1,5 +1,99 @@ //! Storage implementation based on [Nearly Optimal Merkle Tree(NOMT)](https://github.com/thrumdev/nomt/) implementation. +use borsh::{BorshDeserialize, BorshSerialize}; +use nomt_core::hasher::BinaryHasher; +use nomt_core::proof::MultiProof; +use nomt_core::trie::{KeyPath, LeafData, Node, ValueHash}; +use serde::Serialize; +use sov_rollup_interface::reexports::digest::Digest; + +use crate::{MerkleProofSpec, SlotKey, SlotValue, StateRoot, StorageProof, StorageRoot}; + #[cfg(feature = "native")] pub mod prover_storage; pub mod zk_storage; + +/// Verifies a storage proof against a state root and returns the key-value pair. +/// +/// This is shared logic used by both Nomt-based storages. +pub(crate) fn verify_storage_proof( + state_root: StorageRoot, + proof: StorageProof, +) -> anyhow::Result<(SlotKey, Option)> { + let StorageProof { + key, + value, + proof: multi_proof, + namespace, + } = proof; + let root_node: Node = state_root.namespace_root(namespace); + + let verified = + nomt_core::proof::verify_multi_proof::>(&multi_proof.0, root_node) + .map_err(|e| anyhow::anyhow!("Failed to verify proof: {:?}", e))?; + + let key_path: KeyPath = S::Hasher::digest(key.as_ref()).into(); + + match &value { + None => { + if !verified + .confirm_nonexistence(&key_path) + .map_err(|e| anyhow::anyhow!("Key out of scope: {:?}", e))? + { + anyhow::bail!("Failed to verify non-existence of key"); + } + } + Some(slot_value) => { + let authenticated_write = slot_value.combine_val_hash_and_size::(); + let value_hash: ValueHash = S::Hasher::digest(&authenticated_write).into(); + let leaf = LeafData { + key_path, + value_hash, + }; + if !verified + .confirm_value(&leaf) + .map_err(|e| anyhow::anyhow!("Key out of scope: {:?}", e))? + { + anyhow::bail!("Failed to verify value for key"); + } + } + } + + Ok((key, value)) +} + +/// Wrapper around [`nomt_core::proof::MultiProof`] that implements `PartialEq`/`Eq` +/// by manually comparing each of inner attributes of [`nomt_core::proof::MultiProof`] +/// +/// This is necessary because `MultiProof` doesn't derive these traits. +#[derive(Debug, Clone, Serialize, serde::Deserialize, BorshSerialize, BorshDeserialize)] +pub struct NomtMultiProof(pub MultiProof); + +impl PartialEq for NomtMultiProof { + fn eq(&self, other: &Self) -> bool { + let this = &self.0; + let other = &other.0; + + if this.paths.len() != other.paths.len() { + return false; + } + + if this.siblings != other.siblings { + return false; + } + + for (this_path, other_path) in this.paths.iter().zip(other.paths.iter()) { + if this_path.depth != other_path.depth { + return false; + } + + if this_path.terminal != other_path.terminal { + return false; + } + } + + true + } +} + +impl Eq for NomtMultiProof {} diff --git a/crates/module-system/sov-state/src/nomt/prover_storage.rs b/crates/module-system/sov-state/src/nomt/prover_storage.rs index 3f0069ea1c..087e9089c3 100644 --- a/crates/module-system/sov-state/src/nomt/prover_storage.rs +++ b/crates/module-system/sov-state/src/nomt/prover_storage.rs @@ -9,6 +9,7 @@ use anyhow::Context; use nomt::hasher::BinaryHasher; use nomt::proof::MultiProof; use nomt::FinishedSession; +use nomt_core::trie::KeyPath; use sov_db::accessory_db::AccessoryDb; use sov_db::historical_state::HistoricalStateReader; use sov_db::state_db_nomt::{HistoricalValueError, NomtSessionBuilder, SessionsContainer}; @@ -18,6 +19,7 @@ use sov_db::storage_manager::{ use sov_rollup_interface::common::SlotNumber; use sov_rollup_interface::reexports::digest::Digest; +use crate::nomt::NomtMultiProof; use crate::pinned_cache::PinnedCache; use crate::storage::ReadType; use crate::{ @@ -401,7 +403,7 @@ where { type Hasher = S::Hasher; type Witness = S::Witness; - type Proof = (); + type Proof = NomtMultiProof; type Root = StorageRoot; // These 2 are effectively the same thing, `StateUpdate` is not materialized, `ChangeSet` is materialized. type StateUpdate = NomtStateUpdate; @@ -617,10 +619,10 @@ where } fn open_proof( - _state_root: Self::Root, - _proof: StorageProof, + state_root: Self::Root, + proof: StorageProof, ) -> anyhow::Result<(SlotKey, Option)> { - unimplemented!("The NomtProverStorage does not support `open_proof` yet.") + crate::nomt::verify_storage_proof::(state_root, proof) } } @@ -675,11 +677,23 @@ where ProvableNamespace::Kernel => self.read_value::(&key, slot_number)?, }; + let session = match namespace { + ProvableNamespace::User => self + .state_session_builder + .begin_user_session_without_witness()?, + ProvableNamespace::Kernel => self + .state_session_builder + .begin_kernel_session_without_witness()?, + }; + + let key_path: KeyPath = S::Hasher::digest(key.as_ref()).into(); + let path_proof = session.prove(key_path)?; + let multi_proof = MultiProof::from_path_proofs(vec![path_proof]); + Ok(StorageProof { key, value, - // TODO: Proof is empty now, will be fixed in follow - proof: (), + proof: NomtMultiProof(multi_proof), namespace, }) } diff --git a/crates/module-system/sov-state/src/nomt/zk_storage.rs b/crates/module-system/sov-state/src/nomt/zk_storage.rs index ea4f49f326..804baebf49 100644 --- a/crates/module-system/sov-state/src/nomt/zk_storage.rs +++ b/crates/module-system/sov-state/src/nomt/zk_storage.rs @@ -8,6 +8,7 @@ use nomt_core::trie::{KeyPath, LeafData, Node, ValueHash}; use sov_rollup_interface::common::SlotNumber; use sov_rollup_interface::reexports::digest::Digest; +use crate::nomt::NomtMultiProof; use crate::pinned_cache::PinnedCache; use crate::storage::ReadType; use crate::{ @@ -106,7 +107,7 @@ impl NomtVerifierStorage { impl Storage for NomtVerifierStorage { type Hasher = S::Hasher; type Witness = S::Witness; - type Proof = (); + type Proof = NomtMultiProof; type Root = StorageRoot; type StateUpdate = (); type ChangeSet = (); @@ -160,10 +161,10 @@ impl Storage for NomtVerifierStorage { fn materialize_changes(self, _state_update: Self::StateUpdate) -> Self::ChangeSet {} fn open_proof( - _state_root: Self::Root, - _proof: StorageProof, + state_root: Self::Root, + proof: StorageProof, ) -> anyhow::Result<(SlotKey, Option)> { - unimplemented!("The NomtZkStorage does not support `open_proof` yet."); + crate::nomt::verify_storage_proof::(state_root, proof) } } @@ -180,38 +181,38 @@ impl crate::storage::NativeStorage for NomtVerifierStorage( + fn get_historical( &self, - _key: SlotKey, + _key: &SlotKey, _version: Option, - ) -> anyhow::Result> { - unimplemented!("The NomtVerifierStorage should not be used to generate merkle proofs! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); + _witness: &Self::Witness, + ) -> anyhow::Result> { + unimplemented!("The NomtVerifierStorage does not support `get_historical`! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); } - fn get_accessory_historical( + fn get_leaf_historical( &self, _key: &SlotKey, _version: Option, - ) -> anyhow::Result> { - unimplemented!("The NomtVerifierStorage does not support `get_accessory_historical`! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); + _witness: &Self::Witness, + ) -> anyhow::Result> { + unimplemented!("The NomtVerifierStorage does not support `get_leaf_historical`! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); } - fn get_historical( + fn get_accessory_historical( &self, _key: &SlotKey, _version: Option, - _witness: &Self::Witness, ) -> anyhow::Result> { - unimplemented!("The NomtVerifierStorage does not support `get_historical`! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); + unimplemented!("The NomtVerifierStorage does not support `get_accessory_historical`! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); } - fn get_leaf_historical( + fn get_with_proof( &self, - _key: &SlotKey, + _key: SlotKey, _version: Option, - _witness: &Self::Witness, - ) -> anyhow::Result> { - unimplemented!("The NomtVerifierStorage does not support `get_leaf_historical`! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); + ) -> anyhow::Result> { + unimplemented!("The NomtVerifierStorage should not be used to generate merkle proofs! The NativeStorage trait is only implemented to allow for the use of the NomtVerifierStorage in tests."); } fn get_root_hash(&self, version: SlotNumber) -> anyhow::Result { diff --git a/crates/utils/sov-test-utils/src/lib.rs b/crates/utils/sov-test-utils/src/lib.rs index 19561653be..a83f535743 100644 --- a/crates/utils/sov-test-utils/src/lib.rs +++ b/crates/utils/sov-test-utils/src/lib.rs @@ -13,15 +13,15 @@ use serde::{Deserialize, Serialize}; pub use sov_db::schema::SchemaBatch; pub use sov_mock_da::verifier::MockDaSpec; use sov_mock_da::BlockProducingConfig; +pub use sov_mock_da::MockHash; pub use sov_mock_zkvm::{MockZkvm, MockZkvmCryptoSpec}; use sov_modules_api::capabilities::UniquenessData; -use sov_modules_api::configurable_spec::ConfigurableSpec; -use sov_modules_api::default_spec::DefaultSpec; +use sov_modules_api::default_spec::{DefaultNomtSpec, DefaultSpec}; use sov_modules_api::macros::config_value; use sov_modules_api::transaction::{ PriorityFeeBips, Transaction, TransactionCallable, TxDetails, UnsignedTransaction, }; -use sov_modules_api::{Address, Amount, BasicGasMeter, CryptoSpec, Gas, GasArray, Spec}; +use sov_modules_api::{Amount, BasicGasMeter, CryptoSpec, Gas, GasArray, Spec}; pub use sov_modules_api::{EncodeCall, TxProcessingError, TxReceiptContents}; pub use sov_modules_rollup_blueprint::logging::initialize_logging; pub use sov_modules_stf_blueprint::get_gas_used; @@ -77,20 +77,12 @@ pub type TestHasher = ::Hasher; pub type TestStorageSpec = DefaultStorageSpec; /// The default test spec. Uses a [`MockZkvm`] for both inner and outer vm verification. /// Uses [`MockZkvmCryptoSpec`] for cryptographic primitives. -pub type TestSpec = DefaultSpec; +pub type TestJmtSpec = DefaultSpec; /// Shortcut to [`sov_mock_da::MockHash`]; pub type TestSlotHash = ::SlotHash; /// The default test spec for NOMT. Uses a [`MockZkvm`] for both inner and outer vm verification. /// Uses [`MockZkvmCryptoSpec`] for cryptographic primitives. -pub type TestNomtSpec = ConfigurableSpec< - MockDaSpec, - MockZkvm, - MockZkvm, - Address, - Native, - MockZkvmCryptoSpec, - NomtProverStorage, ->; +pub type TestSpec = DefaultNomtSpec; /// The default test spec for ZK. Uses a [`MockZkvm`] for both inner and outer vm verification. pub type ZkTestSpec = DefaultSpec; /// The default address type. This is the [`sov_modules_api::BasicAddress`] type defined by the [`TestSpec`]. @@ -104,9 +96,11 @@ pub type TestSignature = ::Signature; /// The default STF blueprint type. Uses [`MockDaSpec`] for DA and [`sov_kernels::basic::BasicKernel`] for kernel. pub type TestStfBlueprint = StfBlueprint; -/// The default [`sov_db::storage_manager::NativeStorageManager`], that can be used with [`ProverStorage`] and [`TestStorageSpec`]. +/// Just [`NomtProverStorage`] with predefined configs. +pub type TestStorage = NomtProverStorage; +/// The default [`sov_db::storage_manager::NativeStorageManager`], that can be used with [`NomtProverStorage`] and [`TestStorageSpec`]. pub type TestStorageManager = - sov_db::storage_manager::NativeStorageManager>; + sov_db::storage_manager::NomtStorageManager; // --- Blessed test parameters --- // Blessed gas parameters diff --git a/crates/utils/sov-test-utils/src/rt_agnostic_blueprint.rs b/crates/utils/sov-test-utils/src/rt_agnostic_blueprint.rs index e0e2933a36..48f2e59926 100644 --- a/crates/utils/sov-test-utils/src/rt_agnostic_blueprint.rs +++ b/crates/utils/sov-test-utils/src/rt_agnostic_blueprint.rs @@ -31,9 +31,13 @@ use sov_stf_runner::RollupConfig; pub struct RtAgnosticBlueprint< S: Spec, R: RuntimeTrait, - Manager = NativeStorageManager< + Manager = NomtStorageManager< MockDaSpec, - ProverStorage::CryptoSpec as CryptoSpec>::Hasher>>, + <::CryptoSpec as CryptoSpec>::Hasher, + NomtProverStorage< + DefaultStorageSpec<<::CryptoSpec as CryptoSpec>::Hasher>, + MockHash, + >, >, > { phantom: PhantomData<(S, R, Manager)>, diff --git a/crates/utils/sov-test-utils/src/runtime/mod.rs b/crates/utils/sov-test-utils/src/runtime/mod.rs index f85cf50149..6621857cc2 100644 --- a/crates/utils/sov-test-utils/src/runtime/mod.rs +++ b/crates/utils/sov-test-utils/src/runtime/mod.rs @@ -1002,7 +1002,7 @@ pub fn assert_tx_reverted_with_reason(result: TxEffect, reason: anyh } // This replicate logic from `AsyncBatchResponder`. -// And all modifications mede there shold be replicated. +// And all modifications mede there should be replicated. #[derive(Clone)] struct SeqControlFlow; diff --git a/crates/utils/sov-test-utils/src/sequencer.rs b/crates/utils/sov-test-utils/src/sequencer.rs index 3d758add60..da2ba760de 100644 --- a/crates/utils/sov-test-utils/src/sequencer.rs +++ b/crates/utils/sov-test-utils/src/sequencer.rs @@ -3,10 +3,17 @@ use std::num::NonZero; use std::sync::atomic::AtomicU64; use std::sync::Arc; +use crate::runtime::genesis::optimistic::HighLevelOptimisticGenesisConfig; +use crate::runtime::{GenesisConfig, TestOptimisticRuntime}; +use crate::{ + TestHasher, TestPrivateKey, TestSlotHash, TestSpec, TestStfBlueprint, TestStorageManager, + TEST_MAX_BATCH_SIZE, TEST_MAX_CONCURRENT_BLOBS, +}; use sov_api_spec::Client; +use sov_db::config::RollupDbConfig; use sov_db::ledger_db::LedgerDb; use sov_db::schema::SchemaBatch; -use sov_db::storage_manager::NativeStorageManager; +use sov_db::storage_manager::NomtStorageManager; use sov_mock_da::storable::StorableMockDaService; use sov_mock_da::{MockAddress, MockBlock, MockDaSpec}; use sov_modules_api::{DaSyncState, Runtime, SlotData, Spec, SyncStatus}; @@ -18,19 +25,13 @@ use sov_rollup_interface::StateUpdateInfo; use sov_sequencer::standard::{StdSequencer, StdSequencerConfig}; pub use sov_sequencer::test_stateless::TestStatelessSequencer; use sov_sequencer::{SequencerApis, SequencerConfig}; -use sov_state::{DefaultStorageSpec, ProverStorage}; +use sov_state::nomt::prover_storage::NomtProverStorage; +use sov_state::DefaultStorageSpec; use sov_stf_runner::query_state_update_info; use sov_value_setter::ValueSetterConfig; use tempfile::TempDir; use tokio::sync::watch; -use crate::runtime::genesis::optimistic::HighLevelOptimisticGenesisConfig; -use crate::runtime::{GenesisConfig, TestOptimisticRuntime}; -use crate::{ - TestHasher, TestPrivateKey, TestSpec, TestStfBlueprint, TEST_MAX_BATCH_SIZE, - TEST_MAX_CONCURRENT_BLOBS, -}; - /// A `struct` that contains a sequencer and a copy of its running Axum /// server, for use in tests. See [`TestSequencerSetup::new`] and /// [`TestSequencerSetup::with_real_sequencer`]. @@ -66,16 +67,13 @@ impl> Drop for TestSequencerSetup { } impl> TestSequencerSetup { - /// Like [`TestSequencerSetup::new`], but with a custom [`NativeStorageManager`]. + /// Like [`TestSequencerSetup::new`], but with a custom [`NomtStorageManager`]. pub async fn with_storage_manager( dir: TempDir, da_service: StorableMockDaService, sequencer_config: StdSequencerConfig, register_admin: bool, - mut storage_manager: NativeStorageManager< - MockDaSpec, - ProverStorage>, - >, + mut storage_manager: TestStorageManager, ) -> anyhow::Result { // Generate a genesis config, then overwrite the attester key/address with ones that // we know. We leave the other values untouched. @@ -213,10 +211,12 @@ impl> TestSequencerSetup { sequencer_config: StdSequencerConfig, register_admin: bool, ) -> anyhow::Result { - let storage_manager = NativeStorageManager::< + let config = RollupDbConfig::default_in_path(dir.path().to_path_buf()); + let storage_manager = NomtStorageManager::< MockDaSpec, - ProverStorage>, - >::new(dir.path())?; + TestHasher, + NomtProverStorage, TestSlotHash>, + >::new(config)?; Self::with_storage_manager( dir, diff --git a/crates/utils/sov-test-utils/src/storage.rs b/crates/utils/sov-test-utils/src/storage.rs index c9b3fe374b..75c763fa0d 100644 --- a/crates/utils/sov-test-utils/src/storage.rs +++ b/crates/utils/sov-test-utils/src/storage.rs @@ -35,7 +35,7 @@ use crate::TestSlotHash; /// Implementation of [`HierarchicalStorageManager`] that provides [`ProverStorage`] /// and commits changes directly to the underlying database. -pub struct SimpleStorageManager { +pub struct SimpleJmtStorageManager { state: Arc, accessory: Arc, phantom_mp_spec: PhantomData, @@ -44,13 +44,13 @@ pub struct SimpleStorageManager { root: StorageRoot, } -impl Default for SimpleStorageManager { +impl Default for SimpleJmtStorageManager { fn default() -> Self { Self::new() } } -impl SimpleStorageManager { +impl SimpleJmtStorageManager { /// Initialize new instance in temporary folder. pub fn new() -> Self { let dir = tempfile::tempdir().unwrap(); @@ -155,7 +155,7 @@ impl SimpleLedgerStorageManager { /// Implementation of [`HierarchicalStorageManager`] that provides [`NomtProverStorage`] /// and commits changes directly to the underlying database. -pub struct SimpleNomtStorageManager { +pub struct SimpleStorageManager { // Holds ownership of [`Tempdir`] so it is not removed prematurely _dir: TempDir, state: Arc>, @@ -166,8 +166,8 @@ pub struct SimpleNomtStorageManager { pinned_cache: Mutex>, } -impl SimpleNomtStorageManager { - /// Initialize a new instance of [`SimpleNomtStorageManager`] in a temporary directory. +impl SimpleStorageManager { + /// Initialize a new instance of [`SimpleStorageManager`] in a temporary directory. pub fn new() -> Self { let dir = tempfile::tempdir().unwrap(); let config = RollupDbConfig::default_in_path(dir.path().to_path_buf()); @@ -234,7 +234,6 @@ impl SimpleNomtStorageManager { /// Commit [`NomtChangeSet`] to disk. pub fn commit(&mut self, stf_change_set: NomtChangeSet) { - tracing::trace!("Committing changes to disk"); let NomtChangeSet { state, historical_state, @@ -243,18 +242,14 @@ impl SimpleNomtStorageManager { } = stf_change_set; self.state.commit_change_set(state).unwrap(); - tracing::trace!("Committed state changes to disk"); self.accessory.write_schemas(&accessory).unwrap(); - tracing::trace!("Committed accessory changes to disk"); self.historical_state.commit(historical_state).unwrap(); *self.pinned_cache.lock().unwrap() = pinned_cache.map(|c| *c.downcast().expect("Failed to downcast the pinned_cache argument to `NomtProverStorage`. This is a bug. Please report it.")); - tracing::trace!("Committed historical state changes to disk"); - tracing::trace!("Committed all changes to disk"); } } -impl Default for SimpleNomtStorageManager { +impl Default for SimpleStorageManager { fn default() -> Self { Self::new() } @@ -293,7 +288,7 @@ pub trait ForklessStorageManager { ); } -impl ForklessStorageManager for SimpleStorageManager { +impl ForklessStorageManager for SimpleJmtStorageManager { type Storage = ProverStorage; fn new_in_tempdir() -> Self { @@ -318,7 +313,7 @@ impl ForklessStorageManager for SimpleStorageManager { } } -impl ForklessStorageManager for SimpleNomtStorageManager { +impl ForklessStorageManager for SimpleStorageManager { type Storage = NomtProverStorage; fn new_in_tempdir() -> Self { @@ -367,12 +362,17 @@ where } } -/// Using [`HierarchicalStorageManager`] to mimic [`SimpleStorageManager`], -/// but instead of commiting all data on disk, it just appends it to the following block. -/// Emulates fork-less DA without finality. -pub struct NonCommitingStorageManager< +/// Using [`HierarchicalStorageManager`] to mimic [`SimpleJmtStorageManager`], +/// but instead of committing all data on disk, it just appends it to the following block. +/// Emulates fork-less DA. +/// +/// The `FINALIZE` const generic controls whether blocks are finalized after saving: +/// - `false`: Only saves change sets (emulates DA without finality) +/// - `true`: Saves and finalizes (emulates DA with instant finality) +pub struct HierarchicalForklessStorageManager< H: HierarchicalStorageManager + PathInitializer, S: Storage, + const FINALIZE: bool, > { _dir: TempDir, // It holds mutex over the inner storage manager, for compatibility with the testing framework. @@ -381,109 +381,19 @@ pub struct NonCommitingStorageManager< root: S::Root, } -impl NonCommitingStorageManager -where - H: HierarchicalStorageManager + PathInitializer, - S: NativeStorage, -{ - /// Create the new [`NonCommitingStorageManager`]. - /// Passing [`TempDir`] allows keeping the directory from deletion. - pub fn new() -> Self { - let dir = TempDir::new().unwrap(); - let storage_manager = H::new_in_path(dir.path()); - let initial_block_header = MockBlockHeader::from_height(0); - Self { - _dir: dir, - storage_manager: Mutex::new(storage_manager), - last_block: initial_block_header, - root: S::PRE_GENESIS_ROOT, - } - } -} +/// Storage manager that does not finalize blocks - emulates fork-less DA without finality. +pub type NonCommitingStorageManager = HierarchicalForklessStorageManager; -impl Default for NonCommitingStorageManager -where - H: HierarchicalStorageManager + PathInitializer, - S: NativeStorage, -{ - fn default() -> Self { - Self::new() - } -} +/// Storage manager that finalizes blocks - emulates MockDa with instant finality. +pub type CommitingStorageManager = HierarchicalForklessStorageManager; -impl ForklessStorageManager for NonCommitingStorageManager -where - H: HierarchicalStorageManager - + PathInitializer, - >::LedgerChangeSet: Default, - S: NativeStorage, -{ - type Storage = S; - - fn new_in_tempdir() -> Self { - Self::new() - } - - fn current_root(&self) -> ::Root { - self.root.clone() - } - - fn create_prover_storage(&self) -> Self::Storage { - let (prover_storage, _) = self - .storage_manager - .lock() - .unwrap() - .create_state_for(&self.last_block) - .expect("Failed to create storage"); - prover_storage - } - - fn create_api_storage(&self) -> Self::Storage { - let (prover_storage, _) = self - .storage_manager - .lock() - .unwrap() - .create_state_after(&self.last_block) - .expect("Failed to create storage"); - prover_storage - } - - fn commit_change_set( - &mut self, - change_set: ::ChangeSet, - new_root: ::Root, - ) { - // Here is the trick, we don't commit, but chain it to the last block - self.root = new_root; - self.storage_manager - .lock() - .unwrap() - .save_change_set(&self.last_block, change_set, Default::default()) - .expect("Failed to save change set"); - self.last_block = - MockBlockHeader::from_height(self.last_block.height().checked_add(1).unwrap()); - } -} - -/// Storage manager that encapsulates MockDa with instant finality -pub struct CommitingStorageManager< - H: HierarchicalStorageManager + PathInitializer, - S: Storage, -> { - _dir: TempDir, - // It holds mutex over the inner storage manager, for compatibility with the testing framework. - storage_manager: Mutex, - last_block: MockBlockHeader, - root: S::Root, -} - -impl CommitingStorageManager +impl HierarchicalForklessStorageManager where H: HierarchicalStorageManager + PathInitializer, S: NativeStorage, { - /// Create the new [`CommitingStorageManager`]. - /// Passing [`TempDir`] allows keeping the directory from deletion. + /// Create a new [`HierarchicalForklessStorageManager`]. + /// Creates a temporary directory that is kept alive for the lifetime of the manager. pub fn new() -> Self { let dir = TempDir::new().unwrap(); let storage_manager = H::new_in_path(dir.path()); @@ -497,7 +407,7 @@ where } } -impl Default for CommitingStorageManager +impl Default for HierarchicalForklessStorageManager where H: HierarchicalStorageManager + PathInitializer, S: NativeStorage, @@ -507,7 +417,8 @@ where } } -impl ForklessStorageManager for CommitingStorageManager +impl ForklessStorageManager + for HierarchicalForklessStorageManager where H: HierarchicalStorageManager + PathInitializer, @@ -549,15 +460,16 @@ where change_set: ::ChangeSet, new_root: ::Root, ) { - // Here is the trick, we don't commit, but chain it to the last block self.root = new_root; let mut storage_manager = self.storage_manager.lock().unwrap(); storage_manager .save_change_set(&self.last_block, change_set, Default::default()) .expect("Failed to save change set"); - storage_manager - .finalize(&self.last_block) - .expect("Failed to finalize storage manager"); + if FINALIZE { + storage_manager + .finalize(&self.last_block) + .expect("Failed to finalize storage manager"); + } self.last_block = MockBlockHeader::from_height(self.last_block.height().checked_add(1).unwrap()); } diff --git a/crates/utils/sov-test-utils/src/test_rollup.rs b/crates/utils/sov-test-utils/src/test_rollup.rs index ada4023b65..a6a9b66c6b 100644 --- a/crates/utils/sov-test-utils/src/test_rollup.rs +++ b/crates/utils/sov-test-utils/src/test_rollup.rs @@ -737,7 +737,7 @@ where R: FullNodeBlueprint + Default + 'static, { /// Default timeout for polling operations in seconds. - pub const POLLING_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(20); + pub const POLLING_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(60); /// Helper to get api_client pub fn api_client(&self) -> &sov_api_spec::client::Client { diff --git a/crates/utils/transaction-generator/src/generators/transaction.rs b/crates/utils/transaction-generator/src/generators/transaction.rs index 4a047234d2..54de9f0747 100644 --- a/crates/utils/transaction-generator/src/generators/transaction.rs +++ b/crates/utils/transaction-generator/src/generators/transaction.rs @@ -2,6 +2,7 @@ use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use sov_mock_da::MockDaSpec; +use sov_mock_da::MockHash; use sov_modules_api::capabilities::config_chain_id; use sov_modules_api::prelude::arbitrary; use sov_modules_api::transaction::TxDetails; @@ -9,7 +10,8 @@ use sov_modules_api::{ Amount, CryptoSpec, DispatchCall, Gas, GasArray, PrivateKey as _, Runtime, Spec, TxEffect, }; use sov_modules_stf_blueprint::get_gas_used; -use sov_state::{DefaultStorageSpec, ProverStorage}; +use sov_state::nomt::prover_storage::NomtProverStorage; +use sov_state::DefaultStorageSpec; use sov_test_utils::runtime::traits::MinimalGenesis; use sov_test_utils::runtime::TestRunner; use sov_test_utils::{ @@ -155,11 +157,12 @@ pub enum TransactionOutcome { } type DefaultSpecWithHasher = DefaultStorageSpec<<::CryptoSpec as CryptoSpec>::Hasher>; +type NomtStorage = NomtProverStorage, MockHash>; /// Generated transaction implementation using the standard Sovereign SDK transaction struct. #[derive(Clone)] pub struct SovereignGeneratedTransaction< - S: Spec>, Da = MockDaSpec>, + S: Spec, Da = MockDaSpec>, RT: Runtime + MinimalGenesis + DispatchCall, > { /// The generated transaction to be executed by the test runner. @@ -173,7 +176,7 @@ pub struct SovereignGeneratedTransaction< impl PrepareEnv for SovereignGeneratedTransaction where RT: Runtime + MinimalGenesis + DispatchCall, - S: Spec>, Da = MockDaSpec>, + S: Spec, Da = MockDaSpec>, { type Input = TestRunner; @@ -199,7 +202,7 @@ where impl AssertOutcome for SovereignGeneratedTransaction where - S: Spec>, Da = MockDaSpec>, + S: Spec, Da = MockDaSpec>, RT: Runtime + MinimalGenesis + DispatchCall, { type Output = TransactionAssertContext; @@ -231,7 +234,7 @@ pub struct SovereignContext<'a, S: Spec, RT: DispatchCall + Runtime> { impl GeneratedTransaction for SovereignGeneratedTransaction where RT: Runtime + MinimalGenesis + DispatchCall, - S: Spec>, Da = MockDaSpec>, + S: Spec, Da = MockDaSpec>, { type Transaction = TransactionType; @@ -276,7 +279,7 @@ where impl RunTest for SovereignGeneratedTransaction where RT: Runtime + MinimalGenesis + DispatchCall, - S: Spec>, Da = MockDaSpec>, + S: Spec, Da = MockDaSpec>, { fn run_test(mut self, runner: &mut TestRunner) { self.prepare_env(runner); diff --git a/examples/demo-rollup/sov-benchmarks/Cargo.toml b/examples/demo-rollup/sov-benchmarks/Cargo.toml index 57e80eb7ad..1f4c5d10f1 100644 --- a/examples/demo-rollup/sov-benchmarks/Cargo.toml +++ b/examples/demo-rollup/sov-benchmarks/Cargo.toml @@ -14,6 +14,7 @@ sov-rollup-interface = { workspace = true, features = ["arbitrary"] } sov-modules-api = { workspace = true, features = ["arbitrary", "bench", "native"] } sov-capabilities = { workspace = true } sov-state = { workspace = true } +sov-db = { workspace = true } sov-test-modules = { workspace = true, features = ["native"] } sov-test-utils = { workspace = true, features = ["arbitrary"] } diff --git a/examples/demo-rollup/sov-benchmarks/src/bench_runner/mod.rs b/examples/demo-rollup/sov-benchmarks/src/bench_runner/mod.rs index 6ed851aaec..e4c5b416ab 100644 --- a/examples/demo-rollup/sov-benchmarks/src/bench_runner/mod.rs +++ b/examples/demo-rollup/sov-benchmarks/src/bench_runner/mod.rs @@ -13,10 +13,13 @@ use cli::BenchRunnerCLI; use demo_stf::runtime::{GenesisConfig, Runtime, RuntimeCall}; use helpers::{BatchReceiver, BatchSender}; use humantime::Timestamp; +use sov_db::storage_manager::NativeStorageManager; use sov_metrics::{timestamp, TelegrafSocketConfig}; use sov_mock_da::BlockProducingConfig; +use sov_modules_api::{CryptoSpec, Spec}; +use sov_state::{DefaultStorageSpec, ProverStorage}; use sov_test_utils::test_rollup::{GenesisSource, RollupBuilder, TestRollup}; -use sov_test_utils::RtAgnosticBlueprint; +use sov_test_utils::{MockDaSpec, RtAgnosticBlueprint}; use sov_transaction_generator::generators::basic::{BasicChangeLogEntry, BasicClientConfig}; use sov_transaction_generator::{assert_logs_against_state, GeneratedMessage}; use tokio::sync::mpsc; @@ -28,7 +31,11 @@ use crate::{mock_da_risc0_host_args, BenchRisc0Spec, DEFAULT_FINALIZATION_BLOCKS pub type S = BenchRisc0Spec; pub type RT = Runtime; -pub type BenchBlueprint = RtAgnosticBlueprint; +type JmtStorageManager = NativeStorageManager< + MockDaSpec, + ProverStorage::CryptoSpec as CryptoSpec>::Hasher>>, +>; +pub type BenchBlueprint = RtAgnosticBlueprint; pub type BenchRollup = TestRollup; pub type BenchRollupBuilder = RollupBuilder; pub type BenchLogs = BasicChangeLogEntry; diff --git a/examples/demo-rollup/sov-benchmarks/src/node/rollup_bench.rs b/examples/demo-rollup/sov-benchmarks/src/node/rollup_bench.rs index 2245a83c61..ea975c1fb7 100644 --- a/examples/demo-rollup/sov-benchmarks/src/node/rollup_bench.rs +++ b/examples/demo-rollup/sov-benchmarks/src/node/rollup_bench.rs @@ -9,7 +9,7 @@ use sov_benchmarks::{setup_with_runner, BenchSpec, NomtBenchSpec}; use sov_mock_da::MockDaSpec; use sov_modules_api::Spec; use sov_test_utils::storage::{ - ForklessStorageManager, SimpleNomtStorageManager, SimpleStorageManager, + ForklessStorageManager, SimpleJmtStorageManager, SimpleStorageManager, }; use sov_test_utils::MockZkvm; @@ -66,13 +66,13 @@ fn stf_apply_slot_bench(c: &mut Criterion) { bench_after_blocks * senders_count ); - run_spec::, SimpleStorageManager<_>>( + run_spec::, SimpleJmtStorageManager<_>>( c, "jmt", senders_count, bench_after_blocks, ); - run_spec::>( + run_spec::>( c, "nomt", senders_count, diff --git a/examples/demo-rollup/sov-benchmarks/src/node/rollup_coarse_measure.rs b/examples/demo-rollup/sov-benchmarks/src/node/rollup_coarse_measure.rs index f556265550..901e45831f 100644 --- a/examples/demo-rollup/sov-benchmarks/src/node/rollup_coarse_measure.rs +++ b/examples/demo-rollup/sov-benchmarks/src/node/rollup_coarse_measure.rs @@ -13,7 +13,7 @@ use sov_mock_da::MockDaSpec; use sov_modules_api::prelude::anyhow; use sov_modules_api::Spec; use sov_test_utils::storage::{ - ForklessStorageManager, SimpleNomtStorageManager, SimpleStorageManager, + ForklessStorageManager, SimpleJmtStorageManager, SimpleStorageManager, }; use sov_test_utils::MockZkvm; @@ -168,11 +168,11 @@ async fn main() -> anyhow::Result<()> { match env::var("SOV_BENCH") { Ok(s) => { if &s == "nomt" { - run_with_spec::>().await + run_with_spec::>().await } else { - run_with_spec::, SimpleStorageManager<_>>().await + run_with_spec::, SimpleJmtStorageManager<_>>().await } } - Err(_) => run_with_spec::, SimpleStorageManager<_>>().await, + Err(_) => run_with_spec::, SimpleJmtStorageManager<_>>().await, } }