8000 GitHub - chevdor/subwasm at v0.9.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Subwasm is a cli utility to look inside a Substrate WASM Runtime. It can inspect and compare the metadata of Substrate based runtimes such as Polkadot or Kusama.

License

Notifications You must be signed in to change notification settings

chevdor/subwasm

Repository files navigation

submeta

Logo 1024

Introduction

The metadata of a given runtime is a critical piece of information: it can be seen as the signature of a runtime. It contains the exhaustive list of all the features publicly exposed by the runtime.

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.

Sample runs

demo get
Figure 1. subwasm get
demo info
Figure 2. subwasm info
demo meta
Figure 3. subwasm meta
demo diff
Figure 4. subwasm diff

Capabilities

subwasm allows:

  • getting the latest metadata from a running node

  • getting the latest runtime (wasm) from a running node

  • getting runtime and metadata at any point of time using a Block hash as reference

  • getting the metadata from a a wasm file without any node

  • extracting information (those not requiring storage) from a runtime as wasm file

Install

Using Cargo

cargo install --git https://gitlab.com/chevdor/subwasm

Homebrew

MacOS Homebrew users can use:

brew tap chevdor/subwasm
brew install subwasm

Usage

Command: --help

link:doc/usage.adoc[role=include]

Command: get

link:doc/usage_get.adoc[role=include]

Command: info

link:doc/usage_info.adoc[role=include]

Command: meta

link:doc/usage_meta.adoc[role=include]

Command: diff

link:doc/usage_diff.adoc[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 older runtime. A runtime takes around 2MB of storage on-chain and thus, older versions are pruned and will no longer be accessible if you are connectin 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 --url http://localhost:9933
subwasm get --url 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 --input kusama-2030.wasm

# Provide a few explanations and exit with a status that is not 0
subwasm info --input 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 for a version 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.

About

Subwasm is a cli utility to look inside a Substrate WASM Runtime. It can inspect and compare the metadata of Substrate based runtimes such as Polkadot or Kusama.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 15

Languages

0