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

RollupConfig cleanup #677

Merged
merged 10 commits into from
Aug 18, 2023
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
4 changes: 3 additions & 1 deletion adapters/celestia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ pub mod shares;
pub use crate::celestia::*;

#[cfg(feature = "native")]
pub mod da_service;
mod da_service;
pub mod pfb;
pub mod share_commit;
pub mod types;
mod utils;
pub mod verifier;
#[cfg(feature = "native")]
pub use da_service::{CelestiaService, DaServiceConfig};
5 changes: 0 additions & 5 deletions examples/demo-prover/Cargo.lock

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

17 changes: 8 additions & 9 deletions examples/demo-prover/host/benches/prover_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ use std::str::FromStr;
use std::sync::{Arc, Mutex};

use anyhow::Context;
use celestia::da_service::CelestiaService;
use celestia::types::{FilteredCelestiaBlock, NamespaceId};
use celestia::verifier::address::CelestiaAddress;
use celestia::verifier::{ChainValidityCondition, RollupParams};
use celestia::BlobWithSender;
use celestia::verifier::{CelestiaSpec, RollupParams};
use celestia::CelestiaService;
use const_rollup_config::{ROLLUP_NAMESPACE_RAW, SEQUENCER_DA_ADDRESS};
use demo_stf::app::{App, DefaultPrivateKey};
use demo_stf::genesis_config::create_demo_genesis_config;
Expand Down Expand Up @@ -142,17 +141,18 @@ async fn main() -> Result<(), anyhow::Error> {
}

let rollup_config_path = "benches/rollup_config.toml".to_string();
let mut rollup_config: RollupConfig = from_toml_path(&rollup_config_path)
.context("Failed to read rollup configuration")
.unwrap();
let mut rollup_config: RollupConfig<celestia::DaServiceConfig> =
from_toml_path(&rollup_config_path)
.context("Failed to read rollup configuration")
.unwrap();

let mut num_blocks = 0;
let mut num_blobs = 0;
let mut num_blocks_with_txns = 0;
let mut num_total_transactions = 0;

let temp_dir = TempDir::new().expect("Unable to create temporary directory");
rollup_config.runner.storage.path = PathBuf::from(temp_dir.path());
rollup_config.storage.path = PathBuf::from(temp_dir.path());

let da_service = CelestiaService::new(
rollup_config.da.clone(),
Expand All @@ -164,8 +164,7 @@ async fn main() -> Result<(), anyhow::Error> {

let sequencer_private_key = DefaultPrivateKey::generate();

let mut app: App<Risc0Host, ChainValidityCondition, BlobWithSender> =
App::new(rollup_config.runner.storage.clone());
let mut app: App<Risc0Host, CelestiaSpec> = App::new(rollup_config.storage.clone());

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

Expand Down
13 changes: 7 additions & 6 deletions examples/demo-prover/host/benches/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# We define the rollup's genesis to occur at Celestia block number `start_height`. The rollup will ignore
# any Celestia blocks before this height
start_height = 1

[da]
# The JWT used to authenticate with the celestia light client. Instructions for generating this token can be found in the README
celestia_rpc_auth_token = "MY.SECRET.TOKEN"
Expand All @@ -10,11 +6,16 @@ celestia_rpc_address = "http://localhost:11111/"
# The largest response the rollup will accept from the Celestia node. Defaults to 100 MB
max_celestia_response_body_size = 104_857_600

[runner.storage]
[storage]
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "benches/demo_data"

[rpc_config]
[runner]
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
start_height = 1

[runner.rpc_config]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12345
14 changes: 13 additions & 1 deletion examples/demo-prover/host/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
start_height = 671431
[da]
celestia_rpc_auth_token = "SUPER_SECRET_TOKEN"
celestia_rpc_address = "http://localhost:11111/"
# 100 MB
max_celestia_response_body_size = 104_857_600

[storage]
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "demo_data"

[runner.storage]
path = "demo_data"

[runner]
start_height = 671431

[runner.rpc_config]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12345
18 changes: 5 additions & 13 deletions examples/demo-prover/host/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@ use std::env;
use std::str::FromStr;

use anyhow::Context;
use celestia::da_service::{CelestiaService, DaServiceConfig};
use celestia::types::NamespaceId;
use celestia::verifier::address::CelestiaAddress;
use celestia::verifier::{CelestiaSpec, RollupParams};
use celestia::{CelestiaService, DaServiceConfig};
use const_rollup_config::{ROLLUP_NAMESPACE_RAW, SEQUENCER_DA_ADDRESS};
use demo_stf::app::{App, DefaultPrivateKey};
use demo_stf::genesis_config::create_demo_genesis_config;
use methods::{ROLLUP_ELF, ROLLUP_ID};
use risc0_adapter::host::{Risc0Host, Risc0Verifier};
use serde::Deserialize;
use sov_modules_api::PrivateKey;
use sov_rollup_interface::services::da::DaService;
use sov_rollup_interface::stf::StateTransitionFunction;
use sov_rollup_interface::zk::ZkvmHost;
use sov_state::Storage;
use sov_stf_runner::{from_toml_path, Config as RunnerConfig};
use sov_stf_runner::{from_toml_path, RollupConfig};
use tracing::{info, Level};

#[derive(Debug, Clone, PartialEq, Deserialize)]
pub struct RollupConfig {
pub start_height: u64,
pub da: DaServiceConfig,
pub runner: RunnerConfig,
}

// The rollup stores its data in the namespace b"sov-test" on Celestia
const ROLLUP_NAMESPACE: NamespaceId = NamespaceId(ROLLUP_NAMESPACE_RAW);

Expand All @@ -44,7 +36,7 @@ async fn main() -> Result<(), anyhow::Error> {
let rollup_config_path = env::args()
.nth(1)
.unwrap_or_else(|| "rollup_config.toml".to_string());
let rollup_config: RollupConfig =
let rollup_config: RollupConfig<DaServiceConfig> =
from_toml_path(&rollup_config_path).context("Failed to read rollup configuration")?;

let da_service = CelestiaService::new(
Expand All @@ -57,7 +49,7 @@ async fn main() -> Result<(), anyhow::Error> {

let sequencer_private_key = DefaultPrivateKey::generate();

let mut app: App<Risc0Verifier, CelestiaSpec> = App::new(rollup_config.runner.storage.clone());
let mut app: App<Risc0Verifier, CelestiaSpec> = App::new(rollup_config.storage.clone());

let is_storage_empty = app.get_storage().is_empty();

Expand All @@ -79,7 +71,7 @@ async fn main() -> Result<(), anyhow::Error> {
.get_state_root(&Default::default())
.expect("The storage needs to have a state root");

for height in rollup_config.start_height.. {
for height in rollup_config.runner.start_height.. {
let mut host = Risc0Host::new(ROLLUP_ELF);
host.write_to_guest(prev_state_root);
info!(
Expand Down
58 changes: 29 additions & 29 deletions examples/demo-prover/methods/guest/Cargo.lock

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

13 changes: 7 additions & 6 deletions examples/demo-rollup/benches/rollup_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,19 @@ fn rollup_bench(_bench: &mut Criterion) {
.sample_size(10)
.measurement_time(Duration::from_secs(20));
let rollup_config_path = "benches/rollup_config.toml".to_string();
let mut rollup_config: RollupConfig = from_toml_path(&rollup_config_path)
.context("Failed to read rollup configuration")
.unwrap();
let mut rollup_config: RollupConfig<celestia::DaServiceConfig> =
from_toml_path(&rollup_config_path)
.context("Failed to read rollup configuration")
.unwrap();

let temp_dir = TempDir::new().expect("Unable to create temporary directory");
rollup_config.runner.storage.path = PathBuf::from(temp_dir.path());
rollup_config.storage.path = PathBuf::from(temp_dir.path());
let ledger_db =
LedgerDB::with_path(&rollup_config.runner.storage.path).expect("Ledger DB failed to open");
LedgerDB::with_path(&rollup_config.storage.path).expect("Ledger DB failed to open");

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

let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(rollup_config.runner.storage);
let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(rollup_config.storage);

let mut demo = demo_runner.stf;
let sequencer_private_key = DefaultPrivateKey::generate();
Expand Down
13 changes: 7 additions & 6 deletions examples/demo-rollup/benches/rollup_coarse_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,19 @@ async fn main() -> Result<(), anyhow::Error> {
}

let rollup_config_path = "benches/rollup_config.toml".to_string();
let mut rollup_config: RollupConfig = from_toml_path(&rollup_config_path)
.context("Failed to read rollup configuration")
.unwrap();
let mut rollup_config: RollupConfig<celestia::DaServiceConfig> =
from_toml_path(&rollup_config_path)
.context("Failed to read rollup configuration")
.unwrap();

let temp_dir = TempDir::new().expect("Unable to create temporary directory");
rollup_config.runner.storage.path = PathBuf::from(temp_dir.path());
rollup_config.storage.path = PathBuf::from(temp_dir.path());
let ledger_db =
LedgerDB::with_path(&rollup_config.runner.storage.path).expect("Ledger DB failed to open");
LedgerDB::with_path(&rollup_config.storage.path).expect("Ledger DB failed to open");

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

let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(rollup_config.runner.storage);
let demo_runner = App::<Risc0Verifier, RngDaSpec>::new(rollup_config.storage);

let mut demo = demo_runner.stf;
let sequencer_private_key = DefaultPrivateKey::generate();
Expand Down
13 changes: 7 additions & 6 deletions examples/demo-rollup/benches/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# We define the rollup's genesis to occur at Celestia block number `start_height`. The rollup will ignore
# any Celestia blocks before this height
start_height = 1

[da]
# The JWT used to authenticate with the celestia light client. Instructions for generating this token can be found in the README
celestia_rpc_auth_token = "MY.SECRET.TOKEN"
Expand All @@ -12,11 +8,16 @@ max_celestia_response_body_size = 104_857_600
# The maximum time to wait for a response to an RPC query against Celestia node. Defaults to 60 seconds.
celestia_rpc_timeout_seconds = 60

[runner.storage]
[storage]
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "benches/demo_data"

[rpc_config]
[runner]
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
start_height = 1

[runner.rpc_config]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12345
13 changes: 7 additions & 6 deletions examples/demo-rollup/rollup_config.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# We define the rollup's genesis to occur at Celestia block number `start_height`. The rollup will ignore
# any Celestia blocks before this height
start_height = 1

[da]
# The JWT used to authenticate with the celestia light client. Instructions for generating this token can be found in the README
celestia_rpc_auth_token = "MY.SECRET.TOKEN"
Expand All @@ -12,11 +8,16 @@ max_celestia_response_body_size = 104_857_600
# The maximum time to wait for a response to an RPC query against Celestia node. Defaults to 60 seconds.
celestia_rpc_timeout_seconds = 60

[runner.storage]
[storage]
# The path to the rollup's data directory. Paths that do not begin with `/` are interpreted as relative paths.
path = "demo_data"

[rpc_config]
# We define the rollup's genesis to occur at block number `start_height`. The rollup will ignore
# any blocks before this height
[runner]
start_height = 1

[runner.rpc_config]
# the host and port to bind the rpc server for
bind_host = "127.0.0.1"
bind_port = 12345
Loading