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

sov-stf-runner should not depend on modules #991

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 6 additions & 3 deletions Cargo.lock

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

6 changes: 5 additions & 1 deletion examples/demo-prover/benches/prover_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ async fn main() -> Result<(), anyhow::Error> {
let mut num_total_transactions = 0;

let temp_dir = TempDir::new().expect("Unable to create temporary directory");

rollup_config.storage.path = PathBuf::from(temp_dir.path());

let da_service = CelestiaService::new(
Expand All @@ -173,7 +174,10 @@ async fn main() -> Result<(), anyhow::Error> {
)
.await;

let mut app: App<Risc0Host, CelestiaSpec> = App::new(rollup_config.storage.clone());
let storage_config = sov_state::config::Config {
path: rollup_config.storage.path,
};
let mut app: App<Risc0Host, CelestiaSpec> = App::new(storage_config);

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

Expand Down
2 changes: 0 additions & 2 deletions examples/demo-prover/methods/guest-celestia/Cargo.lock

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

2 changes: 0 additions & 2 deletions examples/demo-prover/methods/guest-mock/Cargo.lock

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

5 changes: 4 additions & 1 deletion examples/demo-rollup/benches/rollup_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ fn rollup_bench(_bench: &mut Criterion) {

let da_service = Arc::new(RngDaService::new());

let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(rollup_config.storage);
let storage_config = sov_state::config::Config {
path: rollup_config.storage.path,
};
let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(storage_config);

let mut demo = demo_runner.stf;
let sequencer_da_address = MockAddress::from(MOCK_SEQUENCER_DA_ADDRESS);
Expand Down
5 changes: 4 additions & 1 deletion examples/demo-rollup/benches/rollup_coarse_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,10 @@ async fn main() -> Result<(), anyhow::Error> {

let da_service = Arc::new(RngDaService::new());

let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(rollup_config.storage);
let storage_config = sov_state::config::Config {
path: rollup_config.storage.path,
};
let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(storage_config);

let mut demo = demo_runner.stf;
let sequencer_da_address = MockAddress::from(MOCK_SEQUENCER_DA_ADDRESS);
Expand Down
14 changes: 10 additions & 4 deletions examples/demo-rollup/src/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use const_rollup_config::SEQUENCER_DA_ADDRESS;
#[cfg(feature = "experimental")]
use demo_stf::app::DefaultPrivateKey;
use demo_stf::app::{create_zk_app_template, App, DefaultContext};
use demo_stf::genesis_config::{get_genesis_config, GenesisPaths};
use demo_stf::genesis_config::{get_genesis_config, GenesisPaths, StorageConfig};
use demo_stf::runtime::{get_rpc_methods, GenesisConfig, Runtime};
use demo_stf::AppVerifier;
#[cfg(feature = "experimental")]
Expand Down Expand Up @@ -111,12 +111,15 @@ pub async fn new_rollup_with_celestia_da<Vm: ZkvmHost, P: AsRef<Path>>(
)
.await;

let app = App::new(rollup_config.storage);
let storage_config = StorageConfig {
path: rollup_config.storage.path,
};
let app = App::new(storage_config);
let sequencer_da_address = CelestiaAddress::from_str(SEQUENCER_DA_ADDRESS)?;

#[cfg(feature = "experimental")]
let eth_signer = read_eth_tx_signers();
let genesis_config = demo_stf::genesis_config::get_genesis_config(
let genesis_config = get_genesis_config(
sequencer_da_address,
genesis_paths,
#[cfg(feature = "experimental")]
Expand Down Expand Up @@ -174,7 +177,10 @@ pub fn new_rollup_with_mock_da_from_config<Vm: ZkvmHost, P: AsRef<Path>>(

#[cfg(feature = "experimental")]
let eth_signer = read_eth_tx_signers();
let app = App::new(rollup_config.storage);
let storage_config = StorageConfig {
path: rollup_config.storage.path,
};
let app = App::new(storage_config);
let genesis_config = get_genesis_config(
sequencer_da_address,
genesis_paths,
Expand Down
8 changes: 4 additions & 4 deletions examples/demo-stf/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use sov_modules_stf_template::AppTemplate;
pub use sov_modules_stf_template::Batch;
use sov_rollup_interface::da::DaSpec;
use sov_rollup_interface::zk::Zkvm;
use sov_state::ZkStorage;
#[cfg(feature = "native")]
use sov_state::{ProverStorage, Storage};
use sov_sequencer::batch_builder::FiFoStrictBatchBuilder;
#[cfg(feature = "native")]
use sov_stf_runner::FiFoStrictBatchBuilder;
use sov_state::config::Config as StorageConfig;
use sov_state::ZkStorage;
#[cfg(feature = "native")]
use sov_stf_runner::StorageConfig;
use sov_state::{ProverStorage, Storage};

use crate::runtime::Runtime;

Expand Down
9 changes: 7 additions & 2 deletions full-node/sov-sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ resolver = "2"


[dependencies]

anyhow = { workspace = true }
borsh = { workspace = true }
hex = { workspace = true }
jsonrpsee = { workspace = true, features = ["client", "server"] }
serde = { workspace = true, features = ["derive"] }
tracing = { workspace = true }
sov-rollup-interface = { path = "../../rollup-interface", version = "0.2" }
sov-modules-api = { path = "../../module-system/sov-modules-api", version = "0.2", features = ["native"] }
sov-state = { path = "../../module-system/sov-state", version = "0.2" }

[dev-dependencies]
tempfile = { workspace = true }
rand = { workspace = true }
tokio = { workspace = true }
async-trait = { workspace = true }

sov-rollup-interface = { path = "../../rollup-interface", features = ["mocks", "native"] }
tokio = { workspace = true }
sov-value-setter = { path = "../../module-system/module-implementations/examples/sov-value-setter", features = ["native"] }
5 changes: 4 additions & 1 deletion full-node/sov-sequencer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
#![doc = include_str!("../README.md")]
use std::sync::Mutex;

/// Concrete implementations of `[BatchBuilder]`
pub mod batch_builder;
/// Utilities for the sequencer rpc
pub mod utils;

use anyhow::anyhow;
use jsonrpsee::types::ErrorObjectOwned;
use jsonrpsee::RpcModule;
use sov_modules_api::utils::to_jsonrpsee_error_object;
use sov_rollup_interface::services::batch_builder::BatchBuilder;
use sov_rollup_interface::services::da::DaService;
use utils::to_jsonrpsee_error_object;

const SEQUENCER_RPC_ERROR: &str = "SEQUENCER_RPC_ERROR";

Expand Down
10 changes: 0 additions & 10 deletions full-node/sov-sequencer/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use borsh::BorshSerialize;
use jsonrpsee::core::client::ClientT;
use jsonrpsee::http_client::{HttpClient, HttpClientBuilder};
use jsonrpsee::types::ErrorObjectOwned;
use jsonrpsee::ws_client::{WsClient, WsClientBuilder};
use tracing::info;

Expand Down Expand Up @@ -81,12 +80,3 @@ impl SimpleClient {
&self.ws_client
}
}

/// Creates an jsonrpsee ErrorObject
pub fn to_jsonrpsee_error_object(err: impl ToString, message: &str) -> ErrorObjectOwned {
ErrorObjectOwned::owned(
jsonrpsee::types::error::UNKNOWN_ERROR_CODE,
message,
Some(err.to_string()),
)
}
11 changes: 6 additions & 5 deletions full-node/sov-stf-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,23 @@ tokio = { workspace = true, optional = true }
hex = { workspace = true }
tracing = { workspace = true, optional = true }
futures = { workspace = true, optional = true }

sov-db = { path = "../db/sov-db", version = "0.2", optional = true }
sov-rollup-interface = { path = "../../rollup-interface", version = "0.2" }
sov-state = { path = "../../module-system/sov-state", version = "0.2" }
sov-modules-api = { path = "../../module-system/sov-modules-api", version = "0.2" }


[dev-dependencies]
tempfile = { workspace = true }
rand = { workspace = true }

sov-sequencer-registry = { path = "../../module-system/module-implementations/sov-sequencer-registry", features = ["native"] }
sov-bank = { path = "../../module-system/module-implementations/sov-bank", features = ["native"] }
sov-modules-stf-template = { path = "../../module-system/sov-modules-stf-template", features = ["native"] }
sov-value-setter = { path = "../../module-system/module-implementations/examples/sov-value-setter", features = ["native"] }

sov-accounts = { path = "../../module-system/module-implementations/sov-accounts", features = ["native"] }
sov-celestia-adapter = { path = "../../adapters/celestia", features = ["native"] }
sov-sequencer = { path = "../sov-sequencer" }

sov-state = { path = "../../module-system/sov-state" }
sov-modules-api = { path = "../../module-system/sov-modules-api" }

[features]
default = []
Expand Down
16 changes: 11 additions & 5 deletions full-node/sov-stf-runner/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::path::{Path, PathBuf};

use serde::de::DeserializeOwned;
use serde::Deserialize;
pub use sov_state::config::Config as StorageConfig;

/// Configuration for StateTransitionRunner.
#[derive(Debug, Clone, PartialEq, Deserialize)]
Expand All @@ -24,14 +23,21 @@ pub struct RpcConfig {
pub bind_port: u16,
}

/// Simple storage configuration
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct StorageConfig {
/// Path that can be utilized by concrete implementation
pub path: PathBuf,
}

/// Rollup Configuration
#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct RollupConfig<DaServiceConfig> {
/// Runner configuration.
/// Currently rollup config runner only supports storage path parameter
pub storage: StorageConfig,
citizen-stig marked this conversation as resolved.
Show resolved Hide resolved
/// TODO
/// Runner own configuration.
pub runner: RunnerConfig,
/// DA configuration.
/// Data Availability service configuration.
pub da: DaServiceConfig,
}

Expand Down
10 changes: 9 additions & 1 deletion full-node/sov-stf-runner/src/ledger_rpc.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use futures::future::{select, Either};
use jsonrpsee::types::ErrorObjectOwned;
use jsonrpsee::{RpcModule, SubscriptionMessage};
use serde::de::DeserializeOwned;
use serde::Serialize;
use sov_db::ledger_db::LedgerDB;
use sov_modules_api::utils::to_jsonrpsee_error_object;
use sov_rollup_interface::rpc::{
BatchIdentifier, EventIdentifier, LedgerRpcProvider, SlotIdentifier, TxIdentifier,
};
Expand Down Expand Up @@ -128,3 +128,11 @@ mod query_args {
Ok(QueryArgs(ids, Default::default()))
}
}

pub fn to_jsonrpsee_error_object(err: impl ToString, message: &str) -> ErrorObjectOwned {
ErrorObjectOwned::owned(
jsonrpsee::types::error::UNKNOWN_ERROR_CODE,
message,
Some(err.to_string()),
)
}
7 changes: 2 additions & 5 deletions full-node/sov-stf-runner/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![deny(missing_docs)]
#![doc = include_str!("../README.md")]

#[cfg(feature = "native")]
mod batch_builder;
#[cfg(feature = "native")]
mod config;

Expand All @@ -14,16 +12,15 @@ mod ledger_rpc;
#[cfg(feature = "native")]
mod runner;
#[cfg(feature = "native")]
pub use batch_builder::FiFoStrictBatchBuilder;
#[cfg(feature = "native")]
pub use config::{from_toml_path, RollupConfig, RunnerConfig, StorageConfig};
#[cfg(feature = "native")]
pub use ledger_rpc::get_ledger_rpc;
#[cfg(feature = "native")]
pub use runner::*;
use serde::{Deserialize, Serialize};
use sov_modules_api::{DaSpec, Zkvm};
use sov_rollup_interface::da::DaSpec;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::Zkvm;

/// Implements the `StateTransitionVerifier` type for checking the validity of a state transition
pub mod verifier;
Expand Down
3 changes: 1 addition & 2 deletions full-node/sov-stf-runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ use std::net::SocketAddr;

use jsonrpsee::RpcModule;
use sov_db::ledger_db::{LedgerDB, SlotCommit};
use sov_modules_api::SlotData;
use sov_rollup_interface::da::{BlobReaderTrait, DaSpec};
use sov_rollup_interface::services::da::DaService;
use sov_rollup_interface::services::da::{DaService, SlotData};
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::ZkvmHost;
use tokio::sync::oneshot;
Expand Down
3 changes: 1 addition & 2 deletions full-node/sov-stf-runner/src/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use std::marker::PhantomData;

use sov_modules_api::Zkvm;
use sov_rollup_interface::da::DaVerifier;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::ZkvmGuest;
use sov_rollup_interface::zk::{Zkvm, ZkvmGuest};

use crate::StateTransitionData;

Expand Down
22 changes: 10 additions & 12 deletions module-system/sov-modules-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ sov-first-read-last-write-cache = { path = "../utils/sov-first-read-last-write-c
sov-state = { path = "../sov-state", version = "0.2" }
sov-rollup-interface = { path = "../../rollup-interface", version = "0.2" }
sov-modules-macros = { path = "../sov-modules-macros", version = "0.2", optional = true }
sov-sequencer = { path = "../../full-node/sov-sequencer", version = "0.2", optional = true }
serde = { workspace = true }
borsh = { workspace = true }
thiserror = { workspace = true }
Expand Down Expand Up @@ -50,16 +49,15 @@ arbitrary = ["dep:arbitrary", "sov-state/arbitrary"]
bench = ["sov-zk-cycle-macros", "risc0-zkvm", "risc0-zkvm-platform"]
default = ["macros"]
native = [
"serde_json",
"rand",
"schemars",
"ed25519-dalek/default",
"ed25519-dalek/rand_core",
"clap",
"jsonrpsee",
"macros",
"sov-modules-macros/native",
"sov-state/native",
"sov-sequencer",
"serde_json",
"rand",
"schemars",
"ed25519-dalek/default",
"ed25519-dalek/rand_core",
"clap",
"jsonrpsee",
"macros",
"sov-modules-macros/native",
"sov-state/native",
]
macros = ["sov-modules-macros"]
Loading
Loading