Skip to content

Commit

Permalink
Merge branch 'nightly' into release/v0.3.0-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
neysofu authored Oct 20, 2023
2 parents aa60cce + 08e842f commit 915cec7
Show file tree
Hide file tree
Showing 56 changed files with 1,418 additions and 620 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ members = [

"module-system/sov-cli",
"module-system/sov-modules-stf-template",
"module-system/sov-modules-rollup-template",
"module-system/sov-modules-macros",
"module-system/sov-state",
"module-system/sov-modules-api",
Expand Down
26 changes: 9 additions & 17 deletions examples/demo-rollup/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,18 @@ sov-celestia-adapter = { path = "../../adapters/celestia", 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",
] }
sov-modules-stf-template = { path = "../../module-system/sov-modules-stf-template", features = [
"native",
] }
sov-modules-api = { path = "../../module-system/sov-modules-api", features = [
"native",
] }
sov-stf-runner = { path = "../../full-node/sov-stf-runner", features = ["native"] }
sov-rollup-interface = { path = "../../rollup-interface", features = ["native"] }

sov-modules-rollup-template = { path = "../../module-system/sov-modules-rollup-template" }
sov-modules-stf-template = { path = "../../module-system/sov-modules-stf-template", features = ["native"] }
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, optional = true }
async-trait = { workspace = true }
anyhow = { workspace = true }
jsonrpsee = { workspace = true, features = ["http-client", "server"] }
serde = { workspace = true, features = ["derive"] }
Expand Down Expand Up @@ -97,7 +89,7 @@ default = [
] # Deviate from convention by making the "native" feature active by default. This aligns with how this package is meant to be used (as a binary first, library second).
experimental = ["default", "sov-ethereum/experimental", "reth-primitives", "secp256k1", "demo-stf/experimental", "sov-ethereum/local"]

bench = ["async-trait", "hex", "sov-risc0-adapter/bench", "sov-zk-cycle-macros/bench", "risc0/bench"]
bench = ["hex", "sov-risc0-adapter/bench", "sov-zk-cycle-macros/bench", "risc0/bench"]
offchain = ["demo-stf/offchain"]

[[bench]]
Expand Down
18 changes: 15 additions & 3 deletions examples/demo-rollup/benches/node/rollup_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,31 @@ use std::time::Duration;
use anyhow::Context;
use criterion::{criterion_group, criterion_main, Criterion};
use demo_stf::genesis_config::{get_genesis_config, GenesisPaths};
use demo_stf::App;
use demo_stf::runtime::Runtime;
use sov_db::ledger_db::{LedgerDB, SlotCommit};
use sov_modules_api::default_context::DefaultContext;
use sov_modules_stf_template::AppTemplate;
use sov_risc0_adapter::host::Risc0Verifier;
use sov_rng_da_service::{RngDaService, RngDaSpec};
use sov_rollup_interface::da::DaSpec;
use sov_rollup_interface::mocks::{
MockAddress, MockBlock, MockBlockHeader, MOCK_SEQUENCER_DA_ADDRESS,
};
use sov_rollup_interface::services::da::DaService;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::Zkvm;
use sov_state::{ProverStorage, Storage};
use sov_stf_runner::{from_toml_path, RollupConfig};
use tempfile::TempDir;

fn new_app<Vm: Zkvm, Da: DaSpec>(
storage_config: sov_state::config::Config,
) -> AppTemplate<DefaultContext, Da, Vm, Runtime<DefaultContext, Da>> {
let storage =
ProverStorage::with_config(storage_config).expect("Failed to open prover storage");
AppTemplate::new(storage.clone())
}

fn rollup_bench(_bench: &mut Criterion) {
let start_height: u64 = 0u64;
let mut end_height: u64 = 100u64;
Expand All @@ -44,9 +57,8 @@ fn rollup_bench(_bench: &mut Criterion) {
let storage_config = sov_state::config::Config {
path: rollup_config.storage.path,
};
let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(storage_config);
let mut demo = new_app::<Risc0Verifier, RngDaSpec>(storage_config);

let mut demo = demo_runner.stf;
let sequencer_da_address = MockAddress::from(MOCK_SEQUENCER_DA_ADDRESS);

let demo_genesis_config = get_genesis_config(
Expand Down
19 changes: 15 additions & 4 deletions examples/demo-rollup/benches/node/rollup_coarse_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@ use std::time::{Duration, Instant};

use anyhow::Context;
use demo_stf::genesis_config::{get_genesis_config, GenesisPaths};
use demo_stf::App;
use demo_stf::runtime::Runtime;
use prometheus::{Histogram, HistogramOpts, Registry};
use sov_db::ledger_db::{LedgerDB, SlotCommit};
use sov_modules_api::default_context::DefaultContext;
use sov_modules_stf_template::AppTemplate;
use sov_risc0_adapter::host::Risc0Verifier;
use sov_rng_da_service::{RngDaService, RngDaSpec};
use sov_rollup_interface::da::DaSpec;
use sov_rollup_interface::mocks::{
MockAddress, MockBlock, MockBlockHeader, MOCK_SEQUENCER_DA_ADDRESS,
};
use sov_rollup_interface::services::da::DaService;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::Zkvm;
use sov_state::{ProverStorage, Storage};
use sov_stf_runner::{from_toml_path, RollupConfig};
use tempfile::TempDir;

#[macro_use]
extern crate prettytable;

use prettytable::Table;
use sov_modules_stf_template::TxEffect;

fn new_app<Vm: Zkvm, Da: DaSpec>(
storage_config: sov_state::config::Config,
) -> AppTemplate<DefaultContext, Da, Vm, Runtime<DefaultContext, Da>> {
let storage =
ProverStorage::with_config(storage_config).expect("Failed to open prover storage");
AppTemplate::new(storage.clone())
}

fn print_times(
total: Duration,
apply_block_time: Duration,
Expand Down Expand Up @@ -101,9 +113,8 @@ async fn main() -> Result<(), anyhow::Error> {
let storage_config = sov_state::config::Config {
path: rollup_config.storage.path,
};
let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(storage_config);
let mut demo = new_app::<Risc0Verifier, RngDaSpec>(storage_config);

let mut demo = demo_runner.stf;
let sequencer_da_address = MockAddress::from(MOCK_SEQUENCER_DA_ADDRESS);

let demo_genesis_config = get_genesis_config(
Expand Down
23 changes: 17 additions & 6 deletions examples/demo-rollup/benches/prover/prover_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,34 @@ use std::sync::{Arc, Mutex};
use anyhow::Context;
use const_rollup_config::{ROLLUP_NAMESPACE_RAW, SEQUENCER_DA_ADDRESS};
use demo_stf::genesis_config::{get_genesis_config, GenesisPaths};
use demo_stf::App;
use demo_stf::runtime::Runtime;
use log4rs::config::{Appender, Config, Root};
use regex::Regex;
use risc0::ROLLUP_ELF;
use sov_celestia_adapter::types::{FilteredCelestiaBlock, Namespace};
use sov_celestia_adapter::verifier::address::CelestiaAddress;
use sov_celestia_adapter::verifier::{CelestiaSpec, RollupParams};
use sov_celestia_adapter::CelestiaService;
use sov_modules_api::default_context::DefaultContext;
use sov_modules_api::SlotData;
use sov_modules_stf_template::AppTemplate;
use sov_risc0_adapter::host::Risc0Host;
use sov_rollup_interface::da::DaSpec;
use sov_rollup_interface::services::da::DaService;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::ZkvmHost;
use sov_rollup_interface::zk::{Zkvm, ZkvmHost};
use sov_state::{ProverStorage, Storage};
use sov_stf_runner::{from_toml_path, RollupConfig};
use tempfile::TempDir;

fn new_app<Vm: Zkvm, Da: DaSpec>(
storage_config: sov_state::config::Config,
) -> AppTemplate<DefaultContext, Da, Vm, Runtime<DefaultContext, Da>> {
let storage =
ProverStorage::with_config(storage_config).expect("Failed to open prover storage");
AppTemplate::new(storage.clone())
}

#[derive(Debug)]
struct RegexAppender {
regex: Regex,
Expand Down Expand Up @@ -167,7 +179,8 @@ async fn main() -> Result<(), anyhow::Error> {
let storage_config = sov_state::config::Config {
path: rollup_config.storage.path,
};
let mut app: App<Risc0Host, CelestiaSpec> = App::new(storage_config);

let mut demo = new_app::<Risc0Host, CelestiaSpec>(storage_config);

let sequencer_da_address = CelestiaAddress::from_str(SEQUENCER_DA_ADDRESS).unwrap();

Expand All @@ -178,9 +191,7 @@ async fn main() -> Result<(), anyhow::Error> {
Default::default(),
);
println!("Starting from empty storage, initialization chain");
let mut prev_state_root = app.stf.init_chain(genesis_config);

let mut demo = app.stf;
let mut prev_state_root = demo.init_chain(genesis_config);

let hex_data = read_to_string("benches/prover/blocks.hex").expect("Failed to read data");
let bincoded_blocks: Vec<FilteredCelestiaBlock> = hex_data
Expand Down
3 changes: 3 additions & 0 deletions examples/demo-rollup/provers/risc0/guest-celestia/Cargo.lock

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

5 changes: 3 additions & 2 deletions examples/demo-rollup/provers/risc0/guest-celestia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ demo-stf = { path = "../../../stf" }
sov-risc0-adapter = { path = "../../../../../adapters/risc0" }
const-rollup-config = { path = "../../../../const-rollup-config" }
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" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#![no_main]

use const_rollup_config::ROLLUP_NAMESPACE_RAW;
use demo_stf::runtime::Runtime;
use demo_stf::AppVerifier;
use sov_celestia_adapter::types::Namespace;
use sov_celestia_adapter::verifier::CelestiaVerifier;
use sov_modules_api::default_context::ZkDefaultContext;
use sov_modules_stf_template::AppTemplate;
use sov_risc0_adapter::guest::Risc0Guest;
use demo_stf::{create_zk_app_template, AppVerifier};
use sov_state::ZkStorage;

// The rollup stores its data in the namespace b"sov-test" on Celestia
const ROLLUP_NAMESPACE: Namespace = Namespace::const_v0(ROLLUP_NAMESPACE_RAW);
Expand All @@ -15,8 +19,11 @@ risc0_zkvm::guest::entry!(main);

pub fn main() {
let guest = Risc0Guest::new();
let storage = ZkStorage::new();
let app: AppTemplate<ZkDefaultContext, _, _, Runtime<_, _>> = AppTemplate::new(storage);

let mut stf_verifier = AppVerifier::new(
create_zk_app_template::<Risc0Guest, _>(),
app,
CelestiaVerifier {
rollup_namespace: ROLLUP_NAMESPACE,
},
Expand Down
3 changes: 3 additions & 0 deletions examples/demo-rollup/provers/risc0/guest-mock/Cargo.lock

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

3 changes: 3 additions & 0 deletions examples/demo-rollup/provers/risc0/guest-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ risc0-zkvm-platform = "0.18"
sov-rollup-interface = { path = "../../../../../rollup-interface", features = ["mocks"] }
demo-stf = { path = "../../../stf" }
sov-risc0-adapter = { path = "../../../../../adapters/risc0" }
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" }
Expand Down
11 changes: 8 additions & 3 deletions examples/demo-rollup/provers/risc0/guest-mock/src/bin/mock_da.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#![no_main]
use demo_stf::runtime::Runtime;
use demo_stf::AppVerifier;
use sov_modules_api::default_context::ZkDefaultContext;
use sov_modules_stf_template::AppTemplate;
use sov_risc0_adapter::guest::Risc0Guest;
use demo_stf::{create_zk_app_template, AppVerifier};
use sov_rollup_interface::mocks::MockDaVerifier;
use sov_state::ZkStorage;

risc0_zkvm::guest::entry!(main);

pub fn main() {
let guest = Risc0Guest::new();
let storage = ZkStorage::new();
let app: AppTemplate<ZkDefaultContext, _, _, Runtime<_, _>> = AppTemplate::new(storage);

let mut stf_verifier =
AppVerifier::new(create_zk_app_template::<Risc0Guest, _>(), MockDaVerifier {});
let mut stf_verifier = AppVerifier::new(app, MockDaVerifier {});

stf_verifier
.run_block(guest)
Expand Down
Loading

0 comments on commit 915cec7

Please sign in to comment.