Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mock adapters to separate crates #1128

Merged
merged 18 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 47 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ members = [
"adapters/avail",
"adapters/risc0",
"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",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions adapters/avail/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
3 changes: 1 addition & 2 deletions adapters/celestia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,4 @@ risc0 = [
bench = [
"sov-zk-cycle-macros/bench",
"risc0"
]
verifier = []
]
8 changes: 4 additions & 4 deletions adapters/celestia/src/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
31 changes: 31 additions & 0 deletions adapters/mock-da/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "sov-mock-da"
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 }
async-trait = { workspace = true }
borsh = { workspace = true, features = ["bytes"] }
bytes = { workspace = true, features = ["serde"] }
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"
]
10 changes: 10 additions & 0 deletions adapters/mock-da/README.md
Original file line number Diff line number Diff line change
@@ -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".
15 changes: 15 additions & 0 deletions adapters/mock-da/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![deny(missing_docs)]
#![doc = include_str!("../README.md")]

#[cfg(feature = "native")]
mod service;
mod types;
mod validity_condition;
/// Contains DaSpec and DaVerifier
pub mod verifier;

#[cfg(feature = "native")]
pub use service::*;
pub use types::*;
pub use validity_condition::*;
pub use verifier::MockDaSpec;
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
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, MockDaVerifier};
use crate::verifier::MockDaSpec;

#[derive(Clone)]
/// DaService used in tests.
Expand Down
Loading
Loading