Skip to content

Commit

Permalink
ENV: AUTHORIZE_UPGRADE_CHECK_VERSION
Browse files Browse the repository at this point in the history
* Add flag for new check_version
* Remove unused stuff
* Fix readme
* Fix doc and linting issue, update deps
* Update usage and docs

---------

Co-authored-by: Antonio Antonino <[email protected]>
  • Loading branch information
chevdor and ntn-x2 authored Mar 27, 2024
1 parent 2168474 commit 8cce565
Show file tree
Hide file tree
Showing 26 changed files with 957 additions and 668 deletions.
1,431 changes: 803 additions & 628 deletions Cargo.lock

Large diffs are not rendered by default.

39 changes: 30 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,19 @@ MacOS Homebrew users can use:

Commands:
get Get/Download the runtime wasm from a running node through rpc
info The `info` command returns summarized information about a runtime
version The `version` command returns summarized information about the versions of a runtime
info Shows information about a given runtime
version Shows information about a given runtime
metadata Returns the metadata of the given runtime in several format. You may also use the "meta" alias
show Shows the a reduced view of the runtime
diff Compare 2 runtimes after converting them to `ReducedRuntime`s
diff Compare 2 runtimes after converting them to `[ReducedRuntime]`s
compress Compress a given runtime wasm file. You will get an error if you try compressing a runtime that is already compressed
decompress Decompress a given runtime wasm file. You may pass a runtime that is already uncompressed
help Print this message or the help of the given subcommand(s)

Options:
-v, --version Show the version
-j, --json Output as json
-n, --no-color [env: NO_COLOR=]
-n, --no-color Do not write color information to the output. This is recommended for scripts [env: NO_COLOR=]
-q, --quiet Less output
-h, --help Print help

Expand Down Expand Up @@ -163,6 +163,8 @@ MacOS Homebrew users can use:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand All @@ -173,7 +175,7 @@ MacOS Homebrew users can use:

### Command: info

The `info` command returns summarized information about a runtime
Shows information about a given runtime

Usage: subwasm info [OPTIONS] [FILE]

Expand Down Expand Up @@ -202,6 +204,8 @@ MacOS Homebrew users can use:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand All @@ -211,11 +215,18 @@ MacOS Homebrew users can use:
Print help (see a summary with '-h')

By default, the ID for the Parachain pallet is expected to be `0x01` and the call ID for `authorize_upgrade` is expected to be `0x03`.
This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to the ID of your parachain pallet and the `AUTHORIZE_UPGRADE_PREFIX` to the ID of your choice.
This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to the ID of your parachain pallet and the
`AUTHORIZE_UPGRADE_PREFIX` to the ID of your choice.

Due to a [breaking change to the `parachainSystem::authorizeUpgrade` extrinsic](https://github.com/paritytech/cumulus/commit/3249186fe643f62ca95769e2217f858dde803ab6), a new `checkVersion` boolean flag is required on chains running on Cumulus v0.9.41 and above.
This new behavior is supported by the `AUTHORIZE_UPGRADE_CHECK_VERSION` env variable, which, if set, is evaluated to
`true` if its value is the string `"true"`, or `` false` `` otherwise. If not set, the behavior remains the same as pre-0.9.41.

The new `check_spec_version` parameter can be provided with the `AUTHORIZE_UPGRADE_CHECK_VERSION=true` or `AUTHORIZE_UPGRADE_CHECK_VERSION=false` variable, if needed.

### Command: version

The `version` command returns summarized information about the versions of a runtime
Shows information about a given runtime

Usage: subwasm version [OPTIONS] [FILE]

Expand Down Expand Up @@ -244,6 +255,8 @@ This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to t
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down Expand Up @@ -292,6 +305,8 @@ This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to t
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down Expand Up @@ -335,6 +350,8 @@ This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to t
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand All @@ -345,7 +362,7 @@ This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to t

### Command: diff

Compare 2 runtimes after converting them to `ReducedRuntime`s.
Compare 2 runtimes after converting them to `[ReducedRuntime]`s.

You must pass exactly 2 runtimes.

Expand All @@ -363,6 +380,8 @@ This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to t
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand All @@ -383,7 +402,7 @@ This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to t

Options:
-j, --json Output as json
-n, --no-color [env: NO_COLOR=]
-n, --no-color Do not write color information to the output. This is recommended for scripts [env: NO_COLOR=]
-q, --quiet Less output
-h, --help Print help

Expand All @@ -407,6 +426,8 @@ This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to t
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
2 changes: 1 addition & 1 deletion cli/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ pub struct DecompressOpts {
pub output: PathBuf,
}

/// This parser wrapper is used by clap to parse a `&str` as [Source](subwasmlib::source::Source).
/// This parser wrapper is used by clap to parse a `&str` as [Source].
pub fn parse_source(s: &str) -> error::Result<Source> {
Source::try_from(s).map_err(|_e| error::SubwasmError::SourceParseError(s.to_string()))
}
9 changes: 8 additions & 1 deletion doc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ include::usage_info.adoc[]
----

NOTE: By default, the ID for the Parachain pallet is expected to be `0x01` and the call ID for `authorize_upgrade` is expected to be `0x03`.
This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to the ID of your parachain pallet and the `AUTHORIZE_UPGRADE_PREFIX` to the ID of your choice.
This default behavior can be overriden by setting the `PARACHAIN_PALLET_ID` to the ID of your parachain pallet and the
`AUTHORIZE_UPGRADE_PREFIX` to the ID of your choice.

Due to a https://github.com/paritytech/cumulus/commit/3249186fe643f62ca95769e2217f858dde803ab6[breaking change to the `parachainSystem::authorizeUpgrade` extrinsic], a new `checkVersion` boolean flag is required on chains running on Cumulus v0.9.41 and above.
This new behavior is supported by the `AUTHORIZE_UPGRADE_CHECK_VERSION` env variable, which, if set, is evaluated to
`true` if its value is the string `"true"`, or `false`` otherwise. If not set, the behavior remains the same as pre-0.9.41.

The new `check_spec_version` parameter can be provided with the `AUTHORIZE_UPGRADE_CHECK_VERSION=true` or `AUTHORIZE_UPGRADE_CHECK_VERSION=false` variable, if needed.

=== Command: version
----
Expand Down
8 changes: 4 additions & 4 deletions doc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ Usage: subwasm [OPTIONS] [COMMAND]

Commands:
get Get/Download the runtime wasm from a running node through rpc
info The `info` command returns summarized information about a runtime
version The `version` command returns summarized information about the versions of a runtime
info Shows information about a given runtime
version Shows information about a given runtime
metadata Returns the metadata of the given runtime in several format. You may also use the "meta" alias
show Shows the a reduced view of the runtime
diff Compare 2 runtimes after converting them to `ReducedRuntime`s
diff Compare 2 runtimes after converting them to `[ReducedRuntime]`s
compress Compress a given runtime wasm file. You will get an error if you try compressing a runtime that is already compressed
decompress Decompress a given runtime wasm file. You may pass a runtime that is already uncompressed
help Print this message or the help of the given subcommand(s)

Options:
-v, --version Show the version
-j, --json Output as json
-n, --no-color [env: NO_COLOR=]
-n, --no-color Do not write color information to the output. This is recommended for scripts [env: NO_COLOR=]
-q, --quiet Less output
-h, --help Print help
2 changes: 1 addition & 1 deletion doc/usage_compress.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Arguments:

Options:
-j, --json Output as json
-n, --no-color [env: NO_COLOR=]
-n, --no-color Do not write color information to the output. This is recommended for scripts [env: NO_COLOR=]
-q, --quiet Less output
-h, --help Print help
2 changes: 2 additions & 0 deletions doc/usage_decompress.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Options:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
4 changes: 3 additions & 1 deletion doc/usage_diff.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Compare 2 runtimes after converting them to `ReducedRuntime`s.
Compare 2 runtimes after converting them to `[ReducedRuntime]`s.

You must pass exactly 2 runtimes.

Expand All @@ -16,6 +16,8 @@ Options:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
2 changes: 2 additions & 0 deletions doc/usage_get.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Options:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
4 changes: 3 additions & 1 deletion doc/usage_info.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The `info` command returns summarized information about a runtime
Shows information about a given runtime

Usage: subwasm info [OPTIONS] [FILE]

Expand Down Expand Up @@ -27,6 +27,8 @@ Options:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
2 changes: 2 additions & 0 deletions doc/usage_meta.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Options:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
2 changes: 2 additions & 0 deletions doc/usage_show.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Options:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
4 changes: 3 additions & 1 deletion doc/usage_version.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The `version` command returns summarized information about the versions of a runtime
Shows information about a given runtime

Usage: subwasm version [OPTIONS] [FILE]

Expand Down Expand Up @@ -27,6 +27,8 @@ Options:
Output as json

-n, --no-color
Do not write color information to the output. This is recommended for scripts

[env: NO_COLOR=]

-q, --quiet
Expand Down
4 changes: 2 additions & 2 deletions lib/src/chain_info.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{chain_urls::get_chain_urls, error, SubwasmLibError};
use crate::{chain_urls::get_chain_urls, error};
use error::*;
use rand::seq::SliceRandom;
use std::str::FromStr;
Expand Down Expand Up @@ -31,7 +31,7 @@ pub struct ChainInfo {
/// Name of the chain
pub name: String,

/// List of endpoints for the chain [name]
/// List of endpoints for the chain [ChainInfo::name]
pub endpoints: Vec<NodeEndpoint>,
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::github_ref::GithubRef;
use crate::is_wasm_from_url;
use crate::ChainInfo;

/// The [wasmloader] provides a basic Source struct that
/// The [wasm_loader::WasmLoader] provides a basic Source struct that
/// can handle only a file or RPC endpoint.
/// This Enum here is fancier and will allow more sources.
#[derive(Debug, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/subwasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
error::*,
metadata_wrapper::{self, MetadataWrapper},
utils::print_big_output_safe,
RuntimeInfo, SubwasmLibError,
RuntimeInfo,
};

/// The main `subwasm` object
Expand Down
3 changes: 0 additions & 3 deletions libs/substrate-differ/src/differs/reduced/calls/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use super::{
signature::{Arg, Signature},
};
use comparable::Comparable;
use scale_info::{form::PortableForm, TypeDefVariant};
use serde::Serialize;
use std::{collections::BTreeMap, fmt::Display};

Expand Down Expand Up @@ -70,8 +69,6 @@ pub fn variant_to_calls(td: &TypeDefVariant<PortableForm>) -> BTreeMap<PalletId,

#[cfg(test)]
mod test_reduced_call {
use crate::differs::reduced::calls::signature::Arg;

use super::*;

#[test]
Expand Down
2 changes: 0 additions & 2 deletions libs/substrate-differ/src/differs/reduced/pallet_item.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use super::calls::{call::*, constant::*, error::*, event::*, storage::*};
use comparable::Comparable;
// use frame_metadata::PalletCallMetadata;
// use scale_info::form::PortableForm;
use std::fmt::Display;

#[derive(Debug, PartialEq, Hash, Comparable, PartialOrd, Ord, Eq)]
Expand Down
3 changes: 1 addition & 2 deletions libs/substrate-differ/src/differs/reduced/reduced_pallet.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use super::calls::{prelude::PalletId, *};
use super::calls::*;
use comparable::Comparable;
use frame_metadata::v14::PalletMetadata;
use scale_info::form::PortableForm;
use serde::Serialize;
use std::{collections::BTreeMap, fmt::Display};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl ReducedRuntime {
.find(|reduced_pallet| reduced_pallet.name.to_lowercase() == pallet_name.to_ascii_lowercase())
}

/// You can also use [get_pallet_by_name](fn@get_pallet_by_name) but prefer using [get_pallet_by_id](fn@get_pallet_by_id) where you can.
/// You can also use [get_pallet_by_name](ReducedRuntime::get_pallet_by_name) but prefer using [get_pallet_by_id](ReducedRuntime::get_pallet_by_id) where you can.
pub fn get_pallet_by_id(&self, pallet_id: PalletId) -> Option<&ReducedPallet> {
self.pallets.get(&pallet_id)
}
Expand Down
Loading

0 comments on commit 8cce565

Please sign in to comment.