Skip to content

[PM-21804] task(runtime): benchmark WeightInfo for nine unmetered pallets#1338

Draft
m2ux wants to merge 10 commits into
mainfrom
task/PM-21804-benchmark-weightinfo-pallets
Draft

[PM-21804] task(runtime): benchmark WeightInfo for nine unmetered pallets#1338
m2ux wants to merge 10 commits into
mainfrom
task/PM-21804-benchmark-weightinfo-pallets

Conversation

@m2ux
Copy link
Copy Markdown
Contributor

@m2ux m2ux commented Apr 15, 2026

Summary

Replace placeholder WeightInfo = () with proper benchmarked weight implementations for nine pallets in the runtime, ensuring all user-facing extrinsics have accurate compute metering.

🎫 Ticket 📐 Engineering


Motivation

An AI security audit (Finding R-033) identified that nine pallets in runtime/src/lib.rs use type WeightInfo = (), meaning all their extrinsic weights are placeholder values. This includes user-facing pallets such as pallet_session_validator_management, pallet_federated_authority, and pallet_system_parameters.

Placeholder weights do not reflect actual execution costs, so blocks may include more computation than the weight budget intends to allow. This undermines the chain's resource accounting and could be exploited for denial-of-service against validators.


Changes

Implementation (coming next):

  • Identify all nine pallets using WeightInfo = ()
  • Run FRAME benchmarking for each pallet to generate weight files
  • Replace () with generated WeightInfo implementations in runtime config
  • Document any intentionally unweighted pallets with justification

📌 Submission Checklist

  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason: [reason]
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • No new todos introduced

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other
  • N/A

🗹 TODO before merging

  • Ready for review

m2ux and others added 2 commits April 15, 2026 10:44
…tered pallets

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Mike Clay <mike.clay@shielded.io>
…cument 4 as intentionally unweighted

PM-21804: Replace placeholder WeightInfo = () with proper benchmarked weights.

Wired pallets (SubstrateWeight<Runtime>):
- pallet_federated_authority
- pallet_federated_authority_observation
- pallet_system_parameters
- pallet_session_validator_management
- pallet_timestamp

Documented as intentionally unweighted (WeightInfo = ()):
- pallet_grandpa (weights module not publicly exported)
- pallet_mmr (weights module not publicly exported)
- pallet_beefy_mmr (weights module not publicly exported)
- pallet_beefy (no runtime-benchmarks feature, equivocation disabled)

Additional changes:
- Re-benchmarked 4 pallet weight files (STEPS=100, REPEAT=2)
- Added pallet-mmr/runtime-benchmarks feature to Cargo.toml
- Added pallet_grandpa and pallet_mmr to define_benchmarks! macro
- Observation pallet: preserved 4 inherent extrinsic weights (cannot
  be re-benchmarked via dispatch path)

Signed-off-by: Mike Clay <mike.clay@shielded.io>
@m2ux m2ux self-assigned this Apr 16, 2026
@m2ux m2ux marked this pull request as ready for review April 16, 2026 19:47
@m2ux m2ux requested a review from a team as a code owner April 16, 2026 19:47
m2ux and others added 2 commits April 16, 2026 20:48
Fixes CI changes_check: includes PR link and GitHub issue reference.

Signed-off-by: Mike Clay <mike.clay@shielded.io>
Comment thread partner-chains/toolkit/committee-selection/pallet/src/weights.rs Outdated
Comment thread partner-chains/toolkit/committee-selection/pallet/src/weights.rs
m2ux added 3 commits April 17, 2026 10:41
Regenerated weight files for the following pallets with increased
benchmark parameters for more accurate weight values:

- pallet-federated-authority-observation: removed stale reset_members*
  inherent extrinsic weights, updated set_* dispatchable weights
- pallet-federated-authority: updated weight values
- pallet-system-parameters: updated weight values
- pallet-session-validator-management (committee-selection): updated
  weight values with significantly lower standard error

Signed-off-by: Mike Clay <mike.clay@shielded.io>
…into task/PM-21804-benchmark-weightinfo-pallets

Signed-off-by: Mike Clay <mike.clay@shielded.io>
The benchmarks were run using frame-omni-bencher v1, not
./target/release/midnight-node. Updated the Executed Command
comments in all four weight files to reflect the actual tool used.

Signed-off-by: Mike Clay <mike.clay@shielded.io>
@m2ux m2ux requested a review from Klapeyron April 17, 2026 09:54
…servation

The frame-omni-bencher tool cannot benchmark Mandatory inherent extrinsics
like reset_members. The previous benchmark command excluded these variants
via --extrinsic, which removed the weight functions that lib.rs depends on.
Restore the carried-forward weight values for:
- reset_members_only_council
- reset_members_only_technical_committee
- reset_members
- reset_members_none

Signed-off-by: Mike Clay <mike.clay@shielded.io>
@m2ux m2ux force-pushed the task/PM-21804-benchmark-weightinfo-pallets branch from 0ed1367 to 3401fd8 Compare April 17, 2026 10:25
@m2ux m2ux changed the title task(runtime): benchmark WeightInfo for nine unmetered pallets (PM-21804) [PM-21804] task(runtime): benchmark WeightInfo for nine unmetered pallets Apr 29, 2026
…rk-weightinfo-pallets

Signed-off-by: Mike Clay <mike.clay@shielded.io>

# Conflicts:
#	partner-chains/toolkit/committee-selection/pallet/src/weights.rs
@m2ux m2ux requested review from LGLO and removed request for LGLO April 30, 2026 10:59
Copy link
Copy Markdown
Contributor

@justinfrevert justinfrevert left a comment

Choose a reason for hiding this comment

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

Weights seem sensible. Thanks!

@m2ux m2ux marked this pull request as draft April 30, 2026 15:09
@gilescope
Copy link
Copy Markdown
Contributor

We should benchmark against the benchmarking machine.

@Klapeyron
Copy link
Copy Markdown
Contributor

do we follow this issue as part of #1482 now?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants