Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ total-clean:

test: ## Runs test suite using next test
@cargo nextest run --no-fail-fast --status-level skip --all-features
@echo "Running demo-rollup SP1 prover tests..."
@cargo nextest run --no-fail-fast --status-level skip -p sov-demo-rollup --no-default-features --features mock_da,sp1

test-all: ## Runs test suite using nextest, across the whole workspace
cargo switcheroo save _backup
Expand Down
45 changes: 35 additions & 10 deletions examples/demo-rollup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ workspace = true
[dependencies]
# non-optional dependencies
sov-address = { workspace = true, features = ["evm"] }
sov-celestia-adapter = { workspace = true, features = ["native"] }
sov-mock-da = { workspace = true, features = ["native"] }
sov-celestia-adapter = { workspace = true, features = ["native"], optional = true }
sov-mock-da = { workspace = true, features = ["native"], optional = true }
sov-rollup-interface = { workspace = true, features = ["native"] }
sov-stf-runner = { workspace = true }
sov-metrics = { workspace = true, features = ["native"] }
Expand All @@ -36,18 +36,18 @@ sov-modules-api = { workspace = true, features = ["native"] }
sov-modules-rollup-blueprint = { workspace = true, features = ["native"] }
sov-modules-stf-blueprint = { workspace = true, features = ["native"] }
sov-solana-offchain-auth = { workspace = true }
sov-risc0-adapter = { workspace = true, features = ["native"] }
sov-risc0-adapter = { workspace = true, features = ["native"], optional = true }
sov-sequencer = { workspace = true }
sov-sp1-adapter = { workspace = true, features = ["native"] }
sov-sp1-adapter = { workspace = true, features = ["native"], optional = true }
rustls = { workspace = true, features = ["ring"] }
sov-full-node-configs = { workspace = true }
sov-state = { workspace = true, features = ["native"] }
sov-eth-dev-signer = { workspace = true }

demo-stf = { workspace = true, features = ["native"] }

risc0 = { path = "./provers/risc0" }
sp1 = { path = "./provers/sp1" }
risc0-prover = { path = "./provers/risc0", package = "risc0", optional = true }
sp1-prover = { path = "./provers/sp1", package = "sp1", optional = true }

borsh = { workspace = true, features = ["bytes", "derive"] }
async-trait = { workspace = true }
Expand Down Expand Up @@ -84,8 +84,6 @@ alloy-rlp = { workspace = true }
sov-eth-client = { workspace = true }
jsonrpsee = { workspace = true }
sov-address = { workspace = true, features = ["native"] }
sov-risc0-adapter = { workspace = true, features = ["native"] }
sov-celestia-adapter = { workspace = true, features = ["native"] }
sov-mock-zkvm = { workspace = true, features = ["native"] }
sov-rollup-interface = { workspace = true }
sov-modules-api = { workspace = true, features = [
Expand Down Expand Up @@ -140,9 +138,24 @@ sov-zkvm-utils = { workspace = true }


[features]
default = []
default = ["mock_da", "mock_zkvm"]

# DA layer features (enable exactly one)
mock_da = ["sov-mock-da"]
mock_da_external = ["sov-mock-da"]
celestia_da = ["sov-celestia-adapter"]

# ZKVM features (enable exactly one)
mock_zkvm = []
risc0 = [
"sov-risc0-adapter",
"risc0-prover",
"sov-metrics/risc0"
]
sp1 = ["sov-sp1-adapter", "sp1-prover"]

# Used for using different encoding between host and guest
bincode = ["risc0/bincode", "sov-risc0-adapter/bincode"]
bincode = ["risc0-prover/bincode", "sov-risc0-adapter/bincode"]
migration-script = [
"dep:sov-blob-storage",
"dep:rockbound",
Expand All @@ -157,6 +170,7 @@ migration-script = [
[[bin]]
name = "sov-cli"
path = "src/sov-cli/main.rs"
required-features = ["celestia_da"]

[[bin]]
name = "sov-demo-rollup"
Expand All @@ -165,6 +179,7 @@ path = "src/main.rs"
[[bin]]
name = "demo-celestia-tester"
path = "src/da_tester/demo_celestia_tester.rs"
required-features = ["celestia_da"]

[[bin]]
name = "mockda-to-celestia-migrate"
Expand All @@ -174,3 +189,13 @@ required-features = ["migration-script"]
[[bin]]
name = "sov-hive-genesis-adapter"
path = "src/hive/genesis_adapter.rs"

[[test]]
name = "all_tests"
path = "tests/all_tests.rs"
required-features = ["mock_da", "mock_zkvm"]

[[test]]
name = "prover_tests"
path = "tests/prover_tests.rs"
required-features = ["sp1"]
21 changes: 9 additions & 12 deletions examples/demo-rollup/src/celestia_rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sov_celestia_adapter::CelestiaService;
use sov_db::ledger_db::LedgerDb;
use sov_db::storage_manager::NomtStorageManager;
use sov_ethereum::EthRpcConfig;
use sov_mock_zkvm::{MockCodeCommitment, MockZkvm, MockZkvmHost};
use sov_mock_zkvm::MockCodeCommitment;
use sov_modules_api::configurable_spec::ConfigurableSpec;
use sov_modules_api::execution_mode::Native;
use sov_modules_api::rest::StateUpdateReceiver;
Expand All @@ -19,8 +19,6 @@ use sov_modules_rollup_blueprint::proof_sender::SovApiProofSender;
use sov_modules_rollup_blueprint::{
FullNodeBlueprint, RollupBlueprint, SequencerCreationReceipt, WalletBlueprint,
};
use sov_risc0_adapter::host::Risc0Host;
use sov_risc0_adapter::{Risc0, Risc0CryptoSpec};
use sov_rollup_interface::da::{DaSpec, DaVerifier};
use sov_rollup_interface::execution_mode::WitnessGeneration;
use sov_rollup_interface::zk::CryptoSpec;
Expand All @@ -31,6 +29,7 @@ use sov_stf_runner::processes::{ParallelProverService, ProverService, RollupProv
use sov_stf_runner::RollupConfig;

use crate::solana_offchain_endpoint::solana_offchain_router;
use crate::zk::{self, InnerCryptoSpec, InnerZkvm, OuterZkvm, OuterZkvmHost};
use crate::{eth_dev_signer, ROLLUP_BATCH_NAMESPACE, ROLLUP_PROOF_NAMESPACE};

/// Rollup with CelestiaDa
Expand All @@ -39,17 +38,17 @@ pub struct CelestiaDemoRollup<M> {
phantom: std::marker::PhantomData<M>,
}

type Hasher = <Risc0CryptoSpec as CryptoSpec>::Hasher;
type Hasher = <InnerCryptoSpec as CryptoSpec>::Hasher;
type NativeStorage =
NomtProverStorage<DefaultStorageSpec<Hasher>, <CelestiaSpec as DaSpec>::SlotHash>;

type CelestiaRollupSpec<M> = ConfigurableSpec<
CelestiaSpec,
Risc0,
MockZkvm,
InnerZkvm,
OuterZkvm,
MultiAddressEvmSolana,
M,
Risc0CryptoSpec,
InnerCryptoSpec,
NativeStorage,
>;

Expand Down Expand Up @@ -162,14 +161,12 @@ impl FullNodeBlueprint<Native> for CelestiaDemoRollup<Native> {

async fn create_prover_service(
&self,
prover_config: RollupProverConfig<Risc0>,
prover_config: RollupProverConfig<InnerZkvm>,
rollup_config: &RollupConfig<<Self::Spec as Spec>::Address, Self::DaService>,
_da_service: &Self::DaService,
) -> Self::ProverService {
let (elf, prover_config_disc) = prover_config.split();
let inner_vm = Risc0Host::new(*elf);

let outer_vm = MockZkvmHost::new_non_blocking();
let (inner_vm, prover_config_disc) = zk::create_inner_vm(prover_config);
let outer_vm = OuterZkvmHost::new_non_blocking();

let rollup_params = RollupParams {
rollup_batch_namespace: ROLLUP_BATCH_NAMESPACE,
Expand Down
24 changes: 10 additions & 14 deletions examples/demo-rollup/src/external_mock_rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use sov_db::storage_manager::NomtStorageManager;
use sov_ethereum::EthRpcConfig;
use sov_mock_da::storable::rpc::StorableMockDaClient;
use sov_mock_da::MockDaSpec;
use sov_mock_zkvm::{MockCodeCommitment, MockZkvm, MockZkvmHost};
use sov_mock_zkvm::MockCodeCommitment;
use sov_modules_api::configurable_spec::ConfigurableSpec;
use sov_modules_api::execution_mode::{Native, WitnessGeneration};
use sov_modules_api::rest::StateUpdateReceiver;
Expand All @@ -18,9 +18,6 @@ use sov_modules_api::{NodeEndpoints, Spec, Storage, SyncStatus, ZkVerifier};
use sov_modules_rollup_blueprint::pluggable_traits::PluggableSpec;
use sov_modules_rollup_blueprint::proof_sender::SovApiProofSender;
use sov_modules_rollup_blueprint::{FullNodeBlueprint, RollupBlueprint, SequencerCreationReceipt};
use sov_risc0_adapter::host::Risc0Host;
use sov_risc0_adapter::Risc0;
use sov_risc0_adapter::Risc0CryptoSpec;
use sov_rollup_interface::da::DaSpec;
use sov_sequencer::{ProofBlobSender, Sequencer};
use sov_state::nomt::prover_storage::NomtProverStorage;
Expand All @@ -30,19 +27,20 @@ use sov_stf_runner::RollupConfig;

use crate::eth_dev_signer;
use crate::solana_offchain_endpoint::solana_offchain_router;
use crate::zk::{self, InnerCryptoSpec, InnerZkvm, OuterZkvm, OuterZkvmHost};

type Hasher = <Risc0CryptoSpec as CryptoSpec>::Hasher;
type Hasher = <InnerCryptoSpec as CryptoSpec>::Hasher;
type NativeStorage =
NomtProverStorage<DefaultStorageSpec<Hasher>, <MockDaSpec as DaSpec>::SlotHash>;

/// The default spec of the rollup
pub type ExternalMockRollupSpec<M> = ConfigurableSpec<
MockDaSpec,
Risc0,
MockZkvm,
InnerZkvm,
OuterZkvm,
MultiAddressEvmSolana,
M,
Risc0CryptoSpec,
InnerCryptoSpec,
NativeStorage,
>;

Expand Down Expand Up @@ -154,21 +152,19 @@ impl FullNodeBlueprint<Native> for ExternalMockDemoRollup<Native> {

async fn create_prover_service(
&self,
prover_config: RollupProverConfig<Risc0>,
prover_config: RollupProverConfig<InnerZkvm>,
rollup_config: &RollupConfig<<Self::Spec as Spec>::Address, Self::DaService>,
_da_service: &Self::DaService,
) -> Self::ProverService {
let (host_args, prover_config_discriminant) = prover_config.split();
let inner_vm = Risc0Host::new(*host_args);

let outer_vm = MockZkvmHost::new_non_blocking();
let (inner_vm, prover_config_disc) = zk::create_inner_vm(prover_config);
let outer_vm = OuterZkvmHost::new_non_blocking();
let da_verifier = Default::default();

ParallelProverService::new_with_default_workers(
inner_vm,
outer_vm,
da_verifier,
prover_config_discriminant,
prover_config_disc,
rollup_config.proof_manager.prover_address,
)
}
Expand Down
28 changes: 22 additions & 6 deletions examples/demo-rollup/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,47 @@

use std::str::FromStr;

use sov_celestia_adapter::types::Namespace;
use sov_modules_api::macros::config_value;
// All DA rollup modules compile when their feature is enabled.
// The types have distinct names so there are no conflicts.
// The main binary uses priority (mock_da > mock_da_external > celestia_da)
// to choose which one to run.

#[cfg(feature = "mock_da")]
mod mock_rollup;

#[cfg(feature = "mock_da")]
pub use mock_rollup::*;

#[cfg(feature = "celestia_da")]
mod celestia_rollup;
#[cfg(feature = "celestia_da")]
pub use celestia_rollup::*;

#[cfg(feature = "mock_da_external")]
mod external_mock_rollup;
#[cfg(feature = "mock_da_external")]
pub use external_mock_rollup::*;

mod solana_offchain_endpoint;

mod zk;
/// Feature-gated inner ZKVM selection.
pub mod zk;
pub use zk::*;

/// The rollup stores its data in the namespace b"sov-test" on Celestia
/// You can change this constant by modifying BATCH_NAMESPACE in constants.toml
pub const ROLLUP_BATCH_NAMESPACE: Namespace = Namespace::const_v0(config_value!("BATCH_NAMESPACE"));
#[cfg(feature = "celestia_da")]
pub const ROLLUP_BATCH_NAMESPACE: sov_celestia_adapter::types::Namespace =
sov_celestia_adapter::types::Namespace::const_v0(sov_modules_api::macros::config_value!(
"BATCH_NAMESPACE"
));

/// The rollup stores the zk proofs in the namespace b"sov-test-p" on Celestia.
/// You can change this constant by modifying PROOF_NAMESPACE in constants.toml
pub const ROLLUP_PROOF_NAMESPACE: Namespace = Namespace::const_v0(config_value!("PROOF_NAMESPACE"));
#[cfg(feature = "celestia_da")]
pub const ROLLUP_PROOF_NAMESPACE: sov_celestia_adapter::types::Namespace =
sov_celestia_adapter::types::Namespace::const_v0(sov_modules_api::macros::config_value!(
"PROOF_NAMESPACE"
));

fn sequencer_type(
config: &sov_full_node_configs::sequencer::SequencerConfig<impl Copy>,
Expand Down
Loading
Loading