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,26 @@
// 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.
/// Version 4.
///
/// For backward compatibility reasons, pezpallet-tips uses `Treasury` for storage module prefix
/// before calling this migration. After calling this migration, it will get replaced with
/// own storage identifier.
pub mod v4;
/// A migration that unreserves all funds held in the context of this pallet.
pub mod unreserve_deposits;
@@ -0,0 +1,324 @@
// 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.
//! A migration that unreserves all deposit and unlocks all stake held in the context of this
//! pallet.
use alloc::collections::btree_map::BTreeMap;
use core::iter::Sum;
use pezframe_support::{
pezpallet_prelude::OptionQuery,
storage_alias,
traits::{Currency, LockableCurrency, OnRuntimeUpgrade, ReservableCurrency},
weights::RuntimeDbWeight,
Parameter, Twox64Concat,
};
use pezsp_runtime::{traits::Zero, Saturating};
#[cfg(feature = "try-runtime")]
const LOG_TARGET: &str = "runtime::tips::migrations::unreserve_deposits";
type BalanceOf<T, I> =
<<T as UnlockConfig<I>>::Currency as Currency<<T as UnlockConfig<I>>::AccountId>>::Balance;
/// The configuration for [`UnreserveDeposits`].
pub trait UnlockConfig<I>: 'static {
/// The hash used in the runtime.
type Hash: Parameter;
/// The account ID used in the runtime.
type AccountId: Parameter + Ord;
/// The currency type used in the runtime.
///
/// Should match the currency type previously used for the pallet, if applicable.
type Currency: LockableCurrency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
/// Base deposit to report a tip.
///
/// Should match the currency type previously used for the pallet, if applicable.
type TipReportDepositBase: pezsp_core::Get<BalanceOf<Self, I>>;
/// Deposit per byte to report a tip.
///
/// Should match the currency type previously used for the pallet, if applicable.
type DataDepositPerByte: pezsp_core::Get<BalanceOf<Self, I>>;
/// The name of the pallet as previously configured in
/// [`construct_runtime!`](pezframe_support::construct_runtime).
type PalletName: pezsp_core::Get<&'static str>;
/// The DB weight as configured in the runtime to calculate the correct weight.
type DbWeight: pezsp_core::Get<RuntimeDbWeight>;
/// The block number as configured in the runtime.
type BlockNumber: Parameter + Zero + Copy + Ord;
}
/// An open tipping "motion". Retains all details of a tip including information on the finder
/// and the members who have voted.
#[storage_alias(dynamic)]
type Tips<T: UnlockConfig<I>, I: 'static> = StorageMap<
<T as UnlockConfig<I>>::PalletName,
Twox64Concat,
<T as UnlockConfig<I>>::Hash,
crate::OpenTip<
<T as UnlockConfig<I>>::AccountId,
BalanceOf<T, I>,
<T as UnlockConfig<I>>::BlockNumber,
<T as UnlockConfig<I>>::Hash,
>,
OptionQuery,
>;
/// A migration that unreserves all tip deposits.
///
/// Useful to prevent funds from being locked up when the pallet is deprecated.
///
/// The pallet should be made inoperable before or immediately after this migration is run.
///
/// (See also the `RemovePallet` migration in `frame/support/src/migrations.rs`)
pub struct UnreserveDeposits<T: UnlockConfig<I>, I: 'static>(core::marker::PhantomData<(T, I)>);
impl<T: UnlockConfig<I>, I: 'static> UnreserveDeposits<T, I> {
/// Calculates and returns the total amount reserved by each account by this pallet from open
/// tips.
///
/// # Returns
///
/// * `BTreeMap<T::AccountId, T::Balance>`: Map of account IDs to their respective total
/// reserved balance by this pallet
/// * `pezframe_support::weights::Weight`: The weight of this operation.
fn get_deposits() -> (BTreeMap<T::AccountId, BalanceOf<T, I>>, pezframe_support::weights::Weight) {
use pezsp_core::Get;
let mut tips_len = 0;
let account_deposits: BTreeMap<T::AccountId, BalanceOf<T, I>> = Tips::<T, I>::iter()
.map(|(_hash, open_tip)| open_tip)
.fold(BTreeMap::new(), |mut acc, tip| {
// Count the total number of tips
tips_len.saturating_inc();
// Add the balance to the account's existing deposit in the accumulator
acc.entry(tip.finder).or_insert(Zero::zero()).saturating_accrue(tip.deposit);
acc
});
(account_deposits, T::DbWeight::get().reads(tips_len))
}
}
impl<T: UnlockConfig<I>, I: 'static> OnRuntimeUpgrade for UnreserveDeposits<T, I>
where
BalanceOf<T, I>: Sum,
{
/// Gets the actual reserved amount for each account before the migration, performs integrity
/// checks and prints some summary information.
///
/// Steps:
/// 1. Gets the deposited balances for each account stored in this pallet.
/// 2. Collects actual pre-migration reserved balances for each account.
/// 3. Checks the integrity of the deposited balances.
/// 4. Prints summary statistics about the state to be migrated.
/// 5. Returns the pre-migration actual reserved balance for each account that will
/// be part of the migration.
///
/// Fails with a `TryRuntimeError` if somehow the amount reserved by this pallet is greater than
/// the actual total reserved amount for any accounts.
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<alloc::vec::Vec<u8>, pezsp_runtime::TryRuntimeError> {
use codec::Encode;
use pezframe_support::ensure;
// Get the Tips pallet view of balances it has reserved
let (account_deposits, _) = Self::get_deposits();
// Get the actual amounts reserved for accounts with open tips
let account_reserved_before: BTreeMap<T::AccountId, BalanceOf<T, I>> = account_deposits
.keys()
.map(|account| (account.clone(), T::Currency::reserved_balance(&account)))
.collect();
// The deposit amount must be less than or equal to the reserved amount.
// If it is higher, there is either a bug with the pallet or a bug in the calculation of the
// deposit amount.
ensure!(
account_deposits.iter().all(|(account, deposit)| *deposit <=
*account_reserved_before.get(account).unwrap_or(&Zero::zero())),
"Deposit amount is greater than reserved amount"
);
// Print some summary stats
let total_deposits_to_unreserve =
account_deposits.clone().into_values().sum::<BalanceOf<T, I>>();
log::info!(target: LOG_TARGET, "Total accounts: {}", account_deposits.keys().count());
log::info!(target: LOG_TARGET, "Total amount to unreserve: {:?}", total_deposits_to_unreserve);
// Return the actual amount reserved before the upgrade to verify integrity of the upgrade
// in the post_upgrade hook.
Ok(account_reserved_before.encode())
}
/// Executes the migration, unreserving funds that are locked in Tip deposits.
fn on_runtime_upgrade() -> pezframe_support::weights::Weight {
use pezframe_support::traits::Get;
// Get staked and deposited balances as reported by this pallet.
let (account_deposits, initial_reads) = Self::get_deposits();
// Deposited funds need to be unreserved.
for (account, unreserve_amount) in account_deposits.iter() {
if unreserve_amount.is_zero() {
continue;
}
T::Currency::unreserve(&account, *unreserve_amount);
}
T::DbWeight::get()
.reads_writes(account_deposits.len() as u64, account_deposits.len() as u64)
.saturating_add(initial_reads)
}
/// Verifies that the account reserved balances were reduced by the actual expected amounts.
#[cfg(feature = "try-runtime")]
fn post_upgrade(
account_reserved_before_bytes: alloc::vec::Vec<u8>,
) -> Result<(), pezsp_runtime::TryRuntimeError> {
use codec::Decode;
let account_reserved_before = BTreeMap::<T::AccountId, BalanceOf<T, I>>::decode(
&mut &account_reserved_before_bytes[..],
)
.map_err(|_| "Failed to decode account_reserved_before_bytes")?;
// Get deposited balances as reported by this pallet.
let (account_deposits, _) = Self::get_deposits();
// Check that the reserved balance is reduced by the expected deposited amount.
for (account, actual_reserved_before) in account_reserved_before {
let actual_reserved_after = T::Currency::reserved_balance(&account);
let expected_amount_deducted = *account_deposits
.get(&account)
.expect("account deposit must exist to be in account_reserved_before, qed");
let expected_reserved_after =
actual_reserved_before.saturating_sub(expected_amount_deducted);
if actual_reserved_after != expected_reserved_after {
log::error!(
target: LOG_TARGET,
"Reserved balance for {:?} is incorrect. actual before: {:?}, actual after, {:?}, expected deducted: {:?}",
account,
actual_reserved_before,
actual_reserved_after,
expected_amount_deducted
);
return Err("Reserved balance is incorrect".into());
}
}
Ok(())
}
}
#[cfg(all(feature = "try-runtime", test))]
mod test {
use super::*;
use crate::{
migrations::unreserve_deposits::UnreserveDeposits,
tests::{new_test_ext, Balances, RuntimeOrigin, Test, Tips},
};
use pezframe_support::{assert_ok, parameter_types, traits::TypedGet};
use pezframe_system::pezpallet_prelude::BlockNumberFor;
use pezsp_core::ConstU64;
parameter_types! {
const PalletName: &'static str = "Tips";
}
struct UnlockConfigImpl;
impl super::UnlockConfig<()> for UnlockConfigImpl {
type Currency = Balances;
type TipReportDepositBase = ConstU64<1>;
type DataDepositPerByte = ConstU64<1>;
type Hash = pezsp_core::H256;
type AccountId = u128;
type BlockNumber = BlockNumberFor<Test>;
type DbWeight = ();
type PalletName = PalletName;
}
#[test]
fn unreserve_all_funds_works() {
let tipper_0 = 0;
let tipper_1 = 1;
let tipper_0_initial_reserved = 0;
let tipper_1_initial_reserved = 5;
let recipient = 100;
let tip_0_reason = b"what_is_really_not_awesome".to_vec();
let tip_1_reason = b"pineapple_on_pizza".to_vec();
new_test_ext().execute_with(|| {
// Set up
assert_ok!(<Test as pezpallet_treasury::Config>::Currency::reserve(
&tipper_0,
tipper_0_initial_reserved
));
assert_ok!(<Test as pezpallet_treasury::Config>::Currency::reserve(
&tipper_1,
tipper_1_initial_reserved
));
// Make some tips
assert_ok!(Tips::report_awesome(
RuntimeOrigin::signed(tipper_0),
tip_0_reason.clone(),
recipient
));
assert_ok!(Tips::report_awesome(
RuntimeOrigin::signed(tipper_1),
tip_1_reason.clone(),
recipient
));
// Verify the expected amount is reserved
assert_eq!(
<Test as pezpallet_treasury::Config>::Currency::reserved_balance(&tipper_0),
tipper_0_initial_reserved +
<Test as crate::Config>::TipReportDepositBase::get() +
<Test as crate::Config>::DataDepositPerByte::get() *
tip_0_reason.len() as u64
);
assert_eq!(
<Test as pezpallet_treasury::Config>::Currency::reserved_balance(&tipper_1),
tipper_1_initial_reserved +
<Test as crate::Config>::TipReportDepositBase::get() +
<Test as crate::Config>::DataDepositPerByte::get() *
tip_1_reason.len() as u64
);
// Execute the migration
let bytes = match UnreserveDeposits::<UnlockConfigImpl, ()>::pre_upgrade() {
Ok(bytes) => bytes,
Err(e) => panic!("pre_upgrade failed: {:?}", e),
};
UnreserveDeposits::<UnlockConfigImpl, ()>::on_runtime_upgrade();
assert_ok!(UnreserveDeposits::<UnlockConfigImpl, ()>::post_upgrade(bytes));
// Check the deposits were were unreserved
assert_eq!(
<Test as pezpallet_treasury::Config>::Currency::reserved_balance(&tipper_0),
tipper_0_initial_reserved
);
assert_eq!(
<Test as pezpallet_treasury::Config>::Currency::reserved_balance(&tipper_1),
tipper_1_initial_reserved
);
});
}
}
@@ -0,0 +1,196 @@
// 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.
use core::str;
use pezsp_io::hashing::twox_128;
use super::super::LOG_TARGET;
use pezframe_support::{
storage::StoragePrefixedMap,
traits::{
Get, GetStorageVersion, PalletInfoAccess, StorageVersion,
STORAGE_VERSION_STORAGE_KEY_POSTFIX,
},
weights::Weight,
};
use crate as pezpallet_tips;
/// Migrate the entire storage of this pallet to a new prefix.
///
/// This new prefix must be the same as the one set in construct_runtime.
/// For safety, use `PalletInfo` to get it, as:
/// `<Runtime as pezframe_system::Config>::PalletInfo::name::<TipsPallet>`.
///
/// The migration will look into the storage version in order not to trigger a migration on an up
/// to date storage. Thus the on chain storage version must be less than 4 in order to trigger the
/// migration.
pub fn migrate<T: pezpallet_tips::Config, P: GetStorageVersion + PalletInfoAccess, N: AsRef<str>>(
old_pallet_name: N,
) -> Weight {
let old_pallet_name = old_pallet_name.as_ref();
let new_pallet_name = <P as PalletInfoAccess>::name();
if new_pallet_name == old_pallet_name {
log::info!(
target: LOG_TARGET,
"New pallet name is equal to the old prefix. No migration needs to be done.",
);
return Weight::zero();
}
let on_chain_storage_version = <P as GetStorageVersion>::on_chain_storage_version();
log::info!(
target: LOG_TARGET,
"Running migration to v4 for tips with storage version {:?}",
on_chain_storage_version,
);
if on_chain_storage_version < 4 {
let storage_prefix = pezpallet_tips::Tips::<T>::storage_prefix();
pezframe_support::storage::migration::move_storage_from_pallet(
storage_prefix,
old_pallet_name.as_bytes(),
new_pallet_name.as_bytes(),
);
log_migration("migration", storage_prefix, old_pallet_name, new_pallet_name);
let storage_prefix = pezpallet_tips::Reasons::<T>::storage_prefix();
pezframe_support::storage::migration::move_storage_from_pallet(
storage_prefix,
old_pallet_name.as_bytes(),
new_pallet_name.as_bytes(),
);
log_migration("migration", storage_prefix, old_pallet_name, new_pallet_name);
StorageVersion::new(4).put::<P>();
<T as pezframe_system::Config>::BlockWeights::get().max_block
} else {
log::warn!(
target: LOG_TARGET,
"Attempted to apply migration to v4 but failed because storage version is {:?}",
on_chain_storage_version,
);
Weight::zero()
}
}
/// Some checks prior to migration. This can be linked to
/// `pezframe_support::traits::OnRuntimeUpgrade::pre_upgrade` for further testing.
///
/// Panics if anything goes wrong.
pub fn pre_migrate<
T: pezpallet_tips::Config,
P: GetStorageVersion + PalletInfoAccess,
N: AsRef<str>,
>(
old_pallet_name: N,
) {
let old_pallet_name = old_pallet_name.as_ref();
let new_pallet_name = <P as PalletInfoAccess>::name();
let storage_prefix_tips = pezpallet_tips::Tips::<T>::storage_prefix();
let storage_prefix_reasons = pezpallet_tips::Reasons::<T>::storage_prefix();
log_migration("pre-migration", storage_prefix_tips, old_pallet_name, new_pallet_name);
log_migration("pre-migration", storage_prefix_reasons, old_pallet_name, new_pallet_name);
if new_pallet_name == old_pallet_name {
return;
}
let new_pallet_prefix = twox_128(new_pallet_name.as_bytes());
let storage_version_key = twox_128(STORAGE_VERSION_STORAGE_KEY_POSTFIX);
let mut new_pallet_prefix_iter = pezframe_support::storage::KeyPrefixIterator::new(
new_pallet_prefix.to_vec(),
new_pallet_prefix.to_vec(),
|key| Ok(key.to_vec()),
);
// Ensure nothing except the storage_version_key is stored in the new prefix.
assert!(new_pallet_prefix_iter.all(|key| key == storage_version_key));
assert!(<P as GetStorageVersion>::on_chain_storage_version() < 4);
}
/// Some checks for after migration. This can be linked to
/// `pezframe_support::traits::OnRuntimeUpgrade::post_upgrade` for further testing.
///
/// Panics if anything goes wrong.
pub fn post_migrate<
T: pezpallet_tips::Config,
P: GetStorageVersion + PalletInfoAccess,
N: AsRef<str>,
>(
old_pallet_name: N,
) {
let old_pallet_name = old_pallet_name.as_ref();
let new_pallet_name = <P as PalletInfoAccess>::name();
let storage_prefix_tips = pezpallet_tips::Tips::<T>::storage_prefix();
let storage_prefix_reasons = pezpallet_tips::Reasons::<T>::storage_prefix();
log_migration("post-migration", storage_prefix_tips, old_pallet_name, new_pallet_name);
log_migration("post-migration", storage_prefix_reasons, old_pallet_name, new_pallet_name);
if new_pallet_name == old_pallet_name {
return;
}
// Assert that no `Tips` and `Reasons` storages remains at the old prefix.
let old_pallet_prefix = twox_128(old_pallet_name.as_bytes());
let old_tips_key = [&old_pallet_prefix, &twox_128(storage_prefix_tips)[..]].concat();
let old_tips_key_iter = pezframe_support::storage::KeyPrefixIterator::new(
old_tips_key.to_vec(),
old_tips_key.to_vec(),
|_| Ok(()),
);
assert_eq!(old_tips_key_iter.count(), 0);
let old_reasons_key = [&old_pallet_prefix, &twox_128(storage_prefix_reasons)[..]].concat();
let old_reasons_key_iter = pezframe_support::storage::KeyPrefixIterator::new(
old_reasons_key.to_vec(),
old_reasons_key.to_vec(),
|_| Ok(()),
);
assert_eq!(old_reasons_key_iter.count(), 0);
// Assert that the `Tips` and `Reasons` storages (if they exist) have been moved to the new
// prefix.
// NOTE: storage_version_key is already in the new prefix.
let new_pallet_prefix = twox_128(new_pallet_name.as_bytes());
let new_pallet_prefix_iter = pezframe_support::storage::KeyPrefixIterator::new(
new_pallet_prefix.to_vec(),
new_pallet_prefix.to_vec(),
|_| Ok(()),
);
assert!(new_pallet_prefix_iter.count() >= 1);
assert_eq!(<P as GetStorageVersion>::on_chain_storage_version(), 4);
}
fn log_migration(stage: &str, storage_prefix: &[u8], old_pallet_name: &str, new_pallet_name: &str) {
log::info!(
target: LOG_TARGET,
"{} prefix of storage '{}': '{}' ==> '{}'",
stage,
str::from_utf8(storage_prefix).unwrap_or("<Invalid UTF8>"),
old_pallet_name,
new_pallet_name,
);
}