From d617eb558d94e8cc4091769ec86cb13597b121f5 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 15:48:07 +0100 Subject: [PATCH 01/18] [no ci] Keep splitting --- Cargo.lock | 53 +++++++-- Cargo.toml | 5 +- adapters/mock-da/Cargo.toml | 26 +++++ adapters/mock-da/src/lib.rs | 9 ++ .../mocks => adapters/mock-da/src}/service.rs | 8 +- .../mock-da/src/types/address.rs | 107 +---------------- .../mock-da/src/types/mod.rs | 108 +++++++++++++++++- .../mock-da/src}/validity_condition.rs | 3 +- adapters/mock-zkvm/Cargo.toml | 22 ++++ .../zk_vm.rs => adapters/mock-zkvm/src/lib.rs | 32 ++---- examples/demo-rollup/Cargo.toml | 7 +- .../demo-rollup/benches/node/rollup_bench.rs | 2 +- .../benches/node/rollup_coarse_measure.rs | 2 +- .../provers/risc0/guest-celestia/Cargo.lock | 15 +++ .../provers/risc0/guest-mock/Cargo.lock | 20 +++- .../provers/risc0/guest-mock/Cargo.toml | 2 +- .../risc0/guest-mock/src/bin/mock_da.rs | 5 +- .../demo-rollup/src/bin/sov_nft_script.rs | 2 +- examples/demo-rollup/src/main.rs | 2 +- examples/demo-rollup/src/mock_rollup.rs | 2 +- examples/demo-rollup/stf/Cargo.toml | 4 +- .../demo-rollup/stf/src/tests/stf_tests.rs | 8 +- .../stf/src/tests/tx_revert_tests.rs | 8 +- examples/demo-simple-stf/Cargo.toml | 2 +- full-node/db/sov-db/Cargo.toml | 3 +- full-node/db/sov-db/src/ledger_db/rpc.rs | 2 +- full-node/sov-ethereum/Cargo.toml | 2 +- full-node/sov-ethereum/README.md | 3 + full-node/sov-sequencer/Cargo.toml | 2 +- full-node/sov-sequencer/src/lib.rs | 2 +- .../integration-tests/Cargo.toml | 6 +- .../src/chain_state/tests.rs | 9 +- .../sov-attester-incentives/Cargo.toml | 3 +- .../src/tests/helpers.rs | 8 +- .../sov-blob-storage/Cargo.toml | 2 +- .../tests/blob_storage_tests.rs | 2 +- .../tests/capability_tests.rs | 2 +- .../sov-chain-state/Cargo.toml | 2 +- .../sov-chain-state/tests/all_tests.rs | 4 +- .../sov-prover-incentives/Cargo.toml | 2 +- .../sov-sequencer-registry/Cargo.toml | 2 +- .../sov-sequencer-registry/src/genesis.rs | 2 +- .../tests/helpers/mod.rs | 2 +- .../tests/hooks_test.rs | 2 +- .../tests/sequencer_registry_test.rs | 2 +- module-system/module-schemas/Cargo.toml | 4 +- module-system/module-schemas/build.rs | 3 +- module-system/sov-cli/Cargo.toml | 2 +- module-system/sov-cli/tests/keys.rs | 2 +- module-system/sov-cli/tests/transactions.rs | 2 +- module-system/sov-modules-api/src/lib.rs | 4 + .../utils/sov-data-generators/Cargo.toml | 3 +- .../utils/sov-data-generators/src/lib.rs | 28 +++-- rollup-interface/Cargo.toml | 1 - .../src/state_machine/mocks/mod.rs | 20 ---- rollup-interface/src/state_machine/mod.rs | 3 - utils/rng-da-service/Cargo.toml | 1 + utils/rng-da-service/src/lib.rs | 8 +- 58 files changed, 345 insertions(+), 254 deletions(-) create mode 100644 adapters/mock-da/Cargo.toml create mode 100644 adapters/mock-da/src/lib.rs rename {rollup-interface/src/state_machine/mocks => adapters/mock-da/src}/service.rs (90%) rename rollup-interface/src/state_machine/mocks/da.rs => adapters/mock-da/src/types/address.rs (56%) rename rollup-interface/src/state_machine/mocks/use_std.rs => adapters/mock-da/src/types/mod.rs (56%) rename {rollup-interface/src/state_machine/mocks => adapters/mock-da/src}/validity_condition.rs (95%) create mode 100644 adapters/mock-zkvm/Cargo.toml rename rollup-interface/src/state_machine/mocks/zk_vm.rs => adapters/mock-zkvm/src/lib.rs (77%) create mode 100644 full-node/sov-ethereum/README.md delete mode 100644 rollup-interface/src/state_machine/mocks/mod.rs diff --git a/Cargo.lock b/Cargo.lock index a81c6d390..f72eb9fed 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2095,6 +2095,7 @@ dependencies = [ "hex", "serde", "sha2 0.10.8", + "sov-mock-da", "sov-rollup-interface", ] @@ -2121,6 +2122,7 @@ dependencies = [ "sov-cli", "sov-data-generators", "sov-evm", + "sov-mock-da", "sov-modules-api", "sov-modules-stf-template", "sov-nft-module", @@ -4158,6 +4160,8 @@ dependencies = [ "serde", "sov-chain-state", "sov-data-generators", + "sov-mock-da", + "sov-mock-zkvm", "sov-modules-api", "sov-modules-stf-template", "sov-rollup-interface", @@ -8317,8 +8321,9 @@ dependencies = [ "sov-attester-incentives", "sov-bank", "sov-chain-state", + "sov-mock-da", + "sov-mock-zkvm", "sov-modules-api", - "sov-rollup-interface", "sov-state", "tempfile", "thiserror", @@ -8384,8 +8389,8 @@ dependencies = [ "sov-bank", "sov-blob-storage", "sov-chain-state", + "sov-mock-da", "sov-modules-api", - "sov-rollup-interface", "sov-sequencer-registry", "sov-state", "tempfile", @@ -8437,8 +8442,8 @@ dependencies = [ "serde_json", "sov-chain-state", "sov-data-generators", + "sov-mock-da", "sov-modules-api", - "sov-rollup-interface", "sov-state", "tempfile", ] @@ -8457,8 +8462,8 @@ dependencies = [ "serde_json", "sov-accounts", "sov-bank", + "sov-mock-da", "sov-modules-api", - "sov-rollup-interface", "tempfile", ] @@ -8469,9 +8474,9 @@ dependencies = [ "borsh", "proptest", "sov-bank", + "sov-mock-da", "sov-modules-api", "sov-modules-stf-template", - "sov-rollup-interface", "sov-state", "sov-value-setter", ] @@ -8490,6 +8495,7 @@ dependencies = [ "proptest-derive", "rocksdb", "serde", + "sov-mock-da", "sov-rollup-interface", "sov-schema-db", "tempfile", @@ -8538,6 +8544,7 @@ dependencies = [ "sov-ethereum", "sov-evm", "sov-ledger-rpc", + "sov-mock-da", "sov-modules-api", "sov-modules-rollup-template", "sov-modules-stf-template", @@ -8572,6 +8579,7 @@ dependencies = [ "serde_json", "sov-accounts", "sov-evm", + "sov-mock-da", "sov-modules-api", "sov-rollup-interface", "tokio", @@ -8640,6 +8648,32 @@ dependencies = [ "tokio", ] +[[package]] +name = "sov-mock-da" +version = "0.3.0" +dependencies = [ + "anyhow", + "async-trait", + "borsh", + "bytes", + "hex", + "serde", + "sha2 0.10.8", + "sov-rollup-interface", + "tokio", +] + +[[package]] +name = "sov-mock-zkvm" +version = "0.3.0" +dependencies = [ + "anyhow", + "bincode", + "borsh", + "serde", + "sov-rollup-interface", +] + [[package]] name = "sov-module-schemas" version = "0.3.0" @@ -8647,9 +8681,10 @@ dependencies = [ "sov-accounts", "sov-bank", "sov-evm", + "sov-mock-da", + "sov-mock-zkvm", "sov-modules-api", "sov-prover-incentives", - "sov-rollup-interface", "sov-sequencer-registry", "sov-value-setter", ] @@ -8787,9 +8822,9 @@ dependencies = [ "serde", "serde_json", "sov-bank", + "sov-mock-da", "sov-modules-api", "sov-prover-incentives", - "sov-rollup-interface", "sov-state", "tempfile", ] @@ -8822,6 +8857,7 @@ dependencies = [ "demo-stf", "serde", "sov-bank", + "sov-mock-da", "sov-modules-api", "sov-rollup-interface", ] @@ -8873,6 +8909,7 @@ dependencies = [ "jsonrpsee 0.20.2", "rand 0.8.5", "serde", + "sov-mock-da", "sov-modules-api", "sov-rollup-interface", "sov-state", @@ -8899,8 +8936,8 @@ dependencies = [ "serde", "serde_json", "sov-bank", + "sov-mock-da", "sov-modules-api", - "sov-rollup-interface", "sov-sequencer-registry", "sov-state", "sov-zk-cycle-macros", diff --git a/Cargo.toml b/Cargo.toml index f8c221874..20593094b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,22 +5,21 @@ members = [ "adapters/avail", "adapters/risc0", "adapters/celestia", + "adapters/mock-da", + "adapters/mock-zkvm", "examples/const-rollup-config", "examples/demo-simple-stf", "examples/demo-rollup", "examples/simple-nft-module", - "full-node/db/sov-db", "full-node/sov-sequencer", "full-node/sov-ethereum", "full-node/sov-ledger-rpc", "full-node/sov-stf-runner", - "utils/zk-cycle-macros", "utils/zk-cycle-utils", "utils/bashtestmd", "utils/rng-da-service", - "module-system/sov-cli", "module-system/sov-modules-stf-template", "module-system/sov-modules-rollup-template", diff --git a/adapters/mock-da/Cargo.toml b/adapters/mock-da/Cargo.toml new file mode 100644 index 000000000..bc0dda307 --- /dev/null +++ b/adapters/mock-da/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "sov-mock-da" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +publish = false + +[dependencies] +anyhow = { workspace = true } +async-trait = { workspace = true } +borsh = { workspace = true } +bytes = { workspace = true } +serde = { workspace = true } +hex = { workspace = true } +sha2 = { workspace = true } +tokio = { workspace = true, optional = true } + +sov-rollup-interface = { path = "../../rollup-interface", version = "0.3" } + + +[features] +default = [] +native = [ + "dep:tokio", + "sov-rollup-interface/native" +] \ No newline at end of file diff --git a/adapters/mock-da/src/lib.rs b/adapters/mock-da/src/lib.rs new file mode 100644 index 000000000..4cf8866a0 --- /dev/null +++ b/adapters/mock-da/src/lib.rs @@ -0,0 +1,9 @@ +#[cfg(feature = "native")] +mod service; +mod types; +mod validity_condition; + +#[cfg(feature = "native")] +pub use service::*; +pub use types::*; +pub use validity_condition::*; diff --git a/rollup-interface/src/state_machine/mocks/service.rs b/adapters/mock-da/src/service.rs similarity index 90% rename from rollup-interface/src/state_machine/mocks/service.rs rename to adapters/mock-da/src/service.rs index 31292cdd1..45e23a61d 100644 --- a/rollup-interface/src/state_machine/mocks/service.rs +++ b/adapters/mock-da/src/service.rs @@ -1,11 +1,11 @@ use async_trait::async_trait; +use sov_rollup_interface::da::DaSpec; +use sov_rollup_interface::maybestd::sync::Arc; +use sov_rollup_interface::services::da::DaService; use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio::sync::Mutex; -use crate::da::DaSpec; -use crate::maybestd::sync::Arc; -use crate::mocks::{MockAddress, MockBlob, MockBlock, MockDaSpec, MockDaVerifier}; -use crate::services::da::DaService; +use crate::types::{MockAddress, MockBlob, MockBlock, MockDaSpec, MockDaVerifier}; #[derive(Clone)] /// DaService used in tests. diff --git a/rollup-interface/src/state_machine/mocks/da.rs b/adapters/mock-da/src/types/address.rs similarity index 56% rename from rollup-interface/src/state_machine/mocks/da.rs rename to adapters/mock-da/src/types/address.rs index 8cb006935..2a5947f97 100644 --- a/rollup-interface/src/state_machine/mocks/da.rs +++ b/adapters/mock-da/src/types/address.rs @@ -1,14 +1,6 @@ -use core::fmt::Display; -use core::str::FromStr; +use std::str::FromStr; -use borsh::{BorshDeserialize, BorshSerialize}; -use serde::{Deserialize, Serialize}; - -use crate::da::{BlockHashTrait, BlockHeaderTrait, Time}; -use crate::maybestd::string::String; -use crate::{BasicAddress, RollupAddress}; - -const JAN_1_2023: i64 = 1672531200; +use sov_rollup_interface::{BasicAddress, RollupAddress}; /// Sequencer DA address used in tests. pub const MOCK_SEQUENCER_DA_ADDRESS: [u8; 32] = [0u8; 32]; @@ -97,7 +89,7 @@ impl From<[u8; 32]> for MockAddress { } } -impl Display for MockAddress { +impl std::fmt::Display for MockAddress { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { write!(f, "{}", hex::encode(self.addr)) } @@ -106,100 +98,11 @@ impl Display for MockAddress { impl BasicAddress for MockAddress {} impl RollupAddress for MockAddress {} -/// A mock hash digest. -#[derive( - Clone, - Copy, - Debug, - PartialEq, - Eq, - serde::Serialize, - serde::Deserialize, - BorshDeserialize, - BorshSerialize, -)] -pub struct MockHash(pub [u8; 32]); - -impl AsRef<[u8]> for MockHash { - fn as_ref(&self) -> &[u8] { - &self.0 - } -} - -impl From<[u8; 32]> for MockHash { - fn from(value: [u8; 32]) -> Self { - Self(value) - } -} - -impl From for [u8; 32] { - fn from(value: MockHash) -> Self { - value.0 - } -} - -impl BlockHashTrait for MockHash {} - -/// A mock block header used for testing. -#[derive(Serialize, Deserialize, PartialEq, core::fmt::Debug, Clone, Copy)] -pub struct MockBlockHeader { - /// The hash of the previous block. - pub prev_hash: MockHash, - /// The hash of this block. - pub hash: MockHash, - /// The height of this block - pub height: u64, -} - -impl Default for MockBlockHeader { - fn default() -> Self { - Self { - prev_hash: MockHash([0u8; 32]), - hash: MockHash([1u8; 32]), - height: 0, - } - } -} - -impl BlockHeaderTrait for MockBlockHeader { - type Hash = MockHash; - - fn prev_hash(&self) -> Self::Hash { - self.prev_hash - } - - fn hash(&self) -> Self::Hash { - self.hash - } - - fn height(&self) -> u64 { - self.height - } - - fn time(&self) -> crate::da::Time { - Time::from_secs(JAN_1_2023 + (self.height as i64) * 15) - } -} - -/// A [`crate::da::DaSpec`] suitable for testing. -#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq)] -pub struct MockDaSpec; - -/// The configuration for mock da -#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] -pub struct MockDaConfig { - /// The address to use to "submit" blobs on the mock da layer - pub sender_address: MockAddress, -} - -#[derive(Clone, Default)] -/// DaVerifier used in tests. -pub struct MockDaVerifier {} - #[cfg(test)] mod tests { + use sov_rollup_interface::maybestd::string::ToString; + use super::*; - use crate::maybestd::string::ToString; #[test] fn test_mock_address_string() { diff --git a/rollup-interface/src/state_machine/mocks/use_std.rs b/adapters/mock-da/src/types/mod.rs similarity index 56% rename from rollup-interface/src/state_machine/mocks/use_std.rs rename to adapters/mock-da/src/types/mod.rs index ad3f5a704..2a33b8fa2 100644 --- a/rollup-interface/src/state_machine/mocks/use_std.rs +++ b/adapters/mock-da/src/types/mod.rs @@ -1,11 +1,107 @@ +mod address; + +pub use address::{MockAddress, MOCK_SEQUENCER_DA_ADDRESS}; +use borsh::{BorshDeserialize, BorshSerialize}; use bytes::Bytes; use serde::{Deserialize, Serialize}; - -use crate::da::{BlobReaderTrait, CountedBufReader, DaSpec, DaVerifier}; -use crate::mocks::{ - MockAddress, MockBlockHeader, MockDaSpec, MockDaVerifier, MockHash, MockValidityCond, +use sov_rollup_interface::da::{ + BlobReaderTrait, BlockHashTrait, BlockHeaderTrait, CountedBufReader, DaSpec, DaVerifier, Time, }; -use crate::services::da::SlotData; +use sov_rollup_interface::services::da::SlotData; + +use crate::validity_condition::MockValidityCond; + +const JAN_1_2023: i64 = 1672531200; + +/// A mock hash digest. +#[derive( + Clone, + Copy, + Debug, + PartialEq, + Eq, + serde::Serialize, + serde::Deserialize, + BorshDeserialize, + BorshSerialize, +)] +pub struct MockHash(pub [u8; 32]); + +impl AsRef<[u8]> for MockHash { + fn as_ref(&self) -> &[u8] { + &self.0 + } +} + +impl From<[u8; 32]> for MockHash { + fn from(value: [u8; 32]) -> Self { + Self(value) + } +} + +impl From for [u8; 32] { + fn from(value: MockHash) -> Self { + value.0 + } +} + +impl BlockHashTrait for MockHash {} + +/// A mock block header used for testing. +#[derive(Serialize, Deserialize, PartialEq, core::fmt::Debug, Clone, Copy)] +pub struct MockBlockHeader { + /// The hash of the previous block. + pub prev_hash: MockHash, + /// The hash of this block. + pub hash: MockHash, + /// The height of this block + pub height: u64, +} + +impl Default for MockBlockHeader { + fn default() -> Self { + Self { + prev_hash: MockHash([0u8; 32]), + hash: MockHash([1u8; 32]), + height: 0, + } + } +} + +impl BlockHeaderTrait for MockBlockHeader { + type Hash = MockHash; + + fn prev_hash(&self) -> Self::Hash { + self.prev_hash + } + + fn hash(&self) -> Self::Hash { + self.hash + } + + fn height(&self) -> u64 { + self.height + } + + fn time(&self) -> Time { + Time::from_secs(JAN_1_2023 + (self.height as i64) * 15) + } +} + +/// A [`crate::da::DaSpec`] suitable for testing. +#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq)] +pub struct MockDaSpec; + +/// The configuration for mock da +#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] +pub struct MockDaConfig { + /// The address to use to "submit" blobs on the mock da layer + pub sender_address: MockAddress, +} + +#[derive(Clone, Default)] +/// DaVerifier used in tests. +pub struct MockDaVerifier {} #[derive( Debug, @@ -28,7 +124,7 @@ impl MockBlob { pub fn new(data: Vec, address: MockAddress, hash: [u8; 32]) -> Self { Self { address, - data: CountedBufReader::new(bytes::Bytes::from(data)), + data: CountedBufReader::new(Bytes::from(data)), hash, } } diff --git a/rollup-interface/src/state_machine/mocks/validity_condition.rs b/adapters/mock-da/src/validity_condition.rs similarity index 95% rename from rollup-interface/src/state_machine/mocks/validity_condition.rs rename to adapters/mock-da/src/validity_condition.rs index c0cbd00f1..02e4e5619 100644 --- a/rollup-interface/src/state_machine/mocks/validity_condition.rs +++ b/adapters/mock-da/src/validity_condition.rs @@ -4,8 +4,7 @@ use anyhow::Error; use borsh::{BorshDeserialize, BorshSerialize}; use serde::{Deserialize, Serialize}; use sha2::Digest; - -use crate::zk::{ValidityCondition, ValidityConditionChecker}; +use sov_rollup_interface::zk::{ValidityCondition, ValidityConditionChecker}; /// A trivial test validity condition structure that only contains a boolean #[derive( diff --git a/adapters/mock-zkvm/Cargo.toml b/adapters/mock-zkvm/Cargo.toml new file mode 100644 index 000000000..a079fd45e --- /dev/null +++ b/adapters/mock-zkvm/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "sov-mock-zkvm" +authors = { workspace = true } +description = "Mock zkVM implementation" +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +version = { workspace = true } + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +anyhow = { workspace = true } +borsh = { workspace = true } +bincode = { workspace = true } +serde = { workspace = true } +sov-rollup-interface = { path = "../../rollup-interface", version = "0.3" } + +[features] +default = [] +native = [] \ No newline at end of file diff --git a/rollup-interface/src/state_machine/mocks/zk_vm.rs b/adapters/mock-zkvm/src/lib.rs similarity index 77% rename from rollup-interface/src/state_machine/mocks/zk_vm.rs rename to adapters/mock-zkvm/src/lib.rs index 8b33e0eee..149bff3bb 100644 --- a/rollup-interface/src/state_machine/mocks/zk_vm.rs +++ b/adapters/mock-zkvm/src/lib.rs @@ -1,10 +1,9 @@ +use std::io::Write; + use anyhow::ensure; use borsh::{BorshDeserialize, BorshSerialize}; use serde::{Deserialize, Serialize}; - -use crate::maybestd::io; -use crate::maybestd::vec::Vec; -use crate::zk::Matches; +use sov_rollup_interface::zk::Matches; /// A mock commitment to a particular zkVM program. #[derive(Debug, Clone, PartialEq, Eq, BorshDeserialize, BorshSerialize, Serialize, Deserialize)] @@ -29,7 +28,7 @@ pub struct MockProof<'a> { impl<'a> MockProof<'a> { /// Serializes a proof into a writer. - pub fn encode(&self, mut writer: impl io::Write) { + pub fn encode(&self, mut writer: impl Write) { writer.write_all(&self.program_id.0).unwrap(); let is_valid_byte = if self.is_valid { 1 } else { 0 }; writer.write_all(&[is_valid_byte]).unwrap(); @@ -60,7 +59,7 @@ impl<'a> MockProof<'a> { /// A mock implementing the zkVM trait. pub struct MockZkvm; -impl crate::zk::Zkvm for MockZkvm { +impl sov_rollup_interface::zk::Zkvm for MockZkvm { type CodeCommitment = MockCodeCommitment; type Error = anyhow::Error; @@ -78,30 +77,17 @@ impl crate::zk::Zkvm for MockZkvm { Ok(proof.log) } - #[cfg(feature = "std")] fn verify_and_extract_output< - Add: crate::RollupAddress, - Da: crate::da::DaSpec, - Root: Serialize + serde::de::DeserializeOwned, + Add: sov_rollup_interface::RollupAddress, + Da: sov_rollup_interface::da::DaSpec, + Root: serde::Serialize + serde::de::DeserializeOwned, >( serialized_proof: &[u8], code_commitment: &Self::CodeCommitment, - ) -> Result, Self::Error> { + ) -> Result, Self::Error> { let output = Self::verify(serialized_proof, code_commitment)?; Ok(bincode::deserialize(output)?) } - - #[cfg(not(feature = "std"))] - fn verify_and_extract_output< - Add: crate::RollupAddress, - Da: crate::da::DaSpec, - Root: Serialize + serde::de::DeserializeOwned, - >( - _serialized_proof: &[u8], - _code_commitment: &Self::CodeCommitment, - ) -> Result, Self::Error> { - todo!("the current version of bincode doesn't support no-std; however, the next version is scheduled to") - } } #[test] diff --git a/examples/demo-rollup/Cargo.toml b/examples/demo-rollup/Cargo.toml index 653ab6619..03a8e0885 100644 --- a/examples/demo-rollup/Cargo.toml +++ b/examples/demo-rollup/Cargo.toml @@ -13,9 +13,8 @@ default-run = "sov-demo-rollup" [dependencies] # non-optional dependencies -sov-celestia-adapter = { path = "../../adapters/celestia", features = [ - "native", -] } +sov-celestia-adapter = { path = "../../adapters/celestia", features = ["native"] } +sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } const-rollup-config = { path = "../const-rollup-config" } sov-stf-runner = { path = "../../full-node/sov-stf-runner", features = ["native"] } sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] } @@ -25,7 +24,7 @@ sov-modules-stf-template = { path = "../../module-system/sov-modules-stf-templat sov-modules-api = { path = "../../module-system/sov-modules-api", features = ["native"] } sov-nft-module = { path = "../../module-system/module-implementations/sov-nft-module" } demo-stf = { path = "./stf", features = ["native"] } -sov-ledger-rpc = { path = "../../full-node/sov-ledger-rpc", features = ["server",] } +sov-ledger-rpc = { path = "../../full-node/sov-ledger-rpc", features = ["server", ] } risc0 = { path = "./provers/risc0" } borsh = { workspace = true, features = ["bytes"] } async-trait = { workspace = true } diff --git a/examples/demo-rollup/benches/node/rollup_bench.rs b/examples/demo-rollup/benches/node/rollup_bench.rs index efaebc27c..fc6153b0e 100644 --- a/examples/demo-rollup/benches/node/rollup_bench.rs +++ b/examples/demo-rollup/benches/node/rollup_bench.rs @@ -8,12 +8,12 @@ use criterion::{criterion_group, criterion_main, Criterion}; use demo_stf::genesis_config::{get_genesis_config, GenesisPaths}; use demo_stf::runtime::Runtime; use sov_db::ledger_db::{LedgerDB, SlotCommit}; +use sov_mock_da::{MockBlock, MockBlockHeader}; use sov_modules_api::default_context::DefaultContext; use sov_modules_stf_template::kernels::basic::BasicKernel; use sov_modules_stf_template::AppTemplate; use sov_risc0_adapter::host::Risc0Verifier; use sov_rng_da_service::{RngDaService, RngDaSpec}; -use sov_rollup_interface::mocks::{MockBlock, MockBlockHeader}; use sov_rollup_interface::services::da::DaService; use sov_rollup_interface::stf::StateTransitionFunction; use sov_rollup_interface::storage::StorageManager; diff --git a/examples/demo-rollup/benches/node/rollup_coarse_measure.rs b/examples/demo-rollup/benches/node/rollup_coarse_measure.rs index 21639f10c..bdc5832ad 100644 --- a/examples/demo-rollup/benches/node/rollup_coarse_measure.rs +++ b/examples/demo-rollup/benches/node/rollup_coarse_measure.rs @@ -12,12 +12,12 @@ use demo_stf::runtime::Runtime; use prettytable::Table; use prometheus::{Histogram, HistogramOpts, Registry}; use sov_db::ledger_db::{LedgerDB, SlotCommit}; +use sov_mock_da::{MockBlock, MockBlockHeader}; use sov_modules_api::default_context::DefaultContext; use sov_modules_stf_template::kernels::basic::BasicKernel; use sov_modules_stf_template::{AppTemplate, TxEffect}; use sov_risc0_adapter::host::Risc0Verifier; use sov_rng_da_service::{RngDaService, RngDaSpec}; -use sov_rollup_interface::mocks::{MockBlock, MockBlockHeader}; use sov_rollup_interface::services::da::DaService; use sov_rollup_interface::stf::StateTransitionFunction; use sov_rollup_interface::storage::StorageManager; diff --git a/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock b/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock index 672acb945..06ec987fa 100644 --- a/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock +++ b/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock @@ -611,6 +611,7 @@ dependencies = [ "sov-bank", "sov-blob-storage", "sov-chain-state", + "sov-mock-da", "sov-modules-api", "sov-modules-stf-template", "sov-nft-module", @@ -2065,6 +2066,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "sov-mock-da" +version = "0.3.0" +dependencies = [ + "anyhow", + "async-trait", + "borsh", + "bytes", + "hex", + "serde", + "sha2 0.10.8", + "sov-rollup-interface", +] + [[package]] name = "sov-modules-api" version = "0.3.0" diff --git a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock index 58d157714..8b67f7da6 100644 --- a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock +++ b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock @@ -183,9 +183,6 @@ name = "bytes" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" -dependencies = [ - "serde", -] [[package]] name = "cc" @@ -273,6 +270,7 @@ dependencies = [ "sov-bank", "sov-blob-storage", "sov-chain-state", + "sov-mock-da", "sov-modules-api", "sov-modules-stf-template", "sov-nft-module", @@ -1034,10 +1032,10 @@ dependencies = [ "demo-stf", "risc0-zkvm", "risc0-zkvm-platform", + "sov-mock-da", "sov-modules-api", "sov-modules-stf-template", "sov-risc0-adapter", - "sov-rollup-interface", "sov-state", ] @@ -1048,6 +1046,20 @@ dependencies = [ "thiserror", ] +[[package]] +name = "sov-mock-da" +version = "0.3.0" +dependencies = [ + "anyhow", + "async-trait", + "borsh", + "bytes", + "hex", + "serde", + "sha2", + "sov-rollup-interface", +] + [[package]] name = "sov-modules-api" version = "0.3.0" diff --git a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.toml b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.toml index 98a388803..6a18ae463 100644 --- a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.toml +++ b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.toml @@ -10,7 +10,7 @@ resolver = "2" anyhow = "1.0.68" risc0-zkvm = { version = "0.18", default-features = false, features = ["std"] } risc0-zkvm-platform = "0.18" -sov-rollup-interface = { path = "../../../../../rollup-interface", features = ["mocks"] } +sov-mock-da = { path = "../../../../../adapters/mock-da" } demo-stf = { path = "../../../stf" } sov-risc0-adapter = { path = "../../../../../adapters/risc0" } sov-modules-api = { path = "../../../../../module-system/sov-modules-api" } diff --git a/examples/demo-rollup/provers/risc0/guest-mock/src/bin/mock_da.rs b/examples/demo-rollup/provers/risc0/guest-mock/src/bin/mock_da.rs index 63fcb5e78..fe4da713b 100644 --- a/examples/demo-rollup/provers/risc0/guest-mock/src/bin/mock_da.rs +++ b/examples/demo-rollup/provers/risc0/guest-mock/src/bin/mock_da.rs @@ -1,10 +1,11 @@ #![no_main] use demo_stf::runtime::Runtime; use demo_stf::AppVerifier; +use sov_mock_da::MockDaVerifier; use sov_modules_api::default_context::ZkDefaultContext; -use sov_modules_stf_template::{kernels::basic::BasicKernel, AppTemplate}; +use sov_modules_stf_template::kernels::basic::BasicKernel; +use sov_modules_stf_template::AppTemplate; use sov_risc0_adapter::guest::Risc0Guest; -use sov_rollup_interface::mocks::MockDaVerifier; use sov_state::ZkStorage; risc0_zkvm::guest::entry!(main); diff --git a/examples/demo-rollup/src/bin/sov_nft_script.rs b/examples/demo-rollup/src/bin/sov_nft_script.rs index 87037d22a..56ed15411 100644 --- a/examples/demo-rollup/src/bin/sov_nft_script.rs +++ b/examples/demo-rollup/src/bin/sov_nft_script.rs @@ -3,6 +3,7 @@ use std::time::Duration; use borsh::ser::BorshSerialize; use demo_stf::runtime::RuntimeCall; +use sov_mock_da::MockDaSpec; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_api::transaction::Transaction; @@ -12,7 +13,6 @@ use sov_nft_module::utils::{ get_transfer_nft_message, }; use sov_nft_module::{CallMessage, CollectionAddress}; -use sov_rollup_interface::mocks::MockDaSpec; use sov_sequencer::utils::SimpleClient; const COLLECTION_1: &str = "Sovereign Squirrel Syndicate"; diff --git a/examples/demo-rollup/src/main.rs b/examples/demo-rollup/src/main.rs index c4295d9a0..8b04439df 100644 --- a/examples/demo-rollup/src/main.rs +++ b/examples/demo-rollup/src/main.rs @@ -4,8 +4,8 @@ use anyhow::Context as _; use clap::Parser; use demo_stf::genesis_config::GenesisPaths; use sov_demo_rollup::{CelestiaDemoRollup, MockDemoRollup}; +use sov_mock_da::MockDaConfig; use sov_modules_rollup_template::{Rollup, RollupProverConfig, RollupTemplate}; -use sov_rollup_interface::mocks::MockDaConfig; use sov_stf_runner::{from_toml_path, RollupConfig}; use tracing::log::debug; use tracing_subscriber::prelude::*; diff --git a/examples/demo-rollup/src/mock_rollup.rs b/examples/demo-rollup/src/mock_rollup.rs index 85eb38bc2..b86ee2767 100644 --- a/examples/demo-rollup/src/mock_rollup.rs +++ b/examples/demo-rollup/src/mock_rollup.rs @@ -2,12 +2,12 @@ use async_trait::async_trait; use demo_stf::genesis_config::StorageConfig; use demo_stf::runtime::Runtime; use sov_db::ledger_db::LedgerDB; +use sov_mock_da::{MockDaConfig, MockDaService, MockDaSpec}; use sov_modules_api::default_context::{DefaultContext, ZkDefaultContext}; use sov_modules_api::Spec; use sov_modules_rollup_template::RollupTemplate; use sov_modules_stf_template::kernels::basic::BasicKernel; use sov_risc0_adapter::host::Risc0Host; -use sov_rollup_interface::mocks::{MockDaConfig, MockDaService, MockDaSpec}; use sov_rollup_interface::services::da::DaService; use sov_state::storage_manager::ProverStorageManager; use sov_state::{DefaultStorageSpec, ZkStorage}; diff --git a/examples/demo-rollup/stf/Cargo.toml b/examples/demo-rollup/stf/Cargo.toml index 3ce2711ac..0cd3a46db 100644 --- a/examples/demo-rollup/stf/Cargo.toml +++ b/examples/demo-rollup/stf/Cargo.toml @@ -33,6 +33,7 @@ sov-bank = { path = "../../../module-system/module-implementations/sov-bank" } sov-nft-module = { path = "../../../module-system/module-implementations/sov-nft-module" } simple-nft-module = { path = "../../simple-nft-module" } +sov-mock-da = { path = "../../../adapters/mock-da" } sov-chain-state = { path = "../../../module-system/module-implementations/sov-chain-state" } sov-modules-stf-template = { path = "../../../module-system/sov-modules-stf-template" } sov-value-setter = { path = "../../../module-system/module-implementations/examples/sov-value-setter" } @@ -45,7 +46,7 @@ sov-evm = { path = "../../../module-system/module-implementations/sov-evm", opti [dev-dependencies] -sov-rollup-interface = { path = "../../../rollup-interface", features = ["mocks"] } + sov-data-generators = { path = "../../../module-system/utils/sov-data-generators" } demo-stf = { path = ".", features = ["native"] } tempfile = { workspace = true } @@ -67,7 +68,6 @@ native = [ "sov-chain-state/native", "sov-value-setter/native", "sov-modules-api/native", - "sov-rollup-interface/mocks", "sov-rollup-interface/native", "sov-modules-stf-template/native", "sov-sequencer", diff --git a/examples/demo-rollup/stf/src/tests/stf_tests.rs b/examples/demo-rollup/stf/src/tests/stf_tests.rs index 7e2e6bcae..411873696 100644 --- a/examples/demo-rollup/stf/src/tests/stf_tests.rs +++ b/examples/demo-rollup/stf/src/tests/stf_tests.rs @@ -3,7 +3,7 @@ pub mod test { use sov_cli::wallet_state::PrivateKeyAndAddress; use sov_data_generators::bank_data::get_default_token_address; - use sov_data_generators::{has_tx_events, new_test_blob_from_batch}; + use sov_data_generators::new_test_blob_from_batch; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_api::{Context, PrivateKey, WorkingSet}; @@ -217,16 +217,16 @@ pub mod test { ); assert_eq!(1, apply_block_result.batch_receipts.len()); - let apply_blob_outcome = apply_block_result.batch_receipts[0].clone(); + // let apply_blob_outcome = apply_block_result.batch_receipts[0].clone(); assert_eq!( SequencerOutcome::Ignored, - apply_blob_outcome.inner, + &apply_block_result.batch_receipts[0].inner, "Batch should have been skipped due to unknown sequencer" ); // Assert that there are no events - assert!(!has_tx_events(&apply_blob_outcome)); + // assert!(!has_tx_events(&apply_blob_outcome)); } fn read_private_key() -> PrivateKeyAndAddress { diff --git a/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs b/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs index 63834470a..70192296a 100644 --- a/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs +++ b/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs @@ -1,11 +1,11 @@ use sov_accounts::Response; use sov_data_generators::bank_data::{get_default_private_key, get_default_token_address}; -use sov_data_generators::{has_tx_events, new_test_blob_from_batch}; +use sov_data_generators::new_test_blob_from_batch; +use sov_mock_da::{MockAddress, MockBlock, MockDaSpec, MOCK_SEQUENCER_DA_ADDRESS}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::{PrivateKey, WorkingSet}; use sov_modules_stf_template::{AppTemplate, Batch, SequencerOutcome, SlashingReason, TxEffect}; use sov_rollup_interface::da::BlobReaderTrait; -use sov_rollup_interface::mocks::{MockAddress, MockBlock, MockDaSpec, MOCK_SEQUENCER_DA_ADDRESS}; use sov_rollup_interface::stf::StateTransitionFunction; use sov_rollup_interface::storage::StorageManager; use sov_state::ProverStorage; @@ -208,7 +208,7 @@ fn test_tx_bad_sig() { ); // The batch receipt contains no events. - assert!(!has_tx_events(&apply_blob_outcome)); + // assert!(!has_tx_events(&apply_blob_outcome)); } } @@ -323,7 +323,7 @@ fn test_tx_bad_serialization() { ); // The batch receipt contains no events. - assert!(!has_tx_events(&apply_blob_outcome)); + // assert!(!has_tx_events(&apply_blob_outcome)); } { diff --git a/examples/demo-simple-stf/Cargo.toml b/examples/demo-simple-stf/Cargo.toml index 521ee0072..2657e7542 100644 --- a/examples/demo-simple-stf/Cargo.toml +++ b/examples/demo-simple-stf/Cargo.toml @@ -17,4 +17,4 @@ hex = { workspace = true } sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] } [dev-dependencies] -sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks"] } +sov-mock-da = { path = "../../adapters/mock-da" } diff --git a/full-node/db/sov-db/Cargo.toml b/full-node/db/sov-db/Cargo.toml index 6a3646e38..bf806b8ed 100644 --- a/full-node/db/sov-db/Cargo.toml +++ b/full-node/db/sov-db/Cargo.toml @@ -17,7 +17,7 @@ resolver = "2" # Maintained by sovereign labs jmt = { workspace = true } sov-schema-db = { path = "../sov-schema-db", version = "0.3" } -sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["native", "mocks"] } +sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["native"] } # External anyhow = { workspace = true, default-features = true } @@ -34,6 +34,7 @@ tokio = { workspace = true } [dev-dependencies] +sov-mock-da = { path = "../../../adapters/mock-da" } tempfile = { workspace = true } diff --git a/full-node/db/sov-db/src/ledger_db/rpc.rs b/full-node/db/sov-db/src/ledger_db/rpc.rs index 5476b0204..721de72a3 100644 --- a/full-node/db/sov-db/src/ledger_db/rpc.rs +++ b/full-node/db/sov-db/src/ledger_db/rpc.rs @@ -428,7 +428,7 @@ impl LedgerDB { #[cfg(test)] mod tests { - use sov_rollup_interface::mocks::{MockBlob, MockBlock}; + use sov_mock_da::{MockBlob, MockBlock}; use sov_rollup_interface::rpc::LedgerRpcProvider; use crate::ledger_db::{LedgerDB, SlotCommit}; diff --git a/full-node/sov-ethereum/Cargo.toml b/full-node/sov-ethereum/Cargo.toml index 7c09bc50c..90a83e94e 100644 --- a/full-node/sov-ethereum/Cargo.toml +++ b/full-node/sov-ethereum/Cargo.toml @@ -34,7 +34,7 @@ tokio = { workspace = true } schnellru = "0.2.1" [dev-dependencies] -sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks"] } +sov-mock-da = { path = "../../adapters/mock-da" } tokio = { workspace = true } diff --git a/full-node/sov-ethereum/README.md b/full-node/sov-ethereum/README.md new file mode 100644 index 000000000..80d662349 --- /dev/null +++ b/full-node/sov-ethereum/README.md @@ -0,0 +1,3 @@ +# sov-ethereum + +Crate that provides a thin wrapper for Sovereign SDK Rollup to have same interface as Ethereum RPC. \ No newline at end of file diff --git a/full-node/sov-sequencer/Cargo.toml b/full-node/sov-sequencer/Cargo.toml index d3949b5d5..900d85824 100644 --- a/full-node/sov-sequencer/Cargo.toml +++ b/full-node/sov-sequencer/Cargo.toml @@ -29,5 +29,5 @@ rand = { workspace = true } tokio = { workspace = true } async-trait = { workspace = true } -sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks", "native"] } sov-value-setter = { path = "../../module-system/module-implementations/examples/sov-value-setter", features = ["native"] } +sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } diff --git a/full-node/sov-sequencer/src/lib.rs b/full-node/sov-sequencer/src/lib.rs index 04bbd5a0b..7307638c9 100644 --- a/full-node/sov-sequencer/src/lib.rs +++ b/full-node/sov-sequencer/src/lib.rs @@ -137,8 +137,8 @@ pub enum SubmitTransactionResponse { #[cfg(test)] mod tests { + use sov_mock_da::{MockAddress, MockDaService}; use sov_rollup_interface::da::BlobReaderTrait; - use sov_rollup_interface::mocks::{MockAddress, MockDaService}; use super::*; diff --git a/module-system/module-implementations/integration-tests/Cargo.toml b/module-system/module-implementations/integration-tests/Cargo.toml index 6d38891d1..56919496e 100644 --- a/module-system/module-implementations/integration-tests/Cargo.toml +++ b/module-system/module-implementations/integration-tests/Cargo.toml @@ -16,13 +16,15 @@ anyhow = { workspace = true } borsh = { workspace = true, features = ["rc"] } tempfile = { workspace = true } serde = { workspace = true } -jsonrpsee = { workspace = true } +jsonrpsee = { workspace = true } sov-modules-api = { path = "../../sov-modules-api", features = ["native"] } sov-state = { path = "../../sov-state", features = ["native"] } -sov-rollup-interface = { path = "../../../rollup-interface", features = ["mocks"] } +sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-schema-db = { path = "../../../full-node/db/sov-schema-db" } sov-data-generators = { path = "../../utils/sov-data-generators" } +sov-rollup-interface = { path = "../../../rollup-interface" } sov-modules-stf-template = { path = "../../sov-modules-stf-template", features = ["native"] } sov-chain-state = { path = "../sov-chain-state", features = ["native"] } diff --git a/module-system/module-implementations/integration-tests/src/chain_state/tests.rs b/module-system/module-implementations/integration-tests/src/chain_state/tests.rs index ab88c8efe..4ac242bc4 100644 --- a/module-system/module-implementations/integration-tests/src/chain_state/tests.rs +++ b/module-system/module-implementations/integration-tests/src/chain_state/tests.rs @@ -1,15 +1,14 @@ use sov_chain_state::{StateTransitionId, TransitionInProgress}; use sov_data_generators::value_setter_data::ValueSetterMessages; -use sov_data_generators::{has_tx_events, new_test_blob_from_batch, MessageGenerator}; +use sov_data_generators::{new_test_blob_from_batch, MessageGenerator}; +use sov_mock_da::{MockBlock, MockBlockHeader, MockDaSpec, MockHash, MockValidityCond}; +use sov_mock_zkvm::MockZkvm; use sov_modules_api::default_context::DefaultContext; +use sov_modules_api::storage::StorageManager; use sov_modules_api::{Spec, WorkingSet}; use sov_modules_stf_template::kernels::basic::BasicKernel; use sov_modules_stf_template::{AppTemplate, SequencerOutcome}; -use sov_rollup_interface::mocks::{ - MockBlock, MockBlockHeader, MockDaSpec, MockHash, MockValidityCond, MockZkvm, -}; use sov_rollup_interface::stf::StateTransitionFunction; -use sov_rollup_interface::storage::StorageManager; use sov_state::storage_manager::ProverStorageManager; use sov_state::Storage; diff --git a/module-system/module-implementations/sov-attester-incentives/Cargo.toml b/module-system/module-implementations/sov-attester-incentives/Cargo.toml index 937bc431d..2dd1c7d24 100644 --- a/module-system/module-implementations/sov-attester-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-attester-incentives/Cargo.toml @@ -13,7 +13,8 @@ resolver = "2" publish = false [dev-dependencies] -sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["mocks"] } +sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3" } sov-attester-incentives = { path = ".", features = ["native"] } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-attester-incentives/src/tests/helpers.rs b/module-system/module-implementations/sov-attester-incentives/src/tests/helpers.rs index 02cad720c..e6eed8be8 100644 --- a/module-system/module-implementations/sov-attester-incentives/src/tests/helpers.rs +++ b/module-system/module-implementations/sov-attester-incentives/src/tests/helpers.rs @@ -1,13 +1,13 @@ use jmt::proof::SparseMerkleProof; use sov_bank::{BankConfig, TokenConfig}; +use sov_mock_da::{ + MockBlock, MockBlockHeader, MockDaSpec, MockValidityCond, MockValidityCondChecker, +}; +use sov_mock_zkvm::{MockCodeCommitment, MockZkvm}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::hooks::SlotHooks; use sov_modules_api::utils::generate_address; use sov_modules_api::{Address, Genesis, Spec, ValidityConditionChecker, WorkingSet}; -use sov_rollup_interface::mocks::{ - MockBlock, MockBlockHeader, MockCodeCommitment, MockDaSpec, MockValidityCond, - MockValidityCondChecker, MockZkvm, -}; use sov_state::storage::{NativeStorage, Storage, StorageProof}; use sov_state::{DefaultStorageSpec, ProverStorage}; diff --git a/module-system/module-implementations/sov-blob-storage/Cargo.toml b/module-system/module-implementations/sov-blob-storage/Cargo.toml index e3df6cdca..d1803c954 100644 --- a/module-system/module-implementations/sov-blob-storage/Cargo.toml +++ b/module-system/module-implementations/sov-blob-storage/Cargo.toml @@ -32,7 +32,7 @@ clap = { workspace = true, optional = true } [dev-dependencies] -sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["mocks"] } +sov-mock-da = { path = "../../../adapters/mock-da" } sov-blob-storage = { path = ".", features = ["native"] } sov-bank = { path = "../sov-bank" } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-blob-storage/tests/blob_storage_tests.rs b/module-system/module-implementations/sov-blob-storage/tests/blob_storage_tests.rs index 9c70af280..8813dc3ef 100644 --- a/module-system/module-implementations/sov-blob-storage/tests/blob_storage_tests.rs +++ b/module-system/module-implementations/sov-blob-storage/tests/blob_storage_tests.rs @@ -1,8 +1,8 @@ use sov_blob_storage::BlobStorage; use sov_chain_state::{ChainState, ChainStateConfig}; +use sov_mock_da::{MockAddress, MockBlob, MockDaSpec}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::{Module, WorkingSet}; -use sov_rollup_interface::mocks::{MockAddress, MockBlob, MockDaSpec}; use sov_state::ProverStorage; type C = DefaultContext; diff --git a/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs b/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs index 2633a0c1e..3f762d25a 100644 --- a/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs +++ b/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs @@ -1,6 +1,7 @@ use sov_bank::TokenConfig; use sov_blob_storage::{BlobStorage, DEFERRED_SLOTS_COUNT}; use sov_chain_state::ChainStateConfig; +use sov_mock_da::{MockAddress, MockBlob, MockBlock, MockBlockHeader, MockDaSpec}; use sov_modules_api::capabilities::{BlobRefOrOwned, BlobSelector}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::hooks::SlotHooks; @@ -8,7 +9,6 @@ use sov_modules_api::macros::DefaultRuntime; use sov_modules_api::{ Address, BlobReaderTrait, Context, DaSpec, DispatchCall, MessageCodec, Module, Spec, WorkingSet, }; -use sov_rollup_interface::mocks::{MockAddress, MockBlob, MockBlock, MockBlockHeader, MockDaSpec}; use sov_sequencer_registry::SequencerConfig; use sov_state::{DefaultStorageSpec, ProverStorage, Storage}; diff --git a/module-system/module-implementations/sov-chain-state/Cargo.toml b/module-system/module-implementations/sov-chain-state/Cargo.toml index 78d8888b2..81235be52 100644 --- a/module-system/module-implementations/sov-chain-state/Cargo.toml +++ b/module-system/module-implementations/sov-chain-state/Cargo.toml @@ -25,7 +25,7 @@ sov-state = { path = "../../sov-state", version = "0.3" } tempfile = { workspace = true } sov-data-generators = { path = "../../utils/sov-data-generators" } sov-chain-state = { path = ".", features = ["native"] } -sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["mocks"] } +sov-mock-da = { path = "../../../adapters/mock-da" } [features] diff --git a/module-system/module-implementations/sov-chain-state/tests/all_tests.rs b/module-system/module-implementations/sov-chain-state/tests/all_tests.rs index d8eee00b4..04a4d60d9 100644 --- a/module-system/module-implementations/sov-chain-state/tests/all_tests.rs +++ b/module-system/module-implementations/sov-chain-state/tests/all_tests.rs @@ -1,10 +1,10 @@ use sov_chain_state::{ChainState, ChainStateConfig, StateTransitionId, TransitionInProgress}; +use sov_mock_da::{MockBlock, MockBlockHeader, MockDaSpec, MockValidityCond}; use sov_modules_api::da::BlockHeaderTrait; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::hooks::SlotHooks; +use sov_modules_api::storage::StorageManager; use sov_modules_api::{Genesis, WorkingSet}; -use sov_rollup_interface::mocks::{MockBlock, MockBlockHeader, MockDaSpec, MockValidityCond}; -use sov_rollup_interface::storage::StorageManager; use sov_state::config::Config; use sov_state::storage_manager::ProverStorageManager; use sov_state::{DefaultStorageSpec, Storage}; diff --git a/module-system/module-implementations/sov-prover-incentives/Cargo.toml b/module-system/module-implementations/sov-prover-incentives/Cargo.toml index e2fcd3a04..57be8ab18 100644 --- a/module-system/module-implementations/sov-prover-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-prover-incentives/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" resolver = "2" [dev-dependencies] -sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["mocks"] } +sov-mock-da = { path = "../../../adapters/mock-da" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3", features = ["native"] } tempfile = { workspace = true } sov-prover-incentives = { features = ["native"], path = "." } diff --git a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml index d50981b20..dc9e2bc33 100644 --- a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml +++ b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml @@ -14,7 +14,7 @@ resolver = "2" [dev-dependencies] sov-sequencer-registry = { path = ".", features = ["native"] } -sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["mocks"] } +sov-mock-da = { path = "../../../adapters/mock-da" } tempfile = { workspace = true } [dependencies] diff --git a/module-system/module-implementations/sov-sequencer-registry/src/genesis.rs b/module-system/module-implementations/sov-sequencer-registry/src/genesis.rs index e8638407a..f3f7cbf36 100644 --- a/module-system/module-implementations/sov-sequencer-registry/src/genesis.rs +++ b/module-system/module-implementations/sov-sequencer-registry/src/genesis.rs @@ -61,9 +61,9 @@ mod tests { use std::str::FromStr; use sov_bank::Coins; + use sov_mock_da::{MockAddress, MockDaSpec}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::{AddressBech32, Spec}; - use sov_rollup_interface::mocks::{MockAddress, MockDaSpec}; use crate::SequencerConfig; diff --git a/module-system/module-implementations/sov-sequencer-registry/tests/helpers/mod.rs b/module-system/module-implementations/sov-sequencer-registry/tests/helpers/mod.rs index dac89c0cd..fe26bba2c 100644 --- a/module-system/module-implementations/sov-sequencer-registry/tests/helpers/mod.rs +++ b/module-system/module-implementations/sov-sequencer-registry/tests/helpers/mod.rs @@ -1,8 +1,8 @@ use jsonrpsee::core::RpcResult; +use sov_mock_da::{MockAddress, MockDaSpec}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::digest::Digest; use sov_modules_api::{Address, Module, Spec, WorkingSet}; -use sov_rollup_interface::mocks::{MockAddress, MockDaSpec}; use sov_sequencer_registry::{SequencerConfig, SequencerRegistry}; pub type C = DefaultContext; diff --git a/module-system/module-implementations/sov-sequencer-registry/tests/hooks_test.rs b/module-system/module-implementations/sov-sequencer-registry/tests/hooks_test.rs index d97287609..5149204a0 100644 --- a/module-system/module-implementations/sov-sequencer-registry/tests/hooks_test.rs +++ b/module-system/module-implementations/sov-sequencer-registry/tests/hooks_test.rs @@ -5,7 +5,7 @@ use sov_state::ProverStorage; mod helpers; use helpers::*; -use sov_rollup_interface::mocks::{MockAddress, MockBlob}; +use sov_mock_da::{MockAddress, MockBlob}; use sov_sequencer_registry::{SequencerOutcome, SequencerRegistry}; #[test] diff --git a/module-system/module-implementations/sov-sequencer-registry/tests/sequencer_registry_test.rs b/module-system/module-implementations/sov-sequencer-registry/tests/sequencer_registry_test.rs index e5bd00063..70f80e70d 100644 --- a/module-system/module-implementations/sov-sequencer-registry/tests/sequencer_registry_test.rs +++ b/module-system/module-implementations/sov-sequencer-registry/tests/sequencer_registry_test.rs @@ -5,7 +5,7 @@ use sov_state::ProverStorage; mod helpers; use helpers::*; -use sov_rollup_interface::mocks::MockAddress; +use sov_mock_da::MockAddress; use sov_sequencer_registry::SequencerRegistry; // Happy path for registration and exit diff --git a/module-system/module-schemas/Cargo.toml b/module-system/module-schemas/Cargo.toml index fbd56d9f5..11c704add 100644 --- a/module-system/module-schemas/Cargo.toml +++ b/module-system/module-schemas/Cargo.toml @@ -14,7 +14,9 @@ publish = false [build-dependencies] sov-modules-api = { path = "../sov-modules-api" } -sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks"] } +# Remove when mock-zkvm +sov-mock-da = { path = "../../adapters/mock-da" } +sov-mock-zkvm = { path = "../../adapters/mock-zkvm" } # Modules sov-accounts = { path = "../module-implementations/sov-accounts", features = ["native"] } diff --git a/module-system/module-schemas/build.rs b/module-system/module-schemas/build.rs index 1e949178e..965407c2b 100644 --- a/module-system/module-schemas/build.rs +++ b/module-system/module-schemas/build.rs @@ -1,9 +1,10 @@ use std::fs::File; use std::io::{self, Write}; +use sov_mock_da::MockDaSpec; +use sov_mock_zkvm::MockZkvm; use sov_modules_api::default_context::DefaultContext as C; use sov_modules_api::ModuleCallJsonSchema; -use sov_rollup_interface::mocks::{MockDaSpec, MockZkvm}; fn main() -> io::Result<()> { store_json_schema::>("sov-bank.json")?; diff --git a/module-system/sov-cli/Cargo.toml b/module-system/sov-cli/Cargo.toml index 3a4f0020b..ac5543e8f 100644 --- a/module-system/sov-cli/Cargo.toml +++ b/module-system/sov-cli/Cargo.toml @@ -30,4 +30,4 @@ jsonrpsee = { workspace = true, features = ["client"] } [dev-dependencies] tempfile = { workspace = true } demo-stf = { path = "../../examples/demo-rollup/stf", features = ["native"] } -sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks"] } +sov-mock-da = { path = "../../adapters/mock-da" } diff --git a/module-system/sov-cli/tests/keys.rs b/module-system/sov-cli/tests/keys.rs index ceed1a6fa..e340c9e86 100644 --- a/module-system/sov-cli/tests/keys.rs +++ b/module-system/sov-cli/tests/keys.rs @@ -1,9 +1,9 @@ use demo_stf::runtime::RuntimeCall; use sov_cli::wallet_state::{KeyIdentifier, PrivateKeyAndAddress, WalletState}; use sov_cli::workflows::keys::KeyWorkflow; +use sov_mock_da::MockDaSpec; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::{PrivateKey, PublicKey, Spec}; -use sov_rollup_interface::mocks::MockDaSpec; type Da = MockDaSpec; diff --git a/module-system/sov-cli/tests/transactions.rs b/module-system/sov-cli/tests/transactions.rs index c8881ca7b..c60ba060f 100644 --- a/module-system/sov-cli/tests/transactions.rs +++ b/module-system/sov-cli/tests/transactions.rs @@ -3,9 +3,9 @@ use std::path::{Path, PathBuf}; use demo_stf::runtime::{Runtime, RuntimeCall, RuntimeSubcommand}; use sov_cli::wallet_state::WalletState; use sov_cli::workflows::transactions::{ImportTransaction, TransactionWorkflow}; +use sov_mock_da::MockDaSpec; use sov_modules_api::cli::{FileNameArg, JsonStringArg}; use sov_modules_api::default_context::DefaultContext; -use sov_rollup_interface::mocks::MockDaSpec; type Da = MockDaSpec; diff --git a/module-system/sov-modules-api/src/lib.rs b/module-system/sov-modules-api/src/lib.rs index 09c1031a4..da06a28cf 100644 --- a/module-system/sov-modules-api/src/lib.rs +++ b/module-system/sov-modules-api/src/lib.rs @@ -74,6 +74,10 @@ pub mod da { pub use sov_rollup_interface::da::{BlockHeaderTrait, NanoSeconds, Time}; } +pub mod storage { + pub use sov_rollup_interface::storage::StorageManager; +} + impl AsRef<[u8]> for Address { fn as_ref(&self) -> &[u8] { &self.addr diff --git a/module-system/utils/sov-data-generators/Cargo.toml b/module-system/utils/sov-data-generators/Cargo.toml index 701449cb4..327b1f5ce 100644 --- a/module-system/utils/sov-data-generators/Cargo.toml +++ b/module-system/utils/sov-data-generators/Cargo.toml @@ -8,7 +8,6 @@ license = { workspace = true } repository = { workspace = true } version = { workspace = true } -readme = "README.md" resolver = "2" publish = false @@ -19,7 +18,7 @@ sov-modules-stf-template = { path = "../../sov-modules-stf-template", features = sov-value-setter = { path = "../../module-implementations/examples/sov-value-setter", features = ["native"] } sov-bank = { path = "../../module-implementations/sov-bank", features = ["native"] } sov-state = { path = "../../sov-state" } -sov-rollup-interface = { path = "../../../rollup-interface", features = ["mocks"] } +sov-mock-da = { path = "../../../adapters/mock-da" } borsh = { workspace = true } diff --git a/module-system/utils/sov-data-generators/src/lib.rs b/module-system/utils/sov-data-generators/src/lib.rs index 083753953..f11661c76 100644 --- a/module-system/utils/sov-data-generators/src/lib.rs +++ b/module-system/utils/sov-data-generators/src/lib.rs @@ -1,14 +1,11 @@ use std::rc::Rc; use borsh::ser::BorshSerialize; +use sov_mock_da::{MockAddress, MockBlob, MockDaSpec}; use sov_modules_api::transaction::Transaction; pub use sov_modules_api::EncodeCall; -use sov_modules_api::{Context, Module, Spec}; +use sov_modules_api::{Context, DaSpec, Module, RollupAddress, Spec}; use sov_modules_stf_template::{Batch, RawTx, SequencerOutcome, TxEffect}; -use sov_rollup_interface::da::DaSpec; -use sov_rollup_interface::mocks::{MockAddress, MockBlob, MockDaSpec}; -use sov_rollup_interface::stf::BatchReceipt; -use sov_rollup_interface::RollupAddress; pub mod bank_data; pub mod value_setter_data; @@ -23,16 +20,17 @@ pub fn new_test_blob_from_batch( MockBlob::new(data, address, hash) } -pub fn has_tx_events( - apply_blob_outcome: &BatchReceipt, TxEffect>, -) -> bool { - let events = apply_blob_outcome - .tx_receipts - .iter() - .flat_map(|receipts| receipts.events.iter()); - - events.peekable().peek().is_some() -} +// pub fn has_tx_events( +// apply_blob_outcome: &BatchReceipt, TxEffect>, +// a: &[TransactionReceipt], +// ) -> bool { +// let events = apply_blob_outcome +// .tx_receipts +// .iter() +// .flat_map(|receipts| receipts.events.iter()); +// +// events.peekable().peek().is_some() +// } /// A generic message object used to create transactions. pub struct Message { diff --git a/rollup-interface/Cargo.toml b/rollup-interface/Cargo.toml index e575b71a2..eaa1acee8 100644 --- a/rollup-interface/Cargo.toml +++ b/rollup-interface/Cargo.toml @@ -45,7 +45,6 @@ proptest-derive = { workspace = true } default = ["std"] native = ["std", "tokio"] fuzzing = ["proptest", "proptest-derive", "sha2", "std"] -mocks = ["sha2", "bytes/serde", "std"] std = [ "anyhow/default", "bincode", diff --git a/rollup-interface/src/state_machine/mocks/mod.rs b/rollup-interface/src/state_machine/mocks/mod.rs deleted file mode 100644 index f27e04586..000000000 --- a/rollup-interface/src/state_machine/mocks/mod.rs +++ /dev/null @@ -1,20 +0,0 @@ -//! Defines mock instantiations of many important traits, which are useful -//! for testing, fuzzing, and benchmarking. - -mod da; -#[cfg(feature = "native")] -mod service; -#[cfg(feature = "std")] -mod use_std; -mod validity_condition; -mod zk_vm; -pub use da::{ - MockAddress, MockBlockHeader, MockDaConfig, MockDaSpec, MockDaVerifier, MockHash, - MOCK_SEQUENCER_DA_ADDRESS, -}; -#[cfg(feature = "native")] -pub use service::MockDaService; -#[cfg(feature = "std")] -pub use use_std::{MockBlob, MockBlock}; -pub use validity_condition::{MockValidityCond, MockValidityCondChecker}; -pub use zk_vm::{MockCodeCommitment, MockProof, MockZkvm}; diff --git a/rollup-interface/src/state_machine/mod.rs b/rollup-interface/src/state_machine/mod.rs index 7e7816600..8e89376d9 100644 --- a/rollup-interface/src/state_machine/mod.rs +++ b/rollup-interface/src/state_machine/mod.rs @@ -10,9 +10,6 @@ pub use bytes::{Buf, BufMut, Bytes, BytesMut}; use serde::de::DeserializeOwned; use serde::Serialize; -#[cfg(feature = "mocks")] -pub mod mocks; - pub mod optimistic; pub mod storage; diff --git a/utils/rng-da-service/Cargo.toml b/utils/rng-da-service/Cargo.toml index 60f08398e..e714c8442 100644 --- a/utils/rng-da-service/Cargo.toml +++ b/utils/rng-da-service/Cargo.toml @@ -20,3 +20,4 @@ demo-stf = { path = "../../examples/demo-rollup/stf" } sov-bank = { path = "../../module-system/module-implementations/sov-bank" } sov-modules-api = { path = "../../module-system/sov-modules-api", features = ["native"] } sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] } +sov-mock-da = { path = "../../adapters/mock-da" } diff --git a/utils/rng-da-service/src/lib.rs b/utils/rng-da-service/src/lib.rs index f4801db31..5590aafa9 100644 --- a/utils/rng-da-service/src/lib.rs +++ b/utils/rng-da-service/src/lib.rs @@ -4,15 +4,15 @@ use async_trait::async_trait; use borsh::ser::BorshSerialize; use demo_stf::runtime::Runtime; use sov_bank::{Bank, CallMessage, Coins}; +use sov_mock_da::{ + MockAddress, MockBlob, MockBlock, MockBlockHeader, MockHash, MockValidityCond, + MOCK_SEQUENCER_DA_ADDRESS, +}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_api::transaction::Transaction; use sov_modules_api::{Address, AddressBech32, EncodeCall, PrivateKey, PublicKey, Spec}; use sov_rollup_interface::da::{DaSpec, DaVerifier}; -use sov_rollup_interface::mocks::{ - MockAddress, MockBlob, MockBlock, MockBlockHeader, MockHash, MockValidityCond, - MOCK_SEQUENCER_DA_ADDRESS, -}; use sov_rollup_interface::services::da::DaService; pub fn sender_address_with_pkey() -> (Address, DefaultPrivateKey) { From 610820f7e1d7a0ef94d28f3b70386e03592c5179 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 15:58:24 +0100 Subject: [PATCH 02/18] Move things around --- adapters/celestia/src/verifier/mod.rs | 8 +-- adapters/mock-da/Cargo.toml | 4 +- adapters/mock-da/src/lib.rs | 1 + adapters/mock-da/src/service.rs | 3 +- adapters/mock-da/src/types/mod.rs | 71 ++------------------------- adapters/mock-da/src/verifier.rs | 64 ++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 73 deletions(-) create mode 100644 adapters/mock-da/src/verifier.rs diff --git a/adapters/celestia/src/verifier/mod.rs b/adapters/celestia/src/verifier/mod.rs index a63e73b26..4120258ce 100644 --- a/adapters/celestia/src/verifier/mod.rs +++ b/adapters/celestia/src/verifier/mod.rs @@ -45,15 +45,15 @@ impl BlobReaderTrait for BlobWithSender { self.blob.accumulator() } + fn total_len(&self) -> usize { + self.blob.total_len() + } + #[cfg(feature = "native")] fn advance(&mut self, num_bytes: usize) -> &[u8] { self.blob.advance(num_bytes); self.verified_data() } - - fn total_len(&self) -> usize { - self.blob.total_len() - } } #[derive(Debug, PartialEq, Clone, Eq, Hash, Serialize, Deserialize)] diff --git a/adapters/mock-da/Cargo.toml b/adapters/mock-da/Cargo.toml index bc0dda307..5372ce690 100644 --- a/adapters/mock-da/Cargo.toml +++ b/adapters/mock-da/Cargo.toml @@ -23,4 +23,6 @@ default = [] native = [ "dep:tokio", "sov-rollup-interface/native" -] \ No newline at end of file +] +# TODO: Why this feature is needed? +verifier = [] \ No newline at end of file diff --git a/adapters/mock-da/src/lib.rs b/adapters/mock-da/src/lib.rs index 4cf8866a0..07732a73c 100644 --- a/adapters/mock-da/src/lib.rs +++ b/adapters/mock-da/src/lib.rs @@ -2,6 +2,7 @@ mod service; mod types; mod validity_condition; +pub mod verifier; #[cfg(feature = "native")] pub use service::*; diff --git a/adapters/mock-da/src/service.rs b/adapters/mock-da/src/service.rs index 45e23a61d..e5541fe41 100644 --- a/adapters/mock-da/src/service.rs +++ b/adapters/mock-da/src/service.rs @@ -5,7 +5,8 @@ use sov_rollup_interface::services::da::DaService; use tokio::sync::mpsc::{self, Receiver, Sender}; use tokio::sync::Mutex; -use crate::types::{MockAddress, MockBlob, MockBlock, MockDaSpec, MockDaVerifier}; +use crate::types::{MockAddress, MockBlob, MockBlock, MockDaVerifier}; +use crate::verifier::MockDaSpec; #[derive(Clone)] /// DaService used in tests. diff --git a/adapters/mock-da/src/types/mod.rs b/adapters/mock-da/src/types/mod.rs index 2a33b8fa2..93aa82b5f 100644 --- a/adapters/mock-da/src/types/mod.rs +++ b/adapters/mock-da/src/types/mod.rs @@ -4,9 +4,7 @@ pub use address::{MockAddress, MOCK_SEQUENCER_DA_ADDRESS}; use borsh::{BorshDeserialize, BorshSerialize}; use bytes::Bytes; use serde::{Deserialize, Serialize}; -use sov_rollup_interface::da::{ - BlobReaderTrait, BlockHashTrait, BlockHeaderTrait, CountedBufReader, DaSpec, DaVerifier, Time, -}; +use sov_rollup_interface::da::{BlockHashTrait, BlockHeaderTrait, CountedBufReader, Time}; use sov_rollup_interface::services::da::SlotData; use crate::validity_condition::MockValidityCond; @@ -88,10 +86,6 @@ impl BlockHeaderTrait for MockBlockHeader { } } -/// A [`crate::da::DaSpec`] suitable for testing. -#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq)] -pub struct MockDaSpec; - /// The configuration for mock da #[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)] pub struct MockDaConfig { @@ -114,9 +108,9 @@ pub struct MockDaVerifier {} )] /// A mock BlobTransaction from a DA layer used for testing. pub struct MockBlob { - address: MockAddress, - hash: [u8; 32], - data: CountedBufReader, + pub(crate) address: MockAddress, + pub(crate) hash: [u8; 32], + pub(crate) data: CountedBufReader, } impl MockBlob { @@ -130,32 +124,6 @@ impl MockBlob { } } -impl BlobReaderTrait for MockBlob { - type Address = MockAddress; - - fn sender(&self) -> Self::Address { - self.address - } - - fn hash(&self) -> [u8; 32] { - self.hash - } - - fn verified_data(&self) -> &[u8] { - self.data.accumulator() - } - - fn total_len(&self) -> usize { - self.data.total_len() - } - - #[cfg(feature = "native")] - fn advance(&mut self, num_bytes: usize) -> &[u8] { - self.data.advance(num_bytes); - self.verified_data() - } -} - /// A mock block type used for testing. #[derive(Serialize, Deserialize, PartialEq, core::fmt::Debug, Clone)] pub struct MockBlock { @@ -197,34 +165,3 @@ impl SlotData for MockBlock { self.validity_cond } } - -impl DaSpec for MockDaSpec { - type SlotHash = MockHash; - type BlockHeader = MockBlockHeader; - type BlobTransaction = MockBlob; - type Address = MockAddress; - type ValidityCondition = MockValidityCond; - type InclusionMultiProof = [u8; 32]; - type CompletenessProof = (); - type ChainParams = (); -} - -impl DaVerifier for MockDaVerifier { - type Spec = MockDaSpec; - - type Error = anyhow::Error; - - fn new(_params: ::ChainParams) -> Self { - Self {} - } - - fn verify_relevant_tx_list( - &self, - _block_header: &::BlockHeader, - _txs: &[::BlobTransaction], - _inclusion_proof: ::InclusionMultiProof, - _completeness_proof: ::CompletenessProof, - ) -> Result<::ValidityCondition, Self::Error> { - Ok(Default::default()) - } -} diff --git a/adapters/mock-da/src/verifier.rs b/adapters/mock-da/src/verifier.rs new file mode 100644 index 000000000..d5c23b545 --- /dev/null +++ b/adapters/mock-da/src/verifier.rs @@ -0,0 +1,64 @@ +use sov_rollup_interface::da::{BlobReaderTrait, DaSpec, DaVerifier}; + +use crate::{MockAddress, MockBlob, MockBlockHeader, MockDaVerifier, MockHash, MockValidityCond}; + +impl BlobReaderTrait for MockBlob { + type Address = MockAddress; + + fn sender(&self) -> Self::Address { + self.address + } + + fn hash(&self) -> [u8; 32] { + self.hash + } + + fn verified_data(&self) -> &[u8] { + self.data.accumulator() + } + + fn total_len(&self) -> usize { + self.data.total_len() + } + + #[cfg(feature = "native")] + fn advance(&mut self, num_bytes: usize) -> &[u8] { + self.data.advance(num_bytes); + self.verified_data() + } +} + +/// A [`crate::da::DaSpec`] suitable for testing. +#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq)] +pub struct MockDaSpec; + +impl DaSpec for MockDaSpec { + type SlotHash = MockHash; + type BlockHeader = MockBlockHeader; + type BlobTransaction = MockBlob; + type Address = MockAddress; + type ValidityCondition = MockValidityCond; + type InclusionMultiProof = [u8; 32]; + type CompletenessProof = (); + type ChainParams = (); +} + +impl DaVerifier for MockDaVerifier { + type Spec = MockDaSpec; + + type Error = anyhow::Error; + + fn new(_params: ::ChainParams) -> Self { + Self {} + } + + fn verify_relevant_tx_list( + &self, + _block_header: &::BlockHeader, + _txs: &[::BlobTransaction], + _inclusion_proof: ::InclusionMultiProof, + _completeness_proof: ::CompletenessProof, + ) -> Result<::ValidityCondition, Self::Error> { + Ok(Default::default()) + } +} From 1b84c98b97ee26f86ce8797ad2c58bccf09c5a1a Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 16:29:31 +0100 Subject: [PATCH 03/18] Fix serde compatibility --- Cargo.lock | 1 + Cargo.toml | 4 ++++ adapters/mock-da/Cargo.toml | 4 ++-- adapters/mock-da/src/lib.rs | 1 + adapters/mock-da/src/types/mod.rs | 2 +- .../provers/risc0/guest-celestia/Cargo.toml | 1 + .../demo-rollup/provers/risc0/guest-mock/Cargo.lock | 3 +++ examples/demo-rollup/stf/Cargo.toml | 1 + examples/demo-simple-stf/Cargo.toml | 13 +++++++------ examples/demo-simple-stf/tests/stf_test.rs | 6 +++--- full-node/db/sov-db/Cargo.toml | 2 +- full-node/sov-ethereum/Cargo.toml | 4 ++-- full-node/sov-sequencer/Cargo.toml | 2 +- .../integration-tests/Cargo.toml | 3 ++- .../sov-sequencer-registry/Cargo.toml | 2 +- module-system/module-schemas/build.rs | 2 +- module-system/sov-cli/Cargo.toml | 2 +- module-system/utils/sov-data-generators/src/lib.rs | 8 +++++--- utils/rng-da-service/Cargo.toml | 2 +- 19 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f72eb9fed..cea2e2969 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2096,6 +2096,7 @@ dependencies = [ "serde", "sha2 0.10.8", "sov-mock-da", + "sov-mock-zkvm", "sov-rollup-interface", ] diff --git a/Cargo.toml b/Cargo.toml index 20593094b..e5a80812e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,19 +7,23 @@ members = [ "adapters/celestia", "adapters/mock-da", "adapters/mock-zkvm", + # Examples "examples/const-rollup-config", "examples/demo-simple-stf", "examples/demo-rollup", "examples/simple-nft-module", + # Full Node "full-node/db/sov-db", "full-node/sov-sequencer", "full-node/sov-ethereum", "full-node/sov-ledger-rpc", "full-node/sov-stf-runner", + # Utils "utils/zk-cycle-macros", "utils/zk-cycle-utils", "utils/bashtestmd", "utils/rng-da-service", + # Module System "module-system/sov-cli", "module-system/sov-modules-stf-template", "module-system/sov-modules-rollup-template", diff --git a/adapters/mock-da/Cargo.toml b/adapters/mock-da/Cargo.toml index 5372ce690..1511f0dba 100644 --- a/adapters/mock-da/Cargo.toml +++ b/adapters/mock-da/Cargo.toml @@ -8,8 +8,8 @@ publish = false [dependencies] anyhow = { workspace = true } async-trait = { workspace = true } -borsh = { workspace = true } -bytes = { workspace = true } +borsh = { workspace = true, features = ["bytes"] } +bytes = { workspace = true, features = ["serde"] } serde = { workspace = true } hex = { workspace = true } sha2 = { workspace = true } diff --git a/adapters/mock-da/src/lib.rs b/adapters/mock-da/src/lib.rs index 07732a73c..781e5c94d 100644 --- a/adapters/mock-da/src/lib.rs +++ b/adapters/mock-da/src/lib.rs @@ -8,3 +8,4 @@ pub mod verifier; pub use service::*; pub use types::*; pub use validity_condition::*; +pub use verifier::MockDaSpec; diff --git a/adapters/mock-da/src/types/mod.rs b/adapters/mock-da/src/types/mod.rs index 93aa82b5f..e257c77e5 100644 --- a/adapters/mock-da/src/types/mod.rs +++ b/adapters/mock-da/src/types/mod.rs @@ -2,10 +2,10 @@ mod address; pub use address::{MockAddress, MOCK_SEQUENCER_DA_ADDRESS}; use borsh::{BorshDeserialize, BorshSerialize}; -use bytes::Bytes; use serde::{Deserialize, Serialize}; use sov_rollup_interface::da::{BlockHashTrait, BlockHeaderTrait, CountedBufReader, Time}; use sov_rollup_interface::services::da::SlotData; +use sov_rollup_interface::Bytes; use crate::validity_condition::MockValidityCond; diff --git a/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.toml b/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.toml index ec9f6aceb..dbb10e5f5 100644 --- a/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.toml +++ b/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.toml @@ -17,6 +17,7 @@ sov-celestia-adapter = { path = "../../../../../adapters/celestia" } sov-modules-api = { path = "../../../../../module-system/sov-modules-api" } sov-state = { path = "../../../../../module-system/sov-state" } sov-modules-stf-template = { path = "../../../../../module-system/sov-modules-stf-template" } + [patch.crates-io] sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2/v0.10.6-risc0" } diff --git a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock index 8b67f7da6..c3608452e 100644 --- a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock +++ b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock @@ -183,6 +183,9 @@ name = "bytes" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" +dependencies = [ + "serde", +] [[package]] name = "cc" diff --git a/examples/demo-rollup/stf/Cargo.toml b/examples/demo-rollup/stf/Cargo.toml index 0cd3a46db..cd6cce5e6 100644 --- a/examples/demo-rollup/stf/Cargo.toml +++ b/examples/demo-rollup/stf/Cargo.toml @@ -69,6 +69,7 @@ native = [ "sov-value-setter/native", "sov-modules-api/native", "sov-rollup-interface/native", + "sov-mock-da/native", "sov-modules-stf-template/native", "sov-sequencer", "clap", diff --git a/examples/demo-simple-stf/Cargo.toml b/examples/demo-simple-stf/Cargo.toml index 2657e7542..09aabf0d1 100644 --- a/examples/demo-simple-stf/Cargo.toml +++ b/examples/demo-simple-stf/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "demo-simple-stf" -version = { workspace = true } -edition = { workspace = true } +version = { workspace = true } +edition = { workspace = true } resolver = "2" -authors = { workspace = true } -license = { workspace = true } +authors = { workspace = true } +license = { workspace = true } homepage = "sovereign.xyz" publish = false [dependencies] -anyhow = { workspace = true} +anyhow = { workspace = true } serde = { workspace = true } sha2 = { workspace = true } hex = { workspace = true } @@ -17,4 +17,5 @@ hex = { workspace = true } sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] } [dev-dependencies] -sov-mock-da = { path = "../../adapters/mock-da" } +sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } +sov-mock-zkvm = { path = "../../adapters/mock-zkvm" } diff --git a/examples/demo-simple-stf/tests/stf_test.rs b/examples/demo-simple-stf/tests/stf_test.rs index 4f009ad48..728a35b70 100644 --- a/examples/demo-simple-stf/tests/stf_test.rs +++ b/examples/demo-simple-stf/tests/stf_test.rs @@ -1,7 +1,7 @@ use demo_simple_stf::{ApplySlotResult, CheckHashPreimageStf}; -use sov_rollup_interface::mocks::{ - MockAddress, MockBlob, MockBlockHeader, MockDaSpec, MockValidityCond, MockZkvm, -}; +use sov_mock_da::verifier::MockDaSpec; +use sov_mock_da::{MockAddress, MockBlob, MockBlockHeader, MockValidityCond}; +use sov_mock_zkvm::MockZkvm; use sov_rollup_interface::stf::StateTransitionFunction; #[test] diff --git a/full-node/db/sov-db/Cargo.toml b/full-node/db/sov-db/Cargo.toml index bf806b8ed..af7eaae16 100644 --- a/full-node/db/sov-db/Cargo.toml +++ b/full-node/db/sov-db/Cargo.toml @@ -34,7 +34,7 @@ tokio = { workspace = true } [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } tempfile = { workspace = true } diff --git a/full-node/sov-ethereum/Cargo.toml b/full-node/sov-ethereum/Cargo.toml index 90a83e94e..51d75a13a 100644 --- a/full-node/sov-ethereum/Cargo.toml +++ b/full-node/sov-ethereum/Cargo.toml @@ -15,7 +15,7 @@ publish = false anyhow = { workspace = true } tracing = { workspace = true } jsonrpsee = { workspace = true, features = ["http-client", "server"] } -sov-rollup-interface = { path = "../../rollup-interface" } +sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] } sov-evm = { path = "../../module-system/module-implementations/sov-evm" } demo-stf = { path = "../../examples/demo-rollup/stf", features = ["native"] } @@ -34,7 +34,7 @@ tokio = { workspace = true } schnellru = "0.2.1" [dev-dependencies] -sov-mock-da = { path = "../../adapters/mock-da" } +sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } tokio = { workspace = true } diff --git a/full-node/sov-sequencer/Cargo.toml b/full-node/sov-sequencer/Cargo.toml index 900d85824..eeffe5cd3 100644 --- a/full-node/sov-sequencer/Cargo.toml +++ b/full-node/sov-sequencer/Cargo.toml @@ -28,6 +28,6 @@ tempfile = { workspace = true } rand = { workspace = true } tokio = { workspace = true } async-trait = { workspace = true } - sov-value-setter = { path = "../../module-system/module-implementations/examples/sov-value-setter", features = ["native"] } +sov-rollup-interface = { path = "../../rollup-interface", version = "0.3", features = ["native"] } sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } diff --git a/module-system/module-implementations/integration-tests/Cargo.toml b/module-system/module-implementations/integration-tests/Cargo.toml index 56919496e..10230bde3 100644 --- a/module-system/module-implementations/integration-tests/Cargo.toml +++ b/module-system/module-implementations/integration-tests/Cargo.toml @@ -20,11 +20,12 @@ jsonrpsee = { workspace = true } sov-modules-api = { path = "../../sov-modules-api", features = ["native"] } sov-state = { path = "../../sov-state", features = ["native"] } -sov-mock-da = { path = "../../../adapters/mock-da" } + sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-schema-db = { path = "../../../full-node/db/sov-schema-db" } sov-data-generators = { path = "../../utils/sov-data-generators" } sov-rollup-interface = { path = "../../../rollup-interface" } +sov-mock-da = { path = "../../../adapters/mock-da" } sov-modules-stf-template = { path = "../../sov-modules-stf-template", features = ["native"] } sov-chain-state = { path = "../sov-chain-state", features = ["native"] } diff --git a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml index dc9e2bc33..fd8cecbf6 100644 --- a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml +++ b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml @@ -14,7 +14,7 @@ resolver = "2" [dev-dependencies] sov-sequencer-registry = { path = ".", features = ["native"] } -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } tempfile = { workspace = true } [dependencies] diff --git a/module-system/module-schemas/build.rs b/module-system/module-schemas/build.rs index 965407c2b..b219e3292 100644 --- a/module-system/module-schemas/build.rs +++ b/module-system/module-schemas/build.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::io::{self, Write}; -use sov_mock_da::MockDaSpec; +use sov_mock_da::verifier::MockDaSpec; use sov_mock_zkvm::MockZkvm; use sov_modules_api::default_context::DefaultContext as C; use sov_modules_api::ModuleCallJsonSchema; diff --git a/module-system/sov-cli/Cargo.toml b/module-system/sov-cli/Cargo.toml index ac5543e8f..2b253707d 100644 --- a/module-system/sov-cli/Cargo.toml +++ b/module-system/sov-cli/Cargo.toml @@ -30,4 +30,4 @@ jsonrpsee = { workspace = true, features = ["client"] } [dev-dependencies] tempfile = { workspace = true } demo-stf = { path = "../../examples/demo-rollup/stf", features = ["native"] } -sov-mock-da = { path = "../../adapters/mock-da" } +sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } diff --git a/module-system/utils/sov-data-generators/src/lib.rs b/module-system/utils/sov-data-generators/src/lib.rs index f11661c76..e80550277 100644 --- a/module-system/utils/sov-data-generators/src/lib.rs +++ b/module-system/utils/sov-data-generators/src/lib.rs @@ -1,11 +1,12 @@ use std::rc::Rc; use borsh::ser::BorshSerialize; -use sov_mock_da::{MockAddress, MockBlob, MockDaSpec}; +use sov_mock_da::verifier::MockDaSpec; +use sov_mock_da::{MockAddress, MockBlob}; use sov_modules_api::transaction::Transaction; pub use sov_modules_api::EncodeCall; -use sov_modules_api::{Context, DaSpec, Module, RollupAddress, Spec}; -use sov_modules_stf_template::{Batch, RawTx, SequencerOutcome, TxEffect}; +use sov_modules_api::{Context, DaSpec, Module, Spec}; +use sov_modules_stf_template::{Batch, RawTx}; pub mod bank_data; pub mod value_setter_data; @@ -20,6 +21,7 @@ pub fn new_test_blob_from_batch( MockBlob::new(data, address, hash) } +// TODO: Fix this // pub fn has_tx_events( // apply_blob_outcome: &BatchReceipt, TxEffect>, // a: &[TransactionReceipt], diff --git a/utils/rng-da-service/Cargo.toml b/utils/rng-da-service/Cargo.toml index e714c8442..cb3387ebc 100644 --- a/utils/rng-da-service/Cargo.toml +++ b/utils/rng-da-service/Cargo.toml @@ -20,4 +20,4 @@ demo-stf = { path = "../../examples/demo-rollup/stf" } sov-bank = { path = "../../module-system/module-implementations/sov-bank" } sov-modules-api = { path = "../../module-system/sov-modules-api", features = ["native"] } sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] } -sov-mock-da = { path = "../../adapters/mock-da" } +sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } From 45b57f763d4f5a6c084b11b8020b645b638172df Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 16:45:49 +0100 Subject: [PATCH 04/18] [no ci] More fixes in tests --- Cargo.lock | 3 +++ examples/demo-rollup/src/test_rpc.rs | 2 +- examples/demo-rollup/stf/Cargo.toml | 2 +- .../stf/src/tests/da_simulation.rs | 2 +- examples/demo-rollup/stf/src/tests/mod.rs | 11 +++----- .../demo-rollup/stf/src/tests/stf_tests.rs | 10 +++---- .../integration-tests/Cargo.toml | 4 +-- .../src/chain_state/tests.rs | 2 +- .../sov-attester-incentives/Cargo.toml | 3 ++- .../src/tests/challenger.rs | 7 +++-- .../sov-blob-storage/Cargo.toml | 2 +- .../sov-chain-state/Cargo.toml | 2 +- .../sov-prover-incentives/Cargo.toml | 3 ++- .../sov-prover-incentives/src/tests.rs | 2 +- module-system/module-schemas/Cargo.toml | 2 +- .../sov-modules-stf-template/src/lib.rs | 1 + .../utils/sov-data-generators/Cargo.toml | 2 +- .../utils/sov-data-generators/src/lib.rs | 26 +++++++++---------- 18 files changed, 42 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cea2e2969..896b24f9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2124,6 +2124,7 @@ dependencies = [ "sov-data-generators", "sov-evm", "sov-mock-da", + "sov-mock-zkvm", "sov-modules-api", "sov-modules-stf-template", "sov-nft-module", @@ -8325,6 +8326,7 @@ dependencies = [ "sov-mock-da", "sov-mock-zkvm", "sov-modules-api", + "sov-rollup-interface", "sov-state", "tempfile", "thiserror", @@ -8824,6 +8826,7 @@ dependencies = [ "serde_json", "sov-bank", "sov-mock-da", + "sov-mock-zkvm", "sov-modules-api", "sov-prover-incentives", "sov-state", diff --git a/examples/demo-rollup/src/test_rpc.rs b/examples/demo-rollup/src/test_rpc.rs index d0aed9815..fc8fc3398 100644 --- a/examples/demo-rollup/src/test_rpc.rs +++ b/examples/demo-rollup/src/test_rpc.rs @@ -7,7 +7,7 @@ use reqwest::header::CONTENT_TYPE; use serde_json::json; use sov_db::ledger_db::{LedgerDB, SlotCommit}; #[cfg(test)] -use sov_rollup_interface::mocks::{MockBlock, MockBlockHeader, MockHash}; +use sov_mock_da::{MockBlock, MockBlockHeader, MockHash}; use sov_rollup_interface::services::da::SlotData; use sov_rollup_interface::stf::fuzzing::BatchReceiptStrategyArgs; use sov_rollup_interface::stf::{BatchReceipt, Event, TransactionReceipt}; diff --git a/examples/demo-rollup/stf/Cargo.toml b/examples/demo-rollup/stf/Cargo.toml index cd6cce5e6..72ddd6f7a 100644 --- a/examples/demo-rollup/stf/Cargo.toml +++ b/examples/demo-rollup/stf/Cargo.toml @@ -46,9 +46,9 @@ sov-evm = { path = "../../../module-system/module-implementations/sov-evm", opti [dev-dependencies] - sov-data-generators = { path = "../../../module-system/utils/sov-data-generators" } demo-stf = { path = ".", features = ["native"] } +sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } tempfile = { workspace = true } rand = "0.8" diff --git a/examples/demo-rollup/stf/src/tests/da_simulation.rs b/examples/demo-rollup/stf/src/tests/da_simulation.rs index 4d9478cbf..b11c68619 100644 --- a/examples/demo-rollup/stf/src/tests/da_simulation.rs +++ b/examples/demo-rollup/stf/src/tests/da_simulation.rs @@ -6,10 +6,10 @@ use sov_data_generators::bank_data::{ }; use sov_data_generators::value_setter_data::{ValueSetterMessage, ValueSetterMessages}; use sov_data_generators::MessageGenerator; +use sov_mock_da::MockDaSpec; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_stf_template::RawTx; -use sov_rollup_interface::mocks::MockDaSpec; use crate::runtime::Runtime; diff --git a/examples/demo-rollup/stf/src/tests/mod.rs b/examples/demo-rollup/stf/src/tests/mod.rs index 362049489..53d179cb2 100644 --- a/examples/demo-rollup/stf/src/tests/mod.rs +++ b/examples/demo-rollup/stf/src/tests/mod.rs @@ -1,10 +1,10 @@ use std::path::Path; +use sov_mock_da::MockDaSpec; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::DaSpec; use sov_modules_stf_template::kernels::basic::BasicKernel; use sov_modules_stf_template::AppTemplate; -use sov_rollup_interface::mocks::MockDaSpec; use sov_state::storage_manager::ProverStorageManager; use sov_state::DefaultStorageSpec; @@ -18,13 +18,8 @@ pub(crate) type C = DefaultContext; pub(crate) type Da = MockDaSpec; pub(crate) type RuntimeTest = Runtime; -pub(crate) type AppTemplateTest = AppTemplate< - DefaultContext, - Da, - sov_rollup_interface::mocks::MockZkvm, - RuntimeTest, - BasicKernel, ->; +pub(crate) type AppTemplateTest = + AppTemplate>; pub(crate) fn create_storage_manager_for_tests( path: impl AsRef, diff --git a/examples/demo-rollup/stf/src/tests/stf_tests.rs b/examples/demo-rollup/stf/src/tests/stf_tests.rs index 411873696..90fc0fe76 100644 --- a/examples/demo-rollup/stf/src/tests/stf_tests.rs +++ b/examples/demo-rollup/stf/src/tests/stf_tests.rs @@ -3,12 +3,12 @@ pub mod test { use sov_cli::wallet_state::PrivateKeyAndAddress; use sov_data_generators::bank_data::get_default_token_address; - use sov_data_generators::new_test_blob_from_batch; + use sov_data_generators::{has_tx_events, new_test_blob_from_batch}; + use sov_mock_da::{MockBlock, MockDaSpec, MOCK_SEQUENCER_DA_ADDRESS}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_api::{Context, PrivateKey, WorkingSet}; use sov_modules_stf_template::{AppTemplate, Batch, SequencerOutcome}; - use sov_rollup_interface::mocks::{MockBlock, MockDaSpec, MOCK_SEQUENCER_DA_ADDRESS}; use sov_rollup_interface::stf::StateTransitionFunction; use sov_rollup_interface::storage::StorageManager; @@ -217,16 +217,16 @@ pub mod test { ); assert_eq!(1, apply_block_result.batch_receipts.len()); - // let apply_blob_outcome = apply_block_result.batch_receipts[0].clone(); + let apply_blob_outcome = apply_block_result.batch_receipts[0].clone(); assert_eq!( SequencerOutcome::Ignored, - &apply_block_result.batch_receipts[0].inner, + apply_blob_outcome.inner, "Batch should have been skipped due to unknown sequencer" ); // Assert that there are no events - // assert!(!has_tx_events(&apply_blob_outcome)); + assert!(!has_tx_events(&apply_blob_outcome)); } fn read_private_key() -> PrivateKeyAndAddress { diff --git a/module-system/module-implementations/integration-tests/Cargo.toml b/module-system/module-implementations/integration-tests/Cargo.toml index 10230bde3..63b223c46 100644 --- a/module-system/module-implementations/integration-tests/Cargo.toml +++ b/module-system/module-implementations/integration-tests/Cargo.toml @@ -24,8 +24,8 @@ sov-state = { path = "../../sov-state", features = ["native"] } sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-schema-db = { path = "../../../full-node/db/sov-schema-db" } sov-data-generators = { path = "../../utils/sov-data-generators" } -sov-rollup-interface = { path = "../../../rollup-interface" } -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-rollup-interface = { path = "../../../rollup-interface", features = ["native"] } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } sov-modules-stf-template = { path = "../../sov-modules-stf-template", features = ["native"] } sov-chain-state = { path = "../sov-chain-state", features = ["native"] } diff --git a/module-system/module-implementations/integration-tests/src/chain_state/tests.rs b/module-system/module-implementations/integration-tests/src/chain_state/tests.rs index 4ac242bc4..97f73e4c9 100644 --- a/module-system/module-implementations/integration-tests/src/chain_state/tests.rs +++ b/module-system/module-implementations/integration-tests/src/chain_state/tests.rs @@ -1,6 +1,6 @@ use sov_chain_state::{StateTransitionId, TransitionInProgress}; use sov_data_generators::value_setter_data::ValueSetterMessages; -use sov_data_generators::{new_test_blob_from_batch, MessageGenerator}; +use sov_data_generators::{has_tx_events, new_test_blob_from_batch, MessageGenerator}; use sov_mock_da::{MockBlock, MockBlockHeader, MockDaSpec, MockHash, MockValidityCond}; use sov_mock_zkvm::MockZkvm; use sov_modules_api::default_context::DefaultContext; diff --git a/module-system/module-implementations/sov-attester-incentives/Cargo.toml b/module-system/module-implementations/sov-attester-incentives/Cargo.toml index 2dd1c7d24..2f404e7ab 100644 --- a/module-system/module-implementations/sov-attester-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-attester-incentives/Cargo.toml @@ -13,10 +13,11 @@ resolver = "2" publish = false [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3" } sov-attester-incentives = { path = ".", features = ["native"] } +sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["native"] } tempfile = { workspace = true } [dependencies] diff --git a/module-system/module-implementations/sov-attester-incentives/src/tests/challenger.rs b/module-system/module-implementations/sov-attester-incentives/src/tests/challenger.rs index 5a4b6df94..dcf44f489 100644 --- a/module-system/module-implementations/sov-attester-incentives/src/tests/challenger.rs +++ b/module-system/module-implementations/sov-attester-incentives/src/tests/challenger.rs @@ -1,9 +1,8 @@ use borsh::BorshSerialize; +use sov_mock_da::{MockDaSpec, MockValidityCond, MockValidityCondChecker}; +use sov_mock_zkvm::{MockCodeCommitment, MockProof, MockZkvm}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::WorkingSet; -use sov_rollup_interface::mocks::{ - MockCodeCommitment, MockDaSpec, MockProof, MockValidityCond, MockValidityCondChecker, -}; use sov_rollup_interface::zk::StateTransition; use sov_state::ProverStorage; @@ -140,7 +139,7 @@ fn invalid_proof_helper( challenger_address: sov_modules_api::Address, module: &crate::AttesterIncentives< DefaultContext, - sov_rollup_interface::mocks::MockZkvm, + MockZkvm, MockDaSpec, MockValidityCondChecker, >, diff --git a/module-system/module-implementations/sov-blob-storage/Cargo.toml b/module-system/module-implementations/sov-blob-storage/Cargo.toml index d1803c954..f829bcb91 100644 --- a/module-system/module-implementations/sov-blob-storage/Cargo.toml +++ b/module-system/module-implementations/sov-blob-storage/Cargo.toml @@ -32,7 +32,7 @@ clap = { workspace = true, optional = true } [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } sov-blob-storage = { path = ".", features = ["native"] } sov-bank = { path = "../sov-bank" } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-chain-state/Cargo.toml b/module-system/module-implementations/sov-chain-state/Cargo.toml index 81235be52..eb87043cf 100644 --- a/module-system/module-implementations/sov-chain-state/Cargo.toml +++ b/module-system/module-implementations/sov-chain-state/Cargo.toml @@ -25,7 +25,7 @@ sov-state = { path = "../../sov-state", version = "0.3" } tempfile = { workspace = true } sov-data-generators = { path = "../../utils/sov-data-generators" } sov-chain-state = { path = ".", features = ["native"] } -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } [features] diff --git a/module-system/module-implementations/sov-prover-incentives/Cargo.toml b/module-system/module-implementations/sov-prover-incentives/Cargo.toml index 57be8ab18..59f847494 100644 --- a/module-system/module-implementations/sov-prover-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-prover-incentives/Cargo.toml @@ -12,7 +12,8 @@ readme = "README.md" resolver = "2" [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } +sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3", features = ["native"] } tempfile = { workspace = true } sov-prover-incentives = { features = ["native"], path = "." } diff --git a/module-system/module-implementations/sov-prover-incentives/src/tests.rs b/module-system/module-implementations/sov-prover-incentives/src/tests.rs index 3a9dff590..f82523197 100644 --- a/module-system/module-implementations/sov-prover-incentives/src/tests.rs +++ b/module-system/module-implementations/sov-prover-incentives/src/tests.rs @@ -1,7 +1,7 @@ +use sov_mock_zkvm::{MockCodeCommitment, MockProof, MockZkvm}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::digest::Digest; use sov_modules_api::{Address, Module, Spec, WorkingSet}; -use sov_rollup_interface::mocks::{MockCodeCommitment, MockProof, MockZkvm}; use sov_state::ProverStorage; use crate::ProverIncentives; diff --git a/module-system/module-schemas/Cargo.toml b/module-system/module-schemas/Cargo.toml index 11c704add..21ac18156 100644 --- a/module-system/module-schemas/Cargo.toml +++ b/module-system/module-schemas/Cargo.toml @@ -15,7 +15,7 @@ publish = false [build-dependencies] sov-modules-api = { path = "../sov-modules-api" } # Remove when mock-zkvm -sov-mock-da = { path = "../../adapters/mock-da" } +sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } sov-mock-zkvm = { path = "../../adapters/mock-zkvm" } # Modules diff --git a/module-system/sov-modules-stf-template/src/lib.rs b/module-system/sov-modules-stf-template/src/lib.rs index deb904e0b..1a6e17aff 100644 --- a/module-system/sov-modules-stf-template/src/lib.rs +++ b/module-system/sov-modules-stf-template/src/lib.rs @@ -13,6 +13,7 @@ use sov_modules_api::{ BasicAddress, BlobReaderTrait, Context, DaSpec, DispatchCall, Genesis, Spec, StateCheckpoint, Zkvm, }; +pub use sov_rollup_interface::stf::BatchReceipt; use sov_rollup_interface::stf::{SlotResult, StateTransitionFunction}; use sov_state::Storage; #[cfg(all(target_os = "zkvm", feature = "bench"))] diff --git a/module-system/utils/sov-data-generators/Cargo.toml b/module-system/utils/sov-data-generators/Cargo.toml index 327b1f5ce..5f287caeb 100644 --- a/module-system/utils/sov-data-generators/Cargo.toml +++ b/module-system/utils/sov-data-generators/Cargo.toml @@ -18,7 +18,7 @@ sov-modules-stf-template = { path = "../../sov-modules-stf-template", features = sov-value-setter = { path = "../../module-implementations/examples/sov-value-setter", features = ["native"] } sov-bank = { path = "../../module-implementations/sov-bank", features = ["native"] } sov-state = { path = "../../sov-state" } -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } borsh = { workspace = true } diff --git a/module-system/utils/sov-data-generators/src/lib.rs b/module-system/utils/sov-data-generators/src/lib.rs index e80550277..e295dfd67 100644 --- a/module-system/utils/sov-data-generators/src/lib.rs +++ b/module-system/utils/sov-data-generators/src/lib.rs @@ -5,8 +5,8 @@ use sov_mock_da::verifier::MockDaSpec; use sov_mock_da::{MockAddress, MockBlob}; use sov_modules_api::transaction::Transaction; pub use sov_modules_api::EncodeCall; -use sov_modules_api::{Context, DaSpec, Module, Spec}; -use sov_modules_stf_template::{Batch, RawTx}; +use sov_modules_api::{Context, DaSpec, Module, RollupAddress, Spec}; +use sov_modules_stf_template::{Batch, BatchReceipt, RawTx, TxEffect}; pub mod bank_data; pub mod value_setter_data; @@ -21,18 +21,16 @@ pub fn new_test_blob_from_batch( MockBlob::new(data, address, hash) } -// TODO: Fix this -// pub fn has_tx_events( -// apply_blob_outcome: &BatchReceipt, TxEffect>, -// a: &[TransactionReceipt], -// ) -> bool { -// let events = apply_blob_outcome -// .tx_receipts -// .iter() -// .flat_map(|receipts| receipts.events.iter()); -// -// events.peekable().peek().is_some() -// } +pub fn has_tx_events( + apply_blob_outcome: &BatchReceipt, TxEffect>, +) -> bool { + let events = apply_blob_outcome + .tx_receipts + .iter() + .flat_map(|receipts| receipts.events.iter()); + + events.peekable().peek().is_some() +} /// A generic message object used to create transactions. pub struct Message { From 7d0424f476ea6bb21d2944cedbe032f69f3f49f5 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 16:51:03 +0100 Subject: [PATCH 05/18] More fixes in imports --- examples/demo-rollup/tests/test_helpers.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demo-rollup/tests/test_helpers.rs b/examples/demo-rollup/tests/test_helpers.rs index df9f13a1e..1720e838e 100644 --- a/examples/demo-rollup/tests/test_helpers.rs +++ b/examples/demo-rollup/tests/test_helpers.rs @@ -2,8 +2,8 @@ use std::net::SocketAddr; use demo_stf::genesis_config::GenesisPaths; use sov_demo_rollup::MockDemoRollup; +use sov_mock_da::{MockAddress, MockDaConfig}; use sov_modules_rollup_template::{RollupProverConfig, RollupTemplate}; -use sov_rollup_interface::mocks::{MockAddress, MockDaConfig}; use sov_stf_runner::{RollupConfig, RpcConfig, RunnerConfig, StorageConfig}; use tokio::sync::oneshot; From f74f0eeff0dba4bb843198ed2819c43286cbe278 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 16:56:32 +0100 Subject: [PATCH 06/18] Remove verifier feature --- adapters/avail/Cargo.toml | 3 +-- adapters/celestia/Cargo.toml | 3 +-- adapters/mock-da/Cargo.toml | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/adapters/avail/Cargo.toml b/adapters/avail/Cargo.toml index 9e1704109..25b4cb814 100644 --- a/adapters/avail/Cargo.toml +++ b/adapters/avail/Cargo.toml @@ -35,5 +35,4 @@ sp-core = { version = "21", optional = true } [features] default = ["native"] -native = ["dep:tokio", "dep:codec", "dep:reqwest", "dep:avail-subxt", "dep:subxt", "dep:sp-keyring", "dep:sp-core", "sov-rollup-interface/native"] -verifier = [] +native = ["dep:tokio", "dep:codec", "dep:reqwest", "dep:avail-subxt", "dep:subxt", "dep:sp-keyring", "dep:sp-core", "sov-rollup-interface/native"] \ No newline at end of file diff --git a/adapters/celestia/Cargo.toml b/adapters/celestia/Cargo.toml index e9ee02b9c..639db0b28 100644 --- a/adapters/celestia/Cargo.toml +++ b/adapters/celestia/Cargo.toml @@ -66,5 +66,4 @@ risc0 = [ bench = [ "sov-zk-cycle-macros/bench", "risc0" -] -verifier = [] +] \ No newline at end of file diff --git a/adapters/mock-da/Cargo.toml b/adapters/mock-da/Cargo.toml index 1511f0dba..ff142317f 100644 --- a/adapters/mock-da/Cargo.toml +++ b/adapters/mock-da/Cargo.toml @@ -23,6 +23,4 @@ default = [] native = [ "dep:tokio", "sov-rollup-interface/native" -] -# TODO: Why this feature is needed? -verifier = [] \ No newline at end of file +] \ No newline at end of file From af41d13f112185216854f832ea0a9401669b1e86 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 17:13:23 +0100 Subject: [PATCH 07/18] Forgotten fix in demo rollup tests --- examples/demo-rollup/tests/bank/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/demo-rollup/tests/bank/mod.rs b/examples/demo-rollup/tests/bank/mod.rs index 454518c0b..732d62f3c 100644 --- a/examples/demo-rollup/tests/bank/mod.rs +++ b/examples/demo-rollup/tests/bank/mod.rs @@ -5,12 +5,12 @@ use demo_stf::genesis_config::GenesisPaths; use demo_stf::runtime::RuntimeCall; use jsonrpsee::core::client::{Subscription, SubscriptionClientT}; use jsonrpsee::rpc_params; +use sov_mock_da::MockDaSpec; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_api::transaction::Transaction; use sov_modules_api::{PrivateKey, Spec}; use sov_modules_rollup_template::RollupProverConfig; -use sov_rollup_interface::mocks::MockDaSpec; use sov_sequencer::utils::SimpleClient; use crate::test_helpers::start_rollup; From 2180f5cfc7aa2435be169fbd92fca9e52ee62c57 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 17:55:25 +0100 Subject: [PATCH 08/18] Less public attributes --- adapters/mock-da/src/types/address.rs | 2 +- adapters/mock-da/src/types/mod.rs | 2 +- examples/demo-rollup/src/test_rpc.rs | 4 +- .../stf/src/tests/tx_revert_tests.rs | 6 +-- examples/demo-rollup/tests/test_helpers.rs | 2 +- examples/demo-simple-stf/tests/stf_test.rs | 2 +- .../src/chain_state/tests.rs | 5 ++- .../tests/capability_tests.rs | 6 +-- module-system/module-schemas/Cargo.toml | 1 - utils/rng-da-service/src/lib.rs | 44 ++++++++++--------- 10 files changed, 39 insertions(+), 35 deletions(-) diff --git a/adapters/mock-da/src/types/address.rs b/adapters/mock-da/src/types/address.rs index 2a5947f97..caf8c55db 100644 --- a/adapters/mock-da/src/types/address.rs +++ b/adapters/mock-da/src/types/address.rs @@ -11,7 +11,7 @@ pub const MOCK_SEQUENCER_DA_ADDRESS: [u8; 32] = [0u8; 32]; )] pub struct MockAddress { /// Underlying mock address. - pub addr: [u8; 32], + addr: [u8; 32], } impl MockAddress { diff --git a/adapters/mock-da/src/types/mod.rs b/adapters/mock-da/src/types/mod.rs index e257c77e5..3ecce1cf5 100644 --- a/adapters/mock-da/src/types/mod.rs +++ b/adapters/mock-da/src/types/mod.rs @@ -23,7 +23,7 @@ const JAN_1_2023: i64 = 1672531200; BorshDeserialize, BorshSerialize, )] -pub struct MockHash(pub [u8; 32]); +pub struct MockHash([u8; 32]); impl AsRef<[u8]> for MockHash { fn as_ref(&self) -> &[u8] { diff --git a/examples/demo-rollup/src/test_rpc.rs b/examples/demo-rollup/src/test_rpc.rs index fc8fc3398..8784e625a 100644 --- a/examples/demo-rollup/src/test_rpc.rs +++ b/examples/demo-rollup/src/test_rpc.rs @@ -289,7 +289,7 @@ prop_compose! { let mut total_num_batches = 1; - let mut prev_hash = MockHash([0;32]); + let mut prev_hash = MockHash::from([0;32]); let mut curr_tx_id = 1; let mut curr_event_id = 1; @@ -323,7 +323,7 @@ prop_compose! { slots.push(new_slot); - prev_hash = MockHash(hash); + prev_hash = MockHash::from(hash); } (slots, tx_id_to_event_range, total_num_batches) diff --git a/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs b/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs index 70192296a..d0ade3249 100644 --- a/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs +++ b/examples/demo-rollup/stf/src/tests/tx_revert_tests.rs @@ -1,6 +1,6 @@ use sov_accounts::Response; use sov_data_generators::bank_data::{get_default_private_key, get_default_token_address}; -use sov_data_generators::new_test_blob_from_batch; +use sov_data_generators::{has_tx_events, new_test_blob_from_batch}; use sov_mock_da::{MockAddress, MockBlock, MockDaSpec, MOCK_SEQUENCER_DA_ADDRESS}; use sov_modules_api::default_context::DefaultContext; use sov_modules_api::{PrivateKey, WorkingSet}; @@ -208,7 +208,7 @@ fn test_tx_bad_sig() { ); // The batch receipt contains no events. - // assert!(!has_tx_events(&apply_blob_outcome)); + assert!(!has_tx_events(&apply_blob_outcome)); } } @@ -323,7 +323,7 @@ fn test_tx_bad_serialization() { ); // The batch receipt contains no events. - // assert!(!has_tx_events(&apply_blob_outcome)); + assert!(!has_tx_events(&apply_blob_outcome)); } { diff --git a/examples/demo-rollup/tests/test_helpers.rs b/examples/demo-rollup/tests/test_helpers.rs index 1720e838e..13416405b 100644 --- a/examples/demo-rollup/tests/test_helpers.rs +++ b/examples/demo-rollup/tests/test_helpers.rs @@ -27,7 +27,7 @@ pub async fn start_rollup( }, }, da: MockDaConfig { - sender_address: MockAddress { addr: [0; 32] }, + sender_address: MockAddress::from([0; 32]), }, }; diff --git a/examples/demo-simple-stf/tests/stf_test.rs b/examples/demo-simple-stf/tests/stf_test.rs index 728a35b70..c950a1cbb 100644 --- a/examples/demo-simple-stf/tests/stf_test.rs +++ b/examples/demo-simple-stf/tests/stf_test.rs @@ -6,7 +6,7 @@ use sov_rollup_interface::stf::StateTransitionFunction; #[test] fn test_stf_success() { - let address = MockAddress { addr: [1; 32] }; + let address = MockAddress::from([1; 32]); let stf = &mut CheckHashPreimageStf::::default(); StateTransitionFunction::::init_chain(stf, (), ()); diff --git a/module-system/module-implementations/integration-tests/src/chain_state/tests.rs b/module-system/module-implementations/integration-tests/src/chain_state/tests.rs index 97f73e4c9..f68df8ffd 100644 --- a/module-system/module-implementations/integration-tests/src/chain_state/tests.rs +++ b/module-system/module-implementations/integration-tests/src/chain_state/tests.rs @@ -111,7 +111,10 @@ fn test_simple_value_setter_with_chain_state() { assert_eq!( new_tx_in_progress, - TransitionInProgress::::new(MockHash([10; 32]), MockValidityCond::default()), + TransitionInProgress::::new( + MockHash::from([10; 32]), + MockValidityCond::default() + ), "The new transition has not been correctly stored" ); diff --git a/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs b/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs index 3f762d25a..7710da458 100644 --- a/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs +++ b/module-system/module-implementations/sov-blob-storage/tests/capability_tests.rs @@ -160,7 +160,7 @@ fn do_deferred_blob_test( assert_eq!(expected, blobs_to_execute.len()) } - // If applicable, send the requested callmessage to the blob_storage module + // If applicable, send the requested call message to the blob_storage module if let Some((msg, sender)) = next_slot_info.early_processing_request_with_sender { runtime .blob_storage @@ -222,7 +222,7 @@ fn bonus_blobs_are_delivered_on_request() { } #[test] -fn test_deferrabl_with_small_count() { +fn test_deferrable_with_small_count() { // If blobs are deferred for less than two slots ensure that "early" processing requests do not alter // the order of blob processing if DEFERRED_SLOTS_COUNT > 1 { @@ -653,7 +653,7 @@ struct TestRuntime { pub bank: sov_bank::Bank, pub sequencer_registry: sov_sequencer_registry::SequencerRegistry, pub chain_state: sov_chain_state::ChainState, - pub blob_storage: sov_blob_storage::BlobStorage, + pub blob_storage: BlobStorage, } impl TestRuntime { diff --git a/module-system/module-schemas/Cargo.toml b/module-system/module-schemas/Cargo.toml index 21ac18156..4e8a85b6a 100644 --- a/module-system/module-schemas/Cargo.toml +++ b/module-system/module-schemas/Cargo.toml @@ -14,7 +14,6 @@ publish = false [build-dependencies] sov-modules-api = { path = "../sov-modules-api" } -# Remove when mock-zkvm sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } sov-mock-zkvm = { path = "../../adapters/mock-zkvm" } diff --git a/utils/rng-da-service/src/lib.rs b/utils/rng-da-service/src/lib.rs index 5590aafa9..c53876565 100644 --- a/utils/rng-da-service/src/lib.rs +++ b/utils/rng-da-service/src/lib.rs @@ -3,7 +3,7 @@ use std::env; use async_trait::async_trait; use borsh::ser::BorshSerialize; use demo_stf::runtime::Runtime; -use sov_bank::{Bank, CallMessage, Coins}; +use sov_bank::{Bank, Coins}; use sov_mock_da::{ MockAddress, MockBlob, MockBlock, MockBlockHeader, MockHash, MockValidityCond, MOCK_SEQUENCER_DA_ADDRESS, @@ -12,12 +12,12 @@ use sov_modules_api::default_context::DefaultContext; use sov_modules_api::default_signature::private_key::DefaultPrivateKey; use sov_modules_api::transaction::Transaction; use sov_modules_api::{Address, AddressBech32, EncodeCall, PrivateKey, PublicKey, Spec}; -use sov_rollup_interface::da::{DaSpec, DaVerifier}; -use sov_rollup_interface::services::da::DaService; +use sov_rollup_interface::da::{BlockHeaderTrait, DaSpec, DaVerifier}; +use sov_rollup_interface::services::da::{DaService, SlotData}; pub fn sender_address_with_pkey() -> (Address, DefaultPrivateKey) { // TODO: maybe generate address and private key randomly, instead of - // hardcoding them? + // hard coding them? let addr_bytes = "sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqmlyjd6".to_string(); let addr = Address::from( AddressBech32::try_from(addr_bytes) @@ -47,8 +47,8 @@ pub struct RngDaSpec; impl DaSpec for RngDaSpec { type SlotHash = MockHash; type BlockHeader = MockBlockHeader; - type Address = MockAddress; type BlobTransaction = MockBlob; + type Address = MockAddress; type ValidityCondition = MockValidityCond; type InclusionMultiProof = [u8; 32]; type CompletenessProof = (); @@ -95,12 +95,12 @@ impl DaService for RngDaService { .expect("TXNS_PER_BLOCK var should be a +ve number"); } - let data = if block.header.height == 0 { + let data = if block.header().height() == 0 { // creating the token generate_create(0) } else { // generating the transfer transactions - generate_transfers(num_txns, (block.header.height - 1) * (num_txns as u64)) + generate_transfers(num_txns, (block.header.height() - 1) * (num_txns as u64)) }; let address = MockAddress::from(MOCK_SEQUENCER_DA_ADDRESS); @@ -154,13 +154,14 @@ pub fn generate_transfers(n: usize, start_nonce: u64) -> Vec { for i in 1..(n + 1) { let priv_key = DefaultPrivateKey::generate(); let address: ::Address = priv_key.pub_key().to_address(); - let msg: sov_bank::CallMessage = CallMessage::::Transfer { - to: address, - coins: Coins { - amount: 1, - token_address, - }, - }; + let msg: sov_bank::CallMessage = + sov_bank::CallMessage::::Transfer { + to: address, + coins: Coins { + amount: 1, + token_address, + }, + }; let enc_msg = as EncodeCall>>::encode_call( msg, @@ -177,13 +178,14 @@ pub fn generate_create(start_nonce: u64) -> Vec { let mut message_vec = vec![]; let (minter_address, pk) = sender_address_with_pkey(); - let msg: sov_bank::CallMessage = CallMessage::::CreateToken { - salt: 11, - token_name: "sov-test-token".to_string(), - initial_balance: 100000000, - minter_address, - authorized_minters: vec![minter_address], - }; + let msg: sov_bank::CallMessage = + sov_bank::CallMessage::::CreateToken { + salt: 11, + token_name: "sov-test-token".to_string(), + initial_balance: 100000000, + minter_address, + authorized_minters: vec![minter_address], + }; let enc_msg = as EncodeCall>>::encode_call(msg); let tx = Transaction::::new_signed_tx(&pk, enc_msg, start_nonce); From 95ed0ac709543598711f1f79f20f2817d0bf0f92 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 18:50:01 +0100 Subject: [PATCH 09/18] Remove unused dependencies --- Cargo.lock | 5 ----- Makefile | 2 +- .../provers/risc0/guest-celestia/Cargo.lock | 13 ------------- .../demo-rollup/provers/risc0/guest-mock/Cargo.lock | 13 ------------- examples/demo-rollup/stf/Cargo.toml | 4 ---- .../module-implementations/sov-evm/Cargo.toml | 3 --- rollup-interface/Cargo.toml | 5 ----- 7 files changed, 1 insertion(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 896b24f9e..100806cfc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2115,7 +2115,6 @@ dependencies = [ "secp256k1 0.27.0", "serde", "serde_json", - "simple-nft-module", "sov-accounts", "sov-bank", "sov-blob-storage", @@ -2129,7 +2128,6 @@ dependencies = [ "sov-modules-stf-template", "sov-nft-module", "sov-rollup-interface", - "sov-sequencer", "sov-sequencer-registry", "sov-state", "sov-stf-runner", @@ -8599,10 +8597,8 @@ dependencies = [ "clap 4.4.7", "derive_more", "ethereum-types", - "ethers", "ethers-contract", "ethers-core", - "ethers-middleware", "ethers-signers", "hex", "jsonrpsee 0.20.2", @@ -8872,7 +8868,6 @@ version = "0.3.0" dependencies = [ "anyhow", "async-trait", - "bincode", "borsh", "bytes", "digest 0.10.7", diff --git a/Makefile b/Makefile index 0e81de8da..502ebc66a 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ check-no-std: ## Checks that project compiles without std $(MAKE) -C ./rollup-interface $@ find-unused-deps: ## Prints unused dependencies for project. Note: requires nightly - cargo udeps --all-targets --all-features + cargo +nightly udeps --all-targets --all-features find-flaky-tests: ## Runs tests over and over to find if there's flaky tests flaky-finder -j16 -r320 --continue "cargo test -- --nocapture" diff --git a/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock b/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock index 06ec987fa..7b2cff6e1 100644 --- a/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock +++ b/examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock @@ -606,7 +606,6 @@ dependencies = [ "borsh", "hex", "serde", - "simple-nft-module", "sov-accounts", "sov-bank", "sov-blob-storage", @@ -1947,17 +1946,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" -[[package]] -name = "simple-nft-module" -version = "0.3.0" -dependencies = [ - "anyhow", - "borsh", - "serde", - "sov-modules-api", - "sov-state", -] - [[package]] name = "smol_str" version = "0.2.0" @@ -2161,7 +2149,6 @@ version = "0.3.0" dependencies = [ "anyhow", "async-trait", - "bincode", "borsh", "bytes", "digest 0.10.7", diff --git a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock index c3608452e..341863ffd 100644 --- a/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock +++ b/examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock @@ -268,7 +268,6 @@ dependencies = [ "borsh", "hex", "serde", - "simple-nft-module", "sov-accounts", "sov-bank", "sov-blob-storage", @@ -966,17 +965,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" -[[package]] -name = "simple-nft-module" -version = "0.3.0" -dependencies = [ - "anyhow", - "borsh", - "serde", - "sov-modules-api", - "sov-state", -] - [[package]] name = "sov-accounts" version = "0.3.0" @@ -1144,7 +1132,6 @@ version = "0.3.0" dependencies = [ "anyhow", "async-trait", - "bincode", "borsh", "bytes", "digest", diff --git a/examples/demo-rollup/stf/Cargo.toml b/examples/demo-rollup/stf/Cargo.toml index 72ddd6f7a..2755b5fcc 100644 --- a/examples/demo-rollup/stf/Cargo.toml +++ b/examples/demo-rollup/stf/Cargo.toml @@ -31,7 +31,6 @@ sov-sequencer-registry = { path = "../../../module-system/module-implementations sov-blob-storage = { path = "../../../module-system/module-implementations/sov-blob-storage" } sov-bank = { path = "../../../module-system/module-implementations/sov-bank" } sov-nft-module = { path = "../../../module-system/module-implementations/sov-nft-module" } -simple-nft-module = { path = "../../simple-nft-module" } sov-mock-da = { path = "../../../adapters/mock-da" } sov-chain-state = { path = "../../../module-system/module-implementations/sov-chain-state" } @@ -40,7 +39,6 @@ sov-value-setter = { path = "../../../module-system/module-implementations/examp sov-accounts = { path = "../../../module-system/module-implementations/sov-accounts" } sov-state = { path = "../../../module-system/sov-state" } sov-modules-api = { path = "../../../module-system/sov-modules-api" } -sov-sequencer = { path = "../../../full-node/sov-sequencer", optional = true } # Only enable the evm on "experimental" feature sov-evm = { path = "../../../module-system/module-implementations/sov-evm", optional = true } @@ -60,7 +58,6 @@ native = [ "sov-stf-runner/native", "sov-bank/native", "sov-nft-module/native", - "simple-nft-module/native", "sov-cli", "sov-accounts/native", "sov-sequencer-registry/native", @@ -71,7 +68,6 @@ native = [ "sov-rollup-interface/native", "sov-mock-da/native", "sov-modules-stf-template/native", - "sov-sequencer", "clap", "serde_json", "jsonrpsee", diff --git a/module-system/module-implementations/sov-evm/Cargo.toml b/module-system/module-implementations/sov-evm/Cargo.toml index 68cde09d9..2e4dec4ba 100644 --- a/module-system/module-implementations/sov-evm/Cargo.toml +++ b/module-system/module-implementations/sov-evm/Cargo.toml @@ -13,7 +13,6 @@ resolver = "2" publish = false [dependencies] - sov-modules-api = { path = "../../sov-modules-api", version = "0.3" } sov-state = { path = "../../sov-state", version = "0.3" } @@ -39,9 +38,7 @@ lazy_static = "1.4.0" ethereum-types = { workspace = true } ethers-core = { workspace = true } ethers-contract = { workspace = true } -ethers-middleware = { workspace = true } ethers-signers = { workspace = true } -ethers = { workspace = true } revm = { workspace = true, features = [ "optional_block_gas_limit", diff --git a/rollup-interface/Cargo.toml b/rollup-interface/Cargo.toml index eaa1acee8..082ed255b 100644 --- a/rollup-interface/Cargo.toml +++ b/rollup-interface/Cargo.toml @@ -27,10 +27,6 @@ sha2 = { workspace = true, optional = true } thiserror = { workspace = true, optional = true } tokio = { workspace = true, optional = true } -# TODO: Replace with serde-compatible borsh implementation when it becomes availabile -# see https://github.com/Sovereign-Labs/sovereign-sdk/issues/215 -bincode = { workspace = true, optional = true } - # Proptest should be a dev-dependency, but those can't be optional proptest = { workspace = true, optional = true } proptest-derive = { workspace = true, optional = true } @@ -47,7 +43,6 @@ native = ["std", "tokio"] fuzzing = ["proptest", "proptest-derive", "sha2", "std"] std = [ "anyhow/default", - "bincode", "borsh/default", "borsh/bytes", "bytes", From ae99987c0ad5d1122a752436024ae11f688c7c8e Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 18:55:35 +0100 Subject: [PATCH 10/18] Keep removing native flag --- .../module-implementations/sov-attester-incentives/Cargo.toml | 4 ++-- .../module-implementations/sov-blob-storage/Cargo.toml | 2 +- .../module-implementations/sov-chain-state/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module-system/module-implementations/sov-attester-incentives/Cargo.toml b/module-system/module-implementations/sov-attester-incentives/Cargo.toml index 2f404e7ab..3ae321eaf 100644 --- a/module-system/module-implementations/sov-attester-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-attester-incentives/Cargo.toml @@ -13,11 +13,11 @@ resolver = "2" publish = false [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } +sov-mock-da = { path = "../../../adapters/mock-da" } sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3" } sov-attester-incentives = { path = ".", features = ["native"] } -sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3", features = ["native"] } +sov-rollup-interface = { path = "../../../rollup-interface", version = "0.3" } tempfile = { workspace = true } [dependencies] diff --git a/module-system/module-implementations/sov-blob-storage/Cargo.toml b/module-system/module-implementations/sov-blob-storage/Cargo.toml index f829bcb91..d1803c954 100644 --- a/module-system/module-implementations/sov-blob-storage/Cargo.toml +++ b/module-system/module-implementations/sov-blob-storage/Cargo.toml @@ -32,7 +32,7 @@ clap = { workspace = true, optional = true } [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } +sov-mock-da = { path = "../../../adapters/mock-da" } sov-blob-storage = { path = ".", features = ["native"] } sov-bank = { path = "../sov-bank" } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-chain-state/Cargo.toml b/module-system/module-implementations/sov-chain-state/Cargo.toml index eb87043cf..81235be52 100644 --- a/module-system/module-implementations/sov-chain-state/Cargo.toml +++ b/module-system/module-implementations/sov-chain-state/Cargo.toml @@ -25,7 +25,7 @@ sov-state = { path = "../../sov-state", version = "0.3" } tempfile = { workspace = true } sov-data-generators = { path = "../../utils/sov-data-generators" } sov-chain-state = { path = ".", features = ["native"] } -sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } +sov-mock-da = { path = "../../../adapters/mock-da" } [features] From 2fd3e0869580875d987675fd40e589404e6d5cb3 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 18:56:33 +0100 Subject: [PATCH 11/18] Couple more --- .../module-implementations/sov-prover-incentives/Cargo.toml | 2 +- .../module-implementations/sov-sequencer-registry/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/module-system/module-implementations/sov-prover-incentives/Cargo.toml b/module-system/module-implementations/sov-prover-incentives/Cargo.toml index 59f847494..8e7dcbc4e 100644 --- a/module-system/module-implementations/sov-prover-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-prover-incentives/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" resolver = "2" [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } +sov-mock-da = { path = "../../../adapters/mock-da" } sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3", features = ["native"] } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml index fd8cecbf6..dc9e2bc33 100644 --- a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml +++ b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml @@ -14,7 +14,7 @@ resolver = "2" [dev-dependencies] sov-sequencer-registry = { path = ".", features = ["native"] } -sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } +sov-mock-da = { path = "../../../adapters/mock-da" } tempfile = { workspace = true } [dependencies] From 50536dd74eaa86a7122b176fc0cadd8f96e0b619 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 19:18:45 +0100 Subject: [PATCH 12/18] Fix features --- Cargo.lock | 1 - examples/demo-simple-stf/Cargo.toml | 4 ++-- full-node/sov-ethereum/Cargo.toml | 1 - .../module-implementations/sov-attester-incentives/Cargo.toml | 2 +- .../module-implementations/sov-blob-storage/Cargo.toml | 2 +- .../module-implementations/sov-prover-incentives/Cargo.toml | 2 +- .../module-implementations/sov-sequencer-registry/Cargo.toml | 2 +- 7 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 100806cfc..3914f237b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8580,7 +8580,6 @@ dependencies = [ "serde_json", "sov-accounts", "sov-evm", - "sov-mock-da", "sov-modules-api", "sov-rollup-interface", "tokio", diff --git a/examples/demo-simple-stf/Cargo.toml b/examples/demo-simple-stf/Cargo.toml index 09aabf0d1..62c3a1bdf 100644 --- a/examples/demo-simple-stf/Cargo.toml +++ b/examples/demo-simple-stf/Cargo.toml @@ -14,8 +14,8 @@ serde = { workspace = true } sha2 = { workspace = true } hex = { workspace = true } -sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] } +sov-rollup-interface = { path = "../../rollup-interface" } [dev-dependencies] -sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } +sov-mock-da = { path = "../../adapters/mock-da" } sov-mock-zkvm = { path = "../../adapters/mock-zkvm" } diff --git a/full-node/sov-ethereum/Cargo.toml b/full-node/sov-ethereum/Cargo.toml index 51d75a13a..8cd44bab9 100644 --- a/full-node/sov-ethereum/Cargo.toml +++ b/full-node/sov-ethereum/Cargo.toml @@ -34,7 +34,6 @@ tokio = { workspace = true } schnellru = "0.2.1" [dev-dependencies] -sov-mock-da = { path = "../../adapters/mock-da", features = ["native"] } tokio = { workspace = true } diff --git a/module-system/module-implementations/sov-attester-incentives/Cargo.toml b/module-system/module-implementations/sov-attester-incentives/Cargo.toml index 3ae321eaf..f5d10a67c 100644 --- a/module-system/module-implementations/sov-attester-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-attester-incentives/Cargo.toml @@ -13,7 +13,7 @@ resolver = "2" publish = false [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3" } sov-attester-incentives = { path = ".", features = ["native"] } diff --git a/module-system/module-implementations/sov-blob-storage/Cargo.toml b/module-system/module-implementations/sov-blob-storage/Cargo.toml index d1803c954..f829bcb91 100644 --- a/module-system/module-implementations/sov-blob-storage/Cargo.toml +++ b/module-system/module-implementations/sov-blob-storage/Cargo.toml @@ -32,7 +32,7 @@ clap = { workspace = true, optional = true } [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } sov-blob-storage = { path = ".", features = ["native"] } sov-bank = { path = "../sov-bank" } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-prover-incentives/Cargo.toml b/module-system/module-implementations/sov-prover-incentives/Cargo.toml index 8e7dcbc4e..59f847494 100644 --- a/module-system/module-implementations/sov-prover-incentives/Cargo.toml +++ b/module-system/module-implementations/sov-prover-incentives/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" resolver = "2" [dev-dependencies] -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } sov-mock-zkvm = { path = "../../../adapters/mock-zkvm" } sov-modules-api = { path = "../../sov-modules-api", version = "0.3", features = ["native"] } tempfile = { workspace = true } diff --git a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml index dc9e2bc33..fd8cecbf6 100644 --- a/module-system/module-implementations/sov-sequencer-registry/Cargo.toml +++ b/module-system/module-implementations/sov-sequencer-registry/Cargo.toml @@ -14,7 +14,7 @@ resolver = "2" [dev-dependencies] sov-sequencer-registry = { path = ".", features = ["native"] } -sov-mock-da = { path = "../../../adapters/mock-da" } +sov-mock-da = { path = "../../../adapters/mock-da", features = ["native"] } tempfile = { workspace = true } [dependencies] From 993af254f2de79e5858612b74341ed4ed7f024ed Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 19:24:18 +0100 Subject: [PATCH 13/18] Deny missing docs for new mock things --- adapters/mock-da/src/lib.rs | 5 +++++ adapters/mock-zkvm/src/lib.rs | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/adapters/mock-da/src/lib.rs b/adapters/mock-da/src/lib.rs index 781e5c94d..ff1ef50e0 100644 --- a/adapters/mock-da/src/lib.rs +++ b/adapters/mock-da/src/lib.rs @@ -1,7 +1,12 @@ +#![deny(missing_docs)] + +//! Mock implementation of DaService, DaSpec and DaVerifier for testing. + #[cfg(feature = "native")] mod service; mod types; mod validity_condition; +/// Contains DaSpec and DaVerifier pub mod verifier; #[cfg(feature = "native")] diff --git a/adapters/mock-zkvm/src/lib.rs b/adapters/mock-zkvm/src/lib.rs index 149bff3bb..3e4b7bd6e 100644 --- a/adapters/mock-zkvm/src/lib.rs +++ b/adapters/mock-zkvm/src/lib.rs @@ -1,3 +1,7 @@ +#![deny(missing_docs)] + +//! Mock implementation of zkVM for testing. + use std::io::Write; use anyhow::ensure; @@ -91,7 +95,7 @@ impl sov_rollup_interface::zk::Zkvm for MockZkvm { } #[test] -fn test_mock_proof_roundtrip() { +fn test_mock_proof_round_trip() { let proof = MockProof { program_id: MockCodeCommitment([1; 32]), is_valid: true, From 2eb07cc2e245bd8b8c98ac17e8522d8f7aa798a7 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 19:55:47 +0100 Subject: [PATCH 14/18] Make "data" public, so test can emulate "native" reads --- adapters/mock-da/src/types/mod.rs | 3 ++- examples/demo-simple-stf/src/lib.rs | 2 +- examples/demo-simple-stf/tests/stf_test.rs | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/adapters/mock-da/src/types/mod.rs b/adapters/mock-da/src/types/mod.rs index 3ecce1cf5..256c92707 100644 --- a/adapters/mock-da/src/types/mod.rs +++ b/adapters/mock-da/src/types/mod.rs @@ -110,7 +110,8 @@ pub struct MockDaVerifier {} pub struct MockBlob { pub(crate) address: MockAddress, pub(crate) hash: [u8; 32], - pub(crate) data: CountedBufReader, + /// Actual data from the blob. Public for testing purposes. + pub data: CountedBufReader, } impl MockBlob { diff --git a/examples/demo-simple-stf/src/lib.rs b/examples/demo-simple-stf/src/lib.rs index b44af2f11..d52fbd9d2 100644 --- a/examples/demo-simple-stf/src/lib.rs +++ b/examples/demo-simple-stf/src/lib.rs @@ -75,7 +75,7 @@ impl StateTransitionFunction::apply_slot( stf, &[], From 7a6cd63bf3d155fc3ee5146777a5e3bb1e6a4f97 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Wed, 1 Nov 2023 20:14:35 +0100 Subject: [PATCH 15/18] Fixing packages to publish requirements --- adapters/mock-da/Cargo.toml | 13 +++++++++---- adapters/mock-da/README.md | 10 ++++++++++ adapters/mock-da/src/lib.rs | 3 +-- adapters/mock-da/src/verifier.rs | 2 +- adapters/mock-zkvm/Cargo.toml | 14 ++++++++------ adapters/mock-zkvm/README.md | 3 +++ adapters/mock-zkvm/src/lib.rs | 3 +-- .../sov-modules-rollup-template/Cargo.toml | 1 + packages_to_publish.yml | 2 ++ scripts/validate_packages_to_publish_yml.sh | 2 +- 10 files changed, 37 insertions(+), 16 deletions(-) create mode 100644 adapters/mock-da/README.md create mode 100644 adapters/mock-zkvm/README.md diff --git a/adapters/mock-da/Cargo.toml b/adapters/mock-da/Cargo.toml index ff142317f..f32e37234 100644 --- a/adapters/mock-da/Cargo.toml +++ b/adapters/mock-da/Cargo.toml @@ -1,9 +1,14 @@ [package] name = "sov-mock-da" -version = { workspace = true } -edition = { workspace = true } -license = { workspace = true } -publish = false +description = "Mock impelemntation of Data Availability layer for testing purposes" +version.workspace = true +edition.workspace = true +license.workspace = true +authors.workspace = true +homepage.workspace = true +publish.workspace = true +repository.workspace = true +readme = "README.md" [dependencies] anyhow = { workspace = true } diff --git a/adapters/mock-da/README.md b/adapters/mock-da/README.md new file mode 100644 index 000000000..aa88b9b85 --- /dev/null +++ b/adapters/mock-da/README.md @@ -0,0 +1,10 @@ +# `sov-mock-da` + +Mock implementation of `DaService`, `DaSpec` and `DaVerifier` traits. + +Used for testing and demo purposes. + + +sov-mock-da should be imported with "native" flag if any module is imported with the native flag. +Modules indirectly import rollup-interface with native, +which means that sov-mock-da cannot fully implement BlobReader if it also does not have "native". \ No newline at end of file diff --git a/adapters/mock-da/src/lib.rs b/adapters/mock-da/src/lib.rs index ff1ef50e0..bde22b13c 100644 --- a/adapters/mock-da/src/lib.rs +++ b/adapters/mock-da/src/lib.rs @@ -1,6 +1,5 @@ #![deny(missing_docs)] - -//! Mock implementation of DaService, DaSpec and DaVerifier for testing. +#![doc = include_str!("../README.md")] #[cfg(feature = "native")] mod service; diff --git a/adapters/mock-da/src/verifier.rs b/adapters/mock-da/src/verifier.rs index d5c23b545..6966083d1 100644 --- a/adapters/mock-da/src/verifier.rs +++ b/adapters/mock-da/src/verifier.rs @@ -28,7 +28,7 @@ impl BlobReaderTrait for MockBlob { } } -/// A [`crate::da::DaSpec`] suitable for testing. +/// A [`sov_rollup_interface::da::DaSpec`] suitable for testing. #[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq)] pub struct MockDaSpec; diff --git a/adapters/mock-zkvm/Cargo.toml b/adapters/mock-zkvm/Cargo.toml index a079fd45e..17b7a6947 100644 --- a/adapters/mock-zkvm/Cargo.toml +++ b/adapters/mock-zkvm/Cargo.toml @@ -1,12 +1,14 @@ [package] name = "sov-mock-zkvm" -authors = { workspace = true } description = "Mock zkVM implementation" -edition = { workspace = true } -homepage = { workspace = true } -license = { workspace = true } -repository = { workspace = true } -version = { workspace = true } +version.workspace = true +edition.workspace = true +license.workspace = true +authors.workspace = true +homepage.workspace = true +publish.workspace = true +repository.workspace = true + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/adapters/mock-zkvm/README.md b/adapters/mock-zkvm/README.md new file mode 100644 index 000000000..45b11ff8f --- /dev/null +++ b/adapters/mock-zkvm/README.md @@ -0,0 +1,3 @@ +# `sov-mock-zkvm` + +Mock implementation of zkVM for testing purposes. \ No newline at end of file diff --git a/adapters/mock-zkvm/src/lib.rs b/adapters/mock-zkvm/src/lib.rs index 3e4b7bd6e..267324153 100644 --- a/adapters/mock-zkvm/src/lib.rs +++ b/adapters/mock-zkvm/src/lib.rs @@ -1,6 +1,5 @@ #![deny(missing_docs)] - -//! Mock implementation of zkVM for testing. +#![doc = include_str!("../README.md")] use std::io::Write; diff --git a/module-system/sov-modules-rollup-template/Cargo.toml b/module-system/sov-modules-rollup-template/Cargo.toml index e6dc03902..3b9de3523 100644 --- a/module-system/sov-modules-rollup-template/Cargo.toml +++ b/module-system/sov-modules-rollup-template/Cargo.toml @@ -1,5 +1,6 @@ [package] name = "sov-modules-rollup-template" +description = "This crate contains abstractions needed to create a new rollup" authors = { workspace = true } edition = { workspace = true } homepage = { workspace = true } diff --git a/packages_to_publish.yml b/packages_to_publish.yml index 4d16727f7..ed8706da4 100644 --- a/packages_to_publish.yml +++ b/packages_to_publish.yml @@ -1,4 +1,6 @@ - sov-rollup-interface +- sov-mock-da +- sov-mock-zkvm - sov-first-read-last-write-cache - sov-schema-db - sov-db diff --git a/scripts/validate_packages_to_publish_yml.sh b/scripts/validate_packages_to_publish_yml.sh index 9142f720e..03725f285 100755 --- a/scripts/validate_packages_to_publish_yml.sh +++ b/scripts/validate_packages_to_publish_yml.sh @@ -38,7 +38,7 @@ echo "" echo "Validating the present of package metadata for all packages_to_publish.yml entries..." while read -r pkg; do - # Capture both stdour and stderr. + # Capture both stdout and stderr. output=$(cargo package --allow-dirty -p $pkg --list 2>&1) if echo "$output" | grep -q "warning:"; then printf "%40s | ERR warnings found:\n" "$pkg" From 5aaf2ba6fcc77ca3c067dcef20d73c044b9abf94 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Thu, 2 Nov 2023 10:30:17 +0100 Subject: [PATCH 16/18] Fix doc tests --- examples/demo-rollup/stf/README.md | 1 - examples/demo-simple-stf/README.md | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/demo-rollup/stf/README.md b/examples/demo-rollup/stf/README.md index d44447bc0..930c3d06d 100644 --- a/examples/demo-rollup/stf/README.md +++ b/examples/demo-rollup/stf/README.md @@ -57,7 +57,6 @@ module to your app, just add an additional field to the runtime. ```rust use sov_modules_api::{Genesis, DispatchCall, MessageCodec, Context}; use sov_modules_api::macros::expose_rpc; -use sov_sequencer::Sequencer; use sov_rollup_interface::da::DaSpec; #[cfg(feature = "native")] use sov_accounts::{AccountsRpcImpl, AccountsRpcServer}; diff --git a/examples/demo-simple-stf/README.md b/examples/demo-simple-stf/README.md index 167cf5f27..ecfea2187 100644 --- a/examples/demo-simple-stf/README.md +++ b/examples/demo-simple-stf/README.md @@ -152,10 +152,10 @@ The first transaction that finds the correct hash would break the loop and retur ## Testing -The `sov_rollup_interface::mocks` crate provides two utilities that are useful for testing: +The `sov-mock-da` and `sov-mock-zkvm` crates provide two utilities that are useful for testing: -1. The `MockZkvm` is an implementation of the `Zkvm` trait that can be used in tests. -1. The `MockBlob` is an implementation of the `BlobTransactionTrait` trait that can be used in tests. It accepts an `A: BasicAddress` as a generic parameter. For testing purposes, we use `MockAddress` struct from the same `mocks` module +1. The `sov_mock_zkvm::MockZkvm` is an implementation of the `Zkvm` trait that can be used in tests. +2. The `sov_mock_da::MockBlob` is an implementation of the `BlobTransactionTrait` trait that can be used in tests. It accepts an `A: BasicAddress` as a generic parameter. For testing purposes, we use `MockAddress` struct from the same module You can find more details in the `stf_test.rs` file. @@ -163,7 +163,8 @@ The following test checks the rollup logic. In the test, we call `init_chain, be ```rust use demo_simple_stf::{ApplySlotResult, CheckHashPreimageStf}; -use sov_rollup_interface::mocks::{MockAddress, MockBlob, MockBlock, MockValidityCond, MockZkvm}; +use sov_mock_da::{MockAddress, MockBlob, MockBlock, MockValidityCond}; +use sov_mock_zkvm::MockZkvm; use sov_rollup_interface::stf::StateTransitionFunction; #[test] @@ -171,8 +172,11 @@ fn test_stf() { let address = MockAddress { addr: [1; 32] }; let preimage = vec![0; 32]; - let test_blob = MockBlob::new(preimage, address, [0; 32]); + let mut test_blob = MockBlob::new(preimage, address, [0; 32]); + // Work around for https://github.com/Sovereign-Labs/sovereign-sdk/issues/1129 + test_blob.data.advance(test_blob.data.total_len()); let stf = &mut CheckHashPreimageStf::::default(); + StateTransitionFunction::::init_chain(stf, (), ()); let data = MockBlock::default(); let mut blobs = [test_blob]; @@ -181,8 +185,11 @@ fn test_stf() { let result = StateTransitionFunction::::apply_slot( stf, + &[], (), - &data, + (), + &MockBlockHeader::default(), + &MockValidityCond::default(), &mut blobs, ); From becd272c83bd9cc877ea749c41bd4f468f129123 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Thu, 2 Nov 2023 12:03:48 +0100 Subject: [PATCH 17/18] Decrease debug log for ZkVM --- examples/demo-rollup/src/main.rs | 2 +- module-system/sov-cli/src/workflows/rpc.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/demo-rollup/src/main.rs b/examples/demo-rollup/src/main.rs index 8b04439df..3e02c8b44 100644 --- a/examples/demo-rollup/src/main.rs +++ b/examples/demo-rollup/src/main.rs @@ -35,7 +35,7 @@ async fn main() -> Result<(), anyhow::Error> { // Initializing logging tracing_subscriber::registry() .with(fmt::layer()) - .with(EnvFilter::from_str("debug,hyper=info").unwrap()) + .with(EnvFilter::from_str("debug,hyper=info,guest_execution=info").unwrap()) .init(); let args = Args::parse(); diff --git a/module-system/sov-cli/src/workflows/rpc.rs b/module-system/sov-cli/src/workflows/rpc.rs index 9ba11049e..a82255d7f 100644 --- a/module-system/sov-cli/src/workflows/rpc.rs +++ b/module-system/sov-cli/src/workflows/rpc.rs @@ -90,9 +90,9 @@ impl R if let RpcWorkflows::SetUrl { rpc_url } = self { let _client = HttpClientBuilder::default() .build(rpc_url) - .context("Invalid rpc url: ")?; + .context("Invalid RPC url: ")?; wallet_state.rpc_url = Some(rpc_url.clone()); - println!("Set rpc url to {}", rpc_url); + println!("Set RPC url to {}", rpc_url); return Ok(()); } @@ -181,7 +181,7 @@ async fn get_nonce_for_account nonce, _ => 0, From c7848a9f67124a979404d186d81c78357de874a7 Mon Sep 17 00:00:00 2001 From: Nikolai Golub Date: Thu, 2 Nov 2023 13:29:12 +0100 Subject: [PATCH 18/18] Explicitly do not have about on sov-cli --- module-system/sov-modules-rollup-template/src/wallet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module-system/sov-modules-rollup-template/src/wallet.rs b/module-system/sov-modules-rollup-template/src/wallet.rs index e0cffaf2f..37b8fc6f5 100644 --- a/module-system/sov-modules-rollup-template/src/wallet.rs +++ b/module-system/sov-modules-rollup-template/src/wallet.rs @@ -23,7 +23,7 @@ enum Workflows { } #[derive(clap::Parser)] -#[command(author, version, about, long_about = None)] +#[command(author, version, about = None, long_about = None)] struct CliApp { #[clap(subcommand)] workflow: Workflows,