From 5114c76cf2fa0657ed4b74db106cdd1bc4d3854b Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sun, 22 Dec 2024 23:44:44 +0800 Subject: [PATCH] Release `v0.1.1` Signed-off-by: Xavier Lau --- .github/workflows/release.yml | 2 +- .github/workflows/staging.yml | 2 +- Cargo.lock | 35 +------ Cargo.toml | 3 +- cli/src/cli.rs | 6 -- cli/src/cli/cmp.rs | 30 ------ lib/Cargo.toml | 1 - lib/src/api.rs | 174 ---------------------------------- lib/src/lib.rs | 1 - lib/src/wasmer.rs | 1 - 10 files changed, 7 insertions(+), 248 deletions(-) delete mode 100644 cli/src/cli/cmp.rs delete mode 100644 lib/src/api.rs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 835e7ed..2cbe9c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,4 +94,4 @@ jobs: - name: Login run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }} - name: Publish - run: cargo publish --locked + run: cargo publish --locked -p polkadot-runtime-releaser-cli diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml index 1e5ba45..3c5d0f1 100644 --- a/.github/workflows/staging.yml +++ b/.github/workflows/staging.yml @@ -96,4 +96,4 @@ jobs: # - name: Login # run: cargo login ${{ secrets.CARGO_REGISTRY_TOKEN }} # - name: Publish - # run: cargo publish --locked + # run: cargo publish --locked -p polkadot-runtime-releaser-cli diff --git a/Cargo.lock b/Cargo.lock index a3a7262..ecc89df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -46,15 +46,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "affix" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50e7ea84d3fa2009f355f8429a0b418a96849135a4188fadf384f59127d5d4bc" -dependencies = [ - "convert_case", -] - [[package]] name = "ahash" version = "0.8.11" @@ -149,9 +140,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7" +checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" [[package]] name = "ark-bls12-377" @@ -665,12 +656,6 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd7e35aee659887cbfb97aaf227ac12cad1a9d7c71e55ff3376839ed4e282d08" -[[package]] -name = "convert_case" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" - [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -2553,7 +2538,7 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "polkadot-runtime-releaser-cli" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "array-bytes 8.0.0", @@ -2570,7 +2555,7 @@ dependencies = [ [[package]] name = "polkadot-runtime-releaser-lib" -version = "0.1.0" +version = "0.1.1" dependencies = [ "blake2", "md-5", @@ -2584,7 +2569,6 @@ dependencies = [ "sp-maybe-compressed-blob", "sp-state-machine", "sp-version", - "subrpcer", "thiserror 2.0.9", "tokio", "tracing", @@ -3978,17 +3962,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "subrpcer" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a00780fcd4ebedf099da78a562744c6f17bda08d1223928c3104dd26081b44" -dependencies = [ - "affix", - "serde", - "serde_json", -] - [[package]] name = "substrate-bip39" version = "0.6.0" diff --git a/Cargo.toml b/Cargo.toml index 3b1b446..0a921bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ edition = "2021" homepage = "https://hack.ink/polkadot-runtime-releaser" license = "GPL-3.0" repository = "https://github.com/hack-ink/polkadot-runtime-releaser" -version = "0.1.0" +version = "0.1.1" [workspace.dependencies] # crates.io @@ -32,7 +32,6 @@ sp-core = { version = "34.0" } sp-maybe-compressed-blob = { version = "11.0" } sp-state-machine = { version = "0.43" } sp-version = { version = "37.0" } -subrpcer = { version = "0.11" } thiserror = { version = "2.0" } tokio = { version = "1.42" } toml = { version = "0.8" } diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 990ff49..9139f9a 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1,9 +1,6 @@ mod build; use build::BuildCmd; -mod cmp; -use cmp::CmpCmd; - mod inspect; use inspect::InspectCmd; @@ -45,7 +42,6 @@ impl Run for Cli { fn run(self) -> Result<()> { match self.subcommand { Subcommand::Build(cmd) => cmd.run(), - Subcommand::Cmp(cmd) => cmd.run(), Subcommand::Inspect(cmd) => cmd.run(), } } @@ -55,8 +51,6 @@ impl Run for Cli { enum Subcommand { /// Build the polkadot-sdk-based runtime. Build(BuildCmd), - /// Compare the latest GitHub release's runtime version with the on-chain's. - Cmp(CmpCmd), /// Inspect the WASM runtime. Inspect(InspectCmd), } diff --git a/cli/src/cli/cmp.rs b/cli/src/cli/cmp.rs deleted file mode 100644 index 8113213..0000000 --- a/cli/src/cli/cmp.rs +++ /dev/null @@ -1,30 +0,0 @@ -// std -use std::env; -// crates.io -use clap::Parser; -// self -use crate::{cli::Run, prelude::*}; -use prr_lib::{ - api::{Api, ApiConfig}, - runtime::Version, - wasmer::Wasmer, -}; - -#[derive(Debug, Parser)] -pub struct CmpCmd { - /// Remote repository to compare against. - #[arg(value_name = "REPO")] - repo: String, - /// Live node URIs. - #[arg(value_name = "[URI]")] - uris: Vec, -} -impl Run for CmpCmd { - fn run(self) -> Result<()> { - let Self { repo, uris } = self; - let github_token = env::var("GITHUB_TOKEN")?; - let config = ApiConfig { github_token, repo }; - - Ok(()) - } -} diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 4148f40..97aeee5 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -20,7 +20,6 @@ sp-core = { workspace = true } sp-maybe-compressed-blob = { workspace = true } sp-state-machine = { workspace = true } sp-version = { workspace = true, features = ["serde"] } -subrpcer = { workspace = true } thiserror = { workspace = true } tracing = { workspace = true } diff --git a/lib/src/api.rs b/lib/src/api.rs deleted file mode 100644 index 6c2c5fd..0000000 --- a/lib/src/api.rs +++ /dev/null @@ -1,174 +0,0 @@ -//! Polkadot Runtime Releaser API component. - -// crates.io -use reqwew::{ - error::Error as RError, - reqwest::{header::USER_AGENT, Client, Method, Url}, - Http, Response, -}; -use serde::{de::Error as DeError, Deserialize, Deserializer}; -use sp_version::RuntimeVersion; -use subrpcer::state; -// self -use crate::prelude::*; - -/// API. -#[derive(Debug)] -pub struct Api { - client: Client, - config: ApiConfig, -} -impl Api { - #[allow(missing_docs)] - pub fn new(config: ApiConfig) -> Self { - Self { client: Client::new(), config } - } - - async fn runtimes(&self) -> Result> { - let mut runtimes = Vec::new(); - - for rt_config in &self.config.runtime_configs { - for endpoint in &rt_config.rpc_endpoints { - match self - .client - .request_with_retries( - self.client - .request(Method::POST, endpoint.clone()) - .json(&state::get_runtime_version(0, None::<()>)) - .build() - .map_err(RError::Reqwest)?, - 3, - 50, - ) - .await - { - Ok(resp) => - if let Ok(resp) = resp.json::>() { - runtimes.push(Runtime { - name: rt_config.name.clone(), - on_chain_version: resp.result.spec_version, - ok: true, - }); - - break; - }, - Err(_e) => { - continue; - }, - } - } - - if let Some(rt) = runtimes.last() { - if rt.name != rt_config.name { - runtimes.push(Runtime { - name: rt_config.name.clone(), - on_chain_version: 0, - ok: false, - }); - } - } - } - - Ok(runtimes) - } - - // async fn runtimes(&self) -> Result<()> { - // let releases = self.releases().await.unwrap(); - // let mut remains = (1_u8 << self.config.runtime_configs.len()) - 1; - - // 'outer: for r in releases { - // if remains == 0 { - // break; - // } - - // for (i, rt_config) in self.config.runtime_configs.iter().enumerate() { - // if (remains & (1 << i)) != 0 { - // if let Some(asset) = r.assets.iter().find(|asset| { - // let url = &asset.browser_download_url; - - // if let Some(caps) = rt_config.version_regex.captures(url) { - // println!("Found version {} at URL: {}", &caps[1], url); - - // remains &= !(1 << i); - - // true - // } else { - // false - // } - // }) { - // if remains == 0 { - // break 'outer; - // } - // } - // } - // } - // } - // } - - async fn releases(&self) -> Result> { - let releases = self - .client - .request_with_retries( - self.client - .request(Method::GET, self.config.releases()) - .header(USER_AGENT, "polkadot-runtime-releaser") - .bearer_auth(&self.config.github_token) - .build() - .map_err(RError::Reqwest)?, - 3, - 50, - ) - .await? - .json::>()?; - - Ok(releases) - } -} - -/// API configuration. -#[derive(Debug, Deserialize)] -pub struct ApiConfig { - repo: String, - github_token: String, - runtime_configs: Vec, -} -impl ApiConfig { - fn releases(&self) -> String { - format!("https://api.github.com/repos/{}/releases", self.repo) - } -} -/// Runtime information. -#[derive(Debug, Deserialize)] -pub struct RuntimeConfig { - name: String, - #[serde(deserialize_with = "deserialize_rpc_endpoint")] - rpc_endpoints: Vec, -} - -#[derive(Debug)] -struct Runtime { - name: String, - on_chain_version: u32, - ok: bool, -} - -#[derive(Debug, Deserialize)] -struct Release { - assets: Vec, -} -#[derive(Debug, Deserialize)] -struct Asset { - browser_download_url: String, -} - -#[derive(Debug, Deserialize)] -struct RpcResponse { - result: R, -} - -fn deserialize_rpc_endpoint<'de, D>(d: D) -> Result, D::Error> -where - D: Deserializer<'de>, -{ - >::deserialize(d)?.iter().map(|s| s.parse().map_err(DeError::custom)).collect() -} diff --git a/lib/src/lib.rs b/lib/src/lib.rs index d4a6a5d..1f7e99a 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -2,7 +2,6 @@ //! Polkadot Runtime Releaser library. -pub mod api; pub mod docker; pub mod error; pub mod hasher; diff --git a/lib/src/wasmer.rs b/lib/src/wasmer.rs index db55505..f96da8b 100644 --- a/lib/src/wasmer.rs +++ b/lib/src/wasmer.rs @@ -5,7 +5,6 @@ use std::{fs, path::Path}; // crates.io use parity_scale_codec::Decode; use sc_executor::WasmExecutor; -use serde::Serialize; use sp_core::traits::ReadRuntimeVersion; use sp_maybe_compressed_blob::CODE_BLOB_BOMB_LIMIT; use sp_state_machine::BasicExternalities;