From 489fc9ddc092f1fad2876551b4a3254096bc29d8 Mon Sep 17 00:00:00 2001 From: giuseppere Date: Thu, 19 Dec 2024 11:10:12 +0100 Subject: [PATCH] remove unused `page_size` fn arg + fix tests --- substrate/frame/staking/src/lib.rs | 3 +-- substrate/frame/staking/src/tests.rs | 3 ++- substrate/primitives/staking/src/lib.rs | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/substrate/frame/staking/src/lib.rs b/substrate/frame/staking/src/lib.rs index 5ee0aaea7708..2bec5eab3fc3 100644 --- a/substrate/frame/staking/src/lib.rs +++ b/substrate/frame/staking/src/lib.rs @@ -1200,8 +1200,7 @@ impl EraInfo { .defensive_saturating_add((page_size as usize).defensive_saturating_sub(1)) .saturating_div(page_size as usize); - let (exposure_metadata, exposure_pages) = - exposure.into_pages::(page_size); + let (exposure_metadata, exposure_pages) = exposure.into_pages::(); defensive_assert!(exposure_pages.len() == expected_page_count, "unexpected page count"); >::insert(era, &validator, &exposure_metadata); diff --git a/substrate/frame/staking/src/tests.rs b/substrate/frame/staking/src/tests.rs index 1e9a06e8be9d..8422b355dad4 100644 --- a/substrate/frame/staking/src/tests.rs +++ b/substrate/frame/staking/src/tests.rs @@ -6574,10 +6574,11 @@ fn can_page_exposure() { Exposure { total: total_stake, own: own_stake, others }; // when + MaxExposurePageSize::set(3); let (exposure_metadata, exposure_page): ( PagedExposureMetadata, Vec>, - ) = exposure.clone().into_pages::(3); + ) = exposure.clone().into_pages::(); // then // 7 pages of nominators. diff --git a/substrate/primitives/staking/src/lib.rs b/substrate/primitives/staking/src/lib.rs index fe7895ab5bc3..a9e14dc5858a 100644 --- a/substrate/primitives/staking/src/lib.rs +++ b/substrate/primitives/staking/src/lib.rs @@ -382,15 +382,16 @@ impl { /// Splits an `Exposure` into `PagedExposureMetadata` and multiple chunks of - /// `IndividualExposure` with each chunk having maximum of `page_size` elements. + /// `IndividualExposure` with each chunk having at least 1 element and a maximum of + /// `MaxExposurePageSize::get()` elements. pub fn into_pages( self, - page_size: Page, ) -> (PagedExposureMetadata, Vec>) where MaxExposurePageSize: Get, { - let individual_chunks = self.others.chunks(page_size as usize); + debug_assert!(MaxExposurePageSize::get() >= 1); + let individual_chunks = self.others.chunks(MaxExposurePageSize::get() as usize); let mut exposure_pages: Vec> = Vec::with_capacity(individual_chunks.len());