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,302 @@
|
||||
// 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.
|
||||
|
||||
// Benchmarks for System Extensions
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use alloc::vec;
|
||||
use pezframe_benchmarking::{account, v2::*, BenchmarkError};
|
||||
use pezframe_support::{
|
||||
dispatch::{DispatchClass, DispatchInfo, PostDispatchInfo},
|
||||
pezpallet_prelude::Zero,
|
||||
weights::Weight,
|
||||
};
|
||||
use pezframe_system::{
|
||||
pezpallet_prelude::*, CheckGenesis, CheckMortality, CheckNonZeroSender, CheckNonce,
|
||||
CheckSpecVersion, CheckTxVersion, CheckWeight, Config, ExtensionsWeightInfo, Pallet as System,
|
||||
RawOrigin, WeightReclaim,
|
||||
};
|
||||
use pezsp_runtime::{
|
||||
generic::Era,
|
||||
traits::{
|
||||
AsSystemOriginSigner, AsTransactionAuthorizedOrigin, DispatchTransaction, Dispatchable, Get,
|
||||
},
|
||||
};
|
||||
|
||||
pub struct Pallet<T: Config>(System<T>);
|
||||
|
||||
#[benchmarks(where
|
||||
T: Send + Sync,
|
||||
T::RuntimeCall: Dispatchable<Info = DispatchInfo, PostInfo = PostDispatchInfo>,
|
||||
<T::RuntimeCall as Dispatchable>::RuntimeOrigin: AsSystemOriginSigner<T::AccountId> + AsTransactionAuthorizedOrigin + Clone,
|
||||
)]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn check_genesis() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { call_weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
pezframe_benchmarking::benchmarking::add_to_whitelist(
|
||||
pezframe_system::BlockHash::<T>::hashed_key_for(BlockNumberFor::<T>::zero()).into(),
|
||||
);
|
||||
|
||||
#[block]
|
||||
{
|
||||
CheckGenesis::<T>::new()
|
||||
.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_mortality_mortal_transaction() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let ext = CheckMortality::<T>::from(Era::mortal(16, 256));
|
||||
let block_number: BlockNumberFor<T> = 17u32.into();
|
||||
System::<T>::set_block_number(block_number);
|
||||
let prev_block: BlockNumberFor<T> = 16u32.into();
|
||||
let default_hash: T::Hash = Default::default();
|
||||
pezframe_system::BlockHash::<T>::insert(prev_block, default_hash);
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo {
|
||||
call_weight: Weight::from_parts(100, 0),
|
||||
class: DispatchClass::Normal,
|
||||
..Default::default()
|
||||
};
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
pezframe_benchmarking::benchmarking::add_to_whitelist(
|
||||
pezframe_system::BlockHash::<T>::hashed_key_for(prev_block).into(),
|
||||
);
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_mortality_immortal_transaction() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let ext = CheckMortality::<T>::from(Era::immortal());
|
||||
let block_number: BlockNumberFor<T> = 17u32.into();
|
||||
System::<T>::set_block_number(block_number);
|
||||
let prev_block: BlockNumberFor<T> = 16u32.into();
|
||||
let default_hash: T::Hash = Default::default();
|
||||
pezframe_system::BlockHash::<T>::insert(prev_block, default_hash);
|
||||
let genesis_block: BlockNumberFor<T> = 0u32.into();
|
||||
pezframe_system::BlockHash::<T>::insert(genesis_block, default_hash);
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo {
|
||||
call_weight: Weight::from_parts(100, 0),
|
||||
class: DispatchClass::Normal,
|
||||
..Default::default()
|
||||
};
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
pezframe_benchmarking::benchmarking::add_to_whitelist(
|
||||
pezframe_system::BlockHash::<T>::hashed_key_for(BlockNumberFor::<T>::zero()).into(),
|
||||
);
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_non_zero_sender() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let ext = CheckNonZeroSender::<T>::new();
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { call_weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_nonce() -> Result<(), BenchmarkError> {
|
||||
let caller: T::AccountId = account("caller", 0, 0);
|
||||
let mut info = pezframe_system::AccountInfo::default();
|
||||
info.nonce = 1u32.into();
|
||||
info.providers = 1;
|
||||
let expected_nonce = info.nonce + 1u32.into();
|
||||
pezframe_system::Account::<T>::insert(caller.clone(), info);
|
||||
let len = 0_usize;
|
||||
let ext = CheckNonce::<T>::from(1u32.into());
|
||||
let info = DispatchInfo { call_weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller.clone()).into(), &call, &info, len, 0, |_| {
|
||||
Ok(().into())
|
||||
})
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let updated_info = pezframe_system::Account::<T>::get(caller.clone());
|
||||
assert_eq!(updated_info.nonce, expected_nonce);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_spec_version() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { call_weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
CheckSpecVersion::<T>::new()
|
||||
.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_tx_version() -> Result<(), BenchmarkError> {
|
||||
let len = 0_usize;
|
||||
let caller = account("caller", 0, 0);
|
||||
let info = DispatchInfo { call_weight: Weight::zero(), ..Default::default() };
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
|
||||
#[block]
|
||||
{
|
||||
CheckTxVersion::<T>::new()
|
||||
.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(().into()))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn check_weight() -> Result<(), BenchmarkError> {
|
||||
let caller = account("caller", 0, 0);
|
||||
let base_extrinsic = <T as pezframe_system::Config>::BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.base_extrinsic;
|
||||
let extension_weight = <T as pezframe_system::Config>::ExtensionsWeightInfo::check_weight();
|
||||
let info = DispatchInfo {
|
||||
call_weight: Weight::from_parts(base_extrinsic.ref_time() * 5, 0),
|
||||
extension_weight,
|
||||
class: DispatchClass::Normal,
|
||||
..Default::default()
|
||||
};
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
let post_info = PostDispatchInfo {
|
||||
actual_weight: Some(Weight::from_parts(base_extrinsic.ref_time() * 2, 0)),
|
||||
pays_fee: Default::default(),
|
||||
};
|
||||
let len = 0_usize;
|
||||
let base_extrinsic = <T as pezframe_system::Config>::BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.base_extrinsic;
|
||||
|
||||
let ext = CheckWeight::<T>::new();
|
||||
|
||||
let initial_block_weight = Weight::from_parts(base_extrinsic.ref_time() * 2, 0);
|
||||
pezframe_system::BlockWeight::<T>::mutate(|current_weight| {
|
||||
current_weight.set(Weight::zero(), DispatchClass::Mandatory);
|
||||
current_weight.set(initial_block_weight, DispatchClass::Normal);
|
||||
});
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(post_info))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
System::<T>::block_weight().total(),
|
||||
initial_block_weight +
|
||||
base_extrinsic +
|
||||
post_info.actual_weight.unwrap().saturating_add(extension_weight),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn weight_reclaim() -> Result<(), BenchmarkError> {
|
||||
let caller = account("caller", 0, 0);
|
||||
let base_extrinsic = <T as pezframe_system::Config>::BlockWeights::get()
|
||||
.get(DispatchClass::Normal)
|
||||
.base_extrinsic;
|
||||
let extension_weight = <T as pezframe_system::Config>::ExtensionsWeightInfo::weight_reclaim();
|
||||
let info = DispatchInfo {
|
||||
call_weight: Weight::from_parts(base_extrinsic.ref_time() * 5, 0),
|
||||
extension_weight,
|
||||
class: DispatchClass::Normal,
|
||||
..Default::default()
|
||||
};
|
||||
let call: T::RuntimeCall = pezframe_system::Call::remark { remark: vec![] }.into();
|
||||
let post_info = PostDispatchInfo {
|
||||
actual_weight: Some(Weight::from_parts(base_extrinsic.ref_time() * 2, 0)),
|
||||
pays_fee: Default::default(),
|
||||
};
|
||||
let len = 0_usize;
|
||||
let ext = WeightReclaim::<T>::new();
|
||||
|
||||
let initial_block_weight = Weight::from_parts(base_extrinsic.ref_time() * 2, 0);
|
||||
pezframe_system::BlockWeight::<T>::mutate(|current_weight| {
|
||||
current_weight.set(Weight::zero(), DispatchClass::Mandatory);
|
||||
current_weight.set(initial_block_weight, DispatchClass::Normal);
|
||||
current_weight.accrue(base_extrinsic + info.total_weight(), DispatchClass::Normal);
|
||||
});
|
||||
|
||||
#[block]
|
||||
{
|
||||
ext.test_run(RawOrigin::Signed(caller).into(), &call, &info, len, 0, |_| Ok(post_info))
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
assert_eq!(
|
||||
System::<T>::block_weight().total(),
|
||||
initial_block_weight +
|
||||
base_extrinsic +
|
||||
post_info.actual_weight.unwrap().saturating_add(extension_weight),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test,);
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
// 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.
|
||||
|
||||
//! Frame System benchmarks.
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
use codec::Encode;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::{dispatch::DispatchClass, storage, traits::Get};
|
||||
use pezframe_system::{Call, Pallet as System, RawOrigin};
|
||||
use pezsp_core::storage::well_known_keys;
|
||||
use pezsp_runtime::traits::Hash;
|
||||
|
||||
pub struct Pallet<T: Config>(System<T>);
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Adds ability to the Runtime to test against their sample code.
|
||||
///
|
||||
/// Default is `../res/kitchensink_runtime.compact.compressed.wasm`.
|
||||
fn prepare_set_code_data() -> Vec<u8> {
|
||||
include_bytes!("../res/kitchensink_runtime.compact.compressed.wasm").to_vec()
|
||||
}
|
||||
|
||||
/// Adds ability to the Runtime to prepare/initialize before running benchmark `set_code`.
|
||||
fn setup_set_code_requirements(_code: &Vec<u8>) -> Result<(), BenchmarkError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Adds ability to the Runtime to do custom validation after benchmark.
|
||||
///
|
||||
/// Default is checking for `CodeUpdated` event .
|
||||
fn verify_set_code() {
|
||||
System::<Self>::assert_last_event(pezframe_system::Event::<Self>::CodeUpdated.into());
|
||||
}
|
||||
}
|
||||
|
||||
#[benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn remark(
|
||||
b: Linear<0, { *T::BlockLength::get().max.get(DispatchClass::Normal) as u32 }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let remark_message = vec![1; b as usize];
|
||||
let caller = whitelisted_caller();
|
||||
|
||||
#[extrinsic_call]
|
||||
remark(RawOrigin::Signed(caller), remark_message);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn remark_with_event(
|
||||
b: Linear<0, { *T::BlockLength::get().max.get(DispatchClass::Normal) as u32 }>,
|
||||
) -> Result<(), BenchmarkError> {
|
||||
let remark_message = vec![1; b as usize];
|
||||
let caller: T::AccountId = whitelisted_caller();
|
||||
let hash = T::Hashing::hash(&remark_message[..]);
|
||||
|
||||
#[extrinsic_call]
|
||||
remark_with_event(RawOrigin::Signed(caller.clone()), remark_message);
|
||||
|
||||
System::<T>::assert_last_event(
|
||||
pezframe_system::Event::<T>::Remarked { sender: caller, hash }.into(),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn set_heap_pages() -> Result<(), BenchmarkError> {
|
||||
#[extrinsic_call]
|
||||
set_heap_pages(RawOrigin::Root, Default::default());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn set_code() -> Result<(), BenchmarkError> {
|
||||
let runtime_blob = T::prepare_set_code_data();
|
||||
T::setup_set_code_requirements(&runtime_blob)?;
|
||||
|
||||
#[extrinsic_call]
|
||||
set_code(RawOrigin::Root, runtime_blob);
|
||||
|
||||
T::verify_set_code();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark(extra)]
|
||||
fn set_code_without_checks() -> Result<(), BenchmarkError> {
|
||||
// Assume Wasm ~4MB
|
||||
let code = vec![1; 4_000_000 as usize];
|
||||
T::setup_set_code_requirements(&code)?;
|
||||
|
||||
#[block]
|
||||
{
|
||||
System::<T>::set_code_without_checks(RawOrigin::Root.into(), code)?;
|
||||
}
|
||||
|
||||
let current_code =
|
||||
storage::unhashed::get_raw(well_known_keys::CODE).ok_or("Code not stored.")?;
|
||||
assert_eq!(current_code.len(), 4_000_000 as usize);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark(skip_meta)]
|
||||
fn set_storage(i: Linear<0, { 1_000 }>) -> Result<(), BenchmarkError> {
|
||||
// Set up i items to add
|
||||
let mut items = Vec::new();
|
||||
for j in 0..i {
|
||||
let hash = (i, j).using_encoded(T::Hashing::hash).as_ref().to_vec();
|
||||
items.push((hash.clone(), hash.clone()));
|
||||
}
|
||||
|
||||
let items_to_verify = items.clone();
|
||||
|
||||
#[extrinsic_call]
|
||||
set_storage(RawOrigin::Root, items);
|
||||
|
||||
// Verify that they're actually in the storage.
|
||||
for (item, _) in items_to_verify {
|
||||
let value = storage::unhashed::get_raw(&item).ok_or("No value stored")?;
|
||||
assert_eq!(value, *item);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark(skip_meta)]
|
||||
fn kill_storage(i: Linear<0, { 1_000 }>) -> Result<(), BenchmarkError> {
|
||||
// Add i items to storage
|
||||
let mut items = Vec::with_capacity(i as usize);
|
||||
for j in 0..i {
|
||||
let hash = (i, j).using_encoded(T::Hashing::hash).as_ref().to_vec();
|
||||
storage::unhashed::put_raw(&hash, &hash);
|
||||
items.push(hash);
|
||||
}
|
||||
|
||||
// Verify that they're actually in the storage.
|
||||
for item in &items {
|
||||
let value = storage::unhashed::get_raw(item).ok_or("No value stored")?;
|
||||
assert_eq!(value, *item);
|
||||
}
|
||||
|
||||
let items_to_verify = items.clone();
|
||||
|
||||
#[extrinsic_call]
|
||||
kill_storage(RawOrigin::Root, items);
|
||||
|
||||
// Verify that they're not in the storage anymore.
|
||||
for item in items_to_verify {
|
||||
assert!(storage::unhashed::get_raw(&item).is_none());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark(skip_meta)]
|
||||
fn kill_prefix(p: Linear<0, { 1_000 }>) -> Result<(), BenchmarkError> {
|
||||
let prefix = p.using_encoded(T::Hashing::hash).as_ref().to_vec();
|
||||
let mut items = Vec::with_capacity(p as usize);
|
||||
// add p items that share a prefix
|
||||
for i in 0..p {
|
||||
let hash = (p, i).using_encoded(T::Hashing::hash).as_ref().to_vec();
|
||||
let key = [&prefix[..], &hash[..]].concat();
|
||||
storage::unhashed::put_raw(&key, &key);
|
||||
items.push(key);
|
||||
}
|
||||
|
||||
// Verify that they're actually in the storage.
|
||||
for item in &items {
|
||||
let value = storage::unhashed::get_raw(item).ok_or("No value stored")?;
|
||||
assert_eq!(value, *item);
|
||||
}
|
||||
|
||||
#[extrinsic_call]
|
||||
kill_prefix(RawOrigin::Root, prefix, p);
|
||||
|
||||
// Verify that they're not in the storage anymore.
|
||||
for item in items {
|
||||
assert!(storage::unhashed::get_raw(&item).is_none());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn authorize_upgrade() -> Result<(), BenchmarkError> {
|
||||
let runtime_blob = T::prepare_set_code_data();
|
||||
T::setup_set_code_requirements(&runtime_blob)?;
|
||||
let hash = T::Hashing::hash(&runtime_blob);
|
||||
|
||||
#[extrinsic_call]
|
||||
authorize_upgrade(RawOrigin::Root, hash);
|
||||
|
||||
assert_eq!(System::<T>::authorized_upgrade().unwrap().code_hash(), &hash);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn apply_authorized_upgrade() -> Result<(), BenchmarkError> {
|
||||
let runtime_blob = T::prepare_set_code_data();
|
||||
T::setup_set_code_requirements(&runtime_blob)?;
|
||||
let hash = T::Hashing::hash(&runtime_blob);
|
||||
// Will be heavier when it needs to do verification (i.e. don't use `...without_checks`).
|
||||
System::<T>::authorize_upgrade(RawOrigin::Root.into(), hash)?;
|
||||
|
||||
#[extrinsic_call]
|
||||
apply_authorized_upgrade(RawOrigin::Root, runtime_blob);
|
||||
|
||||
// Can't check for `CodeUpdated` in teyrchain upgrades. Just check that the authorization is
|
||||
// gone.
|
||||
assert!(System::<T>::authorized_upgrade().is_none());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 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.
|
||||
|
||||
//! Frame System benchmarks.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
pub mod extensions;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub mod inner;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub use inner::*;
|
||||
|
||||
#[cfg(all(feature = "runtime-benchmarks", test))]
|
||||
pub(crate) mod mock;
|
||||
@@ -0,0 +1,107 @@
|
||||
// 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 file for system benchmarking.
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use codec::Encode;
|
||||
use pezframe_support::{derive_impl, weights::Weight};
|
||||
use pezsp_runtime::BuildStorage;
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system,
|
||||
}
|
||||
);
|
||||
|
||||
pub struct MockWeights;
|
||||
impl pezframe_system::ExtensionsWeightInfo for MockWeights {
|
||||
fn check_genesis() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn check_mortality_mortal_transaction() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn check_mortality_immortal_transaction() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn check_non_zero_sender() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn check_nonce() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn check_spec_version() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn check_tx_version() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn check_weight() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
|
||||
fn weight_reclaim() -> Weight {
|
||||
Weight::from_parts(10, 0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type Block = Block;
|
||||
type ExtensionsWeightInfo = MockWeights;
|
||||
}
|
||||
|
||||
impl crate::Config for Test {}
|
||||
|
||||
struct MockedReadRuntimeVersion(Vec<u8>);
|
||||
|
||||
impl pezsp_core::traits::ReadRuntimeVersion for MockedReadRuntimeVersion {
|
||||
fn read_runtime_version(
|
||||
&self,
|
||||
_wasm_code: &[u8],
|
||||
_ext: &mut dyn pezsp_externalities::Externalities,
|
||||
) -> Result<Vec<u8>, String> {
|
||||
Ok(self.0.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
|
||||
let version = pezsp_version::RuntimeVersion {
|
||||
spec_name: "spec_name".into(),
|
||||
spec_version: 123,
|
||||
impl_version: 456,
|
||||
..Default::default()
|
||||
};
|
||||
let read_runtime_version = MockedReadRuntimeVersion(version.encode());
|
||||
let mut ext = pezsp_io::TestExternalities::new(t);
|
||||
ext.register_extension(pezsp_core::traits::ReadRuntimeVersionExt::new(read_runtime_version));
|
||||
ext
|
||||
}
|
||||
Reference in New Issue
Block a user