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,61 @@
|
||||
[package]
|
||||
name = "pezpallet-nomination-pools-test-delegate-stake"
|
||||
version = "1.0.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
description = "FRAME nomination pools pallet tests with the staking pallet"
|
||||
publish = false
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dev-dependencies]
|
||||
codec = { features = ["derive"], workspace = true, default-features = true }
|
||||
scale-info = { features = [
|
||||
"derive",
|
||||
], workspace = true, default-features = true }
|
||||
|
||||
pezsp-core = { workspace = true, default-features = true }
|
||||
pezsp-io = { workspace = true, default-features = true }
|
||||
pezsp-runtime = { workspace = true, default-features = true }
|
||||
pezsp-staking = { workspace = true, default-features = true }
|
||||
|
||||
pezframe-election-provider-support = { workspace = true, default-features = true }
|
||||
pezframe-support = { features = [
|
||||
"experimental",
|
||||
], workspace = true, default-features = true }
|
||||
pezframe-system = { workspace = true, default-features = true }
|
||||
|
||||
pezpallet-bags-list = { workspace = true, default-features = true }
|
||||
pezpallet-balances = { workspace = true, default-features = true }
|
||||
pezpallet-delegated-staking = { workspace = true, default-features = true }
|
||||
pezpallet-nomination-pools = { workspace = true, default-features = true }
|
||||
pezpallet-staking = { workspace = true, default-features = true }
|
||||
pezpallet-staking-reward-curve = { workspace = true, default-features = true }
|
||||
pezpallet-timestamp = { workspace = true, default-features = true }
|
||||
|
||||
log = { workspace = true, default-features = true }
|
||||
pezsp-tracing = { workspace = true, default-features = true }
|
||||
|
||||
[features]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-election-provider-support/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezpallet-bags-list/runtime-benchmarks",
|
||||
"pezpallet-balances/runtime-benchmarks",
|
||||
"pezpallet-delegated-staking/runtime-benchmarks",
|
||||
"pezpallet-nomination-pools/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",
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,388 @@
|
||||
// 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.
|
||||
|
||||
// Disable warnings for `TransferStake` being deprecated.
|
||||
#![allow(deprecated)]
|
||||
|
||||
use pezframe_election_provider_support::VoteWeight;
|
||||
use pezframe_support::{
|
||||
assert_ok, derive_impl,
|
||||
pezpallet_prelude::*,
|
||||
parameter_types,
|
||||
traits::{ConstU64, ConstU8, Nothing, VariantCountOf},
|
||||
PalletId,
|
||||
};
|
||||
use pezframe_system::EnsureRoot;
|
||||
use pezpallet_nomination_pools::{
|
||||
adapter::{Member, Pool, StakeStrategyType},
|
||||
BondType,
|
||||
};
|
||||
use pezsp_runtime::{
|
||||
traits::{Convert, IdentityLookup},
|
||||
BuildStorage, FixedU128, Perbill,
|
||||
};
|
||||
|
||||
type AccountId = u128;
|
||||
type Nonce = u32;
|
||||
type BlockNumber = u64;
|
||||
type Balance = u128;
|
||||
|
||||
pub(crate) type T = Runtime;
|
||||
|
||||
pub(crate) const POOL1_BONDED: AccountId = 20318131474730217858575332831085u128;
|
||||
pub(crate) const POOL1_REWARD: AccountId = 20397359637244482196168876781421u128;
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Runtime {
|
||||
type Nonce = Nonce;
|
||||
type AccountId = AccountId;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Block = Block;
|
||||
type AccountData = pezpallet_balances::AccountData<Balance>;
|
||||
}
|
||||
|
||||
impl pezpallet_timestamp::Config for Runtime {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type MinimumPeriod = ConstU64<5>;
|
||||
type WeightInfo = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub static ExistentialDeposit: Balance = 5;
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_balances::Config for Runtime {
|
||||
type Balance = Balance;
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = System;
|
||||
type FreezeIdentifier = RuntimeFreezeReason;
|
||||
type MaxFreezes = VariantCountOf<RuntimeFreezeReason>;
|
||||
type RuntimeHoldReason = RuntimeHoldReason;
|
||||
type RuntimeFreezeReason = RuntimeFreezeReason;
|
||||
}
|
||||
|
||||
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 BondingDuration: u32 = 3;
|
||||
}
|
||||
|
||||
#[derive_impl(pezpallet_staking::config_preludes::TestDefaultConfig)]
|
||||
impl pezpallet_staking::Config for Runtime {
|
||||
type OldCurrency = Balances;
|
||||
type Currency = Balances;
|
||||
type UnixTime = pezpallet_timestamp::Pallet<Self>;
|
||||
type AdminOrigin = pezframe_system::EnsureRoot<Self::AccountId>;
|
||||
type BondingDuration = BondingDuration;
|
||||
type EraPayout = pezpallet_staking::ConvertCurve<RewardCurve>;
|
||||
type ElectionProvider =
|
||||
pezframe_election_provider_support::NoElection<(AccountId, BlockNumber, Staking, (), ())>;
|
||||
type GenesisElectionProvider = Self::ElectionProvider;
|
||||
type VoterList = VoterList;
|
||||
type TargetList = pezpallet_staking::UseValidatorsMap<Self>;
|
||||
type EventListeners = (Pools, DelegatedStaking);
|
||||
type BenchmarkingConfig = pezpallet_staking::TestBenchmarkingConfig;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub static BagThresholds: &'static [VoteWeight] = &[10, 20, 30, 40, 50, 60, 1_000, 2_000, 10_000];
|
||||
}
|
||||
|
||||
type VoterBagsListInstance = pezpallet_bags_list::Instance1;
|
||||
impl pezpallet_bags_list::Config<VoterBagsListInstance> for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type BagThresholds = BagThresholds;
|
||||
type ScoreProvider = Staking;
|
||||
type Score = VoteWeight;
|
||||
type MaxAutoRebagPerBlock = ();
|
||||
}
|
||||
|
||||
pub struct BalanceToU256;
|
||||
impl Convert<Balance, pezsp_core::U256> for BalanceToU256 {
|
||||
fn convert(n: Balance) -> pezsp_core::U256 {
|
||||
n.into()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct U256ToBalance;
|
||||
impl Convert<pezsp_core::U256, Balance> for U256ToBalance {
|
||||
fn convert(n: pezsp_core::U256) -> Balance {
|
||||
n.try_into().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const PostUnbondingPoolsWindow: u32 = 10;
|
||||
pub const PoolsPalletId: PalletId = PalletId(*b"py/nopls");
|
||||
pub static LegacyAdapter: bool = false;
|
||||
}
|
||||
|
||||
pub struct MockAdapter;
|
||||
type DelegateStake =
|
||||
pezpallet_nomination_pools::adapter::DelegateStake<Runtime, Staking, DelegatedStaking>;
|
||||
type TransferStake = pezpallet_nomination_pools::adapter::TransferStake<Runtime, Staking>;
|
||||
impl pezpallet_nomination_pools::adapter::StakeStrategy for MockAdapter {
|
||||
type Balance = Balance;
|
||||
type AccountId = AccountId;
|
||||
type CoreStaking = Staking;
|
||||
|
||||
fn strategy_type() -> StakeStrategyType {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::strategy_type();
|
||||
}
|
||||
DelegateStake::strategy_type()
|
||||
}
|
||||
fn transferable_balance(
|
||||
pool_account: Pool<Self::AccountId>,
|
||||
member_account: Member<Self::AccountId>,
|
||||
) -> Self::Balance {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::transferable_balance(pool_account, member_account);
|
||||
}
|
||||
DelegateStake::transferable_balance(pool_account, member_account)
|
||||
}
|
||||
|
||||
fn total_balance(pool_account: Pool<Self::AccountId>) -> Option<Self::Balance> {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::total_balance(pool_account);
|
||||
}
|
||||
DelegateStake::total_balance(pool_account)
|
||||
}
|
||||
|
||||
fn member_delegation_balance(member_account: Member<Self::AccountId>) -> Option<Self::Balance> {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::member_delegation_balance(member_account);
|
||||
}
|
||||
DelegateStake::member_delegation_balance(member_account)
|
||||
}
|
||||
|
||||
fn pledge_bond(
|
||||
who: Member<Self::AccountId>,
|
||||
pool_account: Pool<Self::AccountId>,
|
||||
reward_account: &Self::AccountId,
|
||||
amount: Self::Balance,
|
||||
bond_type: BondType,
|
||||
) -> DispatchResult {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::pledge_bond(who, pool_account, reward_account, amount, bond_type);
|
||||
}
|
||||
DelegateStake::pledge_bond(who, pool_account, reward_account, amount, bond_type)
|
||||
}
|
||||
|
||||
fn member_withdraw(
|
||||
who: Member<Self::AccountId>,
|
||||
pool_account: Pool<Self::AccountId>,
|
||||
amount: Self::Balance,
|
||||
num_slashing_spans: u32,
|
||||
) -> DispatchResult {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::member_withdraw(who, pool_account, amount, num_slashing_spans);
|
||||
}
|
||||
DelegateStake::member_withdraw(who, pool_account, amount, num_slashing_spans)
|
||||
}
|
||||
|
||||
fn dissolve(pool_account: Pool<Self::AccountId>) -> DispatchResult {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::dissolve(pool_account);
|
||||
}
|
||||
DelegateStake::dissolve(pool_account)
|
||||
}
|
||||
|
||||
fn pending_slash(pool_account: Pool<Self::AccountId>) -> Self::Balance {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::pending_slash(pool_account);
|
||||
}
|
||||
DelegateStake::pending_slash(pool_account)
|
||||
}
|
||||
|
||||
fn member_slash(
|
||||
who: Member<Self::AccountId>,
|
||||
pool_account: Pool<Self::AccountId>,
|
||||
amount: Self::Balance,
|
||||
maybe_reporter: Option<Self::AccountId>,
|
||||
) -> DispatchResult {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::member_slash(who, pool_account, amount, maybe_reporter);
|
||||
}
|
||||
DelegateStake::member_slash(who, pool_account, amount, maybe_reporter)
|
||||
}
|
||||
|
||||
fn migrate_nominator_to_agent(
|
||||
agent: Pool<Self::AccountId>,
|
||||
reward_account: &Self::AccountId,
|
||||
) -> DispatchResult {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::migrate_nominator_to_agent(agent, reward_account);
|
||||
}
|
||||
DelegateStake::migrate_nominator_to_agent(agent, reward_account)
|
||||
}
|
||||
|
||||
fn migrate_delegation(
|
||||
agent: Pool<Self::AccountId>,
|
||||
delegator: Member<Self::AccountId>,
|
||||
value: Self::Balance,
|
||||
) -> DispatchResult {
|
||||
if LegacyAdapter::get() {
|
||||
return TransferStake::migrate_delegation(agent, delegator, value);
|
||||
}
|
||||
DelegateStake::migrate_delegation(agent, delegator, value)
|
||||
}
|
||||
}
|
||||
impl pezpallet_nomination_pools::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type WeightInfo = ();
|
||||
type Currency = Balances;
|
||||
type RuntimeFreezeReason = RuntimeFreezeReason;
|
||||
type RewardCounter = FixedU128;
|
||||
type BalanceToU256 = BalanceToU256;
|
||||
type U256ToBalance = U256ToBalance;
|
||||
type StakeAdapter = MockAdapter;
|
||||
type PostUnbondingPoolsWindow = PostUnbondingPoolsWindow;
|
||||
type MaxMetadataLen = ConstU32<256>;
|
||||
type MaxUnbonding = ConstU32<8>;
|
||||
type MaxPointsToBalance = ConstU8<10>;
|
||||
type PalletId = PoolsPalletId;
|
||||
type AdminOrigin = EnsureRoot<AccountId>;
|
||||
type BlockNumberProvider = System;
|
||||
type Filter = Nothing;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const DelegatedStakingPalletId: PalletId = PalletId(*b"py/dlstk");
|
||||
pub const SlashRewardFraction: Perbill = Perbill::from_percent(1);
|
||||
}
|
||||
impl pezpallet_delegated_staking::Config for Runtime {
|
||||
type RuntimeEvent = RuntimeEvent;
|
||||
type PalletId = DelegatedStakingPalletId;
|
||||
type Currency = Balances;
|
||||
type OnSlash = ();
|
||||
type SlashRewardFraction = SlashRewardFraction;
|
||||
type RuntimeHoldReason = RuntimeHoldReason;
|
||||
type CoreStaking = Staking;
|
||||
}
|
||||
type Block = pezframe_system::mocking::MockBlock<Runtime>;
|
||||
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Runtime {
|
||||
System: pezframe_system,
|
||||
Timestamp: pezpallet_timestamp,
|
||||
Balances: pezpallet_balances,
|
||||
Staking: pezpallet_staking,
|
||||
VoterList: pezpallet_bags_list::<Instance1>,
|
||||
Pools: pezpallet_nomination_pools,
|
||||
DelegatedStaking: pezpallet_delegated_staking,
|
||||
}
|
||||
);
|
||||
|
||||
pub fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
pezsp_tracing::try_init_simple();
|
||||
let mut storage = pezframe_system::GenesisConfig::<Runtime>::default().build_storage().unwrap();
|
||||
let _ = pezpallet_nomination_pools::GenesisConfig::<Runtime> {
|
||||
min_join_bond: 2,
|
||||
min_create_bond: 2,
|
||||
max_pools: Some(3),
|
||||
max_members_per_pool: Some(5),
|
||||
max_members: Some(3 * 5),
|
||||
global_max_commission: Some(Perbill::from_percent(90)),
|
||||
}
|
||||
.assimilate_storage(&mut storage)
|
||||
.unwrap();
|
||||
|
||||
let _ = pezpallet_balances::GenesisConfig::<Runtime> {
|
||||
balances: vec![(10, 100), (20, 100), (21, 100), (22, 100)],
|
||||
..Default::default()
|
||||
}
|
||||
.assimilate_storage(&mut storage)
|
||||
.unwrap();
|
||||
|
||||
let mut ext = pezsp_io::TestExternalities::from(storage);
|
||||
|
||||
ext.execute_with(|| {
|
||||
// for events to be deposited.
|
||||
pezframe_system::Pallet::<Runtime>::set_block_number(1);
|
||||
|
||||
// set some limit for nominations.
|
||||
assert_ok!(Staking::set_staking_configs(
|
||||
RuntimeOrigin::root(),
|
||||
pezpallet_staking::ConfigOp::Set(10), // minimum nominator bond
|
||||
pezpallet_staking::ConfigOp::Noop,
|
||||
pezpallet_staking::ConfigOp::Noop,
|
||||
pezpallet_staking::ConfigOp::Noop,
|
||||
pezpallet_staking::ConfigOp::Noop,
|
||||
pezpallet_staking::ConfigOp::Noop,
|
||||
pezpallet_staking::ConfigOp::Noop,
|
||||
));
|
||||
});
|
||||
|
||||
ext
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
static ObservedEventsPools: usize = 0;
|
||||
static ObservedEventsStaking: usize = 0;
|
||||
static ObservedEventsBalances: usize = 0;
|
||||
static ObservedEventsDelegatedStaking: usize = 0;
|
||||
}
|
||||
|
||||
pub(crate) fn pool_events_since_last_call() -> Vec<pezpallet_nomination_pools::Event<Runtime>> {
|
||||
let events = System::events()
|
||||
.into_iter()
|
||||
.map(|r| r.event)
|
||||
.filter_map(|e| if let RuntimeEvent::Pools(inner) = e { Some(inner) } else { None })
|
||||
.collect::<Vec<_>>();
|
||||
let already_seen = ObservedEventsPools::get();
|
||||
ObservedEventsPools::set(events.len());
|
||||
events.into_iter().skip(already_seen).collect()
|
||||
}
|
||||
|
||||
pub(crate) fn staking_events_since_last_call() -> Vec<pezpallet_staking::Event<Runtime>> {
|
||||
let events = System::events()
|
||||
.into_iter()
|
||||
.map(|r| r.event)
|
||||
.filter_map(|e| if let RuntimeEvent::Staking(inner) = e { Some(inner) } else { None })
|
||||
.collect::<Vec<_>>();
|
||||
let already_seen = ObservedEventsStaking::get();
|
||||
ObservedEventsStaking::set(events.len());
|
||||
events.into_iter().skip(already_seen).collect()
|
||||
}
|
||||
|
||||
pub(crate) fn delegated_staking_events_since_last_call(
|
||||
) -> Vec<pezpallet_delegated_staking::Event<Runtime>> {
|
||||
let events = System::events()
|
||||
.into_iter()
|
||||
.map(|r| r.event)
|
||||
.filter_map(
|
||||
|e| if let RuntimeEvent::DelegatedStaking(inner) = e { Some(inner) } else { None },
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
let already_seen = ObservedEventsDelegatedStaking::get();
|
||||
ObservedEventsDelegatedStaking::set(events.len());
|
||||
events.into_iter().skip(already_seen).collect()
|
||||
}
|
||||
Reference in New Issue
Block a user