diff --git a/examples/demo-rollup/benches/node/rollup_bench.rs b/examples/demo-rollup/benches/node/rollup_bench.rs index 35d23b057..a7064bba4 100644 --- a/examples/demo-rollup/benches/node/rollup_bench.rs +++ b/examples/demo-rollup/benches/node/rollup_bench.rs @@ -19,17 +19,6 @@ use sov_rollup_interface::stf::StateTransitionFunction; use sov_stf_runner::{from_toml_path, RollupConfig}; use tempfile::TempDir; -const TEST_GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../test-data/genesis/integration-tests/bank.json", - sequencer_genesis_path: "../test-data/genesis/integration-tests/sequencer_registry.json", - value_setter_genesis_path: "../test-data/genesis/integration-tests/value_setter.json", - accounts_genesis_path: "../test-data/genesis/integration-tests/accounts.json", - chain_state_genesis_path: "../test-data/genesis/integration-tests/chain_state.json", - nft_path: "../test-data/genesis/integration-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../test-data/genesis/integration-tests/evm.json", -}; - fn rollup_bench(_bench: &mut Criterion) { let start_height: u64 = 0u64; let mut end_height: u64 = 100u64; @@ -63,7 +52,7 @@ fn rollup_bench(_bench: &mut Criterion) { let demo_genesis_config = get_genesis_config( sequencer_da_address, - &TEST_GENESIS_PATHS, + &GenesisPaths::from_dir("../test-data/genesis/integration-tests"), #[cfg(feature = "experimental")] Default::default(), ); diff --git a/examples/demo-rollup/benches/node/rollup_coarse_measure.rs b/examples/demo-rollup/benches/node/rollup_coarse_measure.rs index 279a7e058..7ff625cd1 100644 --- a/examples/demo-rollup/benches/node/rollup_coarse_measure.rs +++ b/examples/demo-rollup/benches/node/rollup_coarse_measure.rs @@ -25,17 +25,6 @@ extern crate prettytable; use prettytable::Table; use sov_modules_stf_template::TxEffect; -const TEST_GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../test-data/genesis/integration-tests/bank.json", - sequencer_genesis_path: "../test-data/genesis/integration-tests/sequencer_registry.json", - value_setter_genesis_path: "../test-data/genesis/integration-tests/value_setter.json", - accounts_genesis_path: "../test-data/genesis/integration-tests/accounts.json", - chain_state_genesis_path: "../test-data/genesis/integration-tests/chain_state.json", - nft_path: "../test-data/genesis/integration-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../test-data/genesis/integration-tests/evm.json", -}; - fn print_times( total: Duration, apply_block_time: Duration, @@ -120,7 +109,7 @@ async fn main() -> Result<(), anyhow::Error> { let demo_genesis_config = get_genesis_config( sequencer_da_address, - &TEST_GENESIS_PATHS, + &GenesisPaths::from_dir("../test-data/genesis/integration-tests"), #[cfg(feature = "experimental")] Default::default(), ); diff --git a/examples/demo-rollup/benches/prover/prover_bench.rs b/examples/demo-rollup/benches/prover/prover_bench.rs index d2ffaafdb..bf7d38f29 100644 --- a/examples/demo-rollup/benches/prover/prover_bench.rs +++ b/examples/demo-rollup/benches/prover/prover_bench.rs @@ -25,17 +25,6 @@ use sov_rollup_interface::zk::ZkvmHost; use sov_stf_runner::{from_toml_path, RollupConfig}; use tempfile::TempDir; -const GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../test-data/genesis/demo-tests/bank.json", - sequencer_genesis_path: "../test-data/genesis/demo-tests/sequencer_registry.json", - value_setter_genesis_path: "../test-data/genesis/demo-tests/value_setter.json", - accounts_genesis_path: "../test-data/genesis/demo-tests/accounts.json", - chain_state_genesis_path: "../test-data/genesis/demo-tests/chain_state.json", - nft_path: "../test-data/genesis/demo-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../test-data/genesis/demo-tests/evm.json", -}; - #[derive(Debug)] struct RegexAppender { regex: Regex, @@ -184,7 +173,7 @@ async fn main() -> Result<(), anyhow::Error> { let genesis_config = get_genesis_config( sequencer_da_address, - &GENESIS_PATHS, + &GenesisPaths::from_dir("../test-data/genesis/demo-tests"), #[cfg(feature = "experimental")] Default::default(), ); diff --git a/examples/demo-rollup/provers/src/main.rs b/examples/demo-rollup/provers/src/main.rs index 1a4e612cf..bf2a1a024 100644 --- a/examples/demo-rollup/provers/src/main.rs +++ b/examples/demo-rollup/provers/src/main.rs @@ -8,17 +8,6 @@ use tracing::info; use tracing_subscriber::filter::LevelFilter; use tracing_subscriber::EnvFilter; -const GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../../test-data/genesis/demo-tests/bank.json", - sequencer_genesis_path: "../../test-data/genesis/demo-tests/sequencer_registry.json", - value_setter_genesis_path: "../../test-data/genesis/demo-tests/value_setter.json", - accounts_genesis_path: "../../test-data/genesis/demo-tests/accounts.json", - chain_state_genesis_path: "../../test-data/genesis/demo-tests/chain_state.json", - nft_path: "../../test-data/genesis/demo-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../../test-data/genesis/demo-tests/evm.json", -}; - #[tokio::main] async fn main() -> Result<(), anyhow::Error> { // If SKIP_PROVER is set, We still compile and run the zkVM code inside of an emulator without generating @@ -51,7 +40,7 @@ async fn main() -> Result<(), anyhow::Error> { let rollup = new_rollup_with_celestia_da( &rollup_config_path, Some((prover, prover_config)), - &GENESIS_PATHS, + &GenesisPaths::from_dir("../test-data/genesis/demo-tests"), ) .await?; rollup.run().await?; diff --git a/examples/demo-rollup/src/main.rs b/examples/demo-rollup/src/main.rs index e97578262..f21dacb96 100644 --- a/examples/demo-rollup/src/main.rs +++ b/examples/demo-rollup/src/main.rs @@ -8,28 +8,6 @@ use sov_risc0_adapter::host::Risc0Host; use tracing_subscriber::prelude::*; use tracing_subscriber::{fmt, EnvFilter}; -const DEMO_GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../test-data/genesis/demo-tests/bank.json", - sequencer_genesis_path: "../test-data/genesis/demo-tests/sequencer_registry.json", - value_setter_genesis_path: "../test-data/genesis/demo-tests/value_setter.json", - accounts_genesis_path: "../test-data/genesis/demo-tests/accounts.json", - chain_state_genesis_path: "../test-data/genesis/demo-tests/chain_state.json", - nft_path: "../test-data/genesis/demo-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../test-data/genesis/demo-tests/evm.json", -}; - -const TEST_GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../test-data/genesis/integration-tests/bank.json", - sequencer_genesis_path: "../test-data/genesis/integration-tests/sequencer_registry.json", - value_setter_genesis_path: "../test-data/genesis/integration-tests/value_setter.json", - accounts_genesis_path: "../test-data/genesis/integration-tests/accounts.json", - chain_state_genesis_path: "../test-data/genesis/integration-tests/chain_state.json", - nft_path: "../test-data/genesis/integration-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../test-data/genesis/integration-tests/evm.json", -}; - #[cfg(test)] mod test_rpc; @@ -69,7 +47,7 @@ async fn main() -> Result<(), anyhow::Error> { rollup_config_path, //Some((prover, config)), None, - &TEST_GENESIS_PATHS, + &GenesisPaths::from_dir("../test-data/genesis/integration-tests"), )?; rollup.run().await } @@ -81,7 +59,7 @@ async fn main() -> Result<(), anyhow::Error> { rollup_config_path, //Some((prover, config)), None, - &DEMO_GENESIS_PATHS, + &GenesisPaths::from_dir("../test-data/genesis/demo-tests"), ) .await?; rollup.run().await diff --git a/examples/demo-rollup/tests/evm/mod.rs b/examples/demo-rollup/tests/evm/mod.rs index 88762a2a1..7023e1e51 100644 --- a/examples/demo-rollup/tests/evm/mod.rs +++ b/examples/demo-rollup/tests/evm/mod.rs @@ -12,17 +12,6 @@ use test_client::TestClient; use super::test_helpers::start_rollup; -const TEST_GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../test-data/genesis/integration-tests/bank.json", - sequencer_genesis_path: "../test-data/genesis/integration-tests/sequencer_registry.json", - value_setter_genesis_path: "../test-data/genesis/integration-tests/value_setter.json", - accounts_genesis_path: "../test-data/genesis/integration-tests/accounts.json", - chain_state_genesis_path: "../test-data/genesis/integration-tests/chain_state.json", - nft_path: "../test-data/genesis/integration-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../test-data/genesis/integration-tests/evm.json", -}; - #[cfg(feature = "experimental")] #[tokio::test] async fn evm_tx_tests() -> Result<(), anyhow::Error> { @@ -30,7 +19,12 @@ async fn evm_tx_tests() -> Result<(), anyhow::Error> { let rollup_task = tokio::spawn(async { // Don't provide a prover since the EVM is not currently provable - start_rollup::, _>(port_tx, None, &TEST_GENESIS_PATHS).await; + start_rollup::, _>( + port_tx, + None, + &GenesisPaths::from_dir("../test_data/genesis/integration-tests"), + ) + .await; }); // Wait for rollup task to start: diff --git a/examples/demo-stf/src/genesis_config.rs b/examples/demo-stf/src/genesis_config.rs index 5f538e731..8386ba469 100644 --- a/examples/demo-stf/src/genesis_config.rs +++ b/examples/demo-stf/src/genesis_config.rs @@ -3,7 +3,7 @@ //! that transforms module genesis data into Rollup genesis data. use std::convert::AsRef; -use std::path::Path; +use std::path::{Path, PathBuf}; use anyhow::{bail, Context as AnyhowContext}; use serde::de::DeserializeOwned; @@ -35,13 +35,33 @@ pub struct GenesisPaths> { pub accounts_genesis_path: P, /// Chain State genesis path. pub chain_state_genesis_path: P, - /// Nft genesis path. + /// NFT genesis path. pub nft_path: P, #[cfg(feature = "experimental")] /// EVM genesis path. pub evm_genesis_path: P, } +impl GenesisPaths { + /// Creates a new [`GenesisPaths`] from the files contained in the given + /// directory. + /// + /// Take a look at the contents of the `test_data` directory to see the + /// expected files. + pub fn from_dir(dir: impl AsRef) -> Self { + Self { + bank_genesis_path: dir.as_ref().join("bank.json"), + sequencer_genesis_path: dir.as_ref().join("sequencer_registry.json"), + value_setter_genesis_path: dir.as_ref().join("value_setter.json"), + accounts_genesis_path: dir.as_ref().join("accounts.json"), + chain_state_genesis_path: dir.as_ref().join("chain_state.json"), + nft_path: dir.as_ref().join("nft.json"), + #[cfg(feature = "experimental")] + evm_genesis_path: dir.as_ref().join("evm.json"), + } + } +} + /// Configure our rollup with a centralized sequencer using the SEQUENCER_DA_ADDRESS /// address constant. Since the centralize sequencer's address is consensus critical, /// it has to be hardcoded as a constant, rather than read from the config at runtime. @@ -49,7 +69,7 @@ pub struct GenesisPaths> { /// If you want to customize the rollup to accept transactions from your own celestia /// address, simply change the value of the SEQUENCER_DA_ADDRESS to your own address. /// For example: -/// ```rust,no_run +/// ``` /// const SEQUENCER_DA_ADDRESS: &str = "celestia1qp09ysygcx6npted5yc0au6k9lner05yvs9208"; /// ``` pub fn get_genesis_config>( diff --git a/examples/demo-stf/src/tests/mod.rs b/examples/demo-stf/src/tests/mod.rs index 95242a7e5..1394cf86a 100644 --- a/examples/demo-stf/src/tests/mod.rs +++ b/examples/demo-stf/src/tests/mod.rs @@ -15,17 +15,6 @@ mod tx_revert_tests; pub(crate) type C = DefaultContext; pub(crate) type Da = MockDaSpec; -const TEST_GENESIS_PATHS: GenesisPaths<&str> = GenesisPaths { - bank_genesis_path: "../test-data/genesis/integration-tests/bank.json", - sequencer_genesis_path: "../test-data/genesis/integration-tests/sequencer_registry.json", - value_setter_genesis_path: "../test-data/genesis/integration-tests/value_setter.json", - accounts_genesis_path: "../test-data/genesis/integration-tests/accounts.json", - chain_state_genesis_path: "../test-data/genesis/integration-tests/chain_state.json", - nft_path: "../test-data/genesis/integration-tests/nft.json", - #[cfg(feature = "experimental")] - evm_genesis_path: "../test-data/genesis/integration-tests/evm.json", -}; - pub(crate) fn create_new_app_template_for_tests( path: impl AsRef, ) -> AppTemplate< @@ -42,7 +31,7 @@ pub(crate) fn create_new_app_template_for_tests( pub(crate) fn get_genesis_config_for_tests() -> GenesisConfig { get_genesis_config::( Da::Address::try_from(&MOCK_SEQUENCER_DA_ADDRESS).unwrap(), - &TEST_GENESIS_PATHS, + &GenesisPaths::from_dir("../test-data/genesis/integration-tests"), #[cfg(feature = "experimental")] Vec::default(), )