Skip to content

Instantly share code, notes, and snippets.

@Skydev0h
Last active August 12, 2026 11:17
Show Gist options
  • Select an option

  • Save Skydev0h/4143db37bc4e4857397024f6564089d9 to your computer and use it in GitHub Desktop.

Select an option

Save Skydev0h/4143db37bc4e4857397024f6564089d9 to your computer and use it in GitHub Desktop.
Quantus | W01 supplementary package
diff --git a/node/Cargo.toml b/node/Cargo.toml
index f9b4c2c3..d65a1eff 100644
--- a/node/Cargo.toml
+++ b/node/Cargo.toml
@@ -17,6 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
clap = { features = ["derive"], workspace = true }
codec.workspace = true
+frame-benchmarking = { workspace = true, default-features = false }
frame-benchmarking-cli = { workspace = true, default-features = true, optional = true }
frame-metadata-hash-extension.default-features = true
frame-metadata-hash-extension.workspace = true
diff --git a/node/src/service.rs b/node/src/service.rs
index 61e8ae44..ad732732 100644
--- a/node/src/service.rs
+++ b/node/src/service.rs
@@ -556,7 +556,10 @@ fn spawn_authority_tasks(
pub(crate) type FullClient = sc_service::TFullClient<
Block,
RuntimeApi,
- sc_executor::WasmExecutor<sp_io::SubstrateHostFunctions>,
+ sc_executor::WasmExecutor<(
+ sp_io::SubstrateHostFunctions,
+ frame_benchmarking::benchmarking::HostFunctions,
+ )>,
>;
type FullBackend = sc_service::TFullBackend<Block>;
pub type PowBlockImport = sc_consensus_qpow::PowBlockImport<
@@ -596,7 +599,10 @@ pub fn new_partial(config: &Configuration) -> Result<Service, ServiceError> {
})
.transpose()?;
- let executor = sc_service::new_wasm_executor::<sp_io::SubstrateHostFunctions>(&config.executor);
+ let executor = sc_service::new_wasm_executor::<(
+ sp_io::SubstrateHostFunctions,
+ frame_benchmarking::benchmarking::HostFunctions,
+ )>(&config.executor);
let (client, backend, keystore_container, task_manager) =
sc_service::new_full_parts::<Block, RuntimeApi, _>(
config,
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0
//! DATE: 2026-08-12 (Y/M/D)
//! HOSTNAME: `soliton`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//!
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Quantus DevNet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `/tmp/bench/out`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/release/quantus-node
// benchmark
// overhead
// --chain=dev
// --base-path
// /tmp/bench/ov
// --weight-path
// /tmp/bench/out
// --warmup=10
// --repeat=100
// --wasm-execution=compiled
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing an empty block.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 1_061_726, 1_608_179
/// Average: 1_084_993
/// Median: 1_075_596
/// Std-Dev: 68315.71
///
/// Percentiles nanoseconds:
/// 99th: 1_506_748
/// 95th: 1_090_976
/// 75th: 1_081_526
pub const BlockExecutionWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(1_084_993), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::BlockExecutionWeight::get();
// At least 100 µs.
assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 50 ms."
);
}
}
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0
//! DATE: 2026-08-12 (Y/M/D)
//! HOSTNAME: `SkyFlare`, CPU: `Intel(R) Core(TM) i9-14900K`
//!
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Quantus DevNet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `/tmp/qbench-out`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/release/quantus-node
// benchmark
// overhead
// --chain=dev
// --base-path
// /tmp/qbench
// --weight-path
// /tmp/qbench-out
// --warmup=10
// --repeat=100
// --wasm-execution=compiled
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing an empty block.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 707_959, 2_096_204
/// Average: 839_258
/// Median: 761_905
/// Std-Dev: 208335.88
///
/// Percentiles nanoseconds:
/// 99th: 1_693_415
/// 95th: 1_215_135
/// 75th: 864_161
pub const BlockExecutionWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(839_258), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::BlockExecutionWeight::get();
// At least 100 µs.
assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 50 ms."
);
}
}
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0
//! DATE: 2026-08-12 (Y/M/D)
//! HOSTNAME: `xxlab`, CPU: `Intel(R) Xeon(R) CPU E5-2687W v4 @ 3.00GHz`
//!
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Quantus DevNet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `/tmp/qbench-out`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/release/quantus-node
// benchmark
// overhead
// --chain=dev
// --base-path
// /tmp/qbench
// --weight-path
// /tmp/qbench-out
// --warmup=10
// --repeat=100
// --wasm-execution=compiled
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing an empty block.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 1_738_477, 1_764_450
/// Average: 1_750_509
/// Median: 1_749_250
/// Std-Dev: 5832.7
///
/// Percentiles nanoseconds:
/// 99th: 1_763_793
/// 95th: 1_759_884
/// 75th: 1_755_620
pub const BlockExecutionWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(1_750_509), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::BlockExecutionWeight::get();
// At least 100 µs.
assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 50 ms."
);
}
}
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0
//! DATE: 2026-08-12 (Y/M/D)
//! HOSTNAME: `soliton`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//!
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Quantus DevNet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `/tmp/bench/out`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/release/quantus-node
// benchmark
// overhead
// --chain=dev
// --base-path
// /tmp/bench/ov
// --weight-path
// /tmp/bench/out
// --warmup=10
// --repeat=100
// --wasm-execution=compiled
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing a NO-OP extrinsic, for example `System::remark`.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 1_246_975, 2_360_579
/// Average: 1_288_206
/// Median: 1_256_626
/// Std-Dev: 156497.43
///
/// Percentiles nanoseconds:
/// 99th: 2_166_001
/// 95th: 1_293_275
/// 75th: 1_266_272
pub const ExtrinsicBaseWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(1_288_206), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::ExtrinsicBaseWeight::get();
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
}
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0
//! DATE: 2026-08-12 (Y/M/D)
//! HOSTNAME: `SkyFlare`, CPU: `Intel(R) Core(TM) i9-14900K`
//!
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Quantus DevNet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `/tmp/qbench-out`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/release/quantus-node
// benchmark
// overhead
// --chain=dev
// --base-path
// /tmp/qbench
// --weight-path
// /tmp/qbench-out
// --warmup=10
// --repeat=100
// --wasm-execution=compiled
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing a NO-OP extrinsic, for example `System::remark`.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 845_313, 921_813
/// Average: 871_694
/// Median: 870_110
/// Std-Dev: 13961.59
///
/// Percentiles nanoseconds:
/// 99th: 914_153
/// 95th: 896_061
/// 75th: 878_017
pub const ExtrinsicBaseWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(871_694), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::ExtrinsicBaseWeight::get();
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
}
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0
//! DATE: 2026-08-12 (Y/M/D)
//! HOSTNAME: `soliton`, CPU: `AMD Ryzen 7 5800X 8-Core Processor`
//!
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Quantus DevNet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `/tmp/bench/outp`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/production/quantus-node
// benchmark
// overhead
// --chain=dev
// --base-path
// /tmp/bench/ovp5
// --weight-path
// /tmp/bench/outp
// --warmup=10
// --repeat=100
// --wasm-execution=compiled
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing a NO-OP extrinsic, for example `System::remark`.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 1_197_217, 1_232_395
/// Average: 1_205_508
/// Median: 1_202_581
/// Std-Dev: 7770.36
///
/// Percentiles nanoseconds:
/// 99th: 1_228_036
/// 95th: 1_222_328
/// 75th: 1_207_899
pub const ExtrinsicBaseWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(1_205_508), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::ExtrinsicBaseWeight::get();
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
}
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 53.0.0
//! DATE: 2026-08-12 (Y/M/D)
//! HOSTNAME: `xxlab`, CPU: `Intel(R) Xeon(R) CPU E5-2687W v4 @ 3.00GHz`
//!
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Quantus DevNet`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `/tmp/qbench-out`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/release/quantus-node
// benchmark
// overhead
// --chain=dev
// --base-path
// /tmp/qbench
// --weight-path
// /tmp/qbench-out
// --warmup=10
// --repeat=100
// --wasm-execution=compiled
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Weight of executing a NO-OP extrinsic, for example `System::remark`.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 1_825_861, 2_368_518
/// Average: 1_865_545
/// Median: 1_851_598
/// Std-Dev: 66830.23
///
/// Percentiles nanoseconds:
/// 99th: 2_178_914
/// 95th: 1_927_760
/// 75th: 1_860_926
pub const ExtrinsicBaseWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(1_865_545), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::ExtrinsicBaseWeight::get();
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
}
#!/usr/bin/env bash
# The build-and-measure half of the Steps section, for convenience: it sets
# LIBCLANG_PATH, applies the executor patch, builds, and runs the benchmark.
#
# Assumes you have already done, from the Steps block:
# git clone https://github.com/immunefi-team/audit-comp-quantus-chain
# cd audit-comp-quantus-chain
# git checkout 3b243b870a5442a6e5f443056f67bbba87d472f5
# git clone <the URL of this gist> w01
#
# Then, from the root of that checkout: bash w01/run.sh
#
# The patch is resolved relative to this script, so it is found wherever the
# gist was cloned to.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# On Ubuntu clang-sys cannot find libclang on its own: `libclang-dev` is a meta
# package and the library lands in a versioned directory that is not on the
# default search path. The project's own CI runs the same probe, see
# .github/actions/ubuntu/action.yml:24-47.
for v in 18 17 16 15 14; do
d=/usr/lib/llvm-$v/lib
[ -d "$d" ] && ls "$d"/libclang*.so* >/dev/null 2>&1 && { export LIBCLANG_PATH=$d; break; }
done
echo "LIBCLANG_PATH=${LIBCLANG_PATH:-<unset, build may fail>}"
# The benchmarking tooling does not run as shipped: the runtime built with
# `runtime-benchmarks` imports nine ext_benchmarking_* host functions that
# node/src/service.rs never registers. This patch touches ONLY the node's
# executor and its dependency list. The runtime is not modified.
PATCH="$HERE/enable-benchmarks.patch"
if git apply --check "$PATCH" 2>/dev/null; then
git apply "$PATCH"
echo "executor patch applied"
elif git apply --reverse --check "$PATCH" 2>/dev/null; then
echo "executor patch already applied, skipping"
else
echo "ERROR: $PATCH does not apply cleanly and is not already applied." >&2
echo " Are you at 3b243b870a5442a6e5f443056f67bbba87d472f5 ?" >&2
exit 1
fi
cargo build --release --features runtime-benchmarks -p quantus-node
# --weight-path must be an existing directory
mkdir -p /tmp/qbench-out
./target/release/quantus-node benchmark overhead \
--chain=dev \
--base-path /tmp/qbench \
--weight-path /tmp/qbench-out \
--warmup=10 --repeat=100 \
--wasm-execution=compiled
# /tmp/qbench-out/extrinsic_weights.rs and block_weights.rs now hold the
# measured values for this runtime. Compare them against the checked-in
# frame/support/src/weights/{extrinsic,block}_weights.rs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment