mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-21 05:11:02 +00:00
Whitelist pallet preimage provider upgrade (#12834)
* whitelist preimage provider upgrade * rustdocs unresolved link error fix * ".git/.scripts/bench-bot.sh" pallet dev pallet_whitelist * PreimageHash alias, remove type annotation Co-authored-by: command-bot <>
This commit is contained in:
@@ -21,10 +21,7 @@
|
||||
|
||||
use super::*;
|
||||
use frame_benchmarking::benchmarks;
|
||||
use frame_support::{
|
||||
ensure,
|
||||
traits::{EnsureOrigin, Get, PreimageRecipient},
|
||||
};
|
||||
use frame_support::{ensure, traits::EnsureOrigin};
|
||||
|
||||
#[cfg(test)]
|
||||
use crate::Pallet as Whitelist;
|
||||
@@ -40,7 +37,7 @@ benchmarks! {
|
||||
"call not whitelisted"
|
||||
);
|
||||
ensure!(
|
||||
T::PreimageProvider::preimage_requested(&call_hash),
|
||||
T::Preimages::is_requested(&call_hash),
|
||||
"preimage not requested"
|
||||
);
|
||||
}
|
||||
@@ -57,7 +54,7 @@ benchmarks! {
|
||||
"whitelist not removed"
|
||||
);
|
||||
ensure!(
|
||||
!T::PreimageProvider::preimage_requested(&call_hash),
|
||||
!T::Preimages::is_requested(&call_hash),
|
||||
"preimage still requested"
|
||||
);
|
||||
}
|
||||
@@ -66,30 +63,30 @@ benchmarks! {
|
||||
// If the resulting weight is too big, maybe it worth having a weight which depends
|
||||
// on the size of the call, with a new witness in parameter.
|
||||
dispatch_whitelisted_call {
|
||||
let origin = T::DispatchWhitelistedOrigin::successful_origin();
|
||||
// NOTE: we remove `10` because we need some bytes to encode the variants and vec length
|
||||
let remark_len = <T::PreimageProvider as PreimageRecipient<_>>::MaxSize::get() - 10;
|
||||
let remark = sp_std::vec![1u8; remark_len as usize];
|
||||
let n in 1 .. T::Preimages::MAX_LENGTH as u32 - 10;
|
||||
|
||||
let origin = T::DispatchWhitelistedOrigin::successful_origin();
|
||||
let remark = sp_std::vec![1u8; n as usize];
|
||||
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark }.into();
|
||||
let call_weight = call.get_dispatch_info().weight;
|
||||
let encoded_call = call.encode();
|
||||
let call_hash = T::Hashing::hash(&encoded_call[..]);
|
||||
let call_encoded_len = encoded_call.len() as u32;
|
||||
let call_hash = call.blake2_256().into();
|
||||
|
||||
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
|
||||
.expect("whitelisting call must be successful");
|
||||
|
||||
let encoded_call = encoded_call.try_into().expect("encoded_call must be small enough");
|
||||
T::PreimageProvider::note_preimage(encoded_call);
|
||||
T::Preimages::note(encoded_call.into()).unwrap();
|
||||
|
||||
}: _<T::RuntimeOrigin>(origin, call_hash, call_weight)
|
||||
}: _<T::RuntimeOrigin>(origin, call_hash, call_encoded_len, call_weight)
|
||||
verify {
|
||||
ensure!(
|
||||
!WhitelistedCall::<T>::contains_key(call_hash),
|
||||
"whitelist not removed"
|
||||
);
|
||||
ensure!(
|
||||
!T::PreimageProvider::preimage_requested(&call_hash),
|
||||
!T::Preimages::is_requested(&call_hash),
|
||||
"preimage still requested"
|
||||
);
|
||||
}
|
||||
@@ -101,7 +98,7 @@ benchmarks! {
|
||||
let remark = sp_std::vec![1u8; n as usize];
|
||||
|
||||
let call: <T as Config>::RuntimeCall = frame_system::Call::remark { remark }.into();
|
||||
let call_hash = T::Hashing::hash_of(&call);
|
||||
let call_hash = call.blake2_256().into();
|
||||
|
||||
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
|
||||
.expect("whitelisting call must be successful");
|
||||
@@ -112,7 +109,7 @@ benchmarks! {
|
||||
"whitelist not removed"
|
||||
);
|
||||
ensure!(
|
||||
!T::PreimageProvider::preimage_requested(&call_hash),
|
||||
!T::Preimages::is_requested(&call_hash),
|
||||
"preimage still requested"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user