Skip to content

Latest commit

 

History

History
127 lines (84 loc) · 4.83 KB

README_src.adoc

File metadata and controls

127 lines (84 loc) · 4.83 KB

subwasm

badge
Logo 256

Introduction

The metadata of a given runtime is a critical piece of information as it describes how one can interact with the runtime, what operations are possible and what are the signatures of the calls. It contains the exhaustive list of all the features publicly exposed by the runtime.

Note
This tool only works with Substrate-based runtimes which are >=V11. For earlier versions, you’ll need to connect to an archive node.

Any node can be queried to provide its current metadata. This can be displayed in json format for instance. This is a great way to have a peek at what the runtime can do. You may however want to inspect a runtime that was not deployed yet to any node.

subwasm can work offline on wasm files without any node or internet connectivity.

Capabilities & features

subwasm can:

  • get the metadata from a a wasm file directly (no need for a node): command get

  • show summary information and version of a runtime: commands info and version)

  • diff between two runtime to help users spot changes and difference: command diff

  • show the list of pallets and their content (calls, events, errors, storage, constants): command show

  • analyze 2 runtimes to figure out whether they are compatible and if the transaction_version needs to be bumped: command diff

  • compress and decompress a runtime WASM: commands compress and decompress

  • get the latest metadata from a running node: command get

  • fetch the latest runtime (wasm) from a running node: command get

  • get runtime and metadata at any point of time using a Block hash as reference: command get

  • do all of the above with an output for human or as json

Install

Using Cargo

cargo install --locked --git https://github.com/chevdor/subwasm --tag v0.16.1

Homebrew

MacOS Homebrew users can use:

brew tap chevdor/subwasm https://github.com/chevdor/subwasm
brew install subwasm

Linux

wget https://github.com/chevdor/subwasm/releases/download/v0.16.1/subwasm_linux_amd64_v0.16.1 -O subwasm.deb
sudo dpkg -i subwasm.deb
subwasm --help

Usage

Environment variables

In addition to the command line flags, you can also pass one of the following ENV variables:

link:.env-sample[role=include]

Sample runs

Fetch a runtime from a running node

We will start by fetching the runtime from a node.

Note
Please note that you will likely need to connect to an archive node to retrieve an older runtime (<V11). A runtime takes around 2MB of storage on-chain and thus, older versions are pruned and will no longer be accessible if you are connecting to a non-archive node.
Here we get the latest version of the runtime, the 3 commands do the same since they all use the default values:
subwasm get
subwasm get http://localhost:9933
subwasm get http://localhost:9933 --output runtime_000.wasm
Here we get an older runtime, back when Polkadot was at block 20 !
subwasm get brew tap chevdor/subwasm --block 0x4d6a0bca208b85d41833a7f35cf73d1ae6974f4bad8ab576e2c3f751d691fe6c
Note
By default, your runtime will be saved as runtime_000.wasm. Running this command again will increase the counter so we you don’t lose your previous runtime. You may also use the --output flag to provide the destination and filename of your choice. Beware, in this case, there will be no incremented counter.
Get quick check of a runtime
# Show the runtime version and exit with status 0
subwasm info kusama-2030.wasm

# Provide a few explanations and exit with a status that is not 0
subwasm info tictactoe.wasm

Metadata JSON and jq tricks

Tip
jq can be used to reprocess the json output. For instance, removing all the documentation from the metadata makes it significantly smaller. The example below shows how to remove documentation, value and default making it much easier on the eyes for human parsing…​
    subwasm --json meta runtime.wasm | jq 'del( .. | .documentation?, .default?, .value? )'

Alternatives

Here is a list of other projects allowing to get the raw metadata through a rpc call:

All those alternatives require a running node and access it via jsonrpc.