Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions prdoc/pr_9325.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Fix pallet-im-online benchmarking for runtimes with MaxKeys < 1000

doc:
- audience: Runtime Dev
description: |
Fixes benchmarking for pallet-im-online when runtime configuration has MaxKeys < 1000.
Previously, the benchmark code used a hardcoded constant MAX_KEYS = 1000 which would
cause benchmark failures for runtimes configured with fewer maximum keys. This change
updates the benchmark to dynamically use the MaxKeys value from the pallet's Config trait.

crates:
- name: pallet-im-online
bump: patch
12 changes: 7 additions & 5 deletions substrate/frame/im-online/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ use sp_runtime::{

use crate::*;

const MAX_KEYS: u32 = 1000;

pub fn create_heartbeat<T: Config>(
k: u32,
) -> Result<
Expand Down Expand Up @@ -67,7 +65,7 @@ mod benchmarks {
use super::*;

#[benchmark(extra)]
fn heartbeat(k: Linear<1, MAX_KEYS>) -> Result<(), BenchmarkError> {
fn heartbeat(k: Linear<1, { <T as Config>::MaxKeys::get() }>) -> Result<(), BenchmarkError> {
let (input_heartbeat, signature) = create_heartbeat::<T>(k)?;

#[extrinsic_call]
Expand All @@ -77,7 +75,9 @@ mod benchmarks {
}

#[benchmark(extra)]
fn validate_unsigned(k: Linear<1, MAX_KEYS>) -> Result<(), BenchmarkError> {
fn validate_unsigned(
k: Linear<1, { <T as Config>::MaxKeys::get() }>,
) -> Result<(), BenchmarkError> {
let (input_heartbeat, signature) = create_heartbeat::<T>(k)?;
let call = Call::heartbeat { heartbeat: input_heartbeat, signature };

Expand All @@ -91,7 +91,9 @@ mod benchmarks {
}

#[benchmark]
fn validate_unsigned_and_then_heartbeat(k: Linear<1, MAX_KEYS>) -> Result<(), BenchmarkError> {
fn validate_unsigned_and_then_heartbeat(
k: Linear<1, { <T as Config>::MaxKeys::get() }>,
) -> Result<(), BenchmarkError> {
let (input_heartbeat, signature) = create_heartbeat::<T>(k)?;
let call = Call::heartbeat { heartbeat: input_heartbeat, signature };
let call_enc = call.encode();
Expand Down
Loading