Skip to content

Commit

Permalink
Fix pallet_nis benchmark for Kusama runtime (#229)
Browse files Browse the repository at this point in the history
Relates to: #223

A type alias `type Nis = pallet_balances::Pallet::<Runtime,
NisCounterpartInstance>;` for the second `pallet_balances` instance was
introduced [here](#58).
Unfortunately, nobody (including myself) realized that `Nis` is also
used for `[pallet_nis, Nis]`. As a result, the benchmark for
`pallet_nis` runs as if it were for `pallet_balances`, and the result
can be seen here:
[link](3bb9a02#diff-9bfa230a9b7f40866df3f84e81dfea72a64cc31bd9ef6e594c3d43582ba76522).

Therefore, this PR fixes this anomaly.

<!-- Remember that you can run `/merge` to enable auto-merge in the PR
-->

<!-- Remember to modify the changelog. If you don't need to modify it,
you can check the following box.
Instead, if you have already modified it, simply delete the following
line. -->

- [x] Does not require a CHANGELOG entry

---------

Co-authored-by: fellowship-merge-bot[bot] <151052383+fellowship-merge-bot[bot]@users.noreply.github.com>
  • Loading branch information
bkontur and fellowship-merge-bot[bot] committed Mar 12, 2024
1 parent cc43238 commit 9566967
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
17 changes: 15 additions & 2 deletions docs/weight-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ for pallet in "${pallets[@]}"; do
done
```

You probably want to do this inside a `tmux` session or similar, as it will take a while.
You probably want to do this inside a `tmux` session or something similar (e.g., `nohup <bench-cmd> &`), as it will take a while (several hours).

7. `rsync` the weights back to your local machine, replacing the existing weights.

Expand All @@ -78,7 +78,20 @@ You probably want to do this inside a `tmux` session or similar, as it will take

9. Commit the weight changes.

10. If not installed, `cargo install subweight`, and check the weight changes with `subweight compare commits --path-pattern "./**/weights/*.rs" --method asymptotic --ignore-errors HEAD origin/main`. Ensure the changes are reasonable.
10. Ensure the changes are reasonable. If not installed, `cargo install subweight`, check the weight changes:
```
subweight compare commits \
--path-pattern "./**/weights/**/*.rs" \
--method asymptotic \
--ignore-errors \
<LATEST-RELEASE-BRANCH> \
<ACTUAL_BRANCH_WITH_COMMITED_WEIGHTS>`
```
_Hint1: Add `--format markdown --no-color` for markdown-compatible results._

_Hint2: Change `--path-pattern "./**/weights/**/*.rs"` to e.g. `--path-pattern "./relay/polkadot/weights/**/*.rs"` for a specific runtime._

_Hint3: Add `--change added changed` to include only relevant changes._

## FAQ

Expand Down
10 changes: 5 additions & 5 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1477,7 +1477,7 @@ impl pallet_balances::Config<NisCounterpartInstance> for Runtime {
type MaxLocks = ConstU32<4>;
type MaxReserves = ConstU32<4>;
type ReserveIdentifier = [u8; 8];
type WeightInfo = weights::pallet_balances_nis::WeightInfo<Runtime>;
type WeightInfo = weights::pallet_balances_nis_counterpart::WeightInfo<Runtime>;
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeFreezeReason = RuntimeFreezeReason;
type FreezeIdentifier = ();
Expand Down Expand Up @@ -1981,7 +1981,7 @@ mod benches {
[runtime_parachains::coretime, Coretime]
// Substrate
[pallet_balances, Native]
[pallet_balances, Nis]
[pallet_balances, NisCounterpart]
[pallet_bags_list, VoterList]
[frame_benchmarking::baseline, Baseline::<Runtime>]
[pallet_bounties, Bounties]
Expand Down Expand Up @@ -2559,9 +2559,9 @@ sp_api::impl_runtime_apis! {
// Benchmark files generated for `Balances/NisCounterpartBalances` instances are by default
// `pallet_balances_balances.rs / pallet_balances_nis_counterpart_balances`, which is not really nice,
// so with this redefinition we can change names to nicer:
// `pallet_balances_native.rs / pallet_balances_nis.rs`.
// `pallet_balances_native.rs / pallet_balances_nis_counterpart.rs`.
type Native = pallet_balances::Pallet::<Runtime, ()>;
type Nis = pallet_balances::Pallet::<Runtime, NisCounterpartInstance>;
type NisCounterpart = pallet_balances::Pallet::<Runtime, NisCounterpartInstance>;

let mut list = Vec::<BenchmarkList>::new();
list_benchmarks!(list, extra);
Expand Down Expand Up @@ -2776,7 +2776,7 @@ sp_api::impl_runtime_apis! {
}

type Native = pallet_balances::Pallet::<Runtime, ()>;
type Nis = pallet_balances::Pallet::<Runtime, NisCounterpartInstance>;
type NisCounterpart = pallet_balances::Pallet::<Runtime, NisCounterpartInstance>;

let mut whitelist: Vec<TrackedStorageKey> = AllPalletsWithSystem::whitelisted_storage_keys();
let treasury_key = frame_system::Account::<Runtime>::hashed_key_for(Treasury::account_id());
Expand Down
2 changes: 1 addition & 1 deletion relay/kusama/src/weights/mod.rs

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

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

0 comments on commit 9566967

Please sign in to comment.