From 375d9906ee6263474a6c5e4bceed4fbad28db2b0 Mon Sep 17 00:00:00 2001 From: TDemeco Date: Thu, 24 Jul 2025 17:54:06 -0300 Subject: [PATCH 1/2] fix: :bug: use `MaxKeys` from `pallet-im-online`'s Config trait instead of hardcoded one --- substrate/frame/im-online/src/benchmarking.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/substrate/frame/im-online/src/benchmarking.rs b/substrate/frame/im-online/src/benchmarking.rs index 439720bcab38a..06b7231b1f485 100644 --- a/substrate/frame/im-online/src/benchmarking.rs +++ b/substrate/frame/im-online/src/benchmarking.rs @@ -29,8 +29,6 @@ use sp_runtime::{ use crate::*; -const MAX_KEYS: u32 = 1000; - pub fn create_heartbeat( k: u32, ) -> Result< @@ -67,7 +65,7 @@ mod benchmarks { use super::*; #[benchmark(extra)] - fn heartbeat(k: Linear<1, MAX_KEYS>) -> Result<(), BenchmarkError> { + fn heartbeat(k: Linear<1, { ::MaxKeys::get() }>) -> Result<(), BenchmarkError> { let (input_heartbeat, signature) = create_heartbeat::(k)?; #[extrinsic_call] @@ -77,7 +75,9 @@ mod benchmarks { } #[benchmark(extra)] - fn validate_unsigned(k: Linear<1, MAX_KEYS>) -> Result<(), BenchmarkError> { + fn validate_unsigned( + k: Linear<1, { ::MaxKeys::get() }>, + ) -> Result<(), BenchmarkError> { let (input_heartbeat, signature) = create_heartbeat::(k)?; let call = Call::heartbeat { heartbeat: input_heartbeat, signature }; @@ -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, { ::MaxKeys::get() }>, + ) -> Result<(), BenchmarkError> { let (input_heartbeat, signature) = create_heartbeat::(k)?; let call = Call::heartbeat { heartbeat: input_heartbeat, signature }; let call_enc = call.encode(); From c8f6c22cf797ee749aa3b35791a9c4e8a5b9b438 Mon Sep 17 00:00:00 2001 From: TDemeco Date: Thu, 24 Jul 2025 18:42:34 -0300 Subject: [PATCH 2/2] docs: :memo: add prdoc --- prdoc/pr_9325.prdoc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 prdoc/pr_9325.prdoc diff --git a/prdoc/pr_9325.prdoc b/prdoc/pr_9325.prdoc new file mode 100644 index 0000000000000..ebdcab0b10767 --- /dev/null +++ b/prdoc/pr_9325.prdoc @@ -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 \ No newline at end of file