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:
2025-12-14 00:04:10 +03:00
parent 286de54384
commit 1c0e57d984
9084 changed files with 997839 additions and 997557 deletions
@@ -0,0 +1,83 @@
[package]
name = "pezpallet-offences-benchmarking"
version = "28.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME offences 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-election-provider-support = { workspace = true }
pezframe-support = { workspace = true }
pezframe-system = { workspace = true }
log = { workspace = true }
pezpallet-babe = { workspace = true }
pezpallet-balances = { workspace = true }
pezpallet-grandpa = { workspace = true }
pezpallet-im-online = { workspace = true }
pezpallet-offences = { workspace = true }
pezpallet-session = { workspace = true }
pezpallet-staking = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
pezsp-runtime = { workspace = true }
pezsp-staking = { workspace = true }
[dev-dependencies]
pezpallet-staking-reward-curve = { workspace = true, default-features = true }
pezpallet-timestamp = { workspace = true, default-features = true }
pezsp-core = { workspace = true, default-features = true }
pezsp-io = { workspace = true, default-features = true }
pezsp-tracing = { workspace = true, default-features = true }
[features]
default = ["std"]
std = [
"codec/std",
"pezframe-benchmarking/std",
"pezframe-election-provider-support/std",
"pezframe-support/std",
"pezframe-system/std",
"log/std",
"pezpallet-babe/std",
"pezpallet-balances/std",
"pezpallet-grandpa/std",
"pezpallet-im-online/std",
"pezpallet-offences/std",
"pezpallet-session/std",
"pezpallet-staking/std",
"pezpallet-timestamp/std",
"scale-info/std",
"pezsp-core/std",
"pezsp-io/std",
"pezsp-runtime/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-babe/runtime-benchmarks",
"pezpallet-balances/runtime-benchmarks",
"pezpallet-grandpa/runtime-benchmarks",
"pezpallet-im-online/runtime-benchmarks",
"pezpallet-offences/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-staking/runtime-benchmarks",
]
@@ -0,0 +1,3 @@
Offences pallet benchmarking.
License: Apache-2.0
@@ -0,0 +1,289 @@
// 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.
use alloc::{vec, vec::Vec};
use codec::Decode;
use pezframe_benchmarking::v2::*;
use pezframe_support::traits::Get;
use pezframe_system::{Config as SystemConfig, Pallet as System, RawOrigin};
use pezpallet_babe::EquivocationOffence as BabeEquivocationOffence;
use pezpallet_balances::Config as BalancesConfig;
use pezpallet_grandpa::{
EquivocationOffence as GrandpaEquivocationOffence, TimeSlot as GrandpaTimeSlot,
};
use pezpallet_offences::{Config as OffencesConfig, Pallet as Offences};
use pezpallet_session::{
historical::{Config as HistoricalConfig, IdentificationTuple},
Config as SessionConfig, Pallet as Session,
};
use pezpallet_staking::{
Config as StakingConfig, Exposure, IndividualExposure, MaxNominationsOf, Pallet as Staking,
RewardDestination, ValidatorPrefs,
};
use pezsp_runtime::{
traits::{Convert, Saturating, StaticLookup},
Perbill,
};
use pezsp_staking::offence::ReportOffence;
const SEED: u32 = 0;
const MAX_NOMINATORS: u32 = 100;
pub struct Pallet<T: Config>(Offences<T>);
pub trait Config:
SessionConfig<ValidatorId = <Self as pezframe_system::Config>::AccountId>
+ StakingConfig
+ OffencesConfig
+ HistoricalConfig
+ BalancesConfig
+ IdTupleConvert<Self>
{
}
/// A helper trait to make sure we can convert `IdentificationTuple` coming from historical
/// and the one required by offences.
pub trait IdTupleConvert<T: HistoricalConfig + OffencesConfig> {
/// Convert identification tuple from `historical` trait to the one expected by `offences`.
fn convert(id: IdentificationTuple<T>) -> <T as OffencesConfig>::IdentificationTuple;
}
impl<T: HistoricalConfig + OffencesConfig> IdTupleConvert<T> for T
where
<T as OffencesConfig>::IdentificationTuple: From<IdentificationTuple<T>>,
{
fn convert(id: IdentificationTuple<T>) -> <T as OffencesConfig>::IdentificationTuple {
id.into()
}
}
type LookupSourceOf<T> = <<T as SystemConfig>::Lookup as StaticLookup>::Source;
type BalanceOf<T> = <T as StakingConfig>::CurrencyBalance;
struct Offender<T: Config> {
pub controller: T::AccountId,
#[allow(dead_code)]
pub stash: T::AccountId,
#[allow(dead_code)]
pub nominator_stashes: Vec<T::AccountId>,
}
fn bond_amount<T: Config>() -> BalanceOf<T> {
pezpallet_staking::asset::existential_deposit::<T>().saturating_mul(10_000u32.into())
}
fn create_offender<T: Config>(n: u32, nominators: u32) -> Result<Offender<T>, &'static str> {
let stash: T::AccountId = account("stash", n, SEED);
let stash_lookup: LookupSourceOf<T> = T::Lookup::unlookup(stash.clone());
let reward_destination = RewardDestination::Staked;
let amount = bond_amount::<T>();
// add twice as much balance to prevent the account from being killed.
let free_amount = amount.saturating_mul(2u32.into());
pezpallet_staking::asset::set_stakeable_balance::<T>(&stash, free_amount);
Staking::<T>::bond(
RawOrigin::Signed(stash.clone()).into(),
amount,
reward_destination.clone(),
)?;
let validator_prefs =
ValidatorPrefs { commission: Perbill::from_percent(50), ..Default::default() };
Staking::<T>::validate(RawOrigin::Signed(stash.clone()).into(), validator_prefs)?;
// set some fake keys for the validators.
let keys =
<T as SessionConfig>::Keys::decode(&mut pezsp_runtime::traits::TrailingZeroInput::zeroes())
.unwrap();
let proof: Vec<u8> = vec![0, 1, 2, 3];
Session::<T>::ensure_can_pay_key_deposit(&stash)?;
Session::<T>::set_keys(RawOrigin::Signed(stash.clone()).into(), keys, proof)?;
let mut individual_exposures = vec![];
let mut nominator_stashes = vec![];
// Create n nominators
for i in 0..nominators {
let nominator_stash: T::AccountId =
account("nominator stash", n * MAX_NOMINATORS + i, SEED);
pezpallet_staking::asset::set_stakeable_balance::<T>(&nominator_stash, free_amount);
Staking::<T>::bond(
RawOrigin::Signed(nominator_stash.clone()).into(),
amount,
reward_destination.clone(),
)?;
let selected_validators: Vec<LookupSourceOf<T>> = vec![stash_lookup.clone()];
Staking::<T>::nominate(
RawOrigin::Signed(nominator_stash.clone()).into(),
selected_validators,
)?;
individual_exposures
.push(IndividualExposure { who: nominator_stash.clone(), value: amount });
nominator_stashes.push(nominator_stash.clone());
}
let exposure = Exposure { total: amount * n.into(), own: amount, others: individual_exposures };
let current_era = 0u32;
Staking::<T>::add_era_stakers(current_era, stash.clone(), exposure);
Ok(Offender { controller: stash.clone(), stash, nominator_stashes })
}
fn make_offenders<T: Config>(
num_offenders: u32,
num_nominators: u32,
) -> Result<Vec<IdentificationTuple<T>>, &'static str> {
let mut offenders = vec![];
for i in 0..num_offenders {
let offender = create_offender::<T>(i + 1, num_nominators)?;
// add them to the session validators -- this is needed since `FullIdentificationOf` usually
// checks this.
pezpallet_session::Validators::<T>::mutate(|v| v.push(offender.controller.clone()));
offenders.push(offender);
}
let id_tuples = offenders
.iter()
.map(|offender| {
<T as SessionConfig>::ValidatorIdOf::convert(offender.controller.clone())
.expect("failed to get validator id from account id")
})
.map(|validator_id| {
<T as HistoricalConfig>::FullIdentificationOf::convert(validator_id.clone())
.map(|full_id| (validator_id, full_id))
.unwrap()
})
.collect::<Vec<IdentificationTuple<T>>>();
if pezpallet_staking::ActiveEra::<T>::get().is_none() {
pezpallet_staking::ActiveEra::<T>::put(pezpallet_staking::ActiveEraInfo {
index: 0,
start: Some(0),
});
}
Ok(id_tuples)
}
#[cfg(test)]
fn assert_all_slashes_applied<T>(offender_count: usize)
where
T: Config,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezpallet_staking::Event<T>>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezpallet_balances::Event<T>>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezpallet_offences::Event>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezframe_system::Event<T>>,
{
// make sure that all slashes have been applied and TotalIssuance adjusted(BurnedDebt).
// deposit to reporter + reporter account endowed.
assert_eq!(System::<T>::read_events_for_pallet::<pezpallet_balances::Event<T>>().len(), 3);
// (n nominators + one validator) * slashed + Slash Reported + Slash Computed
assert_eq!(
System::<T>::read_events_for_pallet::<pezpallet_staking::Event<T>>().len(),
1 * (offender_count + 1) as usize + 1
);
// offence
assert_eq!(System::<T>::read_events_for_pallet::<pezpallet_offences::Event>().len(), 1);
// reporter new account
assert_eq!(System::<T>::read_events_for_pallet::<pezframe_system::Event<T>>().len(), 1);
}
#[benchmarks(
where
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezpallet_staking::Event<T>>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezpallet_balances::Event<T>>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezpallet_offences::Event>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pezframe_system::Event<T>>,
)]
mod benchmarks {
use super::*;
#[benchmark]
pub fn report_offence_grandpa(
n: Linear<0, { MAX_NOMINATORS.min(MaxNominationsOf::<T>::get()) }>,
) -> Result<(), BenchmarkError> {
// for grandpa equivocation reports the number of reporters
// and offenders is always 1
let reporters = vec![account("reporter", 1, SEED)];
// make sure reporters actually get rewarded
Staking::<T>::set_slash_reward_fraction(Perbill::one());
let mut offenders = make_offenders::<T>(1, n)?;
let validator_set_count = Session::<T>::validators().len() as u32;
let offence = GrandpaEquivocationOffence {
time_slot: GrandpaTimeSlot { set_id: 0, round: 0 },
session_index: 0,
validator_set_count,
offender: T::convert(offenders.pop().unwrap()),
};
assert_eq!(System::<T>::event_count(), 0);
#[block]
{
let _ = Offences::<T>::report_offence(reporters, offence);
}
#[cfg(test)]
{
assert_all_slashes_applied::<T>(n as usize);
}
Ok(())
}
#[benchmark]
fn report_offence_babe(
n: Linear<0, { MAX_NOMINATORS.min(MaxNominationsOf::<T>::get()) }>,
) -> Result<(), BenchmarkError> {
// for babe equivocation reports the number of reporters
// and offenders is always 1
let reporters = vec![account("reporter", 1, SEED)];
// make sure reporters actually get rewarded
Staking::<T>::set_slash_reward_fraction(Perbill::one());
let mut offenders = make_offenders::<T>(1, n)?;
let validator_set_count = Session::<T>::validators().len() as u32;
let offence = BabeEquivocationOffence {
slot: 0u64.into(),
session_index: 0,
validator_set_count,
offender: T::convert(offenders.pop().unwrap()),
};
assert_eq!(System::<T>::event_count(), 0);
#[block]
{
let _ = Offences::<T>::report_offence(reporters, offence);
}
#[cfg(test)]
{
assert_all_slashes_applied::<T>(n as usize);
}
Ok(())
}
impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test);
}
@@ -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,205 @@
// 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 offences benchmarking.
use pezframe_election_provider_support::{
bounds::{ElectionBounds, ElectionBoundsBuilder},
onchain, SequentialPhragmen,
};
use pezframe_support::{
derive_impl, parameter_types,
traits::{ConstU32, ConstU64},
};
use pezframe_system as system;
use pezpallet_session::historical as pezpallet_session_historical;
use pezsp_runtime::{
testing::{Header, UintAuthorityId},
BuildStorage, KeyTypeId, Perbill,
};
type AccountId = u64;
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type Block = Block;
type AccountData = pezpallet_balances::AccountData<u64>;
}
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type 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) {}
}
parameter_types! {
pub const Period: u64 = 1;
pub const Offset: u64 = 0;
}
impl pezpallet_session::Config for Test {
type SessionManager = pezpallet_session::historical::NoteHistoricalRoot<Test, Staking>;
type Keys = SessionKeys;
type ShouldEndSession = pezpallet_session::PeriodicSessions<Period, Offset>;
type NextSessionRotation = pezpallet_session::PeriodicSessions<Period, Offset>;
type SessionHandler = TestSessionHandler;
type RuntimeEvent = RuntimeEvent;
type ValidatorId = AccountId;
type ValidatorIdOf = pezsp_runtime::traits::ConvertInto;
type DisablingStrategy = ();
type WeightInfo = ();
type Currency = Balances;
type KeyDeposit = ();
}
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, 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 pezpallet_im_online::Config for Test {
type AuthorityId = UintAuthorityId;
type RuntimeEvent = RuntimeEvent;
type ValidatorSet = Historical;
type NextSessionRotation = pezpallet_session::PeriodicSessions<Period, Offset>;
type ReportUnresponsiveness = Offences;
type UnsignedPriority = ();
type WeightInfo = ();
type MaxKeys = ConstU32<10_000>;
type MaxPeerInHeartbeats = ConstU32<10_000>;
}
impl pezpallet_offences::Config for Test {
type RuntimeEvent = RuntimeEvent;
type IdentificationTuple = pezpallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
}
impl<T> pezframe_system::offchain::CreateTransactionBase<T> for Test
where
RuntimeCall: From<T>,
{
type Extrinsic = UncheckedExtrinsic;
type RuntimeCall = RuntimeCall;
}
impl<T> pezframe_system::offchain::CreateBare<T> for Test
where
RuntimeCall: From<T>,
{
fn create_bare(call: Self::RuntimeCall) -> Self::Extrinsic {
UncheckedExtrinsic::new_bare(call)
}
}
impl crate::Config for Test {}
pub type Block = pezsp_runtime::generic::Block<Header, UncheckedExtrinsic>;
pub type UncheckedExtrinsic = pezsp_runtime::generic::UncheckedExtrinsic<u32, RuntimeCall, u64, ()>;
pezframe_support::construct_runtime!(
pub enum Test
{
System: system::{Pallet, Call, Event<T>},
Balances: pezpallet_balances,
Staking: pezpallet_staking,
Session: pezpallet_session,
ImOnline: pezpallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
Offences: pezpallet_offences::{Pallet, Storage, Event},
Historical: pezpallet_session_historical::{Pallet, Event<T>},
}
);
pub fn new_test_ext() -> pezsp_io::TestExternalities {
pezsp_tracing::try_init_simple();
let t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pezsp_io::TestExternalities::new(t)
}