pallet-glutton: over-unity consumption (#14338)

* pallet-glutton: over-unity consumption

* Add hard limit

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Tests

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Cleanup

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Highlight warning

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Fix docs

* Review test fixes

Co-authored-by: Guillaume Yu Thiolliere <gui.thiolliere@gmail.com>

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet-glutton

* ".git/.scripts/commands/bench/bench.sh" pallet dev pallet-glutton

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Guillaume Yu Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: command-bot <>
This commit is contained in:
Oliver Tale-Yazdi
2023-06-13 17:57:04 +02:00
committed by GitHub
parent 2c7166eb9c
commit 3b6d31f03d
8 changed files with 246 additions and 166 deletions
+7 -6
View File
@@ -25,6 +25,7 @@ use super::*;
use frame_benchmarking::benchmarks;
use frame_support::{pallet_prelude::*, weights::constants::*};
use frame_system::RawOrigin as SystemOrigin;
use sp_runtime::{traits::One, Perbill};
use crate::Pallet as Glutton;
use frame_system::Pallet as System;
@@ -67,8 +68,8 @@ benchmarks! {
// For manual verification only.
on_idle_high_proof_waste {
(0..5000).for_each(|i| TrashData::<T>::insert(i, [i as u8; 1024]));
let _ = Glutton::<T>::set_compute(SystemOrigin::Root.into(), Perbill::from_percent(100));
let _ = Glutton::<T>::set_storage(SystemOrigin::Root.into(), Perbill::from_percent(100));
let _ = Glutton::<T>::set_compute(SystemOrigin::Root.into(), One::one());
let _ = Glutton::<T>::set_storage(SystemOrigin::Root.into(), One::one());
}: {
let weight = Glutton::<T>::on_idle(System::<T>::block_number(), Weight::from_parts(WEIGHT_REF_TIME_PER_MILLIS * 100, WEIGHT_PROOF_SIZE_PER_MB * 5));
}
@@ -76,8 +77,8 @@ benchmarks! {
// For manual verification only.
on_idle_low_proof_waste {
(0..5000).for_each(|i| TrashData::<T>::insert(i, [i as u8; 1024]));
let _ = Glutton::<T>::set_compute(SystemOrigin::Root.into(), Perbill::from_percent(100));
let _ = Glutton::<T>::set_storage(SystemOrigin::Root.into(), Perbill::from_percent(100));
let _ = Glutton::<T>::set_compute(SystemOrigin::Root.into(), One::one());
let _ = Glutton::<T>::set_storage(SystemOrigin::Root.into(), One::one());
}: {
let weight = Glutton::<T>::on_idle(System::<T>::block_number(), Weight::from_parts(WEIGHT_REF_TIME_PER_MILLIS * 100, WEIGHT_PROOF_SIZE_PER_KB * 20));
}
@@ -89,10 +90,10 @@ benchmarks! {
}
set_compute {
}: _(SystemOrigin::Root, Perbill::from_percent(50))
}: _(SystemOrigin::Root, FixedU64::from_perbill(Perbill::from_percent(50)))
set_storage {
}: _(SystemOrigin::Root, Perbill::from_percent(50))
}: _(SystemOrigin::Root, FixedU64::from_perbill(Perbill::from_percent(50)))
impl_benchmark_test_suite!(Glutton, crate::mock::new_test_ext(), crate::mock::Test);
}