Skip to content

Commit 9d5acb8

Browse files
committed
Release v0.1.9
1 parent 34cc683 commit 9d5acb8

13 files changed

Lines changed: 126 additions & 70 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ edition = "2021"
1111
homepage = "https://hack.ink/polkadot-runtime-releaser"
1212
license = "GPL-3.0"
1313
repository = "https://github.com/hack-ink/polkadot-runtime-releaser"
14-
version = "0.1.8"
14+
version = "0.1.9"
1515

1616
[workspace.dependencies]
1717
# crates.io

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ PPR also supports using a custom Docker image. Use `ppr build --help` to get mor
8181
### Runtime
8282
#### IMPORTANT NOTES
8383
- PRR makes some assumption while deal with the runtime artifacts.
84-
- Runtime crate name is in `{}-runtime` format. E.G. [`polkadot-runtime`](https://github.com/polkadot-fellows/runtimes/blob/46dcafcee64fe4d8c722d071a4a0ca983fcc2f08/relay/polkadot/Cargo.toml#L2)
85-
- WASM file name is in `{}_runtime.compact.compressed.wasm` format. E.G. [`polkadot_runtime.compact.compressed.wasm`](https://github.com/polkadot-fellows/runtimes/releases/tag/v1.3.4)
84+
- Runtime crate name must be in `{}-runtime` format. E.G. [`polkadot-runtime`](https://github.com/polkadot-fellows/runtimes/blob/46dcafcee64fe4d8c722d071a4a0ca983fcc2f08/relay/polkadot/Cargo.toml#L2)
85+
- WASM file name must be in `{}_runtime.compact.compressed.wasm` format. E.G. [`polkadot_runtime.compact.compressed.wasm`](https://github.com/polkadot-fellows/runtimes/releases/tag/v1.3.4)
8686

8787
### GitHub
8888

action/build/action.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ inputs:
88
runtime:
99
description: "Target runtime to build."
1010
required: true
11-
override-runtime-name:
12-
description: "The name to use matching the runtime artifacts."
13-
required: false
1411
features:
1512
description: "Features to enable for the runtime."
1613
required: false
@@ -30,7 +27,7 @@ runs:
3027
- name: Setup Polkadot Runtime Releaser
3128
shell: bash
3229
run: curl
33-
-L https://github.com/hack-ink/polkadot-runtime-releaser/releases/download/v0.1.8/prr-x86_64-unknown-linux-gnu.tar.gz |
30+
-L https://github.com/hack-ink/polkadot-runtime-releaser/releases/download/v0.1.9/prr-x86_64-unknown-linux-gnu.tar.gz |
3431
tar xz &&
3532
chmod u+x prr &&
3633
mv prr /usr/local/bin/prr
@@ -39,9 +36,6 @@ runs:
3936
run: |
4037
CMD="prr build ${{ inputs.runtime }}"
4138
42-
if [ ! -z "${{ inputs.override-runtime-name }}" ]; then
43-
CMD="$CMD -n ${{ inputs.override-runtime-name }}"
44-
fi
4539
if [ ! -z "${{ inputs.features }}" ]; then
4640
CMD="$CMD -f ${{ inputs.features }}"
4741
fi

action/inspect/action.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,42 @@ inputs:
88
runtime:
99
description: "Target runtime to inspect."
1010
required: true
11+
no-check-version:
12+
description: "Whether to check the runtime version in the `ParachainSystem::authorized_upgrade` call."
13+
required: false
14+
beautify:
15+
description: "Whether to beautify the JSON output."
16+
required: false
17+
verbose:
18+
description: "Whether to print verbose output."
19+
required: false
1120

1221
runs:
1322
using: "composite"
1423
steps:
1524
- name: Setup Polkadot Runtime Releaser
1625
shell: bash
1726
run: curl
18-
-L https://github.com/hack-ink/polkadot-runtime-releaser/releases/download/v0.1.8/prr-x86_64-unknown-linux-gnu.tar.gz |
27+
-L https://github.com/hack-ink/polkadot-runtime-releaser/releases/download/v0.1.9/prr-x86_64-unknown-linux-gnu.tar.gz |
1928
tar xz &&
2029
chmod u+x prr &&
2130
mv prr /usr/local/bin/prr
2231
- name: Inspect runtime
2332
id: inspect
2433
shell: bash
2534
run: |
26-
RESULT=$(prr inspect ${{ inputs.runtime }})
35+
CMD="prr inspect ${{ inputs.runtime }}"
36+
if [ ! -z "${{ inputs.no-check-version }}" ]; then
37+
CMD="$CMD --no-check-version"
38+
fi
39+
if [ ! -z "${{ inputs.beautify }}" ]; then
40+
CMD="$CMD -b"
41+
fi
42+
if [ ! -z "${{ inputs.verbose }}" ]; then
43+
CMD="$CMD -v"
44+
fi
45+
46+
RESULT=$(${CMD})
2747
echo "result=${RESULT}" >> "$GITHUB_OUTPUT"
2848
2949
outputs:

action/override/action.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ runs:
4343
ref: ${{ inputs.ref }}
4444
path: runtime
4545
- name: Build runtime
46-
uses: hack-ink/polkadot-runtime-releaser/action/build@v0.1.8
46+
uses: hack-ink/polkadot-runtime-releaser/action/build@v0.1.9
4747
with:
4848
runtime: ${{ inputs.runtime }}
49-
override-runtime-name: ${{ inputs.override-runtime-name }}
5049
features: ${{ inputs.features }}
5150
toolchain-ver: ${{ inputs.toolchain-ver }}
5251
workdir: runtime

action/try-runtime/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ runs:
3333
chmod +x try-runtime &&
3434
mv try-runtime /usr/local/bin/try-runtime
3535
- name: Build runtime
36-
uses: hack-ink/polkadot-runtime-releaser/action/build@v0.1.8
36+
uses: hack-ink/polkadot-runtime-releaser/action/build@v0.1.9
3737
with:
3838
runtime: ${{ inputs.runtime }}
3939
features: ${{ inputs.features }}

cli/src/cli/build.rs

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use std::{env, fs, path::PathBuf};
33
// crates.io
44
use clap::Parser;
55
// self
6-
use crate::{cli::Run, prelude::*};
6+
use crate::{
7+
cli::{InspectCmd, Run},
8+
prelude::*,
9+
};
710
use prr_lib::{docker::RunArgs, rust, wasmer::Wasmer};
811

912
const WASM_EXT: &str = "wasm";
@@ -17,20 +20,15 @@ pub struct BuildCmd {
1720
/// This should be the name of the runtime crate in the <Cargo.toml> file.
1821
#[arg(value_name = "RUNTIME", verbatim_doc_comment)]
1922
runtime: String,
20-
/// The name to use matching the runtime artifacts.
21-
/// This is useful when the runtime crate name is different from the runtime name.
22-
///
23-
/// For example, `staging-kusama-runtime`.
24-
/// With this option, you can specify the runtime name to be `kusama`,
25-
/// and it will match the `kusama_runtime*.wasm` artifacts.
26-
#[arg(long, short = 'n', value_name = "NAME", verbatim_doc_comment)]
27-
override_runtime_name: Option<String>,
2823
/// The features to enable for the runtime.
2924
#[arg(long, short, value_name = "FEATURES", verbatim_doc_comment)]
3025
features: Option<String>,
3126
/// Whether to store the compressed runtime only.
3227
#[arg(long, verbatim_doc_comment)]
3328
no_compressed_only: bool,
29+
/// Whether to generate the digest file for the runtime.
30+
#[arg(long, verbatim_doc_comment)]
31+
no_digest: bool,
3432
/// The toolchain version to use for the build; by default, it is set to <stable>.
3533
///
3634
/// This won't take effect if there is a <rust-toolchain.toml> file in the project directory,
@@ -42,7 +40,7 @@ pub struct BuildCmd {
4240
long,
4341
short = 'v',
4442
value_name = "VER",
45-
default_value_t = String::from("0.1.8"),
43+
default_value_t = String::from("0.1.9"),
4644
verbatim_doc_comment,
4745
conflicts_with = "override_docker_image"
4846
)]
@@ -84,9 +82,9 @@ impl Run for BuildCmd {
8482
fn run(self) -> Result<()> {
8583
let Self {
8684
runtime,
87-
override_runtime_name,
8885
features,
8986
no_compressed_only,
87+
no_digest,
9088
toolchain_version,
9189
image_version,
9290
override_docker_image,
@@ -101,7 +99,7 @@ impl Run for BuildCmd {
10199

102100
let output_dir = {
103101
if !output_dir.exists() {
104-
tracing::info!("creating the output directory {}", output_dir.display());
102+
tracing::info!("creating the output directory {output_dir:?}");
105103

106104
fs::create_dir(&output_dir)?;
107105
}
@@ -121,10 +119,7 @@ impl Run for BuildCmd {
121119
let output_target_dir = output_dir.join("target");
122120

123121
if !cache_output && output_target_dir.exists() {
124-
tracing::info!(
125-
"purging previous output target directory {}",
126-
output_target_dir.display()
127-
);
122+
tracing::info!("purging previous output target directory {output_target_dir:?}",);
128123

129124
fs::remove_dir_all(&output_target_dir)?;
130125
}
@@ -145,34 +140,38 @@ impl Run for BuildCmd {
145140
run_args.with_command(&cmd);
146141
run_args.run()?;
147142

148-
let snake_case_rt = if let Some(name) = override_runtime_name {
149-
format!("{name}_runtime")
150-
} else {
151-
runtime.replace("-runtime", "_runtime")
152-
};
143+
// https://github.com/paritytech/polkadot-sdk/blob/ca7817922148c1e6f6856138998f7135f42f3f4f/substrate/utils/wasm-builder/src/wasm_project.rs#L502.
144+
let snake_case_name = runtime.replace("-", "_");
153145
let output_rt =
154-
output_target_dir.join("release/wbuild").join(&runtime).join(&snake_case_rt);
155-
let compressed_wasm = output_rt.with_extension(WASM_EXT_COMPRESSED);
156-
let ver = Wasmer::load(&compressed_wasm)?.runtime_version(true)?.spec_version;
157-
let rt_name = format!("{snake_case_rt}-{ver}");
146+
output_target_dir.join("release/wbuild").join(&runtime).join(&snake_case_name);
147+
let compressed_rt = output_rt.with_extension(WASM_EXT_COMPRESSED);
148+
149+
tracing::info!("loading {compressed_rt:?}");
150+
151+
let wasmer = Wasmer::load(&compressed_rt)?;
152+
let ver = wasmer.runtime_version(true)?.spec_version;
153+
let rt_prefix = output_dir.join(format!("{snake_case_name}-{ver}"));
158154

159-
fs::copy(compressed_wasm, output_dir.join(&rt_name).with_extension(WASM_EXT_COMPRESSED))?;
155+
util::copy(&compressed_rt, &rt_prefix.with_extension(WASM_EXT_COMPRESSED))?;
160156

161157
if no_compressed_only {
162-
fs::copy(
163-
output_rt.with_extension(WASM_EXT_COMPACT),
164-
output_dir.join(&rt_name).with_extension(WASM_EXT_COMPACT),
165-
)?;
166-
fs::copy(
167-
output_rt.with_extension(WASM_EXT),
168-
output_dir.join(&rt_name).with_extension(WASM_EXT),
158+
util::copy(
159+
&output_rt.with_extension(WASM_EXT_COMPACT),
160+
&rt_prefix.with_extension(WASM_EXT_COMPACT),
169161
)?;
162+
util::copy(&output_rt.with_extension(WASM_EXT), &rt_prefix.with_extension(WASM_EXT))?;
163+
}
164+
if !no_digest {
165+
let digest_path = rt_prefix.with_extension("json");
166+
167+
tracing::info!("generating {digest_path:?}");
168+
169+
let digest = InspectCmd::new(compressed_rt, false, false, false).inspect(wasmer)?;
170+
171+
fs::write(&digest_path, digest)?;
170172
}
171173
if !cache_output {
172-
tracing::info!(
173-
"cleaning up the output target directory {}",
174-
output_target_dir.display()
175-
);
174+
tracing::info!("cleaning up the output target directory {output_target_dir:?}",);
176175

177176
fs::remove_dir_all(&output_target_dir)?;
178177
}

cli/src/cli/inspect.rs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ pub struct InspectCmd {
1313
#[arg(value_name = "PATH", verbatim_doc_comment)]
1414
path: PathBuf,
1515
/// Whether to check the runtime version in the `ParachainSystem::authorized_upgrade` call.
16-
#[arg(long, default_value_t = true, verbatim_doc_comment)]
17-
check_version: bool,
16+
#[arg(long, verbatim_doc_comment)]
17+
no_check_version: bool,
18+
/// Whether to beautify the JSON output.
19+
#[arg(long, short, verbatim_doc_comment)]
20+
beautify: bool,
1821
/// Whether to print verbose output.
19-
#[arg(short, long, verbatim_doc_comment)]
22+
#[arg(long, short, verbatim_doc_comment)]
2023
verbose: bool,
2124
}
22-
impl Run for InspectCmd {
23-
fn run(self) -> Result<()> {
24-
let Self { path, check_version, verbose } = self;
25-
let wasmer = Wasmer::load(&path)?;
25+
impl InspectCmd {
26+
pub fn new(path: PathBuf, no_check_version: bool, beautify: bool, verbose: bool) -> Self {
27+
Self { path, no_check_version, beautify, verbose }
28+
}
29+
30+
pub fn inspect(self, wasmer: Wasmer) -> Result<String> {
31+
let Self { path, no_check_version, beautify, verbose } = self;
2632
let built_at = fs::metadata(&path)?.created()?;
2733
let compressed = wasmer.compressed()?.len();
2834
let uncompressed = wasmer.decompressed()?.len();
@@ -35,8 +41,22 @@ impl Run for InspectCmd {
3541
let runtime = wasmer.runtime_version(verbose)?;
3642
let metadata = wasmer.metadata()?.version();
3743
let version = Ver { runtime, metadata };
44+
let check_version = !no_check_version;
3845
let call_hash = CallHash::of(&wasmer, check_version);
39-
let json = serde_json::to_string(&Output { built_at, size, hash, version, call_hash })?;
46+
let output = Output { built_at, size, hash, version, call_hash };
47+
let json = if beautify {
48+
serde_json::to_string_pretty(&output)?
49+
} else {
50+
serde_json::to_string(&output)?
51+
};
52+
53+
Ok(json)
54+
}
55+
}
56+
impl Run for InspectCmd {
57+
fn run(self) -> Result<()> {
58+
let wasmer = Wasmer::load(&self.path)?;
59+
let json = self.inspect(wasmer)?;
4060

4161
println!("{json}");
4262

cli/src/util.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
// std
2-
use std::time::SystemTime;
2+
use std::{fs, path::Path, time::SystemTime};
33
// crates.io
44
use chrono::{DateTime, SecondsFormat, Utc};
55
use serde::Serializer;
6+
// self
7+
use crate::prelude::*;
8+
9+
pub fn copy(from: &Path, to: &Path) -> Result<()> {
10+
tracing::info!("copying {from:?} to {to:?}");
11+
12+
fs::copy(from, to)?;
13+
14+
Ok(())
15+
}
616

717
pub fn ser_system_time<S>(time: &SystemTime, serializer: S) -> Result<S::Ok, S::Error>
818
where

0 commit comments

Comments
 (0)