feat: Rebrand Polkadot/Substrate references to PezkuwiChain
This commit systematically rebrands various references from Parity Technologies' Polkadot/Substrate ecosystem to PezkuwiChain within the kurdistan-sdk. Key changes include: - Updated external repository URLs (zombienet-sdk, parity-db, parity-scale-codec, wasm-instrument) to point to pezkuwichain forks. - Modified internal documentation and code comments to reflect PezkuwiChain naming and structure. - Replaced direct references to with or specific paths within the for XCM, Pezkuwi, and other modules. - Cleaned up deprecated issue and PR references in various and files, particularly in and modules. - Adjusted image and logo URLs in documentation to point to PezkuwiChain assets. - Removed or rephrased comments related to external Polkadot/Substrate PRs and issues. This is a significant step towards fully customizing the SDK for the PezkuwiChain ecosystem.
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
[package]
|
||||
name = "pezpallet-session-benchmarking"
|
||||
version = "28.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "FRAME sessions pallet benchmarking"
|
||||
readme = "README.md"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { workspace = true }
|
||||
pezframe-benchmarking = { workspace = true }
|
||||
pezframe-support = { workspace = true }
|
||||
pezframe-system = { workspace = true }
|
||||
pezpallet-session = { workspace = true }
|
||||
pezpallet-staking = { workspace = true }
|
||||
rand = { features = ["std_rng"], workspace = true }
|
||||
pezsp-runtime = { workspace = true }
|
||||
pezsp-session = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
codec = { features = ["derive"], workspace = true, default-features = true }
|
||||
pezframe-election-provider-support = { workspace = true, default-features = true }
|
||||
pezpallet-balances = { workspace = true, default-features = true }
|
||||
pezpallet-staking-reward-curve = { workspace = true, default-features = true }
|
||||
pezpallet-timestamp = { workspace = true, default-features = true }
|
||||
scale-info = { workspace = true, default-features = true }
|
||||
pezsp-io = { workspace = true, default-features = true }
|
||||
pezsp-staking = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"pezframe-benchmarking/std",
|
||||
"pezframe-election-provider-support/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"pezpallet-session/std",
|
||||
"pezpallet-staking/std",
|
||||
"rand/std",
|
||||
"pezsp-runtime/std",
|
||||
"pezsp-session/std",
|
||||
"pezsp-staking/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-benchmarking/runtime-benchmarks",
|
||||
"pezframe-election-provider-support/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-session/runtime-benchmarks",
|
||||
"pezpallet-staking-reward-curve/runtime-benchmarks",
|
||||
"pezpallet-staking/runtime-benchmarks",
|
||||
"pezpallet-timestamp/runtime-benchmarks",
|
||||
"pezsp-io/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
"pezsp-session/runtime-benchmarks",
|
||||
"pezsp-staking/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,3 @@
|
||||
Benchmarks for the Session Pallet.
|
||||
|
||||
License: Apache-2.0
|
||||
@@ -0,0 +1,189 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Benchmarks for the Session Pallet.
|
||||
// This is separated into its own crate due to cyclic dependency issues.
|
||||
|
||||
use alloc::{vec, vec::Vec};
|
||||
use pezsp_runtime::traits::{One, StaticLookup, TrailingZeroInput};
|
||||
|
||||
use codec::Decode;
|
||||
use pezframe_benchmarking::v2::*;
|
||||
use pezframe_support::{
|
||||
assert_ok,
|
||||
traits::{Get, KeyOwnerProofSystem, OnInitialize},
|
||||
};
|
||||
use pezframe_system::{pezpallet_prelude::BlockNumberFor, RawOrigin};
|
||||
use pezpallet_session::{historical::Pallet as Historical, Pallet as Session, *};
|
||||
use pezpallet_staking::{
|
||||
benchmarking::create_validator_with_nominators, testing_utils::create_validators,
|
||||
MaxNominationsOf, RewardDestination,
|
||||
};
|
||||
|
||||
const MAX_VALIDATORS: u32 = 1000;
|
||||
|
||||
pub struct Pallet<T: Config>(pezpallet_session::Pallet<T>);
|
||||
pub trait Config:
|
||||
pezpallet_session::Config + pezpallet_session::historical::Config + pezpallet_staking::Config
|
||||
{
|
||||
}
|
||||
|
||||
impl<T: Config> OnInitialize<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn on_initialize(n: BlockNumberFor<T>) -> pezframe_support::weights::Weight {
|
||||
pezpallet_session::Pallet::<T>::on_initialize(n)
|
||||
}
|
||||
}
|
||||
|
||||
#[benchmarks]
|
||||
mod benchmarks {
|
||||
use super::*;
|
||||
|
||||
#[benchmark]
|
||||
fn set_keys() -> Result<(), BenchmarkError> {
|
||||
let n = MaxNominationsOf::<T>::get();
|
||||
let (v_stash, _) = create_validator_with_nominators::<T>(
|
||||
n,
|
||||
MaxNominationsOf::<T>::get(),
|
||||
false,
|
||||
true,
|
||||
RewardDestination::Staked,
|
||||
)?;
|
||||
let v_controller = pezpallet_staking::Pallet::<T>::bonded(&v_stash).ok_or("not stash")?;
|
||||
|
||||
let keys = T::Keys::decode(&mut TrailingZeroInput::zeroes()).unwrap();
|
||||
let proof: Vec<u8> = vec![0, 1, 2, 3];
|
||||
// Whitelist controller account from further DB operations.
|
||||
let v_controller_key = pezframe_system::Account::<T>::hashed_key_for(&v_controller);
|
||||
pezframe_benchmarking::benchmarking::add_to_whitelist(v_controller_key.into());
|
||||
assert_ok!(Session::<T>::ensure_can_pay_key_deposit(&v_controller));
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Signed(v_controller), keys, proof);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark]
|
||||
fn purge_keys() -> Result<(), BenchmarkError> {
|
||||
let n = MaxNominationsOf::<T>::get();
|
||||
let (v_stash, _) = create_validator_with_nominators::<T>(
|
||||
n,
|
||||
MaxNominationsOf::<T>::get(),
|
||||
false,
|
||||
true,
|
||||
RewardDestination::Staked,
|
||||
)?;
|
||||
let v_controller = pezpallet_staking::Pallet::<T>::bonded(&v_stash).ok_or("not stash")?;
|
||||
let keys = T::Keys::decode(&mut TrailingZeroInput::zeroes()).unwrap();
|
||||
let proof: Vec<u8> = vec![0, 1, 2, 3];
|
||||
assert_ok!(Session::<T>::ensure_can_pay_key_deposit(&v_controller));
|
||||
Session::<T>::set_keys(RawOrigin::Signed(v_controller.clone()).into(), keys, proof)?;
|
||||
// Whitelist controller account from further DB operations.
|
||||
let v_controller_key = pezframe_system::Account::<T>::hashed_key_for(&v_controller);
|
||||
pezframe_benchmarking::benchmarking::add_to_whitelist(v_controller_key.into());
|
||||
|
||||
#[extrinsic_call]
|
||||
_(RawOrigin::Signed(v_controller));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[benchmark(extra)]
|
||||
fn check_membership_proof_current_session(n: Linear<2, MAX_VALIDATORS>) {
|
||||
let (key, key_owner_proof1) = check_membership_proof_setup::<T>(n);
|
||||
let key_owner_proof2 = key_owner_proof1.clone();
|
||||
|
||||
#[block]
|
||||
{
|
||||
Historical::<T>::check_proof(key, key_owner_proof1);
|
||||
}
|
||||
|
||||
assert!(Historical::<T>::check_proof(key, key_owner_proof2).is_some());
|
||||
}
|
||||
|
||||
#[benchmark(extra)]
|
||||
fn check_membership_proof_historical_session(n: Linear<2, MAX_VALIDATORS>) {
|
||||
let (key, key_owner_proof1) = check_membership_proof_setup::<T>(n);
|
||||
|
||||
// skip to the next session so that the session is historical
|
||||
// and the membership merkle proof must be checked.
|
||||
Session::<T>::rotate_session();
|
||||
|
||||
let key_owner_proof2 = key_owner_proof1.clone();
|
||||
|
||||
#[block]
|
||||
{
|
||||
Historical::<T>::check_proof(key, key_owner_proof1);
|
||||
}
|
||||
|
||||
assert!(Historical::<T>::check_proof(key, key_owner_proof2).is_some());
|
||||
}
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
Pallet,
|
||||
crate::mock::new_test_ext(),
|
||||
crate::mock::Test,
|
||||
extra = false
|
||||
);
|
||||
}
|
||||
|
||||
/// Sets up the benchmark for checking a membership proof. It creates the given
|
||||
/// number of validators, sets random session keys and then creates a membership
|
||||
/// proof for the first authority and returns its key and the proof.
|
||||
fn check_membership_proof_setup<T: Config>(
|
||||
n: u32,
|
||||
) -> ((pezsp_runtime::KeyTypeId, &'static [u8; 32]), pezsp_session::MembershipProof) {
|
||||
pezpallet_staking::ValidatorCount::<T>::put(n);
|
||||
|
||||
// create validators and set random session keys
|
||||
for (n, who) in create_validators::<T>(n, 1000).unwrap().into_iter().enumerate() {
|
||||
use rand::{RngCore, SeedableRng};
|
||||
|
||||
let validator = T::Lookup::lookup(who).unwrap();
|
||||
let controller = pezpallet_staking::Pallet::<T>::bonded(&validator).unwrap();
|
||||
|
||||
let keys = {
|
||||
let mut keys = [0u8; 128];
|
||||
|
||||
// we keep the keys for the first validator as 0x00000...
|
||||
if n > 0 {
|
||||
let mut rng = rand::rngs::StdRng::seed_from_u64(n as u64);
|
||||
rng.fill_bytes(&mut keys);
|
||||
}
|
||||
|
||||
keys
|
||||
};
|
||||
|
||||
// TODO: this benchmark is broken, session keys cannot be decoded into 128 bytes anymore,
|
||||
// but not an issue for CI since it is `extra`.
|
||||
let keys: T::Keys = Decode::decode(&mut &keys[..]).unwrap();
|
||||
let proof: Vec<u8> = vec![];
|
||||
|
||||
Session::<T>::set_keys(RawOrigin::Signed(controller).into(), keys, proof).unwrap();
|
||||
}
|
||||
|
||||
Pallet::<T>::on_initialize(pezframe_system::pezpallet_prelude::BlockNumberFor::<T>::one());
|
||||
|
||||
// skip sessions until the new validator set is enacted
|
||||
while Validators::<T>::get().len() < n as usize {
|
||||
Session::<T>::rotate_session();
|
||||
}
|
||||
|
||||
let key = (pezsp_runtime::KeyTypeId(*b"babe"), &[0u8; 32]);
|
||||
|
||||
(key, Historical::<T>::prove(key).unwrap())
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Offences pallet benchmarking.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub mod inner;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
pub use inner::*;
|
||||
|
||||
#[cfg(all(feature = "runtime-benchmarks", test))]
|
||||
pub(crate) mod mock;
|
||||
@@ -0,0 +1,163 @@
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Mock file for session benchmarking.
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use pezframe_election_provider_support::{
|
||||
bounds::{ElectionBounds, ElectionBoundsBuilder},
|
||||
onchain, SequentialPhragmen,
|
||||
};
|
||||
use pezframe_support::{
|
||||
derive_impl, parameter_types,
|
||||
traits::{ConstU32, ConstU64},
|
||||
};
|
||||
use pezsp_runtime::{traits::IdentityLookup, BuildStorage, KeyTypeId};
|
||||
|
||||
type AccountId = u64;
|
||||
type Nonce = u32;
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system,
|
||||
Balances: pezpallet_balances,
|
||||
Staking: pezpallet_staking,
|
||||
Session: pezpallet_session,
|
||||
Historical: pezpallet_session::historical
|
||||
}
|
||||
);
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type Nonce = Nonce;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Block = Block;
|
||||
type AccountData = pezpallet_balances::AccountData<u64>;
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_balances::Config for Test {
|
||||
type ExistentialDeposit = ConstU64<10>;
|
||||
type AccountStore = System;
|
||||
}
|
||||
|
||||
impl pezpallet_timestamp::Config for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type MinimumPeriod = ConstU64<5>;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
impl pezpallet_session::historical::Config for Test {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type FullIdentification = ();
|
||||
type FullIdentificationOf = pezpallet_staking::UnitIdentificationOf<Self>;
|
||||
}
|
||||
|
||||
pezsp_runtime::impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
pub foo: pezsp_runtime::testing::UintAuthorityId,
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestSessionHandler;
|
||||
impl pezpallet_session::SessionHandler<AccountId> for TestSessionHandler {
|
||||
// corresponds to the opaque key id above
|
||||
const KEY_TYPE_IDS: &'static [KeyTypeId] = &[KeyTypeId([100u8, 117u8, 109u8, 121u8])];
|
||||
|
||||
fn on_genesis_session<Ks: pezsp_runtime::traits::OpaqueKeys>(_validators: &[(AccountId, Ks)]) {}
|
||||
|
||||
fn on_new_session<Ks: pezsp_runtime::traits::OpaqueKeys>(
|
||||
_: bool,
|
||||
_: &[(AccountId, Ks)],
|
||||
_: &[(AccountId, Ks)],
|
||||
) {
|
||||
}
|
||||
|
||||
fn on_disabled(_: u32) {}
|
||||
}
|
||||
|
||||
impl pezpallet_session::Config for Test {
|
||||
type SessionManager = pezpallet_session::historical::NoteHistoricalRoot<Test, Staking>;
|
||||
type Keys = SessionKeys;
|
||||
type ShouldEndSession = pezpallet_session::PeriodicSessions<(), ()>;
|
||||
type NextSessionRotation = pezpallet_session::PeriodicSessions<(), ()>;
|
||||
type SessionHandler = TestSessionHandler;
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type ValidatorId = AccountId;
|
||||
type ValidatorIdOf = pezsp_runtime::traits::ConvertInto;
|
||||
type DisablingStrategy = ();
|
||||
type WeightInfo = ();
|
||||
type Currency = Balances;
|
||||
// Note: setting to a large amount to ensure bench setup can handle increasing the balance of
|
||||
// the validator before setting session keys; see `ensure_can_pay_key_deposit`.
|
||||
type KeyDeposit = ConstU64<2000000000>;
|
||||
}
|
||||
pezpallet_staking_reward_curve::build! {
|
||||
const I_NPOS: pezsp_runtime::curve::PiecewiseLinear<'static> = curve!(
|
||||
min_inflation: 0_025_000,
|
||||
max_inflation: 0_100_000,
|
||||
ideal_stake: 0_500_000,
|
||||
falloff: 0_050_000,
|
||||
max_piece_count: 40,
|
||||
test_precision: 0_005_000,
|
||||
);
|
||||
}
|
||||
parameter_types! {
|
||||
pub const RewardCurve: &'static pezsp_runtime::curve::PiecewiseLinear<'static> = &I_NPOS;
|
||||
pub static ElectionsBounds: ElectionBounds = ElectionBoundsBuilder::default().build();
|
||||
pub const Sort: bool = true;
|
||||
}
|
||||
|
||||
pub struct OnChainSeqPhragmen;
|
||||
impl onchain::Config for OnChainSeqPhragmen {
|
||||
type System = Test;
|
||||
type Solver = SequentialPhragmen<AccountId, pezsp_runtime::Perbill>;
|
||||
type DataProvider = Staking;
|
||||
type WeightInfo = ();
|
||||
type MaxWinnersPerPage = ConstU32<100>;
|
||||
type MaxBackersPerWinner = ConstU32<100>;
|
||||
type Sort = Sort;
|
||||
type Bounds = ElectionsBounds;
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_staking::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_staking::Config for Test {
|
||||
type OldCurrency = Balances;
|
||||
type Currency = Balances;
|
||||
type CurrencyBalance = <Self as pezpallet_balances::Config>::Balance;
|
||||
type UnixTime = pezpallet_timestamp::Pallet<Self>;
|
||||
type AdminOrigin = pezframe_system::EnsureRoot<Self::AccountId>;
|
||||
type SessionInterface = Self;
|
||||
type EraPayout = pezpallet_staking::ConvertCurve<RewardCurve>;
|
||||
type NextNewSession = Session;
|
||||
type ElectionProvider = onchain::OnChainExecution<OnChainSeqPhragmen>;
|
||||
type GenesisElectionProvider = Self::ElectionProvider;
|
||||
type VoterList = pezpallet_staking::UseNominatorsAndValidatorsMap<Self>;
|
||||
type TargetList = pezpallet_staking::UseValidatorsMap<Self>;
|
||||
}
|
||||
|
||||
impl crate::Config for Test {}
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
pezsp_io::TestExternalities::new(t)
|
||||
}
|
||||
Reference in New Issue
Block a user