diff --git a/README.md b/README.md index cca183c..ecd7923 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ This package is a convenient starting point for building a rollup using the Sovereign SDK: +# The repo structure: +- `crates/stf`: The `STF` is derived from the `Runtime` and is used in the `rollup` and `provers` crates. +- `crates/provers`: This crate is responsible for creating proofs for the `STF`. +- `crates/rollup`: This crate runs the `STF` and offers additional full-node functionalities. + # How to run the sov-rollup-starter: #### 1. Change the working directory: @@ -7,26 +12,27 @@ This package is a convenient starting point for building a rollup using the Sove $ cd crates/rollup/ ``` -#### 2. Cleanup database: +#### 2. If you want to run a fresh rollup, clean the database: + ```sh,test-ci $ make clean-db ``` -#### 3. Starting the node: -If you want to run a fresh rollup remove the `rollup-starter-data` folder. +#### 3. Start the rollup node: + This will compile and start the rollup node: ```shell,test-ci,bashtestmd:long-running,bashtestmd:wait-until=RPC $ cargo run --bin node ``` -#### 4. In another shell run: +#### 4. Submit a token creation transaction to the `bank` module: ```sh,test-ci $ make test-create-token ``` -#### 5. Test if token creation succeeded +#### 5. Test if token creation succeeded: ```sh,test-ci $ make test-bank-supply-of diff --git a/crates/rollup/src/lib.rs b/crates/rollup/src/lib.rs index 5df8602..5c515a2 100644 --- a/crates/rollup/src/lib.rs +++ b/crates/rollup/src/lib.rs @@ -1,11 +1,10 @@ -//#![deny(missing_docs)] -//#![doc = include_str!("../README.md")] +#![deny(missing_docs)] +//! StarterRollup provides a minimal self-contained rollup implementation use async_trait::async_trait; use sov_db::ledger_db::LedgerDB; use sov_modules_api::default_context::{DefaultContext, ZkDefaultContext}; use sov_modules_api::Spec; -use sov_modules_rollup_template::{register_rpc, RollupTemplate, WalletTemplate}; use sov_risc0_adapter::host::Risc0Host; use sov_rollup_interface::mocks::{MockDaConfig, MockDaService, MockDaSpec}; use sov_rollup_interface::services::da::DaService; @@ -17,33 +16,48 @@ use stf_starter::Runtime; /// Rollup with [`MockDaService`]. pub struct StarterRollup {} +/// This is the place, where all the rollup components come together and +/// they can be easily swapped with alternative implementations as needed. #[async_trait] -impl RollupTemplate for StarterRollup { +impl sov_modules_rollup_template::RollupTemplate for StarterRollup { + /// This component defines the Data Availability layer. type DaService = MockDaService; + /// DaSpec & DaConfig are derived from DaService. type DaSpec = MockDaSpec; - type DaConfig = MockDaConfig; + + /// The concrete ZkVm used in the rollup. type Vm = Risc0Host<'static>; + /// Context for the Zero Knowledge environment. type ZkContext = ZkDefaultContext; + /// Context for the ZNative environment. type NativeContext = DefaultContext; + /// Manager for the native storage lifecycle. type StorageManager = sov_state::storage_manager::ProverStorageManager; - type ZkRuntime = Runtime; + /// Runtime for the Zero Knowledge environment. + type ZkRuntime = Runtime; + /// Runtime for the Native environment. type NativeRuntime = Runtime; + /// This function generates RPC methods for the rollup, allowing for extension with custom endpoints. fn create_rpc_methods( &self, storage: &::Storage, ledger_db: &LedgerDB, da_service: &Self::DaService, ) -> anyhow::Result> { - register_rpc::( - storage, ledger_db, da_service, - ) + sov_modules_rollup_template::register_rpc::< + Self::NativeRuntime, + Self::NativeContext, + Self::DaService, + >(storage, ledger_db, da_service) } + // Below, we provide the methods for setting up dependencies for the Rollup. + async fn create_da_service( &self, rollup_config: &RollupConfig, @@ -51,7 +65,10 @@ impl RollupTemplate for StarterRollup { MockDaService::new(rollup_config.da.sender_address) } - fn create_storage_manager(&self, rollup_config: &RollupConfig) -> anyhow::Result { + fn create_storage_manager( + &self, + rollup_config: &RollupConfig, + ) -> anyhow::Result { let storage_config = StorageConfig { path: rollup_config.storage.path.clone(), }; @@ -74,4 +91,5 @@ impl RollupTemplate for StarterRollup { } } -impl WalletTemplate for StarterRollup {} +// Here we get a `free` Wallet implementation. +impl sov_modules_rollup_template::WalletTemplate for StarterRollup {}