feat: initialize Kurdistan SDK - independent fork of Polkadot SDK

This commit is contained in:
2025-12-13 15:44:15 +03:00
commit e4778b4576
6838 changed files with 1847450 additions and 0 deletions
+179
View File
@@ -0,0 +1,179 @@
[package]
name = "pezkuwi-runtime-common"
version = "7.0.0"
description = "Pallets and constants used in Relay Chain networks."
authors.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
[lints]
workspace = true
[dependencies]
bitvec = { features = ["alloc"], workspace = true }
codec = { features = ["derive"], workspace = true }
impl-trait-for-tuples = { workspace = true }
log = { workspace = true }
rustc-hex = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
serde = { features = ["alloc"], workspace = true }
static_assertions = { workspace = true, default-features = true }
sp-api = { workspace = true }
sp-core = { features = ["serde"], workspace = true }
sp-inherents = { workspace = true }
sp-io = { workspace = true }
sp-keyring = { workspace = true }
sp-npos-elections = { features = ["serde"], workspace = true }
sp-runtime = { features = ["serde"], workspace = true }
sp-session = { workspace = true }
sp-staking = { features = ["serde"], workspace = true }
frame-election-provider-support = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-asset-rate = { optional = true, workspace = true }
pallet-authorship = { workspace = true }
pallet-balances = { workspace = true }
pallet-broker = { workspace = true }
pallet-election-provider-multi-phase = { workspace = true }
pallet-fast-unstake = { workspace = true }
pallet-identity = { workspace = true }
pallet-session = { workspace = true }
pallet-staking = { workspace = true }
pallet-staking-reward-fn = { workspace = true }
pallet-timestamp = { workspace = true }
pallet-transaction-payment = { workspace = true }
pallet-treasury = { workspace = true }
pallet-vesting = { workspace = true }
frame-benchmarking = { optional = true, workspace = true }
pallet-babe = { optional = true, workspace = true }
libsecp256k1 = { workspace = true }
pezkuwi-primitives = { workspace = true }
pezkuwi-runtime-teyrchains = { workspace = true }
slot-range-helper = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { optional = true, workspace = true }
[dev-dependencies]
frame-support-test = { workspace = true }
hex-literal = { workspace = true, default-features = true }
libsecp256k1 = { workspace = true, default-features = true }
pallet-babe = { workspace = true, default-features = true }
pallet-treasury = { workspace = true, default-features = true }
pezkuwi-primitives-test-helpers = { workspace = true }
serde_json = { workspace = true, default-features = true }
sp-keyring = { workspace = true, default-features = true }
sp-keystore = { workspace = true, default-features = true }
[features]
default = ["std"]
no_std = []
std = [
"bitvec/std",
"codec/std",
"frame-benchmarking?/std",
"frame-election-provider-support/std",
"frame-support/std",
"frame-system/std",
"libsecp256k1/std",
"log/std",
"pallet-asset-rate?/std",
"pallet-authorship/std",
"pallet-babe?/std",
"pallet-balances/std",
"pallet-broker/std",
"pallet-election-provider-multi-phase/std",
"pallet-fast-unstake/std",
"pallet-identity/std",
"pallet-session/std",
"pallet-staking-reward-fn/std",
"pallet-staking/std",
"pallet-timestamp/std",
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-vesting/std",
"pezkuwi-primitives/std",
"pezkuwi-runtime-teyrchains/std",
"rustc-hex/std",
"scale-info/std",
"serde/std",
"slot-range-helper/std",
"sp-api/std",
"sp-core/std",
"sp-inherents/std",
"sp-io/std",
"sp-npos-elections/std",
"sp-runtime/std",
"sp-session/std",
"sp-staking/std",
"xcm-builder/std",
"xcm-executor/std",
"xcm/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-election-provider-support/runtime-benchmarks",
"frame-support-test/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"libsecp256k1/hmac",
"libsecp256k1/static-context",
"pallet-asset-rate/runtime-benchmarks",
"pallet-authorship/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-broker/runtime-benchmarks",
"pallet-election-provider-multi-phase/runtime-benchmarks",
"pallet-fast-unstake/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-session/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"pezkuwi-primitives-test-helpers/runtime-benchmarks",
"pezkuwi-primitives/runtime-benchmarks",
"pezkuwi-runtime-teyrchains/runtime-benchmarks",
"slot-range-helper/runtime-benchmarks",
"sp-api/runtime-benchmarks",
"sp-inherents/runtime-benchmarks",
"sp-io/runtime-benchmarks",
"sp-keyring/runtime-benchmarks",
"sp-npos-elections/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-session/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
try-runtime = [
"frame-election-provider-support/try-runtime",
"frame-support-test/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-asset-rate/try-runtime",
"pallet-authorship/try-runtime",
"pallet-babe?/try-runtime",
"pallet-balances/try-runtime",
"pallet-broker/try-runtime",
"pallet-election-provider-multi-phase/try-runtime",
"pallet-fast-unstake/try-runtime",
"pallet-identity/try-runtime",
"pallet-session/try-runtime",
"pallet-staking/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"pallet-vesting/try-runtime",
"pezkuwi-runtime-teyrchains/try-runtime",
"sp-runtime/try-runtime",
]
@@ -0,0 +1,23 @@
[package]
name = "slot-range-helper"
version = "7.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
description = "Helper crate for generating slot ranges for the Pezkuwi runtime."
homepage.workspace = true
repository.workspace = true
[lints]
workspace = true
[dependencies]
codec = { features = ["derive"], workspace = true }
enumn = { workspace = true }
paste = { workspace = true, default-features = true }
sp-runtime = { workspace = true }
[features]
default = ["std"]
std = ["codec/std", "sp-runtime/std"]
runtime-benchmarks = ["sp-runtime/runtime-benchmarks"]
@@ -0,0 +1,290 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! A helper macro for generating `SlotRange` enum.
#![cfg_attr(not(feature = "std"), no_std)]
pub use codec::{Decode, Encode};
pub use core::{ops::Add, result};
pub use enumn::N;
pub use paste;
pub use sp_runtime::traits::CheckedSub;
/// This macro generates a `SlotRange` enum of arbitrary length for use in the Slot Auction
/// mechanism on Pezkuwi.
///
/// Usage:
/// ```
/// slot_range_helper::generate_slot_range!(Zero(0), One(1), Two(2), Three(3));
/// ```
///
/// To extend the usage, continue to add `Identifier(value)` items to the macro.
///
/// This will generate an enum `SlotRange` with the following properties:
///
/// * Enum variants will range from all consecutive combinations of inputs, i.e. `ZeroZero`,
/// `ZeroOne`, `ZeroTwo`, `ZeroThree`, `OneOne`, `OneTwo`, `OneThree`...
/// * A constant `LEASE_PERIODS_PER_SLOT` will count the number of lease periods.
/// * A constant `SLOT_RANGE_COUNT` will count the total number of enum variants.
/// * A function `as_pair` will return a tuple representation of the `SlotRange`.
/// * A function `intersects` will tell you if two slot ranges intersect with one another.
/// * A function `len` will tell you the length of occupying a `SlotRange`.
/// * A function `new_bounded` will generate a `SlotRange` from an input of the current lease
/// period, the starting lease period, and the final lease period.
#[macro_export]
macro_rules! generate_slot_range{
// Entry point
($( $x:ident ( $e:expr ) ),*) => {
$crate::generate_lease_period_per_slot!( $( $x )* );
$crate::generate_slot_range!(@inner
{ }
$( $x ( $e ) )*
);
};
// Does the magic...
(@inner
{ $( $parsed:ident ( $t1:expr, $t2:expr ) )* }
$current:ident ( $ce:expr )
$( $remaining:ident ( $re:expr ) )*
) => {
$crate::paste::paste! {
$crate::generate_slot_range!(@inner
{
$( $parsed ( $t1, $t2 ) )*
[< $current $current >] ( $ce, $ce )
$( [< $current $remaining >] ($ce, $re) )*
}
$( $remaining ( $re ) )*
);
}
};
(@inner
{ $( $parsed:ident ( $t1:expr, $t2:expr ) )* }
) => {
$crate::generate_slot_range_enum!(@inner $( $parsed )* );
$crate::generate_slot_range_count!( $( $parsed )* );
#[cfg(feature = "std")]
impl std::fmt::Debug for SlotRange {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
let p = self.as_pair();
write!(fmt, "[{}..{}]", p.0, p.1)
}
}
impl SlotRange {
pub const LEASE_PERIODS_PER_SLOT: usize = LEASE_PERIODS_PER_SLOT;
pub const SLOT_RANGE_COUNT: usize = SLOT_RANGE_COUNT;
$crate::generate_slot_range_as_pair!(@inner $( $parsed ( $t1, $t2 ) )* );
$crate::generate_slot_range_len!(@inner $( $parsed ( $t1, $t2 ) )* );
$crate::generate_slot_range_new_bounded!(@inner $( $parsed ( $t1, $t2 ) )* );
}
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! generate_slot_range_enum {
(@inner
$( $parsed:ident )*
) => {
/// A compactly represented sub-range from the series.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, $crate::Encode, $crate::Decode, $crate::N)]
#[repr(u8)]
pub enum SlotRange { $( $parsed ),* }
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! generate_slot_range_as_pair {
(@inner
$( $parsed:ident ( $t1:expr, $t2:expr ) )*
) => {
/// Return true if two `SlotRange` intersect in their lease periods.
pub fn intersects(&self, other: SlotRange) -> bool {
let a = self.as_pair();
let b = other.as_pair();
b.0 <= a.1 && a.0 <= b.1
// == !(b.0 > a.1 || a.0 > b.1)
}
/// Return a tuple representation of the `SlotRange`.
///
/// Example:`SlotRange::OneTwo.as_pair() == (1, 2)`
pub fn as_pair(&self) -> (u8, u8) {
match self {
$( SlotRange::$parsed => { ($t1, $t2) } )*
}
}
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! generate_slot_range_len {
// Use evaluated length in function.
(@inner
$( $parsed:ident ( $t1:expr, $t2:expr ) )*
) => {
/// Return the length of occupying a `SlotRange`.
///
/// Example:`SlotRange::OneTwo.len() == 2`
pub fn len(&self) -> usize {
match self {
// len (0, 2) = 2 - 0 + 1 = 3
$( SlotRange::$parsed => { ( $t2 - $t1 + 1) } )*
}
}
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! generate_slot_range_new_bounded {
(@inner
$( $parsed:ident ( $t1:expr, $t2:expr ) )*
) => {
/// Construct a `SlotRange` from the current lease period, the first lease period of the range,
/// and the last lease period of the range.
///
/// For example: `SlotRange::new_bounded(1, 2, 3) == SlotRange::OneTwo`.
pub fn new_bounded<
Index: $crate::Add<Output=Index> + $crate::CheckedSub + Copy + Ord + From<u32> + TryInto<u32>
>(
current: Index,
first: Index,
last: Index
) -> $crate::result::Result<Self, &'static str> {
if first > last || first < current || last >= current + (LEASE_PERIODS_PER_SLOT as u32).into() {
return Err("Invalid range for this auction")
}
let count: u32 = last.checked_sub(&first)
.ok_or("range ends before it begins")?
.try_into()
.map_err(|_| "range too big")?;
let first: u32 = first.checked_sub(&current)
.ok_or("range begins too early")?
.try_into()
.map_err(|_| "start too far")?;
match (first, first + count) {
$( ($t1, $t2) => { Ok(SlotRange::$parsed) })*
_ => Err("bad range"),
}
}
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! generate_slot_range_count {
(
$start:ident $( $rest:ident )*
) => {
$crate::generate_slot_range_count!(@inner 1; $( $rest )*);
};
(@inner
$count:expr;
$start:ident $( $rest:ident )*
) => {
$crate::generate_slot_range_count!(@inner $count + 1; $( $rest )*);
};
(@inner
$count:expr;
) => {
const SLOT_RANGE_COUNT: usize = $count;
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! generate_lease_period_per_slot {
(
$start:ident $( $rest:ident )*
) => {
$crate::generate_lease_period_per_slot!(@inner 1; $( $rest )*);
};
(@inner
$count:expr;
$start:ident $( $rest:ident )*
) => {
$crate::generate_lease_period_per_slot!(@inner $count + 1; $( $rest )*);
};
(@inner
$count:expr;
) => {
const LEASE_PERIODS_PER_SLOT: usize = $count;
};
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn slot_range_4_works() {
generate_slot_range!(Zero(0), One(1), Two(2), Three(3));
assert_eq!(SlotRange::LEASE_PERIODS_PER_SLOT, 4);
// Sum over n from 0 - 4
assert_eq!(SlotRange::SLOT_RANGE_COUNT, 10);
assert_eq!(SlotRange::new_bounded(0u32, 1u32, 2u32).unwrap(), SlotRange::OneTwo);
assert_eq!(SlotRange::new_bounded(5u32, 6u32, 7u32).unwrap(), SlotRange::OneTwo);
assert!(SlotRange::new_bounded(10u32, 6u32, 7u32).is_err());
assert!(SlotRange::new_bounded(10u32, 16u32, 17u32).is_err());
assert!(SlotRange::new_bounded(10u32, 11u32, 10u32).is_err());
assert_eq!(SlotRange::TwoTwo.len(), 1);
assert_eq!(SlotRange::OneTwo.len(), 2);
assert_eq!(SlotRange::ZeroThree.len(), 4);
assert!(SlotRange::ZeroOne.intersects(SlotRange::OneThree));
assert!(!SlotRange::ZeroOne.intersects(SlotRange::TwoThree));
assert_eq!(SlotRange::ZeroZero.as_pair(), (0, 0));
assert_eq!(SlotRange::OneThree.as_pair(), (1, 3));
}
#[test]
fn slot_range_8_works() {
generate_slot_range!(Zero(0), One(1), Two(2), Three(3), Four(4), Five(5), Six(6), Seven(7));
assert_eq!(SlotRange::LEASE_PERIODS_PER_SLOT, 8);
// Sum over n from 0 to 8
assert_eq!(SlotRange::SLOT_RANGE_COUNT, 36);
assert_eq!(SlotRange::new_bounded(0u32, 1u32, 2u32).unwrap(), SlotRange::OneTwo);
assert_eq!(SlotRange::new_bounded(5u32, 6u32, 7u32).unwrap(), SlotRange::OneTwo);
assert!(SlotRange::new_bounded(10u32, 6u32, 7u32).is_err());
// This one passes with slot range 8
assert_eq!(SlotRange::new_bounded(10u32, 16u32, 17u32).unwrap(), SlotRange::SixSeven);
assert!(SlotRange::new_bounded(10u32, 17u32, 18u32).is_err());
assert!(SlotRange::new_bounded(10u32, 20u32, 21u32).is_err());
assert!(SlotRange::new_bounded(10u32, 11u32, 10u32).is_err());
assert_eq!(SlotRange::TwoTwo.len(), 1);
assert_eq!(SlotRange::OneTwo.len(), 2);
assert_eq!(SlotRange::ZeroThree.len(), 4);
assert_eq!(SlotRange::ZeroSeven.len(), 8);
assert!(SlotRange::ZeroOne.intersects(SlotRange::OneThree));
assert!(!SlotRange::ZeroOne.intersects(SlotRange::TwoThree));
assert!(SlotRange::FiveSix.intersects(SlotRange::SixSeven));
assert!(!SlotRange::ThreeFive.intersects(SlotRange::SixSeven));
assert_eq!(SlotRange::ZeroZero.as_pair(), (0, 0));
assert_eq!(SlotRange::OneThree.as_pair(), (1, 3));
assert_eq!(SlotRange::SixSeven.as_pair(), (6, 7));
}
}
@@ -0,0 +1,160 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for assigned_slots pallet
#![cfg(feature = "runtime-benchmarks")]
use super::*;
use frame_benchmarking::v2::*;
use frame_support::assert_ok;
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use pezkuwi_primitives::Id as ParaId;
use sp_runtime::traits::Bounded;
type CurrencyOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency;
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;
#[benchmarks(where T: Config)]
mod benchmarks {
use super::*;
use crate::assigned_slots::Pallet as AssignedSlots;
fn register_teyrchain<T: Config>(para_id: ParaId) {
let who: T::AccountId = whitelisted_caller();
let worst_validation_code = T::Registrar::worst_validation_code();
let worst_head_data = T::Registrar::worst_head_data();
CurrencyOf::<T>::make_free_balance_be(&who, BalanceOf::<T>::max_value());
assert_ok!(T::Registrar::register(
who,
para_id,
worst_head_data,
worst_validation_code.clone()
));
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
worst_validation_code,
));
T::Registrar::execute_pending_transitions();
}
#[benchmark]
fn assign_perm_teyrchain_slot() {
let para_id = ParaId::from(1_u32);
let caller = RawOrigin::Root;
let _ =
AssignedSlots::<T>::set_max_permanent_slots(frame_system::Origin::<T>::Root.into(), 10);
register_teyrchain::<T>(para_id);
let counter = PermanentSlotCount::<T>::get();
let current_lease_period: BlockNumberFor<T> =
T::Leaser::lease_period_index(frame_system::Pallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap();
#[extrinsic_call]
assign_perm_teyrchain_slot(caller, para_id);
assert_eq!(
PermanentSlots::<T>::get(para_id),
Some((
current_lease_period,
LeasePeriodOf::<T>::from(T::PermanentSlotLeasePeriodLength::get()),
))
);
assert_eq!(PermanentSlotCount::<T>::get(), counter + 1);
}
#[benchmark]
fn assign_temp_teyrchain_slot() {
let para_id = ParaId::from(2_u32);
let caller = RawOrigin::Root;
let _ =
AssignedSlots::<T>::set_max_temporary_slots(frame_system::Origin::<T>::Root.into(), 10);
register_teyrchain::<T>(para_id);
let current_lease_period: BlockNumberFor<T> =
T::Leaser::lease_period_index(frame_system::Pallet::<T>::block_number())
.and_then(|x| Some(x.0))
.unwrap();
let counter = TemporarySlotCount::<T>::get();
#[extrinsic_call]
assign_temp_teyrchain_slot(caller, para_id, SlotLeasePeriodStart::Current);
let tmp = TeyrchainTemporarySlot {
manager: whitelisted_caller(),
period_begin: current_lease_period,
period_count: LeasePeriodOf::<T>::from(T::TemporarySlotLeasePeriodLength::get()),
last_lease: Some(BlockNumberFor::<T>::zero()),
lease_count: 1,
};
assert_eq!(TemporarySlots::<T>::get(para_id), Some(tmp));
assert_eq!(TemporarySlotCount::<T>::get(), counter + 1);
}
#[benchmark]
fn unassign_teyrchain_slot() {
let para_id = ParaId::from(3_u32);
let caller = RawOrigin::Root;
let _ =
AssignedSlots::<T>::set_max_temporary_slots(frame_system::Origin::<T>::Root.into(), 10);
register_teyrchain::<T>(para_id);
let _ = AssignedSlots::<T>::assign_temp_teyrchain_slot(
caller.clone().into(),
para_id,
SlotLeasePeriodStart::Current,
);
let counter = TemporarySlotCount::<T>::get();
#[extrinsic_call]
unassign_teyrchain_slot(caller, para_id);
assert_eq!(TemporarySlots::<T>::get(para_id), None);
assert_eq!(TemporarySlotCount::<T>::get(), counter - 1);
}
#[benchmark]
fn set_max_permanent_slots() {
let caller = RawOrigin::Root;
#[extrinsic_call]
set_max_permanent_slots(caller, u32::MAX);
assert_eq!(MaxPermanentSlots::<T>::get(), u32::MAX);
}
#[benchmark]
fn set_max_temporary_slots() {
let caller = RawOrigin::Root;
#[extrinsic_call]
set_max_temporary_slots(caller, u32::MAX);
assert_eq!(MaxTemporarySlots::<T>::get(), u32::MAX);
}
impl_benchmark_test_suite!(
AssignedSlots,
crate::assigned_slots::tests::new_test_ext(),
crate::assigned_slots::tests::Test,
);
}
@@ -0,0 +1,72 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::{Config, MaxPermanentSlots, MaxTemporarySlots, Pallet, LOG_TARGET};
use frame_support::traits::{Get, GetStorageVersion, UncheckedOnRuntimeUpgrade};
#[cfg(feature = "try-runtime")]
use alloc::vec::Vec;
#[cfg(feature = "try-runtime")]
use frame_support::ensure;
pub mod v1 {
use super::*;
pub struct VersionUncheckedMigrateToV1<T>(core::marker::PhantomData<T>);
impl<T: Config> UncheckedOnRuntimeUpgrade for VersionUncheckedMigrateToV1<T> {
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
ensure!(on_chain_version < 1, "assigned_slots::MigrateToV1 migration can be deleted");
Ok(Default::default())
}
fn on_runtime_upgrade() -> frame_support::weights::Weight {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
if on_chain_version < 1 {
const MAX_PERMANENT_SLOTS: u32 = 100;
const MAX_TEMPORARY_SLOTS: u32 = 100;
MaxPermanentSlots::<T>::put(MAX_PERMANENT_SLOTS);
MaxTemporarySlots::<T>::put(MAX_TEMPORARY_SLOTS);
// Return the weight consumed by the migration.
T::DbWeight::get().reads_writes(1, 3)
} else {
log::info!(target: LOG_TARGET, "MigrateToV1 should be removed");
T::DbWeight::get().reads(1)
}
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
ensure!(on_chain_version == 1, "assigned_slots::MigrateToV1 needs to be run");
assert_eq!(MaxPermanentSlots::<T>::get(), 100);
assert_eq!(MaxTemporarySlots::<T>::get(), 100);
Ok(())
}
}
/// [`VersionUncheckedMigrateToV1`] wrapped in a
/// [`VersionedMigration`](frame_support::migrations::VersionedMigration), ensuring the
/// migration is only performed when on-chain version is 0.
pub type MigrateToV1<T> = frame_support::migrations::VersionedMigration<
0,
1,
VersionUncheckedMigrateToV1<T>,
Pallet<T>,
<T as frame_system::Config>::DbWeight,
>;
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,282 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for auctions pallet
#![cfg(feature = "runtime-benchmarks")]
use super::{Pallet as Auctions, *};
use frame_support::{
assert_ok,
traits::{EnsureOrigin, OnInitialize},
};
use frame_system::RawOrigin;
use pezkuwi_runtime_teyrchains::paras;
use sp_runtime::{traits::Bounded, SaturatedConversion};
use frame_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
fn fill_winners<T: Config + paras::Config>(lease_period_index: LeasePeriodOf<T>) {
let auction_index = AuctionCounter::<T>::get();
let minimum_balance = CurrencyOf::<T>::minimum_balance();
for n in 1..=SlotRange::SLOT_RANGE_COUNT as u32 {
let owner = account("owner", n, 0);
let worst_validation_code = T::Registrar::worst_validation_code();
let worst_head_data = T::Registrar::worst_head_data();
CurrencyOf::<T>::make_free_balance_be(&owner, BalanceOf::<T>::max_value());
assert!(T::Registrar::register(
owner,
ParaId::from(n),
worst_head_data,
worst_validation_code
)
.is_ok());
}
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
T::Registrar::worst_validation_code(),
));
T::Registrar::execute_pending_transitions();
for n in 1..=SlotRange::SLOT_RANGE_COUNT as u32 {
let bidder = account("bidder", n, 0);
CurrencyOf::<T>::make_free_balance_be(&bidder, BalanceOf::<T>::max_value());
let slot_range = SlotRange::n((n - 1) as u8).unwrap();
let (start, end) = slot_range.as_pair();
assert!(Auctions::<T>::bid(
RawOrigin::Signed(bidder).into(),
ParaId::from(n),
auction_index,
lease_period_index + start.into(), // First Slot
lease_period_index + end.into(), // Last slot
minimum_balance.saturating_mul(n.into()), // Amount
)
.is_ok());
}
}
#[benchmarks(
where T: pallet_babe::Config + paras::Config,
)]
mod benchmarks {
use super::*;
#[benchmark]
fn new_auction() -> Result<(), BenchmarkError> {
let duration = BlockNumberFor::<T>::max_value();
let lease_period_index = LeasePeriodOf::<T>::max_value();
let origin =
T::InitiateOrigin::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
#[extrinsic_call]
_(origin as T::RuntimeOrigin, duration, lease_period_index);
assert_last_event::<T>(
Event::<T>::AuctionStarted {
auction_index: AuctionCounter::<T>::get(),
lease_period: LeasePeriodOf::<T>::max_value(),
ending: BlockNumberFor::<T>::max_value(),
}
.into(),
);
Ok(())
}
// Worst case scenario a new bid comes in which kicks out an existing bid for the same slot.
#[benchmark]
fn bid() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
let (_, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration = BlockNumberFor::<T>::max_value();
let lease_period_index = LeasePeriodOf::<T>::zero();
let origin = T::InitiateOrigin::try_successful_origin()
.expect("InitiateOrigin has no successful origin required for the benchmark");
Auctions::<T>::new_auction(origin, duration, lease_period_index)?;
let para = ParaId::from(0);
let new_para = ParaId::from(1_u32);
// Register the paras
let owner = account("owner", 0, 0);
CurrencyOf::<T>::make_free_balance_be(&owner, BalanceOf::<T>::max_value());
let worst_head_data = T::Registrar::worst_head_data();
let worst_validation_code = T::Registrar::worst_validation_code();
T::Registrar::register(
owner.clone(),
para,
worst_head_data.clone(),
worst_validation_code.clone(),
)?;
T::Registrar::register(owner, new_para, worst_head_data, worst_validation_code.clone())?;
assert_ok!(paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
worst_validation_code,
));
T::Registrar::execute_pending_transitions();
// Make an existing bid
let auction_index = AuctionCounter::<T>::get();
let first_slot = AuctionInfo::<T>::get().unwrap().0;
let last_slot = first_slot + 3u32.into();
let first_amount = CurrencyOf::<T>::minimum_balance();
let first_bidder: T::AccountId = account("first_bidder", 0, 0);
CurrencyOf::<T>::make_free_balance_be(&first_bidder, BalanceOf::<T>::max_value());
Auctions::<T>::bid(
RawOrigin::Signed(first_bidder.clone()).into(),
para,
auction_index,
first_slot,
last_slot,
first_amount,
)?;
let caller: T::AccountId = whitelisted_caller();
CurrencyOf::<T>::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
let bigger_amount = CurrencyOf::<T>::minimum_balance().saturating_mul(10u32.into());
assert_eq!(CurrencyOf::<T>::reserved_balance(&first_bidder), first_amount);
#[extrinsic_call]
_(
RawOrigin::Signed(caller.clone()),
new_para,
auction_index,
first_slot,
last_slot,
bigger_amount,
);
// Confirms that we unreserved funds from a previous bidder, which is worst case
// scenario.
assert_eq!(CurrencyOf::<T>::reserved_balance(&caller), bigger_amount);
Ok(())
}
// Worst case: 10 bidders taking all wining spots, and we need to calculate the winner for
// auction end. Entire winner map should be full and removed at the end of the benchmark.
#[benchmark]
fn on_initialize() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
let (lease_length, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration: BlockNumberFor<T> = lease_length / 2u32.into();
let lease_period_index = LeasePeriodOf::<T>::zero();
let now = frame_system::Pallet::<T>::block_number();
let origin = T::InitiateOrigin::try_successful_origin()
.expect("InitiateOrigin has no successful origin required for the benchmark");
Auctions::<T>::new_auction(origin, duration, lease_period_index)?;
fill_winners::<T>(lease_period_index);
for winner in Winning::<T>::get(BlockNumberFor::<T>::from(0u32)).unwrap().iter() {
assert!(winner.is_some());
}
let winning_data = Winning::<T>::get(BlockNumberFor::<T>::from(0u32)).unwrap();
// Make winning map full
for i in 0u32..(T::EndingPeriod::get() / T::SampleLength::get()).saturated_into() {
Winning::<T>::insert(BlockNumberFor::<T>::from(i), winning_data.clone());
}
// Move ahead to the block we want to initialize
frame_system::Pallet::<T>::set_block_number(duration + now + T::EndingPeriod::get());
// Trigger epoch change for new random number value:
{
pallet_babe::EpochStart::<T>::set((Zero::zero(), u32::MAX.into()));
pallet_babe::Pallet::<T>::on_initialize(duration + now + T::EndingPeriod::get());
let authorities = pallet_babe::Pallet::<T>::authorities();
// Check for non empty authority set since it otherwise emits a No-OP warning.
if !authorities.is_empty() {
pallet_babe::Pallet::<T>::enact_epoch_change(
authorities.clone(),
authorities,
None,
);
}
}
#[block]
{
Auctions::<T>::on_initialize(duration + now + T::EndingPeriod::get());
}
let auction_index = AuctionCounter::<T>::get();
assert_last_event::<T>(Event::<T>::AuctionClosed { auction_index }.into());
assert!(Winning::<T>::iter().count().is_zero());
Ok(())
}
// Worst case: 10 bidders taking all wining spots, and winning data is full.
#[benchmark]
fn cancel_auction() -> Result<(), BenchmarkError> {
// If there is an offset, we need to be on that block to be able to do lease things.
let (lease_length, offset) = T::Leaser::lease_period_length();
frame_system::Pallet::<T>::set_block_number(offset + One::one());
// Create a new auction
let duration: BlockNumberFor<T> = lease_length / 2u32.into();
let lease_period_index = LeasePeriodOf::<T>::zero();
let origin = T::InitiateOrigin::try_successful_origin()
.expect("InitiateOrigin has no successful origin required for the benchmark");
Auctions::<T>::new_auction(origin, duration, lease_period_index)?;
fill_winners::<T>(lease_period_index);
let winning_data = Winning::<T>::get(BlockNumberFor::<T>::from(0u32)).unwrap();
for winner in winning_data.iter() {
assert!(winner.is_some());
}
// Make winning map full
for i in 0u32..(T::EndingPeriod::get() / T::SampleLength::get()).saturated_into() {
Winning::<T>::insert(BlockNumberFor::<T>::from(i), winning_data.clone());
}
assert!(AuctionInfo::<T>::get().is_some());
#[extrinsic_call]
_(RawOrigin::Root);
assert!(AuctionInfo::<T>::get().is_none());
Ok(())
}
impl_benchmark_test_suite!(
Auctions,
crate::integration_tests::new_test_ext(),
crate::integration_tests::Test,
);
}
+246
View File
@@ -0,0 +1,246 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in auctions pallet.
#[cfg(test)]
use super::*;
use crate::{auctions, mock::TestRegistrar};
use frame_support::{
assert_ok, derive_impl, ord_parameter_types, parameter_types, traits::EitherOfDiverse,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
use pallet_balances;
use pezkuwi_primitives::{BlockNumber, Id as ParaId};
use pezkuwi_primitives_test_helpers::{dummy_head_data, dummy_validation_code};
use sp_core::H256;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};
use std::{cell::RefCell, collections::BTreeMap};
type Block = frame_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Auctions: auctions,
}
);
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type AccountStore = System;
}
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug)]
pub struct LeaseData {
pub leaser: u64,
pub amount: u64,
}
thread_local! {
pub static LEASES:
RefCell<BTreeMap<(ParaId, BlockNumber), LeaseData>> = RefCell::new(BTreeMap::new());
}
pub fn leases() -> Vec<((ParaId, BlockNumber), LeaseData)> {
LEASES.with(|p| (&*p.borrow()).clone().into_iter().collect::<Vec<_>>())
}
pub struct TestLeaser;
impl Leaser<BlockNumber> for TestLeaser {
type AccountId = u64;
type LeasePeriod = BlockNumber;
type Currency = Balances;
fn lease_out(
para: ParaId,
leaser: &Self::AccountId,
amount: <Self::Currency as Currency<Self::AccountId>>::Balance,
period_begin: Self::LeasePeriod,
period_count: Self::LeasePeriod,
) -> Result<(), LeaseError> {
LEASES.with(|l| {
let mut leases = l.borrow_mut();
let now = System::block_number();
let (current_lease_period, _) =
Self::lease_period_index(now).ok_or(LeaseError::NoLeasePeriod)?;
if period_begin < current_lease_period {
return Err(LeaseError::AlreadyEnded);
}
for period in period_begin..(period_begin + period_count) {
if leases.contains_key(&(para, period)) {
return Err(LeaseError::AlreadyLeased);
}
leases.insert((para, period), LeaseData { leaser: *leaser, amount });
}
Ok(())
})
}
fn deposit_held(
para: ParaId,
leaser: &Self::AccountId,
) -> <Self::Currency as Currency<Self::AccountId>>::Balance {
leases()
.iter()
.filter_map(|((id, _period), data)| {
if id == &para && &data.leaser == leaser {
Some(data.amount)
} else {
None
}
})
.max()
.unwrap_or_default()
}
fn lease_period_length() -> (BlockNumber, BlockNumber) {
(10, 0)
}
fn lease_period_index(b: BlockNumber) -> Option<(Self::LeasePeriod, bool)> {
let (lease_period_length, offset) = Self::lease_period_length();
let b = b.checked_sub(offset)?;
let lease_period = b / lease_period_length;
let first_block = (b % lease_period_length).is_zero();
Some((lease_period, first_block))
}
fn already_leased(
para_id: ParaId,
first_period: Self::LeasePeriod,
last_period: Self::LeasePeriod,
) -> bool {
leases().into_iter().any(|((para, period), _data)| {
para == para_id && first_period <= period && period <= last_period
})
}
}
ord_parameter_types! {
pub const Six: u64 = 6;
}
type RootOrSix = EitherOfDiverse<EnsureRoot<u64>, EnsureSignedBy<Six, u64>>;
thread_local! {
pub static LAST_RANDOM: RefCell<Option<(H256, u32)>> = RefCell::new(None);
}
pub fn set_last_random(output: H256, known_since: u32) {
LAST_RANDOM.with(|p| *p.borrow_mut() = Some((output, known_since)))
}
pub struct TestPastRandomness;
impl Randomness<H256, BlockNumber> for TestPastRandomness {
fn random(_subject: &[u8]) -> (H256, u32) {
LAST_RANDOM.with(|p| {
if let Some((output, known_since)) = &*p.borrow() {
(*output, *known_since)
} else {
(H256::zero(), frame_system::Pallet::<Test>::block_number())
}
})
}
}
parameter_types! {
pub static EndingPeriod: BlockNumber = 3;
pub static SampleLength: BlockNumber = 1;
}
impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type Leaser = TestLeaser;
type Registrar = TestRegistrar<Self>;
type EndingPeriod = EndingPeriod;
type SampleLength = SampleLength;
type Randomness = TestPastRandomness;
type InitiateOrigin = RootOrSix;
type WeightInfo = crate::auctions::TestWeightInfo;
}
// This function basically just builds a genesis storage key/value store according to
// our desired mock up.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
..Default::default()
}
.assimilate_storage(&mut t)
.unwrap();
let mut ext: sp_io::TestExternalities = t.into();
ext.execute_with(|| {
// Register para 0, 1, 2, and 3 for tests
assert_ok!(TestRegistrar::<Test>::register(
1,
0.into(),
dummy_head_data(),
dummy_validation_code()
));
assert_ok!(TestRegistrar::<Test>::register(
1,
1.into(),
dummy_head_data(),
dummy_validation_code()
));
assert_ok!(TestRegistrar::<Test>::register(
1,
2.into(),
dummy_head_data(),
dummy_validation_code()
));
assert_ok!(TestRegistrar::<Test>::register(
1,
3.into(),
dummy_head_data(),
dummy_validation_code()
));
});
ext
}
+678
View File
@@ -0,0 +1,678 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Auctioning system to determine the set of Teyrchains in operation. This includes logic for the
//! auctioning mechanism and for reserving balance as part of the "payment". Unreserving the balance
//! happens elsewhere.
use crate::{
slot_range::SlotRange,
traits::{AuctionStatus, Auctioneer, LeaseError, Leaser, Registrar},
};
use alloc::{vec, vec::Vec};
use codec::Decode;
use core::mem::swap;
use frame_support::{
dispatch::DispatchResult,
ensure,
traits::{Currency, Get, Randomness, ReservableCurrency},
weights::Weight,
};
use frame_system::pallet_prelude::BlockNumberFor;
pub use pallet::*;
use pezkuwi_primitives::Id as ParaId;
use sp_runtime::traits::{CheckedSub, One, Saturating, Zero};
type CurrencyOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency;
type BalanceOf<T> = <<<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;
pub trait WeightInfo {
fn new_auction() -> Weight;
fn bid() -> Weight;
fn cancel_auction() -> Weight;
fn on_initialize() -> Weight;
}
pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn new_auction() -> Weight {
Weight::zero()
}
fn bid() -> Weight {
Weight::zero()
}
fn cancel_auction() -> Weight {
Weight::zero()
}
fn on_initialize() -> Weight {
Weight::zero()
}
}
/// An auction index. We count auctions in this type.
pub type AuctionIndex = u32;
type LeasePeriodOf<T> = <<T as Config>::Leaser as Leaser<BlockNumberFor<T>>>::LeasePeriod;
// Winning data type. This encodes the top bidders of each range together with their bid.
type WinningData<T> = [Option<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>)>;
SlotRange::SLOT_RANGE_COUNT];
// Winners data type. This encodes each of the final winners of a teyrchain auction, the teyrchain
// index assigned to them, their winning bid and the range that they won.
type WinnersData<T> =
Vec<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>, SlotRange)>;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::{dispatch::DispatchClass, pallet_prelude::*, traits::EnsureOrigin};
use frame_system::{ensure_root, ensure_signed, pallet_prelude::*};
#[pallet::pallet]
pub struct Pallet<T>(_);
/// The module's configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The type representing the leasing system.
type Leaser: Leaser<
BlockNumberFor<Self>,
AccountId = Self::AccountId,
LeasePeriod = BlockNumberFor<Self>,
>;
/// The teyrchain registrar type.
type Registrar: Registrar<AccountId = Self::AccountId>;
/// The number of blocks over which an auction may be retroactively ended.
#[pallet::constant]
type EndingPeriod: Get<BlockNumberFor<Self>>;
/// The length of each sample to take during the ending period.
///
/// `EndingPeriod` / `SampleLength` = Total # of Samples
#[pallet::constant]
type SampleLength: Get<BlockNumberFor<Self>>;
/// Something that provides randomness in the runtime.
type Randomness: Randomness<Self::Hash, BlockNumberFor<Self>>;
/// The origin which may initiate auctions.
type InitiateOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// Weight Information for the Extrinsics in the Pallet
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// An auction started. Provides its index and the block number where it will begin to
/// close and the first lease period of the quadruplet that is auctioned.
AuctionStarted {
auction_index: AuctionIndex,
lease_period: LeasePeriodOf<T>,
ending: BlockNumberFor<T>,
},
/// An auction ended. All funds become unreserved.
AuctionClosed { auction_index: AuctionIndex },
/// Funds were reserved for a winning bid. First balance is the extra amount reserved.
/// Second is the total.
Reserved { bidder: T::AccountId, extra_reserved: BalanceOf<T>, total_amount: BalanceOf<T> },
/// Funds were unreserved since bidder is no longer active. `[bidder, amount]`
Unreserved { bidder: T::AccountId, amount: BalanceOf<T> },
/// Someone attempted to lease the same slot twice for a teyrchain. The amount is held in
/// reserve but no teyrchain slot has been leased.
ReserveConfiscated { para_id: ParaId, leaser: T::AccountId, amount: BalanceOf<T> },
/// A new bid has been accepted as the current winner.
BidAccepted {
bidder: T::AccountId,
para_id: ParaId,
amount: BalanceOf<T>,
first_slot: LeasePeriodOf<T>,
last_slot: LeasePeriodOf<T>,
},
/// The winning offset was chosen for an auction. This will map into the `Winning` storage
/// map.
WinningOffset { auction_index: AuctionIndex, block_number: BlockNumberFor<T> },
}
#[pallet::error]
pub enum Error<T> {
/// This auction is already in progress.
AuctionInProgress,
/// The lease period is in the past.
LeasePeriodInPast,
/// Para is not registered
ParaNotRegistered,
/// Not a current auction.
NotCurrentAuction,
/// Not an auction.
NotAuction,
/// Auction has already ended.
AuctionEnded,
/// The para is already leased out for part of this range.
AlreadyLeasedOut,
}
/// Number of auctions started so far.
#[pallet::storage]
pub type AuctionCounter<T> = StorageValue<_, AuctionIndex, ValueQuery>;
/// Information relating to the current auction, if there is one.
///
/// The first item in the tuple is the lease period index that the first of the four
/// contiguous lease periods on auction is for. The second is the block number when the
/// auction will "begin to end", i.e. the first block of the Ending Period of the auction.
#[pallet::storage]
pub type AuctionInfo<T: Config> = StorageValue<_, (LeasePeriodOf<T>, BlockNumberFor<T>)>;
/// Amounts currently reserved in the accounts of the bidders currently winning
/// (sub-)ranges.
#[pallet::storage]
pub type ReservedAmounts<T: Config> =
StorageMap<_, Twox64Concat, (T::AccountId, ParaId), BalanceOf<T>>;
/// The winning bids for each of the 10 ranges at each sample in the final Ending Period of
/// the current auction. The map's key is the 0-based index into the Sample Size. The
/// first sample of the ending period is 0; the last is `Sample Size - 1`.
#[pallet::storage]
pub type Winning<T: Config> = StorageMap<_, Twox64Concat, BlockNumberFor<T>, WinningData<T>>;
#[pallet::extra_constants]
impl<T: Config> Pallet<T> {
#[pallet::constant_name(SlotRangeCount)]
fn slot_range_count() -> u32 {
SlotRange::SLOT_RANGE_COUNT as u32
}
#[pallet::constant_name(LeasePeriodsPerSlot)]
fn lease_periods_per_slot() -> u32 {
SlotRange::LEASE_PERIODS_PER_SLOT as u32
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_initialize(n: BlockNumberFor<T>) -> Weight {
let mut weight = T::DbWeight::get().reads(1);
// If the current auction was in its ending period last block, then ensure that the
// (sub-)range winner information is duplicated from the previous block in case no bids
// happened in the last block.
if let AuctionStatus::EndingPeriod(offset, _sub_sample) = Self::auction_status(n) {
weight = weight.saturating_add(T::DbWeight::get().reads(1));
if !Winning::<T>::contains_key(&offset) {
weight = weight.saturating_add(T::DbWeight::get().writes(1));
let winning_data = offset
.checked_sub(&One::one())
.and_then(Winning::<T>::get)
.unwrap_or([Self::EMPTY; SlotRange::SLOT_RANGE_COUNT]);
Winning::<T>::insert(offset, winning_data);
}
}
// Check to see if an auction just ended.
if let Some((winning_ranges, auction_lease_period_index)) = Self::check_auction_end(n) {
// Auction is ended now. We have the winning ranges and the lease period index which
// acts as the offset. Handle it.
Self::manage_auction_end(auction_lease_period_index, winning_ranges);
weight = weight.saturating_add(T::WeightInfo::on_initialize());
}
weight
}
}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Create a new auction.
///
/// This can only happen when there isn't already an auction in progress and may only be
/// called by the root origin. Accepts the `duration` of this auction and the
/// `lease_period_index` of the initial lease period of the four that are to be auctioned.
#[pallet::call_index(0)]
#[pallet::weight((T::WeightInfo::new_auction(), DispatchClass::Operational))]
pub fn new_auction(
origin: OriginFor<T>,
#[pallet::compact] duration: BlockNumberFor<T>,
#[pallet::compact] lease_period_index: LeasePeriodOf<T>,
) -> DispatchResult {
T::InitiateOrigin::ensure_origin(origin)?;
Self::do_new_auction(duration, lease_period_index)
}
/// Make a new bid from an account (including a teyrchain account) for deploying a new
/// teyrchain.
///
/// Multiple simultaneous bids from the same bidder are allowed only as long as all active
/// bids overlap each other (i.e. are mutually exclusive). Bids cannot be redacted.
///
/// - `sub` is the sub-bidder ID, allowing for multiple competing bids to be made by (and
/// funded by) the same account.
/// - `auction_index` is the index of the auction to bid on. Should just be the present
/// value of `AuctionCounter`.
/// - `first_slot` is the first lease period index of the range to bid on. This is the
/// absolute lease period index value, not an auction-specific offset.
/// - `last_slot` is the last lease period index of the range to bid on. This is the
/// absolute lease period index value, not an auction-specific offset.
/// - `amount` is the amount to bid to be held as deposit for the teyrchain should the
/// bid win. This amount is held throughout the range.
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::bid())]
pub fn bid(
origin: OriginFor<T>,
#[pallet::compact] para: ParaId,
#[pallet::compact] auction_index: AuctionIndex,
#[pallet::compact] first_slot: LeasePeriodOf<T>,
#[pallet::compact] last_slot: LeasePeriodOf<T>,
#[pallet::compact] amount: BalanceOf<T>,
) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::handle_bid(who, para, auction_index, first_slot, last_slot, amount)?;
Ok(())
}
/// Cancel an in-progress auction.
///
/// Can only be called by Root origin.
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::cancel_auction())]
pub fn cancel_auction(origin: OriginFor<T>) -> DispatchResult {
ensure_root(origin)?;
// Unreserve all bids.
for ((bidder, _), amount) in ReservedAmounts::<T>::drain() {
CurrencyOf::<T>::unreserve(&bidder, amount);
}
#[allow(deprecated)]
Winning::<T>::remove_all(None);
AuctionInfo::<T>::kill();
Ok(())
}
}
}
impl<T: Config> Auctioneer<BlockNumberFor<T>> for Pallet<T> {
type AccountId = T::AccountId;
type LeasePeriod = BlockNumberFor<T>;
type Currency = CurrencyOf<T>;
fn new_auction(
duration: BlockNumberFor<T>,
lease_period_index: LeasePeriodOf<T>,
) -> DispatchResult {
Self::do_new_auction(duration, lease_period_index)
}
// Returns the status of the auction given the current block number.
fn auction_status(now: BlockNumberFor<T>) -> AuctionStatus<BlockNumberFor<T>> {
let early_end = match AuctionInfo::<T>::get() {
Some((_, early_end)) => early_end,
None => return AuctionStatus::NotStarted,
};
let after_early_end = match now.checked_sub(&early_end) {
Some(after_early_end) => after_early_end,
None => return AuctionStatus::StartingPeriod,
};
let ending_period = T::EndingPeriod::get();
if after_early_end < ending_period {
let sample_length = T::SampleLength::get().max(One::one());
let sample = after_early_end / sample_length;
let sub_sample = after_early_end % sample_length;
return AuctionStatus::EndingPeriod(sample, sub_sample);
} else {
// This is safe because of the comparison operator above
return AuctionStatus::VrfDelay(after_early_end - ending_period);
}
}
fn place_bid(
bidder: T::AccountId,
para: ParaId,
first_slot: LeasePeriodOf<T>,
last_slot: LeasePeriodOf<T>,
amount: BalanceOf<T>,
) -> DispatchResult {
Self::handle_bid(bidder, para, AuctionCounter::<T>::get(), first_slot, last_slot, amount)
}
fn lease_period_index(b: BlockNumberFor<T>) -> Option<(Self::LeasePeriod, bool)> {
T::Leaser::lease_period_index(b)
}
#[cfg(any(feature = "runtime-benchmarks", test))]
fn lease_period_length() -> (BlockNumberFor<T>, BlockNumberFor<T>) {
T::Leaser::lease_period_length()
}
fn has_won_an_auction(para: ParaId, bidder: &T::AccountId) -> bool {
!T::Leaser::deposit_held(para, bidder).is_zero()
}
}
impl<T: Config> Pallet<T> {
// A trick to allow me to initialize large arrays with nothing in them.
const EMPTY: Option<(<T as frame_system::Config>::AccountId, ParaId, BalanceOf<T>)> = None;
/// Create a new auction.
///
/// This can only happen when there isn't already an auction in progress. Accepts the `duration`
/// of this auction and the `lease_period_index` of the initial lease period of the four that
/// are to be auctioned.
fn do_new_auction(
duration: BlockNumberFor<T>,
lease_period_index: LeasePeriodOf<T>,
) -> DispatchResult {
let maybe_auction = AuctionInfo::<T>::get();
ensure!(maybe_auction.is_none(), Error::<T>::AuctionInProgress);
let now = frame_system::Pallet::<T>::block_number();
if let Some((current_lease_period, _)) = T::Leaser::lease_period_index(now) {
// If there is no active lease period, then we don't need to make this check.
ensure!(lease_period_index >= current_lease_period, Error::<T>::LeasePeriodInPast);
}
// Bump the counter.
let n = AuctionCounter::<T>::mutate(|n| {
*n += 1;
*n
});
// Set the information.
let ending = frame_system::Pallet::<T>::block_number().saturating_add(duration);
AuctionInfo::<T>::put((lease_period_index, ending));
Self::deposit_event(Event::<T>::AuctionStarted {
auction_index: n,
lease_period: lease_period_index,
ending,
});
Ok(())
}
/// Actually place a bid in the current auction.
///
/// - `bidder`: The account that will be funding this bid.
/// - `auction_index`: The auction index of the bid. For this to succeed, must equal
/// the current value of `AuctionCounter`.
/// - `first_slot`: The first lease period index of the range to be bid on.
/// - `last_slot`: The last lease period index of the range to be bid on (inclusive).
/// - `amount`: The total amount to be the bid for deposit over the range.
pub fn handle_bid(
bidder: T::AccountId,
para: ParaId,
auction_index: u32,
first_slot: LeasePeriodOf<T>,
last_slot: LeasePeriodOf<T>,
amount: BalanceOf<T>,
) -> DispatchResult {
// Ensure para is registered before placing a bid on it.
ensure!(T::Registrar::is_registered(para), Error::<T>::ParaNotRegistered);
// Bidding on latest auction.
ensure!(auction_index == AuctionCounter::<T>::get(), Error::<T>::NotCurrentAuction);
// Assume it's actually an auction (this should never fail because of above).
let (first_lease_period, _) = AuctionInfo::<T>::get().ok_or(Error::<T>::NotAuction)?;
// Get the auction status and the current sample block. For the starting period, the sample
// block is zero.
let auction_status = Self::auction_status(frame_system::Pallet::<T>::block_number());
// The offset into the ending samples of the auction.
let offset = match auction_status {
AuctionStatus::NotStarted => return Err(Error::<T>::AuctionEnded.into()),
AuctionStatus::StartingPeriod => Zero::zero(),
AuctionStatus::EndingPeriod(o, _) => o,
AuctionStatus::VrfDelay(_) => return Err(Error::<T>::AuctionEnded.into()),
};
// We also make sure that the bid is not for any existing leases the para already has.
ensure!(
!T::Leaser::already_leased(para, first_slot, last_slot),
Error::<T>::AlreadyLeasedOut
);
// Our range.
let range = SlotRange::new_bounded(first_lease_period, first_slot, last_slot)?;
// Range as an array index.
let range_index = range as u8 as usize;
// The current winning ranges.
let mut current_winning = Winning::<T>::get(offset)
.or_else(|| offset.checked_sub(&One::one()).and_then(Winning::<T>::get))
.unwrap_or([Self::EMPTY; SlotRange::SLOT_RANGE_COUNT]);
// If this bid beat the previous winner of our range.
if current_winning[range_index].as_ref().map_or(true, |last| amount > last.2) {
// Ok; we are the new winner of this range - reserve the additional amount and record.
// Get the amount already held on deposit if this is a renewal bid (i.e. there's
// an existing lease on the same para by the same leaser).
let existing_lease_deposit = T::Leaser::deposit_held(para, &bidder);
let reserve_required = amount.saturating_sub(existing_lease_deposit);
// Get the amount already reserved in any prior and still active bids by us.
let bidder_para = (bidder.clone(), para);
let already_reserved = ReservedAmounts::<T>::get(&bidder_para).unwrap_or_default();
// If these don't already cover the bid...
if let Some(additional) = reserve_required.checked_sub(&already_reserved) {
// ...then reserve some more funds from their account, failing if there's not
// enough funds.
CurrencyOf::<T>::reserve(&bidder, additional)?;
// ...and record the amount reserved.
ReservedAmounts::<T>::insert(&bidder_para, reserve_required);
Self::deposit_event(Event::<T>::Reserved {
bidder: bidder.clone(),
extra_reserved: additional,
total_amount: reserve_required,
});
}
// Return any funds reserved for the previous winner if we are not in the ending period
// and they no longer have any active bids.
let mut outgoing_winner = Some((bidder.clone(), para, amount));
swap(&mut current_winning[range_index], &mut outgoing_winner);
if let Some((who, para, _amount)) = outgoing_winner {
if auction_status.is_starting() &&
current_winning
.iter()
.filter_map(Option::as_ref)
.all(|&(ref other, other_para, _)| other != &who || other_para != para)
{
// Previous bidder is no longer winning any ranges: unreserve their funds.
if let Some(amount) = ReservedAmounts::<T>::take(&(who.clone(), para)) {
// It really should be reserved; there's not much we can do here on fail.
let err_amt = CurrencyOf::<T>::unreserve(&who, amount);
debug_assert!(err_amt.is_zero());
Self::deposit_event(Event::<T>::Unreserved { bidder: who, amount });
}
}
}
// Update the range winner.
Winning::<T>::insert(offset, &current_winning);
Self::deposit_event(Event::<T>::BidAccepted {
bidder,
para_id: para,
amount,
first_slot,
last_slot,
});
}
Ok(())
}
/// Some when the auction's end is known (with the end block number). None if it is unknown.
/// If `Some` then the block number must be at most the previous block and at least the
/// previous block minus `T::EndingPeriod::get()`.
///
/// This mutates the state, cleaning up `AuctionInfo` and `Winning` in the case of an auction
/// ending. An immediately subsequent call with the same argument will always return `None`.
fn check_auction_end(now: BlockNumberFor<T>) -> Option<(WinningData<T>, LeasePeriodOf<T>)> {
if let Some((lease_period_index, early_end)) = AuctionInfo::<T>::get() {
let ending_period = T::EndingPeriod::get();
let late_end = early_end.saturating_add(ending_period);
let is_ended = now >= late_end;
if is_ended {
// auction definitely ended.
// check to see if we can determine the actual ending point.
let (raw_offset, known_since) = T::Randomness::random(&b"para_auction"[..]);
if late_end <= known_since {
// Our random seed was known only after the auction ended. Good to use.
let raw_offset_block_number = <BlockNumberFor<T>>::decode(
&mut raw_offset.as_ref(),
)
.expect("secure hashes should always be bigger than the block number; qed");
let offset = (raw_offset_block_number % ending_period) /
T::SampleLength::get().max(One::one());
let auction_counter = AuctionCounter::<T>::get();
Self::deposit_event(Event::<T>::WinningOffset {
auction_index: auction_counter,
block_number: offset,
});
let res = Winning::<T>::get(offset)
.unwrap_or([Self::EMPTY; SlotRange::SLOT_RANGE_COUNT]);
// This `remove_all` statement should remove at most `EndingPeriod` /
// `SampleLength` items, which should be bounded and sensibly configured in the
// runtime.
#[allow(deprecated)]
Winning::<T>::remove_all(None);
AuctionInfo::<T>::kill();
return Some((res, lease_period_index));
}
}
}
None
}
/// Auction just ended. We have the current lease period, the auction's lease period (which
/// is guaranteed to be at least the current period) and the bidders that were winning each
/// range at the time of the auction's close.
fn manage_auction_end(
auction_lease_period_index: LeasePeriodOf<T>,
winning_ranges: WinningData<T>,
) {
// First, unreserve all amounts that were reserved for the bids. We will later re-reserve
// the amounts from the bidders that ended up being assigned the slot so there's no need to
// special-case them here.
for ((bidder, _), amount) in ReservedAmounts::<T>::drain() {
CurrencyOf::<T>::unreserve(&bidder, amount);
}
// Next, calculate the winning combination of slots and thus the final winners of the
// auction.
let winners = Self::calculate_winners(winning_ranges);
// Go through those winners and re-reserve their bid, updating our table of deposits
// accordingly.
for (leaser, para, amount, range) in winners.into_iter() {
let begin_offset = LeasePeriodOf::<T>::from(range.as_pair().0 as u32);
let period_begin = auction_lease_period_index + begin_offset;
let period_count = LeasePeriodOf::<T>::from(range.len() as u32);
match T::Leaser::lease_out(para, &leaser, amount, period_begin, period_count) {
Err(LeaseError::ReserveFailed) |
Err(LeaseError::AlreadyEnded) |
Err(LeaseError::NoLeasePeriod) => {
// Should never happen since we just unreserved this amount (and our offset is
// from the present period). But if it does, there's not much we can do.
},
Err(LeaseError::AlreadyLeased) => {
// The leaser attempted to get a second lease on the same para ID, possibly
// griefing us. Let's keep the amount reserved and let governance sort it out.
if CurrencyOf::<T>::reserve(&leaser, amount).is_ok() {
Self::deposit_event(Event::<T>::ReserveConfiscated {
para_id: para,
leaser,
amount,
});
}
},
Ok(()) => {}, // Nothing to report.
}
}
Self::deposit_event(Event::<T>::AuctionClosed {
auction_index: AuctionCounter::<T>::get(),
});
}
/// Calculate the final winners from the winning slots.
///
/// This is a simple dynamic programming algorithm designed by Al, the original code is at:
/// `https://github.com/w3f/consensus/blob/master/NPoS/auctiondynamicthing.py`
fn calculate_winners(mut winning: WinningData<T>) -> WinnersData<T> {
let winning_ranges = {
let mut best_winners_ending_at: [(Vec<SlotRange>, BalanceOf<T>);
SlotRange::LEASE_PERIODS_PER_SLOT] = Default::default();
let best_bid = |range: SlotRange| {
winning[range as u8 as usize]
.as_ref()
.map(|(_, _, amount)| *amount * (range.len() as u32).into())
};
for i in 0..SlotRange::LEASE_PERIODS_PER_SLOT {
let r = SlotRange::new_bounded(0, 0, i as u32).expect("`i < LPPS`; qed");
if let Some(bid) = best_bid(r) {
best_winners_ending_at[i] = (vec![r], bid);
}
for j in 0..i {
let r = SlotRange::new_bounded(0, j as u32 + 1, i as u32)
.expect("`i < LPPS`; `j < i`; `j + 1 < LPPS`; qed");
if let Some(mut bid) = best_bid(r) {
bid += best_winners_ending_at[j].1;
if bid > best_winners_ending_at[i].1 {
let mut new_winners = best_winners_ending_at[j].0.clone();
new_winners.push(r);
best_winners_ending_at[i] = (new_winners, bid);
}
} else {
if best_winners_ending_at[j].1 > best_winners_ending_at[i].1 {
best_winners_ending_at[i] = best_winners_ending_at[j].clone();
}
}
}
}
best_winners_ending_at[SlotRange::LEASE_PERIODS_PER_SLOT - 1].0.clone()
};
winning_ranges
.into_iter()
.filter_map(|range| {
winning[range as u8 as usize]
.take()
.map(|(bidder, para, amount)| (bidder, para, amount, range))
})
.collect::<Vec<_>>()
}
}
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
@@ -0,0 +1,821 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the auctions pallet.
#[cfg(test)]
use super::*;
use crate::{auctions::mock::*, mock::TestRegistrar};
use frame_support::{assert_noop, assert_ok, assert_storage_noop};
use pallet_balances;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_primitives_test_helpers::{dummy_hash, dummy_head_data, dummy_validation_code};
use sp_core::H256;
use sp_runtime::DispatchError::BadOrigin;
#[test]
fn basic_setup_works() {
new_test_ext().execute_with(|| {
assert_eq!(AuctionCounter::<Test>::get(), 0);
assert_eq!(TestLeaser::deposit_held(0u32.into(), &1), 0);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::NotStarted
);
System::run_to_block::<AllPalletsWithSystem>(10);
assert_eq!(AuctionCounter::<Test>::get(), 0);
assert_eq!(TestLeaser::deposit_held(0u32.into(), &1), 0);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::NotStarted
);
});
}
#[test]
fn can_start_auction() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_noop!(Auctions::new_auction(RuntimeOrigin::signed(1), 5, 1), BadOrigin);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_eq!(AuctionCounter::<Test>::get(), 1);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
});
}
#[test]
fn bidding_works() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
assert_eq!(Balances::reserved_balance(1), 5);
assert_eq!(Balances::free_balance(1), 5);
assert_eq!(
Winning::<Test>::get(0).unwrap()[SlotRange::ZeroThree as u8 as usize],
Some((1, 0.into(), 5))
);
});
}
#[test]
fn under_bidding_works() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
assert_storage_noop!({
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 1));
});
});
}
#[test]
fn over_bidding_works() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 5));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 1, 4, 6));
assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(Balances::free_balance(1), 10);
assert_eq!(Balances::reserved_balance(2), 6);
assert_eq!(Balances::free_balance(2), 14);
assert_eq!(
Winning::<Test>::get(0).unwrap()[SlotRange::ZeroThree as u8 as usize],
Some((2, 0.into(), 6))
);
});
}
#[test]
fn auction_proceeds_correctly() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_eq!(AuctionCounter::<Test>::get(), 1);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(2);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(3);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(4);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(5);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(6);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(0, 0)
);
System::run_to_block::<AllPalletsWithSystem>(7);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(1, 0)
);
System::run_to_block::<AllPalletsWithSystem>(8);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(2, 0)
);
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::NotStarted
);
});
}
#[test]
fn can_win_auction() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9);
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
leases(),
vec![
((0.into(), 1), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 2), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 3), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 4), LeaseData { leaser: 1, amount: 1 }),
]
);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 1);
});
}
#[test]
fn can_win_auction_with_late_randomness() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(8);
// Auction has not yet ended.
assert_eq!(leases(), vec![]);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(2, 0)
);
// This will prevent the auction's winner from being decided in the next block, since
// the random seed was known before the final bids were made.
set_last_random(H256::zero(), 8);
// Auction definitely ended now, but we don't know exactly when in the last 3 blocks yet
// since no randomness available yet.
System::run_to_block::<AllPalletsWithSystem>(9);
// Auction has now ended... But auction winner still not yet decided, so no leases yet.
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::VrfDelay(0)
);
assert_eq!(leases(), vec![]);
// Random seed now updated to a value known at block 9, when the auction ended. This
// means that the winner can now be chosen.
set_last_random(H256::zero(), 9);
System::run_to_block::<AllPalletsWithSystem>(10);
// Auction ended and winner selected
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::NotStarted
);
assert_eq!(
leases(),
vec![
((0.into(), 1), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 2), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 3), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 4), LeaseData { leaser: 1, amount: 1 }),
]
);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 1);
});
}
#[test]
fn can_win_incomplete_auction() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 5));
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(leases(), vec![((0.into(), 4), LeaseData { leaser: 1, amount: 5 }),]);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
});
}
#[test]
fn should_choose_best_combination() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 0.into(), 1, 2, 3, 4));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 0.into(), 1, 4, 4, 2));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 1, 1, 4, 2));
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
leases(),
vec![
((0.into(), 1), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 2), LeaseData { leaser: 2, amount: 4 }),
((0.into(), 3), LeaseData { leaser: 2, amount: 4 }),
((0.into(), 4), LeaseData { leaser: 3, amount: 2 }),
]
);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 1);
assert_eq!(TestLeaser::deposit_held(1.into(), &1), 0);
assert_eq!(TestLeaser::deposit_held(0.into(), &2), 4);
assert_eq!(TestLeaser::deposit_held(0.into(), &3), 2);
});
}
#[test]
fn gap_bid_works() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
// User 1 will make a bid for period 1 and 4 for the same Para 0
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 4, 4, 4));
// User 2 and 3 will make a bid for para 1 on period 2 and 3 respectively
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), 1.into(), 1, 2, 2, 2));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), 1.into(), 1, 3, 3, 3));
// Total reserved should be the max of the two
assert_eq!(Balances::reserved_balance(1), 4);
// Other people are reserved correctly too
assert_eq!(Balances::reserved_balance(2), 2);
assert_eq!(Balances::reserved_balance(3), 3);
// End the auction.
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
leases(),
vec![
((0.into(), 1), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 4), LeaseData { leaser: 1, amount: 4 }),
((1.into(), 2), LeaseData { leaser: 2, amount: 2 }),
((1.into(), 3), LeaseData { leaser: 3, amount: 3 }),
]
);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 4);
assert_eq!(TestLeaser::deposit_held(1.into(), &2), 2);
assert_eq!(TestLeaser::deposit_held(1.into(), &3), 3);
});
}
#[test]
fn deposit_credit_should_work() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5));
assert_eq!(Balances::reserved_balance(1), 5);
System::run_to_block::<AllPalletsWithSystem>(10);
assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 2, 2, 6));
// Only 1 reserved since we have a deposit credit of 5.
assert_eq!(Balances::reserved_balance(1), 1);
System::run_to_block::<AllPalletsWithSystem>(20);
assert_eq!(
leases(),
vec![
((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),
((0.into(), 2), LeaseData { leaser: 1, amount: 6 }),
]
);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 6);
});
}
#[test]
fn deposit_credit_on_alt_para_should_not_count() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 1, 5));
assert_eq!(Balances::reserved_balance(1), 5);
System::run_to_block::<AllPalletsWithSystem>(10);
assert_eq!(leases(), vec![((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),]);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 2));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1.into(), 2, 2, 2, 6));
// 6 reserved since we are bidding on a new para; only works because we don't
assert_eq!(Balances::reserved_balance(1), 6);
System::run_to_block::<AllPalletsWithSystem>(20);
assert_eq!(
leases(),
vec![
((0.into(), 1), LeaseData { leaser: 1, amount: 5 }),
((1.into(), 2), LeaseData { leaser: 1, amount: 6 }),
]
);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 5);
assert_eq!(TestLeaser::deposit_held(1.into(), &1), 6);
});
}
#[test]
fn multiple_bids_work_pre_ending() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
for i in 1..6u64 {
System::run_to_block::<AllPalletsWithSystem>(i as _);
assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i));
for j in 1..6 {
assert_eq!(Balances::reserved_balance(j), if j == i { j } else { 0 });
assert_eq!(Balances::free_balance(j), if j == i { j * 9 } else { j * 10 });
}
}
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
leases(),
vec![
((0.into(), 1), LeaseData { leaser: 5, amount: 5 }),
((0.into(), 2), LeaseData { leaser: 5, amount: 5 }),
((0.into(), 3), LeaseData { leaser: 5, amount: 5 }),
((0.into(), 4), LeaseData { leaser: 5, amount: 5 }),
]
);
});
}
#[test]
fn multiple_bids_work_post_ending() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 0, 1));
for i in 1..6u64 {
System::run_to_block::<AllPalletsWithSystem>(((i - 1) / 2 + 1) as _);
assert_ok!(Auctions::bid(RuntimeOrigin::signed(i), 0.into(), 1, 1, 4, i));
for j in 1..6 {
assert_eq!(Balances::reserved_balance(j), if j <= i { j } else { 0 });
assert_eq!(Balances::free_balance(j), if j <= i { j * 9 } else { j * 10 });
}
}
for i in 1..6u64 {
assert_eq!(ReservedAmounts::<Test>::get((i, ParaId::from(0))).unwrap(), i);
}
System::run_to_block::<AllPalletsWithSystem>(5);
assert_eq!(
leases(),
(1..=4)
.map(|i| ((0.into(), i), LeaseData { leaser: 2, amount: 2 }))
.collect::<Vec<_>>()
);
});
}
#[test]
fn incomplete_calculate_winners_works() {
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ThreeThree as u8 as usize] = Some((1, 0.into(), 1));
let winners = vec![(1, 0.into(), 1, SlotRange::ThreeThree)];
assert_eq!(Auctions::calculate_winners(winning), winners);
}
#[test]
fn first_incomplete_calculate_winners_works() {
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[0] = Some((1, 0.into(), 1));
let winners = vec![(1, 0.into(), 1, SlotRange::ZeroZero)];
assert_eq!(Auctions::calculate_winners(winning), winners);
}
#[test]
fn calculate_winners_works() {
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroZero as u8 as usize] = Some((2, 0.into(), 2));
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, 100.into(), 1));
winning[SlotRange::OneOne as u8 as usize] = Some((3, 1.into(), 1));
winning[SlotRange::TwoTwo as u8 as usize] = Some((1, 2.into(), 53));
winning[SlotRange::ThreeThree as u8 as usize] = Some((5, 3.into(), 1));
let winners = vec![
(2, 0.into(), 2, SlotRange::ZeroZero),
(3, 1.into(), 1, SlotRange::OneOne),
(1, 2.into(), 53, SlotRange::TwoTwo),
(5, 3.into(), 1, SlotRange::ThreeThree),
];
assert_eq!(Auctions::calculate_winners(winning), winners);
winning[SlotRange::ZeroOne as u8 as usize] = Some((4, 10.into(), 3));
let winners = vec![
(4, 10.into(), 3, SlotRange::ZeroOne),
(1, 2.into(), 53, SlotRange::TwoTwo),
(5, 3.into(), 1, SlotRange::ThreeThree),
];
assert_eq!(Auctions::calculate_winners(winning), winners);
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, 100.into(), 100));
let winners = vec![(1, 100.into(), 100, SlotRange::ZeroThree)];
assert_eq!(Auctions::calculate_winners(winning), winners);
}
#[test]
fn lower_bids_are_correctly_refunded() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 1, 1));
let para_1 = ParaId::from(1_u32);
let para_2 = ParaId::from(2_u32);
// Make a bid and reserve a balance
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 9));
assert_eq!(Balances::reserved_balance(1), 9);
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), Some(9));
assert_eq!(Balances::reserved_balance(2), 0);
assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), None);
// Bigger bid, reserves new balance and returns funds
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 1, 4, 19));
assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(ReservedAmounts::<Test>::get((1, para_1)), None);
assert_eq!(Balances::reserved_balance(2), 19);
assert_eq!(ReservedAmounts::<Test>::get((2, para_2)), Some(19));
});
}
#[test]
fn initialize_winners_in_ending_period_works() {
new_test_ext().execute_with(|| {
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 1));
let para_1 = ParaId::from(1_u32);
let para_2 = ParaId::from(2_u32);
let para_3 = ParaId::from(3_u32);
// Make bids
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 1, 4, 9));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 3, 4, 19));
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 9));
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 19));
assert_eq!(Winning::<Test>::get(0), Some(winning));
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(10);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(0, 0)
);
assert_eq!(Winning::<Test>::get(0), Some(winning));
System::run_to_block::<AllPalletsWithSystem>(11);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(1, 0)
);
assert_eq!(Winning::<Test>::get(1), Some(winning));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 3, 4, 29));
System::run_to_block::<AllPalletsWithSystem>(12);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(2, 0)
);
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 29));
assert_eq!(Winning::<Test>::get(2), Some(winning));
});
}
#[test]
fn handle_bid_requires_registered_para() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_noop!(
Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1),
Error::<Test>::ParaNotRegistered
);
assert_ok!(TestRegistrar::<Test>::register(
1,
1337.into(),
dummy_head_data(),
dummy_validation_code()
));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 1337.into(), 1, 1, 4, 1));
});
}
#[test]
fn handle_bid_checks_existing_lease_periods() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 2, 3, 1));
assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9);
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
leases(),
vec![
((0.into(), 2), LeaseData { leaser: 1, amount: 1 }),
((0.into(), 3), LeaseData { leaser: 1, amount: 1 }),
]
);
assert_eq!(TestLeaser::deposit_held(0.into(), &1), 1);
// Para 1 just won an auction above and won some lease periods.
// No bids can work which overlap these periods.
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_noop!(
Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 4, 1),
Error::<Test>::AlreadyLeasedOut,
);
assert_noop!(
Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 2, 1),
Error::<Test>::AlreadyLeasedOut,
);
assert_noop!(
Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 3, 4, 1),
Error::<Test>::AlreadyLeasedOut,
);
// This is okay, not an overlapping bid.
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 2, 1, 1, 1));
});
}
// Here we will test that taking only 10 samples during the ending period works as expected.
#[test]
fn less_winning_samples_work() {
new_test_ext().execute_with(|| {
let ed: u64 = <Test as pallet_balances::Config>::ExistentialDeposit::get();
assert_eq!(ed, 1);
EndingPeriod::set(30);
SampleLength::set(10);
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11));
let para_1 = ParaId::from(1_u32);
let para_2 = ParaId::from(2_u32);
let para_3 = ParaId::from(3_u32);
// Make bids
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), para_1, 1, 11, 14, 9));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(2), para_2, 1, 13, 14, 19));
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
let mut winning = [None; SlotRange::SLOT_RANGE_COUNT];
winning[SlotRange::ZeroThree as u8 as usize] = Some((1, para_1, 9));
winning[SlotRange::TwoThree as u8 as usize] = Some((2, para_2, 19));
assert_eq!(Winning::<Test>::get(0), Some(winning));
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(10);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(0, 0)
);
assert_eq!(Winning::<Test>::get(0), Some(winning));
// New bids update the current winning
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 14, 14, 29));
winning[SlotRange::ThreeThree as u8 as usize] = Some((3, para_3, 29));
assert_eq!(Winning::<Test>::get(0), Some(winning));
System::run_to_block::<AllPalletsWithSystem>(20);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(1, 0)
);
assert_eq!(Winning::<Test>::get(1), Some(winning));
System::run_to_block::<AllPalletsWithSystem>(25);
// Overbid mid sample
assert_ok!(Auctions::bid(RuntimeOrigin::signed(3), para_3, 1, 13, 14, 29));
winning[SlotRange::TwoThree as u8 as usize] = Some((3, para_3, 29));
assert_eq!(Winning::<Test>::get(1), Some(winning));
System::run_to_block::<AllPalletsWithSystem>(30);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(2, 0)
);
assert_eq!(Winning::<Test>::get(2), Some(winning));
set_last_random(H256::from([254; 32]), 40);
System::run_to_block::<AllPalletsWithSystem>(40);
// Auction ended and winner selected
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::NotStarted
);
assert_eq!(
leases(),
vec![
((3.into(), 13), LeaseData { leaser: 3, amount: 29 }),
((3.into(), 14), LeaseData { leaser: 3, amount: 29 }),
]
);
});
}
#[test]
fn auction_status_works() {
new_test_ext().execute_with(|| {
EndingPeriod::set(30);
SampleLength::set(10);
set_last_random(dummy_hash(), 0);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::NotStarted
);
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 9, 11));
System::run_to_block::<AllPalletsWithSystem>(9);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::StartingPeriod
);
System::run_to_block::<AllPalletsWithSystem>(10);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(0, 0)
);
System::run_to_block::<AllPalletsWithSystem>(11);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(0, 1)
);
System::run_to_block::<AllPalletsWithSystem>(19);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(0, 9)
);
System::run_to_block::<AllPalletsWithSystem>(20);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(1, 0)
);
System::run_to_block::<AllPalletsWithSystem>(25);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(1, 5)
);
System::run_to_block::<AllPalletsWithSystem>(30);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(2, 0)
);
System::run_to_block::<AllPalletsWithSystem>(39);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::EndingPeriod(2, 9)
);
System::run_to_block::<AllPalletsWithSystem>(40);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::VrfDelay(0)
);
System::run_to_block::<AllPalletsWithSystem>(44);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::VrfDelay(4)
);
set_last_random(dummy_hash(), 45);
System::run_to_block::<AllPalletsWithSystem>(45);
assert_eq!(
Auctions::auction_status(System::block_number()),
AuctionStatus::<u32>::NotStarted
);
});
}
#[test]
fn can_cancel_auction() {
new_test_ext().execute_with(|| {
System::run_to_block::<AllPalletsWithSystem>(1);
assert_ok!(Auctions::new_auction(RuntimeOrigin::signed(6), 5, 1));
assert_ok!(Auctions::bid(RuntimeOrigin::signed(1), 0.into(), 1, 1, 4, 1));
assert_eq!(Balances::reserved_balance(1), 1);
assert_eq!(Balances::free_balance(1), 9);
assert_noop!(Auctions::cancel_auction(RuntimeOrigin::signed(6)), BadOrigin);
assert_ok!(Auctions::cancel_auction(RuntimeOrigin::root()));
assert!(AuctionInfo::<Test>::get().is_none());
assert_eq!(Balances::reserved_balance(1), 0);
assert_eq!(ReservedAmounts::<Test>::iter().count(), 0);
assert_eq!(Winning::<Test>::iter().count(), 0);
});
}
@@ -0,0 +1,318 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for claims pallet
#[cfg(feature = "runtime-benchmarks")]
use super::*;
use crate::claims::Call;
use frame_benchmarking::v2::*;
use frame_support::{
dispatch::{DispatchInfo, GetDispatchInfo},
traits::UnfilteredDispatchable,
};
use frame_system::RawOrigin;
use secp_utils::*;
use sp_runtime::{
traits::{DispatchTransaction, ValidateUnsigned},
DispatchResult,
};
const SEED: u32 = 0;
const MAX_CLAIMS: u32 = 10_000;
const VALUE: u32 = 1_000_000;
fn create_claim<T: Config>(input: u32) -> DispatchResult {
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&input.encode())).unwrap();
let eth_address = eth(&secret_key);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
super::Pallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
vesting,
None,
)?;
Ok(())
}
fn create_claim_attest<T: Config>(input: u32) -> DispatchResult {
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&input.encode())).unwrap();
let eth_address = eth(&secret_key);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
super::Pallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
vesting,
Some(Default::default()),
)?;
Ok(())
}
#[benchmarks(
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>> + From<Call<T>>,
<T as frame_system::Config>::RuntimeCall: Dispatchable<Info = DispatchInfo> + GetDispatchInfo,
<<T as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: AsSystemOriginSigner<T::AccountId> + AsTransactionAuthorizedOrigin + Clone,
<<T as frame_system::Config>::RuntimeCall as Dispatchable>::PostInfo: Default,
)]
mod benchmarks {
use super::*;
// Benchmark `claim` including `validate_unsigned` logic.
#[benchmark]
fn claim() -> Result<(), BenchmarkError> {
let c = MAX_CLAIMS;
for _ in 0..c / 2 {
create_claim::<T>(c)?;
create_claim_attest::<T>(u32::MAX - c)?;
}
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&c.encode())).unwrap();
let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", c, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let signature = sig::<T>(&secret_key, &account.encode(), &[][..]);
super::Pallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
vesting,
None,
)?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let source = sp_runtime::transaction_validity::TransactionSource::External;
let call_enc =
Call::<T>::claim { dest: account.clone(), ethereum_signature: signature.clone() }
.encode();
#[block]
{
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct");
super::Pallet::<T>::validate_unsigned(source, &call)
.map_err(|e| -> &'static str { e.into() })?;
call.dispatch_bypass_filter(RawOrigin::None.into())?;
}
assert_eq!(Claims::<T>::get(eth_address), None);
Ok(())
}
// Benchmark `mint_claim` when there already exists `c` claims in storage.
#[benchmark]
fn mint_claim() -> Result<(), BenchmarkError> {
let c = MAX_CLAIMS;
for _ in 0..c / 2 {
create_claim::<T>(c)?;
create_claim_attest::<T>(u32::MAX - c)?;
}
let eth_address = account("eth_address", 0, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let statement = StatementKind::Regular;
#[extrinsic_call]
_(RawOrigin::Root, eth_address, VALUE.into(), vesting, Some(statement));
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
Ok(())
}
// Benchmark `claim_attest` including `validate_unsigned` logic.
#[benchmark]
fn claim_attest() -> Result<(), BenchmarkError> {
let c = MAX_CLAIMS;
for _ in 0..c / 2 {
create_claim::<T>(c)?;
create_claim_attest::<T>(u32::MAX - c)?;
}
// Crate signature
let attest_c = u32::MAX - c;
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap();
let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", c, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let statement = StatementKind::Regular;
let signature = sig::<T>(&secret_key, &account.encode(), statement.to_text());
super::Pallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
vesting,
Some(statement),
)?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let call_enc = Call::<T>::claim_attest {
dest: account.clone(),
ethereum_signature: signature.clone(),
statement: StatementKind::Regular.to_text().to_vec(),
}
.encode();
let source = sp_runtime::transaction_validity::TransactionSource::External;
#[block]
{
let call = <Call<T> as Decode>::decode(&mut &*call_enc)
.expect("call is encoded above, encoding must be correct");
super::Pallet::<T>::validate_unsigned(source, &call)
.map_err(|e| -> &'static str { e.into() })?;
call.dispatch_bypass_filter(RawOrigin::None.into())?;
}
assert_eq!(Claims::<T>::get(eth_address), None);
Ok(())
}
// Benchmark `attest` including prevalidate logic.
#[benchmark]
fn attest() -> Result<(), BenchmarkError> {
let c = MAX_CLAIMS;
for _ in 0..c / 2 {
create_claim::<T>(c)?;
create_claim_attest::<T>(u32::MAX - c)?;
}
let attest_c = u32::MAX - c;
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap();
let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", c, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let statement = StatementKind::Regular;
super::Pallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
vesting,
Some(statement),
)?;
Preclaims::<T>::insert(&account, eth_address);
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
let stmt = StatementKind::Regular.to_text().to_vec();
#[extrinsic_call]
_(RawOrigin::Signed(account), stmt);
assert_eq!(Claims::<T>::get(eth_address), None);
Ok(())
}
#[benchmark]
fn move_claim() -> Result<(), BenchmarkError> {
let c = MAX_CLAIMS;
for _ in 0..c / 2 {
create_claim::<T>(c)?;
create_claim_attest::<T>(u32::MAX - c)?;
}
let attest_c = u32::MAX - c;
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap();
let eth_address = eth(&secret_key);
let new_secret_key =
libsecp256k1::SecretKey::parse(&keccak_256(&(u32::MAX / 2).encode())).unwrap();
let new_eth_address = eth(&new_secret_key);
let account: T::AccountId = account("user", c, SEED);
Preclaims::<T>::insert(&account, eth_address);
assert!(Claims::<T>::contains_key(eth_address));
assert!(!Claims::<T>::contains_key(new_eth_address));
#[extrinsic_call]
_(RawOrigin::Root, eth_address, new_eth_address, Some(account));
assert!(!Claims::<T>::contains_key(eth_address));
assert!(Claims::<T>::contains_key(new_eth_address));
Ok(())
}
// Benchmark the time it takes to do `repeat` number of keccak256 hashes
#[benchmark(extra)]
fn keccak256(i: Linear<0, 10_000>) {
let bytes = (i).encode();
#[block]
{
for _ in 0..i {
let _hash = keccak_256(&bytes);
}
}
}
// Benchmark the time it takes to do `repeat` number of `eth_recover`
#[benchmark(extra)]
fn eth_recover(i: Linear<0, 1_000>) {
// Crate signature
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&i.encode())).unwrap();
let account: T::AccountId = account("user", i, SEED);
let signature = sig::<T>(&secret_key, &account.encode(), &[][..]);
let data = account.using_encoded(to_ascii_hex);
let extra = StatementKind::default().to_text();
#[block]
{
for _ in 0..i {
assert!(super::Pallet::<T>::eth_recover(&signature, &data, extra).is_some());
}
}
}
#[benchmark]
fn prevalidate_attests() -> Result<(), BenchmarkError> {
let c = MAX_CLAIMS;
for _ in 0..c / 2 {
create_claim::<T>(c)?;
create_claim_attest::<T>(u32::MAX - c)?;
}
let ext = PrevalidateAttests::<T>::new();
let call = super::Call::attest { statement: StatementKind::Regular.to_text().to_vec() };
let call: <T as frame_system::Config>::RuntimeCall = call.into();
let info = call.get_dispatch_info();
let attest_c = u32::MAX - c;
let secret_key = libsecp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap();
let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", c, SEED);
let vesting = Some((100_000u32.into(), 1_000u32.into(), 100u32.into()));
let statement = StatementKind::Regular;
super::Pallet::<T>::mint_claim(
RawOrigin::Root.into(),
eth_address,
VALUE.into(),
vesting,
Some(statement),
)?;
Preclaims::<T>::insert(&account, eth_address);
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
#[block]
{
assert!(ext
.test_run(RawOrigin::Signed(account).into(), &call, &info, 0, 0, |_| {
Ok(Default::default())
})
.unwrap()
.is_ok());
}
Ok(())
}
impl_benchmark_test_suite!(
Pallet,
crate::claims::mock::new_test_ext(),
crate::claims::mock::Test,
);
}
+129
View File
@@ -0,0 +1,129 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in claims pallet.
#[cfg(test)]
use super::*;
use secp_utils::*;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use crate::claims;
use frame_support::{derive_impl, ord_parameter_types, parameter_types, traits::WithdrawReasons};
use pallet_balances;
use sp_runtime::{traits::Identity, BuildStorage};
type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Vesting: pallet_vesting,
Claims: claims,
}
);
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type AccountData = pallet_balances::AccountData<u64>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type AccountStore = System;
}
parameter_types! {
pub const MinVestedTransfer: u64 = 1;
pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
}
impl pallet_vesting::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BlockNumberToBalance = Identity;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = ();
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
type BlockNumberProvider = System;
const MAX_VESTING_SCHEDULES: u32 = 28;
}
parameter_types! {
pub Prefix: &'static [u8] = b"Pay RUSTs to the TEST account:";
}
ord_parameter_types! {
pub const Six: u64 = 6;
}
impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type VestingSchedule = Vesting;
type Prefix = Prefix;
type MoveClaimOrigin = frame_system::EnsureSignedBy<Six, u64>;
type WeightInfo = TestWeightInfo;
}
pub fn alice() -> libsecp256k1::SecretKey {
libsecp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap()
}
pub fn bob() -> libsecp256k1::SecretKey {
libsecp256k1::SecretKey::parse(&keccak_256(b"Bob")).unwrap()
}
pub fn dave() -> libsecp256k1::SecretKey {
libsecp256k1::SecretKey::parse(&keccak_256(b"Dave")).unwrap()
}
pub fn eve() -> libsecp256k1::SecretKey {
libsecp256k1::SecretKey::parse(&keccak_256(b"Eve")).unwrap()
}
pub fn frank() -> libsecp256k1::SecretKey {
libsecp256k1::SecretKey::parse(&keccak_256(b"Frank")).unwrap()
}
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
// We use default for brevity, but you can configure as desired if needed.
pallet_balances::GenesisConfig::<Test>::default()
.assimilate_storage(&mut t)
.unwrap();
claims::GenesisConfig::<Test> {
claims: vec![
(eth(&alice()), 100, None, None),
(eth(&dave()), 200, None, Some(StatementKind::Regular)),
(eth(&eve()), 300, Some(42), Some(StatementKind::Saft)),
(eth(&frank()), 400, Some(43), None),
],
vesting: vec![(eth(&alice()), (50, 10, 1))],
}
.assimilate_storage(&mut t)
.unwrap();
t.into()
}
pub fn total_claims() -> u64 {
100 + 200 + 300 + 400
}
+741
View File
@@ -0,0 +1,741 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Pallet to process claims from Ethereum addresses.
#[cfg(not(feature = "std"))]
use alloc::{format, string::String};
use alloc::{vec, vec::Vec};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use core::fmt::Debug;
use frame_support::{
ensure,
traits::{Currency, Get, IsSubType, VestingSchedule},
weights::Weight,
DefaultNoBound,
};
pub use pallet::*;
use pezkuwi_primitives::ValidityError;
use scale_info::TypeInfo;
use serde::{self, Deserialize, Deserializer, Serialize, Serializer};
use sp_io::{crypto::secp256k1_ecdsa_recover, hashing::keccak_256};
use sp_runtime::{
impl_tx_ext_default,
traits::{
AsSystemOriginSigner, AsTransactionAuthorizedOrigin, CheckedSub, DispatchInfoOf,
Dispatchable, TransactionExtension, Zero,
},
transaction_validity::{
InvalidTransaction, TransactionSource, TransactionValidity, TransactionValidityError,
ValidTransaction,
},
RuntimeDebug,
};
type CurrencyOf<T> = <<T as Config>::VestingSchedule as VestingSchedule<
<T as frame_system::Config>::AccountId,
>>::Currency;
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;
pub trait WeightInfo {
fn claim() -> Weight;
fn mint_claim() -> Weight;
fn claim_attest() -> Weight;
fn attest() -> Weight;
fn move_claim() -> Weight;
fn prevalidate_attests() -> Weight;
}
pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn claim() -> Weight {
Weight::zero()
}
fn mint_claim() -> Weight {
Weight::zero()
}
fn claim_attest() -> Weight {
Weight::zero()
}
fn attest() -> Weight {
Weight::zero()
}
fn move_claim() -> Weight {
Weight::zero()
}
fn prevalidate_attests() -> Weight {
Weight::zero()
}
}
/// The kind of statement an account needs to make for a claim to be valid.
#[derive(
Encode,
Decode,
DecodeWithMemTracking,
Clone,
Copy,
Eq,
PartialEq,
RuntimeDebug,
TypeInfo,
Serialize,
Deserialize,
MaxEncodedLen,
)]
pub enum StatementKind {
/// Statement required to be made by non-SAFT holders.
Regular,
/// Statement required to be made by SAFT holders.
Saft,
}
impl StatementKind {
/// Convert this to the (English) statement it represents.
fn to_text(self) -> &'static [u8] {
match self {
StatementKind::Regular =>
&b"I hereby agree to the terms of the statement whose SHA-256 multihash is \
Qmc1XYqT6S39WNp2UeiRUrZichUWUPpGEThDE6dAb3f6Ny. (This may be found at the URL: \
https://statement.polkadot.network/regular.html)"[..],
StatementKind::Saft =>
&b"I hereby agree to the terms of the statement whose SHA-256 multihash is \
QmXEkMahfhHJPzT3RjkXiZVFi77ZeVeuxtAjhojGRNYckz. (This may be found at the URL: \
https://statement.polkadot.network/saft.html)"[..],
}
}
}
impl Default for StatementKind {
fn default() -> Self {
StatementKind::Regular
}
}
/// An Ethereum address (i.e. 20 bytes, used to represent an Ethereum account).
///
/// This gets serialized to the 0x-prefixed hex representation.
#[derive(
Clone,
Copy,
PartialEq,
Eq,
Encode,
Decode,
DecodeWithMemTracking,
Default,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
)]
pub struct EthereumAddress(pub [u8; 20]);
impl Serialize for EthereumAddress {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let hex: String = rustc_hex::ToHex::to_hex(&self.0[..]);
serializer.serialize_str(&format!("0x{}", hex))
}
}
impl<'de> Deserialize<'de> for EthereumAddress {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let base_string = String::deserialize(deserializer)?;
let offset = if base_string.starts_with("0x") { 2 } else { 0 };
let s = &base_string[offset..];
if s.len() != 40 {
Err(serde::de::Error::custom(
"Bad length of Ethereum address (should be 42 including '0x')",
))?;
}
let raw: Vec<u8> = rustc_hex::FromHex::from_hex(s)
.map_err(|e| serde::de::Error::custom(format!("{:?}", e)))?;
let mut r = Self::default();
r.0.copy_from_slice(&raw);
Ok(r)
}
}
impl AsRef<[u8]> for EthereumAddress {
fn as_ref(&self) -> &[u8] {
&self.0[..]
}
}
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, TypeInfo, MaxEncodedLen)]
pub struct EcdsaSignature(pub [u8; 65]);
impl PartialEq for EcdsaSignature {
fn eq(&self, other: &Self) -> bool {
&self.0[..] == &other.0[..]
}
}
impl core::fmt::Debug for EcdsaSignature {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "EcdsaSignature({:?})", &self.0[..])
}
}
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
/// Configuration trait.
#[pallet::config]
pub trait Config: frame_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
type VestingSchedule: VestingSchedule<Self::AccountId, Moment = BlockNumberFor<Self>>;
#[pallet::constant]
type Prefix: Get<&'static [u8]>;
type MoveClaimOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// Someone claimed some DOTs.
Claimed { who: T::AccountId, ethereum_address: EthereumAddress, amount: BalanceOf<T> },
}
#[pallet::error]
pub enum Error<T> {
/// Invalid Ethereum signature.
InvalidEthereumSignature,
/// Ethereum address has no claim.
SignerHasNoClaim,
/// Account ID sending transaction has no claim.
SenderHasNoClaim,
/// There's not enough in the pot to pay out some unvested amount. Generally implies a
/// logic error.
PotUnderflow,
/// A needed statement was not included.
InvalidStatement,
/// The account already has a vested balance.
VestedBalanceExists,
}
#[pallet::storage]
pub type Claims<T: Config> = StorageMap<_, Identity, EthereumAddress, BalanceOf<T>>;
#[pallet::storage]
pub type Total<T: Config> = StorageValue<_, BalanceOf<T>, ValueQuery>;
/// Vesting schedule for a claim.
/// First balance is the total amount that should be held for vesting.
/// Second balance is how much should be unlocked per block.
/// The block number is when the vesting should start.
#[pallet::storage]
pub type Vesting<T: Config> =
StorageMap<_, Identity, EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>;
/// The statement kind that must be signed, if any.
#[pallet::storage]
pub type Signing<T> = StorageMap<_, Identity, EthereumAddress, StatementKind>;
/// Pre-claimed Ethereum accounts, by the Account ID that they are claimed to.
#[pallet::storage]
pub type Preclaims<T: Config> = StorageMap<_, Identity, T::AccountId, EthereumAddress>;
#[pallet::genesis_config]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
pub claims:
Vec<(EthereumAddress, BalanceOf<T>, Option<T::AccountId>, Option<StatementKind>)>,
pub vesting: Vec<(EthereumAddress, (BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>))>,
}
#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
// build `Claims`
self.claims.iter().map(|(a, b, _, _)| (*a, *b)).for_each(|(a, b)| {
Claims::<T>::insert(a, b);
});
// build `Total`
Total::<T>::put(
self.claims
.iter()
.fold(Zero::zero(), |acc: BalanceOf<T>, &(_, b, _, _)| acc + b),
);
// build `Vesting`
self.vesting.iter().for_each(|(k, v)| {
Vesting::<T>::insert(k, v);
});
// build `Signing`
self.claims
.iter()
.filter_map(|(a, _, _, s)| Some((*a, (*s)?)))
.for_each(|(a, s)| {
Signing::<T>::insert(a, s);
});
// build `Preclaims`
self.claims.iter().filter_map(|(a, _, i, _)| Some((i.clone()?, *a))).for_each(
|(i, a)| {
Preclaims::<T>::insert(i, a);
},
);
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Make a claim to collect your DOTs.
///
/// The dispatch origin for this call must be _None_.
///
/// Unsigned Validation:
/// A call to claim is deemed valid if the signature provided matches
/// the expected signed message of:
///
/// > Ethereum Signed Message:
/// > (configured prefix string)(address)
///
/// and `address` matches the `dest` account.
///
/// Parameters:
/// - `dest`: The destination account to payout the claim.
/// - `ethereum_signature`: The signature of an ethereum signed message matching the format
/// described above.
///
/// <weight>
/// The weight of this call is invariant over the input parameters.
/// Weight includes logic to validate unsigned `claim` call.
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(0)]
#[pallet::weight(T::WeightInfo::claim())]
pub fn claim(
origin: OriginFor<T>,
dest: T::AccountId,
ethereum_signature: EcdsaSignature,
) -> DispatchResult {
ensure_none(origin)?;
let data = dest.using_encoded(to_ascii_hex);
let signer = Self::eth_recover(&ethereum_signature, &data, &[][..])
.ok_or(Error::<T>::InvalidEthereumSignature)?;
ensure!(Signing::<T>::get(&signer).is_none(), Error::<T>::InvalidStatement);
Self::process_claim(signer, dest)?;
Ok(())
}
/// Mint a new claim to collect DOTs.
///
/// The dispatch origin for this call must be _Root_.
///
/// Parameters:
/// - `who`: The Ethereum address allowed to collect this claim.
/// - `value`: The number of DOTs that will be claimed.
/// - `vesting_schedule`: An optional vesting schedule for these DOTs.
///
/// <weight>
/// The weight of this call is invariant over the input parameters.
/// We assume worst case that both vesting and statement is being inserted.
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(1)]
#[pallet::weight(T::WeightInfo::mint_claim())]
pub fn mint_claim(
origin: OriginFor<T>,
who: EthereumAddress,
value: BalanceOf<T>,
vesting_schedule: Option<(BalanceOf<T>, BalanceOf<T>, BlockNumberFor<T>)>,
statement: Option<StatementKind>,
) -> DispatchResult {
ensure_root(origin)?;
Total::<T>::mutate(|t| *t += value);
Claims::<T>::insert(who, value);
if let Some(vs) = vesting_schedule {
Vesting::<T>::insert(who, vs);
}
if let Some(s) = statement {
Signing::<T>::insert(who, s);
}
Ok(())
}
/// Make a claim to collect your DOTs by signing a statement.
///
/// The dispatch origin for this call must be _None_.
///
/// Unsigned Validation:
/// A call to `claim_attest` is deemed valid if the signature provided matches
/// the expected signed message of:
///
/// > Ethereum Signed Message:
/// > (configured prefix string)(address)(statement)
///
/// and `address` matches the `dest` account; the `statement` must match that which is
/// expected according to your purchase arrangement.
///
/// Parameters:
/// - `dest`: The destination account to payout the claim.
/// - `ethereum_signature`: The signature of an ethereum signed message matching the format
/// described above.
/// - `statement`: The identity of the statement which is being attested to in the
/// signature.
///
/// <weight>
/// The weight of this call is invariant over the input parameters.
/// Weight includes logic to validate unsigned `claim_attest` call.
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(2)]
#[pallet::weight(T::WeightInfo::claim_attest())]
pub fn claim_attest(
origin: OriginFor<T>,
dest: T::AccountId,
ethereum_signature: EcdsaSignature,
statement: Vec<u8>,
) -> DispatchResult {
ensure_none(origin)?;
let data = dest.using_encoded(to_ascii_hex);
let signer = Self::eth_recover(&ethereum_signature, &data, &statement)
.ok_or(Error::<T>::InvalidEthereumSignature)?;
if let Some(s) = Signing::<T>::get(signer) {
ensure!(s.to_text() == &statement[..], Error::<T>::InvalidStatement);
}
Self::process_claim(signer, dest)?;
Ok(())
}
/// Attest to a statement, needed to finalize the claims process.
///
/// WARNING: Insecure unless your chain includes `PrevalidateAttests` as a
/// `TransactionExtension`.
///
/// Unsigned Validation:
/// A call to attest is deemed valid if the sender has a `Preclaim` registered
/// and provides a `statement` which is expected for the account.
///
/// Parameters:
/// - `statement`: The identity of the statement which is being attested to in the
/// signature.
///
/// <weight>
/// The weight of this call is invariant over the input parameters.
/// Weight includes logic to do pre-validation on `attest` call.
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::call_index(3)]
#[pallet::weight((
T::WeightInfo::attest(),
DispatchClass::Normal,
Pays::No
))]
pub fn attest(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResult {
let who = ensure_signed(origin)?;
let signer = Preclaims::<T>::get(&who).ok_or(Error::<T>::SenderHasNoClaim)?;
if let Some(s) = Signing::<T>::get(signer) {
ensure!(s.to_text() == &statement[..], Error::<T>::InvalidStatement);
}
Self::process_claim(signer, who.clone())?;
Preclaims::<T>::remove(&who);
Ok(())
}
#[pallet::call_index(4)]
#[pallet::weight(T::WeightInfo::move_claim())]
pub fn move_claim(
origin: OriginFor<T>,
old: EthereumAddress,
new: EthereumAddress,
maybe_preclaim: Option<T::AccountId>,
) -> DispatchResultWithPostInfo {
T::MoveClaimOrigin::try_origin(origin).map(|_| ()).or_else(ensure_root)?;
Claims::<T>::take(&old).map(|c| Claims::<T>::insert(&new, c));
Vesting::<T>::take(&old).map(|c| Vesting::<T>::insert(&new, c));
Signing::<T>::take(&old).map(|c| Signing::<T>::insert(&new, c));
maybe_preclaim.map(|preclaim| {
Preclaims::<T>::mutate(&preclaim, |maybe_o| {
if maybe_o.as_ref().map_or(false, |o| o == &old) {
*maybe_o = Some(new)
}
})
});
Ok(Pays::No.into())
}
}
#[pallet::validate_unsigned]
impl<T: Config> ValidateUnsigned for Pallet<T> {
type Call = Call<T>;
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
const PRIORITY: u64 = 100;
let (maybe_signer, maybe_statement) = match call {
// <weight>
// The weight of this logic is included in the `claim` dispatchable.
// </weight>
Call::claim { dest: account, ethereum_signature } => {
let data = account.using_encoded(to_ascii_hex);
(Self::eth_recover(&ethereum_signature, &data, &[][..]), None)
},
// <weight>
// The weight of this logic is included in the `claim_attest` dispatchable.
// </weight>
Call::claim_attest { dest: account, ethereum_signature, statement } => {
let data = account.using_encoded(to_ascii_hex);
(
Self::eth_recover(&ethereum_signature, &data, &statement),
Some(statement.as_slice()),
)
},
_ => return Err(InvalidTransaction::Call.into()),
};
let signer = maybe_signer.ok_or(InvalidTransaction::Custom(
ValidityError::InvalidEthereumSignature.into(),
))?;
let e = InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into());
ensure!(Claims::<T>::contains_key(&signer), e);
let e = InvalidTransaction::Custom(ValidityError::InvalidStatement.into());
match Signing::<T>::get(signer) {
None => ensure!(maybe_statement.is_none(), e),
Some(s) => ensure!(Some(s.to_text()) == maybe_statement, e),
}
Ok(ValidTransaction {
priority: PRIORITY,
requires: vec![],
provides: vec![("claims", signer).encode()],
longevity: TransactionLongevity::max_value(),
propagate: true,
})
}
}
}
/// Converts the given binary data into ASCII-encoded hex. It will be twice the length.
fn to_ascii_hex(data: &[u8]) -> Vec<u8> {
let mut r = Vec::with_capacity(data.len() * 2);
let mut push_nibble = |n| r.push(if n < 10 { b'0' + n } else { b'a' - 10 + n });
for &b in data.iter() {
push_nibble(b / 16);
push_nibble(b % 16);
}
r
}
impl<T: Config> Pallet<T> {
// Constructs the message that Ethereum RPC's `personal_sign` and `eth_sign` would sign.
fn ethereum_signable_message(what: &[u8], extra: &[u8]) -> Vec<u8> {
let prefix = T::Prefix::get();
let mut l = prefix.len() + what.len() + extra.len();
let mut rev = Vec::new();
while l > 0 {
rev.push(b'0' + (l % 10) as u8);
l /= 10;
}
let mut v = b"\x19Ethereum Signed Message:\n".to_vec();
v.extend(rev.into_iter().rev());
v.extend_from_slice(prefix);
v.extend_from_slice(what);
v.extend_from_slice(extra);
v
}
// Attempts to recover the Ethereum address from a message signature signed by using
// the Ethereum RPC's `personal_sign` and `eth_sign`.
fn eth_recover(s: &EcdsaSignature, what: &[u8], extra: &[u8]) -> Option<EthereumAddress> {
let msg = keccak_256(&Self::ethereum_signable_message(what, extra));
let mut res = EthereumAddress::default();
res.0
.copy_from_slice(&keccak_256(&secp256k1_ecdsa_recover(&s.0, &msg).ok()?[..])[12..]);
Some(res)
}
fn process_claim(signer: EthereumAddress, dest: T::AccountId) -> sp_runtime::DispatchResult {
let balance_due = Claims::<T>::get(&signer).ok_or(Error::<T>::SignerHasNoClaim)?;
let new_total =
Total::<T>::get().checked_sub(&balance_due).ok_or(Error::<T>::PotUnderflow)?;
let vesting = Vesting::<T>::get(&signer);
if vesting.is_some() && T::VestingSchedule::vesting_balance(&dest).is_some() {
return Err(Error::<T>::VestedBalanceExists.into());
}
// We first need to deposit the balance to ensure that the account exists.
let _ = CurrencyOf::<T>::deposit_creating(&dest, balance_due);
// Check if this claim should have a vesting schedule.
if let Some(vs) = vesting {
// This can only fail if the account already has a vesting schedule,
// but this is checked above.
T::VestingSchedule::add_vesting_schedule(&dest, vs.0, vs.1, vs.2)
.expect("No other vesting schedule exists, as checked above; qed");
}
Total::<T>::put(new_total);
Claims::<T>::remove(&signer);
Vesting::<T>::remove(&signer);
Signing::<T>::remove(&signer);
// Let's deposit an event to let the outside world know this happened.
Self::deposit_event(Event::<T>::Claimed {
who: dest,
ethereum_address: signer,
amount: balance_due,
});
Ok(())
}
}
/// Validate `attest` calls prior to execution. Needed to avoid a DoS attack since they are
/// otherwise free to place on chain.
#[derive(Encode, Decode, DecodeWithMemTracking, Clone, Eq, PartialEq, TypeInfo)]
#[scale_info(skip_type_params(T))]
pub struct PrevalidateAttests<T>(core::marker::PhantomData<fn(T)>);
impl<T: Config> Debug for PrevalidateAttests<T>
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
#[cfg(feature = "std")]
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
write!(f, "PrevalidateAttests")
}
#[cfg(not(feature = "std"))]
fn fmt(&self, _: &mut core::fmt::Formatter) -> core::fmt::Result {
Ok(())
}
}
impl<T: Config> PrevalidateAttests<T>
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
{
/// Create new `TransactionExtension` to check runtime version.
pub fn new() -> Self {
Self(core::marker::PhantomData)
}
}
impl<T: Config> TransactionExtension<T::RuntimeCall> for PrevalidateAttests<T>
where
<T as frame_system::Config>::RuntimeCall: IsSubType<Call<T>>,
<<T as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin:
AsSystemOriginSigner<T::AccountId> + AsTransactionAuthorizedOrigin + Clone,
{
const IDENTIFIER: &'static str = "PrevalidateAttests";
type Implicit = ();
type Pre = ();
type Val = ();
fn weight(&self, call: &T::RuntimeCall) -> Weight {
if let Some(Call::attest { .. }) = call.is_sub_type() {
T::WeightInfo::prevalidate_attests()
} else {
Weight::zero()
}
}
fn validate(
&self,
origin: <T::RuntimeCall as Dispatchable>::RuntimeOrigin,
call: &T::RuntimeCall,
_info: &DispatchInfoOf<T::RuntimeCall>,
_len: usize,
_self_implicit: Self::Implicit,
_inherited_implication: &impl Encode,
_source: TransactionSource,
) -> Result<
(ValidTransaction, Self::Val, <T::RuntimeCall as Dispatchable>::RuntimeOrigin),
TransactionValidityError,
> {
if let Some(Call::attest { statement: attested_statement }) = call.is_sub_type() {
let who = origin.as_system_origin_signer().ok_or(InvalidTransaction::BadSigner)?;
let signer = Preclaims::<T>::get(who)
.ok_or(InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()))?;
if let Some(s) = Signing::<T>::get(signer) {
let e = InvalidTransaction::Custom(ValidityError::InvalidStatement.into());
ensure!(&attested_statement[..] == s.to_text(), e);
}
}
Ok((ValidTransaction::default(), (), origin))
}
impl_tx_ext_default!(T::RuntimeCall; prepare);
}
#[cfg(any(test, feature = "runtime-benchmarks"))]
mod secp_utils {
use super::*;
pub fn public(secret: &libsecp256k1::SecretKey) -> libsecp256k1::PublicKey {
libsecp256k1::PublicKey::from_secret_key(secret)
}
pub fn eth(secret: &libsecp256k1::SecretKey) -> EthereumAddress {
let mut res = EthereumAddress::default();
res.0.copy_from_slice(&keccak_256(&public(secret).serialize()[1..65])[12..]);
res
}
pub fn sig<T: Config>(
secret: &libsecp256k1::SecretKey,
what: &[u8],
extra: &[u8],
) -> EcdsaSignature {
let msg = keccak_256(&super::Pallet::<T>::ethereum_signable_message(
&to_ascii_hex(what)[..],
extra,
));
let (sig, recovery_id) = libsecp256k1::sign(&libsecp256k1::Message::parse(&msg), secret);
let mut r = [0u8; 65];
r[0..64].copy_from_slice(&sig.serialize()[..]);
r[64] = recovery_id.serialize();
EcdsaSignature(r)
}
}
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
+666
View File
@@ -0,0 +1,666 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the claims pallet.
#[cfg(test)]
use super::*;
use crate::{claims, claims::mock::*};
use claims::Call as ClaimsCall;
use hex_literal::hex;
use secp_utils::*;
use sp_runtime::transaction_validity::TransactionSource::External;
use codec::Encode;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use frame_support::{
assert_err, assert_noop, assert_ok,
dispatch::{GetDispatchInfo, Pays},
traits::ExistenceRequirement,
};
use sp_runtime::{
traits::DispatchTransaction, transaction_validity::TransactionLongevity,
DispatchError::BadOrigin, TokenError,
};
#[test]
fn basic_setup_works() {
new_test_ext().execute_with(|| {
assert_eq!(claims::Total::<Test>::get(), total_claims());
assert_eq!(claims::Claims::<Test>::get(&eth(&alice())), Some(100));
assert_eq!(claims::Claims::<Test>::get(&eth(&dave())), Some(200));
assert_eq!(claims::Claims::<Test>::get(&eth(&eve())), Some(300));
assert_eq!(claims::Claims::<Test>::get(&eth(&frank())), Some(400));
assert_eq!(claims::Claims::<Test>::get(&EthereumAddress::default()), None);
assert_eq!(claims::Vesting::<Test>::get(&eth(&alice())), Some((50, 10, 1)));
});
}
#[test]
fn serde_works() {
let x = EthereumAddress(hex!["0123456789abcdef0123456789abcdef01234567"]);
let y = serde_json::to_string(&x).unwrap();
assert_eq!(y, "\"0x0123456789abcdef0123456789abcdef01234567\"");
let z: EthereumAddress = serde_json::from_str(&y).unwrap();
assert_eq!(x, z);
}
#[test]
fn claiming_works() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
));
assert_eq!(Balances::free_balance(&42), 100);
assert_eq!(claims::mock::Vesting::vesting_balance(&42), Some(50));
assert_eq!(claims::Total::<Test>::get(), total_claims() - 100);
});
}
#[test]
fn basic_claim_moving_works() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
claims::mock::Claims::move_claim(
RuntimeOrigin::signed(1),
eth(&alice()),
eth(&bob()),
None
),
BadOrigin
);
assert_ok!(claims::mock::Claims::move_claim(
RuntimeOrigin::signed(6),
eth(&alice()),
eth(&bob()),
None
));
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim
);
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&bob(), &42u64.encode(), &[][..])
));
assert_eq!(Balances::free_balance(&42), 100);
assert_eq!(claims::mock::Vesting::vesting_balance(&42), Some(50));
assert_eq!(claims::Total::<Test>::get(), total_claims() - 100);
});
}
#[test]
fn claim_attest_moving_works() {
new_test_ext().execute_with(|| {
assert_ok!(claims::mock::Claims::move_claim(
RuntimeOrigin::signed(6),
eth(&dave()),
eth(&bob()),
None
));
let s = sig::<Test>(&bob(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
42,
s,
StatementKind::Regular.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 200);
});
}
#[test]
fn attest_moving_works() {
new_test_ext().execute_with(|| {
assert_ok!(claims::mock::Claims::move_claim(
RuntimeOrigin::signed(6),
eth(&eve()),
eth(&bob()),
Some(42)
));
assert_ok!(claims::mock::Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Saft.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 300);
});
}
#[test]
fn claiming_does_not_bypass_signing() {
new_test_ext().execute_with(|| {
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
));
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&dave(), &42u64.encode(), &[][..])
),
Error::<Test>::InvalidStatement,
);
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&eve(), &42u64.encode(), &[][..])
),
Error::<Test>::InvalidStatement,
);
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&frank(), &42u64.encode(), &[][..])
));
});
}
#[test]
fn attest_claiming_works() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text());
let r = claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
42,
s.clone(),
StatementKind::Saft.to_text().to_vec(),
);
assert_noop!(r, Error::<Test>::InvalidStatement);
let r = claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
42,
s,
StatementKind::Regular.to_text().to_vec(),
);
assert_noop!(r, Error::<Test>::SignerHasNoClaim);
// ^^^ we use ecdsa_recover, so an invalid signature just results in a random signer id
// being recovered, which realistically will never have a claim.
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
42,
s,
StatementKind::Regular.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 200);
assert_eq!(claims::Total::<Test>::get(), total_claims() - 200);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
let r = claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
42,
s,
StatementKind::Regular.to_text().to_vec(),
);
assert_noop!(r, Error::<Test>::SignerHasNoClaim);
});
}
#[test]
fn attesting_works() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
claims::mock::Claims::attest(
RuntimeOrigin::signed(69),
StatementKind::Saft.to_text().to_vec()
),
Error::<Test>::SenderHasNoClaim
);
assert_noop!(
claims::mock::Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Regular.to_text().to_vec()
),
Error::<Test>::InvalidStatement
);
assert_ok!(claims::mock::Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Saft.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 300);
assert_eq!(claims::Total::<Test>::get(), total_claims() - 300);
});
}
#[test]
fn claim_cannot_clobber_preclaim() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
// Alice's claim is 100
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
));
assert_eq!(Balances::free_balance(&42), 100);
// Eve's claim is 300 through Account 42
assert_ok!(claims::mock::Claims::attest(
RuntimeOrigin::signed(42),
StatementKind::Saft.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&42), 100 + 300);
assert_eq!(claims::Total::<Test>::get(), total_claims() - 400);
});
}
#[test]
fn valid_attest_transactions_are_free() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = claims::mock::RuntimeCall::Claims(ClaimsCall::attest {
statement: StatementKind::Saft.to_text().to_vec(),
});
let di = c.get_dispatch_info();
assert_eq!(di.pays_fee, Pays::No);
let r = p.validate_only(Some(42).into(), &c, &di, 20, External, 0);
assert_eq!(r.unwrap().0, ValidTransaction::default());
});
}
#[test]
fn invalid_attest_transactions_are_recognized() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = claims::mock::RuntimeCall::Claims(ClaimsCall::attest {
statement: StatementKind::Regular.to_text().to_vec(),
});
let di = c.get_dispatch_info();
let r = p.validate_only(Some(42).into(), &c, &di, 20, External, 0);
assert!(r.is_err());
let c = claims::mock::RuntimeCall::Claims(ClaimsCall::attest {
statement: StatementKind::Saft.to_text().to_vec(),
});
let di = c.get_dispatch_info();
let r = p.validate_only(Some(69).into(), &c, &di, 20, External, 0);
assert!(r.is_err());
});
}
#[test]
fn cannot_bypass_attest_claiming() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), &[]);
let r = claims::mock::Claims::claim(RuntimeOrigin::none(), 42, s.clone());
assert_noop!(r, Error::<Test>::InvalidStatement);
});
}
#[test]
fn add_claim_works() {
new_test_ext().execute_with(|| {
assert_noop!(
claims::mock::Claims::mint_claim(
RuntimeOrigin::signed(42),
eth(&bob()),
200,
None,
None
),
sp_runtime::traits::BadOrigin,
);
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim,
);
assert_ok!(claims::mock::Claims::mint_claim(
RuntimeOrigin::root(),
eth(&bob()),
200,
None,
None
));
assert_eq!(claims::Total::<Test>::get(), total_claims() + 200);
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
));
assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(claims::mock::Vesting::vesting_balance(&69), None);
assert_eq!(claims::Total::<Test>::get(), total_claims());
});
}
#[test]
fn add_claim_with_vesting_works() {
new_test_ext().execute_with(|| {
assert_noop!(
claims::mock::Claims::mint_claim(
RuntimeOrigin::signed(42),
eth(&bob()),
200,
Some((50, 10, 1)),
None
),
sp_runtime::traits::BadOrigin,
);
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim,
);
assert_ok!(claims::mock::Claims::mint_claim(
RuntimeOrigin::root(),
eth(&bob()),
200,
Some((50, 10, 1)),
None
));
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
));
assert_eq!(Balances::free_balance(&69), 200);
assert_eq!(claims::mock::Vesting::vesting_balance(&69), Some(50));
// Make sure we can not transfer the vested balance.
assert_err!(
<Balances as Currency<_>>::transfer(&69, &80, 180, ExistenceRequirement::AllowDeath),
TokenError::Frozen,
);
});
}
#[test]
fn add_claim_with_statement_works() {
new_test_ext().execute_with(|| {
assert_noop!(
claims::mock::Claims::mint_claim(
RuntimeOrigin::signed(42),
eth(&bob()),
200,
None,
Some(StatementKind::Regular)
),
sp_runtime::traits::BadOrigin,
);
assert_eq!(Balances::free_balance(42), 0);
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text());
assert_noop!(
claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
69,
signature.clone(),
StatementKind::Regular.to_text().to_vec()
),
Error::<Test>::SignerHasNoClaim
);
assert_ok!(claims::mock::Claims::mint_claim(
RuntimeOrigin::root(),
eth(&bob()),
200,
None,
Some(StatementKind::Regular)
));
assert_noop!(
claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
69,
signature.clone(),
vec![],
),
Error::<Test>::SignerHasNoClaim
);
assert_ok!(claims::mock::Claims::claim_attest(
RuntimeOrigin::none(),
69,
signature.clone(),
StatementKind::Regular.to_text().to_vec()
));
assert_eq!(Balances::free_balance(&69), 200);
});
}
#[test]
fn origin_signed_claiming_fail() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_err!(
claims::mock::Claims::claim(
RuntimeOrigin::signed(42),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
),
sp_runtime::traits::BadOrigin,
);
});
}
#[test]
fn double_claiming_doesnt_work() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_ok!(claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
));
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &42u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim
);
});
}
#[test]
fn claiming_while_vested_doesnt_work() {
new_test_ext().execute_with(|| {
CurrencyOf::<Test>::make_free_balance_be(&69, total_claims());
assert_eq!(Balances::free_balance(69), total_claims());
// A user is already vested
assert_ok!(<Test as Config>::VestingSchedule::add_vesting_schedule(
&69,
total_claims(),
100,
10
));
assert_ok!(claims::mock::Claims::mint_claim(
RuntimeOrigin::root(),
eth(&bob()),
200,
Some((50, 10, 1)),
None
));
// New total
assert_eq!(claims::Total::<Test>::get(), total_claims() + 200);
// They should not be able to claim
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
69,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::VestedBalanceExists,
);
});
}
#[test]
fn non_sender_sig_doesnt_work() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&alice(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim
);
});
}
#[test]
fn non_claimant_doesnt_work() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(
claims::mock::Claims::claim(
RuntimeOrigin::none(),
42,
sig::<Test>(&bob(), &69u64.encode(), &[][..])
),
Error::<Test>::SignerHasNoClaim
);
});
}
#[test]
fn real_eth_sig_works() {
new_test_ext().execute_with(|| {
// "Pay RUSTs to the TEST account:2a00000000000000"
let sig = hex!["444023e89b67e67c0562ed0305d252a5dd12b2af5ac51d6d3cb69a0b486bc4b3191401802dc29d26d586221f7256cd3329fe82174bdf659baea149a40e1c495d1c"];
let sig = EcdsaSignature(sig);
let who = 42u64.using_encoded(to_ascii_hex);
let signer = claims::mock::Claims::eth_recover(&sig, &who, &[][..]).unwrap();
assert_eq!(signer.0, hex!["6d31165d5d932d571f3b44695653b46dcc327e84"]);
});
}
#[test]
fn validate_unsigned_works() {
use sp_runtime::traits::ValidateUnsigned;
let source = sp_runtime::transaction_validity::TransactionSource::External;
new_test_ext().execute_with(|| {
assert_eq!(
Pallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim {
dest: 1,
ethereum_signature: sig::<Test>(&alice(), &1u64.encode(), &[][..])
}
),
Ok(ValidTransaction {
priority: 100,
requires: vec![],
provides: vec![("claims", eth(&alice())).encode()],
longevity: TransactionLongevity::max_value(),
propagate: true,
})
);
assert_eq!(
Pallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim { dest: 0, ethereum_signature: EcdsaSignature([0; 65]) }
),
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
assert_eq!(
Pallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim {
dest: 1,
ethereum_signature: sig::<Test>(&bob(), &1u64.encode(), &[][..])
}
),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
Ok(ValidTransaction {
priority: 100,
requires: vec![],
provides: vec![("claims", eth(&dave())).encode()],
longevity: TransactionLongevity::max_value(),
propagate: true,
})
);
assert_eq!(
Pallet::<Test>::validate_unsigned(
source,
&ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: EcdsaSignature([0; 65]),
statement: StatementKind::Regular.to_text().to_vec()
}
),
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
let s = sig::<Test>(&bob(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Regular.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest {
dest: 1,
ethereum_signature: s,
statement: StatementKind::Saft.to_text().to_vec(),
};
assert_eq!(
Pallet::<Test>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::InvalidStatement.into()).into(),
);
});
}
@@ -0,0 +1,227 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::*;
use frame_support::{
storage_alias,
traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion},
Twox64Concat,
};
pub struct MigrateToTrackInactiveV2<T>(core::marker::PhantomData<T>);
impl<T: Config> OnRuntimeUpgrade for MigrateToTrackInactiveV2<T> {
fn on_runtime_upgrade() -> Weight {
let on_chain_version = Pallet::<T>::on_chain_storage_version();
if on_chain_version == 1 {
let mut translated = 0u64;
for item in Funds::<T>::iter_values() {
let b =
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(item.fund_index));
CurrencyOf::<T>::deactivate(b);
translated.saturating_inc();
}
StorageVersion::new(2).put::<Pallet<T>>();
log::info!(target: "runtime::crowdloan", "Summed {} funds, storage to version 1", translated);
T::DbWeight::get().reads_writes(translated * 2 + 1, translated * 2 + 1)
} else {
log::info!(target: "runtime::crowdloan", "Migration did not execute. This probably should be removed");
T::DbWeight::get().reads(1)
}
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
let total = Funds::<T>::iter_values()
.map(|item| {
CurrencyOf::<T>::total_balance(&Pallet::<T>::fund_account_id(item.fund_index))
})
.fold(BalanceOf::<T>::zero(), |a, i| a.saturating_add(i));
Ok((total, CurrencyOf::<T>::active_issuance()).encode())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(total: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
if let Ok((total, active)) = <(BalanceOf<T>, BalanceOf<T>)>::decode(&mut total.as_slice()) {
ensure!(active - total == CurrencyOf::<T>::active_issuance(), "the total be correct");
Ok(())
} else {
Err("the state parameter should be something that was generated by pre_upgrade".into())
}
}
}
/// Migrations for using fund index to create fund accounts instead of para ID.
pub mod crowdloan_index_migration {
use super::*;
#[storage_alias]
type NextTrieIndex<T: Config> = StorageValue<Pallet<T>, FundIndex>;
#[storage_alias]
type Leases<T: Config> = StorageMap<
Slots,
Twox64Concat,
ParaId,
Vec<Option<(<T as frame_system::Config>::AccountId, BalanceOf<T>)>>,
>;
// The old way we generated fund accounts.
fn old_fund_account_id<T: Config>(index: ParaId) -> T::AccountId {
T::PalletId::get().into_sub_account_truncating(index)
}
pub fn pre_migrate<T: Config>() -> Result<(), &'static str> {
// `NextTrieIndex` should have a value.
let next_index = NextTrieIndex::<T>::get().unwrap_or_default();
ensure!(next_index > 0, "Next index is zero, which implies no migration is needed.");
log::info!(
target: "runtime",
"next trie index: {:?}",
next_index,
);
for (para_id, fund) in Funds::<T>::iter() {
let old_fund_account = old_fund_account_id::<T>(para_id);
let total_balance = CurrencyOf::<T>::total_balance(&old_fund_account);
log::info!(
target: "runtime",
"para_id={:?}, old_fund_account={:?}, total_balance={:?}, fund.raised={:?}",
para_id, old_fund_account, total_balance, fund.raised
);
// Each fund should have some non-zero balance.
ensure!(
total_balance >= fund.raised,
"Total balance is not equal to the funds raised."
);
let leases = Leases::<T>::get(para_id).unwrap_or_default();
let mut found_lease_deposit = false;
for (who, _amount) in leases.iter().flatten() {
if *who == old_fund_account {
found_lease_deposit = true;
break;
}
}
if found_lease_deposit {
log::info!(
target: "runtime",
"para_id={:?}, old_fund_account={:?}, leases={:?}",
para_id, old_fund_account, leases,
);
}
}
Ok(())
}
/// This migration converts crowdloans to use a crowdloan index rather than the teyrchain id as
/// a unique identifier. This makes it easier to swap two crowdloans between teyrchains.
pub fn migrate<T: Config>() -> frame_support::weights::Weight {
let mut weight = Weight::zero();
// First migrate `NextTrieIndex` counter to `NextFundIndex`.
let next_index = NextTrieIndex::<T>::take().unwrap_or_default();
NextFundIndex::<T>::set(next_index);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 2));
// Migrate all accounts from `old_fund_account` to `fund_account` using `fund_index`.
for (para_id, fund) in Funds::<T>::iter() {
let old_fund_account = old_fund_account_id::<T>(para_id);
let new_fund_account = Pallet::<T>::fund_account_id(fund.fund_index);
// Funds should only have a free balance and a reserve balance. Both of these are in the
// `Account` storage item, so we just swap them.
let account_info = frame_system::Account::<T>::take(&old_fund_account);
frame_system::Account::<T>::insert(&new_fund_account, account_info);
weight = weight.saturating_add(T::DbWeight::get().reads_writes(1, 2));
let mut leases = Leases::<T>::get(para_id).unwrap_or_default();
for (who, _amount) in leases.iter_mut().flatten() {
if *who == old_fund_account {
*who = new_fund_account.clone();
}
}
Leases::<T>::insert(para_id, leases);
}
weight
}
pub fn post_migrate<T: Config>() -> Result<(), &'static str> {
// `NextTrieIndex` should not have a value, and `NextFundIndex` should.
ensure!(NextTrieIndex::<T>::get().is_none(), "NextTrieIndex still has a value.");
let next_index = NextFundIndex::<T>::get();
log::info!(
target: "runtime",
"next fund index: {:?}",
next_index,
);
ensure!(
next_index > 0,
"NextFundIndex was not migrated or is zero. We assume it cannot be zero else no migration is needed."
);
// Each fund should have balance migrated correctly.
for (para_id, fund) in Funds::<T>::iter() {
// Old fund account is deleted.
let old_fund_account = old_fund_account_id::<T>(para_id);
ensure!(
frame_system::Account::<T>::get(&old_fund_account) == Default::default(),
"Old account wasn't reset to default value."
);
// New fund account has the correct balance.
let new_fund_account = Pallet::<T>::fund_account_id(fund.fund_index);
let total_balance = CurrencyOf::<T>::total_balance(&new_fund_account);
ensure!(
total_balance >= fund.raised,
"Total balance in new account is different than the funds raised."
);
let leases = Leases::<T>::get(para_id).unwrap_or_default();
let mut new_account_found = false;
for (who, _amount) in leases.iter().flatten() {
if *who == old_fund_account {
panic!("Old fund account found after migration!");
} else if *who == new_fund_account {
new_account_found = true;
}
}
if new_account_found {
log::info!(
target: "runtime::crowdloan",
"para_id={:?}, new_fund_account={:?}, leases={:?}",
para_id, new_fund_account, leases,
);
}
}
Ok(())
}
}
File diff suppressed because it is too large Load Diff
+63
View File
@@ -0,0 +1,63 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Code for elections.
/// Implements the weight types for the elections module and a specific
/// runtime.
/// This macro should not be called directly; use
/// [`impl_runtime_weights`](crate::impl_runtime_weights!) instead.
#[macro_export]
macro_rules! impl_elections_weights {
($runtime:ident) => {
parameter_types! {
/// A limit for off-chain phragmen unsigned solution submission.
///
/// We want to keep it as high as possible, but can't risk having it reject,
/// so we always subtract the base block execution weight.
pub OffchainSolutionWeightLimit: Weight = BlockWeights::get()
.get(DispatchClass::Normal)
.max_extrinsic
.expect("Normal extrinsics have weight limit configured by default; qed")
.saturating_sub($runtime::weights::BlockExecutionWeight::get());
/// A limit for off-chain phragmen unsigned solution length.
///
/// We allow up to 90% of the block's size to be consumed by the solution.
pub OffchainSolutionLengthLimit: u32 = Perbill::from_rational(90_u32, 100) *
*BlockLength::get()
.max
.get(DispatchClass::Normal);
}
};
}
/// The numbers configured here could always be more than the the maximum limits of staking pallet
/// to ensure election snapshot will not run out of memory. For now, we set them to smaller values
/// since the staking is bounded and the weight pipeline takes hours for this single pallet.
pub struct BenchmarkConfig;
impl pallet_election_provider_multi_phase::BenchmarkingConfig for BenchmarkConfig {
const VOTERS: [u32; 2] = [1000, 2000];
const TARGETS: [u32; 2] = [500, 1000];
const ACTIVE_VOTERS: [u32; 2] = [500, 800];
const DESIRED_TARGETS: [u32; 2] = [200, 400];
const SNAPSHOT_MAXIMUM_VOTERS: u32 = 1000;
const MINER_MAXIMUM_VOTERS: u32 = 1000;
const MAXIMUM_TARGETS: u32 = 300;
}
/// The accuracy type used for genesis election provider;
pub type OnChainAccuracy = sp_runtime::Perbill;
@@ -0,0 +1,323 @@
// 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 pallet is designed to go into a source chain and destination chain to migrate data. The
//! design motivations are:
//!
//! - Call some function on the source chain that executes some migration (clearing state,
//! forwarding an XCM program).
//! - Call some function (probably from an XCM program) on the destination chain.
//! - Avoid cluttering the source pallet with new dispatchables that are unrelated to its
//! functionality and only used for migration.
//!
//! After the migration is complete, the pallet may be removed from both chains' runtimes as well as
//! the `pezkuwi-runtime-common` crate.
use frame_support::{dispatch::DispatchResult, traits::Currency, weights::Weight};
pub use pallet::*;
use pallet_identity;
use sp_core::Get;
#[cfg(feature = "runtime-benchmarks")]
use frame_benchmarking::{account, v2::*, BenchmarkError};
pub trait WeightInfo {
fn reap_identity(r: u32, s: u32) -> Weight;
fn poke_deposit() -> Weight;
}
impl WeightInfo for () {
fn reap_identity(_r: u32, _s: u32) -> Weight {
Weight::MAX
}
fn poke_deposit() -> Weight {
Weight::MAX
}
}
pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn reap_identity(_r: u32, _s: u32) -> Weight {
Weight::zero()
}
fn poke_deposit() -> Weight {
Weight::zero()
}
}
// Must use the same `Balance` as `T`'s Identity pallet to handle deposits.
type BalanceOf<T> = <<T as pallet_identity::Config>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::Balance;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::{
dispatch::{DispatchResultWithPostInfo, PostDispatchInfo},
pallet_prelude::*,
traits::EnsureOrigin,
};
use frame_system::pallet_prelude::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config + pallet_identity::Config {
/// Overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The origin that can reap identities. Expected to be `EnsureSigned<AccountId>` on the
/// source chain such that anyone can all this function.
type Reaper: EnsureOrigin<Self::RuntimeOrigin>;
/// A handler for what to do when an identity is reaped.
type ReapIdentityHandler: OnReapIdentity<Self::AccountId>;
/// Weight information for the extrinsics in the pallet.
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// The identity and all sub accounts were reaped for `who`.
IdentityReaped { who: T::AccountId },
/// The deposits held for `who` were updated. `identity` is the new deposit held for
/// identity info, and `subs` is the new deposit held for the sub-accounts.
DepositUpdated { who: T::AccountId, identity: BalanceOf<T>, subs: BalanceOf<T> },
}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Reap the `IdentityInfo` of `who` from the Identity pallet of `T`, unreserving any
/// deposits held and removing storage items associated with `who`.
#[pallet::call_index(0)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::reap_identity(
T::MaxRegistrars::get(),
T::MaxSubAccounts::get()
))]
pub fn reap_identity(
origin: OriginFor<T>,
who: T::AccountId,
) -> DispatchResultWithPostInfo {
T::Reaper::ensure_origin(origin)?;
// - number of registrars (required to calculate weight)
// - byte size of `IdentityInfo` (required to calculate remote deposit)
// - number of sub accounts (required to calculate both weight and remote deposit)
let (registrars, bytes, subs) = pallet_identity::Pallet::<T>::reap_identity(&who)?;
T::ReapIdentityHandler::on_reap_identity(&who, bytes, subs)?;
Self::deposit_event(Event::IdentityReaped { who });
let post = PostDispatchInfo {
actual_weight: Some(<T as pallet::Config>::WeightInfo::reap_identity(
registrars, subs,
)),
pays_fee: Pays::No,
};
Ok(post)
}
/// Update the deposit of `who`. Meant to be called by the system with an XCM `Transact`
/// Instruction.
#[pallet::call_index(1)]
#[pallet::weight(<T as pallet::Config>::WeightInfo::poke_deposit())]
pub fn poke_deposit(origin: OriginFor<T>, who: T::AccountId) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
let (id_deposit, subs_deposit) = pallet_identity::Pallet::<T>::poke_deposit(&who)?;
Self::deposit_event(Event::DepositUpdated {
who,
identity: id_deposit,
subs: subs_deposit,
});
Ok(Pays::No.into())
}
}
}
/// Trait to handle reaping identity from state.
pub trait OnReapIdentity<AccountId> {
/// What to do when an identity is reaped. For example, the implementation could send an XCM
/// program to another chain. Concretely, a type implementing this trait in the Pezkuwi
/// runtime would teleport enough HEZ to the People Chain to cover the Identity deposit there.
///
/// This could also directly include `Transact { poke_deposit(..), ..}`.
///
/// Inputs
/// - `who`: Whose identity was reaped.
/// - `bytes`: The byte size of `IdentityInfo`.
/// - `subs`: The number of sub-accounts they had.
fn on_reap_identity(who: &AccountId, bytes: u32, subs: u32) -> DispatchResult;
/// Ensure that identity reaping will be succesful in benchmarking.
///
/// Should setup the state in a way that the same call ot `[Self::on_reap_identity]` will be
/// successful.
#[cfg(feature = "runtime-benchmarks")]
fn ensure_successful_identity_reaping(who: &AccountId, bytes: u32, subs: u32);
}
impl<AccountId> OnReapIdentity<AccountId> for () {
fn on_reap_identity(_who: &AccountId, _bytes: u32, _subs: u32) -> DispatchResult {
Ok(())
}
#[cfg(feature = "runtime-benchmarks")]
fn ensure_successful_identity_reaping(_: &AccountId, _: u32, _: u32) {}
}
#[cfg(feature = "runtime-benchmarks")]
#[benchmarks]
mod benchmarks {
use super::*;
use alloc::{boxed::Box, vec, vec::Vec};
use codec::Encode;
use frame_support::traits::EnsureOrigin;
use frame_system::RawOrigin;
use pallet_identity::{Data, IdentityInformationProvider, Judgement, Pallet as Identity};
use sp_runtime::{
traits::{Bounded, Hash, StaticLookup},
Saturating,
};
const SEED: u32 = 0;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
#[benchmark]
fn reap_identity(
r: Linear<0, { T::MaxRegistrars::get() }>,
s: Linear<0, { T::MaxSubAccounts::get() }>,
) -> Result<(), BenchmarkError> {
// set up target
let target: T::AccountId = account("target", 0, SEED);
let target_origin =
<T as frame_system::Config>::RuntimeOrigin::from(RawOrigin::Signed(target.clone()));
let target_lookup = T::Lookup::unlookup(target.clone());
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
// set identity
let info = <T as pallet_identity::Config>::IdentityInformation::create_identity_info();
Identity::<T>::set_identity(
RawOrigin::Signed(target.clone()).into(),
Box::new(info.clone()),
)?;
// create and set subs
let mut subs = Vec::new();
let data = Data::Raw(vec![0; 32].try_into().unwrap());
for ii in 0..s {
let sub_account = account("sub", ii, SEED);
subs.push((sub_account, data.clone()));
}
Identity::<T>::set_subs(target_origin.clone(), subs.clone())?;
T::ReapIdentityHandler::ensure_successful_identity_reaping(
&target,
info.encoded_size() as u32,
subs.len() as u32,
);
// add registrars and provide judgements
let registrar_origin = T::RegistrarOrigin::try_successful_origin()
.expect("RegistrarOrigin has no successful origin required for the benchmark");
for ii in 0..r {
// registrar account
let registrar: T::AccountId = account("registrar", ii, SEED);
let registrar_lookup = T::Lookup::unlookup(registrar.clone());
let _ = <T as pallet_identity::Config>::Currency::make_free_balance_be(
&registrar,
<T as pallet_identity::Config>::Currency::minimum_balance(),
);
// add registrar
Identity::<T>::add_registrar(registrar_origin.clone(), registrar_lookup)?;
Identity::<T>::set_fee(RawOrigin::Signed(registrar.clone()).into(), ii, 10u32.into())?;
let fields = <T as pallet_identity::Config>::IdentityInformation::all_fields();
Identity::<T>::set_fields(RawOrigin::Signed(registrar.clone()).into(), ii, fields)?;
// request and provide judgement
Identity::<T>::request_judgement(target_origin.clone(), ii, 10u32.into())?;
Identity::<T>::provide_judgement(
RawOrigin::Signed(registrar).into(),
ii,
target_lookup.clone(),
Judgement::Reasonable,
<T as frame_system::Config>::Hashing::hash_of(&info),
)?;
}
let origin = T::Reaper::try_successful_origin().map_err(|_| BenchmarkError::Weightless)?;
#[extrinsic_call]
_(origin as T::RuntimeOrigin, target.clone());
assert_last_event::<T>(Event::<T>::IdentityReaped { who: target.clone() }.into());
let fields = <T as pallet_identity::Config>::IdentityInformation::all_fields();
assert!(!Identity::<T>::has_identity(&target, fields));
assert_eq!(Identity::<T>::subs(&target).len(), 0);
Ok(())
}
#[benchmark]
fn poke_deposit() -> Result<(), BenchmarkError> {
let target: T::AccountId = account("target", 0, SEED);
let _ = T::Currency::make_free_balance_be(&target, BalanceOf::<T>::max_value());
let info = <T as pallet_identity::Config>::IdentityInformation::create_identity_info();
let _ = Identity::<T>::set_identity_no_deposit(&target, info.clone());
let sub_account: T::AccountId = account("sub", 0, SEED);
let name = Data::Raw(b"benchsub".to_vec().try_into().unwrap());
let _ = Identity::<T>::set_subs_no_deposit(&target, vec![(sub_account.clone(), name)]);
// expected deposits
let expected_id_deposit = <T as pallet_identity::Config>::BasicDeposit::get()
.saturating_add(
<T as pallet_identity::Config>::ByteDeposit::get()
.saturating_mul(<BalanceOf<T>>::from(info.encoded_size() as u32)),
);
// only 1 sub
let expected_sub_deposit = <T as pallet_identity::Config>::SubAccountDeposit::get();
#[extrinsic_call]
_(RawOrigin::Root, target.clone());
assert_last_event::<T>(
Event::<T>::DepositUpdated {
who: target,
identity: expected_id_deposit,
subs: expected_sub_deposit,
}
.into(),
);
Ok(())
}
impl_benchmark_test_suite!(
Pallet,
crate::integration_tests::new_test_ext(),
crate::integration_tests::Test,
);
}
+615
View File
@@ -0,0 +1,615 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Auxiliary `struct`/`enum`s for pezkuwi runtime.
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
use frame_support::traits::{
fungible::{Balanced, Credit},
tokens::imbalance::ResolveTo,
Contains, ContainsPair, Imbalance, OnUnbalanced,
};
use pallet_treasury::TreasuryAccountId;
use pezkuwi_primitives::Balance;
use sp_runtime::{traits::TryConvert, Perquintill, RuntimeDebug};
use xcm::VersionedLocation;
/// Logic for the author to get a portion of fees.
pub struct ToAuthor<R>(core::marker::PhantomData<R>);
impl<R> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> for ToAuthor<R>
where
R: pallet_balances::Config + pallet_authorship::Config,
<R as frame_system::Config>::AccountId: From<pezkuwi_primitives::AccountId>,
<R as frame_system::Config>::AccountId: Into<pezkuwi_primitives::AccountId>,
{
fn on_nonzero_unbalanced(
amount: Credit<<R as frame_system::Config>::AccountId, pallet_balances::Pallet<R>>,
) {
if let Some(author) = <pallet_authorship::Pallet<R>>::author() {
let _ = <pallet_balances::Pallet<R>>::resolve(&author, amount);
}
}
}
pub struct DealWithFees<R>(core::marker::PhantomData<R>);
impl<R> OnUnbalanced<Credit<R::AccountId, pallet_balances::Pallet<R>>> for DealWithFees<R>
where
R: pallet_balances::Config + pallet_authorship::Config + pallet_treasury::Config,
<R as frame_system::Config>::AccountId: From<pezkuwi_primitives::AccountId>,
<R as frame_system::Config>::AccountId: Into<pezkuwi_primitives::AccountId>,
{
fn on_unbalanceds(
mut fees_then_tips: impl Iterator<Item = Credit<R::AccountId, pallet_balances::Pallet<R>>>,
) {
if let Some(fees) = fees_then_tips.next() {
// for fees, 80% to treasury, 20% to author
let mut split = fees.ration(80, 20);
if let Some(tips) = fees_then_tips.next() {
// for tips, if any, 100% to author
tips.merge_into(&mut split.1);
}
ResolveTo::<TreasuryAccountId<R>, pallet_balances::Pallet<R>>::on_unbalanced(split.0);
<ToAuthor<R> as OnUnbalanced<_>>::on_unbalanced(split.1);
}
}
}
/// Parameters passed into [`relay_era_payout`] function.
pub struct EraPayoutParams {
/// Total staked amount.
pub total_staked: Balance,
/// Total stakable amount.
///
/// Usually, this is equal to the total issuance, except if a large part of the issuance is
/// locked in another sub-system.
pub total_stakable: Balance,
/// Ideal stake ratio, which is deducted by `legacy_auction_proportion` if not `None`.
pub ideal_stake: Perquintill,
/// Maximum inflation rate.
pub max_annual_inflation: Perquintill,
/// Minimum inflation rate.
pub min_annual_inflation: Perquintill,
/// Falloff used to calculate era payouts.
pub falloff: Perquintill,
/// Fraction of the era period used to calculate era payouts.
pub period_fraction: Perquintill,
/// Legacy auction proportion, which substracts from `ideal_stake` if not `None`.
pub legacy_auction_proportion: Option<Perquintill>,
}
/// A specialized function to compute the inflation of the staking system, tailored for pezkuwi
/// relay chains, such as Pezkuwi, Kusama and Zagros.
pub fn relay_era_payout(params: EraPayoutParams) -> (Balance, Balance) {
use sp_runtime::traits::Saturating;
let EraPayoutParams {
total_staked,
total_stakable,
ideal_stake,
max_annual_inflation,
min_annual_inflation,
falloff,
period_fraction,
legacy_auction_proportion,
} = params;
let delta_annual_inflation = max_annual_inflation.saturating_sub(min_annual_inflation);
let ideal_stake = ideal_stake.saturating_sub(legacy_auction_proportion.unwrap_or_default());
let stake = Perquintill::from_rational(total_staked, total_stakable);
let adjustment = pallet_staking_reward_fn::compute_inflation(stake, ideal_stake, falloff);
let staking_inflation =
min_annual_inflation.saturating_add(delta_annual_inflation * adjustment);
let max_payout = period_fraction * max_annual_inflation * total_stakable;
let staking_payout = (period_fraction * staking_inflation) * total_stakable;
let rest = max_payout.saturating_sub(staking_payout);
let other_issuance = total_stakable.saturating_sub(total_staked);
if total_staked > other_issuance {
let _cap_rest = Perquintill::from_rational(other_issuance, total_staked) * staking_payout;
// We don't do anything with this, but if we wanted to, we could introduce a cap on the
// treasury amount with: `rest = rest.min(cap_rest);`
}
(staking_payout, rest)
}
/// Versioned locatable asset type which contains both an XCM `location` and `asset_id` to identify
/// an asset which exists on some chain.
#[derive(
Encode,
Decode,
DecodeWithMemTracking,
Eq,
PartialEq,
Clone,
RuntimeDebug,
scale_info::TypeInfo,
MaxEncodedLen,
)]
pub enum VersionedLocatableAsset {
#[codec(index = 3)]
V3 { location: xcm::v3::Location, asset_id: xcm::v3::AssetId },
#[codec(index = 4)]
V4 { location: xcm::v4::Location, asset_id: xcm::v4::AssetId },
#[codec(index = 5)]
V5 { location: xcm::v5::Location, asset_id: xcm::v5::AssetId },
}
/// A conversion from latest xcm to `VersionedLocatableAsset`.
impl From<(xcm::latest::Location, xcm::latest::AssetId)> for VersionedLocatableAsset {
fn from(value: (xcm::latest::Location, xcm::latest::AssetId)) -> Self {
VersionedLocatableAsset::V5 { location: value.0, asset_id: value.1 }
}
}
/// Converts the [`VersionedLocatableAsset`] to the [`xcm_builder::LocatableAssetId`].
pub struct LocatableAssetConverter;
impl TryConvert<VersionedLocatableAsset, xcm_builder::LocatableAssetId>
for LocatableAssetConverter
{
fn try_convert(
asset: VersionedLocatableAsset,
) -> Result<xcm_builder::LocatableAssetId, VersionedLocatableAsset> {
match asset {
VersionedLocatableAsset::V3 { location, asset_id } => {
let v4_location: xcm::v4::Location =
location.try_into().map_err(|_| asset.clone())?;
let v4_asset_id: xcm::v4::AssetId =
asset_id.try_into().map_err(|_| asset.clone())?;
Ok(xcm_builder::LocatableAssetId {
location: v4_location.try_into().map_err(|_| asset.clone())?,
asset_id: v4_asset_id.try_into().map_err(|_| asset.clone())?,
})
},
VersionedLocatableAsset::V4 { ref location, ref asset_id } =>
Ok(xcm_builder::LocatableAssetId {
location: location.clone().try_into().map_err(|_| asset.clone())?,
asset_id: asset_id.clone().try_into().map_err(|_| asset.clone())?,
}),
VersionedLocatableAsset::V5 { location, asset_id } =>
Ok(xcm_builder::LocatableAssetId { location, asset_id }),
}
}
}
/// Converts the [`VersionedLocation`] to the [`xcm::latest::Location`].
pub struct VersionedLocationConverter;
impl TryConvert<&VersionedLocation, xcm::latest::Location> for VersionedLocationConverter {
fn try_convert(
location: &VersionedLocation,
) -> Result<xcm::latest::Location, &VersionedLocation> {
let latest = match location.clone() {
VersionedLocation::V3(l) => {
let v4_location: xcm::v4::Location = l.try_into().map_err(|_| location)?;
v4_location.try_into().map_err(|_| location)?
},
VersionedLocation::V4(l) => l.try_into().map_err(|_| location)?,
VersionedLocation::V5(l) => l,
};
Ok(latest)
}
}
/// Adapter for [`Contains`] trait to match [`VersionedLocatableAsset`] type converted to the latest
/// version of itself where it's location matched by `L` and it's asset id by `A` parameter types.
pub struct ContainsParts<C>(core::marker::PhantomData<C>);
impl<C> Contains<VersionedLocatableAsset> for ContainsParts<C>
where
C: ContainsPair<xcm::latest::Location, xcm::latest::Location>,
{
fn contains(asset: &VersionedLocatableAsset) -> bool {
use VersionedLocatableAsset::*;
let (location, asset_id) = match asset.clone() {
V3 { location, asset_id } => {
let v4_location: xcm::v4::Location = match location.try_into() {
Ok(l) => l,
Err(_) => return false,
};
let v4_asset_id: xcm::v4::AssetId = match asset_id.try_into() {
Ok(a) => a,
Err(_) => return false,
};
match (v4_location.try_into(), v4_asset_id.try_into()) {
(Ok(l), Ok(a)) => (l, a),
_ => return false,
}
},
V4 { location, asset_id } => match (location.try_into(), asset_id.try_into()) {
(Ok(l), Ok(a)) => (l, a),
_ => return false,
},
V5 { location, asset_id } => (location, asset_id),
};
C::contains(&location, &asset_id.0)
}
}
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarks {
use super::VersionedLocatableAsset;
use core::marker::PhantomData;
use frame_support::traits::Get;
use pallet_asset_rate::AssetKindFactory;
use pallet_treasury::ArgumentsFactory as TreasuryArgumentsFactory;
use sp_core::{ConstU32, ConstU8};
use xcm::prelude::*;
/// Provides a factory method for the [`VersionedLocatableAsset`].
/// The location of the asset is determined as a Teyrchain with an ID equal to the passed seed.
pub struct AssetRateArguments;
impl AssetKindFactory<VersionedLocatableAsset> for AssetRateArguments {
fn create_asset_kind(seed: u32) -> VersionedLocatableAsset {
(
Location::new(0, [Teyrchain(seed)]),
AssetId(Location::new(
0,
[PalletInstance(seed.try_into().unwrap()), GeneralIndex(seed.into())],
)),
)
.into()
}
}
/// Provide factory methods for the [`VersionedLocatableAsset`] and the `Beneficiary` of the
/// [`VersionedLocation`]. The location of the asset is determined as a Teyrchain with an
/// ID equal to the passed seed.
pub struct TreasuryArguments<Parents = ConstU8<0>, ParaId = ConstU32<0>>(
PhantomData<(Parents, ParaId)>,
);
impl<Parents: Get<u8>, ParaId: Get<u32>>
TreasuryArgumentsFactory<VersionedLocatableAsset, VersionedLocation>
for TreasuryArguments<Parents, ParaId>
{
fn create_asset_kind(seed: u32) -> VersionedLocatableAsset {
(
Location::new(Parents::get(), [Junction::Teyrchain(ParaId::get())]),
AssetId(Location::new(
0,
[PalletInstance(seed.try_into().unwrap()), GeneralIndex(seed.into())],
)),
)
.into()
}
fn create_beneficiary(seed: [u8; 32]) -> VersionedLocation {
VersionedLocation::from(Location::new(0, [AccountId32 { network: None, id: seed }]))
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use frame_support::{
derive_impl,
dispatch::DispatchClass,
parameter_types,
traits::{
tokens::{PayFromAccount, UnityAssetBalanceConversion},
FindAuthor,
},
weights::Weight,
PalletId,
};
use frame_system::limits;
use pezkuwi_primitives::AccountId;
use sp_core::{ConstU64, H256};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
BuildStorage, Perbill,
};
type Block = frame_system::mocking::MockBlock<Test>;
const TEST_ACCOUNT: AccountId = AccountId::new([1; 32]);
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Authorship: pallet_authorship,
Balances: pallet_balances,
Treasury: pallet_treasury,
}
);
parameter_types! {
pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder()
.base_block(Weight::from_parts(10, 0))
.for_class(DispatchClass::all(), |weight| {
weight.base_extrinsic = Weight::from_parts(100, 0);
})
.for_class(DispatchClass::non_mandatory(), |weight| {
weight.max_total = Some(Weight::from_parts(1024, u64::MAX));
})
.build_or_panic();
pub BlockLength: limits::BlockLength = limits::BlockLength::max(2 * 1024);
pub const AvailableBlockRatio: Perbill = Perbill::one();
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type Nonce = u64;
type RuntimeCall = RuntimeCall;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type BlockLength = BlockLength;
type BlockWeights = BlockWeights;
type DbWeight = ();
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type AccountStore = System;
}
parameter_types! {
pub const TreasuryPalletId: PalletId = PalletId(*b"py/trsry");
pub const MaxApprovals: u32 = 100;
pub TreasuryAccount: AccountId = Treasury::account_id();
}
impl pallet_treasury::Config for Test {
type Currency = pallet_balances::Pallet<Test>;
type RejectOrigin = frame_system::EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type SpendPeriod = ();
type Burn = ();
type BurnDestination = ();
type PalletId = TreasuryPalletId;
type SpendFunds = ();
type MaxApprovals = MaxApprovals;
type WeightInfo = ();
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<u64>;
type AssetKind = ();
type Beneficiary = Self::AccountId;
type BeneficiaryLookup = IdentityLookup<Self::AccountId>;
type Paymaster = PayFromAccount<Balances, TreasuryAccount>;
type BalanceConverter = UnityAssetBalanceConversion;
type PayoutPeriod = ConstU64<0>;
type BlockNumberProvider = System;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = ();
}
pub struct OneAuthor;
impl FindAuthor<AccountId> for OneAuthor {
fn find_author<'a, I>(_: I) -> Option<AccountId>
where
I: 'a,
{
Some(TEST_ACCOUNT)
}
}
impl pallet_authorship::Config for Test {
type FindAuthor = OneAuthor;
type EventHandler = ();
}
pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
// We use default for brevity, but you can configure as desired if needed.
pallet_balances::GenesisConfig::<Test>::default()
.assimilate_storage(&mut t)
.unwrap();
t.into()
}
pub fn deprecated_era_payout(
total_staked: Balance,
total_stakable: Balance,
max_annual_inflation: Perquintill,
period_fraction: Perquintill,
auctioned_slots: u64,
) -> (Balance, Balance) {
use pallet_staking_reward_fn::compute_inflation;
use sp_runtime::traits::Saturating;
let min_annual_inflation = Perquintill::from_rational(25u64, 1000u64);
let delta_annual_inflation = max_annual_inflation.saturating_sub(min_annual_inflation);
// 30% reserved for up to 60 slots.
let auction_proportion = Perquintill::from_rational(auctioned_slots.min(60), 200u64);
// Therefore the ideal amount at stake (as a percentage of total issuance) is 75% less the
// amount that we expect to be taken up with auctions.
let ideal_stake = Perquintill::from_percent(75).saturating_sub(auction_proportion);
let stake = Perquintill::from_rational(total_staked, total_stakable);
let falloff = Perquintill::from_percent(5);
let adjustment = compute_inflation(stake, ideal_stake, falloff);
let staking_inflation =
min_annual_inflation.saturating_add(delta_annual_inflation * adjustment);
let max_payout = period_fraction * max_annual_inflation * total_stakable;
let staking_payout = (period_fraction * staking_inflation) * total_stakable;
let rest = max_payout.saturating_sub(staking_payout);
let other_issuance = total_stakable.saturating_sub(total_staked);
if total_staked > other_issuance {
let _cap_rest =
Perquintill::from_rational(other_issuance, total_staked) * staking_payout;
// We don't do anything with this, but if we wanted to, we could introduce a cap on the
// treasury amount with: `rest = rest.min(cap_rest);`
}
(staking_payout, rest)
}
#[test]
fn test_fees_and_tip_split() {
new_test_ext().execute_with(|| {
let fee =
<pallet_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<
AccountId,
>>::issue(10);
let tip =
<pallet_balances::Pallet<Test> as frame_support::traits::fungible::Balanced<
AccountId,
>>::issue(20);
assert_eq!(Balances::free_balance(Treasury::account_id()), 0);
assert_eq!(Balances::free_balance(TEST_ACCOUNT), 0);
DealWithFees::on_unbalanceds(vec![fee, tip].into_iter());
// Author gets 100% of tip and 20% of fee = 22
assert_eq!(Balances::free_balance(TEST_ACCOUNT), 22);
// Treasury gets 80% of fee
assert_eq!(Balances::free_balance(Treasury::account_id()), 8);
});
}
#[test]
fn compute_inflation_should_give_sensible_results() {
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(75),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::one()
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(50),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::from_rational(2u64, 3u64)
);
assert_eq!(
pallet_staking_reward_fn::compute_inflation(
Perquintill::from_percent(80),
Perquintill::from_percent(75),
Perquintill::from_percent(5),
),
Perquintill::from_rational(1u64, 2u64)
);
}
#[test]
fn era_payout_should_give_sensible_results() {
let payout =
deprecated_era_payout(75, 100, Perquintill::from_percent(10), Perquintill::one(), 0);
assert_eq!(payout, (10, 0));
let payout =
deprecated_era_payout(80, 100, Perquintill::from_percent(10), Perquintill::one(), 0);
assert_eq!(payout, (6, 4));
}
#[test]
fn relay_era_payout_should_give_sensible_results() {
let params = EraPayoutParams {
total_staked: 75,
total_stakable: 100,
ideal_stake: Perquintill::from_percent(75),
max_annual_inflation: Perquintill::from_percent(10),
min_annual_inflation: Perquintill::from_rational(25u64, 1000u64),
falloff: Perquintill::from_percent(5),
period_fraction: Perquintill::one(),
legacy_auction_proportion: None,
};
assert_eq!(relay_era_payout(params), (10, 0));
let params = EraPayoutParams {
total_staked: 80,
total_stakable: 100,
ideal_stake: Perquintill::from_percent(75),
max_annual_inflation: Perquintill::from_percent(10),
min_annual_inflation: Perquintill::from_rational(25u64, 1000u64),
falloff: Perquintill::from_percent(5),
period_fraction: Perquintill::one(),
legacy_auction_proportion: None,
};
assert_eq!(relay_era_payout(params), (6, 4));
}
#[test]
fn relay_era_payout_should_give_same_results_as_era_payout() {
let total_staked = 1_000_000;
let total_stakable = 2_000_000;
let max_annual_inflation = Perquintill::from_percent(10);
let period_fraction = Perquintill::from_percent(25);
let auctioned_slots = 30;
let params = EraPayoutParams {
total_staked,
total_stakable,
ideal_stake: Perquintill::from_percent(75),
max_annual_inflation,
min_annual_inflation: Perquintill::from_rational(25u64, 1000u64),
falloff: Perquintill::from_percent(5),
period_fraction,
legacy_auction_proportion: Some(Perquintill::from_rational(
auctioned_slots.min(60),
200u64,
)),
};
let payout = deprecated_era_payout(
total_staked,
total_stakable,
max_annual_inflation,
period_fraction,
auctioned_slots,
);
assert_eq!(relay_era_payout(params), payout);
let total_staked = 1_900_000;
let total_stakable = 2_000_000;
let auctioned_slots = 60;
let params = EraPayoutParams {
total_staked,
total_stakable,
ideal_stake: Perquintill::from_percent(75),
max_annual_inflation,
min_annual_inflation: Perquintill::from_rational(25u64, 1000u64),
falloff: Perquintill::from_percent(5),
period_fraction,
legacy_auction_proportion: Some(Perquintill::from_rational(
auctioned_slots.min(60),
200u64,
)),
};
let payout = deprecated_era_payout(
total_staked,
total_stakable,
max_annual_inflation,
period_fraction,
auctioned_slots,
);
assert_eq!(relay_era_payout(params), payout);
}
}
File diff suppressed because it is too large Load Diff
+285
View File
@@ -0,0 +1,285 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Common runtime code for the Relay Chain, e.g. Pezkuwichain, Zagros, Pezkuwi, Kusama ...
#![cfg_attr(not(feature = "std"), no_std)]
pub mod assigned_slots;
pub mod auctions;
pub mod claims;
pub mod crowdloan;
pub mod elections;
pub mod identity_migrator;
pub mod impls;
pub mod paras_registrar;
pub mod paras_sudo_wrapper;
pub mod purchase;
pub mod slot_range;
pub mod slots;
pub mod traits;
#[cfg(feature = "try-runtime")]
pub mod try_runtime;
pub mod xcm_sender;
#[cfg(test)]
mod integration_tests;
#[cfg(test)]
mod mock;
extern crate alloc;
use frame_support::{
parameter_types,
traits::{ConstU32, Currency, OneSessionHandler},
weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight},
};
use frame_system::limits;
use pezkuwi_primitives::{AssignmentId, Balance, BlockNumber, ValidatorId};
use sp_runtime::{FixedPointNumber, Perbill, Perquintill};
use static_assertions::const_assert;
pub use pallet_balances::Call as BalancesCall;
#[cfg(feature = "std")]
pub use pallet_staking::StakerStatus;
pub use pallet_timestamp::Call as TimestampCall;
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
pub use sp_runtime::traits::Bounded;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
/// Implementations of some helper traits passed into runtime modules as associated types.
pub use impls::ToAuthor;
#[deprecated(
note = "Please use fungible::Credit instead. This type will be removed some time after March 2024."
)]
pub type NegativeImbalance<T> = <pallet_balances::Pallet<T> as Currency<
<T as frame_system::Config>::AccountId,
>>::NegativeImbalance;
/// We assume that an on-initialize consumes 1% of the weight on average, hence a single extrinsic
/// will not be allowed to consume more than `AvailableBlockRatio - 1%`.
pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(1);
/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used
/// by Operational extrinsics.
pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 2 seconds of compute with a 6 second average block time.
/// The storage proof size is not limited so far.
pub const MAXIMUM_BLOCK_WEIGHT: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), u64::MAX);
const_assert!(NORMAL_DISPATCH_RATIO.deconstruct() >= AVERAGE_ON_INITIALIZE_RATIO.deconstruct());
// Common constants used in all runtimes.
parameter_types! {
pub const BlockHashCount: BlockNumber = 4096;
/// The portion of the `NORMAL_DISPATCH_RATIO` that we adjust the fees with. Blocks filled less
/// than this will decrease the weight and more will increase.
pub const TargetBlockFullness: Perquintill = Perquintill::from_percent(25);
/// The adjustment variable of the runtime. Higher values will cause `TargetBlockFullness` to
/// change the fees more rapidly.
pub AdjustmentVariable: Multiplier = Multiplier::saturating_from_rational(75, 1000_000);
/// Minimum amount of the multiplier. This value cannot be too low. A test case should ensure
/// that combined with `AdjustmentVariable`, we can recover from the minimum.
/// See `multiplier_can_grow_from_zero`.
pub MinimumMultiplier: Multiplier = Multiplier::saturating_from_rational(1, 10u128);
/// The maximum amount of the multiplier.
pub MaximumMultiplier: Multiplier = Bounded::max_value();
/// Maximum length of block. Up to 5MB.
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
}
/// Parameterized slow adjusting fee updated based on
/// <https://research.web3.foundation/Polkadot/overview/token-economics#2-slow-adjusting-mechanism>
pub type SlowAdjustingFeeUpdate<R> = TargetedFeeAdjustment<
R,
TargetBlockFullness,
AdjustmentVariable,
MinimumMultiplier,
MaximumMultiplier,
>;
/// Implements the weight types for a runtime.
/// It expects the passed runtime constants to contain a `weights` module.
/// The generated weight types were formerly part of the common
/// runtime but are now runtime dependant.
#[macro_export]
macro_rules! impl_runtime_weights {
($runtime:ident) => {
use frame_support::{dispatch::DispatchClass, weights::Weight};
use frame_system::limits;
use pallet_transaction_payment::{Multiplier, TargetedFeeAdjustment};
pub use pezkuwi_runtime_common::{
impl_elections_weights, AVERAGE_ON_INITIALIZE_RATIO, MAXIMUM_BLOCK_WEIGHT,
NORMAL_DISPATCH_RATIO,
};
use sp_runtime::{FixedPointNumber, Perquintill};
// Implement the weight types of the elections module.
impl_elections_weights!($runtime);
// Expose the weight from the runtime constants module.
pub use $runtime::weights::{
BlockExecutionWeight, ExtrinsicBaseWeight, ParityDbWeight, RocksDbWeight,
};
parameter_types! {
/// Block weights base values and limits.
pub BlockWeights: limits::BlockWeights = limits::BlockWeights::builder()
.base_block($runtime::weights::BlockExecutionWeight::get())
.for_class(DispatchClass::all(), |weights| {
weights.base_extrinsic = $runtime::weights::ExtrinsicBaseWeight::get();
})
.for_class(DispatchClass::Normal, |weights| {
weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);
})
.for_class(DispatchClass::Operational, |weights| {
weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);
// Operational transactions have an extra reserved space, so that they
// are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.
weights.reserved = Some(
MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT,
);
})
.avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)
.build_or_panic();
}
};
}
/// The type used for currency conversion.
///
/// This must only be used as long as the balance type is `u128`.
pub type CurrencyToVote = sp_staking::currency_to_vote::U128CurrencyToVote;
static_assertions::assert_eq_size!(pezkuwi_primitives::Balance, u128);
/// A placeholder since there is currently no provided session key handler for teyrchain validator
/// keys.
pub struct TeyrchainSessionKeyPlaceholder<T>(core::marker::PhantomData<T>);
impl<T> sp_runtime::BoundToRuntimeAppPublic for TeyrchainSessionKeyPlaceholder<T> {
type Public = ValidatorId;
}
impl<T: pallet_session::Config> OneSessionHandler<T::AccountId>
for TeyrchainSessionKeyPlaceholder<T>
{
type Key = ValidatorId;
fn on_genesis_session<'a, I: 'a>(_validators: I)
where
I: Iterator<Item = (&'a T::AccountId, ValidatorId)>,
T::AccountId: 'a,
{
}
fn on_new_session<'a, I: 'a>(_changed: bool, _v: I, _q: I)
where
I: Iterator<Item = (&'a T::AccountId, ValidatorId)>,
T::AccountId: 'a,
{
}
fn on_disabled(_: u32) {}
}
/// A placeholder since there is currently no provided session key handler for teyrchain validator
/// keys.
pub struct AssignmentSessionKeyPlaceholder<T>(core::marker::PhantomData<T>);
impl<T> sp_runtime::BoundToRuntimeAppPublic for AssignmentSessionKeyPlaceholder<T> {
type Public = AssignmentId;
}
impl<T: pallet_session::Config> OneSessionHandler<T::AccountId>
for AssignmentSessionKeyPlaceholder<T>
{
type Key = AssignmentId;
fn on_genesis_session<'a, I: 'a>(_validators: I)
where
I: Iterator<Item = (&'a T::AccountId, AssignmentId)>,
T::AccountId: 'a,
{
}
fn on_new_session<'a, I: 'a>(_changed: bool, _v: I, _q: I)
where
I: Iterator<Item = (&'a T::AccountId, AssignmentId)>,
T::AccountId: 'a,
{
}
fn on_disabled(_: u32) {}
}
/// A reasonable benchmarking config for staking pallet.
pub struct StakingBenchmarkingConfig;
impl pallet_staking::BenchmarkingConfig for StakingBenchmarkingConfig {
type MaxValidators = ConstU32<1000>;
type MaxNominators = ConstU32<1000>;
}
/// Convert a balance to an unsigned 256-bit number, use in nomination pools.
pub struct BalanceToU256;
impl sp_runtime::traits::Convert<Balance, sp_core::U256> for BalanceToU256 {
fn convert(n: Balance) -> sp_core::U256 {
n.into()
}
}
/// Convert an unsigned 256-bit number to balance, use in nomination pools.
pub struct U256ToBalance;
impl sp_runtime::traits::Convert<sp_core::U256, Balance> for U256ToBalance {
fn convert(n: sp_core::U256) -> Balance {
use frame_support::traits::Defensive;
n.try_into().defensive_unwrap_or(Balance::MAX)
}
}
/// Macro to set a value (e.g. when using the `parameter_types` macro) to either a production value
/// or to an environment variable or testing value (in case the `fast-runtime` feature is selected)
/// or one of two testing values depending on feature.
/// Note that the environment variable is evaluated _at compile time_.
///
/// Usage:
/// ```Rust
/// parameter_types! {
/// // Note that the env variable version parameter cannot be const.
/// pub LaunchPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1, "HEZ_LAUNCH_PERIOD");
/// pub const VotingPeriod: BlockNumber = prod_or_fast!(7 * DAYS, 1 * MINUTES);
/// pub const EpochDuration: BlockNumber =
/// prod_or_fast!(1 * HOURS, "fast-runtime", 1 * MINUTES, "fast-runtime-10m", 10 * MINUTES);
/// }
/// ```
#[macro_export]
macro_rules! prod_or_fast {
($prod:expr, $test:expr) => {
if cfg!(feature = "fast-runtime") {
$test
} else {
$prod
}
};
($prod:expr, $test:expr, $env:expr) => {
if cfg!(feature = "fast-runtime") {
core::option_env!($env).map(|s| s.parse().ok()).flatten().unwrap_or($test)
} else {
$prod
}
};
}
+269
View File
@@ -0,0 +1,269 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing.
use crate::traits::Registrar;
use codec::{Decode, Encode};
use frame_support::{dispatch::DispatchResult, weights::Weight};
use frame_system::pallet_prelude::BlockNumberFor;
use pezkuwi_primitives::{HeadData, Id as ParaId, PvfCheckStatement, SessionIndex, ValidationCode};
use pezkuwi_runtime_teyrchains::paras;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{traits::SaturatedConversion, DispatchError, Permill};
use std::{cell::RefCell, collections::HashMap};
thread_local! {
static OPERATIONS: RefCell<Vec<(ParaId, u32, bool)>> = RefCell::new(Vec::new());
static TEYRCHAINS: RefCell<Vec<ParaId>> = RefCell::new(Vec::new());
// On-demand teyrchains
static PARATHREADS: RefCell<Vec<ParaId>> = RefCell::new(Vec::new());
static LOCKS: RefCell<HashMap<ParaId, bool>> = RefCell::new(HashMap::new());
static MANAGERS: RefCell<HashMap<ParaId, Vec<u8>>> = RefCell::new(HashMap::new());
}
pub struct TestRegistrar<T>(core::marker::PhantomData<T>);
impl<T: frame_system::Config> Registrar for TestRegistrar<T> {
type AccountId = T::AccountId;
fn manager_of(id: ParaId) -> Option<Self::AccountId> {
MANAGERS.with(|x| x.borrow().get(&id).and_then(|v| T::AccountId::decode(&mut &v[..]).ok()))
}
fn teyrchains() -> Vec<ParaId> {
TEYRCHAINS.with(|x| x.borrow().clone())
}
// Is on-demand teyrchain
fn is_parathread(id: ParaId) -> bool {
PARATHREADS.with(|x| x.borrow().binary_search(&id).is_ok())
}
fn apply_lock(id: ParaId) {
LOCKS.with(|x| x.borrow_mut().insert(id, true));
}
fn remove_lock(id: ParaId) {
LOCKS.with(|x| x.borrow_mut().insert(id, false));
}
fn register(
manager: Self::AccountId,
id: ParaId,
_genesis_head: HeadData,
_validation_code: ValidationCode,
) -> DispatchResult {
// Should not be teyrchain.
TEYRCHAINS.with(|x| {
let teyrchains = x.borrow_mut();
match teyrchains.binary_search(&id) {
Ok(_) => Err(DispatchError::Other("Already Teyrchain")),
Err(_) => Ok(()),
}
})?;
// Should not be parathread (on-demand teyrchain), then make it.
PARATHREADS.with(|x| {
let mut parathreads = x.borrow_mut();
match parathreads.binary_search(&id) {
Ok(_) => Err(DispatchError::Other("Already Parathread")),
Err(i) => {
parathreads.insert(i, id);
Ok(())
},
}
})?;
MANAGERS.with(|x| x.borrow_mut().insert(id, manager.encode()));
Ok(())
}
fn deregister(id: ParaId) -> DispatchResult {
// Should not be teyrchain.
TEYRCHAINS.with(|x| {
let teyrchains = x.borrow_mut();
match teyrchains.binary_search(&id) {
Ok(_) => Err(DispatchError::Other("cannot deregister teyrchain")),
Err(_) => Ok(()),
}
})?;
// Remove from parathreads (on-demand teyrchains).
PARATHREADS.with(|x| {
let mut parathreads = x.borrow_mut();
match parathreads.binary_search(&id) {
Ok(i) => {
parathreads.remove(i);
Ok(())
},
Err(_) => Err(DispatchError::Other("not parathread, so cannot `deregister`")),
}
})?;
MANAGERS.with(|x| x.borrow_mut().remove(&id));
Ok(())
}
/// If the ParaId corresponds to a parathread (on-demand teyrchain),
/// then upgrade it to a lease holding teyrchain
fn make_teyrchain(id: ParaId) -> DispatchResult {
PARATHREADS.with(|x| {
let mut parathreads = x.borrow_mut();
match parathreads.binary_search(&id) {
Ok(i) => {
parathreads.remove(i);
Ok(())
},
Err(_) => Err(DispatchError::Other("not parathread, so cannot `make_teyrchain`")),
}
})?;
TEYRCHAINS.with(|x| {
let mut teyrchains = x.borrow_mut();
match teyrchains.binary_search(&id) {
Ok(_) => Err(DispatchError::Other("already teyrchain, so cannot `make_teyrchain`")),
Err(i) => {
teyrchains.insert(i, id);
Ok(())
},
}
})?;
OPERATIONS.with(|x| {
x.borrow_mut().push((
id,
frame_system::Pallet::<T>::block_number().saturated_into(),
true,
))
});
Ok(())
}
/// If the ParaId corresponds to a lease holding teyrchain, then downgrade it to a
/// parathread (on-demand teyrchain)
fn make_parathread(id: ParaId) -> DispatchResult {
TEYRCHAINS.with(|x| {
let mut teyrchains = x.borrow_mut();
match teyrchains.binary_search(&id) {
Ok(i) => {
teyrchains.remove(i);
Ok(())
},
Err(_) => Err(DispatchError::Other("not teyrchain, so cannot `make_parathread`")),
}
})?;
PARATHREADS.with(|x| {
let mut parathreads = x.borrow_mut();
match parathreads.binary_search(&id) {
Ok(_) =>
Err(DispatchError::Other("already parathread, so cannot `make_parathread`")),
Err(i) => {
parathreads.insert(i, id);
Ok(())
},
}
})?;
OPERATIONS.with(|x| {
x.borrow_mut().push((
id,
frame_system::Pallet::<T>::block_number().saturated_into(),
false,
))
});
Ok(())
}
#[cfg(test)]
fn worst_head_data() -> HeadData {
vec![0u8; 1000].into()
}
#[cfg(test)]
fn worst_validation_code() -> ValidationCode {
let validation_code = vec![0u8; 1000];
validation_code.into()
}
#[cfg(test)]
fn execute_pending_transitions() {}
}
impl<T: frame_system::Config> TestRegistrar<T> {
pub fn operations() -> Vec<(ParaId, BlockNumberFor<T>, bool)> {
OPERATIONS
.with(|x| x.borrow().iter().map(|(p, b, c)| (*p, (*b).into(), *c)).collect::<Vec<_>>())
}
#[allow(dead_code)]
pub fn teyrchains() -> Vec<ParaId> {
TEYRCHAINS.with(|x| x.borrow().clone())
}
#[allow(dead_code)]
pub fn parathreads() -> Vec<ParaId> {
PARATHREADS.with(|x| x.borrow().clone())
}
#[allow(dead_code)]
pub fn clear_storage() {
OPERATIONS.with(|x| x.borrow_mut().clear());
TEYRCHAINS.with(|x| x.borrow_mut().clear());
PARATHREADS.with(|x| x.borrow_mut().clear());
MANAGERS.with(|x| x.borrow_mut().clear());
}
}
/// A very dumb implementation of `EstimateNextSessionRotation`. At the moment of writing, this
/// is more to satisfy type requirements rather than to test anything.
pub struct TestNextSessionRotation;
impl frame_support::traits::EstimateNextSessionRotation<u32> for TestNextSessionRotation {
fn average_session_length() -> u32 {
10
}
fn estimate_current_session_progress(_now: u32) -> (Option<Permill>, Weight) {
(None, Weight::zero())
}
fn estimate_next_session_rotation(_now: u32) -> (Option<u32>, Weight) {
(None, Weight::zero())
}
}
pub fn validators_public_keys(
validators: &[Sr25519Keyring],
) -> Vec<pezkuwi_primitives::ValidatorId> {
validators.iter().map(|v| v.public().into()).collect()
}
pub fn conclude_pvf_checking<T: paras::Config>(
validation_code: &ValidationCode,
validators: &[Sr25519Keyring],
session_index: SessionIndex,
) {
let num_required = pezkuwi_primitives::supermajority_threshold(validators.len());
validators.iter().enumerate().take(num_required).for_each(|(idx, key)| {
let validator_index = idx as u32;
let statement = PvfCheckStatement {
accept: true,
subject: validation_code.hash(),
session_index,
validator_index: validator_index.into(),
};
let signature = key.sign(&statement.signing_payload());
let _ = paras::Pallet::<T>::include_pvf_check_statement(
frame_system::Origin::<T>::None.into(),
statement,
signature.into(),
);
});
}
@@ -0,0 +1,213 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Benchmarking for paras_registrar pallet
#[cfg(feature = "runtime-benchmarks")]
use super::{Pallet as Registrar, *};
use crate::traits::Registrar as RegistrarT;
use frame_support::assert_ok;
use frame_system::RawOrigin;
use pezkuwi_primitives::{MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MIN_CODE_SIZE};
use pezkuwi_runtime_teyrchains::{paras, shared, Origin as ParaOrigin};
use sp_runtime::traits::Bounded;
use frame_benchmarking::v2::*;
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
let events = frame_system::Pallet::<T>::events();
let system_event: <T as frame_system::Config>::RuntimeEvent = generic_event.into();
// compare to the last event record
let frame_system::EventRecord { event, .. } = &events[events.len() - 1];
assert_eq!(event, &system_event);
}
fn register_para<T: Config>(id: u32) -> ParaId {
let para = ParaId::from(id);
let genesis_head = Registrar::<T>::worst_head_data();
let validation_code = Registrar::<T>::worst_validation_code();
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
assert_ok!(Registrar::<T>::reserve(RawOrigin::Signed(caller.clone()).into()));
assert_ok!(Registrar::<T>::register(
RawOrigin::Signed(caller).into(),
para,
genesis_head,
validation_code.clone()
));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
validation_code,
));
return para;
}
fn para_origin(id: u32) -> ParaOrigin {
ParaOrigin::Teyrchain(id.into())
}
// This function moves forward to the next scheduled session for teyrchain lifecycle upgrades.
fn next_scheduled_session<T: Config>() {
shared::Pallet::<T>::set_session_index(shared::Pallet::<T>::scheduled_session());
paras::Pallet::<T>::test_on_new_session();
}
#[benchmarks(
where ParaOrigin: Into<<T as frame_system::Config>::RuntimeOrigin>,
)]
mod benchmarks {
use super::*;
#[benchmark]
fn reserve() -> Result<(), BenchmarkError> {
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()));
assert_last_event::<T>(
Event::<T>::Reserved { para_id: LOWEST_PUBLIC_ID, who: caller }.into(),
);
assert!(Paras::<T>::get(LOWEST_PUBLIC_ID).is_some());
assert_eq!(paras::Pallet::<T>::lifecycle(LOWEST_PUBLIC_ID), None);
Ok(())
}
#[benchmark]
fn register() -> Result<(), BenchmarkError> {
let para = LOWEST_PUBLIC_ID;
let genesis_head = Registrar::<T>::worst_head_data();
let validation_code = Registrar::<T>::worst_validation_code();
let caller: T::AccountId = whitelisted_caller();
T::Currency::make_free_balance_be(&caller, BalanceOf::<T>::max_value());
assert_ok!(Registrar::<T>::reserve(RawOrigin::Signed(caller.clone()).into()));
#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), para, genesis_head, validation_code.clone());
assert_last_event::<T>(Event::<T>::Registered { para_id: para, manager: caller }.into());
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
validation_code,
));
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
Ok(())
}
#[benchmark]
fn force_register() -> Result<(), BenchmarkError> {
let manager: T::AccountId = account("manager", 0, 0);
let deposit = 0u32.into();
let para = ParaId::from(69);
let genesis_head = Registrar::<T>::worst_head_data();
let validation_code = Registrar::<T>::worst_validation_code();
#[extrinsic_call]
_(RawOrigin::Root, manager.clone(), deposit, para, genesis_head, validation_code.clone());
assert_last_event::<T>(Event::<T>::Registered { para_id: para, manager }.into());
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Onboarding));
assert_ok!(pezkuwi_runtime_teyrchains::paras::Pallet::<T>::add_trusted_validation_code(
frame_system::Origin::<T>::Root.into(),
validation_code,
));
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(para), Some(ParaLifecycle::Parathread));
Ok(())
}
#[benchmark]
fn deregister() -> Result<(), BenchmarkError> {
let para = register_para::<T>(LOWEST_PUBLIC_ID.into());
next_scheduled_session::<T>();
let caller: T::AccountId = whitelisted_caller();
#[extrinsic_call]
_(RawOrigin::Signed(caller), para);
assert_last_event::<T>(Event::<T>::Deregistered { para_id: para }.into());
Ok(())
}
#[benchmark]
fn swap() -> Result<(), BenchmarkError> {
// On demand teyrchain
let parathread = register_para::<T>(LOWEST_PUBLIC_ID.into());
let teyrchain = register_para::<T>((LOWEST_PUBLIC_ID + 1).into());
let teyrchain_origin = para_origin(teyrchain.into());
// Actually finish registration process
next_scheduled_session::<T>();
// Upgrade the teyrchain
Registrar::<T>::make_teyrchain(teyrchain)?;
next_scheduled_session::<T>();
assert_eq!(paras::Pallet::<T>::lifecycle(teyrchain), Some(ParaLifecycle::Teyrchain));
assert_eq!(paras::Pallet::<T>::lifecycle(parathread), Some(ParaLifecycle::Parathread));
let caller: T::AccountId = whitelisted_caller();
Registrar::<T>::swap(teyrchain_origin.into(), teyrchain, parathread)?;
#[extrinsic_call]
_(RawOrigin::Signed(caller.clone()), parathread, teyrchain);
next_scheduled_session::<T>();
// Swapped!
assert_eq!(paras::Pallet::<T>::lifecycle(teyrchain), Some(ParaLifecycle::Parathread));
assert_eq!(paras::Pallet::<T>::lifecycle(parathread), Some(ParaLifecycle::Teyrchain));
Ok(())
}
#[benchmark]
fn schedule_code_upgrade(
b: Linear<MIN_CODE_SIZE, MAX_CODE_SIZE>,
) -> Result<(), BenchmarkError> {
let new_code = ValidationCode(vec![0; b as usize]);
let para_id = ParaId::from(1000);
#[extrinsic_call]
_(RawOrigin::Root, para_id, new_code);
Ok(())
}
#[benchmark]
fn set_current_head(b: Linear<1, MAX_HEAD_DATA_SIZE>) -> Result<(), BenchmarkError> {
let new_head = HeadData(vec![0; b as usize]);
let para_id = ParaId::from(1000);
#[extrinsic_call]
_(RawOrigin::Root, para_id, new_head);
Ok(())
}
impl_benchmark_test_suite!(
Registrar,
crate::integration_tests::new_test_ext(),
crate::integration_tests::Test,
);
}
@@ -0,0 +1,69 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::*;
use frame_support::traits::{Contains, UncheckedOnRuntimeUpgrade};
#[derive(Encode, Decode)]
pub struct ParaInfoV1<Account, Balance> {
manager: Account,
deposit: Balance,
locked: bool,
}
pub struct VersionUncheckedMigrateToV1<T, UnlockParaIds>(
core::marker::PhantomData<(T, UnlockParaIds)>,
);
impl<T: Config, UnlockParaIds: Contains<ParaId>> UncheckedOnRuntimeUpgrade
for VersionUncheckedMigrateToV1<T, UnlockParaIds>
{
fn on_runtime_upgrade() -> Weight {
let mut count = 0u64;
Paras::<T>::translate::<ParaInfoV1<T::AccountId, BalanceOf<T>>, _>(|key, v1| {
count.saturating_inc();
Some(ParaInfo {
manager: v1.manager,
deposit: v1.deposit,
locked: if UnlockParaIds::contains(&key) { None } else { Some(v1.locked) },
})
});
log::info!(target: "runtime::registrar", "Upgraded {} storages to version 1", count);
T::DbWeight::get().reads_writes(count, count)
}
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
Ok((Paras::<T>::iter_keys().count() as u32).encode())
}
#[cfg(feature = "try-runtime")]
fn post_upgrade(state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
let old_count = u32::decode(&mut &state[..]).expect("Known good");
let new_count = Paras::<T>::iter_values().count() as u32;
ensure!(old_count == new_count, "Paras count should not change");
Ok(())
}
}
pub type MigrateToV1<T, UnlockParaIds> = frame_support::migrations::VersionedMigration<
0,
1,
VersionUncheckedMigrateToV1<T, UnlockParaIds>,
super::Pallet<T>,
<T as frame_system::Config>::DbWeight,
>;
@@ -0,0 +1,250 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in paras_registrar pallet.
#[cfg(test)]
use super::*;
use crate::paras_registrar;
use alloc::collections::btree_map::BTreeMap;
use frame_support::{derive_impl, parameter_types};
use frame_system::limits;
use pezkuwi_primitives::{Balance, BlockNumber, MAX_CODE_SIZE};
use pezkuwi_runtime_teyrchains::{configuration, origin, shared};
use sp_core::{ConstUint, H256};
use sp_io::TestExternalities;
use sp_keyring::Sr25519Keyring;
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
transaction_validity::TransactionPriority,
BuildStorage, Perbill,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlockU32<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Configuration: configuration,
Teyrchains: paras,
ParasShared: shared,
Registrar: paras_registrar,
TeyrchainsOrigin: origin,
}
);
impl<C> frame_system::offchain::CreateTransactionBase<C> for Test
where
RuntimeCall: From<C>,
{
type Extrinsic = UncheckedExtrinsic;
type RuntimeCall = RuntimeCall;
}
impl<C> frame_system::offchain::CreateBare<C> for Test
where
RuntimeCall: From<C>,
{
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
const NORMAL_RATIO: Perbill = Perbill::from_percent(75);
parameter_types! {
pub BlockWeights: limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(Weight::from_parts(1024, u64::MAX));
pub BlockLength: limits::BlockLength =
limits::BlockLength::max_with_normal_ratio(4 * 1024 * 1024, NORMAL_RATIO);
}
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<u64>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type DbWeight = ();
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u128>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const ExistentialDeposit: Balance = 1;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type Balance = Balance;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
}
impl shared::Config for Test {
type DisabledValidators = ();
}
impl origin::Config for Test {}
parameter_types! {
pub const ParasUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
}
impl paras::Config for Test {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = paras::TestWeightInfo;
type UnsignedPriority = ParasUnsignedPriority;
type QueueFootprinter = ();
type NextSessionRotation = crate::mock::TestNextSessionRotation;
type OnNewHead = ();
type AssignCoretime = ();
type Fungible = Balances;
type CooldownRemovalMultiplier = ConstUint<1>;
type AuthorizeCurrentCodeOrigin = frame_system::EnsureRoot<u64>;
}
impl configuration::Config for Test {
type WeightInfo = configuration::TestWeightInfo;
}
parameter_types! {
pub const ParaDeposit: Balance = 10;
pub const DataDepositPerByte: Balance = 1;
pub const MaxRetries: u32 = 3;
}
impl Config for Test {
type RuntimeOrigin = RuntimeOrigin;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type OnSwap = MockSwap;
type ParaDeposit = ParaDeposit;
type DataDepositPerByte = DataDepositPerByte;
type WeightInfo = TestWeightInfo;
}
pub fn new_test_ext() -> TestExternalities {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
configuration::GenesisConfig::<Test> {
config: configuration::HostConfiguration {
max_code_size: MAX_CODE_SIZE,
max_head_data_size: 1 * 1024 * 1024, // 1 MB
..Default::default()
},
}
.assimilate_storage(&mut t)
.unwrap();
pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10_000_000), (2, 10_000_000), (3, 10_000_000)],
..Default::default()
}
.assimilate_storage(&mut t)
.unwrap();
t.into()
}
parameter_types! {
pub static SwapData: BTreeMap<ParaId, u64> = BTreeMap::new();
}
pub struct MockSwap;
impl OnSwap for MockSwap {
fn on_swap(one: ParaId, other: ParaId) {
let mut swap_data = SwapData::get();
let one_data = swap_data.remove(&one).unwrap_or_default();
let other_data = swap_data.remove(&other).unwrap_or_default();
swap_data.insert(one, other_data);
swap_data.insert(other, one_data);
SwapData::set(swap_data);
}
}
pub const BLOCKS_PER_SESSION: u32 = 3;
pub const VALIDATORS: &[Sr25519Keyring] = &[
Sr25519Keyring::Alice,
Sr25519Keyring::Bob,
Sr25519Keyring::Charlie,
Sr25519Keyring::Dave,
Sr25519Keyring::Ferdie,
];
pub fn run_to_block(n: BlockNumber) {
// NOTE that this function only simulates modules of interest. Depending on new pallet may
// require adding it here.
System::run_to_block_with::<AllPalletsWithSystem>(
n,
frame_system::RunToBlockHooks::default().before_finalize(|bn| {
// Session change every 3 blocks.
if (bn + 1) % BLOCKS_PER_SESSION == 0 {
let session_index = shared::CurrentSessionIndex::<Test>::get() + 1;
let validators_pub_keys = VALIDATORS.iter().map(|v| v.public().into()).collect();
shared::Pallet::<Test>::set_session_index(session_index);
shared::Pallet::<Test>::set_active_validators_ascending(validators_pub_keys);
Teyrchains::test_on_new_session();
}
}),
);
}
pub fn run_to_session(n: BlockNumber) {
let block_number = n * BLOCKS_PER_SESSION;
run_to_block(block_number);
}
pub fn test_genesis_head(size: usize) -> HeadData {
HeadData(vec![0u8; size])
}
pub fn test_validation_code(size: usize) -> ValidationCode {
let validation_code = vec![0u8; size as usize];
ValidationCode(validation_code)
}
pub fn para_origin(id: ParaId) -> RuntimeOrigin {
pezkuwi_runtime_teyrchains::Origin::Teyrchain(id).into()
}
pub fn max_code_size() -> u32 {
configuration::ActiveConfig::<Test>::get().max_code_size
}
pub fn max_head_size() -> u32 {
configuration::ActiveConfig::<Test>::get().max_head_data_size
}
@@ -0,0 +1,733 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Pallet to handle teyrchain registration and related fund management.
//! In essence this is a simple wrapper around `paras`.
pub mod migration;
use alloc::{vec, vec::Vec};
use core::result;
use frame_support::{
dispatch::DispatchResult,
ensure,
pallet_prelude::Weight,
traits::{Currency, Get, ReservableCurrency},
};
use frame_system::{self, ensure_root, ensure_signed};
use pezkuwi_primitives::{HeadData, Id as ParaId, ValidationCode, LOWEST_PUBLIC_ID, MIN_CODE_SIZE};
use pezkuwi_runtime_teyrchains::{
configuration, ensure_teyrchain,
paras::{self, ParaGenesisArgs, UpgradeStrategy},
Origin, ParaLifecycle,
};
use crate::traits::{OnSwap, Registrar};
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
pub use pallet::*;
use pezkuwi_runtime_teyrchains::paras::{OnNewHead, ParaKind};
use scale_info::TypeInfo;
use sp_runtime::{
traits::{CheckedSub, Saturating},
RuntimeDebug,
};
#[derive(
Encode,
Decode,
Clone,
PartialEq,
Eq,
Default,
RuntimeDebug,
TypeInfo,
MaxEncodedLen,
DecodeWithMemTracking,
)]
pub struct ParaInfo<Account, Balance> {
/// The account that has placed a deposit for registering this para.
pub manager: Account,
/// The amount reserved by the `manager` account for the registration.
pub deposit: Balance,
/// Whether the para registration should be locked from being controlled by the manager.
/// None means the lock had not been explicitly set, and should be treated as false.
pub locked: Option<bool>,
}
impl<Account, Balance> ParaInfo<Account, Balance> {
/// Returns if the para is locked.
pub fn is_locked(&self) -> bool {
self.locked.unwrap_or(false)
}
}
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
pub trait WeightInfo {
fn reserve() -> Weight;
fn register() -> Weight;
fn force_register() -> Weight;
fn deregister() -> Weight;
fn swap() -> Weight;
fn schedule_code_upgrade(b: u32) -> Weight;
fn set_current_head(b: u32) -> Weight;
}
pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn reserve() -> Weight {
Weight::zero()
}
fn register() -> Weight {
Weight::zero()
}
fn force_register() -> Weight {
Weight::zero()
}
fn deregister() -> Weight {
Weight::zero()
}
fn swap() -> Weight {
Weight::zero()
}
fn schedule_code_upgrade(_b: u32) -> Weight {
Weight::zero()
}
fn set_current_head(_b: u32) -> Weight {
Weight::zero()
}
}
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
/// The in-code storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(1);
#[pallet::pallet]
#[pallet::without_storage_info]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);
#[pallet::config]
#[pallet::disable_frame_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// The aggregated origin type must support the `teyrchains` origin. We require that we can
/// infallibly convert between this origin and the system origin, but in reality, they're
/// the same type, we just can't express that to the Rust type system without writing a
/// `where` clause everywhere.
type RuntimeOrigin: From<<Self as frame_system::Config>::RuntimeOrigin>
+ Into<result::Result<Origin, <Self as Config>::RuntimeOrigin>>;
/// The system's currency for on-demand teyrchain payment.
type Currency: ReservableCurrency<Self::AccountId>;
/// Runtime hook for when a lease holding teyrchain and on-demand teyrchain swap.
type OnSwap: crate::traits::OnSwap;
/// The deposit to be paid to run a on-demand teyrchain.
/// This should include the cost for storing the genesis head and validation code.
#[pallet::constant]
type ParaDeposit: Get<BalanceOf<Self>>;
/// The deposit to be paid per byte stored on chain.
#[pallet::constant]
type DataDepositPerByte: Get<BalanceOf<Self>>;
/// Weight Information for the Extrinsics in the Pallet
type WeightInfo: WeightInfo;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
Registered { para_id: ParaId, manager: T::AccountId },
Deregistered { para_id: ParaId },
Reserved { para_id: ParaId, who: T::AccountId },
Swapped { para_id: ParaId, other_id: ParaId },
}
#[pallet::error]
pub enum Error<T> {
/// The ID is not registered.
NotRegistered,
/// The ID is already registered.
AlreadyRegistered,
/// The caller is not the owner of this Id.
NotOwner,
/// Invalid para code size.
CodeTooLarge,
/// Invalid para head data size.
HeadDataTooLarge,
/// Para is not a Teyrchain.
NotTeyrchain,
/// Para is not a Parathread (on-demand teyrchain).
NotParathread,
/// Cannot deregister para
CannotDeregister,
/// Cannot schedule downgrade of lease holding teyrchain to on-demand teyrchain
CannotDowngrade,
/// Cannot schedule upgrade of on-demand teyrchain to lease holding teyrchain
CannotUpgrade,
/// Para is locked from manipulation by the manager. Must use teyrchain or relay chain
/// governance.
ParaLocked,
/// The ID given for registration has not been reserved.
NotReserved,
/// The validation code is invalid.
InvalidCode,
/// Cannot perform a teyrchain slot / lifecycle swap. Check that the state of both paras
/// are correct for the swap to work.
CannotSwap,
}
/// Pending swap operations.
#[pallet::storage]
pub(super) type PendingSwap<T> = StorageMap<_, Twox64Concat, ParaId, ParaId>;
/// Amount held on deposit for each para and the original depositor.
///
/// The given account ID is responsible for registering the code and initial head data, but may
/// only do so if it isn't yet registered. (After that, it's up to governance to do so.)
#[pallet::storage]
pub type Paras<T: Config> =
StorageMap<_, Twox64Concat, ParaId, ParaInfo<T::AccountId, BalanceOf<T>>>;
/// The next free `ParaId`.
#[pallet::storage]
pub type NextFreeParaId<T> = StorageValue<_, ParaId, ValueQuery>;
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
#[serde(skip)]
pub _config: core::marker::PhantomData<T>,
pub next_free_para_id: ParaId,
}
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
GenesisConfig { next_free_para_id: LOWEST_PUBLIC_ID, _config: Default::default() }
}
}
#[pallet::genesis_build]
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
NextFreeParaId::<T>::put(self.next_free_para_id);
}
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Register head data and validation code for a reserved Para Id.
///
/// ## Arguments
/// - `origin`: Must be called by a `Signed` origin.
/// - `id`: The para ID. Must be owned/managed by the `origin` signing account.
/// - `genesis_head`: The genesis head data of the teyrchain/thread.
/// - `validation_code`: The initial validation code of the teyrchain/thread.
///
/// ## Deposits/Fees
/// The account with the originating signature must reserve a deposit.
///
/// The deposit is required to cover the costs associated with storing the genesis head
/// data and the validation code.
/// This accounts for the potential to store validation code of a size up to the
/// `max_code_size`, as defined in the configuration pallet
///
/// Anything already reserved previously for this para ID is accounted for.
///
/// ## Events
/// The `Registered` event is emitted in case of success.
#[pallet::call_index(0)]
#[pallet::weight(<T as Config>::WeightInfo::register())]
pub fn register(
origin: OriginFor<T>,
id: ParaId,
genesis_head: HeadData,
validation_code: ValidationCode,
) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::do_register(who, None, id, genesis_head, validation_code, true)?;
Ok(())
}
/// Force the registration of a Para Id on the relay chain.
///
/// This function must be called by a Root origin.
///
/// The deposit taken can be specified for this registration. Any `ParaId`
/// can be registered, including sub-1000 IDs which are System Teyrchains.
#[pallet::call_index(1)]
#[pallet::weight(<T as Config>::WeightInfo::force_register())]
pub fn force_register(
origin: OriginFor<T>,
who: T::AccountId,
deposit: BalanceOf<T>,
id: ParaId,
genesis_head: HeadData,
validation_code: ValidationCode,
) -> DispatchResult {
ensure_root(origin)?;
Self::do_register(who, Some(deposit), id, genesis_head, validation_code, false)
}
/// Deregister a Para Id, freeing all data and returning any deposit.
///
/// The caller must be Root, the `para` owner, or the `para` itself. The para must be an
/// on-demand teyrchain.
#[pallet::call_index(2)]
#[pallet::weight(<T as Config>::WeightInfo::deregister())]
pub fn deregister(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, id)?;
Self::do_deregister(id)
}
/// Swap a lease holding teyrchain with another teyrchain, either on-demand or lease
/// holding.
///
/// The origin must be Root, the `para` owner, or the `para` itself.
///
/// The swap will happen only if there is already an opposite swap pending. If there is not,
/// the swap will be stored in the pending swaps map, ready for a later confirmatory swap.
///
/// The `ParaId`s remain mapped to the same head data and code so external code can rely on
/// `ParaId` to be a long-term identifier of a notional "teyrchain". However, their
/// scheduling info (i.e. whether they're an on-demand teyrchain or lease holding
/// teyrchain), auction information and the auction deposit are switched.
#[pallet::call_index(3)]
#[pallet::weight(<T as Config>::WeightInfo::swap())]
pub fn swap(origin: OriginFor<T>, id: ParaId, other: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, id)?;
// If `id` and `other` is the same id, we treat this as a "clear" function, and exit
// early, since swapping the same id would otherwise be a noop.
if id == other {
PendingSwap::<T>::remove(id);
return Ok(());
}
// Sanity check that `id` is even a para.
let id_lifecycle =
paras::Pallet::<T>::lifecycle(id).ok_or(Error::<T>::NotRegistered)?;
if PendingSwap::<T>::get(other) == Some(id) {
let other_lifecycle =
paras::Pallet::<T>::lifecycle(other).ok_or(Error::<T>::NotRegistered)?;
// identify which is a lease holding teyrchain and which is a parathread (on-demand
// teyrchain)
if id_lifecycle == ParaLifecycle::Teyrchain &&
other_lifecycle == ParaLifecycle::Parathread
{
Self::do_thread_and_chain_swap(id, other);
} else if id_lifecycle == ParaLifecycle::Parathread &&
other_lifecycle == ParaLifecycle::Teyrchain
{
Self::do_thread_and_chain_swap(other, id);
} else if id_lifecycle == ParaLifecycle::Teyrchain &&
other_lifecycle == ParaLifecycle::Teyrchain
{
// If both chains are currently teyrchains, there is nothing funny we
// need to do for their lifecycle management, just swap the underlying
// data.
T::OnSwap::on_swap(id, other);
} else {
return Err(Error::<T>::CannotSwap.into());
}
Self::deposit_event(Event::<T>::Swapped { para_id: id, other_id: other });
PendingSwap::<T>::remove(other);
} else {
PendingSwap::<T>::insert(id, other);
}
Ok(())
}
/// Remove a manager lock from a para. This will allow the manager of a
/// previously locked para to deregister or swap a para without using governance.
///
/// Can only be called by the Root origin or the teyrchain.
#[pallet::call_index(4)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn remove_lock(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
Self::ensure_root_or_para(origin, para)?;
<Self as Registrar>::remove_lock(para);
Ok(())
}
/// Reserve a Para Id on the relay chain.
///
/// This function will reserve a new Para Id to be owned/managed by the origin account.
/// The origin account is able to register head data and validation code using `register` to
/// create an on-demand teyrchain. Using the Slots pallet, an on-demand teyrchain can then
/// be upgraded to a lease holding teyrchain.
///
/// ## Arguments
/// - `origin`: Must be called by a `Signed` origin. Becomes the manager/owner of the new
/// para ID.
///
/// ## Deposits/Fees
/// The origin must reserve a deposit of `ParaDeposit` for the registration.
///
/// ## Events
/// The `Reserved` event is emitted in case of success, which provides the ID reserved for
/// use.
#[pallet::call_index(5)]
#[pallet::weight(<T as Config>::WeightInfo::reserve())]
pub fn reserve(origin: OriginFor<T>) -> DispatchResult {
let who = ensure_signed(origin)?;
let id = NextFreeParaId::<T>::get().max(LOWEST_PUBLIC_ID);
Self::do_reserve(who, None, id)?;
NextFreeParaId::<T>::set(id + 1);
Ok(())
}
/// Add a manager lock from a para. This will prevent the manager of a
/// para to deregister or swap a para.
///
/// Can be called by Root, the teyrchain, or the teyrchain manager if the teyrchain is
/// unlocked.
#[pallet::call_index(6)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn add_lock(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, para)?;
<Self as Registrar>::apply_lock(para);
Ok(())
}
/// Schedule a teyrchain upgrade.
///
/// This will kick off a check of `new_code` by all validators. After the majority of the
/// validators have reported on the validity of the code, the code will either be enacted
/// or the upgrade will be rejected. If the code will be enacted, the current code of the
/// teyrchain will be overwritten directly. This means that any PoV will be checked by this
/// new code. The teyrchain itself will not be informed explicitly that the validation code
/// has changed.
///
/// Can be called by Root, the teyrchain, or the teyrchain manager if the teyrchain is
/// unlocked.
#[pallet::call_index(7)]
#[pallet::weight(<T as Config>::WeightInfo::schedule_code_upgrade(new_code.0.len() as u32))]
pub fn schedule_code_upgrade(
origin: OriginFor<T>,
para: ParaId,
new_code: ValidationCode,
) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, para)?;
pezkuwi_runtime_teyrchains::schedule_code_upgrade::<T>(
para,
new_code,
UpgradeStrategy::ApplyAtExpectedBlock,
)?;
Ok(())
}
/// Set the teyrchain's current head.
///
/// Can be called by Root, the teyrchain, or the teyrchain manager if the teyrchain is
/// unlocked.
#[pallet::call_index(8)]
#[pallet::weight(<T as Config>::WeightInfo::set_current_head(new_head.0.len() as u32))]
pub fn set_current_head(
origin: OriginFor<T>,
para: ParaId,
new_head: HeadData,
) -> DispatchResult {
Self::ensure_root_para_or_owner(origin, para)?;
pezkuwi_runtime_teyrchains::set_current_head::<T>(para, new_head);
Ok(())
}
}
}
impl<T: Config> Registrar for Pallet<T> {
type AccountId = T::AccountId;
/// Return the manager `AccountId` of a para if one exists.
fn manager_of(id: ParaId) -> Option<T::AccountId> {
Some(Paras::<T>::get(id)?.manager)
}
// All lease holding teyrchains. Ordered ascending by ParaId. On-demand teyrchains are not
// included.
fn teyrchains() -> Vec<ParaId> {
paras::Teyrchains::<T>::get()
}
// Return if a para is a parathread (on-demand teyrchain)
fn is_parathread(id: ParaId) -> bool {
paras::Pallet::<T>::is_parathread(id)
}
// Return if a para is a lease holding teyrchain
fn is_teyrchain(id: ParaId) -> bool {
paras::Pallet::<T>::is_teyrchain(id)
}
// Apply a lock to the teyrchain.
fn apply_lock(id: ParaId) {
Paras::<T>::mutate(id, |x| x.as_mut().map(|info| info.locked = Some(true)));
}
// Remove a lock from the teyrchain.
fn remove_lock(id: ParaId) {
Paras::<T>::mutate(id, |x| x.as_mut().map(|info| info.locked = Some(false)));
}
// Register a Para ID under control of `manager`.
//
// Note this is a backend registration API, so verification of ParaId
// is not done here to prevent.
fn register(
manager: T::AccountId,
id: ParaId,
genesis_head: HeadData,
validation_code: ValidationCode,
) -> DispatchResult {
Self::do_register(manager, None, id, genesis_head, validation_code, false)
}
// Deregister a Para ID, free any data, and return any deposits.
fn deregister(id: ParaId) -> DispatchResult {
Self::do_deregister(id)
}
// Upgrade a registered on-demand teyrchain into a lease holding teyrchain.
fn make_teyrchain(id: ParaId) -> DispatchResult {
// Para backend should think this is an on-demand teyrchain...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Parathread),
Error::<T>::NotParathread
);
pezkuwi_runtime_teyrchains::schedule_parathread_upgrade::<T>(id)
.map_err(|_| Error::<T>::CannotUpgrade)?;
Ok(())
}
// Downgrade a registered para into a parathread (on-demand teyrchain).
fn make_parathread(id: ParaId) -> DispatchResult {
// Para backend should think this is a teyrchain...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Teyrchain),
Error::<T>::NotTeyrchain
);
pezkuwi_runtime_teyrchains::schedule_teyrchain_downgrade::<T>(id)
.map_err(|_| Error::<T>::CannotDowngrade)?;
Ok(())
}
#[cfg(any(feature = "runtime-benchmarks", test))]
fn worst_head_data() -> HeadData {
let max_head_size = configuration::ActiveConfig::<T>::get().max_head_data_size;
assert!(max_head_size > 0, "max_head_data can't be zero for generating worst head data.");
vec![0u8; max_head_size as usize].into()
}
#[cfg(any(feature = "runtime-benchmarks", test))]
fn worst_validation_code() -> ValidationCode {
let max_code_size = configuration::ActiveConfig::<T>::get().max_code_size;
assert!(max_code_size > 0, "max_code_size can't be zero for generating worst code data.");
let validation_code = vec![0u8; max_code_size as usize];
validation_code.into()
}
#[cfg(any(feature = "runtime-benchmarks", test))]
fn execute_pending_transitions() {
use pezkuwi_runtime_teyrchains::shared;
shared::Pallet::<T>::set_session_index(shared::Pallet::<T>::scheduled_session());
paras::Pallet::<T>::test_on_new_session();
}
}
impl<T: Config> Pallet<T> {
/// Ensure the origin is one of Root, the `para` owner, or the `para` itself.
/// If the origin is the `para` owner, the `para` must be unlocked.
fn ensure_root_para_or_owner(
origin: <T as frame_system::Config>::RuntimeOrigin,
id: ParaId,
) -> DispatchResult {
if let Ok(who) = ensure_signed(origin.clone()) {
let para_info = Paras::<T>::get(id).ok_or(Error::<T>::NotRegistered)?;
if para_info.manager == who {
ensure!(!para_info.is_locked(), Error::<T>::ParaLocked);
return Ok(());
}
}
Self::ensure_root_or_para(origin, id)
}
/// Ensure the origin is one of Root or the `para` itself.
fn ensure_root_or_para(
origin: <T as frame_system::Config>::RuntimeOrigin,
id: ParaId,
) -> DispatchResult {
if ensure_root(origin.clone()).is_ok() {
return Ok(());
}
let caller_id = ensure_teyrchain(<T as Config>::RuntimeOrigin::from(origin))?;
// Check if matching para id...
ensure!(caller_id == id, Error::<T>::NotOwner);
Ok(())
}
fn do_reserve(
who: T::AccountId,
deposit_override: Option<BalanceOf<T>>,
id: ParaId,
) -> DispatchResult {
ensure!(!Paras::<T>::contains_key(id), Error::<T>::AlreadyRegistered);
ensure!(paras::Pallet::<T>::lifecycle(id).is_none(), Error::<T>::AlreadyRegistered);
let deposit = deposit_override.unwrap_or_else(T::ParaDeposit::get);
<T as Config>::Currency::reserve(&who, deposit)?;
let info = ParaInfo { manager: who.clone(), deposit, locked: None };
Paras::<T>::insert(id, info);
Self::deposit_event(Event::<T>::Reserved { para_id: id, who });
Ok(())
}
/// Attempt to register a new Para Id under management of `who` in the
/// system with the given information.
fn do_register(
who: T::AccountId,
deposit_override: Option<BalanceOf<T>>,
id: ParaId,
genesis_head: HeadData,
validation_code: ValidationCode,
ensure_reserved: bool,
) -> DispatchResult {
let deposited = if let Some(para_data) = Paras::<T>::get(id) {
ensure!(para_data.manager == who, Error::<T>::NotOwner);
ensure!(!para_data.is_locked(), Error::<T>::ParaLocked);
para_data.deposit
} else {
ensure!(!ensure_reserved, Error::<T>::NotReserved);
Default::default()
};
ensure!(paras::Pallet::<T>::lifecycle(id).is_none(), Error::<T>::AlreadyRegistered);
let (genesis, deposit) =
Self::validate_onboarding_data(genesis_head, validation_code, ParaKind::Parathread)?;
let deposit = deposit_override.unwrap_or(deposit);
if let Some(additional) = deposit.checked_sub(&deposited) {
<T as Config>::Currency::reserve(&who, additional)?;
} else if let Some(rebate) = deposited.checked_sub(&deposit) {
<T as Config>::Currency::unreserve(&who, rebate);
};
let info = ParaInfo { manager: who.clone(), deposit, locked: None };
Paras::<T>::insert(id, info);
// We check above that para has no lifecycle, so this should not fail.
let res = pezkuwi_runtime_teyrchains::schedule_para_initialize::<T>(id, genesis);
debug_assert!(res.is_ok());
Self::deposit_event(Event::<T>::Registered { para_id: id, manager: who });
Ok(())
}
/// Deregister a Para Id, freeing all data returning any deposit.
fn do_deregister(id: ParaId) -> DispatchResult {
match paras::Pallet::<T>::lifecycle(id) {
// Para must be a parathread (on-demand teyrchain), or not exist at all.
Some(ParaLifecycle::Parathread) | None => {},
_ => return Err(Error::<T>::NotParathread.into()),
}
pezkuwi_runtime_teyrchains::schedule_para_cleanup::<T>(id)
.map_err(|_| Error::<T>::CannotDeregister)?;
if let Some(info) = Paras::<T>::take(&id) {
<T as Config>::Currency::unreserve(&info.manager, info.deposit);
}
PendingSwap::<T>::remove(id);
Self::deposit_event(Event::<T>::Deregistered { para_id: id });
Ok(())
}
/// Verifies the onboarding data is valid for a para.
///
/// Returns `ParaGenesisArgs` and the deposit needed for the data.
fn validate_onboarding_data(
genesis_head: HeadData,
validation_code: ValidationCode,
para_kind: ParaKind,
) -> Result<(ParaGenesisArgs, BalanceOf<T>), sp_runtime::DispatchError> {
let config = configuration::ActiveConfig::<T>::get();
ensure!(validation_code.0.len() >= MIN_CODE_SIZE as usize, Error::<T>::InvalidCode);
ensure!(validation_code.0.len() <= config.max_code_size as usize, Error::<T>::CodeTooLarge);
ensure!(
genesis_head.0.len() <= config.max_head_data_size as usize,
Error::<T>::HeadDataTooLarge
);
let per_byte_fee = T::DataDepositPerByte::get();
let deposit = T::ParaDeposit::get()
.saturating_add(per_byte_fee.saturating_mul((genesis_head.0.len() as u32).into()))
.saturating_add(per_byte_fee.saturating_mul(config.max_code_size.into()));
Ok((ParaGenesisArgs { genesis_head, validation_code, para_kind }, deposit))
}
/// Swap a lease holding teyrchain and parathread (on-demand teyrchain), which involves
/// scheduling an appropriate lifecycle update.
fn do_thread_and_chain_swap(to_downgrade: ParaId, to_upgrade: ParaId) {
let res1 = pezkuwi_runtime_teyrchains::schedule_teyrchain_downgrade::<T>(to_downgrade);
debug_assert!(res1.is_ok());
let res2 = pezkuwi_runtime_teyrchains::schedule_parathread_upgrade::<T>(to_upgrade);
debug_assert!(res2.is_ok());
T::OnSwap::on_swap(to_upgrade, to_downgrade);
}
}
impl<T: Config> OnNewHead for Pallet<T> {
fn on_new_head(id: ParaId, _head: &HeadData) -> Weight {
// mark the teyrchain locked if the locked value is not already set
let mut writes = 0;
if let Some(mut info) = Paras::<T>::get(id) {
if info.locked.is_none() {
info.locked = Some(true);
Paras::<T>::insert(id, info);
writes += 1;
}
}
T::DbWeight::get().reads_writes(1, writes)
}
}
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
@@ -0,0 +1,588 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the paras_registrar pallet.
#[cfg(test)]
use super::*;
use crate::{
mock::conclude_pvf_checking, paras_registrar, paras_registrar::mock::*,
traits::Registrar as RegistrarTrait,
};
use frame_support::{assert_noop, assert_ok};
use pallet_balances::Error as BalancesError;
use pezkuwi_primitives::SessionIndex;
use sp_runtime::traits::BadOrigin;
#[test]
fn end_to_end_scenario_works() {
new_test_ext().execute_with(|| {
let para_id = LOWEST_PUBLIC_ID;
const START_SESSION_INDEX: SessionIndex = 1;
run_to_session(START_SESSION_INDEX);
// first para is not yet registered
assert!(!Teyrchains::is_parathread(para_id));
// We register the Para ID
let validation_code = test_validation_code(32);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(32),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX);
run_to_session(START_SESSION_INDEX + 2);
// It is now a parathread (on-demand teyrchain).
assert!(Teyrchains::is_parathread(para_id));
assert!(!Teyrchains::is_teyrchain(para_id));
// Some other external process will elevate on-demand to lease holding teyrchain
assert_ok!(mock::Registrar::make_teyrchain(para_id));
run_to_session(START_SESSION_INDEX + 4);
// It is now a lease holding teyrchain.
assert!(!Teyrchains::is_parathread(para_id));
assert!(Teyrchains::is_teyrchain(para_id));
// Turn it back into a parathread (on-demand teyrchain)
assert_ok!(mock::Registrar::make_parathread(para_id));
run_to_session(START_SESSION_INDEX + 6);
assert!(Teyrchains::is_parathread(para_id));
assert!(!Teyrchains::is_teyrchain(para_id));
// Deregister it
assert_ok!(mock::Registrar::deregister(RuntimeOrigin::root(), para_id,));
run_to_session(START_SESSION_INDEX + 8);
// It is nothing
assert!(!Teyrchains::is_parathread(para_id));
assert!(!Teyrchains::is_teyrchain(para_id));
});
}
#[test]
fn register_works() {
new_test_ext().execute_with(|| {
const START_SESSION_INDEX: SessionIndex = 1;
run_to_session(START_SESSION_INDEX);
let para_id = LOWEST_PUBLIC_ID;
assert!(!Teyrchains::is_parathread(para_id));
let validation_code = test_validation_code(32);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_eq!(Balances::reserved_balance(&1), <Test as Config>::ParaDeposit::get());
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(32),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX);
run_to_session(START_SESSION_INDEX + 2);
assert!(Teyrchains::is_parathread(para_id));
// Even though the registered validation code has a smaller size than the maximum the
// para manager's deposit is reserved as though they registered the maximum-sized code.
// Consequently, they can upgrade their code to the maximum size at any point without
// additional cost.
let validation_code_deposit =
max_code_size() as BalanceOf<Test> * <Test as Config>::DataDepositPerByte::get();
let head_deposit = 32 * <Test as Config>::DataDepositPerByte::get();
assert_eq!(
Balances::reserved_balance(&1),
<Test as Config>::ParaDeposit::get() + head_deposit + validation_code_deposit
);
});
}
#[test]
fn schedule_code_upgrade_validates_code() {
new_test_ext().execute_with(|| {
const START_SESSION_INDEX: SessionIndex = 1;
run_to_session(START_SESSION_INDEX);
let para_id = LOWEST_PUBLIC_ID;
assert!(!Teyrchains::is_parathread(para_id));
let validation_code = test_validation_code(32);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_eq!(Balances::reserved_balance(&1), <Test as Config>::ParaDeposit::get());
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(32),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX);
run_to_session(START_SESSION_INDEX + 2);
assert!(Teyrchains::is_parathread(para_id));
let new_code = test_validation_code(0);
assert_noop!(
mock::Registrar::schedule_code_upgrade(
RuntimeOrigin::signed(1),
para_id,
new_code.clone(),
),
paras::Error::<Test>::InvalidCode
);
let new_code = test_validation_code(max_code_size() as usize + 1);
assert_noop!(
mock::Registrar::schedule_code_upgrade(
RuntimeOrigin::signed(1),
para_id,
new_code.clone(),
),
paras::Error::<Test>::InvalidCode
);
});
}
#[test]
fn register_handles_basic_errors() {
new_test_ext().execute_with(|| {
let para_id = LOWEST_PUBLIC_ID;
assert_noop!(
mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize),
),
Error::<Test>::NotReserved
);
// Successfully register para
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_noop!(
mock::Registrar::register(
RuntimeOrigin::signed(2),
para_id,
test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize),
),
Error::<Test>::NotOwner
);
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize),
));
// Can skip pre-check and deregister para which's still onboarding.
run_to_session(2);
assert_ok!(mock::Registrar::deregister(RuntimeOrigin::root(), para_id));
// Can't do it again
assert_noop!(
mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(max_head_size() as usize),
test_validation_code(max_code_size() as usize),
),
Error::<Test>::NotReserved
);
// Head Size Check
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(2)));
assert_noop!(
mock::Registrar::register(
RuntimeOrigin::signed(2),
para_id + 1,
test_genesis_head((max_head_size() + 1) as usize),
test_validation_code(max_code_size() as usize),
),
Error::<Test>::HeadDataTooLarge
);
// Code Size Check
assert_noop!(
mock::Registrar::register(
RuntimeOrigin::signed(2),
para_id + 1,
test_genesis_head(max_head_size() as usize),
test_validation_code((max_code_size() + 1) as usize),
),
Error::<Test>::CodeTooLarge
);
// Needs enough funds for deposit
assert_noop!(
mock::Registrar::reserve(RuntimeOrigin::signed(1337)),
BalancesError::<Test, _>::InsufficientBalance
);
});
}
#[test]
fn deregister_works() {
new_test_ext().execute_with(|| {
const START_SESSION_INDEX: SessionIndex = 1;
run_to_session(START_SESSION_INDEX);
let para_id = LOWEST_PUBLIC_ID;
assert!(!Teyrchains::is_parathread(para_id));
let validation_code = test_validation_code(32);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(32),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX);
run_to_session(START_SESSION_INDEX + 2);
assert!(Teyrchains::is_parathread(para_id));
assert_ok!(mock::Registrar::deregister(RuntimeOrigin::root(), para_id,));
run_to_session(START_SESSION_INDEX + 4);
assert!(paras::Pallet::<Test>::lifecycle(para_id).is_none());
assert_eq!(Balances::reserved_balance(&1), 0);
});
}
#[test]
fn deregister_handles_basic_errors() {
new_test_ext().execute_with(|| {
const START_SESSION_INDEX: SessionIndex = 1;
run_to_session(START_SESSION_INDEX);
let para_id = LOWEST_PUBLIC_ID;
assert!(!Teyrchains::is_parathread(para_id));
let validation_code = test_validation_code(32);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
test_genesis_head(32),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX);
run_to_session(START_SESSION_INDEX + 2);
assert!(Teyrchains::is_parathread(para_id));
// Owner check
assert_noop!(mock::Registrar::deregister(RuntimeOrigin::signed(2), para_id,), BadOrigin);
assert_ok!(mock::Registrar::make_teyrchain(para_id));
run_to_session(START_SESSION_INDEX + 4);
// Cant directly deregister teyrchain
assert_noop!(
mock::Registrar::deregister(RuntimeOrigin::root(), para_id,),
Error::<Test>::NotParathread
);
});
}
#[test]
fn swap_works() {
new_test_ext().execute_with(|| {
const START_SESSION_INDEX: SessionIndex = 1;
run_to_session(START_SESSION_INDEX);
// Successfully register first two teyrchains
let para_1 = LOWEST_PUBLIC_ID;
let para_2 = LOWEST_PUBLIC_ID + 1;
let validation_code = test_validation_code(max_code_size() as usize);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_1,
test_genesis_head(max_head_size() as usize),
validation_code.clone(),
));
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(2)));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(2),
para_2,
test_genesis_head(max_head_size() as usize),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX);
run_to_session(START_SESSION_INDEX + 2);
// Upgrade para 1 into a teyrchain
assert_ok!(mock::Registrar::make_teyrchain(para_1));
// Set some mock swap data.
let mut swap_data = SwapData::get();
swap_data.insert(para_1, 69);
swap_data.insert(para_2, 1337);
SwapData::set(swap_data);
run_to_session(START_SESSION_INDEX + 4);
// Roles are as we expect
assert!(Teyrchains::is_teyrchain(para_1));
assert!(!Teyrchains::is_parathread(para_1));
assert!(!Teyrchains::is_teyrchain(para_2));
assert!(Teyrchains::is_parathread(para_2));
// Both paras initiate a swap
// Swap between teyrchain and parathread
assert_ok!(mock::Registrar::swap(para_origin(para_1), para_1, para_2,));
assert_ok!(mock::Registrar::swap(para_origin(para_2), para_2, para_1,));
System::assert_last_event(RuntimeEvent::Registrar(paras_registrar::Event::Swapped {
para_id: para_2,
other_id: para_1,
}));
run_to_session(START_SESSION_INDEX + 6);
// Roles are swapped
assert!(!Teyrchains::is_teyrchain(para_1));
assert!(Teyrchains::is_parathread(para_1));
assert!(Teyrchains::is_teyrchain(para_2));
assert!(!Teyrchains::is_parathread(para_2));
// Data is swapped
assert_eq!(SwapData::get().get(&para_1).unwrap(), &1337);
assert_eq!(SwapData::get().get(&para_2).unwrap(), &69);
// Both paras initiate a swap
// Swap between parathread and teyrchain
assert_ok!(mock::Registrar::swap(para_origin(para_1), para_1, para_2,));
assert_ok!(mock::Registrar::swap(para_origin(para_2), para_2, para_1,));
System::assert_last_event(RuntimeEvent::Registrar(paras_registrar::Event::Swapped {
para_id: para_2,
other_id: para_1,
}));
// Data is swapped
assert_eq!(SwapData::get().get(&para_1).unwrap(), &69);
assert_eq!(SwapData::get().get(&para_2).unwrap(), &1337);
// Teyrchain to teyrchain swap
let para_3 = LOWEST_PUBLIC_ID + 2;
let validation_code = test_validation_code(max_code_size() as usize);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(3)));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(3),
para_3,
test_genesis_head(max_head_size() as usize),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX + 6);
run_to_session(START_SESSION_INDEX + 8);
// Upgrade para 3 into a teyrchain
assert_ok!(mock::Registrar::make_teyrchain(para_3));
// Set some mock swap data.
let mut swap_data = SwapData::get();
swap_data.insert(para_3, 777);
SwapData::set(swap_data);
run_to_session(START_SESSION_INDEX + 10);
// Both are teyrchains
assert!(Teyrchains::is_teyrchain(para_3));
assert!(!Teyrchains::is_parathread(para_3));
assert!(Teyrchains::is_teyrchain(para_1));
assert!(!Teyrchains::is_parathread(para_1));
// Both paras initiate a swap
// Swap between teyrchain and teyrchain
assert_ok!(mock::Registrar::swap(para_origin(para_1), para_1, para_3,));
assert_ok!(mock::Registrar::swap(para_origin(para_3), para_3, para_1,));
System::assert_last_event(RuntimeEvent::Registrar(paras_registrar::Event::Swapped {
para_id: para_3,
other_id: para_1,
}));
// Data is swapped
assert_eq!(SwapData::get().get(&para_3).unwrap(), &69);
assert_eq!(SwapData::get().get(&para_1).unwrap(), &777);
});
}
#[test]
fn para_lock_works() {
new_test_ext().execute_with(|| {
run_to_block(1);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
let para_id = LOWEST_PUBLIC_ID;
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_id,
vec![1; 3].into(),
test_validation_code(32)
));
assert_noop!(mock::Registrar::add_lock(RuntimeOrigin::signed(2), para_id), BadOrigin);
// Once they produces new block, we lock them in.
mock::Registrar::on_new_head(para_id, &Default::default());
// Owner cannot pass origin check when checking lock
assert_noop!(
mock::Registrar::ensure_root_para_or_owner(RuntimeOrigin::signed(1), para_id),
Error::<Test>::ParaLocked,
);
// Owner cannot remove lock.
assert_noop!(mock::Registrar::remove_lock(RuntimeOrigin::signed(1), para_id), BadOrigin);
// Para can.
assert_ok!(mock::Registrar::remove_lock(para_origin(para_id), para_id));
// Owner can pass origin check again
assert_ok!(mock::Registrar::ensure_root_para_or_owner(RuntimeOrigin::signed(1), para_id));
// Won't lock again after it is unlocked
mock::Registrar::on_new_head(para_id, &Default::default());
assert_ok!(mock::Registrar::ensure_root_para_or_owner(RuntimeOrigin::signed(1), para_id));
});
}
#[test]
fn swap_handles_bad_states() {
new_test_ext().execute_with(|| {
const START_SESSION_INDEX: SessionIndex = 1;
run_to_session(START_SESSION_INDEX);
let para_1 = LOWEST_PUBLIC_ID;
let para_2 = LOWEST_PUBLIC_ID + 1;
// paras are not yet registered
assert!(!Teyrchains::is_parathread(para_1));
assert!(!Teyrchains::is_parathread(para_2));
// Cannot even start a swap
assert_noop!(
mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2),
Error::<Test>::NotRegistered
);
// We register Paras 1 and 2
let validation_code = test_validation_code(32);
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(1)));
assert_ok!(mock::Registrar::reserve(RuntimeOrigin::signed(2)));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(1),
para_1,
test_genesis_head(32),
validation_code.clone(),
));
assert_ok!(mock::Registrar::register(
RuntimeOrigin::signed(2),
para_2,
test_genesis_head(32),
validation_code.clone(),
));
conclude_pvf_checking::<Test>(&validation_code, VALIDATORS, START_SESSION_INDEX);
// Cannot swap
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!(
mock::Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap
);
run_to_session(START_SESSION_INDEX + 2);
// They are now parathreads (on-demand teyrchains).
assert!(Teyrchains::is_parathread(para_1));
assert!(Teyrchains::is_parathread(para_2));
// Cannot swap
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!(
mock::Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap
);
// Some other external process will elevate one on-demand
// teyrchain to a lease holding teyrchain
assert_ok!(mock::Registrar::make_teyrchain(para_1));
// Cannot swap
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!(
mock::Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap
);
run_to_session(START_SESSION_INDEX + 3);
// Cannot swap
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!(
mock::Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap
);
run_to_session(START_SESSION_INDEX + 4);
// It is now a lease holding teyrchain.
assert!(Teyrchains::is_teyrchain(para_1));
assert!(Teyrchains::is_parathread(para_2));
// Swap works here.
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_2, para_1));
assert!(System::events().iter().any(|r| matches!(
r.event,
RuntimeEvent::Registrar(paras_registrar::Event::Swapped { .. })
)));
run_to_session(START_SESSION_INDEX + 5);
// Cannot swap
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!(
mock::Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap
);
run_to_session(START_SESSION_INDEX + 6);
// Swap worked!
assert!(Teyrchains::is_teyrchain(para_2));
assert!(Teyrchains::is_parathread(para_1));
assert!(System::events().iter().any(|r| matches!(
r.event,
RuntimeEvent::Registrar(paras_registrar::Event::Swapped { .. })
)));
// Something starts to downgrade a para
assert_ok!(mock::Registrar::make_parathread(para_2));
run_to_session(START_SESSION_INDEX + 7);
// Cannot swap
assert_ok!(mock::Registrar::swap(RuntimeOrigin::root(), para_1, para_2));
assert_noop!(
mock::Registrar::swap(RuntimeOrigin::root(), para_2, para_1),
Error::<Test>::CannotSwap
);
run_to_session(START_SESSION_INDEX + 8);
assert!(Teyrchains::is_parathread(para_1));
assert!(Teyrchains::is_parathread(para_2));
});
}
@@ -0,0 +1,191 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! A simple wrapper allowing `Sudo` to call into `paras` routines.
use alloc::boxed::Box;
use codec::Encode;
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
pub use pallet::*;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_runtime_teyrchains::{
configuration, dmp, hrmp,
paras::{self, AssignCoretime, ParaGenesisArgs, ParaKind},
ParaLifecycle,
};
#[frame_support::pallet]
pub mod pallet {
use super::*;
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::config]
#[pallet::disable_frame_system_supertrait_check]
pub trait Config: configuration::Config + paras::Config + dmp::Config + hrmp::Config {}
#[pallet::error]
pub enum Error<T> {
/// The specified teyrchain is not registered.
ParaDoesntExist,
/// The specified teyrchain is already registered.
ParaAlreadyExists,
/// A DMP message couldn't be sent because it exceeds the maximum size allowed for a
/// downward message.
ExceedsMaxMessageSize,
/// A DMP message couldn't be sent because the destination is unreachable.
Unroutable,
/// Could not schedule para cleanup.
CouldntCleanup,
/// Not a parathread (on-demand teyrchain).
NotParathread,
/// Not a lease holding teyrchain.
NotTeyrchain,
/// Cannot upgrade on-demand teyrchain to lease holding teyrchain.
CannotUpgrade,
/// Cannot downgrade lease holding teyrchain to on-demand.
CannotDowngrade,
/// There are more cores than supported by the runtime.
TooManyCores,
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Schedule a para to be initialized at the start of the next session.
///
/// This should only be used for TESTING and not on PRODUCTION chains. It automatically
/// assigns Coretime to the chain and increases the number of cores. Thus, there is no
/// running coretime chain required.
#[pallet::call_index(0)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_para_initialize(
origin: OriginFor<T>,
id: ParaId,
genesis: ParaGenesisArgs,
) -> DispatchResult {
ensure_root(origin)?;
let assign_coretime = genesis.para_kind == ParaKind::Teyrchain;
pezkuwi_runtime_teyrchains::schedule_para_initialize::<T>(id, genesis)
.map_err(|_| Error::<T>::ParaAlreadyExists)?;
if assign_coretime {
T::AssignCoretime::assign_coretime(id)?;
}
Ok(())
}
/// Schedule a para to be cleaned up at the start of the next session.
#[pallet::call_index(1)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_para_cleanup(origin: OriginFor<T>, id: ParaId) -> DispatchResult {
ensure_root(origin)?;
pezkuwi_runtime_teyrchains::schedule_para_cleanup::<T>(id)
.map_err(|_| Error::<T>::CouldntCleanup)?;
Ok(())
}
/// Upgrade a parathread (on-demand teyrchain) to a lease holding teyrchain
#[pallet::call_index(2)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_parathread_upgrade(
origin: OriginFor<T>,
id: ParaId,
) -> DispatchResult {
ensure_root(origin)?;
// Para backend should think this is a parathread (on-demand teyrchain)...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Parathread),
Error::<T>::NotParathread,
);
pezkuwi_runtime_teyrchains::schedule_parathread_upgrade::<T>(id)
.map_err(|_| Error::<T>::CannotUpgrade)?;
Ok(())
}
/// Downgrade a lease holding teyrchain to an on-demand teyrchain
#[pallet::call_index(3)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_schedule_teyrchain_downgrade(
origin: OriginFor<T>,
id: ParaId,
) -> DispatchResult {
ensure_root(origin)?;
// Para backend should think this is a teyrchain...
ensure!(
paras::Pallet::<T>::lifecycle(id) == Some(ParaLifecycle::Teyrchain),
Error::<T>::NotTeyrchain,
);
pezkuwi_runtime_teyrchains::schedule_teyrchain_downgrade::<T>(id)
.map_err(|_| Error::<T>::CannotDowngrade)?;
Ok(())
}
/// Send a downward XCM to the given para.
///
/// The given teyrchain should exist and the payload should not exceed the preconfigured
/// size `config.max_downward_message_size`.
#[pallet::call_index(4)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_queue_downward_xcm(
origin: OriginFor<T>,
id: ParaId,
xcm: Box<xcm::opaque::VersionedXcm>,
) -> DispatchResult {
ensure_root(origin)?;
ensure!(paras::Pallet::<T>::is_valid_para(id), Error::<T>::ParaDoesntExist);
let config = configuration::ActiveConfig::<T>::get();
dmp::Pallet::<T>::queue_downward_message(&config, id, xcm.encode()).map_err(|e| match e
{
dmp::QueueDownwardMessageError::ExceedsMaxMessageSize =>
Error::<T>::ExceedsMaxMessageSize.into(),
dmp::QueueDownwardMessageError::Unroutable => Error::<T>::Unroutable.into(),
})
}
/// Forcefully establish a channel from the sender to the recipient.
///
/// This is equivalent to sending an `Hrmp::hrmp_init_open_channel` extrinsic followed by
/// `Hrmp::hrmp_accept_open_channel`.
#[pallet::call_index(5)]
#[pallet::weight((1_000, DispatchClass::Operational))]
pub fn sudo_establish_hrmp_channel(
origin: OriginFor<T>,
sender: ParaId,
recipient: ParaId,
max_capacity: u32,
max_message_size: u32,
) -> DispatchResult {
ensure_root(origin)?;
hrmp::Pallet::<T>::init_open_channel(
sender,
recipient,
max_capacity,
max_message_size,
)?;
hrmp::Pallet::<T>::accept_open_channel(recipient, sender)?;
Ok(())
}
}
}
+181
View File
@@ -0,0 +1,181 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Mocking utilities for testing in purchase pallet.
#[cfg(test)]
use super::*;
use sp_core::{crypto::AccountId32, H256};
use sp_keyring::{Ed25519Keyring, Sr25519Keyring};
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use crate::purchase;
use frame_support::{
derive_impl, ord_parameter_types, parameter_types,
traits::{Currency, WithdrawReasons},
};
use sp_runtime::{
traits::{BlakeTwo256, Identity, IdentityLookup},
BuildStorage,
};
type Block = frame_system::mocking::MockBlock<Test>;
frame_support::construct_runtime!(
pub enum Test
{
System: frame_system,
Balances: pallet_balances,
Vesting: pallet_vesting,
Purchase: purchase,
}
);
type AccountId = AccountId32;
#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
type BlockWeights = ();
type BlockLength = ();
type DbWeight = ();
type RuntimeOrigin = RuntimeOrigin;
type RuntimeCall = RuntimeCall;
type Nonce = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = AccountId;
type Lookup = IdentityLookup<AccountId>;
type Block = Block;
type RuntimeEvent = RuntimeEvent;
type Version = ();
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<u64>;
type OnNewAccount = ();
type OnKilledAccount = ();
type SystemWeightInfo = ();
type SS58Prefix = ();
type OnSetCode = ();
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
#[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)]
impl pallet_balances::Config for Test {
type AccountStore = System;
}
parameter_types! {
pub const MinVestedTransfer: u64 = 1;
pub UnvestedFundsAllowedWithdrawReasons: WithdrawReasons =
WithdrawReasons::except(WithdrawReasons::TRANSFER | WithdrawReasons::RESERVE);
}
impl pallet_vesting::Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BlockNumberToBalance = Identity;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = ();
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
type BlockNumberProvider = System;
const MAX_VESTING_SCHEDULES: u32 = 28;
}
parameter_types! {
pub const MaxStatementLength: u32 = 1_000;
pub const UnlockedProportion: Permill = Permill::from_percent(10);
pub const MaxUnlocked: u64 = 10;
}
ord_parameter_types! {
pub const ValidityOrigin: AccountId = AccountId32::from([0u8; 32]);
pub const PaymentOrigin: AccountId = AccountId32::from([1u8; 32]);
pub const ConfigurationOrigin: AccountId = AccountId32::from([2u8; 32]);
}
impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type VestingSchedule = Vesting;
type ValidityOrigin = frame_system::EnsureSignedBy<ValidityOrigin, AccountId>;
type ConfigurationOrigin = frame_system::EnsureSignedBy<ConfigurationOrigin, AccountId>;
type MaxStatementLength = MaxStatementLength;
type UnlockedProportion = UnlockedProportion;
type MaxUnlocked = MaxUnlocked;
}
// This function basically just builds a genesis storage key/value store according to
// our desired mockup. It also executes our `setup` function which sets up this pallet for use.
pub fn new_test_ext() -> sp_io::TestExternalities {
let t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let mut ext = sp_io::TestExternalities::new(t);
ext.execute_with(|| setup());
ext
}
pub fn setup() {
let statement = b"Hello, World".to_vec();
let unlock_block = 100;
Purchase::set_statement(RuntimeOrigin::signed(configuration_origin()), statement).unwrap();
Purchase::set_unlock_block(RuntimeOrigin::signed(configuration_origin()), unlock_block)
.unwrap();
Purchase::set_payment_account(RuntimeOrigin::signed(configuration_origin()), payment_account())
.unwrap();
Balances::make_free_balance_be(&payment_account(), 100_000);
}
pub fn alice() -> AccountId {
Sr25519Keyring::Alice.to_account_id()
}
pub fn alice_ed25519() -> AccountId {
Ed25519Keyring::Alice.to_account_id()
}
pub fn bob() -> AccountId {
Sr25519Keyring::Bob.to_account_id()
}
pub fn alice_signature() -> [u8; 64] {
// echo -n "Hello, World" | subkey -s sign "bottom drive obey lake curtain smoke basket hold
// race lonely fit walk//Alice"
hex_literal::hex!("20e0faffdf4dfe939f2faa560f73b1d01cde8472e2b690b7b40606a374244c3a2e9eb9c8107c10b605138374003af8819bd4387d7c24a66ee9253c2e688ab881")
}
pub fn bob_signature() -> [u8; 64] {
// echo -n "Hello, World" | subkey -s sign "bottom drive obey lake curtain smoke basket hold
// race lonely fit walk//Bob"
hex_literal::hex!("d6d460187ecf530f3ec2d6e3ac91b9d083c8fbd8f1112d92a82e4d84df552d18d338e6da8944eba6e84afaacf8a9850f54e7b53a84530d649be2e0119c7ce889")
}
pub fn alice_signature_ed25519() -> [u8; 64] {
// echo -n "Hello, World" | subkey -e sign "bottom drive obey lake curtain smoke basket hold
// race lonely fit walk//Alice"
hex_literal::hex!("ee3f5a6cbfc12a8f00c18b811dc921b550ddf272354cda4b9a57b1d06213fcd8509f5af18425d39a279d13622f14806c3e978e2163981f2ec1c06e9628460b0e")
}
pub fn validity_origin() -> AccountId {
ValidityOrigin::get()
}
pub fn configuration_origin() -> AccountId {
ConfigurationOrigin::get()
}
pub fn payment_account() -> AccountId {
[42u8; 32].into()
}
+485
View File
@@ -0,0 +1,485 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Pallet to process purchase of DOTs.
use alloc::vec::Vec;
use codec::{Decode, Encode};
use frame_support::{
pallet_prelude::*,
traits::{Currency, EnsureOrigin, ExistenceRequirement, Get, VestingSchedule},
};
use frame_system::pallet_prelude::*;
pub use pallet::*;
use scale_info::TypeInfo;
use sp_core::sr25519;
use sp_runtime::{
traits::{CheckedAdd, Saturating, Verify, Zero},
AnySignature, DispatchError, DispatchResult, Permill, RuntimeDebug,
};
type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
/// The kind of statement an account needs to make for a claim to be valid.
#[derive(
Encode, Decode, DecodeWithMemTracking, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo,
)]
pub enum AccountValidity {
/// Account is not valid.
Invalid,
/// Account has initiated the account creation process.
Initiated,
/// Account is pending validation.
Pending,
/// Account is valid with a low contribution amount.
ValidLow,
/// Account is valid with a high contribution amount.
ValidHigh,
/// Account has completed the purchase process.
Completed,
}
impl Default for AccountValidity {
fn default() -> Self {
AccountValidity::Invalid
}
}
impl AccountValidity {
fn is_valid(&self) -> bool {
match self {
Self::Invalid => false,
Self::Initiated => false,
Self::Pending => false,
Self::ValidLow => true,
Self::ValidHigh => true,
Self::Completed => false,
}
}
}
/// All information about an account regarding the purchase of DOTs.
#[derive(Encode, Decode, Default, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct AccountStatus<Balance> {
/// The current validity status of the user. Will denote if the user has passed KYC,
/// how much they are able to purchase, and when their purchase process has completed.
validity: AccountValidity,
/// The amount of free DOTs they have purchased.
free_balance: Balance,
/// The amount of locked DOTs they have purchased.
locked_balance: Balance,
/// Their sr25519/ed25519 signature verifying they have signed our required statement.
signature: Vec<u8>,
/// The percentage of VAT the purchaser is responsible for. This is already factored into
/// account balance.
vat: Permill,
}
#[frame_support::pallet]
pub mod pallet {
use super::*;
#[pallet::pallet]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);
#[pallet::config]
pub trait Config: frame_system::Config {
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Balances Pallet
type Currency: Currency<Self::AccountId>;
/// Vesting Pallet
type VestingSchedule: VestingSchedule<
Self::AccountId,
Moment = BlockNumberFor<Self>,
Currency = Self::Currency,
>;
/// The origin allowed to set account status.
type ValidityOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The origin allowed to make configurations to the pallet.
type ConfigurationOrigin: EnsureOrigin<Self::RuntimeOrigin>;
/// The maximum statement length for the statement users to sign when creating an account.
#[pallet::constant]
type MaxStatementLength: Get<u32>;
/// The amount of purchased locked DOTs that we will unlock for basic actions on the chain.
#[pallet::constant]
type UnlockedProportion: Get<Permill>;
/// The maximum amount of locked DOTs that we will unlock.
#[pallet::constant]
type MaxUnlocked: Get<BalanceOf<Self>>;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// A new account was created.
AccountCreated { who: T::AccountId },
/// Someone's account validity was updated.
ValidityUpdated { who: T::AccountId, validity: AccountValidity },
/// Someone's purchase balance was updated.
BalanceUpdated { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
/// A payout was made to a purchaser.
PaymentComplete { who: T::AccountId, free: BalanceOf<T>, locked: BalanceOf<T> },
/// A new payment account was set.
PaymentAccountSet { who: T::AccountId },
/// A new statement was set.
StatementUpdated,
/// A new statement was set. `[block_number]`
UnlockBlockUpdated { block_number: BlockNumberFor<T> },
}
#[pallet::error]
pub enum Error<T> {
/// Account is not currently valid to use.
InvalidAccount,
/// Account used in the purchase already exists.
ExistingAccount,
/// Provided signature is invalid
InvalidSignature,
/// Account has already completed the purchase process.
AlreadyCompleted,
/// An overflow occurred when doing calculations.
Overflow,
/// The statement is too long to be stored on chain.
InvalidStatement,
/// The unlock block is in the past!
InvalidUnlockBlock,
/// Vesting schedule already exists for this account.
VestingScheduleExists,
}
// A map of all participants in the HEZ purchase process.
#[pallet::storage]
pub(super) type Accounts<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, AccountStatus<BalanceOf<T>>, ValueQuery>;
// The account that will be used to payout participants of the HEZ purchase process.
#[pallet::storage]
pub(super) type PaymentAccount<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
// The statement purchasers will need to sign to participate.
#[pallet::storage]
pub(super) type Statement<T> = StorageValue<_, Vec<u8>, ValueQuery>;
// The block where all locked dots will unlock.
#[pallet::storage]
pub(super) type UnlockBlock<T: Config> = StorageValue<_, BlockNumberFor<T>, ValueQuery>;
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Create a new account. Proof of existence through a valid signed message.
///
/// We check that the account does not exist at this stage.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(0)]
#[pallet::weight(Weight::from_parts(200_000_000, 0) + T::DbWeight::get().reads_writes(4, 1))]
pub fn create_account(
origin: OriginFor<T>,
who: T::AccountId,
signature: Vec<u8>,
) -> DispatchResult {
T::ValidityOrigin::ensure_origin(origin)?;
// Account is already being tracked by the pallet.
ensure!(!Accounts::<T>::contains_key(&who), Error::<T>::ExistingAccount);
// Account should not have a vesting schedule.
ensure!(
T::VestingSchedule::vesting_balance(&who).is_none(),
Error::<T>::VestingScheduleExists
);
// Verify the signature provided is valid for the statement.
Self::verify_signature(&who, &signature)?;
// Create a new pending account.
let status = AccountStatus {
validity: AccountValidity::Initiated,
signature,
free_balance: Zero::zero(),
locked_balance: Zero::zero(),
vat: Permill::zero(),
};
Accounts::<T>::insert(&who, status);
Self::deposit_event(Event::<T>::AccountCreated { who });
Ok(())
}
/// Update the validity status of an existing account. If set to completed, the account
/// will no longer be able to continue through the crowdfund process.
///
/// We check that the account exists at this stage, but has not completed the process.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(1)]
#[pallet::weight(T::DbWeight::get().reads_writes(1, 1))]
pub fn update_validity_status(
origin: OriginFor<T>,
who: T::AccountId,
validity: AccountValidity,
) -> DispatchResult {
T::ValidityOrigin::ensure_origin(origin)?;
ensure!(Accounts::<T>::contains_key(&who), Error::<T>::InvalidAccount);
Accounts::<T>::try_mutate(
&who,
|status: &mut AccountStatus<BalanceOf<T>>| -> DispatchResult {
ensure!(
status.validity != AccountValidity::Completed,
Error::<T>::AlreadyCompleted
);
status.validity = validity;
Ok(())
},
)?;
Self::deposit_event(Event::<T>::ValidityUpdated { who, validity });
Ok(())
}
/// Update the balance of a valid account.
///
/// We check that the account is valid for a balance transfer at this point.
///
/// Origin must match the `ValidityOrigin`.
#[pallet::call_index(2)]
#[pallet::weight(T::DbWeight::get().reads_writes(2, 1))]
pub fn update_balance(
origin: OriginFor<T>,
who: T::AccountId,
free_balance: BalanceOf<T>,
locked_balance: BalanceOf<T>,
vat: Permill,
) -> DispatchResult {
T::ValidityOrigin::ensure_origin(origin)?;
Accounts::<T>::try_mutate(
&who,
|status: &mut AccountStatus<BalanceOf<T>>| -> DispatchResult {
// Account has a valid status (not Invalid, Pending, or Completed)...
ensure!(status.validity.is_valid(), Error::<T>::InvalidAccount);
free_balance.checked_add(&locked_balance).ok_or(Error::<T>::Overflow)?;
status.free_balance = free_balance;
status.locked_balance = locked_balance;
status.vat = vat;
Ok(())
},
)?;
Self::deposit_event(Event::<T>::BalanceUpdated {
who,
free: free_balance,
locked: locked_balance,
});
Ok(())
}
/// Pay the user and complete the purchase process.
///
/// We reverify all assumptions about the state of an account, and complete the process.
///
/// Origin must match the configured `PaymentAccount` (if it is not configured then this
/// will always fail with `BadOrigin`).
#[pallet::call_index(3)]
#[pallet::weight(T::DbWeight::get().reads_writes(4, 2))]
pub fn payout(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
// Payments must be made directly by the `PaymentAccount`.
let payment_account = ensure_signed(origin)?;
let test_against = PaymentAccount::<T>::get().ok_or(DispatchError::BadOrigin)?;
ensure!(payment_account == test_against, DispatchError::BadOrigin);
// Account should not have a vesting schedule.
ensure!(
T::VestingSchedule::vesting_balance(&who).is_none(),
Error::<T>::VestingScheduleExists
);
Accounts::<T>::try_mutate(
&who,
|status: &mut AccountStatus<BalanceOf<T>>| -> DispatchResult {
// Account has a valid status (not Invalid, Pending, or Completed)...
ensure!(status.validity.is_valid(), Error::<T>::InvalidAccount);
// Transfer funds from the payment account into the purchasing user.
let total_balance = status
.free_balance
.checked_add(&status.locked_balance)
.ok_or(Error::<T>::Overflow)?;
T::Currency::transfer(
&payment_account,
&who,
total_balance,
ExistenceRequirement::AllowDeath,
)?;
if !status.locked_balance.is_zero() {
let unlock_block = UnlockBlock::<T>::get();
// We allow some configurable portion of the purchased locked DOTs to be
// unlocked for basic usage.
let unlocked = (T::UnlockedProportion::get() * status.locked_balance)
.min(T::MaxUnlocked::get());
let locked = status.locked_balance.saturating_sub(unlocked);
// We checked that this account has no existing vesting schedule. So this
// function should never fail, however if it does, not much we can do about
// it at this point.
let _ = T::VestingSchedule::add_vesting_schedule(
// Apply vesting schedule to this user
&who,
// For this much amount
locked,
// Unlocking the full amount after one block
locked,
// When everything unlocks
unlock_block,
);
}
// Setting the user account to `Completed` ends the purchase process for this
// user.
status.validity = AccountValidity::Completed;
Self::deposit_event(Event::<T>::PaymentComplete {
who: who.clone(),
free: status.free_balance,
locked: status.locked_balance,
});
Ok(())
},
)?;
Ok(())
}
/* Configuration Operations */
/// Set the account that will be used to payout users in the HEZ purchase process.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(4)]
#[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_payment_account(origin: OriginFor<T>, who: T::AccountId) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
// Possibly this is worse than having the caller account be the payment account?
PaymentAccount::<T>::put(who.clone());
Self::deposit_event(Event::<T>::PaymentAccountSet { who });
Ok(())
}
/// Set the statement that must be signed for a user to participate on the HEZ sale.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(5)]
#[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_statement(origin: OriginFor<T>, statement: Vec<u8>) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
ensure!(
(statement.len() as u32) < T::MaxStatementLength::get(),
Error::<T>::InvalidStatement
);
// Possibly this is worse than having the caller account be the payment account?
Statement::<T>::set(statement);
Self::deposit_event(Event::<T>::StatementUpdated);
Ok(())
}
/// Set the block where locked DOTs will become unlocked.
///
/// Origin must match the `ConfigurationOrigin`
#[pallet::call_index(6)]
#[pallet::weight(T::DbWeight::get().writes(1))]
pub fn set_unlock_block(
origin: OriginFor<T>,
unlock_block: BlockNumberFor<T>,
) -> DispatchResult {
T::ConfigurationOrigin::ensure_origin(origin)?;
ensure!(
unlock_block > frame_system::Pallet::<T>::block_number(),
Error::<T>::InvalidUnlockBlock
);
// Possibly this is worse than having the caller account be the payment account?
UnlockBlock::<T>::set(unlock_block);
Self::deposit_event(Event::<T>::UnlockBlockUpdated { block_number: unlock_block });
Ok(())
}
}
}
impl<T: Config> Pallet<T> {
fn verify_signature(who: &T::AccountId, signature: &[u8]) -> Result<(), DispatchError> {
// sr25519 always expects a 64 byte signature.
let signature: AnySignature = sr25519::Signature::try_from(signature)
.map_err(|_| Error::<T>::InvalidSignature)?
.into();
// In Pezkuwi, the AccountId is always the same as the 32 byte public key.
let account_bytes: [u8; 32] = account_to_bytes(who)?;
let public_key = sr25519::Public::from_raw(account_bytes);
let message = Statement::<T>::get();
// Check if everything is good or not.
match signature.verify(message.as_slice(), &public_key) {
true => Ok(()),
false => Err(Error::<T>::InvalidSignature)?,
}
}
}
// This function converts a 32 byte AccountId to its byte-array equivalent form.
fn account_to_bytes<AccountId>(account: &AccountId) -> Result<[u8; 32], DispatchError>
where
AccountId: Encode,
{
let account_vec = account.encode();
ensure!(account_vec.len() == 32, "AccountId must be 32 bytes.");
let mut bytes = [0u8; 32];
bytes.copy_from_slice(&account_vec);
Ok(bytes)
}
/// WARNING: Executing this function will clear all storage used by this pallet.
/// Be sure this is what you want...
pub fn remove_pallet<T>() -> frame_support::weights::Weight
where
T: frame_system::Config,
{
#[allow(deprecated)]
use frame_support::migration::remove_storage_prefix;
#[allow(deprecated)]
remove_storage_prefix(b"Purchase", b"Accounts", b"");
#[allow(deprecated)]
remove_storage_prefix(b"Purchase", b"PaymentAccount", b"");
#[allow(deprecated)]
remove_storage_prefix(b"Purchase", b"Statement", b"");
#[allow(deprecated)]
remove_storage_prefix(b"Purchase", b"UnlockBlock", b"");
<T as frame_system::Config>::BlockWeights::get().max_block
}
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
@@ -0,0 +1,547 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the purchase pallet.
#[cfg(test)]
use super::*;
use sp_core::crypto::AccountId32;
// The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
use frame_support::{assert_noop, assert_ok, traits::Currency};
use sp_runtime::{traits::Dispatchable, ArithmeticError, DispatchError::BadOrigin};
use crate::purchase::mock::*;
#[test]
fn set_statement_works_and_handles_basic_errors() {
new_test_ext().execute_with(|| {
let statement = b"Test Set Statement".to_vec();
// Invalid origin
assert_noop!(
Purchase::set_statement(RuntimeOrigin::signed(alice()), statement.clone()),
BadOrigin,
);
// Too Long
let long_statement = [0u8; 10_000].to_vec();
assert_noop!(
Purchase::set_statement(RuntimeOrigin::signed(configuration_origin()), long_statement),
Error::<Test>::InvalidStatement,
);
// Just right...
assert_ok!(Purchase::set_statement(
RuntimeOrigin::signed(configuration_origin()),
statement.clone()
));
assert_eq!(Statement::<Test>::get(), statement);
});
}
#[test]
fn set_unlock_block_works_and_handles_basic_errors() {
new_test_ext().execute_with(|| {
let unlock_block = 69;
// Invalid origin
assert_noop!(
Purchase::set_unlock_block(RuntimeOrigin::signed(alice()), unlock_block),
BadOrigin,
);
// Block Number in Past
let bad_unlock_block = 50;
System::set_block_number(bad_unlock_block);
assert_noop!(
Purchase::set_unlock_block(
RuntimeOrigin::signed(configuration_origin()),
bad_unlock_block
),
Error::<Test>::InvalidUnlockBlock,
);
// Just right...
assert_ok!(Purchase::set_unlock_block(
RuntimeOrigin::signed(configuration_origin()),
unlock_block
));
assert_eq!(UnlockBlock::<Test>::get(), unlock_block);
});
}
#[test]
fn set_payment_account_works_and_handles_basic_errors() {
new_test_ext().execute_with(|| {
let payment_account: AccountId32 = [69u8; 32].into();
// Invalid Origin
assert_noop!(
Purchase::set_payment_account(RuntimeOrigin::signed(alice()), payment_account.clone()),
BadOrigin,
);
// Just right...
assert_ok!(Purchase::set_payment_account(
RuntimeOrigin::signed(configuration_origin()),
payment_account.clone()
));
assert_eq!(PaymentAccount::<Test>::get(), Some(payment_account));
});
}
#[test]
fn signature_verification_works() {
new_test_ext().execute_with(|| {
assert_ok!(Purchase::verify_signature(&alice(), &alice_signature()));
assert_ok!(Purchase::verify_signature(&alice_ed25519(), &alice_signature_ed25519()));
assert_ok!(Purchase::verify_signature(&bob(), &bob_signature()));
// Mixing and matching fails
assert_noop!(
Purchase::verify_signature(&alice(), &bob_signature()),
Error::<Test>::InvalidSignature
);
assert_noop!(
Purchase::verify_signature(&bob(), &alice_signature()),
Error::<Test>::InvalidSignature
);
});
}
#[test]
fn account_creation_works() {
new_test_ext().execute_with(|| {
assert!(!Accounts::<Test>::contains_key(alice()));
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
alice_signature().to_vec(),
));
assert_eq!(
Accounts::<Test>::get(alice()),
AccountStatus {
validity: AccountValidity::Initiated,
free_balance: Zero::zero(),
locked_balance: Zero::zero(),
signature: alice_signature().to_vec(),
vat: Permill::zero(),
}
);
});
}
#[test]
fn account_creation_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Wrong Origin
assert_noop!(
Purchase::create_account(
RuntimeOrigin::signed(alice()),
alice(),
alice_signature().to_vec()
),
BadOrigin,
);
// Wrong Account/Signature
assert_noop!(
Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
bob_signature().to_vec()
),
Error::<Test>::InvalidSignature,
);
// Account with vesting
Balances::make_free_balance_be(&alice(), 100);
assert_ok!(<Test as Config>::VestingSchedule::add_vesting_schedule(&alice(), 100, 1, 50));
assert_noop!(
Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
alice_signature().to_vec()
),
Error::<Test>::VestingScheduleExists,
);
// Duplicate Purchasing Account
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
bob(),
bob_signature().to_vec()
));
assert_noop!(
Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
bob(),
bob_signature().to_vec()
),
Error::<Test>::ExistingAccount,
);
});
}
#[test]
fn update_validity_status_works() {
new_test_ext().execute_with(|| {
// Alice account is created.
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
alice_signature().to_vec(),
));
// She submits KYC, and we update the status to `Pending`.
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::Pending,
));
// KYC comes back negative, so we mark the account invalid.
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::Invalid,
));
assert_eq!(
Accounts::<Test>::get(alice()),
AccountStatus {
validity: AccountValidity::Invalid,
free_balance: Zero::zero(),
locked_balance: Zero::zero(),
signature: alice_signature().to_vec(),
vat: Permill::zero(),
}
);
// She fixes it, we mark her account valid.
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::ValidLow,
));
assert_eq!(
Accounts::<Test>::get(alice()),
AccountStatus {
validity: AccountValidity::ValidLow,
free_balance: Zero::zero(),
locked_balance: Zero::zero(),
signature: alice_signature().to_vec(),
vat: Permill::zero(),
}
);
});
}
#[test]
fn update_validity_status_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Wrong Origin
assert_noop!(
Purchase::update_validity_status(
RuntimeOrigin::signed(alice()),
alice(),
AccountValidity::Pending,
),
BadOrigin
);
// Inactive Account
assert_noop!(
Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::Pending,
),
Error::<Test>::InvalidAccount
);
// Already Completed
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
alice_signature().to_vec(),
));
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::Completed,
));
assert_noop!(
Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::Pending,
),
Error::<Test>::AlreadyCompleted
);
});
}
#[test]
fn update_balance_works() {
new_test_ext().execute_with(|| {
// Alice account is created
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
alice_signature().to_vec()
));
// And approved for basic contribution
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::ValidLow,
));
// We set a balance on the user based on the payment they made. 50 locked, 50 free.
assert_ok!(Purchase::update_balance(
RuntimeOrigin::signed(validity_origin()),
alice(),
50,
50,
Permill::from_rational(77u32, 1000u32),
));
assert_eq!(
Accounts::<Test>::get(alice()),
AccountStatus {
validity: AccountValidity::ValidLow,
free_balance: 50,
locked_balance: 50,
signature: alice_signature().to_vec(),
vat: Permill::from_parts(77000),
}
);
// We can update the balance based on new information.
assert_ok!(Purchase::update_balance(
RuntimeOrigin::signed(validity_origin()),
alice(),
25,
50,
Permill::zero(),
));
assert_eq!(
Accounts::<Test>::get(alice()),
AccountStatus {
validity: AccountValidity::ValidLow,
free_balance: 25,
locked_balance: 50,
signature: alice_signature().to_vec(),
vat: Permill::zero(),
}
);
});
}
#[test]
fn update_balance_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Wrong Origin
assert_noop!(
Purchase::update_balance(
RuntimeOrigin::signed(alice()),
alice(),
50,
50,
Permill::zero(),
),
BadOrigin
);
// Inactive Account
assert_noop!(
Purchase::update_balance(
RuntimeOrigin::signed(validity_origin()),
alice(),
50,
50,
Permill::zero(),
),
Error::<Test>::InvalidAccount
);
// Overflow
assert_noop!(
Purchase::update_balance(
RuntimeOrigin::signed(validity_origin()),
alice(),
u64::MAX,
u64::MAX,
Permill::zero(),
),
Error::<Test>::InvalidAccount
);
});
}
#[test]
fn payout_works() {
new_test_ext().execute_with(|| {
// Alice and Bob accounts are created
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
alice_signature().to_vec()
));
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
bob(),
bob_signature().to_vec()
));
// Alice is approved for basic contribution
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::ValidLow,
));
// Bob is approved for high contribution
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
bob(),
AccountValidity::ValidHigh,
));
// We set a balance on the users based on the payment they made. 50 locked, 50 free.
assert_ok!(Purchase::update_balance(
RuntimeOrigin::signed(validity_origin()),
alice(),
50,
50,
Permill::zero(),
));
assert_ok!(Purchase::update_balance(
RuntimeOrigin::signed(validity_origin()),
bob(),
100,
150,
Permill::zero(),
));
// Now we call payout for Alice and Bob.
assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),));
assert_ok!(Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),));
// Payment is made.
assert_eq!(<Test as Config>::Currency::free_balance(&payment_account()), 99_650);
assert_eq!(<Test as Config>::Currency::free_balance(&alice()), 100);
// 10% of the 50 units is unlocked automatically for Alice
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), Some(45));
assert_eq!(<Test as Config>::Currency::free_balance(&bob()), 250);
// A max of 10 units is unlocked automatically for Bob
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), Some(140));
// Status is completed.
assert_eq!(
Accounts::<Test>::get(alice()),
AccountStatus {
validity: AccountValidity::Completed,
free_balance: 50,
locked_balance: 50,
signature: alice_signature().to_vec(),
vat: Permill::zero(),
}
);
assert_eq!(
Accounts::<Test>::get(bob()),
AccountStatus {
validity: AccountValidity::Completed,
free_balance: 100,
locked_balance: 150,
signature: bob_signature().to_vec(),
vat: Permill::zero(),
}
);
// Vesting lock is removed in whole on block 101 (100 blocks after block 1)
System::set_block_number(100);
let vest_call = RuntimeCall::Vesting(pallet_vesting::Call::<Test>::vest {});
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice())));
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob())));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), Some(45));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), Some(140));
System::set_block_number(101);
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(alice())));
assert_ok!(vest_call.clone().dispatch(RuntimeOrigin::signed(bob())));
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&alice()), None);
assert_eq!(<Test as Config>::VestingSchedule::vesting_balance(&bob()), None);
});
}
#[test]
fn payout_handles_basic_errors() {
new_test_ext().execute_with(|| {
// Wrong Origin
assert_noop!(Purchase::payout(RuntimeOrigin::signed(alice()), alice(),), BadOrigin);
// Account with Existing Vesting Schedule
Balances::make_free_balance_be(&bob(), 100);
assert_ok!(<Test as Config>::VestingSchedule::add_vesting_schedule(&bob(), 100, 1, 50,));
assert_noop!(
Purchase::payout(RuntimeOrigin::signed(payment_account()), bob(),),
Error::<Test>::VestingScheduleExists
);
// Invalid Account (never created)
assert_noop!(
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
Error::<Test>::InvalidAccount
);
// Invalid Account (created, but not valid)
assert_ok!(Purchase::create_account(
RuntimeOrigin::signed(validity_origin()),
alice(),
alice_signature().to_vec()
));
assert_noop!(
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice(),),
Error::<Test>::InvalidAccount
);
// Not enough funds in payment account
assert_ok!(Purchase::update_validity_status(
RuntimeOrigin::signed(validity_origin()),
alice(),
AccountValidity::ValidHigh,
));
assert_ok!(Purchase::update_balance(
RuntimeOrigin::signed(validity_origin()),
alice(),
100_000,
100_000,
Permill::zero(),
));
assert_noop!(
Purchase::payout(RuntimeOrigin::signed(payment_account()), alice()),
ArithmeticError::Underflow
);
});
}
#[test]
fn remove_pallet_works() {
new_test_ext().execute_with(|| {
let account_status = AccountStatus {
validity: AccountValidity::Completed,
free_balance: 1234,
locked_balance: 4321,
signature: b"my signature".to_vec(),
vat: Permill::from_percent(50),
};
// Add some storage.
Accounts::<Test>::insert(alice(), account_status.clone());
Accounts::<Test>::insert(bob(), account_status);
PaymentAccount::<Test>::put(alice());
Statement::<Test>::put(b"hello, world!".to_vec());
UnlockBlock::<Test>::put(4);
// Verify storage exists.
assert_eq!(Accounts::<Test>::iter().count(), 2);
assert!(PaymentAccount::<Test>::exists());
assert!(Statement::<Test>::exists());
assert!(UnlockBlock::<Test>::exists());
// Remove storage.
remove_pallet::<Test>();
// Verify storage is gone.
assert_eq!(Accounts::<Test>::iter().count(), 0);
assert!(!PaymentAccount::<Test>::exists());
assert!(!Statement::<Test>::exists());
assert!(!UnlockBlock::<Test>::exists());
});
}
+69
View File
@@ -0,0 +1,69 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! The `SlotRange` struct which succinctly handles the 36 values that
//! represent all sub ranges between 0 and 7 inclusive.
slot_range_helper::generate_slot_range!(
Zero(0),
One(1),
Two(2),
Three(3),
Four(4),
Five(5),
Six(6),
Seven(7)
);
// Will generate:
// pub enum SlotRange {
// ZeroZero, 0
// ZeroOne, 1
// ZeroTwo, 2
// ZeroThree, 3
// ZeroFour, 4
// ZeroFive, 5
// ZeroSix, 6
// ZeroSeven, 7
// OneOne, 8
// OneTwo, 9
// OneThree, 10
// OneFour, 11
// OneFive, 12
// OneSix, 13
// OneSeven, 14
// TwoTwo, 15
// TwoThree, 16
// TwoFour, 17
// TwoFive, 18
// TwoSix, 19
// TwoSeven, 20
// ThreeThree, 21
// ThreeFour, 22
// ThreeFive, 23
// ThreeSix, 24
// ThreeSeven, 25
// FourFour, 26
// FourFive, 27
// FourSix, 28
// FourSeven, 29
// FiveFive, 30
// FiveSix, 31
// FiveSeven, 32
// SixSix, 33
// SixSeven, 34
// SevenSeven, 35
// }
@@ -0,0 +1,90 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
use super::*;
use crate::crowdloan;
use sp_runtime::traits::AccountIdConversion;
/// Migrations for using fund index to create fund accounts instead of para ID.
pub mod slots_crowdloan_index_migration {
use super::*;
// The old way we generated fund accounts.
fn old_fund_account_id<T: Config + crowdloan::Config>(index: ParaId) -> T::AccountId {
<T as crowdloan::Config>::PalletId::get().into_sub_account_truncating(index)
}
pub fn pre_migrate<T: Config + crowdloan::Config>() -> Result<(), &'static str> {
for (para_id, leases) in Leases::<T>::iter() {
let old_fund_account = old_fund_account_id::<T>(para_id);
for (who, _amount) in leases.iter().flatten() {
if *who == old_fund_account {
let crowdloan =
crowdloan::Funds::<T>::get(para_id).ok_or("no crowdloan found")?;
log::info!(
target: "runtime",
"para_id={:?}, old_fund_account={:?}, fund_id={:?}, leases={:?}",
para_id, old_fund_account, crowdloan.fund_index, leases,
);
break;
}
}
}
Ok(())
}
pub fn migrate<T: Config + crowdloan::Config>() -> frame_support::weights::Weight {
let mut weight = Weight::zero();
for (para_id, mut leases) in Leases::<T>::iter() {
weight = weight.saturating_add(T::DbWeight::get().reads(2));
// the para id must have a crowdloan
if let Some(fund) = crowdloan::Funds::<T>::get(para_id) {
let old_fund_account = old_fund_account_id::<T>(para_id);
let new_fund_account = crowdloan::Pallet::<T>::fund_account_id(fund.fund_index);
// look for places the old account is used, and replace with the new account.
for (who, _amount) in leases.iter_mut().flatten() {
if *who == old_fund_account {
*who = new_fund_account.clone();
}
}
// insert the changes.
weight = weight.saturating_add(T::DbWeight::get().writes(1));
Leases::<T>::insert(para_id, leases);
}
}
weight
}
pub fn post_migrate<T: Config + crowdloan::Config>() -> Result<(), &'static str> {
for (para_id, leases) in Leases::<T>::iter() {
let old_fund_account = old_fund_account_id::<T>(para_id);
log::info!(target: "runtime", "checking para_id: {:?}", para_id);
// check the old fund account doesn't exist anywhere.
for (who, _amount) in leases.iter().flatten() {
if *who == old_fund_account {
panic!("old fund account found after migration!");
}
}
}
Ok(())
}
}
File diff suppressed because it is too large Load Diff
+265
View File
@@ -0,0 +1,265 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Traits used across pallets for Pezkuwi.
use alloc::vec::*;
use frame_support::{
dispatch::DispatchResult,
traits::{Currency, ReservableCurrency},
};
use pezkuwi_primitives::{HeadData, Id as ParaId, ValidationCode};
/// Teyrchain registration API.
pub trait Registrar {
/// The account ID type that encodes a teyrchain manager ID.
type AccountId;
/// Report the manager (permissioned owner) of a teyrchain, if there is one.
fn manager_of(id: ParaId) -> Option<Self::AccountId>;
/// All lease holding teyrchains. Ordered ascending by `ParaId`. On-demand
/// teyrchains are not included.
fn teyrchains() -> Vec<ParaId>;
/// Return if a `ParaId` is a lease holding Teyrchain.
fn is_teyrchain(id: ParaId) -> bool {
Self::teyrchains().binary_search(&id).is_ok()
}
/// Return if a `ParaId` is a Parathread (on-demand teyrchain).
fn is_parathread(id: ParaId) -> bool;
/// Return if a `ParaId` is registered in the system.
fn is_registered(id: ParaId) -> bool {
Self::is_parathread(id) || Self::is_teyrchain(id)
}
/// Apply a lock to the para registration so that it cannot be modified by
/// the manager directly. Instead the para must use its sovereign governance
/// or the governance of the relay chain.
fn apply_lock(id: ParaId);
/// Remove any lock on the para registration.
fn remove_lock(id: ParaId);
/// Register a Para ID under control of `who`. Registration may be
/// delayed by session rotation.
fn register(
who: Self::AccountId,
id: ParaId,
genesis_head: HeadData,
validation_code: ValidationCode,
) -> DispatchResult;
/// Deregister a Para ID, free any data, and return any deposits.
fn deregister(id: ParaId) -> DispatchResult;
/// Elevate a para to teyrchain status.
fn make_teyrchain(id: ParaId) -> DispatchResult;
/// Downgrade lease holding teyrchain into parathread (on-demand teyrchain)
fn make_parathread(id: ParaId) -> DispatchResult;
#[cfg(any(feature = "runtime-benchmarks", test))]
fn worst_head_data() -> HeadData;
#[cfg(any(feature = "runtime-benchmarks", test))]
fn worst_validation_code() -> ValidationCode;
/// Execute any pending state transitions for paras.
/// For example onboarding to on-demand teyrchain, or upgrading on-demand to
/// lease holding teyrchain.
#[cfg(any(feature = "runtime-benchmarks", test))]
fn execute_pending_transitions();
}
/// Error type for something that went wrong with leasing.
#[derive(Debug)]
pub enum LeaseError {
/// Unable to reserve the funds in the leaser's account.
ReserveFailed,
/// There is already a lease on at least one period for the given para.
AlreadyLeased,
/// The period to be leased has already ended.
AlreadyEnded,
/// A lease period has not started yet, due to an offset in the starting block.
NoLeasePeriod,
}
/// Lease manager. Used by the auction module to handle teyrchain slot leases.
pub trait Leaser<BlockNumber> {
/// An account identifier for a leaser.
type AccountId;
/// The measurement type for counting lease periods (generally just a `BlockNumber`).
type LeasePeriod;
/// The currency type in which the lease is taken.
type Currency: ReservableCurrency<Self::AccountId>;
/// Lease a new teyrchain slot for `para`.
///
/// `leaser` shall have a total of `amount` balance reserved by the implementer of this trait.
///
/// Note: The implementer of the trait (the leasing system) is expected to do all
/// reserve/unreserve calls. The caller of this trait *SHOULD NOT* pre-reserve the deposit
/// (though should ensure that it is reservable).
///
/// The lease will last from `period_begin` for `period_count` lease periods. It is undefined if
/// the `para` already has a slot leased during those periods.
///
/// Returns `Err` in the case of an error, and in which case nothing is changed.
fn lease_out(
para: ParaId,
leaser: &Self::AccountId,
amount: <Self::Currency as Currency<Self::AccountId>>::Balance,
period_begin: Self::LeasePeriod,
period_count: Self::LeasePeriod,
) -> Result<(), LeaseError>;
/// Return the amount of balance currently held in reserve on `leaser`'s account for leasing
/// `para`. This won't go down outside a lease period.
fn deposit_held(
para: ParaId,
leaser: &Self::AccountId,
) -> <Self::Currency as Currency<Self::AccountId>>::Balance;
/// The length of a lease period, and any offset which may be introduced.
/// This is only used in benchmarking to automate certain calls.
#[cfg(any(feature = "runtime-benchmarks", test))]
fn lease_period_length() -> (BlockNumber, BlockNumber);
/// Returns the lease period at `block`, and if this is the first block of a new lease period.
///
/// Will return `None` if the first lease period has not started yet, for example when an offset
/// is placed.
fn lease_period_index(block: BlockNumber) -> Option<(Self::LeasePeriod, bool)>;
/// Returns true if the teyrchain already has a lease in any of lease periods in the inclusive
/// range `[first_period, last_period]`, intersected with the unbounded range
/// `[current_lease_period..]`.
fn already_leased(
para_id: ParaId,
first_period: Self::LeasePeriod,
last_period: Self::LeasePeriod,
) -> bool;
}
/// An enum which tracks the status of the auction system, and which phase it is in.
#[derive(PartialEq, Debug)]
pub enum AuctionStatus<BlockNumber> {
/// An auction has not started yet.
NotStarted,
/// We are in the starting period of the auction, collecting initial bids.
StartingPeriod,
/// We are in the ending period of the auction, where we are taking snapshots of the winning
/// bids. This state supports "sampling", where we may only take a snapshot every N blocks.
/// In this case, the first number is the current sample number, and the second number
/// is the sub-sample. i.e. for sampling every 20 blocks, the 25th block in the ending period
/// will be `EndingPeriod(1, 5)`.
EndingPeriod(BlockNumber, BlockNumber),
/// We have completed the bidding process and are waiting for the VRF to return some acceptable
/// randomness to select the winner. The number represents how many blocks we have been
/// waiting.
VrfDelay(BlockNumber),
}
impl<BlockNumber> AuctionStatus<BlockNumber> {
/// Returns true if the auction is in any state other than `NotStarted`.
pub fn is_in_progress(&self) -> bool {
!matches!(self, Self::NotStarted)
}
/// Return true if the auction is in the starting period.
pub fn is_starting(&self) -> bool {
matches!(self, Self::StartingPeriod)
}
/// Returns `Some(sample, sub_sample)` if the auction is in the `EndingPeriod`,
/// otherwise returns `None`.
pub fn is_ending(self) -> Option<(BlockNumber, BlockNumber)> {
match self {
Self::EndingPeriod(sample, sub_sample) => Some((sample, sub_sample)),
_ => None,
}
}
/// Returns true if the auction is in the `VrfDelay` period.
pub fn is_vrf(&self) -> bool {
matches!(self, Self::VrfDelay(_))
}
}
pub trait Auctioneer<BlockNumber> {
/// An account identifier for a leaser.
type AccountId;
/// The measurement type for counting lease periods (generally the same as `BlockNumber`).
type LeasePeriod;
/// The currency type in which the lease is taken.
type Currency: ReservableCurrency<Self::AccountId>;
/// Create a new auction.
///
/// This can only happen when there isn't already an auction in progress. Accepts the `duration`
/// of this auction and the `lease_period_index` of the initial lease period of the four that
/// are to be auctioned.
fn new_auction(duration: BlockNumber, lease_period_index: Self::LeasePeriod) -> DispatchResult;
/// Given the current block number, return the current auction status.
fn auction_status(now: BlockNumber) -> AuctionStatus<BlockNumber>;
/// Place a bid in the current auction.
///
/// - `bidder`: The account that will be funding this bid.
/// - `para`: The para to bid for.
/// - `first_slot`: The first lease period index of the range to be bid on.
/// - `last_slot`: The last lease period index of the range to be bid on (inclusive).
/// - `amount`: The total amount to be the bid for deposit over the range.
///
/// The account `Bidder` must have at least `amount` available as a free balance in `Currency`.
/// The implementation *MUST* remove or reserve `amount` funds from `bidder` and those funds
/// should be returned or freed once the bid is rejected or lease has ended.
fn place_bid(
bidder: Self::AccountId,
para: ParaId,
first_slot: Self::LeasePeriod,
last_slot: Self::LeasePeriod,
amount: <Self::Currency as Currency<Self::AccountId>>::Balance,
) -> DispatchResult;
/// The length of a lease period, and any offset which may be introduced.
/// This is only used in benchmarking to automate certain calls.
#[cfg(any(feature = "runtime-benchmarks", test))]
fn lease_period_length() -> (BlockNumber, BlockNumber);
/// Returns the lease period at `block`, and if this is the first block of a new lease period.
///
/// Will return `None` if the first lease period has not started yet, for example when an offset
/// is placed.
fn lease_period_index(block: BlockNumber) -> Option<(Self::LeasePeriod, bool)>;
/// Check if the para and user combination has won an auction in the past.
fn has_won_an_auction(para: ParaId, bidder: &Self::AccountId) -> bool;
}
/// Runtime hook for when we swap a lease holding teyrchain and an on-demand teyrchain.
#[impl_trait_for_tuples::impl_for_tuples(30)]
pub trait OnSwap {
/// Updates any needed state/references to enact a logical swap of two teyrchains. Identity,
/// code and `head_data` remain equivalent for all teyrchains/threads, however other properties
/// such as leases, deposits held and thread/chain nature are swapped.
fn on_swap(one: ParaId, other: ParaId);
}
+107
View File
@@ -0,0 +1,107 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Common try-runtime only tests for runtimes.
use alloc::{collections::btree_set::BTreeSet, vec::Vec};
use frame_support::{
dispatch::RawOrigin,
traits::{Get, Hooks},
};
use pallet_fast_unstake::{Pallet as FastUnstake, *};
use pallet_staking::*;
/// register all inactive nominators for fast-unstake, and progress until they have all been
/// processed.
pub fn migrate_all_inactive_nominators<T: pallet_fast_unstake::Config + pallet_staking::Config>()
where
<T as frame_system::Config>::RuntimeEvent: TryInto<pallet_fast_unstake::Event<T>>,
{
let mut unstaked_ok = 0;
let mut unstaked_err = 0;
let mut unstaked_slashed = 0;
let all_stakers = Ledger::<T>::iter().map(|(ctrl, l)| (ctrl, l.stash)).collect::<BTreeSet<_>>();
let mut all_exposed = BTreeSet::new();
ErasStakersPaged::<T>::iter().for_each(|((_era, val, _page), expo)| {
all_exposed.insert(val);
all_exposed.extend(expo.others.iter().map(|ie| ie.who.clone()))
});
let eligible = all_stakers
.iter()
.filter_map(|(ctrl, stash)| all_exposed.contains(stash).then_some(ctrl))
.collect::<Vec<_>>();
log::info!(
target: "runtime::test",
"registering {} out of {} stakers for fast-unstake",
eligible.len(),
all_stakers.len()
);
for ctrl in eligible {
if let Err(why) =
FastUnstake::<T>::register_fast_unstake(RawOrigin::Signed(ctrl.clone()).into())
{
log::warn!(target: "runtime::test", "failed to register {:?} due to {:?}", ctrl, why);
}
}
log::info!(
target: "runtime::test",
"registered {} successfully, starting at {:?}.",
Queue::<T>::count(),
frame_system::Pallet::<T>::block_number(),
);
while Queue::<T>::count() != 0 || Head::<T>::get().is_some() {
let now = frame_system::Pallet::<T>::block_number();
let weight = <T as frame_system::Config>::BlockWeights::get().max_block;
let consumed = FastUnstake::<T>::on_idle(now, weight);
log::debug!(target: "runtime::test", "consumed {:?} ({})", consumed, consumed.ref_time() as f32 / weight.ref_time() as f32);
frame_system::Pallet::<T>::read_events_no_consensus()
.into_iter()
.map(|r| r.event)
.filter_map(|e| {
let maybe_fast_unstake_event: Option<pallet_fast_unstake::Event<T>> =
e.try_into().ok();
maybe_fast_unstake_event
})
.for_each(|e: pallet_fast_unstake::Event<T>| match e {
pallet_fast_unstake::Event::<T>::Unstaked { result, .. } =>
if result.is_ok() {
unstaked_ok += 1;
} else {
unstaked_err += 1
},
pallet_fast_unstake::Event::<T>::Slashed { .. } => unstaked_slashed += 1,
pallet_fast_unstake::Event::<T>::InternalError => unreachable!(),
_ => {},
});
if now % 100u32.into() == sp_runtime::traits::Zero::zero() {
log::info!(
target: "runtime::test",
"status: ok {}, err {}, slash {}",
unstaked_ok,
unstaked_err,
unstaked_slashed,
);
}
frame_system::Pallet::<T>::reset_events();
}
}
+386
View File
@@ -0,0 +1,386 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! XCM sender for relay chain.
use alloc::vec::Vec;
use codec::{DecodeLimit, Encode};
use core::marker::PhantomData;
use frame_support::traits::Get;
use frame_system::pallet_prelude::BlockNumberFor;
use pezkuwi_primitives::Id as ParaId;
use pezkuwi_runtime_teyrchains::{
configuration::{self, HostConfiguration},
dmp, FeeTracker,
};
use sp_runtime::FixedPointNumber;
use xcm::{prelude::*, MAX_XCM_DECODE_DEPTH};
use xcm_builder::InspectMessageQueues;
use SendError::*;
/// Simple value-bearing trait for determining/expressing the assets required to be paid for a
/// messages to be delivered to a teyrchain.
pub trait PriceForMessageDelivery {
/// Type used for charging different prices to different destinations
type Id;
/// Return the assets required to deliver `message` to the given `para` destination.
fn price_for_delivery(id: Self::Id, message: &Xcm<()>) -> Assets;
}
impl PriceForMessageDelivery for () {
type Id = ();
fn price_for_delivery(_: Self::Id, _: &Xcm<()>) -> Assets {
Assets::new()
}
}
pub struct NoPriceForMessageDelivery<Id>(PhantomData<Id>);
impl<Id> PriceForMessageDelivery for NoPriceForMessageDelivery<Id> {
type Id = Id;
fn price_for_delivery(_: Self::Id, _: &Xcm<()>) -> Assets {
Assets::new()
}
}
/// Implementation of [`PriceForMessageDelivery`] which returns a fixed price.
pub struct ConstantPrice<T>(core::marker::PhantomData<T>);
impl<T: Get<Assets>> PriceForMessageDelivery for ConstantPrice<T> {
type Id = ();
fn price_for_delivery(_: Self::Id, _: &Xcm<()>) -> Assets {
T::get()
}
}
/// Implementation of [`PriceForMessageDelivery`] which returns an exponentially increasing price.
/// The formula for the fee is based on the sum of a base fee plus a message length fee, multiplied
/// by a specified factor. In mathematical form:
///
/// `F * (B + encoded_msg_len * M)`
///
/// Thus, if F = 1 and M = 0, this type is equivalent to [`ConstantPrice<B>`].
///
/// The type parameters are understood as follows:
///
/// - `A`: Used to denote the asset ID that will be used for paying the delivery fee.
/// - `B`: The base fee to pay for message delivery.
/// - `M`: The fee to pay for each and every byte of the message after encoding it.
/// - `F`: A fee factor multiplier. It can be understood as the exponent term in the formula.
pub struct ExponentialPrice<A, B, M, F>(core::marker::PhantomData<(A, B, M, F)>);
impl<A: Get<AssetId>, B: Get<u128>, M: Get<u128>, F: FeeTracker> PriceForMessageDelivery
for ExponentialPrice<A, B, M, F>
{
type Id = F::Id;
fn price_for_delivery(id: Self::Id, msg: &Xcm<()>) -> Assets {
let msg_fee = (msg.encoded_size() as u128).saturating_mul(M::get());
let fee_sum = B::get().saturating_add(msg_fee);
let amount = F::get_fee_factor(id).saturating_mul_int(fee_sum);
(A::get(), amount).into()
}
}
/// XCM sender for relay chain. It only sends downward message.
pub struct ChildTeyrchainRouter<T, W, P>(PhantomData<(T, W, P)>);
impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion, P> SendXcm
for ChildTeyrchainRouter<T, W, P>
where
P: PriceForMessageDelivery<Id = ParaId>,
{
type Ticket = (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>);
fn validate(
dest: &mut Option<Location>,
msg: &mut Option<Xcm<()>>,
) -> SendResult<(HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>)> {
let d = dest.take().ok_or(MissingArgument)?;
let id = if let (0, [Teyrchain(id)]) = d.unpack() {
*id
} else {
*dest = Some(d);
return Err(NotApplicable);
};
// Downward message passing.
let xcm = msg.take().ok_or(MissingArgument)?;
let config = configuration::ActiveConfig::<T>::get();
let para = id.into();
let price = P::price_for_delivery(para, &xcm);
let versioned_xcm = W::wrap_version(&d, xcm).map_err(|()| DestinationUnsupported)?;
versioned_xcm.check_is_decodable().map_err(|()| ExceedsMaxMessageSize)?;
let blob = versioned_xcm.encode();
dmp::Pallet::<T>::can_queue_downward_message(&config, &para, &blob)
.map_err(Into::<SendError>::into)?;
Ok(((config, para, blob), price))
}
fn deliver(
(config, para, blob): (HostConfiguration<BlockNumberFor<T>>, ParaId, Vec<u8>),
) -> Result<XcmHash, SendError> {
let hash = sp_io::hashing::blake2_256(&blob[..]);
dmp::Pallet::<T>::queue_downward_message(&config, para, blob)
.map(|()| hash)
.map_err(|error| {
log::debug!(
target: "xcm::xcm_sender::deliver",
"Failed to place into DMP queue: error: {error:?}, id: {hash:?}",
);
SendError::Transport(&"Error placing into DMP queue")
})
}
#[cfg(feature = "runtime-benchmarks")]
fn ensure_successful_delivery(location: Option<Location>) {
if let Some((0, [Teyrchain(id)])) = location.as_ref().map(|l| l.unpack()) {
dmp::Pallet::<T>::make_teyrchain_reachable(*id);
}
}
}
impl<T: dmp::Config, W, P> InspectMessageQueues for ChildTeyrchainRouter<T, W, P> {
fn clear_messages() {
// Best effort.
let _ = dmp::DownwardMessageQueues::<T>::clear(u32::MAX, None);
}
fn get_messages() -> Vec<(VersionedLocation, Vec<VersionedXcm<()>>)> {
dmp::DownwardMessageQueues::<T>::iter()
.map(|(para_id, messages)| {
let decoded_messages: Vec<VersionedXcm<()>> = messages
.iter()
.map(|downward_message| {
let message = VersionedXcm::<()>::decode_all_with_depth_limit(
MAX_XCM_DECODE_DEPTH,
&mut &downward_message.msg[..],
)
.unwrap();
log::trace!(
target: "xcm::DownwardMessageQueues::get_messages",
"Message: {:?}, sent at: {:?}", message, downward_message.sent_at
);
message
})
.collect();
(
VersionedLocation::from(Location::from(Teyrchain(para_id.into()))),
decoded_messages,
)
})
.collect()
}
}
/// Implementation of `xcm_builder::EnsureDelivery` which helps to ensure delivery to the
/// `ParaId` teyrchain (sibling or child). Deposits existential deposit for origin (if needed).
/// Deposits estimated fee to the origin account (if needed).
/// Allows to trigger additional logic for specific `ParaId` (e.g. open HRMP channel) (if needed).
#[cfg(feature = "runtime-benchmarks")]
pub struct ToTeyrchainDeliveryHelper<
XcmConfig,
ExistentialDeposit,
PriceForDelivery,
ParaId,
ToParaIdHelper,
>(
core::marker::PhantomData<(
XcmConfig,
ExistentialDeposit,
PriceForDelivery,
ParaId,
ToParaIdHelper,
)>,
);
#[cfg(feature = "runtime-benchmarks")]
impl<
XcmConfig: xcm_executor::Config,
ExistentialDeposit: Get<Option<Asset>>,
PriceForDelivery: PriceForMessageDelivery<Id = ParaId>,
Teyrchain: Get<ParaId>,
ToTeyrchainHelper: pezkuwi_runtime_teyrchains::EnsureForTeyrchain,
> xcm_builder::EnsureDelivery
for ToTeyrchainDeliveryHelper<
XcmConfig,
ExistentialDeposit,
PriceForDelivery,
Teyrchain,
ToTeyrchainHelper,
>
{
fn ensure_successful_delivery(
origin_ref: &Location,
dest: &Location,
fee_reason: xcm_executor::traits::FeeReason,
) -> (Option<xcm_executor::FeesMode>, Option<Assets>) {
use alloc::vec;
use xcm::{latest::MAX_ITEMS_IN_ASSETS, MAX_INSTRUCTIONS_TO_DECODE};
use xcm_executor::{
traits::{FeeManager, TransactAsset},
FeesMode,
};
// check if the destination matches the expected `Teyrchain`.
if let Some(Teyrchain(para_id)) = dest.first_interior() {
if ParaId::from(*para_id) != Teyrchain::get().into() {
return (None, None);
}
} else {
return (None, None);
}
// allow more initialization for target teyrchain
ToTeyrchainHelper::ensure(Teyrchain::get());
let mut fees_mode = None;
if !XcmConfig::FeeManager::is_waived(Some(origin_ref), fee_reason) {
// if not waived, we need to set up accounts for paying and receiving fees
// mint ED to origin if needed
if let Some(ed) = ExistentialDeposit::get() {
XcmConfig::AssetTransactor::deposit_asset(&ed, &origin_ref, None).unwrap();
}
// overestimate delivery fee
let mut max_assets: Vec<Asset> = Vec::new();
for i in 0..MAX_ITEMS_IN_ASSETS {
max_assets.push((GeneralIndex(i as u128), 100u128).into());
}
let overestimated_xcm =
vec![WithdrawAsset(max_assets.into()); MAX_INSTRUCTIONS_TO_DECODE as usize].into();
let overestimated_fees =
PriceForDelivery::price_for_delivery(Teyrchain::get(), &overestimated_xcm);
// mint overestimated fee to origin
for fee in overestimated_fees.inner() {
XcmConfig::AssetTransactor::deposit_asset(&fee, &origin_ref, None).unwrap();
}
// expected worst case - direct withdraw
fees_mode = Some(FeesMode { jit_withdraw: true });
}
(fees_mode, None)
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::integration_tests::new_test_ext;
use alloc::vec;
use frame_support::{assert_ok, parameter_types};
use pezkuwi_runtime_teyrchains::FeeTracker;
use sp_runtime::FixedU128;
use xcm::MAX_XCM_DECODE_DEPTH;
parameter_types! {
pub const BaseDeliveryFee: u128 = 300_000_000;
pub const TransactionByteFee: u128 = 1_000_000;
pub FeeAssetId: AssetId = AssetId(Here.into());
}
struct TestFeeTracker;
impl FeeTracker for TestFeeTracker {
type Id = ParaId;
fn get_fee_factor(_: Self::Id) -> FixedU128 {
FixedU128::from_rational(101, 100)
}
fn set_fee_factor(_id: Self::Id, _val: FixedU128) {}
fn increase_fee_factor(_: Self::Id, _: u128) {}
fn decrease_fee_factor(_: Self::Id) -> bool {
true
}
}
type TestExponentialPrice =
ExponentialPrice<FeeAssetId, BaseDeliveryFee, TransactionByteFee, TestFeeTracker>;
#[test]
fn exponential_price_correct_price_calculation() {
let id: ParaId = 123.into();
let b: u128 = BaseDeliveryFee::get();
let m: u128 = TransactionByteFee::get();
// F * (B + msg_length * M)
// message_length = 1
let result: u128 = TestFeeTracker::get_fee_factor(id).saturating_mul_int(b + m);
assert_eq!(
TestExponentialPrice::price_for_delivery(id, &Xcm(vec![])),
(FeeAssetId::get(), result).into()
);
// message size = 2
let result: u128 = TestFeeTracker::get_fee_factor(id).saturating_mul_int(b + (2 * m));
assert_eq!(
TestExponentialPrice::price_for_delivery(id, &Xcm(vec![ClearOrigin])),
(FeeAssetId::get(), result).into()
);
// message size = 4
let result: u128 = TestFeeTracker::get_fee_factor(id).saturating_mul_int(b + (4 * m));
assert_eq!(
TestExponentialPrice::price_for_delivery(
id,
&Xcm(vec![SetAppendix(Xcm(vec![ClearOrigin]))])
),
(FeeAssetId::get(), result).into()
);
}
#[test]
fn child_teyrchain_router_validate_nested_xcm_works() {
let dest = Teyrchain(5555);
type Router = ChildTeyrchainRouter<
crate::integration_tests::Test,
(),
NoPriceForMessageDelivery<ParaId>,
>;
// Message that is not too deeply nested:
let mut good = Xcm(vec![ClearOrigin]);
for _ in 0..MAX_XCM_DECODE_DEPTH - 1 {
good = Xcm(vec![SetAppendix(good)]);
}
new_test_ext().execute_with(|| {
configuration::ActiveConfig::<crate::integration_tests::Test>::mutate(|c| {
c.max_downward_message_size = u32::MAX;
});
dmp::Pallet::<crate::integration_tests::Test>::make_teyrchain_reachable(5555);
// Check that the good message is validated:
assert_ok!(<Router as SendXcm>::validate(
&mut Some(dest.into()),
&mut Some(good.clone())
));
// Nesting the message one more time should reject it:
let bad = Xcm(vec![SetAppendix(good)]);
assert_eq!(
Err(ExceedsMaxMessageSize),
<Router as SendXcm>::validate(&mut Some(dest.into()), &mut Some(bad))
);
});
}
}
+35
View File
@@ -0,0 +1,35 @@
[package]
name = "pezkuwi-runtime-metrics"
version = "7.0.0"
authors.workspace = true
edition.workspace = true
license.workspace = true
description = "Runtime metric interface for the Pezkuwi node"
homepage.workspace = true
repository.workspace = true
[lints]
workspace = true
[dependencies]
codec = { workspace = true }
frame-benchmarking = { optional = true, workspace = true }
pezkuwi-primitives = { workspace = true }
sp-tracing = { workspace = true }
bs58 = { features = ["alloc"], workspace = true }
[features]
default = ["std"]
std = [
"bs58/std",
"codec/std",
"frame-benchmarking?/std",
"pezkuwi-primitives/std",
"sp-tracing/std",
]
runtime-metrics = ["frame-benchmarking", "sp-tracing/with-tracing"]
runtime-benchmarks = [
"frame-benchmarking?/runtime-benchmarks",
"pezkuwi-primitives/runtime-benchmarks",
]
+35
View File
@@ -0,0 +1,35 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Runtime metric interface similar to native Prometheus metrics.
//!
//! This is intended to be used only for testing and debugging and **must never
//! be used in production**. It requires the Substrate wasm tracing support
//! and command line configuration: `--tracing-targets wasm_tracing=trace`.
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(feature = "runtime-metrics")]
mod with_runtime_metrics;
#[cfg(feature = "runtime-metrics")]
pub use crate::with_runtime_metrics::*;
#[cfg(not(feature = "runtime-metrics"))]
mod without_runtime_metrics;
#[cfg(not(feature = "runtime-metrics"))]
pub use crate::without_runtime_metrics::*;
@@ -0,0 +1,146 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! This module provides an implementation for the runtime metrics types: `Counter`,
//! `CounterVec` and `Histogram`. These types expose a Prometheus like interface and
//! same functionality. Each instance of a runtime metric is mapped to a Prometheus
//! metric on the client side. The runtime metrics must be registered with the registry
//! in the client, otherwise they will not be published.
const TRACING_TARGET: &'static str = "metrics";
use alloc::vec::Vec;
use codec::Encode;
use pezkuwi_primitives::{
metric_definitions::{CounterDefinition, CounterVecDefinition, HistogramDefinition},
RuntimeMetricLabelValues, RuntimeMetricOp, RuntimeMetricUpdate,
};
/// Holds a set of counters that have different values for their labels,
/// like Prometheus `CounterVec`.
pub struct CounterVec {
name: &'static str,
}
/// A counter metric.
pub struct Counter {
name: &'static str,
}
pub struct Histogram {
name: &'static str,
}
/// Convenience trait implemented for all metric types.
trait MetricEmitter {
fn emit(metric_op: &RuntimeMetricUpdate) {
sp_tracing::event!(
target: TRACING_TARGET,
sp_tracing::Level::TRACE,
update_op = bs58::encode(&metric_op.encode()).into_string().as_str()
);
}
}
///
pub struct LabeledMetric {
name: &'static str,
label_values: RuntimeMetricLabelValues,
}
impl LabeledMetric {
/// Increment the counter by `value`.
pub fn inc_by(&self, value: u64) {
let metric_update = RuntimeMetricUpdate {
metric_name: Vec::from(self.name),
op: RuntimeMetricOp::IncrementCounterVec(value, self.label_values.clone()),
};
Self::emit(&metric_update);
}
/// Increment the counter value.
pub fn inc(&self) {
self.inc_by(1);
}
}
impl MetricEmitter for LabeledMetric {}
impl MetricEmitter for Counter {}
impl MetricEmitter for Histogram {}
impl CounterVec {
/// Create a new counter as specified by `definition`. This metric needs to be registered
/// in the client before it can be used.
pub const fn new(definition: CounterVecDefinition) -> Self {
// No register op is emitted since the metric is supposed to be registered
// on the client by the time `inc()` is called.
CounterVec { name: definition.name }
}
/// Returns a `LabeledMetric` instance that provides an interface for incrementing
/// the metric.
pub fn with_label_values(&self, label_values: &[&'static str]) -> LabeledMetric {
LabeledMetric { name: self.name, label_values: label_values.into() }
}
}
impl Counter {
/// Create a new counter as specified by `definition`. This metric needs to be registered
/// in the client before it can be used.
pub const fn new(definition: CounterDefinition) -> Self {
Counter { name: definition.name }
}
/// Increment counter by `value`.
pub fn inc_by(&self, value: u64) {
let metric_update = RuntimeMetricUpdate {
metric_name: Vec::from(self.name),
op: RuntimeMetricOp::IncrementCounter(value),
};
Self::emit(&metric_update);
}
/// Increment counter.
pub fn inc(&self) {
self.inc_by(1);
}
}
impl Histogram {
/// Create a new histogram as specified by `definition`. This metric needs to be registered
/// in the client before it can be used.
pub const fn new(definition: HistogramDefinition) -> Self {
// No register op is emitted since the metric is supposed to be registered
// on the client by the time `inc()` is called.
Histogram { name: definition.name }
}
// Observe a value in the histogram
pub fn observe(&self, value: u128) {
let metric_update = RuntimeMetricUpdate {
metric_name: Vec::from(self.name),
op: RuntimeMetricOp::ObserveHistogram(value),
};
Self::emit(&metric_update);
}
}
/// Returns current time in ns
pub fn get_current_time() -> u128 {
frame_benchmarking::current_time()
}
@@ -0,0 +1,76 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Runtime metrics are usable from the wasm runtime only. The purpose of this module is to
//! provide a dummy implementation for the native runtime to avoid cluttering the runtime code
//! with `#[cfg(feature = "runtime-metrics")]`.
use pezkuwi_primitives::metric_definitions::{
CounterDefinition, CounterVecDefinition, HistogramDefinition,
};
/// A dummy `Counter`.
pub struct Counter;
/// A dummy `CounterVec`.
pub struct CounterVec;
/// A dummy `Histogram`
pub struct Histogram;
/// Dummy implementation.
impl CounterVec {
/// Constructor.
pub const fn new(_definition: CounterVecDefinition) -> Self {
CounterVec
}
/// Sets label values, implementation is a `no op`.
pub fn with_label_values(&self, _label_values: &[&'static str]) -> &Self {
self
}
/// Increment counter by value, implementation is a `no op`.
pub fn inc_by(&self, _: u64) {}
/// Increment counter, implementation is a `no op`.
pub fn inc(&self) {}
}
/// Dummy implementation.
impl Counter {
/// Constructor.
pub const fn new(_definition: CounterDefinition) -> Self {
Counter
}
/// Increment counter by value, implementation is a `no op`.
pub fn inc_by(&self, _: u64) {}
/// Increment counter, implementation is a `no op`.
pub fn inc(&self) {}
}
/// Dummy implementation
impl Histogram {
/// Create a new histogram as specified by `definition`. This metric needs to be registered
/// in the client before it can be used.
pub const fn new(_definition: HistogramDefinition) -> Self {
Histogram
}
// Observe a value in the histogram
pub fn observe(&self, _value: u128) {}
}
/// Dummy implementation - always 0
pub fn get_current_time() -> u128 {
0
}
+374
View File
@@ -0,0 +1,374 @@
[package]
name = "pezkuwichain-runtime"
build = "build.rs"
version = "7.0.0"
description = "Pezkuwichain testnet Relay Chain runtime."
authors.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
[lints]
workspace = true
[dependencies]
bitvec = { features = ["alloc"], workspace = true }
codec = { features = ["derive", "max-encoded-len"], workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
serde = { workspace = true }
serde_derive = { optional = true, workspace = true }
serde_json = { features = ["alloc"], workspace = true }
binary-merkle-tree = { workspace = true }
pezkuwichain-runtime-constants = { workspace = true }
sp-api = { workspace = true }
sp-arithmetic = { workspace = true }
sp-authority-discovery = { workspace = true }
sp-block-builder = { workspace = true }
sp-consensus-babe = { workspace = true }
sp-consensus-beefy = { workspace = true }
sp-consensus-grandpa = { workspace = true }
sp-core = { workspace = true }
sp-genesis-builder = { workspace = true }
sp-inherents = { workspace = true }
sp-io = { workspace = true }
sp-keyring = { workspace = true }
sp-mmr-primitives = { workspace = true }
sp-npos-elections = { workspace = true }
sp-offchain = { workspace = true }
sp-runtime = { workspace = true }
sp-session = { workspace = true }
sp-staking = { workspace = true }
sp-storage = { workspace = true }
sp-transaction-pool = { workspace = true }
sp-version = { workspace = true }
frame-election-provider-support = { workspace = true }
frame-executive = { workspace = true }
frame-support = { features = ["tuples-96"], workspace = true }
frame-system = { workspace = true }
frame-system-rpc-runtime-api = { workspace = true }
pallet-authority-discovery = { workspace = true }
pallet-authorship = { workspace = true }
pallet-babe = { workspace = true }
pallet-bags-list = { workspace = true }
pallet-balances = { workspace = true }
pallet-beefy = { workspace = true }
pallet-beefy-mmr = { workspace = true }
pallet-collective = { workspace = true }
pallet-conviction-voting = { workspace = true }
# pallet-democracy removed - pallet-welati implements custom governance
# pallet-election-provider-multi-phase removed - using OnChain election
# pallet-elections-phragmen removed - pallet-welati implements custom elections
pallet-fast-unstake = { workspace = true }
pallet-grandpa = { workspace = true }
pallet-indices = { workspace = true }
pallet-message-queue = { workspace = true }
pallet-migrations = { workspace = true }
pallet-mmr = { workspace = true }
pallet-multisig = { workspace = true }
pallet-nomination-pools = { workspace = true }
pallet-nomination-pools-runtime-api = { workspace = true }
pallet-offences = { workspace = true }
pallet-parameters = { workspace = true }
pallet-preimage = { workspace = true }
pallet-proxy = { workspace = true }
pallet-referenda = { workspace = true }
pallet-root-testing = { workspace = true }
pallet-scheduler = { workspace = true }
pallet-session = { workspace = true }
pallet-staking = { workspace = true }
pallet-staking-runtime-api = { workspace = true }
pallet-state-trie-migration = { workspace = true }
pallet-sudo = { workspace = true }
pallet-timestamp = { workspace = true }
# pallet-tips removed - not used in Pezkuwi governance model
pallet-transaction-payment = { workspace = true }
pallet-transaction-payment-rpc-runtime-api = { workspace = true }
pallet-treasury = { workspace = true }
pallet-utility = { workspace = true }
pallet-vesting = { workspace = true }
pallet-whitelist = { workspace = true }
pallet-xcm = { workspace = true }
pallet-xcm-benchmarks = { optional = true, workspace = true }
frame-benchmarking = { optional = true, workspace = true }
frame-metadata-hash-extension = { workspace = true }
frame-system-benchmarking = { optional = true, workspace = true }
frame-try-runtime = { optional = true, workspace = true }
hex-literal = { workspace = true, default-features = true }
pallet-election-provider-support-benchmarking = { optional = true, workspace = true }
pallet-nomination-pools-benchmarking = { optional = true, workspace = true }
pallet-offences-benchmarking = { optional = true, workspace = true }
pallet-session-benchmarking = { optional = true, workspace = true }
pezkuwi-primitives = { workspace = true }
pezkuwi-runtime-common = { workspace = true }
pezkuwi-runtime-teyrchains = { workspace = true }
pezkuwi-teyrchain-primitives = { workspace = true }
# Custom Pezkuwi Pallets
pallet-validator-pool = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
xcm-executor = { workspace = true }
xcm-runtime-apis = { workspace = true }
[dev-dependencies]
remote-externalities = { workspace = true, default-features = true }
serde_json = { workspace = true, default-features = true }
sp-keyring = { workspace = true, default-features = true }
sp-tracing = { workspace = true }
tokio = { features = ["macros"], workspace = true, default-features = true }
[build-dependencies]
substrate-wasm-builder = { optional = true, workspace = true, default-features = true }
[features]
default = ["std"]
no_std = []
std = [
"binary-merkle-tree/std",
"bitvec/std",
"codec/std",
"frame-benchmarking?/std",
"frame-election-provider-support/std",
"frame-executive/std",
"frame-metadata-hash-extension/std",
"frame-support/std",
"frame-system-benchmarking?/std",
"frame-system-rpc-runtime-api/std",
"frame-system/std",
"frame-try-runtime/std",
"log/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
"pallet-babe/std",
"pallet-bags-list/std",
"pallet-balances/std",
"pallet-beefy-mmr/std",
"pallet-beefy/std",
"pallet-collective/std",
"pallet-conviction-voting/std",
"pallet-election-provider-support-benchmarking?/std",
"pallet-fast-unstake/std",
"pallet-grandpa/std",
"pallet-indices/std",
"pallet-message-queue/std",
"pallet-migrations/std",
"pallet-mmr/std",
"pallet-multisig/std",
"pallet-nomination-pools-benchmarking?/std",
"pallet-nomination-pools-runtime-api/std",
"pallet-nomination-pools/std",
"pallet-offences-benchmarking?/std",
"pallet-offences/std",
"pallet-parameters/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-referenda/std",
"pallet-root-testing/std",
"pallet-scheduler/std",
"pallet-session-benchmarking?/std",
"pallet-session/std",
"pallet-staking-runtime-api/std",
"pallet-staking/std",
"pallet-state-trie-migration/std",
"pallet-sudo/std",
"pallet-timestamp/std",
"pallet-transaction-payment-rpc-runtime-api/std",
"pallet-transaction-payment/std",
"pallet-treasury/std",
"pallet-utility/std",
"pallet-validator-pool/std",
"pallet-vesting/std",
"pallet-whitelist/std",
"pallet-xcm-benchmarks?/std",
"pallet-xcm/std",
"pezkuwi-primitives/std",
"pezkuwi-runtime-common/std",
"pezkuwi-runtime-teyrchains/std",
"pezkuwi-teyrchain-primitives/std",
"pezkuwichain-runtime-constants/std",
"scale-info/std",
"serde/std",
"serde_derive",
"serde_json/std",
"sp-api/std",
"sp-arithmetic/std",
"sp-authority-discovery/std",
"sp-block-builder/std",
"sp-consensus-babe/std",
"sp-consensus-beefy/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-genesis-builder/std",
"sp-inherents/std",
"sp-io/std",
"sp-mmr-primitives/std",
"sp-npos-elections/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
"sp-staking/std",
"sp-storage/std",
"sp-tracing/std",
"sp-transaction-pool/std",
"sp-version/std",
"substrate-wasm-builder",
"xcm-builder/std",
"xcm-executor/std",
"xcm-runtime-apis/std",
"xcm/std",
]
runtime-benchmarks = [
"binary-merkle-tree/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-election-provider-support/runtime-benchmarks",
"frame-executive/runtime-benchmarks",
"frame-metadata-hash-extension/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system-benchmarking/runtime-benchmarks",
"frame-system-rpc-runtime-api/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"frame-try-runtime?/runtime-benchmarks",
"pallet-authority-discovery/runtime-benchmarks",
"pallet-authorship/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-bags-list/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-beefy-mmr/runtime-benchmarks",
"pallet-beefy/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-election-provider-support-benchmarking/runtime-benchmarks",
"pallet-fast-unstake/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-indices/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"pallet-migrations/runtime-benchmarks",
"pallet-mmr/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-nomination-pools-benchmarking/runtime-benchmarks",
"pallet-nomination-pools-runtime-api/runtime-benchmarks",
"pallet-nomination-pools/runtime-benchmarks",
"pallet-offences-benchmarking/runtime-benchmarks",
"pallet-offences/runtime-benchmarks",
"pallet-parameters/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-proxy/runtime-benchmarks",
"pallet-referenda/runtime-benchmarks",
"pallet-root-testing/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-session-benchmarking/runtime-benchmarks",
"pallet-session/runtime-benchmarks",
"pallet-staking-runtime-api/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-state-trie-migration/runtime-benchmarks",
"pallet-sudo/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-transaction-payment-rpc-runtime-api/runtime-benchmarks",
"pallet-transaction-payment/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
"pallet-utility/runtime-benchmarks",
"pallet-validator-pool/runtime-benchmarks",
"pallet-vesting/runtime-benchmarks",
"pallet-whitelist/runtime-benchmarks",
"pallet-xcm-benchmarks/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pezkuwi-primitives/runtime-benchmarks",
"pezkuwi-runtime-common/runtime-benchmarks",
"pezkuwi-runtime-teyrchains/runtime-benchmarks",
"pezkuwi-teyrchain-primitives/runtime-benchmarks",
"pezkuwichain-runtime-constants/runtime-benchmarks",
"remote-externalities/runtime-benchmarks",
"sp-api/runtime-benchmarks",
"sp-authority-discovery/runtime-benchmarks",
"sp-block-builder/runtime-benchmarks",
"sp-consensus-babe/runtime-benchmarks",
"sp-consensus-beefy/runtime-benchmarks",
"sp-consensus-grandpa/runtime-benchmarks",
"sp-genesis-builder/runtime-benchmarks",
"sp-inherents/runtime-benchmarks",
"sp-io/runtime-benchmarks",
"sp-keyring/runtime-benchmarks",
"sp-mmr-primitives/runtime-benchmarks",
"sp-npos-elections/runtime-benchmarks",
"sp-offchain/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"sp-session/runtime-benchmarks",
"sp-staking/runtime-benchmarks",
"sp-transaction-pool/runtime-benchmarks",
"sp-version/runtime-benchmarks",
"substrate-wasm-builder?/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"xcm-runtime-apis/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
try-runtime = [
"frame-election-provider-support/try-runtime",
"frame-executive/try-runtime",
"frame-support/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime",
"frame-try-runtime/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
"pallet-babe/try-runtime",
"pallet-bags-list/try-runtime",
"pallet-balances/try-runtime",
"pallet-beefy-mmr/try-runtime",
"pallet-beefy/try-runtime",
"pallet-collective/try-runtime",
"pallet-conviction-voting/try-runtime",
"pallet-fast-unstake/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-indices/try-runtime",
"pallet-message-queue/try-runtime",
"pallet-migrations/try-runtime",
"pallet-mmr/try-runtime",
"pallet-multisig/try-runtime",
"pallet-nomination-pools/try-runtime",
"pallet-offences/try-runtime",
"pallet-parameters/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-referenda/try-runtime",
"pallet-root-testing/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
"pallet-staking/try-runtime",
"pallet-state-trie-migration/try-runtime",
"pallet-sudo/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-treasury/try-runtime",
"pallet-utility/try-runtime",
"pallet-validator-pool/try-runtime",
"pallet-vesting/try-runtime",
"pallet-whitelist/try-runtime",
"pallet-xcm/try-runtime",
"pezkuwi-runtime-common/try-runtime",
"pezkuwi-runtime-teyrchains/try-runtime",
"sp-runtime/try-runtime",
]
# Enable the metadata hash generation in the wasm builder.
metadata-hash = ["substrate-wasm-builder/metadata-hash"]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = ["pezkuwichain-runtime-constants/fast-runtime"]
runtime-metrics = [
"pezkuwi-runtime-teyrchains/runtime-metrics",
"sp-io/with-tracing",
]
# A feature that should be enabled when the runtime should be built for on-chain
# deployment. This will disable stuff that shouldn't be part of the on-chain wasm
# to make it smaller, like logging for example.
on-chain-release-build = ["metadata-hash"]
+20
View File
@@ -0,0 +1,20 @@
# pezkuwichain: v2.1
pezkuwichain is a testnet runtime with no stability guarantees.
## How to build `pezkuwichain` runtime
`EpochDurationInBlocks` parameter is configurable via `pezkuwichain_EPOCH_DURATION` environment variable. To build wasm
runtime blob with customized epoch duration the following command shall be executed:
```bash
pezkuwichain_EPOCH_DURATION=10 ./pezkuwi/scripts/build-only-wasm.sh pezkuwichain-runtime /path/to/output/directory/
```
## How to run `pezkuwichain-local`
The [Cumulus Tutorial](https://docs.pezkuwichain.io/tutorials/v3/cumulus/start-relay/) details building, starting, and
testing `pezkuwichain-local` and teyrchains connecting to it.
## How to register a teyrchain on the pezkuwichain testnet
The [teyrchain registration process](https://docs.pezkuwichain.io/tutorials/v3/cumulus/pezkuwichain/) on the public pezkuwichain
testnet is also outlined.
@@ -0,0 +1,43 @@
[package]
name = "bp-pezkuwichain"
description = "Primitives of Pezkuwichain runtime."
version = "0.6.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
repository.workspace = true
[package.metadata.pezkuwi-sdk]
exclude-from-umbrella = true
[lints]
workspace = true
[dependencies]
# Bridge Dependencies
bp-header-chain = { workspace = true }
bp-pezkuwi-core = { workspace = true }
bp-runtime = { workspace = true }
# Substrate Based Dependencies
frame-support = { workspace = true }
sp-api = { workspace = true }
sp-std = { workspace = true }
[features]
default = ["std"]
std = [
"bp-header-chain/std",
"bp-pezkuwi-core/std",
"bp-runtime/std",
"frame-support/std",
"sp-api/std",
"sp-std/std",
]
runtime-benchmarks = [
"bp-header-chain/runtime-benchmarks",
"bp-pezkuwi-core/runtime-benchmarks",
"bp-runtime/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"sp-api/runtime-benchmarks",
]
@@ -0,0 +1,81 @@
// 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.
//! Bridge-related primitives of the Pezkuwichain chain.
#![warn(missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
pub use bp_pezkuwi_core::*;
use bp_header_chain::ChainWithGrandpa;
use bp_runtime::{decl_bridge_finality_runtime_apis, Chain, ChainId};
use frame_support::{sp_runtime::StateVersion, weights::Weight};
/// Pezkuwichain Chain
pub struct Pezkuwichain;
impl Chain for Pezkuwichain {
const ID: ChainId = *b"roco";
type BlockNumber = BlockNumber;
type Hash = Hash;
type Hasher = Hasher;
type Header = Header;
type AccountId = AccountId;
type Balance = Balance;
type Nonce = Nonce;
type Signature = Signature;
const STATE_VERSION: StateVersion = StateVersion::V1;
fn max_extrinsic_size() -> u32 {
max_extrinsic_size()
}
fn max_extrinsic_weight() -> Weight {
max_extrinsic_weight()
}
}
impl ChainWithGrandpa for Pezkuwichain {
const WITH_CHAIN_GRANDPA_PALLET_NAME: &'static str = WITH_PEZKUWICHAIN_GRANDPA_PALLET_NAME;
const MAX_AUTHORITIES_COUNT: u32 = MAX_AUTHORITIES_COUNT;
const REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY: u32 =
REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY;
const MAX_MANDATORY_HEADER_SIZE: u32 = MAX_MANDATORY_HEADER_SIZE;
const AVERAGE_HEADER_SIZE: u32 = AVERAGE_HEADER_SIZE;
}
// The TransactionExtension used by Pezkuwichain.
pub use bp_pezkuwi_core::CommonTransactionExtension as TransactionExtension;
/// Name of the teyrchains pallet in the Pezkuwichain runtime.
pub const PARAS_PALLET_NAME: &str = "Paras";
/// Name of the With-Pezkuwichain GRANDPA pallet instance that is deployed at bridged chains.
pub const WITH_PEZKUWICHAIN_GRANDPA_PALLET_NAME: &str = "BridgePezkuwichainGrandpa";
/// Name of the With-Pezkuwichain teyrchains pallet instance that is deployed at bridged chains.
pub const WITH_PEZKUWICHAIN_BRIDGE_TEYRCHAINS_PALLET_NAME: &str = "BridgePezkuwichainTeyrchains";
/// Maximal size of encoded `bp_teyrchains::ParaStoredHeaderData` structure among all Pezkuwichain
/// teyrchains.
///
/// It includes the block number and state root, so it shall be near 40 bytes, but let's have some
/// reserve.
pub const MAX_NESTED_TEYRCHAIN_HEAD_DATA_SIZE: u32 = 128;
decl_bridge_finality_runtime_apis!(pezkuwichain, grandpa);
+41
View File
@@ -0,0 +1,41 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
#[cfg(all(not(feature = "metadata-hash"), feature = "std"))]
fn main() {
substrate_wasm_builder::WasmBuilder::build_using_defaults();
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.set_file_name("fast_runtime_binary.rs")
.enable_feature("fast-runtime")
.build();
}
#[cfg(all(feature = "metadata-hash", feature = "std"))]
fn main() {
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.enable_metadata_hash("TYR", 12)
.build();
substrate_wasm_builder::WasmBuilder::init_with_defaults()
.set_file_name("fast_runtime_binary.rs")
.enable_feature("fast-runtime")
.enable_metadata_hash("TYR", 12)
.build();
}
#[cfg(not(feature = "std"))]
fn main() {}
@@ -0,0 +1,52 @@
[package]
name = "pezkuwichain-runtime-constants"
version = "7.0.0"
description = "Constants used throughout the Pezkuwichain network."
authors.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true
[package.metadata.pezkuwi-sdk]
exclude-from-umbrella = true
[lints]
workspace = true
[dependencies]
smallvec = { workspace = true, default-features = true }
frame-support = { workspace = true }
pezkuwi-primitives = { workspace = true }
pezkuwi-runtime-common = { workspace = true }
sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-weights = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
[features]
default = ["std"]
std = [
"frame-support/std",
"pezkuwi-primitives/std",
"pezkuwi-runtime-common/std",
"sp-core/std",
"sp-runtime/std",
"sp-weights/std",
"xcm-builder/std",
"xcm/std",
]
# Set timing constants (e.g. session period) to faster versions to speed up testing.
fast-runtime = []
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"pezkuwi-primitives/runtime-benchmarks",
"pezkuwi-runtime-common/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"xcm/runtime-benchmarks",
]
@@ -0,0 +1,175 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
#![cfg_attr(not(feature = "std"), no_std)]
pub mod weights;
/// Money matters.
pub mod currency {
use pezkuwi_primitives::Balance;
/// The existential deposit.
pub const EXISTENTIAL_DEPOSIT: Balance = 1 * CENTS;
pub const UNITS: Balance = 1_000_000_000_000;
pub const CENTS: Balance = UNITS / 30_000;
pub const GRAND: Balance = CENTS * 100_000;
pub const MILLICENTS: Balance = CENTS / 1_000;
pub const fn deposit(items: u32, bytes: u32) -> Balance {
items as Balance * 2_000 * CENTS + (bytes as Balance) * 100 * MILLICENTS
}
}
/// Time and blocks.
pub mod time {
use pezkuwi_runtime_common::prod_or_fast;
use pezkuwi_primitives::{BlockNumber, Moment};
pub const MILLISECS_PER_BLOCK: Moment = 6000;
pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK;
frame_support::parameter_types! {
pub EpochDurationInBlocks: BlockNumber =
prod_or_fast!(1 * HOURS, 1 * MINUTES, "PEZKUWICHAIN_EPOCH_DURATION");
}
// These time units are defined in number of blocks.
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
pub const WEEKS: BlockNumber = DAYS * 7;
// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
// The choice of is done in accordance to the slot duration and expected target
// block time, for safely resisting network delays of maximum two seconds.
// <https://research.web3.foundation/Polkadot/protocols/block-production/Babe#6-practical-results>
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
}
/// Fee-related.
pub mod fee {
use crate::weights::ExtrinsicBaseWeight;
use frame_support::weights::{
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
};
use pezkuwi_primitives::Balance;
use smallvec::smallvec;
pub use sp_runtime::Perbill;
/// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the
/// node's balance type.
///
/// This should typically create a mapping between the following ranges:
/// - [0, `frame_system::MaximumBlockWeight`]
/// - [Balance::min, Balance::max]
///
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being:
/// - Setting it to `0` will essentially disable the weight fee.
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged.
pub struct WeightToFee;
impl WeightToFeePolynomial for WeightToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// in Pezkuwichain, extrinsic base weight (smallest non-zero weight) is mapped to 1/10
// CENT:
let p = super::currency::CENTS;
let q = 10 * Balance::from(ExtrinsicBaseWeight::get().ref_time());
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}
}
/// System Teyrchains.
pub mod system_teyrchain {
use frame_support::parameter_types;
use pezkuwi_primitives::Id as ParaId;
use xcm_builder::IsChildSystemTeyrchain;
parameter_types! {
pub AssetHubParaId: ParaId = ASSET_HUB_ID.into();
pub PeopleParaId: ParaId = PEOPLE_ID.into();
}
/// Network's Asset Hub teyrchain ID.
pub const ASSET_HUB_ID: u32 = 1000;
/// Contracts teyrchain ID.
pub const CONTRACTS_ID: u32 = 1002;
/// Encointer teyrchain ID.
pub const ENCOINTER_ID: u32 = 1003;
/// People teyrchain ID.
pub const PEOPLE_ID: u32 = 1004;
/// BridgeHub teyrchain ID.
pub const BRIDGE_HUB_ID: u32 = 1002;
/// Brokerage teyrchain ID.
pub const BROKER_ID: u32 = 1005;
/// All system teyrchains of Pezkuwichain.
pub type SystemTeyrchains = IsChildSystemTeyrchain<ParaId>;
/// Coretime constants
pub mod coretime {
/// Coretime timeslice period in blocks
/// WARNING: This constant is used accross chains, so additional care should be taken
/// when changing it.
#[cfg(feature = "fast-runtime")]
pub const TIMESLICE_PERIOD: u32 = 20;
#[cfg(not(feature = "fast-runtime"))]
pub const TIMESLICE_PERIOD: u32 = 80;
}
}
/// Pezkuwichain Treasury pallet instance.
pub const TREASURY_PALLET_ID: u8 = 18;
#[cfg(test)]
mod tests {
use super::{
currency::{CENTS, MILLICENTS},
fee::WeightToFee,
};
use crate::weights::ExtrinsicBaseWeight;
use frame_support::weights::WeightToFee as WeightToFeeT;
use pezkuwi_runtime_common::MAXIMUM_BLOCK_WEIGHT;
#[test]
// Test that the fee for `MAXIMUM_BLOCK_WEIGHT` of weight has sane bounds.
fn full_block_fee_is_correct() {
// A full block should cost between 1,000 and 10,000 CENTS.
let full_block = WeightToFee::weight_to_fee(&MAXIMUM_BLOCK_WEIGHT);
assert!(full_block >= 1_000 * CENTS);
assert!(full_block <= 10_000 * CENTS);
}
#[test]
// This function tests that the fee for `ExtrinsicBaseWeight` of weight is correct
fn extrinsic_base_fee_is_correct() {
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
println!("Base: {}", ExtrinsicBaseWeight::get());
let x = WeightToFee::weight_to_fee(&ExtrinsicBaseWeight::get());
let y = CENTS / 10;
assert!(x.max(y) - x.min(y) < MILLICENTS);
}
}
@@ -0,0 +1,80 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-29 (Y/M/D)
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//!
//! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Development`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `./pezkuwi/runtime/pezkuwichain/constants/src/weights/`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/production/pezkuwi
// benchmark
// overhead
// --chain=pezkuwichain-dev
// --wasm-execution=compiled
// --weight-path=./pezkuwi/runtime/pezkuwichain/constants/src/weights/
// --warmup=10
// --repeat=100
// --header=./pezkuwi/file_header.txt
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Time to execute an empty block.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 440_142, 476_907
/// Average: 450_240
/// Median: 448_633
/// Std-Dev: 7301.18
///
/// Percentiles nanoseconds:
/// 99th: 470_733
/// 95th: 465_082
/// 75th: 452_536
pub const BlockExecutionWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(450_240), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::BlockExecutionWeight::get();
// At least 100 µs.
assert!(
w.ref_time() >= 100u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 100 µs."
);
// At most 50 ms.
assert!(
w.ref_time() <= 50u64 * constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 50 ms."
);
}
}
@@ -0,0 +1,80 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-29 (Y/M/D)
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//!
//! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Development`
//! WARMUPS: `10`, REPEAT: `100`
//! WEIGHT-PATH: `./pezkuwi/runtime/pezkuwichain/constants/src/weights/`
//! WEIGHT-METRIC: `Average`, WEIGHT-MUL: `1.0`, WEIGHT-ADD: `0`
// Executed Command:
// ./target/production/pezkuwi
// benchmark
// overhead
// --chain=pezkuwichain-dev
// --wasm-execution=compiled
// --weight-path=./pezkuwi/runtime/pezkuwichain/constants/src/weights/
// --warmup=10
// --repeat=100
// --header=./pezkuwi/file_header.txt
use sp_core::parameter_types;
use sp_weights::{constants::WEIGHT_REF_TIME_PER_NANOS, Weight};
parameter_types! {
/// Time to execute a NO-OP extrinsic, for example `System::remark`.
/// Calculated by multiplying the *Average* with `1.0` and adding `0`.
///
/// Stats nanoseconds:
/// Min, Max: 92_961, 94_143
/// Average: 93_369
/// Median: 93_331
/// Std-Dev: 217.39
///
/// Percentiles nanoseconds:
/// 99th: 93_848
/// 95th: 93_691
/// 75th: 93_514
pub const ExtrinsicBaseWeight: Weight =
Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(93_369), 0);
}
#[cfg(test)]
mod test_weights {
use sp_weights::constants;
/// Checks that the weight exists and is sane.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
let w = super::ExtrinsicBaseWeight::get();
// At least 10 µs.
assert!(
w.ref_time() >= 10u64 * constants::WEIGHT_REF_TIME_PER_MICROS,
"Weight should be at least 10 µs."
);
// At most 1 ms.
assert!(
w.ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Weight should be at most 1 ms."
);
}
}
@@ -0,0 +1,28 @@
// This file is part of Pezkuwi.
// 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.
//! Expose the auto generated weight files.
pub mod block_weights;
pub mod extrinsic_weights;
pub mod paritydb_weights;
pub mod rocksdb_weights;
pub use block_weights::BlockExecutionWeight;
pub use extrinsic_weights::ExtrinsicBaseWeight;
pub use paritydb_weights::constants::ParityDbWeight;
pub use rocksdb_weights::constants::RocksDbWeight;
@@ -0,0 +1,63 @@
// This file is part of Pezkuwi.
// 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.
pub mod constants {
use frame_support::{
parameter_types,
weights::{constants, RuntimeDbWeight},
};
parameter_types! {
/// `ParityDB` can be enabled with a feature flag, but is still experimental. These weights
/// are available for brave runtime engineers who may want to try this out as default.
pub const ParityDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 8_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
write: 50_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
};
}
#[cfg(test)]
mod test_db_weights {
use super::constants::ParityDbWeight as W;
use frame_support::weights::constants;
/// Checks that all weights exist and have sane values.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
// At least 1 µs.
assert!(
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Read weight should be at least 1 µs."
);
assert!(
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Write weight should be at least 1 µs."
);
// At most 1 ms.
assert!(
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Read weight should be at most 1 ms."
);
assert!(
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Write weight should be at most 1 ms."
);
}
}
}
@@ -0,0 +1,63 @@
// This file is part of Pezkuwi.
// 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.
pub mod constants {
use frame_support::{
parameter_types,
weights::{constants, RuntimeDbWeight},
};
parameter_types! {
/// By default, Substrate uses `RocksDB`, so this will be the weight used throughout
/// the runtime.
pub const RocksDbWeight: RuntimeDbWeight = RuntimeDbWeight {
read: 25_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
write: 100_000 * constants::WEIGHT_REF_TIME_PER_NANOS,
};
}
#[cfg(test)]
mod test_db_weights {
use super::constants::RocksDbWeight as W;
use frame_support::weights::constants;
/// Checks that all weights exist and have sane values.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
#[test]
fn sane() {
// At least 1 µs.
assert!(
W::get().reads(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Read weight should be at least 1 µs."
);
assert!(
W::get().writes(1).ref_time() >= constants::WEIGHT_REF_TIME_PER_MICROS,
"Write weight should be at least 1 µs."
);
// At most 1 ms.
assert!(
W::get().reads(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Read weight should be at most 1 ms."
);
assert!(
W::get().writes(1).ref_time() <= constants::WEIGHT_REF_TIME_PER_MILLIS,
"Write weight should be at most 1 ms."
);
}
}
}
@@ -0,0 +1,233 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated voter bag thresholds.
//!
//! Generated for the PezkuwiChain runtime.
/// Existential weight for this runtime.
#[cfg(any(test, feature = "std"))]
#[allow(unused)]
pub const EXISTENTIAL_WEIGHT: u64 = 10_000_000_000;
/// Constant ratio between bags for this runtime.
#[cfg(any(test, feature = "std"))]
#[allow(unused)]
pub const CONSTANT_RATIO: f64 = 1.1131723507077667;
/// Upper thresholds delimiting the bag list.
pub const THRESHOLDS: [u64; 200] = [
10_000_000_000,
11_131_723_507,
12_391_526_824,
13_793_905_044,
15_354_993_703,
17_092_754_435,
19_027_181_634,
21_180_532_507,
23_577_583_160,
26_245_913_670,
29_216_225_417,
32_522_694_326,
36_203_364_094,
40_300_583_912,
44_861_495_728,
49_938_576_656,
55_590_242_767,
61_881_521_217,
68_884_798_439,
76_680_653_006,
85_358_782_760,
95_019_036_859,
105_772_564_622,
117_743_094_401,
131_068_357_174,
145_901_671_259,
162_413_706_368,
180_794_447_305,
201_255_379_901,
224_031_924_337,
249_386_143_848,
277_609_759_981,
309_027_509_097,
344_000_878_735,
382_932_266_827,
426_269_611_626,
474_511_545_609,
528_213_132_664,
587_992_254_562,
654_536_720_209,
728_612_179_460,
811_070_932_564,
902_861_736_593,
1_005_040_721_687,
1_118_783_542_717,
1_245_398_906_179,
1_386_343_627_960,
1_543_239_395_225,
1_717_891_425_287,
1_912_309_236_147,
2_128_729_767_682,
2_369_643_119_512,
2_637_821_201_686,
2_936_349_627_828,
3_268_663_217_709,
3_638_585_517_729,
4_050_372_794_022,
4_508_763_004_364,
5_019_030_312_352,
5_587_045_771_074,
6_219_344_874_498,
6_923_202_753_807,
7_706_717_883_882,
8_578_905_263_043,
9_549_800_138_161,
10_630_573_468_586,
11_833_660_457_397,
13_172_903_628_838,
14_663_712_098_160,
16_323_238_866_411,
18_170_578_180_087,
20_226_985_226_447,
22_516_120_692_255,
25_064_322_999_817,
27_900_911_352_605,
31_058_523_077_268,
34_573_489_143_434,
38_486_252_181_966,
42_841_831_811_331,
47_690_342_626_046,
53_087_570_807_094,
59_095_615_988_698,
65_783_605_766_662,
73_228_491_069_308,
81_515_931_542_404,
90_741_281_135_191,
101_010_685_227_495,
112_442_301_921_293,
125_167_661_548_718,
139_333_180_038_781,
155_101_843_555_358,
172_655_083_789_626,
192_194_865_483_744,
213_946_010_204_502,
238_158_783_103_893,
265_111_772_429_462,
295_115_094_915_607,
328_513_963_936_552,
365_692_661_475_578,
407_078_959_611_349,
453_149_042_394_237,
504_432_984_742_966,
561_520_851_400_862,
625_069_486_125_324,
695_810_069_225_823,
774_556_530_406_243,
862_214_913_708_369,
959_793_802_308_039,
1_068_415_923_109_985,
1_189_331_064_661_951,
1_323_930_457_019_515,
1_473_762_779_014_021,
1_640_551_977_100_649,
1_826_217_100_807_404,
2_032_894_383_008_501,
2_262_961_819_074_188,
2_519_066_527_700_738,
2_804_155_208_229_882,
3_121_508_044_894_685,
3_474_776_448_088_622,
3_868_025_066_902_796,
4_305_778_556_320_752,
4_793_073_637_166_665,
5_335_517_047_800_242,
5_939_350_054_341_159,
6_611_520_261_667_250,
7_359_761_551_432_161,
8_192_683_066_856_378,
9_119_868_268_136_230,
10_151_985_198_186_376,
11_300_909_227_415_580,
12_579_859_689_817_292,
14_003_551_982_487_792,
15_588_366_878_604_342,
17_352_539_001_951_086,
19_316_366_631_550_092,
21_502_445_250_375_680,
23_935_927_525_325_748,
26_644_812_709_737_600,
29_660_268_798_266_784,
33_016_991_140_790_860,
36_753_601_641_491_664,
40_913_093_136_236_104,
45_543_324_061_189_736,
50_697_569_104_240_168,
56_435_132_174_936_472,
62_822_028_745_677_552,
69_931_745_415_056_768,
77_846_085_432_775_824,
86_656_109_914_600_688,
96_463_185_576_826_656,
107_380_151_045_315_664,
119_532_615_158_469_088,
133_060_402_202_199_856,
148_119_160_705_543_712,
164_882_154_307_451_552,
183_542_255_300_186_560,
204_314_163_786_713_728,
227_436_877_985_347_776,
253_176_444_104_585_088,
281_829_017_427_734_464,
313_724_269_827_691_328,
349_229_182_918_168_832,
388_752_270_484_770_624,
432_748_278_778_513_664,
481_723_418_752_617_984,
536_241_190_443_833_600,
596_928_866_512_693_376,
664_484_709_541_257_600,
739_686_006_129_409_280,
823_398_010_228_713_984,
916_583_898_614_395_264,
1_020_315_853_041_475_584,
1_135_787_396_594_579_584,
1_264_327_126_171_442_688,
1_407_413_999_103_859_968,
1_566_694_349_801_462_272,
1_744_000_832_209_069_824,
1_941_373_506_026_471_680,
2_161_083_309_305_266_176,
2_405_658_187_494_662_656,
2_677_912_179_572_818_944,
2_980_977_795_924_034_048,
3_318_342_060_496_414_208,
3_693_886_631_935_247_360,
4_111_932_465_319_354_368,
4_577_289_528_371_127_808,
5_095_312_144_166_932_480,
5_671_960_597_112_134_656,
6_313_869_711_009_142_784,
7_028_425_188_266_614_784,
7_823_848_588_596_424_704,
8_709_291_924_949_524_480,
9_694_942_965_096_232_960,
10_792_142_450_433_898_496,
12_013_514_580_722_579_456,
13_373_112_266_084_982_784,
14_886_578_817_516_689_408,
16_571_327_936_291_497_984,
18_446_744_073_709_551_615,
];
@@ -0,0 +1,733 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Genesis configs presets for the Pezkuwichain runtime
//!
//! This module contains genesis configuration for:
//! - HEZ token initial distribution (200M genesis supply)
//! - Validator session keys
//! - Initial balance distributions
//!
//! ## HEZ Genesis Distribution (200M Total)
//! - 10% Founder: 20,000,000 HEZ
//! - 50% Presale: 100,000,000 HEZ
//! - 20% Kurdistan Treasury: 40,000,000 HEZ
//! - 20% Airdrop: 40,000,000 HEZ
use crate::{
BabeConfig, BalancesConfig, ConfigurationConfig, RegistrarConfig, RuntimeGenesisConfig,
SessionConfig, SessionKeys, SudoConfig, BABE_GENESIS_EPOCH_CONFIG,
};
#[cfg(not(feature = "std"))]
use alloc::format;
use alloc::{vec, vec::Vec};
use frame_support::build_struct_json_patch;
use pezkuwi_primitives::{AccountId, AssignmentId, SchedulerParams, ValidatorId};
use pezkuwichain_runtime_constants::currency::UNITS as TYR;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{crypto::get_public_from_string_or_panic, sr25519};
use sp_genesis_builder::PresetId;
use sp_keyring::Sr25519Keyring;
// ============================================================================
// HEZ TOKEN GENESIS CONSTANTS
// ============================================================================
/// Total HEZ genesis supply: 200 Million
pub const HEZ_GENESIS_SUPPLY: u128 = 200_000_000 * TYR;
/// Founder allocation: 10% = 20,000,000 HEZ
pub const HEZ_FOUNDER_ALLOCATION: u128 = 20_000_000 * TYR;
/// Presale allocation: 50% = 100,000,000 HEZ
pub const HEZ_PRESALE_ALLOCATION: u128 = 100_000_000 * TYR;
/// Kurdistan Treasury allocation: 20% = 40,000,000 HEZ
pub const HEZ_TREASURY_ALLOCATION: u128 = 40_000_000 * TYR;
/// Airdrop allocation: 20% = 40,000,000 HEZ
pub const HEZ_AIRDROP_ALLOCATION: u128 = 40_000_000 * TYR;
// ===========================================================================
// COMPILE-TIME VALIDATION: Ensure allocation integrity
// ===========================================================================
const _: () = assert!(
HEZ_FOUNDER_ALLOCATION +
HEZ_PRESALE_ALLOCATION +
HEZ_TREASURY_ALLOCATION +
HEZ_AIRDROP_ALLOCATION ==
HEZ_GENESIS_SUPPLY,
"HEZ allocations MUST sum to genesis supply (200M)"
);
/// Helper function to generate stash, controller and session key from seed
fn get_authority_keys_from_seed(
seed: &str,
) -> (
AccountId,
AccountId,
BabeId,
GrandpaId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
) {
let keys = get_authority_keys_from_seed_no_beefy(seed);
(
keys.0,
keys.1,
keys.2,
keys.3,
keys.4,
keys.5,
keys.6,
get_public_from_string_or_panic::<BeefyId>(seed),
)
}
/// Helper function to generate stash, controller and session key from seed
fn get_authority_keys_from_seed_no_beefy(
seed: &str,
) -> (AccountId, AccountId, BabeId, GrandpaId, ValidatorId, AssignmentId, AuthorityDiscoveryId) {
(
get_public_from_string_or_panic::<sr25519::Public>(&format!("{}//stash", seed)).into(),
get_public_from_string_or_panic::<sr25519::Public>(seed).into(),
get_public_from_string_or_panic::<BabeId>(seed),
get_public_from_string_or_panic::<GrandpaId>(seed),
get_public_from_string_or_panic::<ValidatorId>(seed),
get_public_from_string_or_panic::<AssignmentId>(seed),
get_public_from_string_or_panic::<AuthorityDiscoveryId>(seed),
)
}
fn testnet_accounts() -> Vec<AccountId> {
Sr25519Keyring::well_known().map(|x| x.to_account_id()).collect()
}
fn pezkuwichain_session_keys(
babe: BabeId,
grandpa: GrandpaId,
para_validator: ValidatorId,
para_assignment: AssignmentId,
authority_discovery: AuthorityDiscoveryId,
beefy: BeefyId,
) -> SessionKeys {
SessionKeys { babe, grandpa, para_validator, para_assignment, authority_discovery, beefy }
}
fn default_teyrchains_host_configuration(
) -> pezkuwi_runtime_teyrchains::configuration::HostConfiguration<pezkuwi_primitives::BlockNumber> {
use pezkuwi_primitives::{
node_features::FeatureIndex, AsyncBackingParams, MAX_CODE_SIZE, MAX_POV_SIZE,
};
pezkuwi_runtime_teyrchains::configuration::HostConfiguration {
validation_upgrade_cooldown: 2u32,
validation_upgrade_delay: 2,
code_retention_period: 1200,
max_code_size: MAX_CODE_SIZE,
max_pov_size: MAX_POV_SIZE,
max_head_data_size: 32 * 1024,
max_upward_queue_count: 8,
max_upward_queue_size: 1024 * 1024,
max_downward_message_size: 1024 * 1024,
max_upward_message_size: 50 * 1024,
max_upward_message_num_per_candidate: 5,
hrmp_sender_deposit: 0,
hrmp_recipient_deposit: 0,
hrmp_channel_max_capacity: 8,
hrmp_channel_max_total_size: 8 * 1024,
hrmp_max_teyrchain_inbound_channels: 4,
hrmp_channel_max_message_size: 1024 * 1024,
hrmp_max_teyrchain_outbound_channels: 4,
hrmp_max_message_num_per_candidate: 5,
dispute_period: 6,
no_show_slots: 2,
n_delay_tranches: 25,
needed_approvals: 2,
relay_vrf_modulo_samples: 2,
zeroth_delay_tranche_width: 0,
minimum_validation_upgrade_delay: 5,
async_backing_params: AsyncBackingParams {
max_candidate_depth: 0,
allowed_ancestry_len: 0,
},
node_features: bitvec::vec::BitVec::from_element(
(1u8 << (FeatureIndex::ElasticScalingMVP as usize)) |
(1u8 << (FeatureIndex::EnableAssignmentsV2 as usize)) |
(1u8 << (FeatureIndex::CandidateReceiptV2 as usize)),
),
scheduler_params: SchedulerParams {
lookahead: 3,
group_rotation_frequency: 20,
paras_availability_period: 4,
// num_cores: 0 olmalı çünkü assign_coretime() genesis'te
// her teyrchain için otomatik olarak artırır
num_cores: 0,
..Default::default()
},
..Default::default()
}
}
#[test]
fn default_teyrchains_host_configuration_is_consistent() {
default_teyrchains_host_configuration().panic_if_not_consistent();
}
fn pezkuwichain_testnet_genesis(
initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)>,
root_key: AccountId,
endowed_accounts: Option<Vec<AccountId>>,
) -> serde_json::Value {
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
const ENDOWMENT: u128 = 1_000_000 * TYR;
build_struct_json_patch!(RuntimeGenesisConfig {
balances: BalancesConfig {
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect::<Vec<_>>(),
},
session: SessionConfig {
keys: initial_authorities
.iter()
.map(|x| {
(
x.0.clone(),
x.0.clone(),
pezkuwichain_session_keys(
x.2.clone(),
x.3.clone(),
x.4.clone(),
x.5.clone(),
x.6.clone(),
x.7.clone(),
),
)
})
.collect::<Vec<_>>(),
},
babe: BabeConfig { epoch_config: BABE_GENESIS_EPOCH_CONFIG },
sudo: SudoConfig { key: Some(root_key.clone()) },
configuration: ConfigurationConfig {
config: pezkuwi_runtime_teyrchains::configuration::HostConfiguration {
scheduler_params: SchedulerParams {
max_validators_per_core: Some(1),
..default_teyrchains_host_configuration().scheduler_params
},
..default_teyrchains_host_configuration()
},
},
registrar: RegistrarConfig { next_free_para_id: pezkuwi_primitives::LOWEST_PUBLIC_ID },
})
}
// staging_testnet
fn pezkuwichain_staging_testnet_config_genesis() -> serde_json::Value {
use hex_literal::hex;
use sp_core::crypto::UncheckedInto;
// subkey inspect "$SECRET"
let endowed_accounts = Vec::from([
// 5DwBmEFPXRESyEam5SsQF1zbWSCn2kCjyLW51hJHXe9vW4xs
hex!["52bc71c1eca5353749542dfdf0af97bf764f9c2f44e860cd485f1cd86400f649"].into(),
]);
// ./scripts/prepare-test-net.sh 8
let initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)> = Vec::from([
(
//5EHZkbp22djdbuMFH9qt1DVzSCvqi3zWpj6DAYfANa828oei
hex!["62475fe5406a7cb6a64c51d0af9d3ab5c2151bcae982fb812f7a76b706914d6a"].into(),
//5FeSEpi9UYYaWwXXb3tV88qtZkmSdB3mvgj3pXkxKyYLGhcd
hex!["9e6e781a76810fe93187af44c79272c290c2b9e2b8b92ee11466cd79d8023f50"].into(),
//5Fh6rDpMDhM363o1Z3Y9twtaCPfizGQWCi55BSykTQjGbP7H
hex!["a076ef1280d768051f21d060623da3ab5b56944d681d303ed2d4bf658c5bed35"]
.unchecked_into(),
//5CPd3zoV9Aaah4xWucuDivMHJ2nEEmpdi864nPTiyRZp4t87
hex!["0e6d7d1afbcc6547b92995a394ba0daed07a2420be08220a5a1336c6731f0bfa"]
.unchecked_into(),
//5CP6oGfwqbEfML8efqm1tCZsUgRsJztp9L8ZkEUxA16W8PPz
hex!["0e07a51d3213842f8e9363ce8e444255990a225f87e80a3d651db7841e1a0205"]
.unchecked_into(),
//5HQdwiDh8Qtd5dSNWajNYpwDvoyNWWA16Y43aEkCNactFc2b
hex!["ec60e71fe4a567ef9fef99d4bbf37ffae70564b41aa6f94ef0317c13e0a5477b"]
.unchecked_into(),
//5HbSgM72xVuscsopsdeG3sCSCYdAeM1Tay9p79N6ky6vwDGq
hex!["f49eae66a0ac9f610316906ec8f1a0928e20d7059d76a5ca53cbcb5a9b50dd3c"]
.unchecked_into(),
//5DPSWdgw38Spu315r6LSvYCggeeieBAJtP5A1qzuzKhqmjVu
hex!["034f68c5661a41930c82f26a662276bf89f33467e1c850f2fb8ef687fe43d62276"]
.unchecked_into(),
),
(
//5DvH8oEjQPYhzCoQVo7WDU91qmQfLZvxe9wJcrojmJKebCmG
hex!["520b48452969f6ddf263b664de0adb0c729d0e0ad3b0e5f3cb636c541bc9022a"].into(),
//5ENZvCRzyXJJYup8bM6yEzb2kQHEb1NDpY2ZEyVGBkCfRdj3
hex!["6618289af7ae8621981ffab34591e7a6486e12745dfa3fd3b0f7e6a3994c7b5b"].into(),
//5DLjSUfqZVNAADbwYLgRvHvdzXypiV1DAEaDMjcESKTcqMoM
hex!["38757d0de00a0c739e7d7984ef4bc01161bd61e198b7c01b618425c16bb5bd5f"]
.unchecked_into(),
//5HnDVBN9mD6mXyx8oryhDbJtezwNSj1VRXgLoYCBA6uEkiao
hex!["fcd5f87a6fd5707a25122a01b4dac0a8482259df7d42a9a096606df1320df08d"]
.unchecked_into(),
//5EPEWRecy2ApL5n18n3aHyU1956zXTRqaJpzDa9DoqiggNwF
hex!["669a10892119453e9feb4e3f1ee8e028916cc3240022920ad643846fbdbee816"]
.unchecked_into(),
//5ES3fw5X4bndSgLNmtPfSbM2J1kLqApVB2CCLS4CBpM1UxUZ
hex!["68bf52c482630a8d1511f2edd14f34127a7d7082219cccf7fd4c6ecdb535f80d"]
.unchecked_into(),
//5HeXbwb5PxtcRoopPZTp5CQun38atn2UudQ8p2AxR5BzoaXw
hex!["f6f8fe475130d21165446a02fb1dbce3a7bf36412e5d98f4f0473aed9252f349"]
.unchecked_into(),
//5F7nTtN8MyJV4UsXpjg7tHSnfANXZ5KRPJmkASc1ZSH2Xoa5
hex!["03a90c2bb6d3b7000020f6152fe2e5002fa970fd1f42aafb6c8edda8dacc2ea77e"]
.unchecked_into(),
),
(
//5FPMzsezo1PRxYbVpJMWK7HNbR2kUxidsAAxH4BosHa4wd6S
hex!["92ef83665b39d7a565e11bf8d18d41d45a8011601c339e57a8ea88c8ff7bba6f"].into(),
//5G6NQidFG7YiXsvV7hQTLGArir9tsYqD4JDxByhgxKvSKwRx
hex!["b235f57244230589523271c27b8a490922ffd7dccc83b044feaf22273c1dc735"].into(),
//5GpZhzAVg7SAtzLvaAC777pjquPEcNy1FbNUAG2nZvhmd6eY
hex!["d2644c1ab2c63a3ad8d40ad70d4b260969e3abfe6d7e6665f50dc9f6365c9d2a"]
.unchecked_into(),
//5HAes2RQYPbYKbLBfKb88f4zoXv6pPA6Ke8CjN7dob3GpmSP
hex!["e1b68fbd84333e31486c08e6153d9a1415b2e7e71b413702b7d64e9b631184a1"]
.unchecked_into(),
//5FtAGDZYJKXkhVhAxCQrXmaP7EE2mGbBMfmKDHjfYDgq2BiU
hex!["a8e61ffacafaf546283dc92d14d7cc70ea0151a5dd81fdf73ff5a2951f2b6037"]
.unchecked_into(),
//5CtK7JHv3h6UQZ44y54skxdwSVBRtuxwPE1FYm7UZVhg8rJV
hex!["244f3421b310c68646e99cdbf4963e02067601f57756b072a4b19431448c186e"]
.unchecked_into(),
//5D4r6YaB6F7A7nvMRHNFNF6zrR9g39bqDJFenrcaFmTCRwfa
hex!["2c57f81fd311c1ab53813c6817fe67f8947f8d39258252663b3384ab4195494d"]
.unchecked_into(),
//5EPoHj8uV4fFKQHYThc6Z9fDkU7B6ih2ncVzQuDdNFb8UyhF
hex!["039d065fe4f9234f0a4f13cc3ae585f2691e9c25afa469618abb6645111f607a53"]
.unchecked_into(),
),
(
//5DMNx7RoX6d7JQ38NEM7DWRcW2THu92LBYZEWvBRhJeqcWgR
hex!["38f3c2f38f6d47f161e98c697bbe3ca0e47c033460afda0dda314ab4222a0404"].into(),
//5GGdKNDr9P47dpVnmtq3m8Tvowwf1ot1abw6tPsTYYFoKm2v
hex!["ba0898c1964196474c0be08d364cdf4e9e1d47088287f5235f70b0590dfe1704"].into(),
//5EjkyPCzR2SjhDZq8f7ufsw6TfkvgNRepjCRQFc4TcdXdaB1
hex!["764186bc30fd5a02477f19948dc723d6d57ab174debd4f80ed6038ec960bfe21"]
.unchecked_into(),
//5DJV3zCBTJBLGNDCcdWrYxWDacSz84goGTa4pFeKVvehEBte
hex!["36be9069cdb4a8a07ecd51f257875150f0a8a1be44a10d9d98dabf10a030aef4"]
.unchecked_into(),
//5F9FsRjpecP9GonktmtFL3kjqNAMKjHVFjyjRdTPa4hbQRZA
hex!["882d72965e642677583b333b2d173ac94b5fd6c405c76184bb14293be748a13b"]
.unchecked_into(),
//5F1FZWZSj3JyTLs8sRBxU6QWyGLSL9BMRtmSKDmVEoiKFxSP
hex!["821271c99c958b9220f1771d9f5e29af969edfa865631dba31e1ab7bc0582b75"]
.unchecked_into(),
//5CtgRR74VypK4h154s369abs78hDUxZSJqcbWsfXvsjcHJNA
hex!["2496f28d887d84705c6dae98aee8bf90fc5ad10bb5545eca1de6b68425b70f7c"]
.unchecked_into(),
//5CPx6dsr11SCJHKFkcAQ9jpparS7FwXQBrrMznRo4Hqv1PXz
hex!["0307d29bbf6a5c4061c2157b44fda33b7bb4ec52a5a0305668c74688cedf288d58"]
.unchecked_into(),
),
(
//5C8AL1Zb4bVazgT3EgDxFgcow1L4SJjVu44XcLC9CrYqFN4N
hex!["02a2d8cfcf75dda85fafc04ace3bcb73160034ed1964c43098fb1fe831de1b16"].into(),
//5FLYy3YKsAnooqE4hCudttAsoGKbVG3hYYBtVzwMjJQrevPa
hex!["90cab33f0bb501727faa8319f0845faef7d31008f178b65054b6629fe531b772"].into(),
//5Et3tfbVf1ByFThNAuUq5pBssdaPPskip5yob5GNyUFojXC7
hex!["7c94715e5dd8ab54221b1b6b2bfa5666f593f28a92a18e28052531de1bd80813"]
.unchecked_into(),
//5EX1JBghGbQqWohTPU6msR9qZ2nYPhK9r3RTQ2oD1K8TCxaG
hex!["6c878e33b83c20324238d22240f735457b6fba544b383e70bb62a27b57380c81"]
.unchecked_into(),
//5EUNaBpX9mJgcmLQHyG5Pkms6tbDiKuLbeTEJS924Js9cA1N
hex!["6a8570b9c6408e54bacf123cc2bb1b0f087f9c149147d0005badba63a5a4ac01"]
.unchecked_into(),
//5CaZuueRVpMATZG4hkcrgDoF4WGixuz7zu83jeBdY3bgWGaG
hex!["16c69ea8d595e80b6736f44be1eaeeef2ac9c04a803cc4fd944364cb0d617a33"]
.unchecked_into(),
//5DABsdQCDUGuhzVGWe5xXzYQ9rtrVxRygW7RXf9Tsjsw1aGJ
hex!["306ac5c772fe858942f92b6e28bd82fb7dd8cdd25f9a4626c1b0eee075fcb531"]
.unchecked_into(),
//5H91T5mHhoCw9JJG4NjghDdQyhC6L7XcSuBWKD3q3TAhEVvQ
hex!["02fb0330356e63a35dd930bc74525edf28b3bf5eb44aab9e9e4962c8309aaba6a6"]
.unchecked_into(),
),
(
//5C8XbDXdMNKJrZSrQURwVCxdNdk8AzG6xgLggbzuA399bBBF
hex!["02ea6bfa8b23b92fe4b5db1063a1f9475e3acd0ab61e6b4f454ed6ba00b5f864"].into(),
//5GsyzFP8qtF8tXPSsjhjxAeU1v7D1PZofuQKN9TdCc7Dp1JM
hex!["d4ffc4c05b47d1115ad200f7f86e307b20b46c50e1b72a912ec4f6f7db46b616"].into(),
//5GHWB8ZDzegLcMW7Gdd1BS6WHVwDdStfkkE4G7KjPjZNJBtD
hex!["bab3cccdcc34401e9b3971b96a662686cf755aa869a5c4b762199ce531b12c5b"]
.unchecked_into(),
//5GzDPGbUM9uH52ZEwydasTj8edokGUJ7vEpoFWp9FE1YNuFB
hex!["d9c056c98ca0e6b4eb7f5c58c007c1db7be0fe1f3776108f797dd4990d1ccc33"]
.unchecked_into(),
//5CmLCFeSurRXXtwMmLcVo7sdJ9EqDguvJbuCYDcHkr3cpqyE
hex!["1efc23c0b51ad609ab670ecf45807e31acbd8e7e5cb7c07cf49ee42992d2867c"]
.unchecked_into(),
//5DnsSy8a8pfE2aFjKBDtKw7WM1V4nfE5sLzP15MNTka53GqS
hex!["4c64d3f06d28adeb36a892fdaccecace150bec891f04694448a60b74fa469c22"]
.unchecked_into(),
//5CZdFnyzZvKetZTeUwj5APAYskVJe4QFiTezo5dQNsrnehGd
hex!["160ea09c5717270e958a3da42673fa011613a9539b2e4ebcad8626bc117ca04a"]
.unchecked_into(),
//5HgoR9JJkdBusxKrrs3zgd3ToppgNoGj1rDyAJp4e7eZiYyT
hex!["020019a8bb188f8145d02fa855e9c36e9914457d37c500e03634b5223aa5702474"]
.unchecked_into(),
),
(
//5HinEonzr8MywkqedcpsmwpxKje2jqr9miEwuzyFXEBCvVXM
hex!["fa373e25a1c4fe19c7148acde13bc3db1811cf656dc086820f3dda736b9c4a00"].into(),
//5EHJbj6Td6ks5HDnyfN4ttTSi57osxcQsQexm7XpazdeqtV7
hex!["62145d721967bd88622d08625f0f5681463c0f1b8bcd97eb3c2c53f7660fd513"].into(),
//5EeCsC58XgJ1DFaoYA1WktEpP27jvwGpKdxPMFjicpLeYu96
hex!["720537e2c1c554654d73b3889c3ef4c3c2f95a65dd3f7c185ebe4afebed78372"]
.unchecked_into(),
//5DnEySxbnppWEyN8cCLqvGjAorGdLRg2VmkY96dbJ1LHFK8N
hex!["4bea0b37e0cce9bddd80835fa2bfd5606f5dcfb8388bbb10b10c483f0856cf14"]
.unchecked_into(),
//5CAC278tFCHAeHYqE51FTWYxHmeLcENSS1RG77EFRTvPZMJT
hex!["042f07fc5268f13c026bbe199d63e6ac77a0c2a780f71cda05cee5a6f1b3f11f"]
.unchecked_into(),
//5HjRTLWcQjZzN3JDvaj1UzjNSayg5ZD9ZGWMstaL7Ab2jjAa
hex!["fab485e87ed1537d089df521edf983a777c57065a702d7ed2b6a2926f31da74f"]
.unchecked_into(),
//5ELv74v7QcsS6FdzvG4vL2NnYDGWmRnJUSMKYwdyJD7Xcdi7
hex!["64d59feddb3d00316a55906953fb3db8985797472bd2e6c7ea1ab730cc339d7f"]
.unchecked_into(),
//5FaUcPt4fPz93vBhcrCJqmDkjYZ7jCbzAF56QJoCmvPaKrmx
hex!["033f1a6d47fe86f88934e4b83b9fae903b92b5dcf4fec97d5e3e8bf4f39df03685"]
.unchecked_into(),
),
(
//5Ey3NQ3dfabaDc16NUv7wRLsFCMDFJSqZFzKVycAsWuUC6Di
hex!["8062e9c21f1d92926103119f7e8153cebdb1e5ab3e52d6f395be80bb193eab47"].into(),
//5HiWsuSBqt8nS9pnggexXuHageUifVPKPHDE2arTKqhTp1dV
hex!["fa0388fa88f3f0cb43d583e2571fbc0edad57dff3a6fd89775451dd2c2b8ea00"].into(),
//5H168nKX2Yrfo3bxj7rkcg25326Uv3CCCnKUGK6uHdKMdPt8
hex!["da6b2df18f0f9001a6dcf1d301b92534fe9b1f3ccfa10c49449fee93adaa8349"]
.unchecked_into(),
//5DrA2fZdzmNqT5j6DXNwVxPBjDV9jhkAqvjt6Us3bQHKy3cF
hex!["4ee66173993dd0db5d628c4c9cb61a27b76611ad3c3925947f0d0011ee2c5dcc"]
.unchecked_into(),
//5Gx6YeNhynqn8qkda9QKpc9S7oDr4sBrfAu516d3sPpEt26F
hex!["d822d4088b20dca29a580a577a97d6f024bb24c9550bebdfd7d2d18e946a1c7d"]
.unchecked_into(),
//5DhDcHqwxoes5s89AyudGMjtZXx1nEgrk5P45X88oSTR3iyx
hex!["481538f8c2c011a76d7d57db11c2789a5e83b0f9680dc6d26211d2f9c021ae4c"]
.unchecked_into(),
//5DqAvikdpfRdk5rR35ZobZhqaC5bJXZcEuvzGtexAZP1hU3T
hex!["4e262811acdfe94528bfc3c65036080426a0e1301b9ada8d687a70ffcae99c26"]
.unchecked_into(),
//5E41Znrr2YtZu8bZp3nvRuLVHg3jFksfQ3tXuviLku4wsao7
hex!["025e84e95ed043e387ddb8668176b42f8e2773ddd84f7f58a6d9bf436a4b527986"]
.unchecked_into(),
),
]);
const ENDOWMENT: u128 = 1_000_000 * TYR;
const STASH: u128 = 100 * TYR;
build_struct_json_patch!(RuntimeGenesisConfig {
balances: BalancesConfig {
balances: endowed_accounts
.iter()
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect::<Vec<_>>(),
},
session: SessionConfig {
keys: initial_authorities
.into_iter()
.map(|x| (
x.0.clone(),
x.0,
pezkuwichain_session_keys(x.2, x.3, x.4, x.5, x.6, x.7)
))
.collect::<Vec<_>>(),
},
babe: BabeConfig { epoch_config: BABE_GENESIS_EPOCH_CONFIG },
sudo: SudoConfig { key: Some(endowed_accounts[0].clone()) },
configuration: ConfigurationConfig { config: default_teyrchains_host_configuration() },
registrar: RegistrarConfig { next_free_para_id: pezkuwi_primitives::LOWEST_PUBLIC_ID },
})
}
//development
fn pezkuwichain_development_config_genesis() -> serde_json::Value {
pezkuwichain_testnet_genesis(
Vec::from([get_authority_keys_from_seed("Alice")]),
Sr25519Keyring::Alice.to_account_id(),
None,
)
}
//local_testnet
fn pezkuwichain_local_testnet_genesis() -> serde_json::Value {
pezkuwichain_testnet_genesis(
Vec::from([get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")]),
Sr25519Keyring::Alice.to_account_id(),
None,
)
}
/// `Versi` is a temporary testnet that uses the same runtime as pezkuwichain.
// versi_local_testnet
fn versi_local_testnet_genesis() -> serde_json::Value {
pezkuwichain_testnet_genesis(
Vec::from([
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
get_authority_keys_from_seed("Charlie"),
get_authority_keys_from_seed("Dave"),
]),
Sr25519Keyring::Alice.to_account_id(),
None,
)
}
/// Encapsulates names of predefined presets.
mod preset_names {
pub const PRESET_GENESIS: &str = "genesis";
}
/// Genesis configuration for mainnet with HEZ distribution
/// Accounts from Founder_treasury_presale_wallets.json
fn pezkuwichain_genesis_config() -> serde_json::Value {
use hex_literal::hex;
use sp_core::crypto::UncheckedInto;
// ==========================================================================
// MAINNET ACCOUNTS - Real addresses from founder_governance.json & presale_airdrop_wallets.json
// ==========================================================================
// Founder account - receives 10% (20M HEZ)
// From: founder_governance.json - Founder_Satoshi_Qazi_Muhammed
// SS58: 5GRTwhBCAPR2un27NxMw9uyHFmXdfJa1EJx8TNZxJWjAFmyc
let founder_account: AccountId =
hex!("c0c6403050931c67e13edfa4a558a9c3d4ae64f04b0fd8cb57b2f796c668a068").into();
// Presale account - receives 50% (100M HEZ)
// From: presale_airdrop_wallets.json
// SS58: 5F4fVGo9E33EpWoqPYyoWXiu34MvKhovMDeAboQzfbtFQ43Q
let presale_account: AccountId =
hex!("84acb9d8e22fe6ee32e2ea92919e6ee7355c9fc4112bc2ca4b29942ebd986e69").into();
// Kurdistan Treasury account - receives 20% (40M HEZ)
// From: founder_governance.json - treasury
// SS58: 5GdprKXDvoXAryJa6YH8WMdjRprFU4584TDX2FEG8AqYDnV9
let treasury_account: AccountId =
hex!("ca3393764525378c54d83478b88453091c27031ba8de693d64da16ac21277359").into();
// Airdrop account - receives 20% (40M HEZ)
// From: presale_airdrop_wallets.json
// SS58: 5DVitukYFhLsXJnzxXekMJKuimUu7Qc38HxTZTjF9NH4VsUM
let airdrop_account: AccountId =
hex!("3f50dd6e1cb2f47d355e6160f63f11cf42660e0fadd8126785314943294b3678").into();
// ==========================================================================
// INITIAL VALIDATORS - First 4 validators from mainnet_validators JSON
// Full 100 validators will be added via validator registration after launch
// ==========================================================================
let initial_authorities: Vec<(
AccountId,
AccountId,
BabeId,
GrandpaId,
ValidatorId,
AssignmentId,
AuthorityDiscoveryId,
BeefyId,
)> = Vec::from([
(
// Validator 1: E8XC6rTJRsioKCp6KMy6zd24ykj4gWsusZ3AkSeyavpVBAG (stash)
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608").into(),
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608").into(),
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
.unchecked_into(),
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
.unchecked_into(),
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
.unchecked_into(),
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
.unchecked_into(),
hex!("44cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
.unchecked_into(),
hex!("0244cb62d1d6cdd2fff2a5ef3bb7ef827be5b3e117a394ecaa634d8dd9809d5608")
.unchecked_into(),
),
(
// Validator 2: G28iWEybndgGRbhfx83t7Q42YhMPByHpyqWDUgeyoGF94ri (stash)
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944").into(),
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944").into(),
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
.unchecked_into(),
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
.unchecked_into(),
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
.unchecked_into(),
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
.unchecked_into(),
hex!("9864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
.unchecked_into(),
hex!("029864b85e23aa4506643db9879c3dbbeabaa94d269693a4447f537dd6b5893944")
.unchecked_into(),
),
(
// Validator 3: G839e2eMiq7UXbConsY6DS1XDAYG2XnQxAmLuRLGGQ3Px9c (stash)
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948").into(),
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948").into(),
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
.unchecked_into(),
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
.unchecked_into(),
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
.unchecked_into(),
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
.unchecked_into(),
hex!("9ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
.unchecked_into(),
hex!("029ce5741ee2f1ac3bdedbde9f3339048f4da2cb88ddf33a0977fa0b4cf86e2948")
.unchecked_into(),
),
(
// Validator 4: GLao4ukFUW6qhexuZowdFrKa2NLCfnEjZMftSXXfvGv1vvt (stash)
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f").into(),
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f").into(),
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
.unchecked_into(),
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
.unchecked_into(),
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
.unchecked_into(),
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
.unchecked_into(),
hex!("a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
.unchecked_into(),
hex!("02a676ed15f5a325eab49ed8d5f8c00f3f814b19bb58cda14ad10894c078dd337f")
.unchecked_into(),
),
]);
// Validator stash amount
const STASH: u128 = 100 * TYR;
build_struct_json_patch!(RuntimeGenesisConfig {
balances: BalancesConfig {
balances: vec![
// HEZ Genesis Distribution (200M Total)
(founder_account.clone(), HEZ_FOUNDER_ALLOCATION), // 10% = 20M HEZ
(presale_account.clone(), HEZ_PRESALE_ALLOCATION), // 50% = 100M HEZ
(treasury_account.clone(), HEZ_TREASURY_ALLOCATION), // 20% = 40M HEZ
(airdrop_account.clone(), HEZ_AIRDROP_ALLOCATION), // 20% = 40M HEZ
]
.into_iter()
// Add validator stash balances
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
.collect::<Vec<_>>(),
},
session: SessionConfig {
keys: initial_authorities
.into_iter()
.map(|x| (
x.0.clone(),
x.0,
pezkuwichain_session_keys(x.2, x.3, x.4, x.5, x.6, x.7)
))
.collect::<Vec<_>>(),
},
babe: BabeConfig { epoch_config: BABE_GENESIS_EPOCH_CONFIG },
sudo: SudoConfig { key: Some(founder_account) },
configuration: ConfigurationConfig { config: default_teyrchains_host_configuration() },
registrar: RegistrarConfig { next_free_para_id: pezkuwi_primitives::LOWEST_PUBLIC_ID },
})
}
/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
use preset_names::*;
let patch = match id.as_ref() {
// ====================================================================
// GENESIS PRESET - For mainnet with HEZ distribution
// ====================================================================
PRESET_GENESIS => pezkuwichain_genesis_config(),
// ====================================================================
// LOCAL TESTNET PRESET - For local multi-node testing
// ====================================================================
sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => pezkuwichain_local_testnet_genesis(),
// ====================================================================
// DEV PRESET - For single-node development
// ====================================================================
sp_genesis_builder::DEV_RUNTIME_PRESET => pezkuwichain_development_config_genesis(),
// ====================================================================
// STAGING TESTNET - For pre-production testing
// ====================================================================
"staging_testnet" => pezkuwichain_staging_testnet_config_genesis(),
// ====================================================================
// VERSI LOCAL TESTNET - Extended local testing
// ====================================================================
"versi_local_testnet" => versi_local_testnet_genesis(),
_ => return None,
};
Some(
serde_json::to_string(&patch)
.expect("serialization to json is expected to work. qed.")
.into_bytes(),
)
}
/// List of supported presets.
pub fn preset_names() -> Vec<PresetId> {
use preset_names::*;
vec![
PresetId::from(PRESET_GENESIS),
PresetId::from(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET),
PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET),
PresetId::from("staging_testnet"),
PresetId::from("versi_local_testnet"),
]
}
@@ -0,0 +1,94 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! New governance configurations for the Pezkuwichain runtime.
use super::*;
use frame_support::{
parameter_types,
traits::{ConstU16, EitherOf},
};
use frame_system::EnsureRootWithSuccess;
mod origins;
pub use origins::{
pallet_custom_origins, AuctionAdmin, Fellows, FellowshipAdmin, FellowshipExperts,
FellowshipInitiates, FellowshipMasters, GeneralAdmin, LeaseAdmin, ReferendumCanceller,
ReferendumKiller, Spender, StakingAdmin, Treasurer, WhitelistedCaller,
};
mod tracks;
pub use tracks::TracksInfo;
parameter_types! {
pub const VoteLockingPeriod: BlockNumber = 7 * DAYS;
}
impl pallet_conviction_voting::Config for Runtime {
type WeightInfo = weights::pallet_conviction_voting::WeightInfo<Self>;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type VoteLockingPeriod = VoteLockingPeriod;
type MaxVotes = ConstU32<512>;
type MaxTurnout =
frame_support::traits::tokens::currency::ActiveIssuanceOf<Balances, Self::AccountId>;
type Polls = Referenda;
type BlockNumberProvider = System;
type VotingHooks = ();
}
parameter_types! {
pub const AlarmInterval: BlockNumber = 1;
pub const SubmissionDeposit: Balance = 1 * 3 * CENTS;
pub const UndecidingTimeout: BlockNumber = 14 * DAYS;
}
parameter_types! {
pub const MaxBalance: Balance = Balance::max_value();
}
pub type TreasurySpender = EitherOf<EnsureRootWithSuccess<AccountId, MaxBalance>, Spender>;
impl origins::pallet_custom_origins::Config for Runtime {}
impl pallet_whitelist::Config for Runtime {
type WeightInfo = weights::pallet_whitelist::WeightInfo<Self>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WhitelistOrigin =
EitherOf<EnsureRootWithSuccess<Self::AccountId, ConstU16<65535>>, Fellows>;
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
type Preimages = Preimage;
}
impl pallet_referenda::Config for Runtime {
type WeightInfo = weights::pallet_referenda_referenda::WeightInfo<Self>;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
type Currency = Balances;
type SubmitOrigin = frame_system::EnsureSigned<AccountId>;
type CancelOrigin = EitherOf<EnsureRoot<AccountId>, ReferendumCanceller>;
type KillOrigin = EitherOf<EnsureRoot<AccountId>, ReferendumKiller>;
type Slash = Treasury;
type Votes = pallet_conviction_voting::VotesOf<Runtime>;
type Tally = pallet_conviction_voting::TallyOf<Runtime>;
type SubmissionDeposit = SubmissionDeposit;
type MaxQueued = ConstU32<100>;
type UndecidingTimeout = UndecidingTimeout;
type AlarmInterval = AlarmInterval;
type Tracks = TracksInfo;
type Preimages = Preimage;
type BlockNumberProvider = System;
}
@@ -0,0 +1,210 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Custom origins for governance interventions.
pub use pallet_custom_origins::*;
#[frame_support::pallet]
pub mod pallet_custom_origins {
use crate::{Balance, CENTS, GRAND};
use frame_support::pallet_prelude::*;
#[pallet::config]
pub trait Config: frame_system::Config {}
#[pallet::pallet]
pub struct Pallet<T>(_);
#[derive(
PartialEq,
Eq,
Clone,
MaxEncodedLen,
Encode,
Decode,
DecodeWithMemTracking,
TypeInfo,
RuntimeDebug,
)]
#[pallet::origin]
pub enum Origin {
/// Origin for cancelling slashes.
StakingAdmin,
/// Origin for spending (any amount of) funds.
Treasurer,
/// Origin for managing the composition of the fellowship.
FellowshipAdmin,
/// Origin for managing the registrar.
GeneralAdmin,
/// Origin for starting auctions.
AuctionAdmin,
/// Origin able to force slot leases.
LeaseAdmin,
/// Origin able to cancel referenda.
ReferendumCanceller,
/// Origin able to kill referenda.
ReferendumKiller,
/// Origin able to spend up to 1 HEZ from the treasury at once.
SmallTipper,
/// Origin able to spend up to 5 HEZ from the treasury at once.
BigTipper,
/// Origin able to spend up to 50 HEZ from the treasury at once.
SmallSpender,
/// Origin able to spend up to 500 HEZ from the treasury at once.
MediumSpender,
/// Origin able to spend up to 5,000 HEZ from the treasury at once.
BigSpender,
/// Origin able to dispatch a whitelisted call.
WhitelistedCaller,
/// Origin commanded by any members of the Pezkuwi Fellowship (no Dan grade needed).
FellowshipInitiates,
/// Origin commanded by Pezkuwi Fellows (3rd Dan fellows or greater).
Fellows,
/// Origin commanded by Pezkuwi Experts (5th Dan fellows or greater).
FellowshipExperts,
/// Origin commanded by Pezkuwi Masters (7th Dan fellows of greater).
FellowshipMasters,
/// Origin commanded by rank 1 of the Pezkuwi Fellowship and with a success of 1.
Fellowship1Dan,
/// Origin commanded by rank 2 of the Pezkuwi Fellowship and with a success of 2.
Fellowship2Dan,
/// Origin commanded by rank 3 of the Pezkuwi Fellowship and with a success of 3.
Fellowship3Dan,
/// Origin commanded by rank 4 of the Pezkuwi Fellowship and with a success of 4.
Fellowship4Dan,
/// Origin commanded by rank 5 of the Pezkuwi Fellowship and with a success of 5.
Fellowship5Dan,
/// Origin commanded by rank 6 of the Pezkuwi Fellowship and with a success of 6.
Fellowship6Dan,
/// Origin commanded by rank 7 of the Pezkuwi Fellowship and with a success of 7.
Fellowship7Dan,
/// Origin commanded by rank 8 of the Pezkuwi Fellowship and with a success of 8.
Fellowship8Dan,
/// Origin commanded by rank 9 of the Pezkuwi Fellowship and with a success of 9.
Fellowship9Dan,
}
macro_rules! decl_unit_ensures {
( $name:ident: $success_type:ty = $success:expr ) => {
pub struct $name;
impl<O: OriginTrait + From<Origin>> EnsureOrigin<O> for $name
where
for <'a> &'a O::PalletsOrigin: TryInto<&'a Origin>,
{
type Success = $success_type;
fn try_origin(o: O) -> Result<Self::Success, O> {
match o.caller().try_into() {
Ok(Origin::$name) => return Ok($success),
_ => (),
}
Err(o)
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<O, ()> {
Ok(O::from(Origin::$name))
}
}
};
( $name:ident ) => { decl_unit_ensures! { $name : () = () } };
( $name:ident: $success_type:ty = $success:expr, $( $rest:tt )* ) => {
decl_unit_ensures! { $name: $success_type = $success }
decl_unit_ensures! { $( $rest )* }
};
( $name:ident, $( $rest:tt )* ) => {
decl_unit_ensures! { $name }
decl_unit_ensures! { $( $rest )* }
};
() => {}
}
decl_unit_ensures!(
StakingAdmin,
Treasurer,
FellowshipAdmin,
GeneralAdmin,
AuctionAdmin,
LeaseAdmin,
ReferendumCanceller,
ReferendumKiller,
WhitelistedCaller,
FellowshipInitiates: u16 = 0,
Fellows: u16 = 3,
FellowshipExperts: u16 = 5,
FellowshipMasters: u16 = 7,
);
macro_rules! decl_ensure {
(
$vis:vis type $name:ident: EnsureOrigin<Success = $success_type:ty> {
$( $item:ident = $success:expr, )*
}
) => {
$vis struct $name;
impl<O: OriginTrait + From<Origin>> EnsureOrigin<O> for $name
where
for <'a> &'a O::PalletsOrigin: TryInto<&'a Origin>,
{
type Success = $success_type;
fn try_origin(o: O) -> Result<Self::Success, O> {
match o.caller().try_into() {
$(
Ok(Origin::$item) => return Ok($success),
)*
_ => (),
}
Err(o)
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<O, ()> {
// By convention the more privileged origins go later, so for greatest chance
// of success, we want the last one.
let _result: Result<O, ()> = Err(());
$(
let _result: Result<O, ()> = Ok(O::from(Origin::$item));
)*
_result
}
}
}
}
decl_ensure! {
pub type Spender: EnsureOrigin<Success = Balance> {
SmallTipper = 250 * 3 * CENTS,
BigTipper = 1 * GRAND,
SmallSpender = 10 * GRAND,
MediumSpender = 100 * GRAND,
BigSpender = 1_000 * GRAND,
Treasurer = 10_000 * GRAND,
}
}
decl_ensure! {
pub type EnsureFellowship: EnsureOrigin<Success = u16> {
Fellowship1Dan = 1,
Fellowship2Dan = 2,
Fellowship3Dan = 3,
Fellowship4Dan = 4,
Fellowship5Dan = 5,
Fellowship6Dan = 6,
Fellowship7Dan = 7,
Fellowship8Dan = 8,
Fellowship9Dan = 9,
}
}
}
@@ -0,0 +1,325 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Track configurations for governance.
use super::*;
use alloc::borrow::Cow;
use sp_runtime::str_array as s;
const fn percent(x: i32) -> sp_arithmetic::FixedI64 {
sp_arithmetic::FixedI64::from_rational(x as u128, 100)
}
use pallet_referenda::Curve;
const APP_ROOT: Curve = Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
const SUP_ROOT: Curve = Curve::make_linear(28, 28, percent(0), percent(50));
const APP_STAKING_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
const SUP_STAKING_ADMIN: Curve =
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
const APP_TREASURER: Curve = Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
const SUP_TREASURER: Curve = Curve::make_linear(28, 28, percent(0), percent(50));
const APP_FELLOWSHIP_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
const SUP_FELLOWSHIP_ADMIN: Curve =
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
const APP_GENERAL_ADMIN: Curve =
Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
const SUP_GENERAL_ADMIN: Curve =
Curve::make_reciprocal(7, 28, percent(10), percent(0), percent(50));
const APP_AUCTION_ADMIN: Curve =
Curve::make_reciprocal(4, 28, percent(80), percent(50), percent(100));
const SUP_AUCTION_ADMIN: Curve =
Curve::make_reciprocal(7, 28, percent(10), percent(0), percent(50));
const APP_LEASE_ADMIN: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
const SUP_LEASE_ADMIN: Curve = Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
const APP_REFERENDUM_CANCELLER: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
const SUP_REFERENDUM_CANCELLER: Curve =
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
const APP_REFERENDUM_KILLER: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
const SUP_REFERENDUM_KILLER: Curve =
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
const APP_SMALL_TIPPER: Curve = Curve::make_linear(10, 28, percent(50), percent(100));
const SUP_SMALL_TIPPER: Curve = Curve::make_reciprocal(1, 28, percent(4), percent(0), percent(50));
const APP_BIG_TIPPER: Curve = Curve::make_linear(10, 28, percent(50), percent(100));
const SUP_BIG_TIPPER: Curve = Curve::make_reciprocal(8, 28, percent(1), percent(0), percent(50));
const APP_SMALL_SPENDER: Curve = Curve::make_linear(17, 28, percent(50), percent(100));
const SUP_SMALL_SPENDER: Curve =
Curve::make_reciprocal(12, 28, percent(1), percent(0), percent(50));
const APP_MEDIUM_SPENDER: Curve = Curve::make_linear(23, 28, percent(50), percent(100));
const SUP_MEDIUM_SPENDER: Curve =
Curve::make_reciprocal(16, 28, percent(1), percent(0), percent(50));
const APP_BIG_SPENDER: Curve = Curve::make_linear(28, 28, percent(50), percent(100));
const SUP_BIG_SPENDER: Curve = Curve::make_reciprocal(20, 28, percent(1), percent(0), percent(50));
const APP_WHITELISTED_CALLER: Curve =
Curve::make_reciprocal(16, 28 * 24, percent(96), percent(50), percent(100));
const SUP_WHITELISTED_CALLER: Curve =
Curve::make_reciprocal(1, 28, percent(20), percent(5), percent(50));
const TRACKS_DATA: [pallet_referenda::Track<u16, Balance, BlockNumber>; 15] = [
pallet_referenda::Track {
id: 0,
info: pallet_referenda::TrackInfo {
name: s("root"),
max_deciding: 1,
decision_deposit: 100 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 12 * MINUTES,
min_enactment_period: 5 * MINUTES,
min_approval: APP_ROOT,
min_support: SUP_ROOT,
},
},
pallet_referenda::Track {
id: 1,
info: pallet_referenda::TrackInfo {
name: s("whitelisted_caller"),
max_deciding: 100,
decision_deposit: 10 * GRAND,
prepare_period: 6 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 4 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_WHITELISTED_CALLER,
min_support: SUP_WHITELISTED_CALLER,
},
},
pallet_referenda::Track {
id: 10,
info: pallet_referenda::TrackInfo {
name: s("staking_admin"),
max_deciding: 10,
decision_deposit: 5 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_STAKING_ADMIN,
min_support: SUP_STAKING_ADMIN,
},
},
pallet_referenda::Track {
id: 11,
info: pallet_referenda::TrackInfo {
name: s("treasurer"),
max_deciding: 10,
decision_deposit: 1 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 5 * MINUTES,
min_approval: APP_TREASURER,
min_support: SUP_TREASURER,
},
},
pallet_referenda::Track {
id: 12,
info: pallet_referenda::TrackInfo {
name: s("lease_admin"),
max_deciding: 10,
decision_deposit: 5 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_LEASE_ADMIN,
min_support: SUP_LEASE_ADMIN,
},
},
pallet_referenda::Track {
id: 13,
info: pallet_referenda::TrackInfo {
name: s("fellowship_admin"),
max_deciding: 10,
decision_deposit: 5 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_FELLOWSHIP_ADMIN,
min_support: SUP_FELLOWSHIP_ADMIN,
},
},
pallet_referenda::Track {
id: 14,
info: pallet_referenda::TrackInfo {
name: s("general_admin"),
max_deciding: 10,
decision_deposit: 5 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_GENERAL_ADMIN,
min_support: SUP_GENERAL_ADMIN,
},
},
pallet_referenda::Track {
id: 15,
info: pallet_referenda::TrackInfo {
name: s("auction_admin"),
max_deciding: 10,
decision_deposit: 5 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_AUCTION_ADMIN,
min_support: SUP_AUCTION_ADMIN,
},
},
pallet_referenda::Track {
id: 20,
info: pallet_referenda::TrackInfo {
name: s("referendum_canceller"),
max_deciding: 1_000,
decision_deposit: 10 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 14 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_REFERENDUM_CANCELLER,
min_support: SUP_REFERENDUM_CANCELLER,
},
},
pallet_referenda::Track {
id: 21,
info: pallet_referenda::TrackInfo {
name: s("referendum_killer"),
max_deciding: 1_000,
decision_deposit: 50 * GRAND,
prepare_period: 8 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 8 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_REFERENDUM_KILLER,
min_support: SUP_REFERENDUM_KILLER,
},
},
pallet_referenda::Track {
id: 30,
info: pallet_referenda::TrackInfo {
name: s("small_tipper"),
max_deciding: 200,
decision_deposit: 1 * 3 * CENTS,
prepare_period: 1 * MINUTES,
decision_period: 14 * MINUTES,
confirm_period: 4 * MINUTES,
min_enactment_period: 1 * MINUTES,
min_approval: APP_SMALL_TIPPER,
min_support: SUP_SMALL_TIPPER,
},
},
pallet_referenda::Track {
id: 31,
info: pallet_referenda::TrackInfo {
name: s("big_tipper"),
max_deciding: 100,
decision_deposit: 10 * 3 * CENTS,
prepare_period: 4 * MINUTES,
decision_period: 14 * MINUTES,
confirm_period: 12 * MINUTES,
min_enactment_period: 3 * MINUTES,
min_approval: APP_BIG_TIPPER,
min_support: SUP_BIG_TIPPER,
},
},
pallet_referenda::Track {
id: 32,
info: pallet_referenda::TrackInfo {
name: s("small_spender"),
max_deciding: 50,
decision_deposit: 100 * 3 * CENTS,
prepare_period: 10 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 10 * MINUTES,
min_enactment_period: 5 * MINUTES,
min_approval: APP_SMALL_SPENDER,
min_support: SUP_SMALL_SPENDER,
},
},
pallet_referenda::Track {
id: 33,
info: pallet_referenda::TrackInfo {
name: s("medium_spender"),
max_deciding: 50,
decision_deposit: 200 * 3 * CENTS,
prepare_period: 10 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 12 * MINUTES,
min_enactment_period: 5 * MINUTES,
min_approval: APP_MEDIUM_SPENDER,
min_support: SUP_MEDIUM_SPENDER,
},
},
pallet_referenda::Track {
id: 34,
info: pallet_referenda::TrackInfo {
name: s("big_spender"),
max_deciding: 50,
decision_deposit: 400 * 3 * CENTS,
prepare_period: 10 * MINUTES,
decision_period: 20 * MINUTES,
confirm_period: 14 * MINUTES,
min_enactment_period: 5 * MINUTES,
min_approval: APP_BIG_SPENDER,
min_support: SUP_BIG_SPENDER,
},
},
];
pub struct TracksInfo;
impl pallet_referenda::TracksInfo<Balance, BlockNumber> for TracksInfo {
type Id = u16;
type RuntimeOrigin = <RuntimeOrigin as frame_support::traits::OriginTrait>::PalletsOrigin;
fn tracks(
) -> impl Iterator<Item = Cow<'static, pallet_referenda::Track<Self::Id, Balance, BlockNumber>>>
{
TRACKS_DATA.iter().map(Cow::Borrowed)
}
fn track_for(id: &Self::RuntimeOrigin) -> Result<Self::Id, ()> {
if let Ok(system_origin) = frame_system::RawOrigin::try_from(id.clone()) {
match system_origin {
frame_system::RawOrigin::Root => Ok(0),
_ => Err(()),
}
} else if let Ok(custom_origin) = origins::Origin::try_from(id.clone()) {
match custom_origin {
origins::Origin::WhitelistedCaller => Ok(1),
// General admin
origins::Origin::StakingAdmin => Ok(10),
origins::Origin::Treasurer => Ok(11),
origins::Origin::LeaseAdmin => Ok(12),
origins::Origin::FellowshipAdmin => Ok(13),
origins::Origin::GeneralAdmin => Ok(14),
origins::Origin::AuctionAdmin => Ok(15),
// Referendum admins
origins::Origin::ReferendumCanceller => Ok(20),
origins::Origin::ReferendumKiller => Ok(21),
// Limited treasury spenders
origins::Origin::SmallTipper => Ok(30),
origins::Origin::BigTipper => Ok(31),
origins::Origin::SmallSpender => Ok(32),
origins::Origin::MediumSpender => Ok(33),
origins::Origin::BigSpender => Ok(34),
_ => Err(()),
}
} else {
Err(())
}
}
}
File diff suppressed because it is too large Load Diff
+130
View File
@@ -0,0 +1,130 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Tests for the Pezkuwichain Runtime Configuration
use crate::*;
use std::collections::HashSet;
use crate::xcm_config::LocationConverter;
use frame_support::traits::WhitelistedStorageKeys;
use sp_core::{crypto::Ss58Codec, hexdisplay::HexDisplay};
use sp_keyring::Sr25519Keyring::Alice;
use xcm_runtime_apis::conversions::LocationToAccountHelper;
#[test]
fn check_whitelist() {
let whitelist: HashSet<String> = AllPalletsWithSystem::whitelisted_storage_keys()
.iter()
.map(|e| HexDisplay::from(&e.key).to_string())
.collect();
// Block number
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"));
// Total issuance
assert!(whitelist.contains("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80"));
// Execution phase
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a"));
// Event count
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850"));
// System events
assert!(whitelist.contains("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7"));
// XcmPallet VersionDiscoveryQueue
assert!(whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d194a222ba0333561192e474c59ed8e30e1"));
// XcmPallet SafeXcmVersion
assert!(whitelist.contains("1405f2411d0af5a7ff397e7c9dc68d196323ae84c43568be0d1394d5d0d522c4"));
}
#[test]
fn check_treasury_pallet_id() {
assert_eq!(
<Treasury as frame_support::traits::PalletInfoAccess>::index() as u8,
pezkuwichain_runtime_constants::TREASURY_PALLET_ID
);
}
#[test]
fn location_conversion_works() {
// the purpose of hardcoded values is to catch an unintended location conversion logic change.
struct TestCase {
description: &'static str,
location: Location,
expected_account_id_str: &'static str,
}
let test_cases = vec![
// DescribeTerminus
TestCase {
description: "DescribeTerminus Child",
location: Location::new(0, [Teyrchain(1111)]),
expected_account_id_str: "5Ec4AhP4h37t7TFsAZ4HhFq6k92usAAJDUC3ADSZ4H4Acru3",
},
// DescribePalletTerminal
TestCase {
description: "DescribePalletTerminal Child",
location: Location::new(0, [Teyrchain(1111), PalletInstance(50)]),
expected_account_id_str: "5FjEBrKn3STAFsZpQF4jzwxUYHNGnNgzdZqSQfTzeJ82XKp6",
},
// DescribeAccountId32Terminal
TestCase {
description: "DescribeAccountId32Terminal Child",
location: Location::new(
0,
[Teyrchain(1111), AccountId32 { network: None, id: AccountId::from(Alice).into() }],
),
expected_account_id_str: "5EEMro9RRDpne4jn9TuD7cTB6Amv1raVZ3xspSkqb2BF3FJH",
},
// DescribeAccountKey20Terminal
TestCase {
description: "DescribeAccountKey20Terminal Child",
location: Location::new(
0,
[Teyrchain(1111), AccountKey20 { network: None, key: [0u8; 20] }],
),
expected_account_id_str: "5HohjXdjs6afcYcgHHSstkrtGfxgfGKsnZ1jtewBpFiGu4DL",
},
// DescribeTreasuryVoiceTerminal
TestCase {
description: "DescribeTreasuryVoiceTerminal Child",
location: Location::new(
0,
[Teyrchain(1111), Plurality { id: BodyId::Treasury, part: BodyPart::Voice }],
),
expected_account_id_str: "5GenE4vJgHvwYVcD6b4nBvH5HNY4pzpVHWoqwFpNMFT7a2oX",
},
// DescribeBodyTerminal
TestCase {
description: "DescribeBodyTerminal Child",
location: Location::new(
0,
[Teyrchain(1111), Plurality { id: BodyId::Unit, part: BodyPart::Voice }],
),
expected_account_id_str: "5DPgGBFTTYm1dGbtB1VWHJ3T3ScvdrskGGx6vSJZNP1WNStV",
},
];
for tc in test_cases {
let expected =
AccountId::from_string(tc.expected_account_id_str).expect("Invalid AccountId string");
let got = LocationToAccountHelper::<AccountId, LocationConverter>::convert_location(
tc.location.into(),
)
.unwrap();
assert_eq!(got, expected, "{}", tc.description);
}
}
@@ -0,0 +1,144 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! A pallet for managing validators on Pezkuwichain.
use alloc::vec::Vec;
use sp_staking::SessionIndex;
pub use pallet::*;
type Session<T> = pallet_session::Pallet<T>;
#[frame_support::pallet]
pub mod pallet {
use super::*;
use frame_support::{dispatch::DispatchResult, pallet_prelude::*, traits::EnsureOrigin};
use frame_system::pallet_prelude::*;
#[pallet::pallet]
#[pallet::without_storage_info]
pub struct Pallet<T>(_);
/// Configuration for the teyrchain proposer.
#[pallet::config]
pub trait Config: frame_system::Config + pallet_session::Config {
/// The overreaching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
/// Privileged origin that can add or remove validators.
type PrivilegedOrigin: EnsureOrigin<<Self as frame_system::Config>::RuntimeOrigin>;
}
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config> {
/// New validators were added to the set.
ValidatorsRegistered(Vec<T::ValidatorId>),
/// Validators were removed from the set.
ValidatorsDeregistered(Vec<T::ValidatorId>),
}
/// Validators that should be retired, because their Teyrchain was deregistered.
#[pallet::storage]
pub(crate) type ValidatorsToRetire<T: Config> =
StorageValue<_, Vec<T::ValidatorId>, ValueQuery>;
/// Validators that should be added.
#[pallet::storage]
pub(crate) type ValidatorsToAdd<T: Config> = StorageValue<_, Vec<T::ValidatorId>, ValueQuery>;
#[pallet::call]
impl<T: Config> Pallet<T> {
/// Add new validators to the set.
///
/// The new validators will be active from current session + 2.
#[pallet::call_index(0)]
#[pallet::weight({100_000})]
pub fn register_validators(
origin: OriginFor<T>,
validators: Vec<T::ValidatorId>,
) -> DispatchResult {
T::PrivilegedOrigin::ensure_origin(origin)?;
validators.clone().into_iter().for_each(|v| ValidatorsToAdd::<T>::append(v));
Self::deposit_event(Event::ValidatorsRegistered(validators));
Ok(())
}
/// Remove validators from the set.
///
/// The removed validators will be deactivated from current session + 2.
#[pallet::call_index(1)]
#[pallet::weight({100_000})]
pub fn deregister_validators(
origin: OriginFor<T>,
validators: Vec<T::ValidatorId>,
) -> DispatchResult {
T::PrivilegedOrigin::ensure_origin(origin)?;
validators.clone().into_iter().for_each(|v| ValidatorsToRetire::<T>::append(v));
Self::deposit_event(Event::ValidatorsDeregistered(validators));
Ok(())
}
}
}
impl<T: Config> pallet_session::SessionManager<T::ValidatorId> for Pallet<T> {
fn new_session(new_index: SessionIndex) -> Option<Vec<T::ValidatorId>> {
if new_index <= 1 {
return None;
}
let mut validators = Session::<T>::validators();
ValidatorsToRetire::<T>::take().iter().for_each(|v| {
if let Some(pos) = validators.iter().position(|r| r == v) {
validators.swap_remove(pos);
}
});
ValidatorsToAdd::<T>::take().into_iter().for_each(|v| {
if !validators.contains(&v) {
validators.push(v);
}
});
Some(validators)
}
fn end_session(_: SessionIndex) {}
fn start_session(_start_index: SessionIndex) {}
}
impl<T: Config> pallet_session::historical::SessionManager<T::ValidatorId, ()> for Pallet<T> {
fn new_session(new_index: SessionIndex) -> Option<Vec<(T::ValidatorId, ())>> {
<Self as pallet_session::SessionManager<_>>::new_session(new_index)
.map(|r| r.into_iter().map(|v| (v, Default::default())).collect())
}
fn start_session(start_index: SessionIndex) {
<Self as pallet_session::SessionManager<_>>::start_session(start_index)
}
fn end_session(end_index: SessionIndex) {
<Self as pallet_session::SessionManager<_>>::end_session(end_index)
}
}
@@ -0,0 +1,109 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `frame_benchmarking::baseline`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=frame_benchmarking::baseline
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `frame_benchmarking::baseline`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_benchmarking::baseline::WeightInfo for WeightInfo<T> {
/// The range of component `i` is `[0, 1000000]`.
fn addition(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 173_000 picoseconds.
Weight::from_parts(222_892, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 1000000]`.
fn subtraction(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 169_000 picoseconds.
Weight::from_parts(222_168, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 1000000]`.
fn multiplication(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 169_000 picoseconds.
Weight::from_parts(223_087, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 1000000]`.
fn division(_i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 168_000 picoseconds.
Weight::from_parts(213_881, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn hashing() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 23_455_147_000 picoseconds.
Weight::from_parts(23_482_871_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `i` is `[0, 100]`.
fn sr25519_verification(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 218_000 picoseconds.
Weight::from_parts(4_844_185, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 5_976
.saturating_add(Weight::from_parts(41_000_340, 0).saturating_mul(i.into()))
}
}
@@ -0,0 +1,172 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `frame_system`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=frame_system
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `frame_system`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_system::WeightInfo for WeightInfo<T> {
/// The range of component `b` is `[0, 3932160]`.
fn remark(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_123_000 picoseconds.
Weight::from_parts(2_269_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 122
.saturating_add(Weight::from_parts(10_875, 0).saturating_mul(b.into()))
}
/// The range of component `b` is `[0, 3932160]`.
fn remark_with_event(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_077_000 picoseconds.
Weight::from_parts(6_283_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 124
.saturating_add(Weight::from_parts(12_278, 0).saturating_mul(b.into()))
}
/// Storage: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a686561707061676573` (r:0 w:1)
fn set_heap_pages() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_563_000 picoseconds.
Weight::from_parts(3_736_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
fn set_code() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `67035`
// Minimum execution time: 161_249_913_000 picoseconds.
Weight::from_parts(163_979_962_000, 0)
.saturating_add(Weight::from_parts(0, 67035))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `i` is `[0, 1000]`.
fn set_storage(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_211_000 picoseconds.
Weight::from_parts(2_330_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 2_482
.saturating_add(Weight::from_parts(730_029, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into())))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `i` is `[0, 1000]`.
fn kill_storage(i: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_188_000 picoseconds.
Weight::from_parts(2_260_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 867
.saturating_add(Weight::from_parts(550_426, 0).saturating_mul(i.into()))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into())))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `p` is `[0, 1000]`.
fn kill_prefix(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `80 + p * (69 ±0)`
// Estimated: `82 + p * (70 ±0)`
// Minimum execution time: 4_311_000 picoseconds.
Weight::from_parts(4_421_000, 0)
.saturating_add(Weight::from_parts(0, 82))
// Standard Error: 1_436
.saturating_add(Weight::from_parts(1_323_523, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(p.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(p.into())))
.saturating_add(Weight::from_parts(0, 70).saturating_mul(p.into()))
}
/// Storage: `System::AuthorizedUpgrade` (r:0 w:1)
/// Proof: `System::AuthorizedUpgrade` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`)
fn authorize_upgrade() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 11_048_000 picoseconds.
Weight::from_parts(12_802_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::AuthorizedUpgrade` (r:1 w:1)
/// Proof: `System::AuthorizedUpgrade` (`max_values`: Some(1), `max_size`: Some(33), added: 528, mode: `MaxEncodedLen`)
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a636f6465` (r:0 w:1)
fn apply_authorized_upgrade() -> Weight {
// Proof Size summary in bytes:
// Measured: `26`
// Estimated: `67035`
// Minimum execution time: 164_430_843_000 picoseconds.
Weight::from_parts(167_377_634_000, 0)
.saturating_add(Weight::from_parts(0, 67035))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
}
@@ -0,0 +1,130 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `frame_system_extensions`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=frame_system_extensions
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `frame_system_extensions`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> frame_system::ExtensionsWeightInfo for WeightInfo<T> {
fn check_genesis() -> Weight {
// Proof Size summary in bytes:
// Measured: `30`
// Estimated: `0`
// Minimum execution time: 3_553_000 picoseconds.
Weight::from_parts(3_745_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn check_mortality_mortal_transaction() -> Weight {
// Proof Size summary in bytes:
// Measured: `68`
// Estimated: `0`
// Minimum execution time: 6_521_000 picoseconds.
Weight::from_parts(6_806_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn check_mortality_immortal_transaction() -> Weight {
// Proof Size summary in bytes:
// Measured: `68`
// Estimated: `0`
// Minimum execution time: 6_382_000 picoseconds.
Weight::from_parts(6_642_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn check_non_zero_sender() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 527_000 picoseconds.
Weight::from_parts(580_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn check_nonce() -> Weight {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
// Minimum execution time: 6_851_000 picoseconds.
Weight::from_parts(7_142_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
fn check_spec_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 442_000 picoseconds.
Weight::from_parts(508_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn check_tx_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 400_000 picoseconds.
Weight::from_parts(479_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn check_weight() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_811_000 picoseconds.
Weight::from_parts(4_002_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn weight_reclaim() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_211_000 picoseconds.
Weight::from_parts(2_338_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
@@ -0,0 +1,57 @@
// 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.
//! A list of the different weight modules for our runtime.
pub mod frame_system;
pub mod frame_system_extensions;
pub mod pallet_balances_balances;
pub mod pallet_beefy_mmr;
pub mod pallet_conviction_voting;
pub mod pallet_indices;
pub mod pallet_message_queue;
pub mod pallet_migrations;
pub mod pallet_mmr;
pub mod pallet_multisig;
pub mod pallet_parameters;
pub mod pallet_preimage;
pub mod pallet_proxy;
pub mod pallet_referenda_referenda;
pub mod pallet_scheduler;
pub mod pallet_session;
pub mod pallet_sudo;
pub mod pallet_timestamp;
pub mod pallet_transaction_payment;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
pub mod pallet_whitelist;
pub mod pallet_xcm;
pub mod pezkuwi_runtime_common_assigned_slots;
pub mod pezkuwi_runtime_common_auctions;
pub mod pezkuwi_runtime_common_claims;
pub mod pezkuwi_runtime_common_crowdloan;
pub mod pezkuwi_runtime_common_paras_registrar;
pub mod pezkuwi_runtime_common_slots;
pub mod pezkuwi_runtime_teyrchains_configuration;
pub mod pezkuwi_runtime_teyrchains_coretime;
pub mod pezkuwi_runtime_teyrchains_disputes;
pub mod pezkuwi_runtime_teyrchains_hrmp;
pub mod pezkuwi_runtime_teyrchains_inclusion;
pub mod pezkuwi_runtime_teyrchains_initializer;
pub mod pezkuwi_runtime_teyrchains_on_demand;
pub mod pezkuwi_runtime_teyrchains_paras;
pub mod pezkuwi_runtime_teyrchains_paras_inherent;
pub mod xcm;
@@ -0,0 +1,179 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_balances`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_balances
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_balances`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_balances::WeightInfo for WeightInfo<T> {
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn transfer_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
// Minimum execution time: 50_406_000 picoseconds.
Weight::from_parts(51_633_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn transfer_keep_alive() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
// Minimum execution time: 39_512_000 picoseconds.
Weight::from_parts(40_179_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn force_set_balance_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `174`
// Estimated: `3593`
// Minimum execution time: 15_723_000 picoseconds.
Weight::from_parts(16_200_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn force_set_balance_killing() -> Weight {
// Proof Size summary in bytes:
// Measured: `174`
// Estimated: `3593`
// Minimum execution time: 23_197_000 picoseconds.
Weight::from_parts(24_047_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn force_transfer() -> Weight {
// Proof Size summary in bytes:
// Measured: `103`
// Estimated: `6196`
// Minimum execution time: 52_821_000 picoseconds.
Weight::from_parts(54_074_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn transfer_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
// Minimum execution time: 49_164_000 picoseconds.
Weight::from_parts(50_996_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn force_unreserve() -> Weight {
// Proof Size summary in bytes:
// Measured: `174`
// Estimated: `3593`
// Minimum execution time: 18_865_000 picoseconds.
Weight::from_parts(19_389_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:999 w:999)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `u` is `[1, 1000]`.
/// The range of component `u` is `[1, 1000]`.
fn upgrade_accounts(u: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + u * (135 ±0)`
// Estimated: `990 + u * (2603 ±0)`
// Minimum execution time: 17_271_000 picoseconds.
Weight::from_parts(17_803_000, 0)
.saturating_add(Weight::from_parts(0, 990))
// Standard Error: 12_308
.saturating_add(Weight::from_parts(15_103_184, 0).saturating_mul(u.into()))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(u.into())))
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(u.into()))
}
fn force_adjust_total_issuance() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 6_621_000 picoseconds.
Weight::from_parts(6_958_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn burn_allow_death() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 31_019_000 picoseconds.
Weight::from_parts(32_086_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn burn_keep_alive() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 21_242_000 picoseconds.
Weight::from_parts(22_146_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
@@ -0,0 +1,103 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_beefy_mmr`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_beefy_mmr
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_beefy_mmr`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_beefy_mmr::WeightInfo for WeightInfo<T> {
/// The range of component `n` is `[2, 512]`.
fn n_leafs_proof_is_optimal(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 678_000 picoseconds.
Weight::from_parts(1_212_467, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 68
.saturating_add(Weight::from_parts(1_684, 0).saturating_mul(n.into()))
}
/// Storage: `System::BlockHash` (r:1 w:0)
/// Proof: `System::BlockHash` (`max_values`: None, `max_size`: Some(44), added: 2519, mode: `MaxEncodedLen`)
fn extract_validation_context() -> Weight {
// Proof Size summary in bytes:
// Measured: `68`
// Estimated: `3509`
// Minimum execution time: 6_169_000 picoseconds.
Weight::from_parts(6_483_000, 0)
.saturating_add(Weight::from_parts(0, 3509))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: `Mmr::Nodes` (r:1 w:0)
/// Proof: `Mmr::Nodes` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
fn read_peak() -> Weight {
// Proof Size summary in bytes:
// Measured: `254`
// Estimated: `3505`
// Minimum execution time: 6_311_000 picoseconds.
Weight::from_parts(6_506_000, 0)
.saturating_add(Weight::from_parts(0, 3505))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: `Mmr::RootHash` (r:1 w:0)
/// Proof: `Mmr::RootHash` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
/// Storage: `Mmr::NumberOfLeaves` (r:1 w:0)
/// Proof: `Mmr::NumberOfLeaves` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// The range of component `n` is `[2, 512]`.
fn n_items_proof_is_non_canonical(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `246`
// Estimated: `1517`
// Minimum execution time: 12_425_000 picoseconds.
Weight::from_parts(20_442_969, 0)
.saturating_add(Weight::from_parts(0, 1517))
// Standard Error: 1_942
.saturating_add(Weight::from_parts(1_372_433, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(2))
}
}
@@ -0,0 +1,204 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_conviction_voting`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_conviction_voting
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_conviction_voting`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_conviction_voting::WeightInfo for WeightInfo<T> {
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `ConvictionVoting::VotingFor` (r:1 w:1)
/// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`)
/// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1)
/// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(311), added: 2786, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn vote_new() -> Weight {
// Proof Size summary in bytes:
// Measured: `13408`
// Estimated: `42428`
// Minimum execution time: 152_060_000 picoseconds.
Weight::from_parts(162_731_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `ConvictionVoting::VotingFor` (r:1 w:1)
/// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`)
/// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1)
/// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(311), added: 2786, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn vote_existing() -> Weight {
// Proof Size summary in bytes:
// Measured: `14129`
// Estimated: `83866`
// Minimum execution time: 176_385_000 picoseconds.
Weight::from_parts(184_428_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(7))
}
/// Storage: `ConvictionVoting::VotingFor` (r:1 w:1)
/// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`)
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn remove_vote() -> Weight {
// Proof Size summary in bytes:
// Measured: `13919`
// Estimated: `83866`
// Minimum execution time: 142_873_000 picoseconds.
Weight::from_parts(150_271_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `ConvictionVoting::VotingFor` (r:1 w:1)
/// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`)
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
fn remove_other_vote() -> Weight {
// Proof Size summary in bytes:
// Measured: `13005`
// Estimated: `30706`
// Minimum execution time: 79_946_000 picoseconds.
Weight::from_parts(83_518_000, 0)
.saturating_add(Weight::from_parts(0, 30706))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `ConvictionVoting::VotingFor` (r:2 w:2)
/// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`)
/// Storage: `Referenda::ReferendumInfoFor` (r:512 w:512)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1)
/// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(311), added: 2786, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:50)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// The range of component `r` is `[0, 512]`.
fn delegate(r: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `29603 + r * (365 ±0)`
// Estimated: `83866 + r * (3411 ±0)`
// Minimum execution time: 67_979_000 picoseconds.
Weight::from_parts(895_607_514, 0)
.saturating_add(Weight::from_parts(0, 83866))
// Standard Error: 65_064
.saturating_add(Weight::from_parts(21_549_011, 0).saturating_mul(r.into()))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into())))
.saturating_add(T::DbWeight::get().writes(45))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into())))
.saturating_add(Weight::from_parts(0, 3411).saturating_mul(r.into()))
}
/// Storage: `ConvictionVoting::VotingFor` (r:2 w:2)
/// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`)
/// Storage: `Referenda::ReferendumInfoFor` (r:512 w:512)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:50)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// The range of component `r` is `[0, 512]`.
fn undelegate(r: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `29556 + r * (365 ±0)`
// Estimated: `83866 + r * (3411 ±0)`
// Minimum execution time: 40_027_000 picoseconds.
Weight::from_parts(811_699_645, 0)
.saturating_add(Weight::from_parts(0, 83866))
// Standard Error: 60_140
.saturating_add(Weight::from_parts(21_801_527, 0).saturating_mul(r.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(r.into())))
.saturating_add(T::DbWeight::get().writes(43))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(r.into())))
.saturating_add(Weight::from_parts(0, 3411).saturating_mul(r.into()))
}
/// Storage: `ConvictionVoting::VotingFor` (r:1 w:1)
/// Proof: `ConvictionVoting::VotingFor` (`max_values`: None, `max_size`: Some(27241), added: 29716, mode: `MaxEncodedLen`)
/// Storage: `ConvictionVoting::ClassLocksFor` (r:1 w:1)
/// Proof: `ConvictionVoting::ClassLocksFor` (`max_values`: None, `max_size`: Some(311), added: 2786, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
fn unlock() -> Weight {
// Proof Size summary in bytes:
// Measured: `12180`
// Estimated: `30706`
// Minimum execution time: 102_112_000 picoseconds.
Weight::from_parts(107_265_000, 0)
.saturating_add(Weight::from_parts(0, 30706))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
}
@@ -0,0 +1,130 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_indices`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_indices
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_indices`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_indices::WeightInfo for WeightInfo<T> {
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn claim() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3534`
// Minimum execution time: 22_587_000 picoseconds.
Weight::from_parts(23_441_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn transfer() -> Weight {
// Proof Size summary in bytes:
// Measured: `203`
// Estimated: `3593`
// Minimum execution time: 35_007_000 picoseconds.
Weight::from_parts(36_135_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn free() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 23_448_000 picoseconds.
Weight::from_parts(24_791_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn force_transfer() -> Weight {
// Proof Size summary in bytes:
// Measured: `203`
// Estimated: `3593`
// Minimum execution time: 25_753_000 picoseconds.
Weight::from_parts(26_682_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn freeze() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 26_420_000 picoseconds.
Weight::from_parts(27_307_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Indices::Accounts` (r:1 w:1)
/// Proof: `Indices::Accounts` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`)
fn poke_deposit() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3534`
// Minimum execution time: 23_290_000 picoseconds.
Weight::from_parts(24_217_000, 0)
.saturating_add(Weight::from_parts(0, 3534))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,213 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_message_queue`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_message_queue
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_message_queue`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_message_queue::WeightInfo for WeightInfo<T> {
/// Storage: `MessageQueue::ServiceHead` (r:1 w:0)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(6), added: 501, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::BookStateFor` (r:2 w:2)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
fn ready_ring_knit() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `6050`
// Minimum execution time: 13_997_000 picoseconds.
Weight::from_parts(14_511_000, 0)
.saturating_add(Weight::from_parts(0, 6050))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `MessageQueue::BookStateFor` (r:2 w:2)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(6), added: 501, mode: `MaxEncodedLen`)
fn ready_ring_unknit() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `6050`
// Minimum execution time: 12_624_000 picoseconds.
Weight::from_parts(13_092_000, 0)
.saturating_add(Weight::from_parts(0, 6050))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
fn service_queue_base() -> Weight {
// Proof Size summary in bytes:
// Measured: `42`
// Estimated: `3520`
// Minimum execution time: 5_156_000 picoseconds.
Weight::from_parts(5_347_000, 0)
.saturating_add(Weight::from_parts(0, 3520))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(32818), added: 35293, mode: `MaxEncodedLen`)
fn service_page_base_completion() -> Weight {
// Proof Size summary in bytes:
// Measured: `115`
// Estimated: `36283`
// Minimum execution time: 7_373_000 picoseconds.
Weight::from_parts(7_708_000, 0)
.saturating_add(Weight::from_parts(0, 36283))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(32818), added: 35293, mode: `MaxEncodedLen`)
fn service_page_base_no_completion() -> Weight {
// Proof Size summary in bytes:
// Measured: `115`
// Estimated: `36283`
// Minimum execution time: 7_616_000 picoseconds.
Weight::from_parts(7_844_000, 0)
.saturating_add(Weight::from_parts(0, 36283))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MessageQueue::BookStateFor` (r:0 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:0 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(32818), added: 35293, mode: `MaxEncodedLen`)
fn service_page_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 81_916_000 picoseconds.
Weight::from_parts(84_364_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `MessageQueue::ServiceHead` (r:1 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(6), added: 501, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::BookStateFor` (r:1 w:0)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
fn bump_service_head() -> Weight {
// Proof Size summary in bytes:
// Measured: `220`
// Estimated: `3520`
// Minimum execution time: 8_966_000 picoseconds.
Weight::from_parts(9_192_000, 0)
.saturating_add(Weight::from_parts(0, 3520))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:0)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::ServiceHead` (r:0 w:1)
/// Proof: `MessageQueue::ServiceHead` (`max_values`: Some(1), `max_size`: Some(6), added: 501, mode: `MaxEncodedLen`)
fn set_service_head() -> Weight {
// Proof Size summary in bytes:
// Measured: `220`
// Estimated: `3520`
// Minimum execution time: 7_678_000 picoseconds.
Weight::from_parts(8_082_000, 0)
.saturating_add(Weight::from_parts(0, 3520))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(32818), added: 35293, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Storage: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
/// Proof: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
fn reap_page() -> Weight {
// Proof Size summary in bytes:
// Measured: `32945`
// Estimated: `36283`
// Minimum execution time: 42_796_000 picoseconds.
Weight::from_parts(43_804_000, 0)
.saturating_add(Weight::from_parts(0, 36283))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(32818), added: 35293, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Storage: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
/// Proof: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
fn execute_overweight_page_removed() -> Weight {
// Proof Size summary in bytes:
// Measured: `32945`
// Estimated: `36283`
// Minimum execution time: 53_889_000 picoseconds.
Weight::from_parts(54_749_000, 0)
.saturating_add(Weight::from_parts(0, 36283))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:1 w:1)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(32818), added: 35293, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Storage: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
/// Proof: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
fn execute_overweight_page_updated() -> Weight {
// Proof Size summary in bytes:
// Measured: `32945`
// Estimated: `36283`
// Minimum execution time: 76_298_000 picoseconds.
Weight::from_parts(77_776_000, 0)
.saturating_add(Weight::from_parts(0, 36283))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(4))
}
}
@@ -0,0 +1,225 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_migrations`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_migrations
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_migrations`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_migrations::WeightInfo for WeightInfo<T> {
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:1)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
fn onboard_new_mbms() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `67035`
// Minimum execution time: 8_067_000 picoseconds.
Weight::from_parts(8_622_000, 0)
.saturating_add(Weight::from_parts(0, 67035))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn progress_mbms_none() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `67035`
// Minimum execution time: 2_137_000 picoseconds.
Weight::from_parts(2_248_000, 0)
.saturating_add(Weight::from_parts(0, 67035))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn exec_migration_completed() -> Weight {
// Proof Size summary in bytes:
// Measured: `96`
// Estimated: `3561`
// Minimum execution time: 6_390_000 picoseconds.
Weight::from_parts(6_783_000, 0)
.saturating_add(Weight::from_parts(0, 3561))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Storage: `MultiBlockMigrations::Historic` (r:1 w:0)
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_skipped_historic() -> Weight {
// Proof Size summary in bytes:
// Measured: `154`
// Estimated: `3731`
// Minimum execution time: 11_465_000 picoseconds.
Weight::from_parts(11_825_000, 0)
.saturating_add(Weight::from_parts(0, 3731))
.saturating_add(T::DbWeight::get().reads(2))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Storage: `MultiBlockMigrations::Historic` (r:1 w:0)
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_advance() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3731`
// Minimum execution time: 10_680_000 picoseconds.
Weight::from_parts(11_162_000, 0)
.saturating_add(Weight::from_parts(0, 3731))
.saturating_add(T::DbWeight::get().reads(2))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Storage: `MultiBlockMigrations::Historic` (r:1 w:1)
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
fn exec_migration_complete() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3731`
// Minimum execution time: 12_344_000 picoseconds.
Weight::from_parts(12_664_000, 0)
.saturating_add(Weight::from_parts(0, 3731))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Storage: `MultiBlockMigrations::Historic` (r:1 w:0)
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn exec_migration_fail() -> Weight {
// Proof Size summary in bytes:
// Measured: `100`
// Estimated: `3731`
// Minimum execution time: 13_460_000 picoseconds.
Weight::from_parts(13_714_000, 0)
.saturating_add(Weight::from_parts(0, 3731))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
fn on_init_loop() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 211_000 picoseconds.
Weight::from_parts(246_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn force_set_cursor() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_673_000 picoseconds.
Weight::from_parts(2_962_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:0 w:1)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
fn force_set_active_cursor() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_177_000 picoseconds.
Weight::from_parts(3_369_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `MultiBlockMigrations::Cursor` (r:1 w:0)
/// Proof: `MultiBlockMigrations::Cursor` (`max_values`: Some(1), `max_size`: Some(65550), added: 66045, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
/// Proof: UNKNOWN KEY `0x583359fe0e84d953a9dd84e8addb08a5` (r:1 w:0)
fn force_onboard_mbms() -> Weight {
// Proof Size summary in bytes:
// Measured: `76`
// Estimated: `67035`
// Minimum execution time: 5_731_000 picoseconds.
Weight::from_parts(5_965_000, 0)
.saturating_add(Weight::from_parts(0, 67035))
.saturating_add(T::DbWeight::get().reads(2))
}
/// Storage: `MultiBlockMigrations::Historic` (r:256 w:256)
/// Proof: `MultiBlockMigrations::Historic` (`max_values`: None, `max_size`: Some(266), added: 2741, mode: `MaxEncodedLen`)
/// The range of component `n` is `[0, 256]`.
fn clear_historic(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `984 + n * (271 ±0)`
// Estimated: `3834 + n * (2740 ±0)`
// Minimum execution time: 16_687_000 picoseconds.
Weight::from_parts(14_511_109, 0)
.saturating_add(Weight::from_parts(0, 3834))
// Standard Error: 3_316
.saturating_add(Weight::from_parts(1_480_963, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 2740).saturating_mul(n.into()))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `n` is `[0, 2048]`.
fn reset_pallet_migration(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1676 + n * (38 ±0)`
// Estimated: `754 + n * (39 ±0)`
// Minimum execution time: 1_992_000 picoseconds.
Weight::from_parts(9_901_880, 0)
.saturating_add(Weight::from_parts(0, 754))
// Standard Error: 1_616
.saturating_add(Weight::from_parts(849_031, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 39).saturating_mul(n.into()))
}
}
@@ -0,0 +1,82 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_mmr`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_mmr
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_mmr`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_mmr::WeightInfo for WeightInfo<T> {
/// Storage: `Mmr::NumberOfLeaves` (r:1 w:1)
/// Proof: `Mmr::NumberOfLeaves` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `System::ParentHash` (r:1 w:0)
/// Proof: `System::ParentHash` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
/// Storage: `Paras::Heads` (r:1025 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `MmrLeaf::BeefyNextAuthorities` (r:1 w:0)
/// Proof: `MmrLeaf::BeefyNextAuthorities` (`max_values`: Some(1), `max_size`: Some(44), added: 539, mode: `MaxEncodedLen`)
/// Storage: `Mmr::Nodes` (r:7 w:1)
/// Proof: `Mmr::Nodes` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
/// Storage: `Mmr::UseLocalStorage` (r:1 w:0)
/// Proof: `Mmr::UseLocalStorage` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`)
/// Storage: `Mmr::RootHash` (r:0 w:1)
/// Proof: `Mmr::RootHash` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
/// The range of component `x` is `[1, 1000]`.
fn on_initialize(x: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1071107`
// Estimated: `3608956 + x * (8 ±0)`
// Minimum execution time: 9_272_249_000 picoseconds.
Weight::from_parts(9_430_037_507, 0)
.saturating_add(Weight::from_parts(0, 3608956))
// Standard Error: 3_766
.saturating_add(Weight::from_parts(86_999, 0).saturating_mul(x.into()))
.saturating_add(T::DbWeight::get().reads(1032))
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(Weight::from_parts(0, 8).saturating_mul(x.into()))
}
}
@@ -0,0 +1,181 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_multisig`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-25, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `c8c7296f7413`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_multisig
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_multisig`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
/// The range of component `z` is `[0, 10000]`.
fn as_multi_threshold_1(z: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 16_031_000 picoseconds.
Weight::from_parts(16_334_237, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 27
.saturating_add(Weight::from_parts(655, 0).saturating_mul(z.into()))
}
/// Storage: `Multisig::Multisigs` (r:1 w:1)
/// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3346), added: 5821, mode: `MaxEncodedLen`)
/// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`.
fn as_multi_create(s: u32, z: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `229 + s * (2 ±0)`
// Estimated: `6811`
// Minimum execution time: 47_422_000 picoseconds.
Weight::from_parts(34_453_063, 0)
.saturating_add(Weight::from_parts(0, 6811))
// Standard Error: 3_967
.saturating_add(Weight::from_parts(149_468, 0).saturating_mul(s.into()))
// Standard Error: 38
.saturating_add(Weight::from_parts(2_115, 0).saturating_mul(z.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Multisig::Multisigs` (r:1 w:1)
/// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3346), added: 5821, mode: `MaxEncodedLen`)
/// The range of component `s` is `[3, 100]`.
/// The range of component `z` is `[0, 10000]`.
fn as_multi_approve(s: u32, z: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `248`
// Estimated: `6811`
// Minimum execution time: 32_443_000 picoseconds.
Weight::from_parts(20_948_248, 0)
.saturating_add(Weight::from_parts(0, 6811))
// Standard Error: 2_516
.saturating_add(Weight::from_parts(134_093, 0).saturating_mul(s.into()))
// Standard Error: 24
.saturating_add(Weight::from_parts(1_905, 0).saturating_mul(z.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Multisig::Multisigs` (r:1 w:1)
/// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3346), added: 5821, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `s` is `[2, 100]`.
/// The range of component `z` is `[0, 10000]`.
fn as_multi_complete(s: u32, z: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `354 + s * (33 ±0)`
// Estimated: `6811`
// Minimum execution time: 53_028_000 picoseconds.
Weight::from_parts(23_678_558, 0)
.saturating_add(Weight::from_parts(0, 6811))
// Standard Error: 6_864
.saturating_add(Weight::from_parts(300_804, 0).saturating_mul(s.into()))
// Standard Error: 67
.saturating_add(Weight::from_parts(3_380, 0).saturating_mul(z.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Multisig::Multisigs` (r:1 w:1)
/// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3346), added: 5821, mode: `MaxEncodedLen`)
/// The range of component `s` is `[2, 100]`.
fn approve_as_multi_create(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `229 + s * (2 ±0)`
// Estimated: `6811`
// Minimum execution time: 31_551_000 picoseconds.
Weight::from_parts(33_991_440, 0)
.saturating_add(Weight::from_parts(0, 6811))
// Standard Error: 2_114
.saturating_add(Weight::from_parts(123_260, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Multisig::Multisigs` (r:1 w:1)
/// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3346), added: 5821, mode: `MaxEncodedLen`)
/// The range of component `s` is `[2, 100]`.
fn approve_as_multi_approve(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `248`
// Estimated: `6811`
// Minimum execution time: 17_063_000 picoseconds.
Weight::from_parts(17_667_306, 0)
.saturating_add(Weight::from_parts(0, 6811))
// Standard Error: 1_384
.saturating_add(Weight::from_parts(146_228, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Multisig::Multisigs` (r:1 w:1)
/// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3346), added: 5821, mode: `MaxEncodedLen`)
/// The range of component `s` is `[2, 100]`.
fn cancel_as_multi(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `420 + s * (1 ±0)`
// Estimated: `6811`
// Minimum execution time: 31_979_000 picoseconds.
Weight::from_parts(35_042_991, 0)
.saturating_add(Weight::from_parts(0, 6811))
// Standard Error: 3_858
.saturating_add(Weight::from_parts(163_176, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Multisig::Multisigs` (r:1 w:1)
/// Proof: `Multisig::Multisigs` (`max_values`: None, `max_size`: Some(3346), added: 5821, mode: `MaxEncodedLen`)
/// The range of component `s` is `[2, 100]`.
fn poke_deposit(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `420 + s * (1 ±0)`
// Estimated: `6811`
// Minimum execution time: 30_328_000 picoseconds.
Weight::from_parts(34_135_440, 0)
.saturating_add(Weight::from_parts(0, 6811))
// Standard Error: 4_398
.saturating_add(Weight::from_parts(161_074, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,66 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_parameters`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_parameters
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_parameters`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_parameters::WeightInfo for WeightInfo<T> {
/// Storage: `Parameters::Parameters` (r:1 w:1)
/// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
fn set_parameter() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3501`
// Minimum execution time: 8_947_000 picoseconds.
Weight::from_parts(9_434_000, 0)
.saturating_add(Weight::from_parts(0, 3501))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,274 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_preimage`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_preimage
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_preimage`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_preimage::WeightInfo for WeightInfo<T> {
/// 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`)
/// Storage: `Parameters::Parameters` (r:2 w:0)
/// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(103), added: 2578, mode: `MaxEncodedLen`)
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 4194304]`.
fn note_preimage(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `45`
// Estimated: `6012`
// Minimum execution time: 53_899_000 picoseconds.
Weight::from_parts(54_621_000, 0)
.saturating_add(Weight::from_parts(0, 6012))
// Standard Error: 130
.saturating_add(Weight::from_parts(13_753, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// 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`)
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 4194304]`.
fn note_requested_preimage(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `105`
// Estimated: `3556`
// Minimum execution time: 17_297_000 picoseconds.
Weight::from_parts(17_779_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
// Standard Error: 133
.saturating_add(Weight::from_parts(13_695, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// 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`)
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 4194304]`.
fn note_no_deposit_preimage(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `105`
// Estimated: `3556`
// Minimum execution time: 16_666_000 picoseconds.
Weight::from_parts(16_886_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
// Standard Error: 133
.saturating_add(Weight::from_parts(13_719, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// 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`)
/// Storage: `Balances::Holds` (r:1 w:1)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(103), added: 2578, mode: `MaxEncodedLen`)
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
fn unnote_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `242`
// Estimated: `3568`
// Minimum execution time: 58_837_000 picoseconds.
Weight::from_parts(62_730_000, 0)
.saturating_add(Weight::from_parts(0, 3568))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// 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`)
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
fn unnote_no_deposit_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `143`
// Estimated: `3556`
// Minimum execution time: 29_826_000 picoseconds.
Weight::from_parts(32_245_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// 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 request_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `187`
// Estimated: `3556`
// Minimum execution time: 23_613_000 picoseconds.
Weight::from_parts(29_331_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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 request_no_deposit_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `143`
// Estimated: `3556`
// Minimum execution time: 17_098_000 picoseconds.
Weight::from_parts(20_367_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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 request_unnoted_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `41`
// Estimated: `3556`
// Minimum execution time: 17_049_000 picoseconds.
Weight::from_parts(18_673_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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 request_requested_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `105`
// Estimated: `3556`
// Minimum execution time: 11_900_000 picoseconds.
Weight::from_parts(12_500_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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`)
/// Storage: `Preimage::PreimageFor` (r:0 w:1)
/// Proof: `Preimage::PreimageFor` (`max_values`: None, `max_size`: Some(4194344), added: 4196819, mode: `MaxEncodedLen`)
fn unrequest_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `143`
// Estimated: `3556`
// Minimum execution time: 25_863_000 picoseconds.
Weight::from_parts(28_230_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// 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 unrequest_unnoted_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `105`
// Estimated: `3556`
// Minimum execution time: 11_962_000 picoseconds.
Weight::from_parts(13_250_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// 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 unrequest_multi_referenced_preimage() -> Weight {
// Proof Size summary in bytes:
// Measured: `105`
// Estimated: `3556`
// Minimum execution time: 11_656_000 picoseconds.
Weight::from_parts(12_846_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Preimage::StatusFor` (r:1023 w:1023)
/// Proof: `Preimage::StatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1023 w:1023)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Parameters::Parameters` (r:2 w:0)
/// Proof: `Parameters::Parameters` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Balances::Holds` (r:1023 w:1023)
/// Proof: `Balances::Holds` (`max_values`: None, `max_size`: Some(103), added: 2578, mode: `MaxEncodedLen`)
/// Storage: `Preimage::RequestStatusFor` (r:0 w:1023)
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// The range of component `n` is `[1, 1024]`.
fn ensure_updated(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0 + n * (227 ±0)`
// Estimated: `6012 + n * (2603 ±0)`
// Minimum execution time: 61_032_000 picoseconds.
Weight::from_parts(63_195_000, 0)
.saturating_add(Weight::from_parts(0, 6012))
// Standard Error: 51_433
.saturating_add(Weight::from_parts(57_910_931, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 2603).saturating_mul(n.into()))
}
}
@@ -0,0 +1,243 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_proxy`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-03-04, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `99fc4dfa9c86`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_proxy
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_proxy`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
/// Storage: `Proxy::Proxies` (r:1 w:0)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// The range of component `p` is `[1, 31]`.
fn proxy(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `89 + p * (37 ±0)`
// Estimated: `4706`
// Minimum execution time: 13_806_000 picoseconds.
Weight::from_parts(14_554_351, 0)
.saturating_add(Weight::from_parts(0, 4706))
// Standard Error: 1_532
.saturating_add(Weight::from_parts(34_377, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: `Proxy::Proxies` (r:1 w:0)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// Storage: `Proxy::Announcements` (r:1 w:1)
/// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2233), added: 4708, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `a` is `[0, 31]`.
/// The range of component `p` is `[1, 31]`.
fn proxy_announced(a: u32, p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `416 + a * (68 ±0) + p * (37 ±0)`
// Estimated: `5698`
// Minimum execution time: 37_228_000 picoseconds.
Weight::from_parts(38_313_529, 0)
.saturating_add(Weight::from_parts(0, 5698))
// Standard Error: 2_504
.saturating_add(Weight::from_parts(152_320, 0).saturating_mul(a.into()))
// Standard Error: 2_587
.saturating_add(Weight::from_parts(31_543, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Proxy::Announcements` (r:1 w:1)
/// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2233), added: 4708, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `a` is `[0, 31]`.
/// The range of component `p` is `[1, 31]`.
fn remove_announcement(a: u32, p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `331 + a * (68 ±0)`
// Estimated: `5698`
// Minimum execution time: 25_166_000 picoseconds.
Weight::from_parts(26_418_176, 0)
.saturating_add(Weight::from_parts(0, 5698))
// Standard Error: 2_246
.saturating_add(Weight::from_parts(153_564, 0).saturating_mul(a.into()))
// Standard Error: 2_320
.saturating_add(Weight::from_parts(4_962, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Proxy::Announcements` (r:1 w:1)
/// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2233), added: 4708, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `a` is `[0, 31]`.
/// The range of component `p` is `[1, 31]`.
fn reject_announcement(a: u32, p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `331 + a * (68 ±0)`
// Estimated: `5698`
// Minimum execution time: 25_037_000 picoseconds.
Weight::from_parts(26_468_002, 0)
.saturating_add(Weight::from_parts(0, 5698))
// Standard Error: 2_411
.saturating_add(Weight::from_parts(143_670, 0).saturating_mul(a.into()))
// Standard Error: 2_491
.saturating_add(Weight::from_parts(6_595, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Proxy::Proxies` (r:1 w:0)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// Storage: `Proxy::Announcements` (r:1 w:1)
/// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2233), added: 4708, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `a` is `[0, 31]`.
/// The range of component `p` is `[1, 31]`.
fn announce(a: u32, p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `348 + a * (68 ±0) + p * (37 ±0)`
// Estimated: `5698`
// Minimum execution time: 33_282_000 picoseconds.
Weight::from_parts(34_525_175, 0)
.saturating_add(Weight::from_parts(0, 5698))
// Standard Error: 2_568
.saturating_add(Weight::from_parts(153_824, 0).saturating_mul(a.into()))
// Standard Error: 2_654
.saturating_add(Weight::from_parts(32_899, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Proxy::Proxies` (r:1 w:1)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// The range of component `p` is `[1, 31]`.
fn add_proxy(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `89 + p * (37 ±0)`
// Estimated: `4706`
// Minimum execution time: 23_623_000 picoseconds.
Weight::from_parts(24_796_223, 0)
.saturating_add(Weight::from_parts(0, 4706))
// Standard Error: 1_528
.saturating_add(Weight::from_parts(49_181, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Proxy::Proxies` (r:1 w:1)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// The range of component `p` is `[1, 31]`.
fn remove_proxy(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `89 + p * (37 ±0)`
// Estimated: `4706`
// Minimum execution time: 23_507_000 picoseconds.
Weight::from_parts(24_816_973, 0)
.saturating_add(Weight::from_parts(0, 4706))
// Standard Error: 1_511
.saturating_add(Weight::from_parts(38_405, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Proxy::Proxies` (r:1 w:1)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// The range of component `p` is `[1, 31]`.
fn remove_proxies(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `89 + p * (37 ±0)`
// Estimated: `4706`
// Minimum execution time: 20_730_000 picoseconds.
Weight::from_parts(22_017_715, 0)
.saturating_add(Weight::from_parts(0, 4706))
// Standard Error: 1_790
.saturating_add(Weight::from_parts(23_582, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Proxy::Proxies` (r:1 w:1)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// The range of component `p` is `[1, 31]`.
fn create_pure(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `4706`
// Minimum execution time: 25_202_000 picoseconds.
Weight::from_parts(26_459_004, 0)
.saturating_add(Weight::from_parts(0, 4706))
// Standard Error: 1_850
.saturating_add(Weight::from_parts(3_579, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Proxy::Proxies` (r:1 w:1)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// The range of component `p` is `[0, 30]`.
fn kill_pure(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `126 + p * (37 ±0)`
// Estimated: `4706`
// Minimum execution time: 21_449_000 picoseconds.
Weight::from_parts(22_621_565, 0)
.saturating_add(Weight::from_parts(0, 4706))
// Standard Error: 2_057
.saturating_add(Weight::from_parts(41_291, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Proxy::Proxies` (r:1 w:1)
/// Proof: `Proxy::Proxies` (`max_values`: None, `max_size`: Some(1241), added: 3716, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Proxy::Announcements` (r:1 w:1)
/// Proof: `Proxy::Announcements` (`max_values`: None, `max_size`: Some(2233), added: 4708, mode: `MaxEncodedLen`)
fn poke_deposit() -> Weight {
// Proof Size summary in bytes:
// Measured: `414`
// Estimated: `5698`
// Minimum execution time: 44_155_000 picoseconds.
Weight::from_parts(45_402_000, 0)
.saturating_add(Weight::from_parts(0, 5698))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
}
@@ -0,0 +1,516 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_referenda`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_referenda
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_referenda`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_referenda::WeightInfo for WeightInfo<T> {
/// Storage: `Referenda::ReferendumCount` (r:1 w:1)
/// Proof: `Referenda::ReferendumCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Referenda::ReferendumInfoFor` (r:0 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
fn submit() -> Weight {
// Proof Size summary in bytes:
// Measured: `186`
// Estimated: `42428`
// Minimum execution time: 36_161_000 picoseconds.
Weight::from_parts(37_541_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn place_decision_deposit_preparing() -> Weight {
// Proof Size summary in bytes:
// Measured: `439`
// Estimated: `83866`
// Minimum execution time: 50_258_000 picoseconds.
Weight::from_parts(51_573_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:0)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn place_decision_deposit_queued() -> Weight {
// Proof Size summary in bytes:
// Measured: `3226`
// Estimated: `42428`
// Minimum execution time: 67_889_000 picoseconds.
Weight::from_parts(69_418_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:0)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn place_decision_deposit_not_queued() -> Weight {
// Proof Size summary in bytes:
// Measured: `3246`
// Estimated: `42428`
// Minimum execution time: 67_397_000 picoseconds.
Weight::from_parts(69_064_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:1)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn place_decision_deposit_passing() -> Weight {
// Proof Size summary in bytes:
// Measured: `439`
// Estimated: `83866`
// Minimum execution time: 59_530_000 picoseconds.
Weight::from_parts(61_636_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:1)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn place_decision_deposit_failing() -> Weight {
// Proof Size summary in bytes:
// Measured: `439`
// Estimated: `83866`
// Minimum execution time: 58_673_000 picoseconds.
Weight::from_parts(59_873_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
fn refund_decision_deposit() -> Weight {
// Proof Size summary in bytes:
// Measured: `279`
// Estimated: `4401`
// Minimum execution time: 28_556_000 picoseconds.
Weight::from_parts(29_193_000, 0)
.saturating_add(Weight::from_parts(0, 4401))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
fn refund_submission_deposit() -> Weight {
// Proof Size summary in bytes:
// Measured: `269`
// Estimated: `4401`
// Minimum execution time: 28_953_000 picoseconds.
Weight::from_parts(29_541_000, 0)
.saturating_add(Weight::from_parts(0, 4401))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn cancel() -> Weight {
// Proof Size summary in bytes:
// Measured: `347`
// Estimated: `83866`
// Minimum execution time: 34_545_000 picoseconds.
Weight::from_parts(35_543_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Referenda::MetadataOf` (r:1 w:0)
/// Proof: `Referenda::MetadataOf` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn kill() -> Weight {
// Proof Size summary in bytes:
// Measured: `588`
// Estimated: `83866`
// Minimum execution time: 90_482_000 picoseconds.
Weight::from_parts(92_143_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Referenda::TrackQueue` (r:1 w:0)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:1)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
fn one_fewer_deciding_queue_empty() -> Weight {
// Proof Size summary in bytes:
// Measured: `102`
// Estimated: `5477`
// Minimum execution time: 11_032_000 picoseconds.
Weight::from_parts(11_405_000, 0)
.saturating_add(Weight::from_parts(0, 5477))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn one_fewer_deciding_failing() -> Weight {
// Proof Size summary in bytes:
// Measured: `3116`
// Estimated: `42428`
// Minimum execution time: 46_541_000 picoseconds.
Weight::from_parts(47_840_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn one_fewer_deciding_passing() -> Weight {
// Proof Size summary in bytes:
// Measured: `3116`
// Estimated: `42428`
// Minimum execution time: 48_312_000 picoseconds.
Weight::from_parts(49_940_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
fn nudge_referendum_requeued_insertion() -> Weight {
// Proof Size summary in bytes:
// Measured: `2939`
// Estimated: `5477`
// Minimum execution time: 22_797_000 picoseconds.
Weight::from_parts(23_534_000, 0)
.saturating_add(Weight::from_parts(0, 5477))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
fn nudge_referendum_requeued_slide() -> Weight {
// Proof Size summary in bytes:
// Measured: `2939`
// Estimated: `5477`
// Minimum execution time: 22_528_000 picoseconds.
Weight::from_parts(23_292_000, 0)
.saturating_add(Weight::from_parts(0, 5477))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:0)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
fn nudge_referendum_queued() -> Weight {
// Proof Size summary in bytes:
// Measured: `2943`
// Estimated: `5477`
// Minimum execution time: 28_813_000 picoseconds.
Weight::from_parts(30_051_000, 0)
.saturating_add(Weight::from_parts(0, 5477))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:0)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Referenda::TrackQueue` (r:1 w:1)
/// Proof: `Referenda::TrackQueue` (`max_values`: None, `max_size`: Some(2012), added: 4487, mode: `MaxEncodedLen`)
fn nudge_referendum_not_queued() -> Weight {
// Proof Size summary in bytes:
// Measured: `2963`
// Estimated: `5477`
// Minimum execution time: 28_198_000 picoseconds.
Weight::from_parts(29_080_000, 0)
.saturating_add(Weight::from_parts(0, 5477))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_no_deposit() -> Weight {
// Proof Size summary in bytes:
// Measured: `299`
// Estimated: `42428`
// Minimum execution time: 23_048_000 picoseconds.
Weight::from_parts(24_004_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_preparing() -> Weight {
// Proof Size summary in bytes:
// Measured: `347`
// Estimated: `42428`
// Minimum execution time: 23_198_000 picoseconds.
Weight::from_parts(24_029_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
fn nudge_referendum_timed_out() -> Weight {
// Proof Size summary in bytes:
// Measured: `206`
// Estimated: `4401`
// Minimum execution time: 14_495_000 picoseconds.
Weight::from_parts(15_167_000, 0)
.saturating_add(Weight::from_parts(0, 4401))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:1)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_begin_deciding_failing() -> Weight {
// Proof Size summary in bytes:
// Measured: `347`
// Estimated: `42428`
// Minimum execution time: 30_480_000 picoseconds.
Weight::from_parts(31_982_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::DecidingCount` (r:1 w:1)
/// Proof: `Referenda::DecidingCount` (`max_values`: None, `max_size`: Some(14), added: 2489, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_begin_deciding_passing() -> Weight {
// Proof Size summary in bytes:
// Measured: `347`
// Estimated: `42428`
// Minimum execution time: 32_934_000 picoseconds.
Weight::from_parts(33_999_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_begin_confirming() -> Weight {
// Proof Size summary in bytes:
// Measured: `400`
// Estimated: `42428`
// Minimum execution time: 27_875_000 picoseconds.
Weight::from_parts(28_645_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_end_confirming() -> Weight {
// Proof Size summary in bytes:
// Measured: `383`
// Estimated: `42428`
// Minimum execution time: 28_150_000 picoseconds.
Weight::from_parts(28_967_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_continue_not_confirming() -> Weight {
// Proof Size summary in bytes:
// Measured: `400`
// Estimated: `42428`
// Minimum execution time: 27_692_000 picoseconds.
Weight::from_parts(28_559_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_continue_confirming() -> Weight {
// Proof Size summary in bytes:
// Measured: `404`
// Estimated: `42428`
// Minimum execution time: 25_836_000 picoseconds.
Weight::from_parts(26_852_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:2 w:2)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Lookup` (r:1 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
fn nudge_referendum_approved() -> Weight {
// Proof Size summary in bytes:
// Measured: `404`
// Estimated: `83866`
// Minimum execution time: 38_301_000 picoseconds.
Weight::from_parts(39_972_000, 0)
.saturating_add(Weight::from_parts(0, 83866))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:1)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
fn nudge_referendum_rejected() -> Weight {
// Proof Size summary in bytes:
// Measured: `400`
// Estimated: `42428`
// Minimum execution time: 27_978_000 picoseconds.
Weight::from_parts(28_811_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, 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:0)
/// Proof: `Preimage::RequestStatusFor` (`max_values`: None, `max_size`: Some(91), added: 2566, mode: `MaxEncodedLen`)
/// Storage: `Referenda::MetadataOf` (r:0 w:1)
/// Proof: `Referenda::MetadataOf` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
fn set_some_metadata() -> Weight {
// Proof Size summary in bytes:
// Measured: `349`
// Estimated: `4401`
// Minimum execution time: 22_243_000 picoseconds.
Weight::from_parts(23_351_000, 0)
.saturating_add(Weight::from_parts(0, 4401))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Referenda::ReferendumInfoFor` (r:1 w:0)
/// Proof: `Referenda::ReferendumInfoFor` (`max_values`: None, `max_size`: Some(936), added: 3411, mode: `MaxEncodedLen`)
/// Storage: `Referenda::MetadataOf` (r:1 w:1)
/// Proof: `Referenda::MetadataOf` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
fn clear_metadata() -> Weight {
// Proof Size summary in bytes:
// Measured: `283`
// Estimated: `4401`
// Minimum execution time: 17_273_000 picoseconds.
Weight::from_parts(17_926_000, 0)
.saturating_add(Weight::from_parts(0, 4401))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,291 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_scheduler`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_scheduler
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_scheduler`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_scheduler::WeightInfo for WeightInfo<T> {
/// Storage: `Scheduler::IncompleteSince` (r:1 w:1)
/// Proof: `Scheduler::IncompleteSince` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn service_agendas_base() -> Weight {
// Proof Size summary in bytes:
// Measured: `69`
// Estimated: `1489`
// Minimum execution time: 4_408_000 picoseconds.
Weight::from_parts(4_723_000, 0)
.saturating_add(Weight::from_parts(0, 1489))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 50]`.
fn service_agenda_base(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 4_789_000 picoseconds.
Weight::from_parts(8_177_405, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 1_630
.saturating_add(Weight::from_parts(349_930, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
fn service_task_base() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_674_000 picoseconds.
Weight::from_parts(3_982_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// 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 `s` is `[128, 4194304]`.
fn service_task_fetched(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `178 + s * (1 ±0)`
// Estimated: `3643 + s * (1 ±0)`
// Minimum execution time: 20_723_000 picoseconds.
Weight::from_parts(21_259_000, 0)
.saturating_add(Weight::from_parts(0, 3643))
// Standard Error: 261
.saturating_add(Weight::from_parts(23_543, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
.saturating_add(Weight::from_parts(0, 1).saturating_mul(s.into()))
}
/// Storage: `Scheduler::Lookup` (r:0 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
fn service_task_named() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_474_000 picoseconds.
Weight::from_parts(5_762_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
fn service_task_periodic() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_712_000 picoseconds.
Weight::from_parts(3_892_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn execute_dispatch_signed() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_258_000 picoseconds.
Weight::from_parts(2_535_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn execute_dispatch_unsigned() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_358_000 picoseconds.
Weight::from_parts(2_478_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 49]`.
fn schedule(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 12_009_000 picoseconds.
Weight::from_parts(15_253_217, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 1_770
.saturating_add(Weight::from_parts(402_617, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Lookup` (r:0 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// The range of component `s` is `[1, 50]`.
fn cancel(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `116 + s * (177 ±0)`
// Estimated: `42428`
// Minimum execution time: 17_471_000 picoseconds.
Weight::from_parts(17_840_084, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 3_141
.saturating_add(Weight::from_parts(581_579, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Scheduler::Lookup` (r:1 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// The range of component `s` is `[0, 49]`.
fn schedule_named(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `293 + s * (185 ±0)`
// Estimated: `42428`
// Minimum execution time: 15_635_000 picoseconds.
Weight::from_parts(20_871_297, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 4_083
.saturating_add(Weight::from_parts(449_239, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Scheduler::Lookup` (r:1 w:1)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// The range of component `s` is `[1, 50]`.
fn cancel_named(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `319 + s * (185 ±0)`
// Estimated: `42428`
// Minimum execution time: 20_631_000 picoseconds.
Weight::from_parts(22_129_643, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 2_057
.saturating_add(Weight::from_parts(615_161, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Scheduler::Agenda` (r:1 w:1)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
/// The range of component `s` is `[1, 50]`.
fn schedule_retry(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `156`
// Estimated: `42428`
// Minimum execution time: 11_472_000 picoseconds.
Weight::from_parts(12_021_769, 0)
.saturating_add(Weight::from_parts(0, 42428))
// Standard Error: 696
.saturating_add(Weight::from_parts(27_300, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn set_retry() -> Weight {
// Proof Size summary in bytes:
// Measured: `8966`
// Estimated: `42428`
// Minimum execution time: 28_031_000 picoseconds.
Weight::from_parts(29_185_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Lookup` (r:1 w:0)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn set_retry_named() -> Weight {
// Proof Size summary in bytes:
// Measured: `9644`
// Estimated: `42428`
// Minimum execution time: 34_902_000 picoseconds.
Weight::from_parts(36_691_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn cancel_retry() -> Weight {
// Proof Size summary in bytes:
// Measured: `8978`
// Estimated: `42428`
// Minimum execution time: 27_013_000 picoseconds.
Weight::from_parts(28_502_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Scheduler::Lookup` (r:1 w:0)
/// Proof: `Scheduler::Lookup` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Agenda` (r:1 w:0)
/// Proof: `Scheduler::Agenda` (`max_values`: None, `max_size`: Some(38963), added: 41438, mode: `MaxEncodedLen`)
/// Storage: `Scheduler::Retries` (r:0 w:1)
/// Proof: `Scheduler::Retries` (`max_values`: None, `max_size`: Some(30), added: 2505, mode: `MaxEncodedLen`)
fn cancel_retry_named() -> Weight {
// Proof Size summary in bytes:
// Measured: `9656`
// Estimated: `42428`
// Minimum execution time: 34_538_000 picoseconds.
Weight::from_parts(35_510_000, 0)
.saturating_add(Weight::from_parts(0, 42428))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,62 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_session`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
//! DATE: 2022-03-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("pezkuwi-dev"), DB CACHE: 1024
// Executed Command:
// ./target/production/pezkuwi
// benchmark
// --chain=pezkuwichain-dev
// --steps=50
// --repeat=20
// --pallet=pallet_session
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --heap-pages=4096
// --header=./file_header.txt
// --output=./runtime/pezkuwi/src/weights/pallet_session.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_session`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_session::WeightInfo for WeightInfo<T> {
// Storage: Staking Ledger (r:1 w:0)
// Storage: Session NextKeys (r:1 w:1)
// Storage: Session KeyOwner (r:6 w:6)
fn set_keys() -> Weight {
Weight::from_parts(36_115_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(8 as u64))
.saturating_add(T::DbWeight::get().writes(7 as u64))
}
// Storage: Staking Ledger (r:1 w:0)
// Storage: Session NextKeys (r:1 w:1)
// Storage: Session KeyOwner (r:0 w:6)
fn purge_keys() -> Weight {
Weight::from_parts(21_459_000 as u64, 0)
.saturating_add(T::DbWeight::get().reads(2 as u64))
.saturating_add(T::DbWeight::get().writes(7 as u64))
}
}
@@ -0,0 +1,111 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_sudo`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_sudo
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_sudo`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_sudo::WeightInfo for WeightInfo<T> {
/// Storage: `Sudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn set_key() -> Weight {
// Proof Size summary in bytes:
// Measured: `132`
// Estimated: `1517`
// Minimum execution time: 10_640_000 picoseconds.
Weight::from_parts(11_130_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Sudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo() -> Weight {
// Proof Size summary in bytes:
// Measured: `132`
// Estimated: `1517`
// Minimum execution time: 11_327_000 picoseconds.
Weight::from_parts(11_786_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: `Sudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn sudo_as() -> Weight {
// Proof Size summary in bytes:
// Measured: `132`
// Estimated: `1517`
// Minimum execution time: 11_356_000 picoseconds.
Weight::from_parts(11_953_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: `Sudo::Key` (r:1 w:1)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn remove_key() -> Weight {
// Proof Size summary in bytes:
// Measured: `132`
// Estimated: `1517`
// Minimum execution time: 9_720_000 picoseconds.
Weight::from_parts(10_242_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Sudo::Key` (r:1 w:0)
/// Proof: `Sudo::Key` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
fn check_only_sudo_account() -> Weight {
// Proof Size summary in bytes:
// Measured: `132`
// Estimated: `1517`
// Minimum execution time: 4_553_000 picoseconds.
Weight::from_parts(4_813_000, 0)
.saturating_add(Weight::from_parts(0, 1517))
.saturating_add(T::DbWeight::get().reads(1))
}
}
@@ -0,0 +1,76 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_timestamp`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_timestamp
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_timestamp`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_timestamp::WeightInfo for WeightInfo<T> {
/// Storage: `Timestamp::Now` (r:1 w:1)
/// Proof: `Timestamp::Now` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Babe::CurrentSlot` (r:1 w:0)
/// Proof: `Babe::CurrentSlot` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
fn set() -> Weight {
// Proof Size summary in bytes:
// Measured: `137`
// Estimated: `1493`
// Minimum execution time: 8_077_000 picoseconds.
Weight::from_parts(8_671_000, 0)
.saturating_add(Weight::from_parts(0, 1493))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
fn on_finalize() -> Weight {
// Proof Size summary in bytes:
// Measured: `57`
// Estimated: `0`
// Minimum execution time: 3_954_000 picoseconds.
Weight::from_parts(4_164_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
@@ -0,0 +1,66 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_transaction_payment`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_transaction_payment
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_transaction_payment`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_transaction_payment::WeightInfo for WeightInfo<T> {
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn charge_transaction_payment() -> Weight {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
// Minimum execution time: 41_116_000 picoseconds.
Weight::from_parts(42_005_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,167 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_treasury`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_treasury
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_treasury`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_treasury::WeightInfo for WeightInfo<T> {
/// Storage: `Treasury::ProposalCount` (r:1 w:1)
/// Proof: `Treasury::ProposalCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Approvals` (r:1 w:1)
/// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Proposals` (r:0 w:1)
/// Proof: `Treasury::Proposals` (`max_values`: None, `max_size`: Some(108), added: 2583, mode: `MaxEncodedLen`)
fn spend_local() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `1887`
// Minimum execution time: 12_748_000 picoseconds.
Weight::from_parts(13_519_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Treasury::Approvals` (r:1 w:1)
/// Proof: `Treasury::Approvals` (`max_values`: Some(1), `max_size`: Some(402), added: 897, mode: `MaxEncodedLen`)
fn remove_approval() -> Weight {
// Proof Size summary in bytes:
// Measured: `227`
// Estimated: `1887`
// Minimum execution time: 7_025_000 picoseconds.
Weight::from_parts(7_385_000, 0)
.saturating_add(Weight::from_parts(0, 1887))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Treasury::Deactivated` (r:1 w:1)
/// Proof: `Treasury::Deactivated` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Treasury::LastSpendPeriod` (r:1 w:1)
/// Proof: `Treasury::LastSpendPeriod` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// The range of component `p` is `[0, 99]`.
fn on_initialize_proposals(p: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `236`
// Estimated: `1501`
// Minimum execution time: 11_611_000 picoseconds.
Weight::from_parts(14_424_000, 0)
.saturating_add(Weight::from_parts(0, 1501))
// Standard Error: 750
.saturating_add(Weight::from_parts(37_523, 0).saturating_mul(p.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `AssetRate::ConversionRateToNative` (r:1 w:0)
/// Proof: `AssetRate::ConversionRateToNative` (`max_values`: None, `max_size`: Some(1238), added: 3713, mode: `MaxEncodedLen`)
/// Storage: `Treasury::SpendCount` (r:1 w:1)
/// Proof: `Treasury::SpendCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Treasury::Spends` (r:0 w:1)
/// Proof: `Treasury::Spends` (`max_values`: None, `max_size`: Some(1853), added: 4328, mode: `MaxEncodedLen`)
fn spend() -> Weight {
// Proof Size summary in bytes:
// Measured: `214`
// Estimated: `4703`
// Minimum execution time: 20_171_000 picoseconds.
Weight::from_parts(21_114_000, 0)
.saturating_add(Weight::from_parts(0, 4703))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Treasury::Spends` (r:1 w:1)
/// Proof: `Treasury::Spends` (`max_values`: None, `max_size`: Some(1853), added: 4328, mode: `MaxEncodedLen`)
/// Storage: `XcmPallet::QueryCounter` (r:1 w:1)
/// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::Queries` (r:0 w:1)
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn payout() -> Weight {
// Proof Size summary in bytes:
// Measured: `522`
// Estimated: `5318`
// Minimum execution time: 58_081_000 picoseconds.
Weight::from_parts(64_709_000, 0)
.saturating_add(Weight::from_parts(0, 5318))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `Treasury::Spends` (r:1 w:1)
/// Proof: `Treasury::Spends` (`max_values`: None, `max_size`: Some(1853), added: 4328, mode: `MaxEncodedLen`)
/// Storage: `XcmPallet::Queries` (r:1 w:1)
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn check_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `305`
// Estimated: `5318`
// Minimum execution time: 25_238_000 picoseconds.
Weight::from_parts(25_654_000, 0)
.saturating_add(Weight::from_parts(0, 5318))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Treasury::Spends` (r:1 w:1)
/// Proof: `Treasury::Spends` (`max_values`: None, `max_size`: Some(1853), added: 4328, mode: `MaxEncodedLen`)
fn void_spend() -> Weight {
// Proof Size summary in bytes:
// Measured: `277`
// Estimated: `5318`
// Minimum execution time: 14_929_000 picoseconds.
Weight::from_parts(15_441_000, 0)
.saturating_add(Weight::from_parts(0, 5318))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,119 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_utility`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_utility
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_utility`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> {
/// The range of component `c` is `[0, 1000]`.
fn batch(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_402_000 picoseconds.
Weight::from_parts(5_543_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 2_006
.saturating_add(Weight::from_parts(3_376_579, 0).saturating_mul(c.into()))
}
fn as_derivative() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 4_737_000 picoseconds.
Weight::from_parts(5_103_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `c` is `[0, 1000]`.
fn batch_all(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_485_000 picoseconds.
Weight::from_parts(5_863_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 1_759
.saturating_add(Weight::from_parts(3_566_901, 0).saturating_mul(c.into()))
}
fn dispatch_as() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_565_000 picoseconds.
Weight::from_parts(8_133_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// The range of component `c` is `[0, 1000]`.
fn force_batch(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_353_000 picoseconds.
Weight::from_parts(5_774_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 2_009
.saturating_add(Weight::from_parts(3_357_568, 0).saturating_mul(c.into()))
}
fn dispatch_as_fallible() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_232_000 picoseconds.
Weight::from_parts(7_558_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn if_else() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 9_169_000 picoseconds.
Weight::from_parts(9_536_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
@@ -0,0 +1,262 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_vesting`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_vesting
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_vesting`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_vesting::WeightInfo for WeightInfo<T> {
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[1, 28]`.
fn vest_locked(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `277 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 34_644_000 picoseconds.
Weight::from_parts(34_294_075, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 2_502
.saturating_add(Weight::from_parts(33_997, 0).saturating_mul(l.into()))
// Standard Error: 4_451
.saturating_add(Weight::from_parts(82_158, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[1, 28]`.
fn vest_unlocked(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `277 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 37_051_000 picoseconds.
Weight::from_parts(37_406_778, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 2_143
.saturating_add(Weight::from_parts(25_479, 0).saturating_mul(l.into()))
// Standard Error: 3_813
.saturating_add(Weight::from_parts(59_478, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[1, 28]`.
fn vest_other_locked(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `380 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 36_942_000 picoseconds.
Weight::from_parts(36_397_510, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 2_194
.saturating_add(Weight::from_parts(43_154, 0).saturating_mul(l.into()))
// Standard Error: 3_904
.saturating_add(Weight::from_parts(78_209, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[1, 28]`.
fn vest_other_unlocked(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `380 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 39_129_000 picoseconds.
Weight::from_parts(39_172_044, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 2_803
.saturating_add(Weight::from_parts(33_251, 0).saturating_mul(l.into()))
// Standard Error: 4_988
.saturating_add(Weight::from_parts(83_808, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[0, 27]`.
fn vested_transfer(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `451 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 75_395_000 picoseconds.
Weight::from_parts(77_352_873, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 4_000
.saturating_add(Weight::from_parts(33_084, 0).saturating_mul(l.into()))
// Standard Error: 7_117
.saturating_add(Weight::from_parts(78_022, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[0, 27]`.
fn force_vested_transfer(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `554 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `6196`
// Minimum execution time: 76_648_000 picoseconds.
Weight::from_parts(77_970_331, 0)
.saturating_add(Weight::from_parts(0, 6196))
// Standard Error: 3_437
.saturating_add(Weight::from_parts(45_910, 0).saturating_mul(l.into()))
// Standard Error: 6_116
.saturating_add(Weight::from_parts(105_157, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[2, 28]`.
fn not_unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `277 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 34_725_000 picoseconds.
Weight::from_parts(35_867_784, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 2_233
.saturating_add(Weight::from_parts(30_025, 0).saturating_mul(l.into()))
// Standard Error: 4_125
.saturating_add(Weight::from_parts(56_964, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[2, 28]`.
fn unlocking_merge_schedules(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `277 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 37_897_000 picoseconds.
Weight::from_parts(37_679_187, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 2_178
.saturating_add(Weight::from_parts(37_935, 0).saturating_mul(l.into()))
// Standard Error: 4_022
.saturating_add(Weight::from_parts(89_640, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `l` is `[0, 49]`.
/// The range of component `s` is `[2, 28]`.
fn force_remove_vesting_schedule(l: u32, s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `451 + l * (25 ±0) + s * (36 ±0)`
// Estimated: `4764`
// Minimum execution time: 42_163_000 picoseconds.
Weight::from_parts(42_827_949, 0)
.saturating_add(Weight::from_parts(0, 4764))
// Standard Error: 2_205
.saturating_add(Weight::from_parts(28_809, 0).saturating_mul(l.into()))
// Standard Error: 4_073
.saturating_add(Weight::from_parts(67_463, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
}
}
@@ -0,0 +1,127 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_whitelist`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_whitelist
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_whitelist`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_whitelist::WeightInfo for WeightInfo<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: `150`
// Estimated: `3556`
// Minimum execution time: 20_475_000 picoseconds.
Weight::from_parts(20_986_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// 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: `279`
// Estimated: `3556`
// Minimum execution time: 20_529_000 picoseconds.
Weight::from_parts(21_448_000, 0)
.saturating_add(Weight::from_parts(0, 3556))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// 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: `355 + n * (1 ±0)`
// Estimated: `3819 + n * (1 ±0)`
// Minimum execution time: 32_770_000 picoseconds.
Weight::from_parts(33_390_000, 0)
.saturating_add(Weight::from_parts(0, 3819))
// Standard Error: 260
.saturating_add(Weight::from_parts(23_701, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(3))
.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: `279`
// Estimated: `3556`
// Minimum execution time: 24_811_000 picoseconds.
Weight::from_parts(25_795_703, 0)
.saturating_add(Weight::from_parts(0, 3556))
// Standard Error: 5
.saturating_add(Weight::from_parts(1_287, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
}
@@ -0,0 +1,392 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_xcm`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pallet_xcm
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_xcm`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_xcm::WeightInfo for WeightInfo<T> {
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn send() -> Weight {
// Proof Size summary in bytes:
// Measured: `245`
// Estimated: `3710`
// Minimum execution time: 38_240_000 picoseconds.
Weight::from_parts(39_348_000, 0)
.saturating_add(Weight::from_parts(0, 3710))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0)
/// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn teleport_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `245`
// Estimated: `3710`
// Minimum execution time: 139_859_000 picoseconds.
Weight::from_parts(143_227_000, 0)
.saturating_add(Weight::from_parts(0, 3710))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Benchmark::Override` (r:0 w:0)
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn reserve_transfer_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
Weight::from_parts(18_446_744_073_709_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0)
/// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn transfer_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `245`
// Estimated: `3710`
// Minimum execution time: 139_455_000 picoseconds.
Weight::from_parts(141_408_000, 0)
.saturating_add(Weight::from_parts(0, 3710))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0)
/// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn execute() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `1485`
// Minimum execution time: 9_783_000 picoseconds.
Weight::from_parts(10_335_000, 0)
.saturating_add(Weight::from_parts(0, 1485))
.saturating_add(T::DbWeight::get().reads(1))
}
/// Storage: `XcmPallet::SupportedVersion` (r:0 w:1)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_xcm_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_365_000 picoseconds.
Weight::from_parts(8_800_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
fn force_default_xcm_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_374_000 picoseconds.
Weight::from_parts(2_628_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1)
/// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::QueryCounter` (r:1 w:1)
/// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::Queries` (r:0 w:1)
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_subscribe_version_notify() -> Weight {
// Proof Size summary in bytes:
// Measured: `245`
// Estimated: `3710`
// Minimum execution time: 46_371_000 picoseconds.
Weight::from_parts(47_805_000, 0)
.saturating_add(Weight::from_parts(0, 3710))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `XcmPallet::VersionNotifiers` (r:1 w:1)
/// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::Queries` (r:0 w:1)
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_unsubscribe_version_notify() -> Weight {
// Proof Size summary in bytes:
// Measured: `425`
// Estimated: `3890`
// Minimum execution time: 50_324_000 picoseconds.
Weight::from_parts(52_149_000, 0)
.saturating_add(Weight::from_parts(0, 3890))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `XcmPallet::XcmExecutionSuspended` (r:0 w:1)
/// Proof: `XcmPallet::XcmExecutionSuspended` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn force_suspension() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_436_000 picoseconds.
Weight::from_parts(2_677_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::SupportedVersion` (r:6 w:2)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_supported_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `22`
// Estimated: `15862`
// Minimum execution time: 22_292_000 picoseconds.
Weight::from_parts(23_053_000, 0)
.saturating_add(Weight::from_parts(0, 15862))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `XcmPallet::VersionNotifiers` (r:6 w:2)
/// Proof: `XcmPallet::VersionNotifiers` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_version_notifiers() -> Weight {
// Proof Size summary in bytes:
// Measured: `26`
// Estimated: `15866`
// Minimum execution time: 22_559_000 picoseconds.
Weight::from_parts(23_110_000, 0)
.saturating_add(Weight::from_parts(0, 15866))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:7 w:0)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn already_notified_target() -> Weight {
// Proof Size summary in bytes:
// Measured: `40`
// Estimated: `18355`
// Minimum execution time: 26_171_000 picoseconds.
Weight::from_parts(26_599_000, 0)
.saturating_add(Weight::from_parts(0, 18355))
.saturating_add(T::DbWeight::get().reads(7))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:2 w:1)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:0)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn notify_current_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `244`
// Estimated: `6184`
// Minimum execution time: 33_588_000 picoseconds.
Weight::from_parts(35_745_000, 0)
.saturating_add(Weight::from_parts(0, 6184))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:5 w:0)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn notify_target_migration_fail() -> Weight {
// Proof Size summary in bytes:
// Measured: `40`
// Estimated: `13405`
// Minimum execution time: 17_845_000 picoseconds.
Weight::from_parts(18_283_000, 0)
.saturating_add(Weight::from_parts(0, 13405))
.saturating_add(T::DbWeight::get().reads(5))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:2)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_version_notify_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `33`
// Estimated: `15873`
// Minimum execution time: 22_364_000 picoseconds.
Weight::from_parts(23_010_000, 0)
.saturating_add(Weight::from_parts(0, 15873))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:6 w:1)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:0)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn migrate_and_notify_old_targets() -> Weight {
// Proof Size summary in bytes:
// Measured: `244`
// Estimated: `16084`
// Minimum execution time: 44_278_000 picoseconds.
Weight::from_parts(45_260_000, 0)
.saturating_add(Weight::from_parts(0, 16084))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::QueryCounter` (r:1 w:1)
/// Proof: `XcmPallet::QueryCounter` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::Queries` (r:0 w:1)
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn new_query() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `1485`
// Minimum execution time: 2_998_000 picoseconds.
Weight::from_parts(3_160_000, 0)
.saturating_add(Weight::from_parts(0, 1485))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `XcmPallet::Queries` (r:1 w:1)
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn take_response() -> Weight {
// Proof Size summary in bytes:
// Measured: `7576`
// Estimated: `11041`
// Minimum execution time: 27_607_000 picoseconds.
Weight::from_parts(28_140_000, 0)
.saturating_add(Weight::from_parts(0, 11041))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::ShouldRecordXcm` (r:1 w:0)
/// Proof: `XcmPallet::ShouldRecordXcm` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::AssetTraps` (r:1 w:1)
/// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn claim_assets() -> Weight {
// Proof Size summary in bytes:
// Measured: `23`
// Estimated: `3488`
// Minimum execution time: 40_344_000 picoseconds.
Weight::from_parts(41_498_000, 0)
.saturating_add(Weight::from_parts(0, 3488))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::AuthorizedAliases` (r:1 w:1)
/// Proof: `XcmPallet::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn add_authorized_alias() -> Weight {
// Proof Size summary in bytes:
// Measured: `361`
// Estimated: `3826`
// Minimum execution time: 15_975_000 picoseconds.
Weight::from_parts(16_398_000, 3826)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `XcmPallet::AuthorizedAliases` (r:1 w:1)
/// Proof: `XcmPallet::AuthorizedAliases` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn remove_authorized_alias() -> Weight {
// Proof Size summary in bytes:
// Measured: `400`
// Estimated: `3865`
// Minimum execution time: 17_326_000 picoseconds.
Weight::from_parts(17_622_000, 3865)
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
fn weigh_message() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_785_000 picoseconds.
Weight::from_parts(8_077_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
}
@@ -0,0 +1,191 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_xcm_benchmarks::fungible`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("pezkuwichain-dev")`, DB CACHE: 1024
// Executed Command:
// ./target/production/pezkuwi
// benchmark
// pallet
// --chain=pezkuwichain-dev
// --steps=50
// --repeat=20
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --pallet=pallet_xcm_benchmarks::fungible
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --header=./pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights/pallet_xcm_benchmarks_fungible.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_xcm_benchmarks::fungible`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_xcm_benchmarks::fungible::WeightInfo for WeightInfo<T> {
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn withdraw_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `3593`
// Minimum execution time: 27_223_000 picoseconds.
Weight::from_parts(27_947_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn transfer_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `101`
// Estimated: `6196`
// Minimum execution time: 36_502_000 picoseconds.
Weight::from_parts(37_023_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn transfer_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `6196`
// Minimum execution time: 85_152_000 picoseconds.
Weight::from_parts(86_442_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Benchmark::Override` (r:0 w:0)
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn reserve_asset_deposited() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 18_446_744_073_709_551_000 picoseconds.
Weight::from_parts(18_446_744_073_709_551_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn initiate_reserve_withdraw() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `3746`
// Minimum execution time: 56_571_000 picoseconds.
Weight::from_parts(58_163_000, 0)
.saturating_add(Weight::from_parts(0, 3746))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn receive_teleported_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `103`
// Estimated: `3593`
// Minimum execution time: 27_411_000 picoseconds.
Weight::from_parts(27_953_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn deposit_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3593`
// Minimum execution time: 20_776_000 picoseconds.
Weight::from_parts(21_145_000, 0)
.saturating_add(Weight::from_parts(0, 3593))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn deposit_reserve_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3645`
// Minimum execution time: 51_738_000 picoseconds.
Weight::from_parts(53_251_000, 0)
.saturating_add(Weight::from_parts(0, 3645))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn initiate_teleport() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3645`
// Minimum execution time: 39_333_000 picoseconds.
Weight::from_parts(40_515_000, 0)
.saturating_add(Weight::from_parts(0, 3645))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
}
@@ -0,0 +1,354 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pallet_xcm_benchmarks::generic`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2024-02-29, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `runner-bn-ce5rx-project-674-concurrent-0`, CPU: `Intel(R) Xeon(R) CPU @ 2.60GHz`
//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("pezkuwichain-dev")`, DB CACHE: 1024
// Executed Command:
// ./target/production/pezkuwi
// benchmark
// pallet
// --chain=pezkuwichain-dev
// --steps=50
// --repeat=20
// --no-storage-info
// --no-median-slopes
// --no-min-squares
// --pallet=pallet_xcm_benchmarks::generic
// --extrinsic=*
// --execution=wasm
// --wasm-execution=compiled
// --header=./pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights/pallet_xcm_benchmarks_generic.rs
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pallet_xcm_benchmarks::generic`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_xcm_benchmarks::generic::WeightInfo for WeightInfo<T> {
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn report_holding() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `3746`
// Minimum execution time: 55_210_000 picoseconds.
Weight::from_parts(56_613_000, 0)
.saturating_add(Weight::from_parts(0, 3746))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
fn buy_execution() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_246_000 picoseconds.
Weight::from_parts(1_339_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `XcmPallet::Queries` (r:1 w:0)
/// Proof: `XcmPallet::Queries` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn query_response() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `3465`
// Minimum execution time: 5_377_000 picoseconds.
Weight::from_parts(5_549_000, 0)
.saturating_add(Weight::from_parts(0, 3465))
.saturating_add(T::DbWeight::get().reads(1))
}
fn transact() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_008_000 picoseconds.
Weight::from_parts(7_361_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn refund_surplus() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_700_000 picoseconds.
Weight::from_parts(1_848_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn set_error_handler() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_198_000 picoseconds.
Weight::from_parts(1_265_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn set_appendix() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_197_000 picoseconds.
Weight::from_parts(1_267_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn clear_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_193_000 picoseconds.
Weight::from_parts(1_258_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn descend_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_268_000 picoseconds.
Weight::from_parts(1_342_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn clear_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_173_000 picoseconds.
Weight::from_parts(1_248_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn report_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `3746`
// Minimum execution time: 53_715_000 picoseconds.
Weight::from_parts(54_860_000, 0)
.saturating_add(Weight::from_parts(0, 3746))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `XcmPallet::AssetTraps` (r:1 w:1)
/// Proof: `XcmPallet::AssetTraps` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn claim_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `23`
// Estimated: `3488`
// Minimum execution time: 8_621_000 picoseconds.
Weight::from_parts(8_903_000, 0)
.saturating_add(Weight::from_parts(0, 3488))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
fn trap() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_211_000 picoseconds.
Weight::from_parts(1_281_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:1 w:1)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn subscribe_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3645`
// Minimum execution time: 26_448_000 picoseconds.
Weight::from_parts(27_057_000, 0)
.saturating_add(Weight::from_parts(0, 3645))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `XcmPallet::VersionNotifyTargets` (r:0 w:1)
/// Proof: `XcmPallet::VersionNotifyTargets` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn unsubscribe_version() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 3_498_000 picoseconds.
Weight::from_parts(3_614_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
fn burn_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_575_000 picoseconds.
Weight::from_parts(1_698_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn expect_asset() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_334_000 picoseconds.
Weight::from_parts(1_435_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn expect_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_244_000 picoseconds.
Weight::from_parts(1_337_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn expect_error() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_244_000 picoseconds.
Weight::from_parts(1_331_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn expect_transact_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_407_000 picoseconds.
Weight::from_parts(1_522_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn query_pallet() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `3746`
// Minimum execution time: 62_963_000 picoseconds.
Weight::from_parts(64_556_000, 0)
.saturating_add(Weight::from_parts(0, 3746))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
fn expect_pallet() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 8_458_000 picoseconds.
Weight::from_parts(8_741_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn report_transact_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `281`
// Estimated: `3746`
// Minimum execution time: 54_068_000 picoseconds.
Weight::from_parts(55_665_000, 0)
.saturating_add(Weight::from_parts(0, 3746))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
fn clear_transact_status() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_290_000 picoseconds.
Weight::from_parts(1_348_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn set_topic() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_189_000 picoseconds.
Weight::from_parts(1_268_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn clear_topic() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_197_000 picoseconds.
Weight::from_parts(1_276_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn set_fees_mode() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_197_000 picoseconds.
Weight::from_parts(1_253_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn unpaid_execution() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 1_250_000 picoseconds.
Weight::from_parts(1_354_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
fn execute_with_origin() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 713_000 picoseconds.
Weight::from_parts(776_000, 0)
}
}
@@ -0,0 +1,154 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_common::assigned_slots`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_common::assigned_slots
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_common::assigned_slots`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_common::assigned_slots::WeightInfo for WeightInfo<T> {
/// Storage: `Registrar::Paras` (r:1 w:0)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:1)
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:0)
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
/// Storage: `Slots::Leases` (r:1 w:1)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AssignedSlots::PermanentSlotCount` (r:1 w:1)
/// Proof: `AssignedSlots::PermanentSlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `AssignedSlots::MaxPermanentSlots` (r:1 w:0)
/// Proof: `AssignedSlots::MaxPermanentSlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn assign_perm_teyrchain_slot() -> Weight {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `4158`
// Minimum execution time: 90_018_000 picoseconds.
Weight::from_parts(95_844_000, 0)
.saturating_add(Weight::from_parts(0, 4158))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `Registrar::Paras` (r:1 w:0)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:0)
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:1)
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
/// Storage: `Slots::Leases` (r:1 w:1)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AssignedSlots::TemporarySlotCount` (r:1 w:1)
/// Proof: `AssignedSlots::TemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `AssignedSlots::MaxTemporarySlots` (r:1 w:0)
/// Proof: `AssignedSlots::MaxTemporarySlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `AssignedSlots::ActiveTemporarySlotCount` (r:1 w:1)
/// Proof: `AssignedSlots::ActiveTemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn assign_temp_teyrchain_slot() -> Weight {
// Proof Size summary in bytes:
// Measured: `693`
// Estimated: `4158`
// Minimum execution time: 76_112_000 picoseconds.
Weight::from_parts(81_378_000, 0)
.saturating_add(Weight::from_parts(0, 4158))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(6))
}
/// Storage: `AssignedSlots::PermanentSlots` (r:1 w:0)
/// Proof: `AssignedSlots::PermanentSlots` (`max_values`: None, `max_size`: Some(20), added: 2495, mode: `MaxEncodedLen`)
/// Storage: `AssignedSlots::TemporarySlots` (r:1 w:1)
/// Proof: `AssignedSlots::TemporarySlots` (`max_values`: None, `max_size`: Some(61), added: 2536, mode: `MaxEncodedLen`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Slots::Leases` (r:1 w:1)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `AssignedSlots::TemporarySlotCount` (r:1 w:1)
/// Proof: `AssignedSlots::TemporarySlotCount` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn unassign_teyrchain_slot() -> Weight {
// Proof Size summary in bytes:
// Measured: `856`
// Estimated: `4321`
// Minimum execution time: 41_605_000 picoseconds.
Weight::from_parts(47_109_000, 0)
.saturating_add(Weight::from_parts(0, 4321))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `AssignedSlots::MaxPermanentSlots` (r:0 w:1)
/// Proof: `AssignedSlots::MaxPermanentSlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn set_max_permanent_slots() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_659_000 picoseconds.
Weight::from_parts(5_917_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `AssignedSlots::MaxTemporarySlots` (r:0 w:1)
/// Proof: `AssignedSlots::MaxTemporarySlots` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn set_max_temporary_slots() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 5_520_000 picoseconds.
Weight::from_parts(5_883_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,142 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_common::auctions`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_common::auctions
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_common::auctions`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_common::auctions::WeightInfo for WeightInfo<T> {
/// Storage: `Auctions::AuctionInfo` (r:1 w:1)
/// Proof: `Auctions::AuctionInfo` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Auctions::AuctionCounter` (r:1 w:1)
/// Proof: `Auctions::AuctionCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
fn new_auction() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `1493`
// Minimum execution time: 9_499_000 picoseconds.
Weight::from_parts(9_872_000, 0)
.saturating_add(Weight::from_parts(0, 1493))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Auctions::AuctionCounter` (r:1 w:0)
/// Proof: `Auctions::AuctionCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Auctions::AuctionInfo` (r:1 w:0)
/// Proof: `Auctions::AuctionInfo` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Slots::Leases` (r:1 w:0)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Auctions::Winning` (r:1 w:1)
/// Proof: `Auctions::Winning` (`max_values`: None, `max_size`: Some(1920), added: 4395, mode: `MaxEncodedLen`)
/// Storage: `Auctions::ReservedAmounts` (r:2 w:2)
/// Proof: `Auctions::ReservedAmounts` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn bid() -> Weight {
// Proof Size summary in bytes:
// Measured: `762`
// Estimated: `6060`
// Minimum execution time: 87_828_000 picoseconds.
Weight::from_parts(91_541_000, 0)
.saturating_add(Weight::from_parts(0, 6060))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Auctions::AuctionInfo` (r:1 w:1)
/// Proof: `Auctions::AuctionInfo` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Babe::NextRandomness` (r:1 w:0)
/// Proof: `Babe::NextRandomness` (`max_values`: Some(1), `max_size`: Some(32), added: 527, mode: `MaxEncodedLen`)
/// Storage: `Babe::EpochStart` (r:1 w:0)
/// Proof: `Babe::EpochStart` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Auctions::AuctionCounter` (r:1 w:0)
/// Proof: `Auctions::AuctionCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Auctions::Winning` (r:3600 w:3600)
/// Proof: `Auctions::Winning` (`max_values`: None, `max_size`: Some(1920), added: 4395, mode: `MaxEncodedLen`)
/// Storage: `Auctions::ReservedAmounts` (r:37 w:36)
/// Proof: `Auctions::ReservedAmounts` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:36 w:36)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Slots::Leases` (r:2 w:2)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn on_initialize() -> Weight {
// Proof Size summary in bytes:
// Measured: `6947018`
// Estimated: `15822990`
// Minimum execution time: 8_633_205_000 picoseconds.
Weight::from_parts(8_845_826_000, 0)
.saturating_add(Weight::from_parts(0, 15822990))
.saturating_add(T::DbWeight::get().reads(3682))
.saturating_add(T::DbWeight::get().writes(3677))
}
/// Storage: `Auctions::ReservedAmounts` (r:37 w:36)
/// Proof: `Auctions::ReservedAmounts` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:36 w:36)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Auctions::Winning` (r:3600 w:3600)
/// Proof: `Auctions::Winning` (`max_values`: None, `max_size`: Some(1920), added: 4395, mode: `MaxEncodedLen`)
/// Storage: `Auctions::AuctionInfo` (r:0 w:1)
/// Proof: `Auctions::AuctionInfo` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
fn cancel_auction() -> Weight {
// Proof Size summary in bytes:
// Measured: `177732`
// Estimated: `15822990`
// Minimum execution time: 6_693_150_000 picoseconds.
Weight::from_parts(6_883_632_000, 0)
.saturating_add(Weight::from_parts(0, 15822990))
.saturating_add(T::DbWeight::get().reads(3673))
.saturating_add(T::DbWeight::get().writes(3673))
}
}
@@ -0,0 +1,183 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_common::claims`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_common::claims
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_common::claims`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_common::claims::WeightInfo for WeightInfo<T> {
/// Storage: `Claims::Claims` (r:1 w:1)
/// Proof: `Claims::Claims` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Signing` (r:1 w:1)
/// Proof: `Claims::Signing` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`)
/// Storage: `Claims::Total` (r:1 w:1)
/// Proof: `Claims::Total` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Vesting` (r:1 w:1)
/// Proof: `Claims::Vesting` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`)
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:0)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
fn claim() -> Weight {
// Proof Size summary in bytes:
// Measured: `558`
// Estimated: `4764`
// Minimum execution time: 197_918_000 picoseconds.
Weight::from_parts(206_140_000, 0)
.saturating_add(Weight::from_parts(0, 4764))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(6))
}
/// Storage: `Claims::Total` (r:1 w:1)
/// Proof: `Claims::Total` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Vesting` (r:0 w:1)
/// Proof: `Claims::Vesting` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`)
/// Storage: `Claims::Claims` (r:0 w:1)
/// Proof: `Claims::Claims` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Signing` (r:0 w:1)
/// Proof: `Claims::Signing` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`)
fn mint_claim() -> Weight {
// Proof Size summary in bytes:
// Measured: `216`
// Estimated: `1501`
// Minimum execution time: 15_619_000 picoseconds.
Weight::from_parts(17_392_000, 0)
.saturating_add(Weight::from_parts(0, 1501))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Claims::Claims` (r:1 w:1)
/// Proof: `Claims::Claims` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Signing` (r:1 w:1)
/// Proof: `Claims::Signing` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`)
/// Storage: `Claims::Total` (r:1 w:1)
/// Proof: `Claims::Total` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Vesting` (r:1 w:1)
/// Proof: `Claims::Vesting` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`)
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:0)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
fn claim_attest() -> Weight {
// Proof Size summary in bytes:
// Measured: `558`
// Estimated: `4764`
// Minimum execution time: 205_045_000 picoseconds.
Weight::from_parts(217_083_000, 0)
.saturating_add(Weight::from_parts(0, 4764))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(6))
}
/// Storage: `Claims::Preclaims` (r:1 w:1)
/// Proof: `Claims::Preclaims` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `Claims::Signing` (r:1 w:1)
/// Proof: `Claims::Signing` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`)
/// Storage: `Claims::Claims` (r:1 w:1)
/// Proof: `Claims::Claims` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Total` (r:1 w:1)
/// Proof: `Claims::Total` (`max_values`: Some(1), `max_size`: Some(16), added: 511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Vesting` (r:1 w:1)
/// Proof: `Claims::Vesting` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`)
/// Storage: `Vesting::Vesting` (r:1 w:1)
/// Proof: `Vesting::Vesting` (`max_values`: None, `max_size`: Some(1057), added: 3532, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:0)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Balances::Locks` (r:1 w:1)
/// Proof: `Balances::Locks` (`max_values`: None, `max_size`: Some(1299), added: 3774, mode: `MaxEncodedLen`)
/// Storage: `Balances::Freezes` (r:1 w:0)
/// Proof: `Balances::Freezes` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
fn attest() -> Weight {
// Proof Size summary in bytes:
// Measured: `632`
// Estimated: `4764`
// Minimum execution time: 92_260_000 picoseconds.
Weight::from_parts(94_975_000, 0)
.saturating_add(Weight::from_parts(0, 4764))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(7))
}
/// Storage: `Claims::Claims` (r:1 w:2)
/// Proof: `Claims::Claims` (`max_values`: None, `max_size`: Some(36), added: 2511, mode: `MaxEncodedLen`)
/// Storage: `Claims::Vesting` (r:1 w:2)
/// Proof: `Claims::Vesting` (`max_values`: None, `max_size`: Some(56), added: 2531, mode: `MaxEncodedLen`)
/// Storage: `Claims::Signing` (r:1 w:2)
/// Proof: `Claims::Signing` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`)
/// Storage: `Claims::Preclaims` (r:1 w:1)
/// Proof: `Claims::Preclaims` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
fn move_claim() -> Weight {
// Proof Size summary in bytes:
// Measured: `440`
// Estimated: `3521`
// Minimum execution time: 30_996_000 picoseconds.
Weight::from_parts(33_583_000, 0)
.saturating_add(Weight::from_parts(0, 3521))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(7))
}
/// Storage: `Claims::Preclaims` (r:1 w:0)
/// Proof: `Claims::Preclaims` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`)
/// Storage: `Claims::Signing` (r:1 w:0)
/// Proof: `Claims::Signing` (`max_values`: None, `max_size`: Some(21), added: 2496, mode: `MaxEncodedLen`)
fn prevalidate_attests() -> Weight {
// Proof Size summary in bytes:
// Measured: `296`
// Estimated: `3517`
// Minimum execution time: 12_086_000 picoseconds.
Weight::from_parts(13_070_000, 0)
.saturating_add(Weight::from_parts(0, 3517))
.saturating_add(T::DbWeight::get().reads(2))
}
}
@@ -0,0 +1,222 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_common::crowdloan`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_common::crowdloan
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_common::crowdloan`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_common::crowdloan::WeightInfo for WeightInfo<T> {
/// Storage: `Crowdloan::Funds` (r:1 w:1)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Registrar::Paras` (r:1 w:0)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Crowdloan::NextFundIndex` (r:1 w:1)
/// Proof: `Crowdloan::NextFundIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn create() -> Weight {
// Proof Size summary in bytes:
// Measured: `401`
// Estimated: `3866`
// Minimum execution time: 54_117_000 picoseconds.
Weight::from_parts(59_162_000, 0)
.saturating_add(Weight::from_parts(0, 3866))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Crowdloan::Funds` (r:1 w:1)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Slots::Leases` (r:1 w:0)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Auctions::AuctionInfo` (r:1 w:0)
/// Proof: `Auctions::AuctionInfo` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Crowdloan::EndingsCount` (r:1 w:0)
/// Proof: `Crowdloan::EndingsCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Crowdloan::NewRaise` (r:1 w:1)
/// Proof: `Crowdloan::NewRaise` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1)
/// Proof: UNKNOWN KEY `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1)
fn contribute() -> Weight {
// Proof Size summary in bytes:
// Measured: `564`
// Estimated: `4029`
// Minimum execution time: 139_243_000 picoseconds.
Weight::from_parts(145_356_000, 0)
.saturating_add(Weight::from_parts(0, 4029))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Crowdloan::Funds` (r:1 w:1)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: UNKNOWN KEY `0xc85982571aa615c788ef9b2c16f54f25773fd439e8ee1ed2aa3ae43d48e880f0` (r:1 w:1)
/// Proof: UNKNOWN KEY `0xc85982571aa615c788ef9b2c16f54f25773fd439e8ee1ed2aa3ae43d48e880f0` (r:1 w:1)
fn withdraw() -> Weight {
// Proof Size summary in bytes:
// Measured: `688`
// Estimated: `6196`
// Minimum execution time: 85_152_000 picoseconds.
Weight::from_parts(88_704_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Skipped::Metadata` (r:0 w:0)
/// Proof: `Skipped::Metadata` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `k` is `[0, 1000]`.
fn refund(k: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `126 + k * (189 ±0)`
// Estimated: `139 + k * (189 ±0)`
// Minimum execution time: 38_767_000 picoseconds.
Weight::from_parts(42_119_000, 0)
.saturating_add(Weight::from_parts(0, 139))
// Standard Error: 28_534
.saturating_add(Weight::from_parts(45_736_695, 0).saturating_mul(k.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(k.into())))
.saturating_add(T::DbWeight::get().writes(2))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(k.into())))
.saturating_add(Weight::from_parts(0, 189).saturating_mul(k.into()))
}
/// Storage: `Crowdloan::Funds` (r:1 w:1)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn dissolve() -> Weight {
// Proof Size summary in bytes:
// Measured: `515`
// Estimated: `6196`
// Minimum execution time: 52_853_000 picoseconds.
Weight::from_parts(58_194_000, 0)
.saturating_add(Weight::from_parts(0, 6196))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
}
/// Storage: `Crowdloan::Funds` (r:1 w:1)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn edit() -> Weight {
// Proof Size summary in bytes:
// Measured: `235`
// Estimated: `3700`
// Minimum execution time: 22_698_000 picoseconds.
Weight::from_parts(25_666_000, 0)
.saturating_add(Weight::from_parts(0, 3700))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Crowdloan::Funds` (r:1 w:0)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1)
/// Proof: UNKNOWN KEY `0xd861ea1ebf4800d4b89f4ff787ad79ee96d9a708c85b57da7eb8f9ddeda61291` (r:1 w:1)
fn add_memo() -> Weight {
// Proof Size summary in bytes:
// Measured: `413`
// Estimated: `3878`
// Minimum execution time: 33_040_000 picoseconds.
Weight::from_parts(34_518_000, 0)
.saturating_add(Weight::from_parts(0, 3878))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Crowdloan::Funds` (r:1 w:0)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Crowdloan::NewRaise` (r:1 w:1)
/// Proof: `Crowdloan::NewRaise` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn poke() -> Weight {
// Proof Size summary in bytes:
// Measured: `239`
// Estimated: `3704`
// Minimum execution time: 22_259_000 picoseconds.
Weight::from_parts(23_547_000, 0)
.saturating_add(Weight::from_parts(0, 3704))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Auctions::AuctionInfo` (r:1 w:0)
/// Proof: `Auctions::AuctionInfo` (`max_values`: Some(1), `max_size`: Some(8), added: 503, mode: `MaxEncodedLen`)
/// Storage: `Crowdloan::EndingsCount` (r:1 w:1)
/// Proof: `Crowdloan::EndingsCount` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Crowdloan::NewRaise` (r:1 w:1)
/// Proof: `Crowdloan::NewRaise` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Crowdloan::Funds` (r:100 w:0)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Auctions::AuctionCounter` (r:1 w:0)
/// Proof: `Auctions::AuctionCounter` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
/// Storage: `Paras::ParaLifecycles` (r:100 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Slots::Leases` (r:100 w:0)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Auctions::Winning` (r:1 w:1)
/// Proof: `Auctions::Winning` (`max_values`: None, `max_size`: Some(1920), added: 4395, mode: `MaxEncodedLen`)
/// Storage: `Auctions::ReservedAmounts` (r:100 w:100)
/// Proof: `Auctions::ReservedAmounts` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`)
/// Storage: `System::Account` (r:100 w:100)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// The range of component `n` is `[2, 100]`.
fn on_initialize(n: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `231 + n * (356 ±0)`
// Estimated: `5385 + n * (2832 ±0)`
// Minimum execution time: 137_657_000 picoseconds.
Weight::from_parts(10_705_659, 0)
.saturating_add(Weight::from_parts(0, 5385))
// Standard Error: 38_062
.saturating_add(Weight::from_parts(63_582_684, 0).saturating_mul(n.into()))
.saturating_add(T::DbWeight::get().reads(5))
.saturating_add(T::DbWeight::get().reads((5_u64).saturating_mul(n.into())))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(n.into())))
.saturating_add(Weight::from_parts(0, 2832).saturating_mul(n.into()))
}
}
@@ -0,0 +1,227 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_common::paras_registrar`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_common::paras_registrar
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_common::paras_registrar`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_common::paras_registrar::WeightInfo for WeightInfo<T> {
/// Storage: `Registrar::NextFreeParaId` (r:1 w:1)
/// Proof: `Registrar::NextFreeParaId` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Registrar::Paras` (r:1 w:1)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn reserve() -> Weight {
// Proof Size summary in bytes:
// Measured: `59`
// Estimated: `3524`
// Minimum execution time: 29_694_000 picoseconds.
Weight::from_parts(30_576_000, 0)
.saturating_add(Weight::from_parts(0, 3524))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Registrar::Paras` (r:1 w:1)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteMap` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteMap` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHash` (r:1 w:1)
/// Proof: `Paras::CodeByHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::ActiveValidatorKeys` (r:1 w:0)
/// Proof: `ParasShared::ActiveValidatorKeys` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteList` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHashRefs` (r:1 w:1)
/// Proof: `Paras::CodeByHashRefs` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CurrentCodeHash` (r:0 w:1)
/// Proof: `Paras::CurrentCodeHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::UpcomingParasGenesis` (r:0 w:1)
/// Proof: `Paras::UpcomingParasGenesis` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn register() -> Weight {
// Proof Size summary in bytes:
// Measured: `315`
// Estimated: `3780`
// Minimum execution time: 42_435_823_000 picoseconds.
Weight::from_parts(42_629_021_000, 0)
.saturating_add(Weight::from_parts(0, 3780))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(8))
}
/// Storage: `Registrar::Paras` (r:1 w:1)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteMap` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteMap` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHash` (r:1 w:1)
/// Proof: `Paras::CodeByHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::ActiveValidatorKeys` (r:1 w:0)
/// Proof: `ParasShared::ActiveValidatorKeys` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteList` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHashRefs` (r:1 w:1)
/// Proof: `Paras::CodeByHashRefs` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CurrentCodeHash` (r:0 w:1)
/// Proof: `Paras::CurrentCodeHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::UpcomingParasGenesis` (r:0 w:1)
/// Proof: `Paras::UpcomingParasGenesis` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn force_register() -> Weight {
// Proof Size summary in bytes:
// Measured: `232`
// Estimated: `3697`
// Minimum execution time: 42_304_137_000 picoseconds.
Weight::from_parts(42_578_673_000, 0)
.saturating_add(Weight::from_parts(0, 3697))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(8))
}
/// Storage: `Registrar::Paras` (r:1 w:1)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::FutureCodeHash` (r:1 w:0)
/// Proof: `Paras::FutureCodeHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::BookStateFor` (r:1 w:0)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `Registrar::PendingSwap` (r:0 w:1)
/// Proof: `Registrar::PendingSwap` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn deregister() -> Weight {
// Proof Size summary in bytes:
// Measured: `462`
// Estimated: `3927`
// Minimum execution time: 57_713_000 picoseconds.
Weight::from_parts(60_916_000, 0)
.saturating_add(Weight::from_parts(0, 3927))
.saturating_add(T::DbWeight::get().reads(6))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Registrar::Paras` (r:1 w:0)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:2 w:2)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Registrar::PendingSwap` (r:1 w:1)
/// Proof: `Registrar::PendingSwap` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Crowdloan::Funds` (r:2 w:2)
/// Proof: `Crowdloan::Funds` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Slots::Leases` (r:2 w:2)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:0)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn swap() -> Weight {
// Proof Size summary in bytes:
// Measured: `897`
// Estimated: `6837`
// Minimum execution time: 106_644_000 picoseconds.
Weight::from_parts(112_061_000, 0)
.saturating_add(Weight::from_parts(0, 6837))
.saturating_add(T::DbWeight::get().reads(14))
.saturating_add(T::DbWeight::get().writes(8))
}
/// Storage: `Paras::FutureCodeHash` (r:1 w:1)
/// Proof: `Paras::FutureCodeHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::UpgradeRestrictionSignal` (r:1 w:1)
/// Proof: `Paras::UpgradeRestrictionSignal` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CurrentCodeHash` (r:1 w:0)
/// Proof: `Paras::CurrentCodeHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::UpgradeCooldowns` (r:1 w:1)
/// Proof: `Paras::UpgradeCooldowns` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteMap` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteMap` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHash` (r:1 w:1)
/// Proof: `Paras::CodeByHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::ActiveValidatorKeys` (r:1 w:0)
/// Proof: `ParasShared::ActiveValidatorKeys` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteList` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHashRefs` (r:1 w:1)
/// Proof: `Paras::CodeByHashRefs` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `b` is `[9, 3145728]`.
fn schedule_code_upgrade(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `201`
// Estimated: `3666`
// Minimum execution time: 41_874_000 picoseconds.
Weight::from_parts(42_554_000, 0)
.saturating_add(Weight::from_parts(0, 3666))
// Standard Error: 103
.saturating_add(Weight::from_parts(10_806, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(7))
}
/// Storage: `Paras::Heads` (r:0 w:1)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `b` is `[1, 1048576]`.
fn set_current_head(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 7_265_000 picoseconds.
Weight::from_parts(7_411_000, 0)
.saturating_add(Weight::from_parts(0, 0))
// Standard Error: 31
.saturating_add(Weight::from_parts(3_656, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,132 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_common::slots`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_common::slots
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_common::slots`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_common::slots::WeightInfo for WeightInfo<T> {
/// Storage: `Slots::Leases` (r:1 w:1)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:1 w:1)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn force_lease() -> Weight {
// Proof Size summary in bytes:
// Measured: `320`
// Estimated: `3785`
// Minimum execution time: 30_768_000 picoseconds.
Weight::from_parts(32_170_000, 0)
.saturating_add(Weight::from_parts(0, 3785))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `Paras::Teyrchains` (r:1 w:0)
/// Proof: `Paras::Teyrchains` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Slots::Leases` (r:101 w:100)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:200 w:200)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `c` is `[0, 100]`.
/// The range of component `t` is `[0, 100]`.
fn manage_lease_period_start(c: u32, t: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `594 + c * (20 ±0) + t * (234 ±0)`
// Estimated: `4065 + c * (2496 ±0) + t * (2709 ±0)`
// Minimum execution time: 863_592_000 picoseconds.
Weight::from_parts(870_348_000, 0)
.saturating_add(Weight::from_parts(0, 4065))
// Standard Error: 108_559
.saturating_add(Weight::from_parts(3_564_970, 0).saturating_mul(c.into()))
// Standard Error: 108_559
.saturating_add(Weight::from_parts(10_619_180, 0).saturating_mul(t.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(t.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(t.into())))
.saturating_add(Weight::from_parts(0, 2496).saturating_mul(c.into()))
.saturating_add(Weight::from_parts(0, 2709).saturating_mul(t.into()))
}
/// Storage: `Slots::Leases` (r:1 w:1)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:8 w:8)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
fn clear_all_leases() -> Weight {
// Proof Size summary in bytes:
// Measured: `2792`
// Estimated: `21814`
// Minimum execution time: 141_337_000 picoseconds.
Weight::from_parts(145_252_000, 0)
.saturating_add(Weight::from_parts(0, 21814))
.saturating_add(T::DbWeight::get().reads(9))
.saturating_add(T::DbWeight::get().writes(9))
}
/// Storage: `Slots::Leases` (r:1 w:0)
/// Proof: `Slots::Leases` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:1)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ActionsQueue` (r:1 w:1)
/// Proof: `Paras::ActionsQueue` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn trigger_onboard() -> Weight {
// Proof Size summary in bytes:
// Measured: `612`
// Estimated: `4077`
// Minimum execution time: 29_294_000 picoseconds.
Weight::from_parts(30_872_000, 0)
.saturating_add(Weight::from_parts(0, 4077))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().writes(2))
}
}
@@ -0,0 +1,192 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_teyrchains::configuration`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-26, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `13d69b199c54`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_teyrchains::configuration
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_teyrchains::configuration`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_teyrchains::configuration::WeightInfo for WeightInfo<T> {
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_block_number() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_901_000 picoseconds.
Weight::from_parts(11_468_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_u32() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_847_000 picoseconds.
Weight::from_parts(11_499_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_option_u32() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_143_000 picoseconds.
Weight::from_parts(11_488_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Benchmark::Override` (r:0 w:0)
/// Proof: `Benchmark::Override` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn set_hrmp_open_request_ttl() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_000_000_000_000 picoseconds.
Weight::from_parts(2_000_000_000_000, 0)
.saturating_add(Weight::from_parts(0, 0))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_balance() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_126_000 picoseconds.
Weight::from_parts(11_416_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_executor_params() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 13_119_000 picoseconds.
Weight::from_parts(13_612_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_perbill() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_072_000 picoseconds.
Weight::from_parts(11_412_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_node_feature() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 13_268_000 picoseconds.
Weight::from_parts(13_664_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn set_config_with_scheduler_params() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 11_047_000 picoseconds.
Weight::from_parts(11_298_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,123 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_teyrchains::coretime`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_teyrchains::coretime
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_teyrchains::coretime`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_teyrchains::coretime::WeightInfo for WeightInfo<T> {
/// Storage: `OnDemandAssignmentProvider::Revenue` (r:1 w:1)
/// Proof: `OnDemandAssignmentProvider::Revenue` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `System::Account` (r:2 w:2)
/// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:0)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn request_revenue_at() -> Weight {
// Proof Size summary in bytes:
// Measured: `3116`
// Estimated: `6581`
// Minimum execution time: 99_786_000 picoseconds.
Weight::from_parts(102_776_000, 0)
.saturating_add(Weight::from_parts(0, 6581))
.saturating_add(T::DbWeight::get().reads(8))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `Configuration::PendingConfigs` (r:1 w:1)
/// Proof: `Configuration::PendingConfigs` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Configuration::BypassConsistencyCheck` (r:1 w:0)
/// Proof: `Configuration::BypassConsistencyCheck` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::CurrentSessionIndex` (r:1 w:0)
/// Proof: `ParasShared::CurrentSessionIndex` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn request_core_count() -> Weight {
// Proof Size summary in bytes:
// Measured: `151`
// Estimated: `1636`
// Minimum execution time: 10_716_000 picoseconds.
Weight::from_parts(11_141_000, 0)
.saturating_add(Weight::from_parts(0, 1636))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `CoretimeAssignmentProvider::CoreDescriptors` (r:1 w:1)
/// Proof: `CoretimeAssignmentProvider::CoreDescriptors` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `CoretimeAssignmentProvider::CoreSchedules` (r:0 w:1)
/// Proof: `CoretimeAssignmentProvider::CoreSchedules` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `s` is `[1, 100]`.
fn assign_core(s: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `180`
// Estimated: `3645`
// Minimum execution time: 12_223_000 picoseconds.
Weight::from_parts(12_949_530, 0)
.saturating_add(Weight::from_parts(0, 3645))
// Standard Error: 335
.saturating_add(Weight::from_parts(8_625, 0).saturating_mul(s.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(2))
}
/// Storage: `OnDemandAssignmentProvider::Credits` (r:1 w:1)
/// Proof: `OnDemandAssignmentProvider::Credits` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn credit_account() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3607`
// Minimum execution time: 9_810_000 picoseconds.
Weight::from_parts(10_300_000, 0)
.saturating_add(Weight::from_parts(0, 3607))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,65 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_teyrchains::disputes`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_teyrchains::disputes
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_teyrchains::disputes`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_teyrchains::disputes::WeightInfo for WeightInfo<T> {
/// Storage: `ParasDisputes::Frozen` (r:0 w:1)
/// Proof: `ParasDisputes::Frozen` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
fn force_unfreeze() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
// Minimum execution time: 2_616_000 picoseconds.
Weight::from_parts(2_747_000, 0)
.saturating_add(Weight::from_parts(0, 0))
.saturating_add(T::DbWeight::get().writes(1))
}
}
@@ -0,0 +1,384 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_teyrchains::hrmp`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-22, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_teyrchains::hrmp
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_teyrchains::hrmp`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_teyrchains::hrmp::WeightInfo for WeightInfo<T> {
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:1 w:0)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn hrmp_init_open_channel() -> Weight {
// Proof Size summary in bytes:
// Measured: `510`
// Estimated: `3975`
// Minimum execution time: 52_537_000 picoseconds.
Weight::from_parts(54_902_000, 0)
.saturating_add(Weight::from_parts(0, 3975))
.saturating_add(T::DbWeight::get().reads(10))
.saturating_add(T::DbWeight::get().writes(5))
}
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpAcceptedChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpAcceptedChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn hrmp_accept_open_channel() -> Weight {
// Proof Size summary in bytes:
// Measured: `722`
// Estimated: `4187`
// Minimum execution time: 51_535_000 picoseconds.
Weight::from_parts(54_023_000, 0)
.saturating_add(Weight::from_parts(0, 4187))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Hrmp::HrmpChannels` (r:1 w:0)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpCloseChannelRequests` (r:1 w:1)
/// Proof: `Hrmp::HrmpCloseChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpCloseChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpCloseChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:1 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:1 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn hrmp_close_channel() -> Weight {
// Proof Size summary in bytes:
// Measured: `835`
// Estimated: `4300`
// Minimum execution time: 53_232_000 picoseconds.
Weight::from_parts(55_429_000, 0)
.saturating_add(Weight::from_parts(0, 4300))
.saturating_add(T::DbWeight::get().reads(7))
.saturating_add(T::DbWeight::get().writes(4))
}
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:128 w:128)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:128 w:128)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:254 w:254)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpAcceptedChannelRequestCount` (r:0 w:1)
/// Proof: `Hrmp::HrmpAcceptedChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannelContents` (r:0 w:254)
/// Proof: `Hrmp::HrmpChannelContents` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:0 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `i` is `[0, 127]`.
/// The range of component `e` is `[0, 127]`.
fn force_clean_hrmp(i: u32, e: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `297 + e * (100 ±0) + i * (100 ±0)`
// Estimated: `3759 + e * (2575 ±0) + i * (2575 ±0)`
// Minimum execution time: 1_442_401_000 picoseconds.
Weight::from_parts(1_459_213_000, 0)
.saturating_add(Weight::from_parts(0, 3759))
// Standard Error: 133_411
.saturating_add(Weight::from_parts(4_222_698, 0).saturating_mul(i.into()))
// Standard Error: 133_411
.saturating_add(Weight::from_parts(4_358_958, 0).saturating_mul(e.into()))
.saturating_add(T::DbWeight::get().reads(2))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(i.into())))
.saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(e.into())))
.saturating_add(T::DbWeight::get().writes(4))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(i.into())))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(e.into())))
.saturating_add(Weight::from_parts(0, 2575).saturating_mul(e.into()))
.saturating_add(Weight::from_parts(0, 2575).saturating_mul(i.into()))
}
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:128 w:128)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:256 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:128 w:128)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:128 w:128)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:128 w:128)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpAcceptedChannelRequestCount` (r:128 w:128)
/// Proof: `Hrmp::HrmpAcceptedChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:0 w:128)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `c` is `[0, 128]`.
fn force_process_hrmp_open(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `525 + c * (136 ±0)`
// Estimated: `1980 + c * (5086 ±0)`
// Minimum execution time: 8_418_000 picoseconds.
Weight::from_parts(3_865_971, 0)
.saturating_add(Weight::from_parts(0, 1980))
// Standard Error: 21_427
.saturating_add(Weight::from_parts(25_857_386, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().reads((7_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((6_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 5086).saturating_mul(c.into()))
}
/// Storage: `Hrmp::HrmpCloseChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpCloseChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:128 w:128)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:128 w:128)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:128 w:128)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpCloseChannelRequests` (r:0 w:128)
/// Proof: `Hrmp::HrmpCloseChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannelContents` (r:0 w:128)
/// Proof: `Hrmp::HrmpChannelContents` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `c` is `[0, 128]`.
fn force_process_hrmp_close(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `368 + c * (124 ±0)`
// Estimated: `1828 + c * (2600 ±0)`
// Minimum execution time: 7_036_000 picoseconds.
Weight::from_parts(2_042_224, 0)
.saturating_add(Weight::from_parts(0, 1828))
// Standard Error: 19_415
.saturating_add(Weight::from_parts(15_766_725, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((5_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 2600).saturating_mul(c.into()))
}
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `c` is `[0, 128]`.
fn hrmp_cancel_open_request(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `1059 + c * (13 ±0)`
// Estimated: `4328 + c * (15 ±0)`
// Minimum execution time: 22_232_000 picoseconds.
Weight::from_parts(31_115_368, 0)
.saturating_add(Weight::from_parts(0, 4328))
// Standard Error: 2_350
.saturating_add(Weight::from_parts(140_575, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(3))
.saturating_add(T::DbWeight::get().writes(3))
.saturating_add(Weight::from_parts(0, 15).saturating_mul(c.into()))
}
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:128 w:128)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `c` is `[0, 128]`.
fn clean_open_channel_requests(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `276 + c * (63 ±0)`
// Estimated: `1755 + c * (2538 ±0)`
// Minimum execution time: 5_195_000 picoseconds.
Weight::from_parts(7_840_420, 0)
.saturating_add(Weight::from_parts(0, 1755))
// Standard Error: 5_423
.saturating_add(Weight::from_parts(4_251_353, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes(1))
.saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 2538).saturating_mul(c.into()))
}
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:1 w:0)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:2 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:2 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpAcceptedChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpAcceptedChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// The range of component `c` is `[0, 1]`.
fn force_open_hrmp_channel(c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `510 + c * (235 ±0)`
// Estimated: `6450 + c * (235 ±0)`
// Minimum execution time: 75_316_000 picoseconds.
Weight::from_parts(78_457_616, 0)
.saturating_add(Weight::from_parts(0, 6450))
// Standard Error: 261_131
.saturating_add(Weight::from_parts(14_565_983, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(16))
.saturating_add(T::DbWeight::get().writes(8))
.saturating_add(Weight::from_parts(0, 235).saturating_mul(c.into()))
}
/// Storage: `Paras::ParaLifecycles` (r:1 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:1 w:0)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:2 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:2 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:1 w:0)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpAcceptedChannelRequestCount` (r:1 w:1)
/// Proof: `Hrmp::HrmpAcceptedChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn establish_system_channel() -> Weight {
// Proof Size summary in bytes:
// Measured: `510`
// Estimated: `6450`
// Minimum execution time: 75_246_000 picoseconds.
Weight::from_parts(78_578_000, 0)
.saturating_add(Weight::from_parts(0, 6450))
.saturating_add(T::DbWeight::get().reads(16))
.saturating_add(T::DbWeight::get().writes(8))
}
/// Storage: `Hrmp::HrmpChannels` (r:1 w:1)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn poke_channel_deposits() -> Weight {
// Proof Size summary in bytes:
// Measured: `296`
// Estimated: `3761`
// Minimum execution time: 15_499_000 picoseconds.
Weight::from_parts(16_347_000, 0)
.saturating_add(Weight::from_parts(0, 3761))
.saturating_add(T::DbWeight::get().reads(1))
.saturating_add(T::DbWeight::get().writes(1))
}
/// Storage: `Paras::ParaLifecycles` (r:2 w:0)
/// Proof: `Paras::ParaLifecycles` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequests` (r:2 w:2)
/// Proof: `Hrmp::HrmpOpenChannelRequests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:2 w:0)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpEgressChannelsIndex` (r:2 w:0)
/// Proof: `Hrmp::HrmpEgressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestCount` (r:2 w:2)
/// Proof: `Hrmp::HrmpOpenChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpOpenChannelRequestsList` (r:1 w:1)
/// Proof: `Hrmp::HrmpOpenChannelRequestsList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `XcmPallet::SupportedVersion` (r:2 w:0)
/// Proof: `XcmPallet::SupportedVersion` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:2 w:0)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueueHeads` (r:2 w:2)
/// Proof: `Dmp::DownwardMessageQueueHeads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpIngressChannelsIndex` (r:2 w:0)
/// Proof: `Hrmp::HrmpIngressChannelsIndex` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpAcceptedChannelRequestCount` (r:2 w:2)
/// Proof: `Hrmp::HrmpAcceptedChannelRequestCount` (`max_values`: None, `max_size`: None, mode: `Measured`)
fn establish_channel_with_system() -> Weight {
// Proof Size summary in bytes:
// Measured: `510`
// Estimated: `6450`
// Minimum execution time: 124_212_000 picoseconds.
Weight::from_parts(127_879_000, 0)
.saturating_add(Weight::from_parts(0, 6450))
.saturating_add(T::DbWeight::get().reads(23))
.saturating_add(T::DbWeight::get().writes(11))
}
}
@@ -0,0 +1,130 @@
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Pezkuwi.
// Pezkuwi is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Pezkuwi is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
//! Autogenerated weights for `pezkuwi_runtime_teyrchains::inclusion`
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 32.0.0
//! DATE: 2025-02-21, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
//! HOSTNAME: `d3a9aad6f7a3`, 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/pezkuwichain-runtime/pezkuwichain_runtime.wasm
// --pallet=pezkuwi_runtime_teyrchains::inclusion
// --header=/__w/pezkuwi-sdk/pezkuwi-sdk/pezkuwi/file_header.txt
// --output=./pezkuwi/runtime/pezkuwichain/src/weights
// --wasm-execution=compiled
// --steps=50
// --repeat=20
// --heap-pages=4096
// --no-storage-info
// --no-min-squares
// --no-median-slopes
#![cfg_attr(rustfmt, rustfmt_skip)]
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(missing_docs)]
use frame_support::{traits::Get, weights::Weight};
use core::marker::PhantomData;
/// Weight functions for `pezkuwi_runtime_teyrchains::inclusion`.
pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pezkuwi_runtime_teyrchains::inclusion::WeightInfo for WeightInfo<T> {
/// Storage: `Paras::FutureCodeHash` (r:1 w:1)
/// Proof: `Paras::FutureCodeHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CurrentCodeHash` (r:1 w:0)
/// Proof: `Paras::CurrentCodeHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::UpgradeCooldowns` (r:1 w:1)
/// Proof: `Paras::UpgradeCooldowns` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteMap` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteMap` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHash` (r:1 w:1)
/// Proof: `Paras::CodeByHash` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `ParasShared::ActiveValidatorKeys` (r:1 w:0)
/// Proof: `ParasShared::ActiveValidatorKeys` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::PvfActiveVoteList` (r:1 w:1)
/// Proof: `Paras::PvfActiveVoteList` (`max_values`: Some(1), `max_size`: None, mode: `Measured`)
/// Storage: `Paras::CodeByHashRefs` (r:1 w:1)
/// Proof: `Paras::CodeByHashRefs` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DownwardMessageQueues` (r:1 w:1)
/// Proof: `Dmp::DownwardMessageQueues` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Dmp::DeliveryFeeFactor` (r:1 w:1)
/// Proof: `Dmp::DeliveryFeeFactor` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `MessageQueue::BookStateFor` (r:1 w:1)
/// Proof: `MessageQueue::BookStateFor` (`max_values`: None, `max_size`: Some(55), added: 2530, mode: `MaxEncodedLen`)
/// Storage: `MessageQueue::Pages` (r:1 w:2)
/// Proof: `MessageQueue::Pages` (`max_values`: None, `max_size`: Some(32818), added: 35293, mode: `MaxEncodedLen`)
/// Storage: `Hrmp::HrmpChannelDigests` (r:3 w:3)
/// Proof: `Hrmp::HrmpChannelDigests` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannels` (r:2 w:2)
/// Proof: `Hrmp::HrmpChannels` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Hrmp::HrmpChannelContents` (r:2 w:2)
/// Proof: `Hrmp::HrmpChannelContents` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::FutureCodeUpgrades` (r:1 w:0)
/// Proof: `Paras::FutureCodeUpgrades` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Registrar::Paras` (r:1 w:0)
/// Proof: `Registrar::Paras` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Proof: UNKNOWN KEY `0x3a72656c61795f64697370617463685f71756575655f72656d61696e696e675f` (r:0 w:1)
/// Storage: `Hrmp::HrmpWatermarks` (r:0 w:1)
/// Proof: `Hrmp::HrmpWatermarks` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::Heads` (r:0 w:1)
/// Proof: `Paras::Heads` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::UpgradeGoAheadSignal` (r:0 w:1)
/// Proof: `Paras::UpgradeGoAheadSignal` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::MostRecentContext` (r:0 w:1)
/// Proof: `Paras::MostRecentContext` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: `Paras::UpgradeRestrictionSignal` (r:0 w:1)
/// Proof: `Paras::UpgradeRestrictionSignal` (`max_values`: None, `max_size`: None, mode: `Measured`)
/// Storage: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
/// Proof: UNKNOWN KEY `0xf5207f03cfdce586301014700e2c2593fad157e461d71fd4c1f936839a5f1f3e` (r:0 w:1)
/// The range of component `u` is `[0, 2]`.
/// The range of component `h` is `[0, 2]`.
/// The range of component `c` is `[0, 1]`.
fn enact_candidate(u: u32, h: u32, c: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `330 + c * (16114 ±0) + h * (92 ±0) + u * (32955 ±0)`
// Estimated: `36283 + c * (16122 ±370) + h * (7594 ±341) + u * (20798 ±341)`
// Minimum execution time: 380_428_000 picoseconds.
Weight::from_parts(69_678_364, 0)
.saturating_add(Weight::from_parts(0, 36283))
// Standard Error: 289_403
.saturating_add(Weight::from_parts(136_373_549, 0).saturating_mul(u.into()))
// Standard Error: 289_403
.saturating_add(Weight::from_parts(150_488_651, 0).saturating_mul(h.into()))
// Standard Error: 479_576
.saturating_add(Weight::from_parts(65_201_475, 0).saturating_mul(c.into()))
.saturating_add(T::DbWeight::get().reads(4))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(u.into())))
.saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(h.into())))
.saturating_add(T::DbWeight::get().reads((9_u64).saturating_mul(c.into())))
.saturating_add(T::DbWeight::get().writes(5))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(u.into())))
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(h.into())))
.saturating_add(T::DbWeight::get().writes((8_u64).saturating_mul(c.into())))
.saturating_add(Weight::from_parts(0, 16122).saturating_mul(c.into()))
.saturating_add(Weight::from_parts(0, 7594).saturating_mul(h.into()))
.saturating_add(Weight::from_parts(0, 20798).saturating_mul(u.into()))
}
}

Some files were not shown because too many files have changed in this diff Show More