Skip to content
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
1706959
use weights files
l0r1s Mar 19, 2026
dc29557
added script to compare and stub weights
l0r1s Mar 19, 2026
53be549
rework scripts
l0r1s Mar 19, 2026
166b60f
simplify workflow by extracting label check in a script
l0r1s Mar 19, 2026
083d0c2
update weight template
l0r1s Mar 19, 2026
25b693d
added doc
l0r1s Mar 19, 2026
7ce2379
remove noise from output when benchmarking
l0r1s Mar 19, 2026
ccbaec1
fix result display
l0r1s Mar 19, 2026
c619b8d
Merge branch 'devnet-ready' into rework-benchmarks
l0r1s Mar 19, 2026
48bb604
put old inlined weights into files
l0r1s Mar 19, 2026
33f0aa5
remove #[benchmark(extra)]
l0r1s Mar 19, 2026
770c01c
Merge branch 'devnet-ready' into rework-benchmarks
l0r1s Mar 19, 2026
b6ebe74
fixed types
l0r1s Mar 19, 2026
aaa2ea1
cargo clippy
l0r1s Mar 19, 2026
cebe936
cargo fmt
l0r1s Mar 19, 2026
3a8eea6
remove weight-stub, rate case of new pallet, update doc
l0r1s Mar 20, 2026
50cc4b9
fix registry benchmarks
l0r1s Mar 23, 2026
b4daa9d
fix pallet swap benchmarks
l0r1s Mar 23, 2026
30b2486
restore commitments benchmark tests suite
l0r1s Mar 23, 2026
f45570a
fix benchmark scripts
l0r1s Mar 23, 2026
e695c1a
fix compilation error
l0r1s Mar 23, 2026
140ddf1
fix clippy
l0r1s Mar 23, 2026
b1c81de
cargo fmt
l0r1s Mar 23, 2026
c695168
fix benchmark run
l0r1s Mar 23, 2026
fb36adf
fix scripts
l0r1s Mar 23, 2026
051db40
fix pallet swap benchmarks
l0r1s Mar 23, 2026
87ebed8
fix tests compilation
l0r1s Mar 23, 2026
637d9d1
zepter fix
l0r1s Mar 23, 2026
29dd012
auto-update benchmark weights
github-actions[bot] Mar 23, 2026
9c57c05
added pallet auto discovery
l0r1s Mar 30, 2026
fd10c5b
try ci with missing pallet
l0r1s Mar 30, 2026
f09af56
doc update
l0r1s Mar 30, 2026
4669ce8
Merge branch 'devnet-ready' into rework-benchmarks
l0r1s Mar 30, 2026
7529dae
clean benchmark scripts
l0r1s Mar 30, 2026
882a67d
fix subtensor benchmarks tests
l0r1s Mar 30, 2026
dabe5a0
use correct pallet_swap weights in runtime
l0r1s Mar 30, 2026
558215e
update doc
l0r1s Mar 30, 2026
3c3c8e8
Merge branch 'devnet-ready' into rework-benchmarks
l0r1s Mar 30, 2026
f5fa6e4
cargo fmt
l0r1s Mar 30, 2026
2f49da2
fix trap returning kill exit code instead of 0
l0r1s Mar 31, 2026
b241266
discove_pallets use bash instead of zsh
l0r1s Mar 31, 2026
8ffef64
fix mock eco-tests
l0r1s Mar 31, 2026
e2a3284
Merge branch 'devnet-ready' into rework-benchmarks
l0r1s Apr 3, 2026
e062158
fix compiation errors
l0r1s Apr 3, 2026
e626b43
use weight fn when possible
l0r1s Apr 3, 2026
6bc8883
added back utility pallet to benchmarks
l0r1s Apr 3, 2026
0f79a51
fix tests announce/reannounce delays
l0r1s Apr 3, 2026
ab57ca0
bump spec version
l0r1s Apr 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/e2e.yml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/scripts/check-skip-label.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# Check if the "skip-validate-benchmarks" label is present on a PR.
# Usage: check-skip-label.sh <PR_NUMBER>
# Exits 0 normally, or exits 0 after cancelling the workflow if label found.

set -euo pipefail

PR_NUMBER="${1:-}"
[[ -z "$PR_NUMBER" ]] && exit 0

REPO="${GITHUB_REPOSITORY:-}"
[[ -z "$REPO" ]] && exit 0

labels=$(gh pr view "$PR_NUMBER" --repo "$REPO" --json labels --jq '.labels[].name' 2>/dev/null || true)

if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — exiting."
exit 1
fi
120 changes: 14 additions & 106 deletions .github/workflows/run-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,157 +18,65 @@ jobs:
validate-benchmarks:
runs-on: Benchmarking

env:
SKIP_BENCHMARKS: "0"

steps:
- name: Check out PR branch
if: ${{ env.SKIP_BENCHMARKS != '1' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: Install GitHub CLI
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token

# (1) — first skip‑label check
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi

- name: Install system dependencies
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" build-essential clang curl libssl-dev llvm libudev-dev protobuf-compiler pkg-config

# (2)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi
sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends \
-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" \
build-essential clang curl libssl-dev llvm libudev-dev protobuf-compiler pkg-config

- name: Install Rust toolchain
if: ${{ env.SKIP_BENCHMARKS != '1' }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

# (3)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi

- name: Cache Rust build
if: ${{ env.SKIP_BENCHMARKS != '1' }}
uses: Swatinem/rust-cache@v2
with:
key: bench-${{ hashFiles('**/Cargo.lock') }}
cache-on-failure: true

# (4)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi

- name: Build node with benchmarks
if: ${{ env.SKIP_BENCHMARKS != '1' }}
- name: Build node with benchmarks + weight tools
run: |
.github/scripts/check-skip-label.sh ${{ github.event.pull_request.number }}
cargo build --profile production -p node-subtensor --features runtime-benchmarks

# (5)
- name: Check skip label
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label found — skipping benchmarks."
echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV"
fi

- name: Ensure artifact folder exists
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: mkdir -p .bench_patch
.github/scripts/check-skip-label.sh ${{ github.event.pull_request.number }}
cargo build --profile production -p subtensor-weight-tools --bin weight-compare

- name: Run & validate benchmarks
if: ${{ env.SKIP_BENCHMARKS != '1' }}
timeout-minutes: 180
run: |
.github/scripts/check-skip-label.sh ${{ github.event.pull_request.number }}
mkdir -p .bench_patch
chmod +x scripts/benchmark_action.sh
scripts/benchmark_action.sh

- name: List artifact contents (for debugging)
if: ${{ always() }}
run: |
echo "Workspace: $GITHUB_WORKSPACE"
if [ -d ".bench_patch" ]; then
echo "== .bench_patch =="
ls -la .bench_patch || true
else
echo ".bench_patch directory is missing"
fi

- name: Archive bench patch
if: ${{ always() }}
if: always()
run: |
if [ -d ".bench_patch" ]; then
tar -czf bench-patch.tgz .bench_patch
ls -lh bench-patch.tgz
else
echo "No .bench_patch directory to archive."
fi

- name: Upload patch artifact (if prepared)
if: ${{ always() }}
- name: Upload patch artifact
if: always()
uses: actions/upload-artifact@v4
with:
name: bench-patch
path: bench-patch.tgz
if-no-files-found: warn

# (6) — final check after run
- name: Check skip label after run
if: ${{ env.SKIP_BENCHMARKS != '1' }}
run: |
labels=$(gh pr view ${{ github.event.pull_request.number }} \
--repo "${{ github.repository }}" \
--json labels --jq '.labels[].name')
if echo "$labels" | grep -q "skip-validate-benchmarks"; then
echo "skip-validate-benchmarks label was found — but benchmarks already ran."
fi
5 changes: 3 additions & 2 deletions .maintain/frame-weight-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
#![allow(dead_code)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use core::marker::PhantomData;
Expand All @@ -33,7 +34,7 @@ pub trait WeightInfo {

/// Weights for `{{pallet}}` using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
{{#if (eq pallet "frame_system")}}
{{#if (or (eq pallet "frame_system") (eq pallet "frame_system_extensions"))}}
impl<T: crate::Config> WeightInfo for SubstrateWeight<T> {
{{else}}
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
Expand Down Expand Up @@ -118,4 +119,4 @@ impl WeightInfo for () {
{{/each}}
}
{{/each}}
}
}
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions chain-extensions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,20 @@ std = [
"num_enum/std",
"substrate-fixed/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-subtensor/runtime-benchmarks",
"pallet-subtensor-swap/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-contracts/runtime-benchmarks",
"pallet-crowdloan/runtime-benchmarks",
"pallet-drand/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-subtensor-proxy/runtime-benchmarks",
"pallet-subtensor-utility/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"subtensor-runtime-common/runtime-benchmarks"
]
4 changes: 4 additions & 0 deletions chain-extensions/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ impl pallet_subtensor::Config for Test {
type CommitmentsInterface = CommitmentsI;
type EvmKeyAssociateRateLimit = EvmKeyAssociateRateLimit;
type AuthorshipProvider = MockAuthorshipProvider;
type WeightInfo = ();
}

// Swap-related parameter types
Expand All @@ -442,6 +443,8 @@ impl pallet_subtensor_swap::Config for Test {
type MinimumLiquidity = SwapMinimumLiquidity;
type MinimumReserve = SwapMinimumReserve;
type WeightInfo = ();
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}

pub struct OriginPrivilegeCmp;
Expand Down Expand Up @@ -586,6 +589,7 @@ impl pallet_drand::Config for Test {
type Verifier = pallet_drand::verifier::QuicknetVerifier;
type UnsignedPriority = ConstU64<{ 1 << 20 }>;
type HttpFetchTimeout = ConstU64<1_000>;
type WeightInfo = ();
}

impl frame_system::offchain::SigningTypes for Test {
Expand Down
Loading
Loading