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,48 @@
|
||||
[package]
|
||||
name = "pezpallet-example-mbm"
|
||||
version = "0.1.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Example FRAME pallet for multi-block migrations"
|
||||
publish = false
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { workspace = true }
|
||||
pezframe-benchmarking = { optional = true, workspace = true }
|
||||
pezframe-support = { workspace = true }
|
||||
pezframe-system = { workspace = true }
|
||||
log = { workspace = true }
|
||||
pezpallet-migrations = { workspace = true }
|
||||
scale-info = { workspace = true }
|
||||
pezsp-io = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezframe-benchmarking?/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"log/std",
|
||||
"pezpallet-migrations/std",
|
||||
"scale-info/std",
|
||||
"pezsp-io/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-benchmarking/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-migrations/runtime-benchmarks",
|
||||
"pezsp-io/runtime-benchmarks",
|
||||
]
|
||||
try-runtime = [
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezpallet-migrations/try-runtime",
|
||||
]
|
||||
@@ -0,0 +1,87 @@
|
||||
// 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.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
//! # Multi-Block Migrations Example Pallet
|
||||
//!
|
||||
//! This pallet serves as a minimal example of a pallet that uses the [Multi-Block Migrations
|
||||
//! Framework](pezframe_support::migrations). You can observe how to configure it in a runtime in the
|
||||
//! `kitchensink-runtime` crate.
|
||||
//!
|
||||
//! ## Introduction and Purpose
|
||||
//!
|
||||
//! The primary purpose of this pallet is to demonstrate the concept of Multi-Block Migrations in
|
||||
//! Bizinikiwi. It showcases the migration of values from in the
|
||||
//! [`MyMap`](`pallet::MyMap`) storage map a `u32` to a `u64` data type using the
|
||||
//! [`SteppedMigration`](`pezframe_support::migrations::SteppedMigration`) implementation from the
|
||||
//! [`migrations::v1`] module.
|
||||
//!
|
||||
//! The [`MyMap`](`pallet::MyMap`) storage item is defined in this `pallet`, and is
|
||||
//! aliased to [`v0::MyMap`](`migrations::v1::v0::MyMap`) in the [`migrations::v1`]
|
||||
//! module.
|
||||
//!
|
||||
//! ## How to Read the Documentation
|
||||
//!
|
||||
//! To access and navigate this documentation in your browser, use the following command:
|
||||
//!
|
||||
//! - `cargo doc --package pezpallet-example-mbm --open`
|
||||
//!
|
||||
//! This documentation is organized to help you understand the pallet's components, features, and
|
||||
//! migration process.
|
||||
//!
|
||||
//! ## Example Usage
|
||||
//!
|
||||
//! To use this pallet and understand multi-block migrations, you can refer to the
|
||||
//! [`migrations::v1`] module, which contains a step-by-step migration example.
|
||||
//!
|
||||
//! ## Pallet Structure
|
||||
//!
|
||||
//! The pallet is structured as follows:
|
||||
//!
|
||||
//! - [`migrations`]: Contains migration-related modules and migration logic.
|
||||
//! - [`v1`](`migrations::v1`): Demonstrates the migration process for changing the data type in
|
||||
//! the storage map.
|
||||
//! - [`pallet`]: Defines the pallet configuration and storage items.
|
||||
//!
|
||||
//! ## Migration Safety
|
||||
//!
|
||||
//! When working with migrations, it's crucial to ensure the safety of your migrations. The
|
||||
//! preferred tool to test migrations is
|
||||
//! [`try-runtime-cli`](https://github.com/paritytech/try-runtime-cli). Support will be added to
|
||||
//! dry-run MBMs once they are stable
|
||||
//! (tracked: <https://github.com/pezkuwichain/kurdistan-sdk/issues/190>).
|
||||
|
||||
pub mod migrations;
|
||||
mod mock;
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
use pezframe_support::{pezpallet_prelude::StorageMap, Blake2_128Concat};
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {}
|
||||
|
||||
/// Define a storage item to illustrate multi-block migrations.
|
||||
#[pallet::storage]
|
||||
pub type MyMap<T: Config> = StorageMap<_, Blake2_128Concat, u32, u64>;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
/// # Multi-Block Migrations Module
|
||||
///
|
||||
/// This module showcases a simple use of the multi-block migrations framework.
|
||||
pub mod v1;
|
||||
|
||||
/// A unique identifier across all pallets.
|
||||
///
|
||||
/// This constant represents a unique identifier for the migrations of this pallet.
|
||||
/// It helps differentiate migrations for this pallet from those of others. Note that we don't
|
||||
/// directly pull the crate name from the environment, since that would change if the crate were
|
||||
/// ever to be renamed and could cause historic migrations to run again.
|
||||
pub const PALLET_MIGRATIONS_ID: &[u8; 18] = b"pezpallet-example-mbm";
|
||||
@@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
//! Benchmark the multi-block-migration.
|
||||
|
||||
#![cfg(feature = "runtime-benchmarks")]
|
||||
|
||||
use crate::{
|
||||
migrations::{
|
||||
v1,
|
||||
v1::{weights, weights::WeightInfo},
|
||||
},
|
||||
Config, Pallet,
|
||||
};
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::{migrations::SteppedMigration, weights::WeightMeter};
|
||||
|
||||
#[benchmarks]
|
||||
mod benches {
|
||||
use super::*;
|
||||
|
||||
/// Benchmark a single step of the `v1::LazyMigrationV1` migration.
|
||||
#[benchmark]
|
||||
fn step() {
|
||||
v1::v0::MyMap::<T>::insert(0, 0);
|
||||
let mut meter = WeightMeter::new();
|
||||
|
||||
#[block]
|
||||
{
|
||||
v1::LazyMigrationV1::<T, weights::BizinikiwiWeight<T>>::step(None, &mut meter).unwrap();
|
||||
}
|
||||
|
||||
// Check that the new storage is decodable:
|
||||
assert_eq!(crate::MyMap::<T>::get(0), Some(0));
|
||||
// uses twice the weight once for migration and then for checking if there is another key.
|
||||
assert_eq!(meter.consumed(), weights::BizinikiwiWeight::<T>::step() * 2);
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Runtime);
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
// 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.
|
||||
|
||||
//! # Multi-Block Migration v1
|
||||
//!
|
||||
//! This module showcases a simple migration that iterates over the values in the
|
||||
//! [`v0::MyMap`](`crate::migrations::v1::v0::MyMap`) storage map, transforms them,
|
||||
//! and inserts them into the [`MyMap`](`crate::pallet::MyMap`) storage map.
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
use super::PALLET_MIGRATIONS_ID;
|
||||
use crate::pallet::{Config, MyMap};
|
||||
use pezframe_support::{
|
||||
migrations::{MigrationId, SteppedMigration, SteppedMigrationError},
|
||||
pezpallet_prelude::PhantomData,
|
||||
weights::WeightMeter,
|
||||
};
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use alloc::collections::btree_map::BTreeMap;
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
use alloc::vec::Vec;
|
||||
|
||||
mod benchmarks;
|
||||
mod tests;
|
||||
pub mod weights;
|
||||
|
||||
/// Module containing the OLD (v0) storage items.
|
||||
///
|
||||
/// Before running this migration, the storage alias defined here represents the
|
||||
/// `on_chain` storage.
|
||||
// This module is public only for the purposes of linking it in the documentation. It is not
|
||||
// intended to be used by any other code.
|
||||
pub mod v0 {
|
||||
use super::Config;
|
||||
use crate::pallet::Pallet;
|
||||
use pezframe_support::{storage_alias, Blake2_128Concat};
|
||||
|
||||
#[storage_alias]
|
||||
/// The storage item that is being migrated from.
|
||||
pub type MyMap<T: Config> = StorageMap<Pallet<T>, Blake2_128Concat, u32, u32>;
|
||||
}
|
||||
|
||||
/// Migrates the items of the [`crate::MyMap`] map from `u32` to `u64`.
|
||||
///
|
||||
/// The `step` function will be called once per block. It is very important that this function
|
||||
/// *never* panics and never uses more weight than it got in its meter. The migrations should also
|
||||
/// try to make maximal progress per step, so that the total time it takes to migrate stays low.
|
||||
pub struct LazyMigrationV1<T: Config, W: weights::WeightInfo>(PhantomData<(T, W)>);
|
||||
impl<T: Config, W: weights::WeightInfo> SteppedMigration for LazyMigrationV1<T, W> {
|
||||
type Cursor = u32;
|
||||
// Without the explicit length here the construction of the ID would not be infallible.
|
||||
type Identifier = MigrationId<18>;
|
||||
|
||||
/// The identifier of this migration. Which should be globally unique.
|
||||
fn id() -> Self::Identifier {
|
||||
MigrationId { pezpallet_id: *PALLET_MIGRATIONS_ID, version_from: 0, version_to: 1 }
|
||||
}
|
||||
|
||||
/// The actual logic of the migration.
|
||||
///
|
||||
/// This function is called repeatedly until it returns `Ok(None)`, indicating that the
|
||||
/// migration is complete. Ideally, the migration should be designed in such a way that each
|
||||
/// step consumes as much weight as possible. However, this is simplified to perform one stored
|
||||
/// value mutation per block.
|
||||
fn step(
|
||||
mut cursor: Option<Self::Cursor>,
|
||||
meter: &mut WeightMeter,
|
||||
) -> Result<Option<Self::Cursor>, SteppedMigrationError> {
|
||||
let required = W::step();
|
||||
// If there is not enough weight for a single step, return an error. This case can be
|
||||
// problematic if it is the first migration that ran in this block. But there is nothing
|
||||
// that we can do about it here.
|
||||
if meter.remaining().any_lt(required) {
|
||||
return Err(SteppedMigrationError::InsufficientWeight { required });
|
||||
}
|
||||
|
||||
// We loop here to do as much progress as possible per step.
|
||||
loop {
|
||||
if meter.try_consume(required).is_err() {
|
||||
break;
|
||||
}
|
||||
|
||||
let mut iter = if let Some(last_key) = cursor {
|
||||
// If a cursor is provided, start iterating from the stored value
|
||||
// corresponding to the last key processed in the previous step.
|
||||
// Note that this only works if the old and the new map use the same way to hash
|
||||
// storage keys.
|
||||
v0::MyMap::<T>::iter_from(v0::MyMap::<T>::hashed_key_for(last_key))
|
||||
} else {
|
||||
// If no cursor is provided, start iterating from the beginning.
|
||||
v0::MyMap::<T>::iter()
|
||||
};
|
||||
|
||||
// If there's a next item in the iterator, perform the migration.
|
||||
if let Some((last_key, value)) = iter.next() {
|
||||
// Migrate the inner value: u32 -> u64.
|
||||
let value = value as u64;
|
||||
// We can just insert here since the old and the new map share the same key-space.
|
||||
// Otherwise it would have to invert the concat hash function and re-hash it.
|
||||
MyMap::<T>::insert(last_key, value);
|
||||
cursor = Some(last_key) // Return the processed key as the new cursor.
|
||||
} else {
|
||||
cursor = None; // Signal that the migration is complete (no more items to process).
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(cursor)
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, pezframe_support::pezsp_runtime::TryRuntimeError> {
|
||||
use codec::Encode;
|
||||
|
||||
// Return the state of the storage before the migration.
|
||||
Ok(v0::MyMap::<T>::iter().collect::<BTreeMap<_, _>>().encode())
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(prev: Vec<u8>) -> Result<(), pezframe_support::pezsp_runtime::TryRuntimeError> {
|
||||
use codec::Decode;
|
||||
|
||||
// Check the state of the storage after the migration.
|
||||
let prev_map = BTreeMap::<u32, u32>::decode(&mut &prev[..])
|
||||
.expect("Failed to decode the previous storage state");
|
||||
|
||||
// Check the len of prev and post are the same.
|
||||
assert_eq!(
|
||||
MyMap::<T>::iter().count(),
|
||||
prev_map.len(),
|
||||
"Migration failed: the number of items in the storage after the migration is not the same as before"
|
||||
);
|
||||
|
||||
for (key, value) in prev_map {
|
||||
let new_value =
|
||||
MyMap::<T>::get(key).expect("Failed to get the value after the migration");
|
||||
assert_eq!(
|
||||
value as u64, new_value,
|
||||
"Migration failed: the value after the migration is not the same as before"
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// 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.
|
||||
|
||||
#![cfg(all(test, not(feature = "runtime-benchmarks")))]
|
||||
|
||||
use crate::{
|
||||
migrations::{
|
||||
v1,
|
||||
v1::{weights, weights::WeightInfo as _},
|
||||
},
|
||||
mock::{
|
||||
new_test_ext, run_to_block, AllPalletsWithSystem, MigratorServiceWeight, Runtime as T,
|
||||
System,
|
||||
},
|
||||
};
|
||||
use codec::Decode;
|
||||
use pezframe_support::traits::OnRuntimeUpgrade;
|
||||
use pezpallet_migrations::WeightInfo as _;
|
||||
|
||||
#[test]
|
||||
fn lazy_migration_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
pezframe_support::__private::pezsp_tracing::try_init_simple();
|
||||
// Insert some values into the old storage map.
|
||||
for i in 0..1024 {
|
||||
v1::v0::MyMap::<T>::insert(i, i);
|
||||
}
|
||||
|
||||
// Give it enough weight do do exactly 16 iterations:
|
||||
let limit = <T as pezpallet_migrations::Config>::WeightInfo::progress_mbms_none() +
|
||||
pezpallet_migrations::Pallet::<T>::exec_migration_max_weight() +
|
||||
weights::BizinikiwiWeight::<T>::step() * 16;
|
||||
MigratorServiceWeight::set(&limit);
|
||||
|
||||
System::set_block_number(1);
|
||||
AllPalletsWithSystem::on_runtime_upgrade(); // onboard MBMs
|
||||
|
||||
let mut last_decodable = 0;
|
||||
for block in 2..=65 {
|
||||
run_to_block(block);
|
||||
|
||||
let mut decodable = 0;
|
||||
for i in 0..1024 {
|
||||
let key = crate::MyMap::<T>::hashed_key_for(i);
|
||||
let value =
|
||||
pezframe_support::storage::unhashed::get_raw(&key[..]).expect("value exists");
|
||||
|
||||
if let Ok(value) = u64::decode(&mut &value[..]) {
|
||||
assert_eq!(value, i as u64);
|
||||
decodable += 1;
|
||||
} else {
|
||||
assert_eq!(u32::decode(&mut &value[..]).expect("not migrated yet"), i);
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(decodable, last_decodable + 16);
|
||||
last_decodable = decodable;
|
||||
}
|
||||
|
||||
// Check that everything is decodable now:
|
||||
for i in 0..1024 {
|
||||
assert_eq!(crate::MyMap::<T>::get(i), Some(i as u64));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// 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_example_mbm`
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE BIZINIKIWI BENCHMARK CLI VERSION 32.0.0
|
||||
//! DATE: 2024-03-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! WORST CASE MAP SIZE: `1000000`
|
||||
//! HOSTNAME: `Olivers-MBP`, CPU: `<UNKNOWN>`
|
||||
//! WASM-EXECUTION: `Compiled`, CHAIN: `None`, DB CACHE: `1024`
|
||||
|
||||
// Executed Command:
|
||||
// pezkuwi-omni-bencher
|
||||
// v1
|
||||
// benchmark
|
||||
// pallet
|
||||
// --runtime
|
||||
// target/release/wbuild/kitchensink-runtime/kitchensink_runtime.compact.compressed.wasm
|
||||
// --pallet
|
||||
// pezpallet_example_mbm
|
||||
// --extrinsic
|
||||
//
|
||||
// --template
|
||||
// bizinikiwi/.maintain/frame-weight-template.hbs
|
||||
// --output
|
||||
// bizinikiwi/pezframe/examples/multi-block-migrations/src/migrations/weights.rs
|
||||
|
||||
#![cfg_attr(rustfmt, rustfmt_skip)]
|
||||
#![allow(unused_parens)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(missing_docs)]
|
||||
|
||||
use pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for `pezpallet_example_mbm`.
|
||||
pub trait WeightInfo {
|
||||
fn step() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pezpallet_example_mbm` using the Bizinikiwi node and recommended hardware.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
/// Storage: `PalletExampleMbms::MyMap` (r:2 w:1)
|
||||
/// Proof: `PalletExampleMbms::MyMap` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
|
||||
fn step() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `28`
|
||||
// Estimated: `5996`
|
||||
// Minimum execution time: 6_000_000 picoseconds.
|
||||
Weight::from_parts(8_000_000, 5996)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `PalletExampleMbms::MyMap` (r:2 w:1)
|
||||
/// Proof: `PalletExampleMbms::MyMap` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
|
||||
fn step() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `28`
|
||||
// Estimated: `5996`
|
||||
// Minimum execution time: 6_000_000 picoseconds.
|
||||
Weight::from_parts(8_000_000, 5996)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// 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.
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
//! # Mock runtime for testing Multi-Block-Migrations
|
||||
//!
|
||||
//! This runtime is for testing only and should *never* be used in production. Please see the
|
||||
//! comments on the specific config items. The core part of this runtime is the
|
||||
//! [`pezpallet_migrations::Config`] implementation, where you define the migrations you want to run
|
||||
//! using the [`Migrations`] type.
|
||||
|
||||
use pezframe_support::{
|
||||
construct_runtime, derive_impl, migrations::MultiStepMigrator, pezpallet_prelude::Weight,
|
||||
};
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Runtime>;
|
||||
|
||||
impl crate::Config for Runtime {}
|
||||
|
||||
pezframe_support::parameter_types! {
|
||||
pub storage MigratorServiceWeight: Weight = Weight::from_parts(100, 100); // do not use in prod
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_migrations::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_migrations::Config for Runtime {
|
||||
// Here we inject the actual MBMs. Currently there is just one, but it accepts a tuple.
|
||||
//
|
||||
// # Example
|
||||
// ```ignore
|
||||
// type Migrations = (v1::Migration<Runtime>, v2::Migration<Runtime>, v3::Migration<Runtime>);
|
||||
// ```
|
||||
#[cfg(not(feature = "runtime-benchmarks"))]
|
||||
type Migrations = (
|
||||
crate::migrations::v1::LazyMigrationV1<
|
||||
Runtime,
|
||||
crate::migrations::v1::weights::BizinikiwiWeight<Runtime>,
|
||||
>,
|
||||
);
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
type Migrations = pezpallet_migrations::mock_helpers::MockedMigrations;
|
||||
type MaxServiceWeight = MigratorServiceWeight;
|
||||
}
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Runtime {
|
||||
type Block = Block;
|
||||
type MultiBlockMigrator = Migrator;
|
||||
}
|
||||
|
||||
// Construct the runtime using the `construct_runtime` macro, specifying the pezpallet_migrations.
|
||||
construct_runtime! {
|
||||
pub struct Runtime
|
||||
{
|
||||
System: pezframe_system,
|
||||
Pallet: crate,
|
||||
Migrator: pezpallet_migrations,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
pezsp_io::TestExternalities::new(Default::default())
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn run_to_block(n: u64) {
|
||||
System::run_to_block_with::<AllPalletsWithSystem>(
|
||||
n,
|
||||
pezframe_system::RunToBlockHooks::default().after_initialize(|_| {
|
||||
// Done by Executive:
|
||||
<Runtime as pezframe_system::Config>::MultiBlockMigrator::step();
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
// 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_example_mbm`
|
||||
//!
|
||||
//! 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_example_mbm
|
||||
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/HEADER-APACHE2
|
||||
// --output=/__w/pezkuwi-sdk/pezkuwi-sdk/bizinikiwi/pezframe/examples/multi-block-migrations/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 pezframe_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
|
||||
use core::marker::PhantomData;
|
||||
|
||||
/// Weight functions needed for `pezpallet_example_mbm`.
|
||||
pub trait WeightInfo {
|
||||
fn step() -> Weight;
|
||||
}
|
||||
|
||||
/// Weights for `pezpallet_example_mbm` using the Bizinikiwi node and recommended hardware.
|
||||
pub struct BizinikiwiWeight<T>(PhantomData<T>);
|
||||
impl<T: pezframe_system::Config> WeightInfo for BizinikiwiWeight<T> {
|
||||
/// Storage: `PalletExampleMbms::MyMap` (r:2 w:1)
|
||||
/// Proof: `PalletExampleMbms::MyMap` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
|
||||
fn step() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `28`
|
||||
// Estimated: `5996`
|
||||
// Minimum execution time: 6_832_000 picoseconds.
|
||||
Weight::from_parts(7_201_000, 5996)
|
||||
.saturating_add(T::DbWeight::get().reads(2_u64))
|
||||
.saturating_add(T::DbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
|
||||
// For backwards compatibility and tests.
|
||||
impl WeightInfo for () {
|
||||
/// Storage: `PalletExampleMbms::MyMap` (r:2 w:1)
|
||||
/// Proof: `PalletExampleMbms::MyMap` (`max_values`: None, `max_size`: Some(28), added: 2503, mode: `MaxEncodedLen`)
|
||||
fn step() -> Weight {
|
||||
// Proof Size summary in bytes:
|
||||
// Measured: `28`
|
||||
// Estimated: `5996`
|
||||
// Minimum execution time: 6_832_000 picoseconds.
|
||||
Weight::from_parts(7_201_000, 5996)
|
||||
.saturating_add(RocksDbWeight::get().reads(2_u64))
|
||||
.saturating_add(RocksDbWeight::get().writes(1_u64))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user