Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
AurevoirXavier committed Dec 22, 2024
1 parent d577787 commit c5f22b5
Show file tree
Hide file tree
Showing 21 changed files with 468 additions and 367 deletions.
186 changes: 94 additions & 92 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ version = "0.1.0"
[workspace.dependencies]
# crates.io
anyhow = { version = "1.0" }
array-bytes = { version = "7.1" }
array-bytes = { version = "8.0" }
blake2 = { version = "0.10" }
chrono = { version = "0.4" }
clap = { version = "4.5" }
Expand All @@ -40,7 +40,7 @@ tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3" }
vergen-gitcl = { version = "1.0" }
# self
polkadot-runtime-releaser-lib = { version = "0.1", path = "lib" }
prr-lib = { version = "0.1", package = "polkadot-runtime-releaser-lib", path = "lib" }

[profile.ci-dev]
incremental = false
Expand Down
78 changes: 63 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,84 @@
[![GitHub last commit](https://img.shields.io/github/last-commit/hack-ink/polkadot-runtime-releaser?color=red&style=plastic)](https://github.com/hack-ink/polkadot-runtime-releaser)
</div>

## Quick Guide
### CLI Tool
Check [cli/README.md](cli/README.md) for more details.

#### Installation
## Setup Guide
### Polkadot Runtime Releaser CLI
#### Install from Source Code
```sh
# From source code.
git clone https://github.com/hack-ink/polkadot-runtime-releaser
cd polkadot-runtime-releaser
cargo install --path cli
# From crates.io.
```

#### Install from [crates.io](https://crates.io)
```sh
cargo install polkadot-runtime-releaser-cli
# From GitHub release.
```

#### Install from GitHub
```sh
curl -L ..
```

#### Build Deterministic Runtime
### Rust Toolchain
Having a fixed version of Rust toolchain is one of the crucial parts of building a deterministic runtime.

Create a `rust-toolchain.toml` file in the root of your project and add the following content:

```toml
[toolchain]
# Using Rust `stable` as an example, you can replace it with your desired version.
channel = "stable"
# `clippy`, `rust-src` and `rustfmt` are optional, you can remove them if you don't need them.
components = ["cargo", "clippy", "rust-src", "rustc", "rustfmt"]
# `minimal` is the basic and minimal one to build the runtime, you can choose the profile that you need.
# https://rust-lang.github.io/rustup/concepts/profiles.html.
profile = "minimal"
targets = ["wasm32-unknown-unknown"]
```

With this file in place, PPR will automatically use the specified version of Rust toolchain.

This is the best way to manage the Rust toolchain version for your project.

If you don't have a `rust-toolchain.toml` file, PPR will automatically generate one with the `stable` version for you.

PPR also supports configuring the Rust toolchain version while there isn't a `rust-toolchain.toml` file in the root of your project. Use `ppr build --help` to get more information.

### Docker
The second crucial part of building a deterministic runtime is to use the same environment for building the runtime.

We use Docker to create a deterministic environment for building the runtime.

So, to use the runtime build feature, you need to have Docker installed on your system.

The default image is [polkadot-runtime-releaser](https://github.com/hack-ink/polkadot-runtime-releaser/pkgs/container/polkadot-runtime-releaser), which is maintained by hack-ink community. It has a well-configured environment for building the runtime. Each release is sticked to a specific version of the image for creating a deterministic environment. But you can use `-v` or `--image-version` flag to use a specific version of the image.

PPR also supports using a custom Docker image. Use `ppr build --help` to get more information.

### Runtime
#### IMPORTANT NOTES
- PRR makes some assumption while deal with the runtime artifacts.
- Runtime crate name is in `{}-runtime` format. E.G. [`polkadot-runtime`](https://github.com/polkadot-fellows/runtimes/blob/46dcafcee64fe4d8c722d071a4a0ca983fcc2f08/relay/polkadot/Cargo.toml#L2)
- 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)

### GitHub


## Usage
### Build Deterministic Runtime
#### Example
```sh
prr build <RUNTIME_CRATE_NAME>
git clone https://github.com/polkadot-fellows/runtimes.git
cd runtimes
prr build polkadot-runtime -f on-chain-release-build
```

#### Inspect Runtime WASM
### Inspect Runtime WASM
```sh
prr inspect <RUNTIME_WASM_FILE>
```

### GitHub Actions
#### Release
TODO

<div align="right">

#### License
Expand Down
28 changes: 28 additions & 0 deletions action/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Polkadot Runtime Releaser Build Action"
description: "Polkadot Runtime Releaser Build Action."
branding:
icon: "check-circle"
color: "blue"

inputs:
runtime:
description: "Target runtime crate to build."
required: true
features:
description: "Features to enable for the runtime crate."
required: false
default: ""
toolchain-version:
description: "Rust toolchain version to use."
required: false
default: "stable"

runs:
using: "composite"
steps:
- name: Setup Polkadot Runtime Releaser
shell: bash
run: curl -L https://github.com/hack-ink/polkadot-runtime-releaser/releases/download/v0.1.0/polkadot-runtime-releaser.tar.gz | tar xz && chmod +x prr && mv prr /usr/local/bin/prr
- name: Build
shell: bash
run: prr build ${{ inputs.runtime }} -f ${{ inputs.features }} -t ${{ inputs.toolchain-version }}
30 changes: 30 additions & 0 deletions action/override/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "Polkadot Runtime Releaser Build Action"
description: "Polkadot Runtime Releaser Build Action."
branding:
icon: "check-circle"
color: "blue"

inputs:
runtime:
description: "Target runtime crate to build."
required: true
features:
description: "Features to enable for the runtime crate."
required: false
default: ""
toolchain-version:
description: "Rust toolchain version to use."
required: false
default: "stable"

runs:
using: "composite"
steps:
- name: Fetch latest code
uses: actions/checkout@v4
- name: Build runtime
uses: ../build/action.yml
with:
runtime: ${{ inputs.runtime }}
features: ${{ inputs.features }}
toolchain-version: ${{ inputs.toolchain-version }}
Empty file removed action/release.yml
Empty file.
53 changes: 53 additions & 0 deletions action/try-runtime/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "Polkadot Runtime Releaser Try Runtime Action"
description: "Polkadot Runtime Releaser Try Runtime Action."
branding:
icon: "check-circle"
color: "blue"

inputs:
runtime:
description: "Target runtime crate to build."
required: true
features:
description: "Features to enable for the runtime crate."
required: false
default: ""
toolchain-version:
description: "Rust toolchain version to use."
required: false
default: "stable"
try-runtime-version:
description: "Try Runtime CLI version to use."
required: false
default: "0.8.0"
uri:
description: "Node URI to use."
required: true

runs:
using: "composite"
steps:
- name: Setup try runtime CLI
shell: bash
run: curl -L https://github.com/paritytech/try-runtime-cli/releases/download/v${{ inputs.try-runtime-version }}/try-runtime-x86_64-unknown-linux-musl -o try-runtime && chmod +x try-runtime && mv try-runtime /usr/local/bin/try-runtime
- name: Build runtime
uses: ../build/action.yml
with:
runtime: ${{ inputs.runtime }}
features: ${{ inputs.features }}
toolchain-version: ${{ inputs.toolchain-version }}
- name: Try runtime
shell: bash
run: try-runtime --runtime $(find polkadot-runtime-releaser-output -name "*.compact.compressed.wasm") on-runtime-upgrade live -u ${{ inputs.uri }} 2>&1 | tee output.log
- name: Comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
<details>
<summary>Try Runtime Output for ${{ inputs.runtime }}</summary>
```
${{ cat output.log }}
```
</details>
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ serde_json = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
# self
polkadot-runtime-releaser-lib = { workspace = true }
prr-lib = { workspace = true }
38 changes: 0 additions & 38 deletions cli/README.md

This file was deleted.

18 changes: 12 additions & 6 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
mod build;
use build::BuildCommand;
use build::BuildCmd;

mod cmp;
use cmp::CmpCmd;

mod inspect;
use inspect::InspectCommand;
use inspect::InspectCmd;

// crates.io
use clap::{
Expand Down Expand Up @@ -41,18 +44,21 @@ pub struct Cli {
impl Run for Cli {
fn run(self) -> Result<()> {
match self.subcommand {
Subcommand::Build(build) => build.run(),
Subcommand::Inspect(inspect) => inspect.run(),
Subcommand::Build(cmd) => cmd.run(),
Subcommand::Cmp(cmd) => cmd.run(),
Subcommand::Inspect(cmd) => cmd.run(),
}
}
}

#[derive(Debug, Parser)]
enum Subcommand {
/// Build the polkadot-sdk-based runtime.
Build(BuildCommand),
Build(BuildCmd),
/// Compare the latest GitHub release's runtime version with the on-chain's.
Cmp(CmpCmd),
/// Inspect the WASM runtime.
Inspect(InspectCommand),
Inspect(InspectCmd),
}

fn styles() -> Styles {
Expand Down
Loading

0 comments on commit c5f22b5

Please sign in to comment.