From 091dd76434248d4144d3f7ab579bdf150eca33f5 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 21:59:52 +0800 Subject: [PATCH 01/12] Subalfred Book --- .gitignore | 2 + README.md | 58 -------------- doc/book.toml | 6 ++ doc/src/SUMMARY.md | 20 +++++ doc/src/user/cli/README.md | 14 ++++ doc/src/user/cli/check.md | 138 ++++++++++++++++++++++++++++++++ doc/src/user/cli/convert.md | 1 + doc/src/user/cli/get.md | 44 ++++++++++ doc/src/user/cli/hash.md | 1 + doc/src/user/cli/key.md | 1 + doc/src/user/cli/state.md | 1 + doc/src/user/cli/storage-key.md | 1 + doc/src/user/cli/workspace.md | 1 + doc/src/user/installation.md | 44 ++++++++++ 14 files changed, 274 insertions(+), 58 deletions(-) create mode 100644 doc/book.toml create mode 100644 doc/src/SUMMARY.md create mode 100644 doc/src/user/cli/README.md create mode 100644 doc/src/user/cli/check.md create mode 100644 doc/src/user/cli/convert.md create mode 100644 doc/src/user/cli/get.md create mode 100644 doc/src/user/cli/hash.md create mode 100644 doc/src/user/cli/key.md create mode 100644 doc/src/user/cli/state.md create mode 100644 doc/src/user/cli/storage-key.md create mode 100644 doc/src/user/cli/workspace.md create mode 100644 doc/src/user/installation.md diff --git a/.gitignore b/.gitignore index 73e64f14..2efafd48 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ # Package Manager ## Cargo target +## mdBook +book # Test data test-data diff --git a/README.md b/README.md index ba806e25..fbe23cf5 100644 --- a/README.md +++ b/README.md @@ -23,61 +23,3 @@ - **No `unsafe {}`/`.unwrap()`** - **Easy to Use** - **Strive for Excellence** - -## Usage -``` -subalfred 0.9.0-1bc3414-x86_64-unknown-linux-gnu -Xavier Lau -Your Substrate Alfred - -USAGE: - subalfred [OPTIONS] - -OPTIONS: - -h, --help Print help information - --log Set a custom logging filter. Also, work with the `RUST_LOG` environment variable [default: info] - -V, --version Print version information - -SUBCOMMANDS: - check Some checking tools are pretty useful for runtime development - export-state Export the chain state - hash Hash the hex with the specific hasher - help Print this message or the help of the given subcommand(s) - key Convert the public key/SS58 address from SS58 address/public key - storage-key Calculate the storage key for the storage prefix/item - workspace Workspace manager -``` - -## Components -### CLI -- [check](src/bin/subalfred/command/check) - - [runtime](src/bin/subalfred/command/check/runtime) - - [std-feature](src/bin/subalfred/command/check/std-feature) -- [workspace](src/bin/subalfred/command/workspace) - - [update](src/bin/subalfred/command/update) -- [export-state](src/bin/subalfred/command/export-state.rs) -- [hash](src/bin/subalfred/command/hash.rs) -- [key](src/bin/subalfred/command/key.rs) -- [storage-key](src/bin/subalfred/command/storage-key.rs) - -### Subalfred Core Libraries -- [cargo](src/subalfred/core/cargo) -- [check](src/subalfred/core/check) -- [error](src/subalfred/core/error) -- [http](src/subalfred/core/http) -- [jsonrpc](src/subalfred/core/jsonrpc) -- [key](src/subalfred/core/key) -- [node](src/subalfred/core/node) -- [ss58](src/subalfred/core/ss58) -- [substrate-client](src/subalfred/core/substrate-client) -- [system](src/subalfred/core/system) - -### Substrate Minimal Libraries -- [subcryptor](substrate-minimal/subcryptor) -- [subgrandpa](substrate-minimal/subgrandpa) -- [subhasher](substrate-minimal/subhasher) -- [submetadatan](substrate-minimal/submetadatan) -- [subrpcer](substrate-minimal/subrpcer) - - [impl](substrate-minimal/subrpcer/impl) -- [substorager](substrate-minimal/substorager) -- [subversioner](substrate-minimal/subversioner) diff --git a/doc/book.toml b/doc/book.toml new file mode 100644 index 00000000..7272a300 --- /dev/null +++ b/doc/book.toml @@ -0,0 +1,6 @@ +[book] +authors = ["Xavier Lau"] +language = "en" +multilingual = false +src = "src" +title = "Subalfred Documentation" diff --git a/doc/src/SUMMARY.md b/doc/src/SUMMARY.md new file mode 100644 index 00000000..2a12d06f --- /dev/null +++ b/doc/src/SUMMARY.md @@ -0,0 +1,20 @@ +# Summary +[Introduction](../../README.md) + +# User Guide +- [Installation](user/installation.md) +- [Command Line Tool](user/cli/README.md) + - [check](user/cli/check.md) + - [convert](user/cli/convert.md) + - [get](user/cli/get.md) + - [hash](user/cli/hash.md) + - [key](user/cli/key.md) + - [state](user/cli/state.md) + - [storage-key](user/cli/storage-key.md) + - [workspace](user/cli/workspace.md) + +# Reference Guide +- [todo]() + - [todo]() + - [todo]() + - [todo]() diff --git a/doc/src/user/cli/README.md b/doc/src/user/cli/README.md new file mode 100644 index 00000000..69dac500 --- /dev/null +++ b/doc/src/user/cli/README.md @@ -0,0 +1,14 @@ +# Command Line Tool +The `subalfred` command-line tool is used to create and build books. +After you have [installed](../installation.md) `subalfred`, you can run the `subalfred help` command in your terminal to view the available commands. + +This following sections provide in-depth information on the different commands available. + +* [`subalfred check`](check.md) +* [`subalfred convert`](convert.md) +* [`subalfred get`](get.md) +* [`subalfred hash`](hash.md) +* [`subalfred key`](key.md) +* [`subalfred state`](state.md) +* [`subalfred storage-key`](storage-key.md) +* [`subalfred workspace`](workspace.md) diff --git a/doc/src/user/cli/check.md b/doc/src/user/cli/check.md new file mode 100644 index 00000000..d5835e7e --- /dev/null +++ b/doc/src/user/cli/check.md @@ -0,0 +1,138 @@ +# The Check Command +Currently, there are two subcommands available. + +## Runtime +As the name says, the checks are on the runtime level. + +There are three shared options: +- `--chain `The chain name, which will supply to the executable. +- `--executable ` The executable path. +- `--live ` The live chain's RPC HTTP endpoint. + +And there are two properties to check, `storage` and `version`. + +### Examples +For convenience, I use the [Pangolin Network][pangolin-network] to demonstrate. +- `pangolin-dev` is the dev chain spec, which means its genesis is built from the latest code. +If you are on Polkadot, then use `polkadot-dev`. +- `./drml` is the path to my local pangolin node executable. +- `https://pangolin-rpc.darwinia.network` is the Pangoro live chain's RPC HTTP endpoint. Note, I use the Pangoro here. Just because I'm doing a demonstration. Compare with two different chains' runtime storage/version will get a lot of output. + +[pangolin-network]: https://github.com/darwinia-network/darwinia-common + +#### Check Runtime Storage +```sh +subalfred check runtime --chain pangolin-dev --executable ./drml --live https://pangoro-rpc.darwinia.network --property storage +``` +```diff ++ Pallet: "Bounties" +- Pallet: "BridgePangolinGrandpa" +- Pallet: "BridgePangolinMessages" ++ Pallet: "BridgePangolinParachainMessages" ++ Pallet: "BridgePangoroGrandpa" ++ Pallet: "BridgePangoroMessages" ++ Pallet: "BridgeRococoGrandpa" ++ Pallet: "BridgeRococoParachains" ++ Pallet: "Council" ++ Pallet: "DarwiniaEthereumRelay" ++ Pallet: "Democracy" ++ Pallet: "EcdsaRelayAuthority" ++ Pallet: "EthereumBacking" ++ Pallet: "HeaderMmr" ++ Pallet: "Identity" ++ Pallet: "Instance1DarwiniaRelayerGame" ++ Pallet: "KtonTreasury" ++ Pallet: "Multisig" +- Pallet: "PangolinFeeMarket" ++ Pallet: "PangolinParachainFeeMarket" ++ Pallet: "PangoroFeeMarket" ++ Pallet: "PhragmenElection" ++ Pallet: "Proxy" ++ Pallet: "Recovery" ++ Pallet: "Society" +- Pallet: "Substrate2SubstrateBacking" ++ Pallet: "Substrate2SubstrateIssuing" ++ Pallet: "TechnicalCommittee" ++ Pallet: "TechnicalMembership" ++ Pallet: "Tips" ++ Pallet: "ToPangolinParachainBacking" ++ Pallet: "Vesting" + +Pallet ElectionProviderMultiPhase ++ Entry: StorageEntryMetadata { name: "SignedSubmissionsMap", modifier: Default, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 4, marker: PhantomData }, value: UntrackedSymbol { id: 227, marker: PhantomData } }, default: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], docs: [" Unchecked, signed solutions.", "", " Together with `SubmissionIndices`, this stores a bounded set of `SignedSubmissions` while", " allowing us to keep only a single one in memory at a time.", "", " Twox note: the key of the map is an auto-incrementing index which users cannot inspect or", " affect; we shouldn't need a cryptographically secure hasher."] } +- Entry: StorageEntryMetadata { name: "SignedSubmissionsMap", modifier: Default, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 4, marker: PhantomData }, value: UntrackedSymbol { id: 186, marker: PhantomData } }, default: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], docs: [" Unchecked, signed solutions.", "", " Together with `SubmissionIndices`, this stores a bounded set of `SignedSubmissions` while", " allowing us to keep only a single one in memory at a time.", "", " Twox note: the key of the map is an auto-incrementing index which users cannot inspect or", " affect; we shouldn't need a cryptographically secure hasher."] } + +Pallet Scheduler ++ Entry: StorageEntryMetadata { name: "Agenda", modifier: Default, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 4, marker: PhantomData }, value: UntrackedSymbol { id: 609, marker: PhantomData } }, default: [0], docs: [" Items to be executed, indexed by the block number that they should be executed on."] } +- Entry: StorageEntryMetadata { name: "Agenda", modifier: Default, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 4, marker: PhantomData }, value: UntrackedSymbol { id: 378, marker: PhantomData } }, default: [0], docs: [" Items to be executed, indexed by the block number that they should be executed on."] } + +Pallet Session ++ Entry: StorageEntryMetadata { name: "NextKeys", modifier: Optional, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 0, marker: PhantomData }, value: UntrackedSymbol { id: 347, marker: PhantomData } }, default: [0], docs: [" The next session keys for a validator."] } +- Entry: StorageEntryMetadata { name: "NextKeys", modifier: Optional, ty: Map { hashers: [Twox64Concat], key: UntrackedSymbol { id: 0, marker: PhantomData }, value: UntrackedSymbol { id: 282, marker: PhantomData } }, default: [0], docs: [" The next session keys for a validator."] } ++ Entry: StorageEntryMetadata { name: "QueuedKeys", modifier: Default, ty: Plain(UntrackedSymbol { id: 345, marker: PhantomData }), default: [0], docs: [" The queued keys for the next session. When the next session begins, these keys", " will be used to determine the validator's session keys."] } +- Entry: StorageEntryMetadata { name: "QueuedKeys", modifier: Default, ty: Plain(UntrackedSymbol { id: 280, marker: PhantomData }), default: [0], docs: [" The queued keys for the next session. When the next session begins, these keys", " will be used to determine the validator's session keys."] } + +Pallet System ++ Entry: StorageEntryMetadata { name: "Events", modifier: Default, ty: Plain(UntrackedSymbol { id: 15, marker: PhantomData }), default: [0], docs: [" Events deposited for the current block.", "", " NOTE: This storage item is explicitly unbounded since it is never intended to be read", " from within the runtime."] } +- Entry: StorageEntryMetadata { name: "Events", modifier: Default, ty: Plain(UntrackedSymbol { id: 15, marker: PhantomData }), default: [0], docs: [" Events deposited for the current block.", "", " NOTE: This storage item is explicitly unbounded since it is never intended to be read", " from within the runtime."] } +``` + +#### Check Runtime Version +```sh +subalfred check runtime --chain pangolin-dev --executable ./drml --live https://pangoro-rpc.darwinia.network --property version +``` +```diff +RuntimeVersion { +- spec_name: "Pangoro", ++ spec_name: "Pangolin", +- impl_name: "Pangoro", ++ impl_name: "Pangolin", + authoring_version: 0, + spec_version: 29020, + impl_version: 0, + transaction_version: 0, +} +``` + +## STD Feature +As we know Substrate have two runtime ENVs, native and WASM. + +If a runtime dependency is not pure no-std, we need to write: +```toml +[features] +std = ["xxx/std"] + +[dependencies] +xxx = { version = "0.1.0", default-features = false } +``` + +Sometimes, we might forget to write add the `xxx/std`. +Recently, I found someone have the same [requirement][issue]. +So, I decide to make this public. + +[issue]: https://github.com/paritytech/substrate/pull/11715 + +### Example +```sh +git clone https://github.com/paritytech/frontier /tmp/paritytech +subalfred check std-feature --manifest-path /tmp/paritytech/frontier/Cargo.toml +``` +``` +`fp-evm`'s std feature was disabled in `/tmp/paritytech/frontier/primitives/ethereum/Cargo.toml` +`ed25519-dalek`'s std feature was disabled in `/tmp/paritytech/frontier/frame/evm/precompile/ed25519/Cargo.toml` +`bn`'s std feature was disabled in `/tmp/paritytech/frontier/frame/evm/precompile/bn128/Cargo.toml` +`curve25519-dalek`'s std feature was disabled in `/tmp/paritytech/frontier/frame/evm/precompile/curve25519/Cargo.toml` +`frame-benchmarking`'s std feature was disabled in `/tmp/paritytech/frontier/template/runtime/Cargo.toml` +`frame-system-benchmarking`'s std feature was disabled in `/tmp/paritytech/frontier/template/runtime/Cargo.toml` +``` + +--- + +## CI +Moreover, we can add the checks into your project CI. + +I've already add these to the [Darwinia CI][checks-ci]. +And here is a real world [example][checks-ci-example]. + +[checks-ci]: https://github.com/darwinia-network/darwinia/blob/v0.12.3/.github/workflows/ci.yml +[checks-ci-example]: https://github.com/darwinia-network/darwinia/pull/940#issuecomment-1226917895 diff --git a/doc/src/user/cli/convert.md b/doc/src/user/cli/convert.md new file mode 100644 index 00000000..81dea33a --- /dev/null +++ b/doc/src/user/cli/convert.md @@ -0,0 +1 @@ +# convert diff --git a/doc/src/user/cli/get.md b/doc/src/user/cli/get.md new file mode 100644 index 00000000..0e3ddd45 --- /dev/null +++ b/doc/src/user/cli/get.md @@ -0,0 +1,44 @@ +# The Get Command +Currently, there only one subcommand available. + +## Runtime Upgrade Block +The origin question is from [stackexchange][question]. + +Yep, I think that is an interesting question. +SO, I implemented this method. + +It uses dichotomy algorithm, the whole process takes times requests. + +[question]: https://substrate.stackexchange.com/questions/3861/how-do-you-tell-which-block-number-the-last-runtime-upgrade-happened-on-a-chain + +### Example +```sh +subalfred get runtime-upgrade-block 9100 --uri wss://polkadot.api.onfinality.io/public-ws -lsubalfred::core::node +``` +```log +2022-08-27T13:58:07.684200Z TRACE subalfred::core::node: (0, 11788056) -> 9050 +2022-08-27T13:58:09.469688Z TRACE subalfred::core::node: (5894028, 11788056) -> 9151 +2022-08-27T13:58:10.874493Z TRACE subalfred::core::node: (5894028, 8841042) -> 9110 +2022-08-27T13:58:11.852626Z TRACE subalfred::core::node: (5894028, 7367535) -> 9080 +2022-08-27T13:58:12.916960Z TRACE subalfred::core::node: (6630782, 7367535) -> 9090 +2022-08-27T13:58:13.126836Z TRACE subalfred::core::node: (6999158, 7367535) -> 9090 +2022-08-27T13:58:14.591213Z TRACE subalfred::core::node: (7183346, 7367535) -> 9110 +2022-08-27T13:58:14.800144Z TRACE subalfred::core::node: (7183346, 7275440) -> 9110 +2022-08-27T13:58:15.921005Z TRACE subalfred::core::node: (7183346, 7229393) -> 9090 +2022-08-27T13:58:18.036717Z TRACE subalfred::core::node: (7206370, 7229393) -> 9090 +2022-08-27T13:58:18.993673Z TRACE subalfred::core::node: (7217881, 7229393) -> 9100 +2022-08-27T13:58:19.208425Z TRACE subalfred::core::node: (7217881, 7223637) -> 9100 +2022-08-27T13:58:19.415621Z TRACE subalfred::core::node: (7217881, 7220759) -> 9100 +2022-08-27T13:58:19.624220Z TRACE subalfred::core::node: (7217881, 7219320) -> 9100 +2022-08-27T13:58:19.828821Z TRACE subalfred::core::node: (7217881, 7218601) -> 9100 +2022-08-27T13:58:20.035127Z TRACE subalfred::core::node: (7217881, 7218241) -> 9100 +2022-08-27T13:58:20.240336Z TRACE subalfred::core::node: (7217881, 7218061) -> 9100 +2022-08-27T13:58:20.444889Z TRACE subalfred::core::node: (7217881, 7217971) -> 9100 +2022-08-27T13:58:21.594894Z TRACE subalfred::core::node: (7217881, 7217926) -> 9090 +2022-08-27T13:58:24.625042Z TRACE subalfred::core::node: (7217904, 7217926) -> 9100 +2022-08-27T13:58:24.824345Z TRACE subalfred::core::node: (7217904, 7217915) -> 9100 +2022-08-27T13:58:25.030852Z TRACE subalfred::core::node: (7217904, 7217910) -> 9100 +2022-08-27T13:58:26.058492Z TRACE subalfred::core::node: (7217904, 7217907) -> 9090 +2022-08-27T13:58:26.275470Z TRACE subalfred::core::node: (7217906, 7217907) -> 9090 +7217907 0x8f10de9e6dcf190dccc90f464a8aa4448c9b080746d8e905bb0e4841fef80fdd +``` diff --git a/doc/src/user/cli/hash.md b/doc/src/user/cli/hash.md new file mode 100644 index 00000000..e59e2f32 --- /dev/null +++ b/doc/src/user/cli/hash.md @@ -0,0 +1 @@ +# hash diff --git a/doc/src/user/cli/key.md b/doc/src/user/cli/key.md new file mode 100644 index 00000000..0957f013 --- /dev/null +++ b/doc/src/user/cli/key.md @@ -0,0 +1 @@ +# key diff --git a/doc/src/user/cli/state.md b/doc/src/user/cli/state.md new file mode 100644 index 00000000..3e02771d --- /dev/null +++ b/doc/src/user/cli/state.md @@ -0,0 +1 @@ +# state diff --git a/doc/src/user/cli/storage-key.md b/doc/src/user/cli/storage-key.md new file mode 100644 index 00000000..fe3b2672 --- /dev/null +++ b/doc/src/user/cli/storage-key.md @@ -0,0 +1 @@ +# storage-key diff --git a/doc/src/user/cli/workspace.md b/doc/src/user/cli/workspace.md new file mode 100644 index 00000000..16cd1639 --- /dev/null +++ b/doc/src/user/cli/workspace.md @@ -0,0 +1 @@ +# workspace diff --git a/doc/src/user/installation.md b/doc/src/user/installation.md new file mode 100644 index 00000000..d05f4235 --- /dev/null +++ b/doc/src/user/installation.md @@ -0,0 +1,44 @@ +# Installation +There are multiple ways to install the `subalfred` CLI tool. +Choose any one of the methods below that best suit your needs. + +## Pre-compiled Binaries +Executable binaries are available for download on the [GitHub Releases page][releases]. +Download the binary for your platform (Windows, macOS, or Linux) and extract the archive. +The archive contains an `subalfred` executable which you can run to build your books. + +The compressing algorithm is zstd. +For some old systems, you might need to install zstd lib first. +And for the macOS users, you need to install gnu-tar and replace the `tar` command with `gtar`. + +Example: +```sh +# One line command: +curl -L https://github.com/hack-ink/subalfred/releases/download/v0.9.0-rc6/subalfred-x86_64-unknown-linux-gnu.tar.zst | tar x -I pzstd +# Or: +curl -LO https://github.com/hack-ink/subalfred/releases/download/v0.9.0-rc6/subalfred-x86_64-unknown-linux-gnu.tar.zst +tar xf subalfred-x86_64-unknown-linux-gnu.tar.zst -I pzstd +``` + +[releases]: https://github.com/hack-ink/subalfred/releases + +## Build from Source +To build the `subalfred` executable from source, you will first need to install Rust and Cargo. +Once you have installed Rust, the following command can be used to build and install `subalfred`: +```sh +# Build from crates.io: +cargo install subalfred +# Build from the latest main branch code: +cargo install subalfred --git https://github.com/hack-ink/subalfred +``` + +This will automatically download `subalfred` from [crates.io]/[github.com], build it, and install it in Cargo's global binary directory (`~/.cargo/bin/` by default). + +The version published to crates.io will ever so slightly be behind the version hosted on GitHub. +If you need the latest version you can build the git version of `subalfred` yourself. +Cargo makes this ***super easy***! + +To uninstall, run the command `cargo uninstall subalfred`. + +[crates.io]: https://crates.io +[github.com]: https://github.com/hack-ink/subalfred From c95110a3abfa6f968c09e65b309d9281061a23ac Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:05:48 +0800 Subject: [PATCH 02/12] Deploy Pages --- .github/workflows/pages.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/pages.yml diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 00000000..39c408db --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,30 @@ +name: Pages + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + steps: + - name: Fetch latest code + uses: actions/checkout@v3 + - name: Setup mdBook + uses: peaceiris/actions-mdbook@v1 + with: + mdbook-version: "latest" + - name: Build pages + run: mdbook build + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + # if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: doc/book From 9472377e6a7dddd7b7aca530a28cb1827957c678 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:07:17 +0800 Subject: [PATCH 03/12] Correct Path --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 39c408db..cd5fce34 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -21,7 +21,7 @@ jobs: with: mdbook-version: "latest" - name: Build pages - run: mdbook build + run: mdbook build doc - name: Deploy uses: peaceiris/actions-gh-pages@v3 # if: ${{ github.ref == 'refs/heads/main' }} From 71ef961ae02932a6462028417200861b668f0f9d Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:10:28 +0800 Subject: [PATCH 04/12] Restrict to `main` Branch --- .github/workflows/pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index cd5fce34..1278e70e 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -24,7 +24,7 @@ jobs: run: mdbook build doc - name: Deploy uses: peaceiris/actions-gh-pages@v3 - # if: ${{ github.ref == 'refs/heads/main' }} + if: ${{ github.ref == 'refs/heads/main' }} with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: doc/book From fe0bfddb1de865062335e8bd534e536272561961 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:27:38 +0800 Subject: [PATCH 05/12] Format --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fbe23cf5..cd396d2a 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,12 @@ ## Philosophies -- **Lighting Fast** -- **Less Dependencies** -- **No `unsafe {}`/`.unwrap()`** -- **Easy to Use** -- **Strive for Excellence** +- ***Lighting fast*** +- ***Less dependencies*** +- ***No `unsafe {}`, `.unwrap()`*** +- ***Easy to use*** +- ***Strive for excellence*** + +## Documentations +- [`subalfred.hack.ink`](https://subalfred.hack.ink) +- [`hack-ink.github.io (backup)`](https://hack-ink.github.io) From 41c0dbc8f75cbfeee125b599dadd22460ea334a4 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:33:51 +0800 Subject: [PATCH 06/12] Ignore `index.html` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2efafd48..4ab0e70c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ target ## mdBook book +index.html # Test data test-data From 403f9faebddd21497942dafa8ee19a65bf37329b Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:34:01 +0800 Subject: [PATCH 07/12] Update --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index cd396d2a..9df22101 100644 --- a/README.md +++ b/README.md @@ -25,5 +25,13 @@ - ***Strive for excellence*** ## Documentations +```sh +# Use the `--help` flag to get more information. +subalfred --help +# Each subcommand also provides its own `--help`. +subalfred check --help +subalfred check runtime --help +``` + - [`subalfred.hack.ink`](https://subalfred.hack.ink) - [`hack-ink.github.io (backup)`](https://hack-ink.github.io) From 1f16bbaf731904e53fa8da2e284385576542ac9f Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:37:35 +0800 Subject: [PATCH 08/12] Fix Typo --- doc/src/user/cli/get.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/user/cli/get.md b/doc/src/user/cli/get.md index 0e3ddd45..15a726fa 100644 --- a/doc/src/user/cli/get.md +++ b/doc/src/user/cli/get.md @@ -5,7 +5,7 @@ Currently, there only one subcommand available. The origin question is from [stackexchange][question]. Yep, I think that is an interesting question. -SO, I implemented this method. +So, I implemented this method. It uses dichotomy algorithm, the whole process takes times requests. From d406823c368fe6fc5d0dc700067fc73ba81b52d8 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:39:59 +0800 Subject: [PATCH 09/12] Rename --- .github/workflows/pages.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 1278e70e..10934c45 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -10,6 +10,7 @@ on: jobs: deploy: + name: Deploy pages runs-on: ubuntu-latest concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 9984ecf97c08dd7600835d6e486cb36281f08717 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:47:55 +0800 Subject: [PATCH 10/12] Add Contribution Part --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 9df22101..77a76b16 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,8 @@ subalfred check runtime --help - [`subalfred.hack.ink`](https://subalfred.hack.ink) - [`hack-ink.github.io (backup)`](https://hack-ink.github.io) + +## Contribution +- If you have a question or request a new feature, [start a discussion](https://github.com/hack-ink/subalfred/discussions/new). +- If you encounter any bugs, [report an issue](https://github.com/hack-ink/subalfred/issues/new). +- Otherwise, PRs are always welcome! From 2ba5f0bd777dec2671300d8204d601fcd10b2ff4 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:50:35 +0800 Subject: [PATCH 11/12] Format --- doc/src/user/installation.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/user/installation.md b/doc/src/user/installation.md index d05f4235..8c0da275 100644 --- a/doc/src/user/installation.md +++ b/doc/src/user/installation.md @@ -13,9 +13,9 @@ And for the macOS users, you need to install gnu-tar and replace the `tar` comma Example: ```sh -# One line command: +# One line command curl -L https://github.com/hack-ink/subalfred/releases/download/v0.9.0-rc6/subalfred-x86_64-unknown-linux-gnu.tar.zst | tar x -I pzstd -# Or: +# Or curl -LO https://github.com/hack-ink/subalfred/releases/download/v0.9.0-rc6/subalfred-x86_64-unknown-linux-gnu.tar.zst tar xf subalfred-x86_64-unknown-linux-gnu.tar.zst -I pzstd ``` From 369b0828329ba0e8be286069df5ed06eaa029126 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 27 Aug 2022 22:57:25 +0800 Subject: [PATCH 12/12] Format --- doc/src/user/cli/check.md | 15 ++++----------- doc/src/user/cli/get.md | 4 +--- doc/src/user/installation.md | 6 +++--- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/doc/src/user/cli/check.md b/doc/src/user/cli/check.md index d5835e7e..52533fec 100644 --- a/doc/src/user/cli/check.md +++ b/doc/src/user/cli/check.md @@ -12,14 +12,12 @@ There are three shared options: And there are two properties to check, `storage` and `version`. ### Examples -For convenience, I use the [Pangolin Network][pangolin-network] to demonstrate. +For convenience, I use the [Pangolin Network](https://github.com/darwinia-network/darwinia-common) to demonstrate. - `pangolin-dev` is the dev chain spec, which means its genesis is built from the latest code. If you are on Polkadot, then use `polkadot-dev`. - `./drml` is the path to my local pangolin node executable. - `https://pangolin-rpc.darwinia.network` is the Pangoro live chain's RPC HTTP endpoint. Note, I use the Pangoro here. Just because I'm doing a demonstration. Compare with two different chains' runtime storage/version will get a lot of output. -[pangolin-network]: https://github.com/darwinia-network/darwinia-common - #### Check Runtime Storage ```sh subalfred check runtime --chain pangolin-dev --executable ./drml --live https://pangoro-rpc.darwinia.network --property storage @@ -107,11 +105,9 @@ xxx = { version = "0.1.0", default-features = false } ``` Sometimes, we might forget to write add the `xxx/std`. -Recently, I found someone have the same [requirement][issue]. +Recently, I found someone have the same [requirement](https://github.com/paritytech/substrate/pull/11715). So, I decide to make this public. -[issue]: https://github.com/paritytech/substrate/pull/11715 - ### Example ```sh git clone https://github.com/paritytech/frontier /tmp/paritytech @@ -131,8 +127,5 @@ subalfred check std-feature --manifest-path /tmp/paritytech/frontier/Cargo.toml ## CI Moreover, we can add the checks into your project CI. -I've already add these to the [Darwinia CI][checks-ci]. -And here is a real world [example][checks-ci-example]. - -[checks-ci]: https://github.com/darwinia-network/darwinia/blob/v0.12.3/.github/workflows/ci.yml -[checks-ci-example]: https://github.com/darwinia-network/darwinia/pull/940#issuecomment-1226917895 +I've already add these to the [Darwinia CI](https://github.com/darwinia-network/darwinia/blob/v0.12.3/.github/workflows/ci.yml). +And here is a real world [example](https://github.com/darwinia-network/darwinia/pull/940#issuecomment-1226917895). diff --git a/doc/src/user/cli/get.md b/doc/src/user/cli/get.md index 15a726fa..9798ebdb 100644 --- a/doc/src/user/cli/get.md +++ b/doc/src/user/cli/get.md @@ -2,15 +2,13 @@ Currently, there only one subcommand available. ## Runtime Upgrade Block -The origin question is from [stackexchange][question]. +The origin question is from [stackexchange](https://substrate.stackexchange.com/questions/3861/how-do-you-tell-which-block-number-the-last-runtime-upgrade-happened-on-a-chain). Yep, I think that is an interesting question. So, I implemented this method. It uses dichotomy algorithm, the whole process takes times requests. -[question]: https://substrate.stackexchange.com/questions/3861/how-do-you-tell-which-block-number-the-last-runtime-upgrade-happened-on-a-chain - ### Example ```sh subalfred get runtime-upgrade-block 9100 --uri wss://polkadot.api.onfinality.io/public-ws -lsubalfred::core::node diff --git a/doc/src/user/installation.md b/doc/src/user/installation.md index 8c0da275..302e601a 100644 --- a/doc/src/user/installation.md +++ b/doc/src/user/installation.md @@ -3,7 +3,7 @@ There are multiple ways to install the `subalfred` CLI tool. Choose any one of the methods below that best suit your needs. ## Pre-compiled Binaries -Executable binaries are available for download on the [GitHub Releases page][releases]. +Executable binaries are available for download on the [GitHub Releases page]. Download the binary for your platform (Windows, macOS, or Linux) and extract the archive. The archive contains an `subalfred` executable which you can run to build your books. @@ -20,7 +20,7 @@ curl -LO https://github.com/hack-ink/subalfred/releases/download/v0.9.0-rc6/suba tar xf subalfred-x86_64-unknown-linux-gnu.tar.zst -I pzstd ``` -[releases]: https://github.com/hack-ink/subalfred/releases +[GitHub Releases page]: https://github.com/hack-ink/subalfred/releases ## Build from Source To build the `subalfred` executable from source, you will first need to install Rust and Cargo. @@ -34,7 +34,7 @@ cargo install subalfred --git https://github.com/hack-ink/subalfred This will automatically download `subalfred` from [crates.io]/[github.com], build it, and install it in Cargo's global binary directory (`~/.cargo/bin/` by default). -The version published to crates.io will ever so slightly be behind the version hosted on GitHub. +The version published to [crates.io] will ever so slightly be behind the version hosted on GitHub. If you need the latest version you can build the git version of `subalfred` yourself. Cargo makes this ***super easy***!