feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
[package]
|
||||
name = "frame-omni-bencher"
|
||||
version = "0.1.0"
|
||||
description = "Freestanding benchmark runner for any Pezkuwi runtime."
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
repository.workspace = true
|
||||
license.workspace = true
|
||||
readme = "README.md"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
clap = { features = ["derive"], workspace = true }
|
||||
pezcumulus-primitives-proof-size-hostfunction = { workspace = true, default-features = true }
|
||||
pezframe-benchmarking-cli = { workspace = true }
|
||||
pezsc-cli = { workspace = true, default-features = true }
|
||||
pezsp-runtime = { workspace = true, default-features = true }
|
||||
pezsp-statement-store = { workspace = true, default-features = true }
|
||||
tracing-subscriber = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = { workspace = true }
|
||||
pezcumulus-test-runtime = { workspace = true }
|
||||
pezsc-chain-spec = { workspace = true }
|
||||
pezsp-genesis-builder = { workspace = true, default-features = true }
|
||||
tempfile = { workspace = true }
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = [
|
||||
"pezcumulus-primitives-proof-size-hostfunction/runtime-benchmarks",
|
||||
"pezcumulus-test-runtime/runtime-benchmarks",
|
||||
"pezframe-benchmarking-cli/runtime-benchmarks",
|
||||
"pezsc-chain-spec/runtime-benchmarks",
|
||||
"pezsc-cli/runtime-benchmarks",
|
||||
"pezsp-genesis-builder/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
"pezsp-statement-store/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,77 @@
|
||||
# PezkuwiChain Omni Benchmarking CLI
|
||||
|
||||
The PezkuwiChain Omni benchmarker allows to benchmark the extrinsics of any PezkuwiChain runtime. It is
|
||||
meant to replace the current manual integration of the `benchmark pallet` into every teyrchain node.
|
||||
This reduces duplicate code and makes maintenance for builders easier. The CLI is currently only
|
||||
able to benchmark extrinsics. In the future it is planned to extend this to some other areas.
|
||||
|
||||
General FRAME runtimes could also be used with this benchmarker, as long as they don't utilize any
|
||||
host functions that are not part of the PezkuwiChain host specification.
|
||||
|
||||
## Installation
|
||||
|
||||
Directly via crates.io:
|
||||
|
||||
```sh
|
||||
cargo install frame-omni-bencher --profile=production --locked
|
||||
```
|
||||
|
||||
from GitHub:
|
||||
|
||||
```sh
|
||||
cargo install --git https://github.com/pezkuwichain/pezkuwi-sdk frame-omni-bencher --profile=production --locked
|
||||
```
|
||||
|
||||
or locally from the sources:
|
||||
|
||||
```sh
|
||||
cargo install --path bizinikiwi/utils/pezframe/omni-bencher --profile=production
|
||||
```
|
||||
|
||||
Check the installed version and print the docs:
|
||||
|
||||
```sh
|
||||
frame-omni-bencher --help
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
First we need to ensure that there is a runtime available. As example we will build the zagros
|
||||
runtime:
|
||||
|
||||
```sh
|
||||
cargo build -p zagros-runtime --profile production --features runtime-benchmarks
|
||||
```
|
||||
|
||||
Now as an example, we benchmark the `balances` pallet:
|
||||
|
||||
```sh
|
||||
frame-omni-bencher v1 benchmark pallet \
|
||||
--runtime target/release/wbuild/zagros-runtime/zagros-runtime.compact.compressed.wasm \
|
||||
--pallet "pallet_balances" --extrinsic ""
|
||||
```
|
||||
|
||||
The `--steps`, `--repeat`, `--heap-pages` and `--wasm-execution` arguments have sane defaults and do
|
||||
not need be passed explicitly anymore.
|
||||
|
||||
### Generate weights (templates)
|
||||
|
||||
To render Rust weight files from benchmark results, pass an output path. Optionally you can pass a
|
||||
custom header and a Handlebars template (defaults are provided):
|
||||
|
||||
```sh
|
||||
frame-omni-bencher v1 benchmark pallet \
|
||||
--runtime target/release/wbuild/zagros-runtime/zagros-runtime.compact.compressed.wasm \
|
||||
--pallet "pallet_balances" --extrinsic "*" \
|
||||
--output ./weights/ \
|
||||
--header ./HEADER.rs \
|
||||
--template ./template.hbs
|
||||
```
|
||||
|
||||
This uses the same flags as the node-integrated benchmarking CLI. The output can be a directory or a
|
||||
file path; when a directory is given, a file name is generated per pallet/instance.
|
||||
|
||||
## Backwards Compatibility
|
||||
|
||||
The exposed pallet sub-command is identical as the node-integrated CLI. The only difference is that
|
||||
it needs to be prefixed with a `v1` to ensure drop-in compatibility.
|
||||
@@ -0,0 +1,148 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use clap::Parser;
|
||||
use pezframe_benchmarking_cli::{BenchmarkCmd, OpaqueBlock};
|
||||
use pezsc_cli::Result;
|
||||
use pezsp_runtime::traits::BlakeTwo256;
|
||||
|
||||
/// # Pezkuwi Omni Benchmarking CLI
|
||||
///
|
||||
/// The Pezkuwi Omni benchmarker allows to benchmark the extrinsics of any Pezkuwi runtime. It is
|
||||
/// meant to replace the current manual integration of the `benchmark pallet` into every teyrchain
|
||||
/// node. This reduces duplicate code and makes maintenance for builders easier. The CLI is
|
||||
/// currently only able to benchmark extrinsics. In the future it is planned to extend this to some
|
||||
/// other areas.
|
||||
///
|
||||
/// General FRAME runtimes could also be used with this benchmarker, as long as they don't utilize
|
||||
/// any host functions that are not part of the Pezkuwi host specification.
|
||||
///
|
||||
/// ## Installation
|
||||
///
|
||||
/// Directly via crates.io:
|
||||
///
|
||||
/// ```sh
|
||||
/// cargo install frame-omni-bencher --profile=production
|
||||
/// ```
|
||||
///
|
||||
/// from GitHub:
|
||||
///
|
||||
/// ```sh
|
||||
/// cargo install --git https://github.com/pezkuwichain/pezkuwi-sdk frame-omni-bencher --profile=production
|
||||
/// ```
|
||||
///
|
||||
/// or locally from the sources:
|
||||
///
|
||||
/// ```sh
|
||||
/// cargo install --path bizinikiwi/utils/pezframe/omni-bencher --profile=production
|
||||
/// ```
|
||||
///
|
||||
/// Check the installed version and print the docs:
|
||||
///
|
||||
/// ```sh
|
||||
/// frame-omni-bencher --help
|
||||
/// ```
|
||||
///
|
||||
/// ## Usage
|
||||
///
|
||||
/// First we need to ensure that there is a runtime available. As example we will build the Zagros
|
||||
/// runtime:
|
||||
///
|
||||
/// ```sh
|
||||
/// cargo build -p zagros-runtime --profile production --features runtime-benchmarks
|
||||
/// ```
|
||||
///
|
||||
/// Now as an example, we benchmark the `balances` pallet:
|
||||
///
|
||||
/// ```sh
|
||||
/// frame-omni-bencher v1 benchmark pallet \
|
||||
/// --runtime target/release/wbuild/zagros-runtime/zagros-runtime.compact.compressed.wasm \
|
||||
/// --pallet "pezpallet_balances" --extrinsic ""
|
||||
/// ```
|
||||
///
|
||||
/// For the exact arguments of the `pallet` command, please refer to the `pallet` sub-module.
|
||||
///
|
||||
/// ## Backwards Compatibility
|
||||
///
|
||||
/// The exposed pallet sub-command is identical as the node-integrated CLI. The only difference is
|
||||
/// that it needs to be prefixed with a `v1` to ensure drop-in compatibility.
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about, verbatim_doc_comment)]
|
||||
pub struct Command {
|
||||
#[command(subcommand)]
|
||||
sub: SubCommand,
|
||||
}
|
||||
|
||||
/// Root-level subcommands.
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
pub enum SubCommand {
|
||||
/// Compatibility syntax with the old benchmark runner.
|
||||
V1(V1Command),
|
||||
// NOTE: Here we can add new commands in a forward-compatible way. For example when
|
||||
// transforming the CLI from a monolithic design to a data driven pipeline, there could be
|
||||
// commands like `measure`, `analyze` and `render`.
|
||||
}
|
||||
|
||||
/// A command that conforms to the legacy `benchmark` argument syntax.
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct V1Command {
|
||||
#[command(subcommand)]
|
||||
sub: V1SubCommand,
|
||||
}
|
||||
|
||||
/// The `v1 benchmark` subcommand.
|
||||
#[derive(Debug, clap::Subcommand)]
|
||||
pub enum V1SubCommand {
|
||||
Benchmark(V1BenchmarkCommand),
|
||||
}
|
||||
|
||||
/// Subcommands for `v1 benchmark`.
|
||||
#[derive(Parser, Debug)]
|
||||
pub struct V1BenchmarkCommand {
|
||||
#[command(subcommand)]
|
||||
sub: BenchmarkCmd,
|
||||
}
|
||||
|
||||
type HostFunctions = (
|
||||
pezsp_statement_store::runtime_api::HostFunctions,
|
||||
cumulus_primitives_proof_size_hostfunction::storage_proof_size::HostFunctions,
|
||||
);
|
||||
|
||||
impl Command {
|
||||
pub fn run(self) -> Result<()> {
|
||||
match self.sub {
|
||||
SubCommand::V1(V1Command { sub }) => sub.run(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl V1SubCommand {
|
||||
pub fn run(self) -> Result<()> {
|
||||
match self {
|
||||
V1SubCommand::Benchmark(V1BenchmarkCommand { sub }) => match sub {
|
||||
BenchmarkCmd::Pallet(pallet) => {
|
||||
pallet.run_with_spec::<BlakeTwo256, HostFunctions>(None)
|
||||
},
|
||||
BenchmarkCmd::Overhead(overhead_cmd) =>
|
||||
overhead_cmd.run_with_default_builder_and_spec::<OpaqueBlock, HostFunctions>(None),
|
||||
_ =>
|
||||
return Err(
|
||||
"Only the `v1 benchmark pallet` and `v1 benchmark overhead` command is currently supported".into()
|
||||
),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
mod command;
|
||||
|
||||
use clap::Parser;
|
||||
use pezsc_cli::Result;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
setup_logger();
|
||||
|
||||
command::Command::parse().run()
|
||||
}
|
||||
|
||||
/// Setup logging with `info` as default level. Can be set via `RUST_LOG` env.
|
||||
fn setup_logger() {
|
||||
// Disable these log targets because they are spammy.
|
||||
let unwanted_targets =
|
||||
&["cranelift_codegen", "wasm_cranelift", "wasmtime_jit", "wasmtime_cranelift", "wasm_jit"];
|
||||
|
||||
let mut env_filter =
|
||||
EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
|
||||
|
||||
for target in unwanted_targets {
|
||||
env_filter = env_filter.add_directive(format!("{}=off", target).parse().unwrap());
|
||||
}
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(env_filter)
|
||||
.with_writer(std::io::stderr)
|
||||
.init();
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use assert_cmd::cargo::cargo_bin;
|
||||
use std::{
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
process::{Command, ExitStatus},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn benchmark_overhead_runtime_works() -> std::result::Result<(), String> {
|
||||
let tmp_dir = tempfile::tempdir().expect("Should be able to create tmp dir.");
|
||||
let base_path = tmp_dir.path();
|
||||
let wasm = cumulus_test_runtime::WASM_BINARY.ok_or("WASM binary not available".to_string())?;
|
||||
let runtime_path = base_path.join("runtime.wasm");
|
||||
let _ =
|
||||
fs::write(&runtime_path, wasm).map_err(|e| format!("Unable to write runtime file: {}", e));
|
||||
|
||||
// Invoke `benchmark overhead` with all options to make sure that they are valid.
|
||||
let status = std::process::Command::new(cargo_bin("frame-omni-bencher"))
|
||||
.args(["v1", "benchmark", "overhead", "--runtime", runtime_path.to_str().unwrap()])
|
||||
.arg("-d")
|
||||
.arg(base_path)
|
||||
.arg("--weight-path")
|
||||
.arg(base_path)
|
||||
.args(["--warmup", "5", "--repeat", "5"])
|
||||
// Exotic para id to see that we are actually patching.
|
||||
.args(["--para-id", "666"])
|
||||
.args(["--add", "100", "--mul", "1.2", "--metric", "p75"])
|
||||
// Only put 5 extrinsics into the block otherwise it takes forever to build it
|
||||
// especially for a non-release builds.
|
||||
.args(["--max-ext-per-block", "5"])
|
||||
.status()
|
||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||
|
||||
assert_benchmark_success(status, base_path)
|
||||
}
|
||||
#[test]
|
||||
fn benchmark_overhead_chain_spec_works() -> std::result::Result<(), String> {
|
||||
let tmp_dir = tempfile::tempdir().expect("Should be able to create tmp dir.");
|
||||
let (base_path, chain_spec_path) = setup_chain_spec(tmp_dir.path(), false)?;
|
||||
|
||||
let status = create_benchmark_spec_command(&base_path, &chain_spec_path)
|
||||
.args(["--genesis-builder-policy", "spec-runtime"])
|
||||
.args(["--para-id", "666"])
|
||||
.status()
|
||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||
|
||||
assert_benchmark_success(status, &base_path)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn benchmark_overhead_chain_spec_works_plain_spec() -> std::result::Result<(), String> {
|
||||
let tmp_dir = tempfile::tempdir().expect("Should be able to create tmp dir.");
|
||||
let (base_path, chain_spec_path) = setup_chain_spec(tmp_dir.path(), false)?;
|
||||
|
||||
let status = create_benchmark_spec_command(&base_path, &chain_spec_path)
|
||||
.args(["--genesis-builder-policy", "spec"])
|
||||
.args(["--para-id", "100"])
|
||||
.status()
|
||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||
|
||||
assert_benchmark_success(status, &base_path)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn benchmark_overhead_chain_spec_works_raw() -> std::result::Result<(), String> {
|
||||
let tmp_dir = tempfile::tempdir().expect("Should be able to create tmp dir.");
|
||||
let (base_path, chain_spec_path) = setup_chain_spec(tmp_dir.path(), true)?;
|
||||
|
||||
let status = create_benchmark_spec_command(&base_path, &chain_spec_path)
|
||||
.args(["--genesis-builder-policy", "spec"])
|
||||
.args(["--para-id", "100"])
|
||||
.status()
|
||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||
|
||||
assert_benchmark_success(status, &base_path)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn benchmark_overhead_chain_spec_fails_wrong_para_id() -> std::result::Result<(), String> {
|
||||
let tmp_dir = tempfile::tempdir().expect("Should be able to create tmp dir.");
|
||||
let (base_path, chain_spec_path) = setup_chain_spec(tmp_dir.path(), false)?;
|
||||
|
||||
let status = create_benchmark_spec_command(&base_path, &chain_spec_path)
|
||||
.args(["--genesis-builder-policy", "spec"])
|
||||
.args(["--para-id", "666"])
|
||||
.status()
|
||||
.map_err(|e| format!("command failed: {:?}", e))?;
|
||||
|
||||
if status.success() {
|
||||
return Err("Command should have failed!".into());
|
||||
}
|
||||
|
||||
// Weight files should not have been created
|
||||
assert!(!base_path.join("block_weights.rs").exists());
|
||||
assert!(!base_path.join("extrinsic_weights.rs").exists());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets up a temporary directory and creates a chain spec file
|
||||
fn setup_chain_spec(tmp_dir: &Path, raw: bool) -> Result<(PathBuf, PathBuf), String> {
|
||||
let base_path = tmp_dir.to_path_buf();
|
||||
let chain_spec_path = base_path.join("chain_spec.json");
|
||||
|
||||
let wasm = cumulus_test_runtime::WASM_BINARY.ok_or("WASM binary not available".to_string())?;
|
||||
|
||||
let mut properties = pezsc_chain_spec::Properties::new();
|
||||
properties.insert("tokenSymbol".into(), "UNIT".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
|
||||
let chain_spec = pezsc_chain_spec::GenericChainSpec::<()>::builder(wasm, Default::default())
|
||||
.with_name("some-chain")
|
||||
.with_id("some-id")
|
||||
.with_properties(properties)
|
||||
.with_chain_type(pezsc_chain_spec::ChainType::Development)
|
||||
.with_genesis_config_preset_name(pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
|
||||
.build();
|
||||
|
||||
let json = chain_spec.as_json(raw).unwrap();
|
||||
fs::write(&chain_spec_path, json)
|
||||
.map_err(|e| format!("Unable to write chain-spec file: {}", e))?;
|
||||
|
||||
Ok((base_path, chain_spec_path))
|
||||
}
|
||||
|
||||
/// Creates a Command for the benchmark with common arguments
|
||||
fn create_benchmark_spec_command(base_path: &Path, chain_spec_path: &Path) -> Command {
|
||||
let mut cmd = Command::new(cargo_bin("frame-omni-bencher"));
|
||||
cmd.args(["v1", "benchmark", "overhead", "--chain", chain_spec_path.to_str().unwrap()])
|
||||
.arg("-d")
|
||||
.arg(base_path)
|
||||
.arg("--weight-path")
|
||||
.arg(base_path)
|
||||
.args(["--warmup", "5", "--repeat", "5"])
|
||||
.args(["--add", "100", "--mul", "1.2", "--metric", "p75"])
|
||||
// Only put 5 extrinsics into the block otherwise it takes forever to build it
|
||||
.args(["--max-ext-per-block", "5"]);
|
||||
cmd
|
||||
}
|
||||
|
||||
/// Checks if the benchmark completed successfully and created weight files
|
||||
fn assert_benchmark_success(status: ExitStatus, base_path: &Path) -> Result<(), String> {
|
||||
if !status.success() {
|
||||
return Err("Command failed".into());
|
||||
}
|
||||
|
||||
// Weight files have been created
|
||||
assert!(base_path.join("block_weights.rs").exists());
|
||||
assert!(base_path.join("extrinsic_weights.rs").exists());
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user