From e28c7e341e89e57c66c517de68c2525fba784a5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cem=20=C3=96zer?= Date: Tue, 7 May 2024 14:03:42 -0400 Subject: [PATCH] WIP: Upgrade to latest starter --- .github/workflows/rust.yml | 4 ++-- Cargo.lock | 2 +- README.md | 15 ++++++++------- rust-toolchain.toml | 4 ++++ src/init.rs | 8 ++++---- 5 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3599c26..51044ab 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -23,8 +23,8 @@ jobs: - name: Create the sov-runtime library run: | cargo new --lib sov-runtime - echo -e '[package]\nname = "sov-runtime"\nversion = "0.1.0"\nedition = "2021"\n[dependencies]\nborsh = "0.10.3"\nserde_json = "1.0"\nsov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be", features = ["serde"] }\ndemo-stf = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be", features = ["serde"] }\nsov-mock-da = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be" }\n' > ./sov-runtime/Cargo.toml - echo -e 'pub use sov_modules_api::default_context::ZkDefaultContext as Context;\npub use sov_mock_da::MockDaSpec as DaSpec;\npub use demo_stf::runtime::RuntimeCall;\n' > ./sov-runtime/src/lib.rs + echo -e '[package]\nname = "sov-runtime"\nversion = "0.1.0"\nedition = "2021"\n[dependencies]\nborsh = "0.10.3"\nserde_json = "1.0"\nsov-modules-api = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "4c609117a61783527129f3fd87cff2590c2c9fd1" }\nstf-starter = { git = "ssh://git@github.com/Sovereign-Labs/sov-rollup-starter-wip.git", rev = "6ec3ef41025e0249ba7ccdf61a5ab70a97e046dd" }\nsov-mock-da = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "4c609117a61783527129f3fd87cff2590c2c9fd1" }\n' > ./sov-runtime/Cargo.toml + echo -e 'pub use sov_modules_api::default_spec::ZkDefaultSpec as Spec;\npub use sov_mock_da::MockDaSpec as DaSpec;\npub use stf_starter::runtime::RuntimeCall;\n' > ./sov-runtime/src/lib.rs wget -O ./sov-runtime/constants.json 'https://raw.githubusercontent.com/Sovereign-Labs/sovereign-sdk/d42e289f26b9824b5ed54dbfbda94007dee305b2/constants.json' - name: Sanity check the sov-runtime library run: cargo check --manifest-path ./sov-runtime/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index bcca64f..53fc04b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -491,7 +491,7 @@ checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" [[package]] name = "sov-snap-generator" -version = "0.1.0" +version = "0.1.2" dependencies = [ "anyhow", "clap", diff --git a/README.md b/README.md index 4b2b6bb..93d3e96 100644 --- a/README.md +++ b/README.md @@ -58,30 +58,31 @@ edition = "2021" ## Required dependencies for the Snap borsh = "0.10.3" serde_json = "1.0" -sov-modules-api = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be", features = ["serde"] } +sov-modules-api = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "4c609117a61783527129f3fd87cff2590c2c9fd1" } ## Example definition of a module `RuntimeCall` ## Will be replaced by the user module implementation -demo-stf = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be", features = ["serde"] } -sov-mock-da = { git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be" } +stf-starter = { git = "ssh://git@github.com/Sovereign-Labs/sov-rollup-starter-wip.git", rev = "6ec3ef41025e0249ba7ccdf61a5ab70a97e046dd" } +sov-mock-da = { git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "4c609117a61783527129f3fd87cff2590c2c9fd1" } ``` Then, update the `src/lib.rs` with the following: ```rust -/// The `Context` will be used to define the asymmetric key pair. -pub use sov_modules_api::default_context::ZkDefaultContext as Context; +/// The `Spec` will be used to define the asymmetric key pair. +pub use sov_modules_api::default_spec::ZkDefaultSpec as Spec; /// The `DaSpec` will be used to define the runtime specification. pub use sov_mock_da::MockDaSpec as DaSpec; /// The `RuntimeCall` will be the call message of the transaction to be signed. This is normally generated automatically by the SDK via the `DispatchCall` derive macro. -pub use demo_stf::runtime::RuntimeCall; +pub use stf_starter::runtime::RuntimeCall; ``` Finally, fetch the default `constants.json` required for module compilation. ```bash +TODO! replace this with a method to get constants.json from sov-rollup-starter-wip (which is a priavate repo and causing issues as a result) wget https://raw.githubusercontent.com/Sovereign-Labs/sovereign-sdk/d42e289f26b9824b5ed54dbfbda94007dee305b2/constants.json ``` @@ -98,7 +99,7 @@ cargo check Some prompts can be specified through CLI arguments. For more information, run: ```bash -sov-snap-generator --help +cargo sov-snap-generator --help ``` We use the options `--defaults` and `--force` to skip prompt confirmations and checks. diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..8138355 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "1.77" +components = [ "rustfmt", "rust-src", "clippy" ] +profile = "minimal" diff --git a/src/init.rs b/src/init.rs index 3484afe..5fd337a 100644 --- a/src/init.rs +++ b/src/init.rs @@ -140,8 +140,8 @@ pub fn init(args: Init, interface: &mut Interface) -> anyhow::Result<()> { .get(&Dependency::new("serde_json")) .cloned() .unwrap_or_else(|| String::from("\"1.0\"")); - let sov_modules_api = manifest.dependencies.get(&Dependency::new("sov-modules-api")).cloned().unwrap_or_else(|| String::from(r#"{ git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be", features = ["serde"] }"#)); - let sov_mock_da = manifest.dependencies.get(&Dependency::new("sov-mock-da")).cloned().unwrap_or_else(|| String::from(r#"{ git = "https://github.com/Sovereign-Labs/sovereign-sdk.git", rev = "df169be" }"#)); + let sov_modules_api = manifest.dependencies.get(&Dependency::new("sov-modules-api")).cloned().unwrap_or_else(|| String::from(r#"{ git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "4c609117a61783527129f3fd87cff2590c2c9fd1" }"#)); + let sov_mock_da = manifest.dependencies.get(&Dependency::new("sov-mock-da")).cloned().unwrap_or_else(|| String::from(r#"{ git = "ssh://git@github.com/Sovereign-Labs/sovereign-sdk-wip.git", rev = "4c609117a61783527129f3fd87cff2590c2c9fd1" }"#)); let project = path .parent() @@ -168,9 +168,9 @@ sov-mock-da = {} ); let definitions = format!( - r#"pub type Context = sov_modules_api::default_context::ZkDefaultContext; + r#"pub type Spec = sov_modules_api::default_spec::ZkDefaultSpec; pub type DaSpec = sov_mock_da::MockDaSpec; -pub type RuntimeCall = {}::RuntimeCall; +pub type RuntimeCall = {}::RuntimeCall; "#, manifest.project.formatted );