diff --git a/Cargo.lock b/Cargo.lock index 06b3a07c..abd936fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1827,20 +1827,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "polkadot-metadata-checker" -version = "0.2.15" -dependencies = [ - "clap", - "color-eyre", - "crossterm", - "env_logger", - "log", - "polkadot-introspector-essentials", - "subxt", - "tokio", -] - [[package]] name = "polkadot-parachain-tracer" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index 1a1da39b..f8a702f3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = [ "essentials", "jaeger", "kvdb", - "metadata-checker", "parachain-tracer", "priority-channel", "whois", diff --git a/README.md b/README.md index b07221a2..b9872be2 100644 --- a/README.md +++ b/README.md @@ -15,18 +15,6 @@ The tools utilize data sources such as [subxt](https://github.com/paritytech/sub ## Building -**TODO: the following information is outdated, needs to be edited.** +We utilize the latest polkadot metadata to decode block data. It is possible that we might lack some types, which are already present in test networks but not yet in polkadot. In such instances, we implement our own provisional types, which should be removed once they are included in the polkadot metadata. -It is mandatory to specify which `Runtime` the build will target. Currently, the tools can only build for a single runtime version by enabling one of the following features: - -- `rococo` - for Rococo and Versi test networks -- `kusama` - for Kusama production networks -- `polkadot` - for Polkadot production networks - -These features will select which metadata to use for decoding block data. To enable a specific feature, use the following command: - -``` -cargo build --release --no-default-features --features=polkadot -``` - -See also: [Updating or supporting a new `Runtime`](essentials/README.md#updating-or-supporting-a-new-runtime) +See also: [Updating a `Runtime`](essentials/README.md#updating-a-runtime) diff --git a/essentials/README.md b/essentials/README.md index bb28dc35..0a801678 100644 --- a/essentials/README.md +++ b/essentials/README.md @@ -1,24 +1,16 @@ # polkadot-introspector-essentials -This repository contains essential components for the Polkadot Introspector toolset, including pre-built runtime modules for Polkadot- and Rococo-like Substrate-based blockchains. +This repository contains essential components for the Polkadot Introspector toolset, including pre-built runtime modules for Polkadot-like Substrate-based blockchains. -## Updating or supporting a new `Runtime` +## Updating a `Runtime` -**TODO: the following information is outdated, needs to be edited.** +The deployed `Runtime` version on a network might be newer and incompatible with the metadata included in the repository. To keeo the metadata up-to-date, we employ automated metadata updates [within our CI/CD workflow](./../.github/workflows/update_metadata.yml). -The `Runtime` version deployed on a network might be newer and incompatible with the metadata bundled in the repository. To check whether the metadata is up-to-date, we run [polkadot-metadata-checker](../metadata-checker/README.md) on our CI/CD pipelines. In case it fails, to bring the new metadata, we use [subxt-cli](https://github.com/paritytech/subxt/#downloading-metadata-from-a-substrate-node). - -Here's an example of how to update the metadata: +For manually updating the metadata, we utilize [subxt-cli](https://github.com/paritytech/subxt/#downloading-metadata-from-a-substrate-node). ``` -# Update metadata for Rococo -subxt metadata --format bytes --url wss://rococo-rpc.polkadot.io:443 > assets/rococo_metadata.scale - -# Update metadata for Kusama -subxt metadata --format bytes --url wss://kusama-rpc.polkadot.io:443 > assets/kusama_metadata.scale - # Update metadata for Polkadot subxt metadata --format bytes --url wss://rpc.polkadot.io:443 > assets/polkadot_metadata.scale ``` -After replacing metadata files in the assets' folder with new ones, we need to rebuild the tools. +After replacing the existing metadata file in the assets folder with the updated one, we need to rebuild the tools. diff --git a/metadata-checker/Cargo.toml b/metadata-checker/Cargo.toml deleted file mode 100644 index 6a06d809..00000000 --- a/metadata-checker/Cargo.toml +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "polkadot-metadata-checker" -version.workspace = true -authors.workspace = true -edition.workspace = true -license.workspace = true -repository.workspace = true -publish = true - -[dependencies] -clap = { workspace = true } -color-eyre = { workspace = true } -crossterm = { workspace = true } -env_logger = { workspace = true } -log = { workspace = true } -polkadot-introspector-essentials = { workspace = true } -subxt = { workspace = true } -tokio = { workspace = true } diff --git a/metadata-checker/README.md b/metadata-checker/README.md deleted file mode 100644 index e44ee0f6..00000000 --- a/metadata-checker/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# polkadot-metadata-checker - -**For internal use only.** - -**TODO: the following information is outdated, needs to be edited.** - -The `Runtime` version deployed on a network might be newer and incompatible with the metadata -bundled in the repository. To check whether the metadata is up-to-date, we run `polkadot-metadata-checker` on our CI/CD pipelines: - -``` -# For Rococo Metadata -cargo run --features=rococo --bin polkadot-metadata-checker -- --ws=wss://rococo-rpc.polkadot.io:443 - -# For Kusama Metadata -cargo run --features=kusama --bin polkadot-metadata-checker -- --ws=wss://rococo-rpc.polkadot.io:443 - -# For Polkadot Metadata -cargo run --features=polkadot --bin polkadot-metadata-checker -- --ws=wss://rpc.polkadot.io:443 -``` - -See also: [Updating or supporting a new `Runtime`](../essentials/README.md#updating-or-supporting-a-new-runtime) diff --git a/metadata-checker/src/main.rs b/metadata-checker/src/main.rs deleted file mode 100644 index aeda8410..00000000 --- a/metadata-checker/src/main.rs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2023 Parity Technologies (UK) Ltd. -// This file is part of polkadot-introspector. -// -// polkadot-introspector is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// polkadot-introspector is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with polkadot-introspector. If not, see . - -use clap::Parser; -use crossterm::style::Stylize; -use log::error; -use polkadot_introspector_essentials::{init, metadata::polkadot}; -use subxt::{OnlineClient, PolkadotConfig}; - -#[derive(Debug, Parser)] -#[clap(author, version, about = "Validate statically generated metadata")] -pub(crate) struct MetadataCheckerOptions { - /// Web-Socket URL of a relay chain node. - #[clap(name = "ws", long)] - pub url: String, - #[clap(flatten)] - pub verbose: init::VerbosityOptions, -} - -pub(crate) struct MetadataChecker { - opts: MetadataCheckerOptions, -} - -impl MetadataChecker { - pub(crate) fn new(opts: MetadataCheckerOptions) -> color_eyre::Result { - Ok(Self { opts }) - } - - pub(crate) async fn run(self) -> color_eyre::Result<()> { - print!("[metadata-checker] Checking metadata for {}... ", self.opts.url); - let api = OnlineClient::::from_url(self.opts.url).await.unwrap(); - - match polkadot::validate_codegen(&api) { - Ok(_) => println!("{}", "OK".green()), - Err(_) => { - println!("{}", "FAILED".red()); - std::process::exit(1); - }, - }; - - Ok(()) - } -} - -#[tokio::main] -async fn main() -> color_eyre::Result<()> { - let opts = MetadataCheckerOptions::parse(); - init::init_cli(&opts.verbose)?; - - if let Err(err) = MetadataChecker::new(opts)?.run().await { - error!("FATAL: cannot start metadata checker: {}", err) - } - - Ok(()) -}