diff --git a/substrate/frame/preimage/src/benchmarking.rs b/substrate/frame/preimage/src/benchmarking.rs index d7c643ff9042..d0c3404f40a9 100644 --- a/substrate/frame/preimage/src/benchmarking.rs +++ b/substrate/frame/preimage/src/benchmarking.rs @@ -216,7 +216,7 @@ benchmarks! { } ensure_updated { - let n in 0..MAX_HASH_UPGRADE_BULK_COUNT; + let n in 1..MAX_HASH_UPGRADE_BULK_COUNT; let caller = funded_account::(); let hashes = (0..n).map(|i| insert_old_unrequested::(i)).collect::>(); diff --git a/substrate/frame/preimage/src/lib.rs b/substrate/frame/preimage/src/lib.rs index e603f1a32e6a..4dda0207e62c 100644 --- a/substrate/frame/preimage/src/lib.rs +++ b/substrate/frame/preimage/src/lib.rs @@ -156,6 +156,8 @@ pub mod pallet { NotRequested, /// More than `MAX_HASH_UPGRADE_BULK_COUNT` hashes were requested to be upgraded at once. TooMany, + /// Too few hashes were requested to be upgraded (i.e. zero). + TooFew, } /// A reason for this pallet placing a hold on funds. @@ -242,6 +244,7 @@ pub mod pallet { hashes: Vec, ) -> DispatchResultWithPostInfo { ensure_signed(origin)?; + ensure!(hashes.len() > 0, Error::::TooFew); ensure!(hashes.len() <= MAX_HASH_UPGRADE_BULK_COUNT as usize, Error::::TooMany); let updated = hashes.iter().map(Self::do_ensure_updated).filter(|b| *b).count() as u32;