Open
Conversation
35ecc91 to
3a8eea6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts the benchmark and weight system to the standard FRAME
WeightInfopattern. This lays the groundwork for using parameterized weights where extrinsic cost scales with input size (e.g., number of contributors, batch size), which was not possible with hardcoded values.Before: Extrinsics had
Weight::from_parts(X, 0)hardcoded directly in#[pallet::weight(...)]annotations. CI parsed benchmark stdout and patched values in source files.After: Each pallet has a
weights.rsfile, aWeightInfotrait, and extrinsics referenceT::WeightInfo::fn_name(). CI uses a syn-based Rust tool to compare old vs new weight values with a threshold.Note: we generate weights using
--runtime+--genesis-builderflags (not--chain) because the runtime uses custom host functions that require the full node binary.Pallet changes
T::WeightInfo::fn(), 18 without benchmarks kept hardcodedweights.rsfixed (set_rate_limitrenamed toset_max_space)For each pallet: added
pub mod weights,type WeightInfoin Config, wiredSubstrateWeight<Runtime>in runtime, addedtype WeightInfo = ()to all test mocks.New tooling (
support/weight-tools/)Lightweight crate (~4s build, no runtime dependency):
weight-compare— parses twoweights.rsfiles withsyn, compares base weights (threshold-based), reads/writes (exact), and per-component slopes for parameterized weights. Used by CI.Scripts
scripts/benchmark_all.sh— rewritten to generateweights.rsvia--output/--template, supports single-pallet runs andSKIP_BUILD=1scripts/benchmark_action.sh— rewritten to useweight-comparewith 40% drift thresholdscripts/benchmark.shfilesCI
run-benchmarks.yml— cleaned up, extracted repeated skip-label check into.github/scripts/check-skip-label.sh, addedweight-comparebuild stepapply-benchmark-patch.yml— uses a GitHub App token instead ofGITHUB_TOKENso the pushed commit re-triggers all CI workflows. RequiresGH_APP_ID(repo variable) andGH_APP_PRIVATE_KEY(repo secret) to be configured once.Other
.maintain/frame-weight-template.hbssynced with upstream polkadot-sdkdocs/benchmarks-and-weights.md— guide covering new pallet setup, adding extrinsics, parameterized weights, CI workflow