Skip to content

Improve Benchmarking#2798

Open
JohnReedV wants to merge 32 commits into
devnet-readyfrom
apply-benchmark-to-only-bad-benches
Open

Improve Benchmarking#2798
JohnReedV wants to merge 32 commits into
devnet-readyfrom
apply-benchmark-to-only-bad-benches

Conversation

@JohnReedV

@JohnReedV JohnReedV commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

This PR

  • Modifies the benchmark flow so that only extrinsics that have drifted passed the threshold or have incorrect read/writes are updated rather than replacing the entire file and creating conflicts everywhere.

  • Adds a lint to check for extrinsics with missing benchmarks

  • Adds missing benchmarks

  • fixes a bug where it would fail extrinsics where it shouldn't.

@JohnReedV JohnReedV added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Jun 25, 2026
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

🛡️ AI Review — Skeptic (security review)

VERDICT: SAFE

Baseline scrutiny: established OpenTensor-associated contributor with repo write permission; branch apply-benchmark-to-only-bad-benches -> devnet-ready.

Reviewed the trusted instructions, prior Skeptic sticky, contributor signals, PR metadata, comments, changed-file list, overlap signal, and the pre-fetched diff. The prior Skeptic sticky contains no finding IDs to reconcile.

The PR does not modify .github/ai-review/*, .github/copilot-instructions.md, workflows, or Cargo.lock. Cargo manifest edits only enable features on existing workspace dependencies. The diff is scoped to benchmark setup, generated/runtime weight updates with a spec_version bump, benchmark tooling, and a build-time local-source benchmark coverage warning. I did not find credential access, hidden network access, shell injection, supply-chain dependency introduction, origin/permission bypass, unsafe runtime code, or a credible malicious patch path.

Findings

No findings.

Conclusion

No malicious intent or security vulnerability was found in the reviewed diff. Residual risk is limited to benchmark-tooling correctness and generated-weight accuracy, which does not cross the Skeptic security threshold here.


🔍 AI Review — Auditor (domain review)

VERDICT: 👍

Gittensor UNKNOWN; author has write permission, @opentensor profile context, and substantial recent subtensor contribution history, so this was calibrated as an established-contributor domain review.

PR body is concise but substantive enough to leave unchanged.

Spec version is bumped from 423 to 424 for the runtime/weight changes, and the PR has no no-spec-version-bump label.

Duplicate-work check: overlapping open PRs touch common runtime/weight files, but their titles and scopes are unrelated to benchmark drift patching or the new benchmark-coverage lint.

Validation: bash -n scripts/benchmark_action.sh and git diff --check origin/devnet-ready...HEAD passed. I attempted cargo test -p subtensor-linting require_extrinsic_benchmarks --lib, but this sandbox cannot create rustup temp files under /home/runner/.rustup, so the targeted cargo test did not run. No auto-fixes were made.

Findings

No findings.

Prior-comment reconciliation

  • 2cfa55a3: addressed — The matcher now requires a complete WeightInfo method-name boundary and includes tests for prefix false positives such as swap_coldkey versus swap_coldkey_announced.

Conclusion

The prior matcher precision issue is addressed, the generated benchmark weight plumbing is now wired to the corresponding dispatch annotations, and the benchmark update script/lint changes are consistent with the PR description. I found no remaining blocking domain issues.


📜 Previous run (superseded)
Sev File Finding Status
MEDIUM support/linting/src/require_extrinsic_benchmarks.rs:323 Match the complete WeightInfo method name ✅ Addressed
The matcher now requires a complete WeightInfo method-name boundary and includes tests for prefix false positives such as swap_coldkey versus swap_coldkey_announced.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@JohnReedV JohnReedV changed the title Apply Benchmark patch only where its needed Improve Benchmarking Jun 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread support/weight-tools/src/weight_compare.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👎

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/src/weights.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👎

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/src/weights.rs
Comment thread pallets/admin-utils/src/weights.rs
Comment thread pallets/swap/src/weights.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👎

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment on lines +318 to +323
let direct = format!("WeightInfo::{name}");
let associated = format!("::{name}");
normalized.contains(&direct)
|| normalized.split("WeightInfo").skip(1).any(|suffix| {
suffix.contains(&associated) || suffix.contains(&format!("::<T>{associated}"))
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] Match the complete WeightInfo method name

This accepts any WeightInfo call whose method merely starts with the dispatchable name. For example, a dispatchable named swap_coldkey would be treated as correctly plugged if its weight attribute called WeightInfo::swap_coldkey_announced(), because ::swap_coldkey_announced contains ::swap_coldkey. That is the exact class of benchmark/weight wiring mistake this lint is meant to catch, especially in this repo where prefix-related names exist. Require a call boundary after the matched method name, and add a unit test for the prefix case.

Suggested change
let direct = format!("WeightInfo::{name}");
let associated = format!("::{name}");
normalized.contains(&direct)
|| normalized.split("WeightInfo").skip(1).any(|suffix| {
suffix.contains(&associated) || suffix.contains(&format!("::<T>{associated}"))
})
normalized.split("WeightInfo").skip(1).any(|suffix| {
[format!("::{name}"), format!("::<T>::{name}")]
.iter()
.any(|needle| {
suffix
.split(needle.as_str())
.skip(1)
.any(|rest| rest.starts_with('(') || rest.starts_with("::<"))
})
})

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant