Open
Conversation
35ecc91 to
3a8eea6
Compare
9b9dd4b to
f45570a
Compare
shamil-gadelshin
approved these changes
Mar 24, 2026
Collaborator
shamil-gadelshin
left a comment
There was a problem hiding this comment.
Nice change! I added a small optional request for automation.
| 7. Add `type WeightInfo = ();` to all test mocks implementing your pallet's | ||
| `Config`. | ||
|
|
||
| 8. Register the pallet in the `define_benchmarks!` macro in |
Collaborator
There was a problem hiding this comment.
Is there a way to automate 8-9? We'll definitely miss these steps without some warning from CI or other tools.
JohnReedV
approved these changes
Mar 24, 2026
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 hardcoded. Removed#[benchmark(extra)]fromregister_leased_networkandterminate_leaseso they run in normal benchmark passes.weights.rsfixed (set_rate_limitrenamed toset_max_space), benchmark test suite restoredweights.rsregenerated (cleanup, no functional change)For each pallet: added
pub mod weights,type WeightInfoin Config, wiredSubstrateWeight<Runtime>in runtime, addedtype WeightInfo = ()to all test mocks.Benchmark fixes
remove_liquidity(HotKeyAccountNotExists) andmodify_position(SubtokenDisabled) benchmark setup. Added benchmarks foradd_liquidity,toggle_user_liquidity, anddisable_lp.set_identityandclear_identitybenchmarks failing withFundsUnavailable(replacedset_balance(max_value)withmint_into, set identity on caller instead of separate account).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 stepOther
.maintain/frame-weight-template.hbssynced with upstream polkadot-sdkdocs/benchmarks-and-weights.md— guide covering new pallet setup, adding extrinsics, parameterized weights, CI workflow