feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
[package]
|
||||
name = "pezpallet-whitelist"
|
||||
version = "27.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "FRAME pallet for whitelisting calls, and dispatching from a specific origin"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { features = ["derive", "max-encoded-len"], workspace = true }
|
||||
frame = { workspace = true, features = ["runtime"] }
|
||||
scale-info = { features = ["derive"], workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
pezpallet-balances = { workspace = true, default-features = true }
|
||||
pezpallet-preimage = { workspace = true, default-features = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = ["codec/std", "frame/std", "scale-info/std"]
|
||||
runtime-benchmarks = [
|
||||
"frame/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-preimage/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"frame/try-runtime",
|
||||
"pezpallet-balances/try-runtime",
|
||||
"pezpallet-preimage/try-runtime",
|
||||
]
|
||||
@@ -0,0 +1,115 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Whitelist pallet benchmarking.
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use super::*;
|
||||
#[cfg(test)]
|
||||
use crate::Pallet as Whitelist;
|
||||
use frame::benchmarking::prelude::*;
|
||||
|
||||
#[benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn whitelist_call() -> Result<(), BenchmarkError> {
|
||||
let origin =
|
||||
T::WhitelistOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||
let call_hash = Default::default();
|
||||
|
||||
#[extrinsic_call]
|
||||
_(origin as T::RuntimeOrigin, call_hash);
|
||||
|
||||
ensure!(WhitelistedCall::<T>::contains_key(call_hash), "call not whitelisted");
|
||||
ensure!(T::Preimages::is_requested(&call_hash), "preimage not requested");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn remove_whitelisted_call() -> Result<(), BenchmarkError> {
|
||||
let origin =
|
||||
T::WhitelistOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
|
||||
let call_hash = Default::default();
|
||||
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
|
||||
.expect("whitelisting call must be successful");
|
||||
|
||||
#[extrinsic_call]
|
||||
_(origin as T::RuntimeOrigin, call_hash);
|
||||
|
||||
ensure!(!WhitelistedCall::<T>::contains_key(call_hash), "whitelist not removed");
|
||||
ensure!(!T::Preimages::is_requested(&call_hash), "preimage still requested");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// We benchmark with the maximum possible size for a call.
|
||||
// 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.
|
||||
#[benchmark(pov_mode = MaxEncodedLen {
|
||||
// Use measured PoV size for the Preimages since we pass in a length witness.
|
||||
Preimage::PreimageFor: Measured
|
||||
})]
|
||||
// NOTE: we remove `10` because we need some bytes to encode the variants and vec length
|
||||
fn dispatch_whitelisted_call(
|
||||
n: Linear<1, { T::Preimages::MAX_LENGTH as u32 - 10 }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let origin = T::DispatchWhitelistedOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let remark = alloc::vec![1u8; n as usize];
|
||||
let call: <T as Config>::RuntimeCall = pezframe_system::Call::remark { remark }.into();
|
||||
let call_weight = call.get_dispatch_info().call_weight;
|
||||
let encoded_call = call.encode();
|
||||
let call_encoded_len = encoded_call.len() as u32;
|
||||
let call_hash = T::Hashing::hash_of(&call);
|
||||
|
||||
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
|
||||
.expect("whitelisting call must be successful");
|
||||
|
||||
T::Preimages::note(encoded_call.into()).unwrap();
|
||||
|
||||
#[extrinsic_call]
|
||||
_(origin as T::RuntimeOrigin, call_hash, call_encoded_len, call_weight);
|
||||
|
||||
ensure!(!WhitelistedCall::<T>::contains_key(call_hash), "whitelist not removed");
|
||||
ensure!(!T::Preimages::is_requested(&call_hash), "preimage still requested");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn dispatch_whitelisted_call_with_preimage(n: Linear<1, 10_000>) -> Result<(), BenchmarkError> {
|
||||
let origin = T::DispatchWhitelistedOrigin::try_successful_origin()
|
||||
.map_err(|_| BenchmarkError::Weightless)?;
|
||||
let remark = alloc::vec![1u8; n as usize];
|
||||
|
||||
let call: <T as Config>::RuntimeCall = pezframe_system::Call::remark { remark }.into();
|
||||
let call_hash = T::Hashing::hash_of(&call);
|
||||
|
||||
Pallet::<T>::whitelist_call(origin.clone(), call_hash)
|
||||
.expect("whitelisting call must be successful");
|
||||
|
||||
#[extrinsic_call]
|
||||
_(origin as T::RuntimeOrigin, Box::new(call));
|
||||
|
||||
ensure!(!WhitelistedCall::<T>::contains_key(call_hash), "whitelist not removed");
|
||||
ensure!(!T::Preimages::is_requested(&call_hash), "preimage still requested");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Whitelist, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! # Whitelist Pallet
|
||||
//!
|
||||
//! - [`Config`]
|
||||
//! - [`Call`]
|
||||
//!
|
||||
//! ## Overview
|
||||
//!
|
||||
//! Allow some configurable origin: [`Config::WhitelistOrigin`] to whitelist some hash of a call,
|
||||
//! and allow another configurable origin: [`Config::DispatchWhitelistedOrigin`] to dispatch them
|
||||
//! with the root origin.
|
||||
//!
|
||||
//! In the meantime the call corresponding to the hash must have been submitted to the pre-image
|
||||
//! handler [`pallet::Config::Preimages`].
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
mod benchmarking;
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
pub mod weights;
|
||||
pub use weights::WeightInfo;
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use codec::{DecodeLimit, Encode, FullCodec};
|
||||
use frame::{
|
||||
prelude::*,
|
||||
traits::{QueryPreimage, StorePreimage},
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
#[frame::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// The overarching event type.
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
|
||||
/// The overarching call type.
|
||||
type RuntimeCall: IsType<<Self as pezframe_system::Config>::RuntimeCall>
|
||||
+ Dispatchable<RuntimeOrigin = Self::RuntimeOrigin, PostInfo = PostDispatchInfo>
|
||||
+ GetDispatchInfo
|
||||
+ FullCodec
|
||||
+ TypeInfo
|
||||
+ From<pezframe_system::Call<Self>>
|
||||
+ Parameter;
|
||||
|
||||
/// Required origin for whitelisting a call.
|
||||
type WhitelistOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// Required origin for dispatching whitelisted call with root origin.
|
||||
type DispatchWhitelistedOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The handler of pre-images.
|
||||
type Preimages: QueryPreimage<H = Self::Hashing> + StorePreimage;
|
||||
|
||||
/// The weight information for this pallet.
|
||||
type WeightInfo: WeightInfo;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
CallWhitelisted { call_hash: T::Hash },
|
||||
WhitelistedCallRemoved { call_hash: T::Hash },
|
||||
WhitelistedCallDispatched { call_hash: T::Hash, result: DispatchResultWithPostInfo },
|
||||
}
|
||||
|
||||
#[pallet::error]
|
||||
pub enum Error<T> {
|
||||
/// The preimage of the call hash could not be loaded.
|
||||
UnavailablePreImage,
|
||||
/// The call could not be decoded.
|
||||
UndecodableCall,
|
||||
/// The weight of the decoded call was higher than the witness.
|
||||
InvalidCallWeightWitness,
|
||||
/// The call was not whitelisted.
|
||||
CallIsNotWhitelisted,
|
||||
/// The call was already whitelisted; No-Op.
|
||||
CallAlreadyWhitelisted,
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
pub type WhitelistedCall<T: Config> = StorageMap<_, Twox64Concat, T::Hash, (), OptionQuery>;
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {
|
||||
#[pallet::call_index(0)]
|
||||
#[pallet::weight(T::WeightInfo::whitelist_call())]
|
||||
pub fn whitelist_call(origin: OriginFor<T>, call_hash: T::Hash) -> DispatchResult {
|
||||
T::WhitelistOrigin::ensure_origin(origin)?;
|
||||
|
||||
ensure!(
|
||||
!WhitelistedCall::<T>::contains_key(call_hash),
|
||||
Error::<T>::CallAlreadyWhitelisted,
|
||||
);
|
||||
|
||||
WhitelistedCall::<T>::insert(call_hash, ());
|
||||
T::Preimages::request(&call_hash);
|
||||
|
||||
Self::deposit_event(Event::<T>::CallWhitelisted { call_hash });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(1)]
|
||||
#[pallet::weight(T::WeightInfo::remove_whitelisted_call())]
|
||||
pub fn remove_whitelisted_call(origin: OriginFor<T>, call_hash: T::Hash) -> DispatchResult {
|
||||
T::WhitelistOrigin::ensure_origin(origin)?;
|
||||
|
||||
WhitelistedCall::<T>::take(call_hash).ok_or(Error::<T>::CallIsNotWhitelisted)?;
|
||||
|
||||
T::Preimages::unrequest(&call_hash);
|
||||
|
||||
Self::deposit_event(Event::<T>::WhitelistedCallRemoved { call_hash });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pallet::call_index(2)]
|
||||
#[pallet::weight(
|
||||
T::WeightInfo::dispatch_whitelisted_call(*call_encoded_len)
|
||||
.saturating_add(*call_weight_witness)
|
||||
)]
|
||||
pub fn dispatch_whitelisted_call(
|
||||
origin: OriginFor<T>,
|
||||
call_hash: T::Hash,
|
||||
call_encoded_len: u32,
|
||||
call_weight_witness: Weight,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::DispatchWhitelistedOrigin::ensure_origin(origin)?;
|
||||
|
||||
ensure!(
|
||||
WhitelistedCall::<T>::contains_key(call_hash),
|
||||
Error::<T>::CallIsNotWhitelisted,
|
||||
);
|
||||
|
||||
let call = T::Preimages::fetch(&call_hash, Some(call_encoded_len))
|
||||
.map_err(|_| Error::<T>::UnavailablePreImage)?;
|
||||
|
||||
let call = <T as Config>::RuntimeCall::decode_all_with_depth_limit(
|
||||
frame::deps::pezframe_support::MAX_EXTRINSIC_DEPTH,
|
||||
&mut &call[..],
|
||||
)
|
||||
.map_err(|_| Error::<T>::UndecodableCall)?;
|
||||
|
||||
ensure!(
|
||||
call.get_dispatch_info().call_weight.all_lte(call_weight_witness),
|
||||
Error::<T>::InvalidCallWeightWitness
|
||||
);
|
||||
|
||||
let actual_weight = Self::clean_and_dispatch(call_hash, call).map(|w| {
|
||||
w.saturating_add(T::WeightInfo::dispatch_whitelisted_call(call_encoded_len))
|
||||
});
|
||||
|
||||
Ok(actual_weight.into())
|
||||
}
|
||||
|
||||
#[pallet::call_index(3)]
|
||||
#[pallet::weight({
|
||||
let call_weight = call.get_dispatch_info().call_weight;
|
||||
let call_len = call.encoded_size() as u32;
|
||||
|
||||
T::WeightInfo::dispatch_whitelisted_call_with_preimage(call_len)
|
||||
.saturating_add(call_weight)
|
||||
})]
|
||||
pub fn dispatch_whitelisted_call_with_preimage(
|
||||
origin: OriginFor<T>,
|
||||
call: Box<<T as Config>::RuntimeCall>,
|
||||
) -> DispatchResultWithPostInfo {
|
||||
T::DispatchWhitelistedOrigin::ensure_origin(origin)?;
|
||||
|
||||
let call_hash = T::Hashing::hash_of(&call).into();
|
||||
|
||||
ensure!(
|
||||
WhitelistedCall::<T>::contains_key(call_hash),
|
||||
Error::<T>::CallIsNotWhitelisted,
|
||||
);
|
||||
|
||||
let call_len = call.encoded_size() as u32;
|
||||
let actual_weight = Self::clean_and_dispatch(call_hash, *call).map(|w| {
|
||||
w.saturating_add(T::WeightInfo::dispatch_whitelisted_call_with_preimage(call_len))
|
||||
});
|
||||
|
||||
Ok(actual_weight.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Clean whitelisting/preimage and dispatch call.
|
||||
///
|
||||
/// Return the call actual weight of the dispatched call if there is some.
|
||||
fn clean_and_dispatch(call_hash: T::Hash, call: <T as Config>::RuntimeCall) -> Option<Weight> {
|
||||
WhitelistedCall::<T>::remove(call_hash);
|
||||
|
||||
T::Preimages::unrequest(&call_hash);
|
||||
|
||||
let result = call.dispatch(pezframe_system::Origin::<T>::Root.into());
|
||||
|
||||
let call_actual_weight = match result {
|
||||
Ok(call_post_info) => call_post_info.actual_weight,
|
||||
Err(call_err) => call_err.post_info.actual_weight,
|
||||
};
|
||||
|
||||
Self::deposit_event(Event::<T>::WhitelistedCallDispatched { call_hash, result });
|
||||
|
||||
call_actual_weight
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Mock for Whitelist Pallet
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use crate as pezpallet_whitelist;
|
||||
|
||||
use frame::testing_prelude::*;
|
||||
type Block = MockBlock<Test>;
|
||||
|
||||
construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system,
|
||||
Balances: pezpallet_balances,
|
||||
Whitelist: pezpallet_whitelist,
|
||||
Preimage: pezpallet_preimage,
|
||||
}
|
||||
);
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type Block = Block;
|
||||
type AccountData = pezpallet_balances::AccountData<u64>;
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_balances::Config for Test {
|
||||
type AccountStore = System;
|
||||
}
|
||||
|
||||
impl pezpallet_preimage::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type Currency = Balances;
|
||||
type ManagerOrigin = EnsureRoot<Self::AccountId>;
|
||||
type Consideration = ();
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
impl pezpallet_whitelist::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
type WhitelistOrigin = EnsureRoot<Self::AccountId>;
|
||||
type DispatchWhitelistedOrigin = EnsureRoot<Self::AccountId>;
|
||||
type Preimages = Preimage;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> TestExternalities {
|
||||
let t = RuntimeGenesisConfig::default().build_storage().unwrap();
|
||||
let mut ext = TestExternalities::new(t);
|
||||
ext.execute_with(|| System::set_block_number(1));
|
||||
ext
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Tests for Whitelist Pallet
|
||||
|
||||
use crate::mock::*;
|
||||
use codec::Encode;
|
||||
use frame::{
|
||||
testing_prelude::*,
|
||||
traits::{QueryPreimage, StorePreimage},
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_whitelist_call_and_remove() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = RuntimeCall::System(pezframe_system::Call::remark { remark: vec![] });
|
||||
let encoded_call = call.encode();
|
||||
let call_hash = <Test as pezframe_system::Config>::Hashing::hash(&encoded_call[..]);
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::remove_whitelisted_call(RuntimeOrigin::root(), call_hash),
|
||||
crate::Error::<Test>::CallIsNotWhitelisted,
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::whitelist_call(RuntimeOrigin::signed(1), call_hash),
|
||||
DispatchError::BadOrigin,
|
||||
);
|
||||
|
||||
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
|
||||
|
||||
assert!(Preimage::is_requested(&call_hash));
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash),
|
||||
crate::Error::<Test>::CallAlreadyWhitelisted,
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::remove_whitelisted_call(RuntimeOrigin::signed(1), call_hash),
|
||||
DispatchError::BadOrigin,
|
||||
);
|
||||
|
||||
assert_ok!(Whitelist::remove_whitelisted_call(RuntimeOrigin::root(), call_hash));
|
||||
|
||||
assert!(!Preimage::is_requested(&call_hash));
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::remove_whitelisted_call(RuntimeOrigin::root(), call_hash),
|
||||
crate::Error::<Test>::CallIsNotWhitelisted,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_whitelist_call_and_execute() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = RuntimeCall::System(pezframe_system::Call::remark_with_event { remark: vec![1] });
|
||||
let call_weight = call.get_dispatch_info().call_weight;
|
||||
let encoded_call = call.encode();
|
||||
let call_encoded_len = encoded_call.len() as u32;
|
||||
let call_hash = <Test as pezframe_system::Config>::Hashing::hash(&encoded_call[..]);
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::root(),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight
|
||||
),
|
||||
crate::Error::<Test>::CallIsNotWhitelisted,
|
||||
);
|
||||
|
||||
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::signed(1),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight
|
||||
),
|
||||
DispatchError::BadOrigin,
|
||||
);
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::root(),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight
|
||||
),
|
||||
crate::Error::<Test>::UnavailablePreImage,
|
||||
);
|
||||
|
||||
assert_ok!(Preimage::note(encoded_call.into()));
|
||||
|
||||
assert!(Preimage::is_requested(&call_hash));
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::root(),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight - Weight::from_parts(1, 0)
|
||||
),
|
||||
crate::Error::<Test>::InvalidCallWeightWitness,
|
||||
);
|
||||
|
||||
assert_ok!(Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::root(),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight
|
||||
));
|
||||
|
||||
assert!(!Preimage::is_requested(&call_hash));
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::root(),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight
|
||||
),
|
||||
crate::Error::<Test>::CallIsNotWhitelisted,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_whitelist_call_and_execute_failing_call() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = RuntimeCall::Whitelist(crate::Call::dispatch_whitelisted_call {
|
||||
call_hash: Default::default(),
|
||||
call_encoded_len: Default::default(),
|
||||
call_weight_witness: Weight::zero(),
|
||||
});
|
||||
let call_weight = call.get_dispatch_info().call_weight;
|
||||
let encoded_call = call.encode();
|
||||
let call_encoded_len = encoded_call.len() as u32;
|
||||
let call_hash = <Test as pezframe_system::Config>::Hashing::hash(&encoded_call[..]);
|
||||
|
||||
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
|
||||
assert_ok!(Preimage::note(encoded_call.into()));
|
||||
assert!(Preimage::is_requested(&call_hash));
|
||||
assert_ok!(Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::root(),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight
|
||||
));
|
||||
assert!(!Preimage::is_requested(&call_hash));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_whitelist_call_and_execute_without_note_preimage() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = Box::new(RuntimeCall::System(pezframe_system::Call::remark_with_event {
|
||||
remark: vec![1],
|
||||
}));
|
||||
let call_hash = <Test as pezframe_system::Config>::Hashing::hash_of(&call);
|
||||
|
||||
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
|
||||
assert!(Preimage::is_requested(&call_hash));
|
||||
|
||||
assert_ok!(Whitelist::dispatch_whitelisted_call_with_preimage(
|
||||
RuntimeOrigin::root(),
|
||||
call.clone()
|
||||
));
|
||||
|
||||
assert!(!Preimage::is_requested(&call_hash));
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::dispatch_whitelisted_call_with_preimage(RuntimeOrigin::root(), call),
|
||||
crate::Error::<Test>::CallIsNotWhitelisted,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_whitelist_call_and_execute_decode_consumes_all() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let call = RuntimeCall::System(pezframe_system::Call::remark_with_event { remark: vec![1] });
|
||||
let call_weight = call.get_dispatch_info().call_weight;
|
||||
let mut call = call.encode();
|
||||
// Appending something does not make the encoded call invalid.
|
||||
// This tests that the decode function consumes all data.
|
||||
call.extend(call.clone());
|
||||
let call_encoded_len = call.len() as u32;
|
||||
|
||||
let call_hash = <Test as pezframe_system::Config>::Hashing::hash(&call[..]);
|
||||
|
||||
assert_ok!(Preimage::note(call.into()));
|
||||
assert_ok!(Whitelist::whitelist_call(RuntimeOrigin::root(), call_hash));
|
||||
|
||||
assert_noop!(
|
||||
Whitelist::dispatch_whitelisted_call(
|
||||
RuntimeOrigin::root(),
|
||||
call_hash,
|
||||
call_encoded_len,
|
||||
call_weight
|
||||
),
|
||||
crate::Error::<Test>::UndecodableCall,
|
||||
);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,226 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Autogenerated weights for `pezpallet_whitelist`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `4563561839a5`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// frame-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// --extrinsic=*
|
||||
// --runtime=target/production/wbuild/kitchensink-runtime/kitchensink_runtime.wasm
|
||||
// --pallet=pezpallet_whitelist
|
||||
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
|
||||
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/whitelist/src/weights.rs
|
||||
// --wasm-execution=compiled
|
||||
// --steps=50
|
||||
// --repeat=20
|
||||
// --heap-pages=4096
|
||||
// --template=bizinikiwi/.maintain/frame-weight-template.hbs
|
||||
// --no-storage-info
|
||||
// --no-min-squares
|
||||
// --no-median-slopes
|
||||
// --genesis-builder-policy=none
|
||||
// --exclude-pallets=pezpallet_xcm,pezpallet_xcm_benchmarks::fungible,pezpallet_xcm_benchmarks::generic,pezpallet_nomination_pools,pezpallet_remark,pezpallet_transaction_storage,pezpallet_election_provider_multi_block,pezpallet_election_provider_multi_block::signed,pezpallet_election_provider_multi_block::unsigned,pezpallet_election_provider_multi_block::verifier
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use frame::weights_prelude::*;
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for `pezpallet_whitelist`.
|
||||
pub trait WeightInfo {
|
||||
fn whitelist_call() -> Weight;
|
||||
fn remove_whitelisted_call() -> Weight;
|
||||
fn dispatch_whitelisted_call(n: u32, ) -> Weight;
|
||||
fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pezpallet_whitelist` using the Bizinikiwi node and recommended hardware.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
fn whitelist_call() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 12_978_000 picoseconds.
|
||||
Weight::from_parts(13_434_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
fn remove_whitelisted_call() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `45`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 12_959_000 picoseconds.
|
||||
Weight::from_parts(13_371_000, 3556)
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `Measured`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 4194294]`.
|
||||
fn dispatch_whitelisted_call(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `114 + n * (1 ±0)`
|
||||
// Estimated: `3578 + n * (1 ±0)`
|
||||
// Minimum execution time: 24_702_000 picoseconds.
|
||||
Weight::from_parts(25_001_000, 3578)
|
||||
// Standard Error: 259
|
||||
.saturating_add(Weight::from_parts(23_372, 0).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(4_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into()))
|
||||
}
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 10000]`.
|
||||
fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `45`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 16_083_000 picoseconds.
|
||||
Weight::from_parts(16_582_910, 3556)
|
||||
// Standard Error: 3
|
||||
.saturating_add(Weight::from_parts(1_325, 0).saturating_mul(n.into()))
|
||||
.saturating_add(T::DbWeight::get().reads(3_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(2_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
fn whitelist_call() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `0`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 12_978_000 picoseconds.
|
||||
Weight::from_parts(13_434_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
fn remove_whitelisted_call() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `45`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 12_959_000 picoseconds.
|
||||
Weight::from_parts(13_371_000, 3556)
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::PreimageFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `Measured`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 4194294]`.
|
||||
fn dispatch_whitelisted_call(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `114 + n * (1 ±0)`
|
||||
// Estimated: `3578 + n * (1 ±0)`
|
||||
// Minimum execution time: 24_702_000 picoseconds.
|
||||
Weight::from_parts(25_001_000, 3578)
|
||||
// Standard Error: 259
|
||||
.saturating_add(Weight::from_parts(23_372, 0).saturating_mul(n.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(4_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(3_u64))
|
||||
.saturating_add(Weight::from_parts(0, 1).saturating_mul(n.into()))
|
||||
}
|
||||
/// Storage: `Whitelist::WhitelistedCall` (r:1 w:1)
|
||||
/// Proof: `Whitelist::WhitelistedCall` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::StatusFor` (r:1 w:0)
|
||||
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// Storage: `Preimage::RequestStatusFor` (r:1 w:1)
|
||||
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
|
||||
/// The range of component `n` is `[1, 10000]`.
|
||||
fn dispatch_whitelisted_call_with_preimage(n: u32, ) -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `45`
|
||||
// Estimated: `3556`
|
||||
// Minimum execution time: 16_083_000 picoseconds.
|
||||
Weight::from_parts(16_582_910, 3556)
|
||||
// Standard Error: 3
|
||||
.saturating_add(Weight::from_parts(1_325, 0).saturating_mul(n.into()))
|
||||
.saturating_add(RocksDbWeight::get().reads(3_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(2_u64))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user