From 1c535562b8260c0bce7642aa61e9ace9643cb34c Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 12:35:00 +0100 Subject: [PATCH 1/4] Add docs --- crates/rollup/src/lib.rs | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/crates/rollup/src/lib.rs b/crates/rollup/src/lib.rs index 5df8602..003d008 100644 --- a/crates/rollup/src/lib.rs +++ b/crates/rollup/src/lib.rs @@ -5,7 +5,6 @@ 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 method 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 `free` Wallet implementation. +impl sov_modules_rollup_template::WalletTemplate for StarterRollup {} From 88bb3702e23ba48c4b0db81d0ec311926e38d3a4 Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 12:39:16 +0100 Subject: [PATCH 2/4] Doc fixses --- crates/rollup/src/lib.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/rollup/src/lib.rs b/crates/rollup/src/lib.rs index 003d008..5c515a2 100644 --- a/crates/rollup/src/lib.rs +++ b/crates/rollup/src/lib.rs @@ -1,5 +1,5 @@ -//#![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; @@ -42,7 +42,7 @@ impl sov_modules_rollup_template::RollupTemplate for StarterRollup { /// Runtime for the Native environment. type NativeRuntime = Runtime; - /// This method generates RPC methods for the rollup, allowing for extension with custom endpoints. + /// This function generates RPC methods for the rollup, allowing for extension with custom endpoints. fn create_rpc_methods( &self, storage: &::Storage, @@ -91,5 +91,5 @@ impl sov_modules_rollup_template::RollupTemplate for StarterRollup { } } -// Here we get `free` Wallet implementation. +// Here we get a `free` Wallet implementation. impl sov_modules_rollup_template::WalletTemplate for StarterRollup {} From 8b546663710628fffd41b732e1120ed9467ad66f Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 13:14:09 +0100 Subject: [PATCH 3/4] Update Readme --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cca183c..2375169 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 From a8d42c35b52611c48dad50eb1979c6feca463543 Mon Sep 17 00:00:00 2001 From: bkolad Date: Mon, 30 Oct 2023 13:15:54 +0100 Subject: [PATCH 4/4] formatting --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2375169..ecd7923 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ 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/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.