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,245 @@
// 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 crate::{
verifier::{Config, Event, FeasibilityError, Pallet, Status, StatusStorage},
CurrentPhase, Phase,
};
use pezframe_benchmarking::v2::*;
use pezframe_election_provider_support::{ElectionProvider, NposSolution};
use pezframe_support::pezpallet_prelude::*;
use pezsp_std::prelude::*;
#[benchmarks(where
T: crate::Config + crate::signed::Config + crate::unsigned::Config,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<crate::verifier::Event<T>>
)]
mod benchmarks {
use super::*;
fn events_for<T: Config>() -> Vec<Event<T>>
where
<T as pezframe_system::Config>::RuntimeEvent: TryInto<Event<T>>,
{
pezframe_system::Pallet::<T>::read_events_for_pallet::<Event<T>>()
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_valid_non_terminal() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet
crate::Pallet::<T>::roll_to_signed_and_submit_full_solution()?;
// roll to verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
// start signal must have been sent by now
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp() - 1));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_valid_terminal() -> Result<(), BenchmarkError> {
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet
assert!(
T::SignedValidationPhase::get() >= T::Pages::get().into(),
"Signed validation phase must be larger than the number of pages"
);
crate::Pallet::<T>::roll_to_signed_and_submit_full_solution()?;
// roll to before the last page of verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
// start signal must have been sent by now
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
for _ in 0..(T::Pages::get() - 1) {
crate::Pallet::<T>::roll_next(true, false);
}
// we must have verified all pages by now, minus the last one.
assert!(matches!(
&events_for::<T>()[..],
[Event::Verified(_, _), .., Event::Verified(1, _)]
));
// verify the last page.
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
// we are done
assert_eq!(StatusStorage::<T>::get(), Status::Nothing);
// last event is success
assert!(matches!(
&events_for::<T>()[..],
[Event::Verified(_, _), .., Event::Verified(0, _), Event::Queued(_, None)]
));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_invalid_terminal() -> Result<(), BenchmarkError> {
// this is the verification of the current page + removing all of the previously valid
// pages. The worst case is therefore when the last page is invalid, for example the final
// score.
assert!(T::Pages::get() >= 2, "benchmark only works if we have more than 2 pages");
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet
// but this solution is corrupt
let mut paged_solution = crate::Pallet::<T>::roll_to_signed_and_mine_full_solution();
paged_solution.score.minimal_stake -= 1;
crate::Pallet::<T>::submit_full_solution(paged_solution)?;
// roll to verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
// verify all pages, except for the last one.
for i in 0..T::Pages::get() - 1 {
crate::Pallet::<T>::roll_next(true, false);
assert_eq!(
StatusStorage::<T>::get(),
Status::Ongoing(crate::Pallet::<T>::msp() - 1 - i)
);
}
// next page to be verified is the last one
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::lsp()));
assert!(matches!(
&events_for::<T>()[..],
[Event::Verified(_, _), .., Event::Verified(1, _)]
));
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
// we are now reset.
assert_eq!(StatusStorage::<T>::get(), Status::Nothing);
assert!(matches!(
&events_for::<T>()[..],
[
..,
Event::Verified(0, _),
Event::VerificationFailed(0, FeasibilityError::InvalidScore)
]
));
Ok(())
}
#[benchmark(pov_mode = Measured)]
fn on_initialize_invalid_non_terminal(
// number of valid pages that have been verified, before we verify the non-terminal invalid
// page.
v: Linear<0, { T::Pages::get() - 1 }>,
) -> Result<(), BenchmarkError> {
assert!(T::Pages::get() >= 2, "benchmark only works if we have more than 2 pages");
#[cfg(test)]
crate::mock::ElectionStart::set(pezsp_runtime::traits::Bounded::max_value());
crate::Pallet::<T>::start().unwrap();
// roll to signed validation, with a solution stored in the signed pallet, but this solution
// is corrupt in its msp.
let mut paged_solution = crate::Pallet::<T>::roll_to_signed_and_mine_full_solution();
let page_to_corrupt = crate::Pallet::<T>::msp() - v;
crate::log!(
info,
"pages of solution: {:?}, to corrupt {}, v {}",
paged_solution.solution_pages.len(),
page_to_corrupt,
v
);
paged_solution.solution_pages[page_to_corrupt as usize].corrupt();
crate::Pallet::<T>::submit_full_solution(paged_solution)?;
// roll to verification
crate::Pallet::<T>::roll_until_matches(|| {
matches!(CurrentPhase::<T>::get(), Phase::SignedValidation(_))
});
// send start signal
crate::Pallet::<T>::roll_next(true, false);
// we should be ready to go
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp()));
// validate the the parameterized number of valid pages.
for _ in 0..v {
crate::Pallet::<T>::roll_next(true, false);
}
// we are still ready to continue
assert_eq!(StatusStorage::<T>::get(), Status::Ongoing(crate::Pallet::<T>::msp() - v));
// verify one page, which will be invalid.
#[block]
{
crate::Pallet::<T>::roll_next(true, false);
}
// we are now reset, because this page was invalid.
assert_eq!(StatusStorage::<T>::get(), Status::Nothing);
assert!(matches!(
&events_for::<T>()[..],
[.., Event::VerificationFailed(_, FeasibilityError::NposElection(_))]
));
Ok(())
}
impl_benchmark_test_suite!(
Pallet,
crate::mock::ExtBuilder::full().build_unchecked(),
crate::mock::Runtime
);
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,291 @@
// 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.
//! # The Verifier Pallet
//!
//! This pallet has no end-user functionality, and is only used internally by other pallets in the
//! EPMB machinery to verify solutions.
//!
//! ### *Feasibility* Check
//!
//! Before explaining the pallet itself, it should be explained what a *verification* even means.
//! Verification of a solution page ([`crate::unsigned::miner::MinerConfig::Solution`]) includes the
//! process of checking all of its edges against a snapshot to be correct. For instance, all voters
//! that are presented in a solution page must have actually voted for the winner that they are
//! backing, based on the snapshot kept in the parent pallet.
//!
//! Such checks are bound to each page of the solution, and happen per-page. After checking all of
//! the edges in each page, a handful of other checks are performed. These checks cannot happen
//! per-page, and in order to do them we need to have the entire solution checked and verified.
//!
//! 1. Check that the total number of winners is sufficient (`DesiredTargets`).
//! 2. Check that the claimed score ([`pezsp_npos_elections::ElectionScore`]) is correct,
//! * and more than the minimum score that can be specified via [`Verifier::set_minimum_score`].
//! 3. Check that all of the bounds of the solution are respected, namely
//! [`Verifier::MaxBackersPerWinner`], [`Verifier::MaxWinnersPerPage`] and
//! [`Verifier::MaxBackersPerWinnerFinal`].
//!
//! Note that the common factor of all of the above checks is that they can ONLY be checked after
//! all pages are already verified. So, in the case of a multi-page verification, these checks are
//! performed at the last page.
//!
//! The errors that can arise while performing the feasibility check are encapsulated in
//! [`verifier::FeasibilityError`].
//!
//! ## Modes of Verification
//!
//! The verifier pallet provide two modes of functionality:
//!
//! 1. Single or multi-page, synchronous verification. This is useful in the context of single-page,
//! emergency, or unsigned solutions that need to be verified on the fly. This is similar to how
//! the old school `multi-phase` pallet works. See [`Verifier::verify_synchronous`] and
//! [`Verifier::verify_synchronous_multi`].
//! 2. Multi-page, asynchronous verification. This is useful in the context of multi-page, signed
//! solutions. See [`verifier::AsynchronousVerifier`] and [`verifier::SolutionDataProvider`].
//!
//! Both of this, plus some helper functions, is exposed via the [`verifier::Verifier`] trait.
//!
//! ## Queued Solution
//!
//! once a solution has been verified, it is called a *queued solution*. It is sitting in a queue,
//! waiting for either of:
//!
//! 1. being challenged and potentially replaced by better solution, if any.
//! 2. being exported as the final outcome of the election.
#[cfg(feature = "runtime-benchmarks")]
pub mod benchmarking;
mod impls;
#[cfg(test)]
mod tests;
// internal imports
pub use crate::weights::traits::pezpallet_election_provider_multi_block_verifier::*;
use pezframe_election_provider_support::PageIndex;
use impls::SupportsOfVerifier;
pub use impls::{feasibility_check_page_inner_with_snapshot, pallet::*, Status};
use pezsp_core::Get;
use pezsp_npos_elections::ElectionScore;
use pezsp_std::{fmt::Debug, prelude::*};
/// Errors that can happen in the feasibility check.
#[derive(
Debug,
Eq,
PartialEq,
codec::Encode,
codec::Decode,
codec::DecodeWithMemTracking,
scale_info::TypeInfo,
Clone,
)]
pub enum FeasibilityError {
/// Wrong number of winners presented.
WrongWinnerCount,
/// The snapshot is not available.
///
/// Kinda defensive: The pallet should technically never attempt to do a feasibility check
/// when no snapshot is present.
SnapshotUnavailable,
/// A vote is invalid.
InvalidVote,
/// A voter is invalid.
InvalidVoter,
/// A winner is invalid.
InvalidWinner,
/// The given score was invalid.
InvalidScore,
/// The provided round is incorrect.
InvalidRound,
/// Solution does not have a good enough score.
ScoreTooLow,
/// The support type failed to be bounded.
///
/// Relates to [`Config::MaxWinnersPerPage`], [`Config::MaxBackersPerWinner`] or
/// `MaxBackersPerWinnerFinal`
FailedToBoundSupport,
/// Internal error from the election crate.
NposElection(pezsp_npos_elections::Error),
/// The solution is incomplete, it has too few pages.
///
/// This is (somewhat) synonym to `WrongPageCount` in other places.
Incomplete,
}
impl From<pezsp_npos_elections::Error> for FeasibilityError {
fn from(e: pezsp_npos_elections::Error) -> Self {
FeasibilityError::NposElection(e)
}
}
/// The interface of something that can verify solutions for other sub-pallets in the multi-block
/// election pezpallet-network.
pub trait Verifier {
/// The solution type.
type Solution;
/// The account if type.
type AccountId;
/// Maximum number of winners that can be represented in each page.
///
/// A reasonable value for this should be the maximum number of winners that the election user
/// (e.g. the staking pallet) could ever desire.
type MaxWinnersPerPage: Get<u32>;
/// Maximum number of backers, per winner, among all pages of an election.
///
/// This can only be checked at the very final step of verification.
type MaxBackersPerWinnerFinal: Get<u32>;
/// Maximum number of backers that each winner could have, per page.
type MaxBackersPerWinner: Get<u32>;
/// Set the minimum score that is acceptable for any solution.
///
/// Henceforth, all solutions must have at least this degree of quality, single-page or
/// multi-page.
fn set_minimum_score(score: ElectionScore);
/// The score of the current best solution. `None` if there is none.
fn queued_score() -> Option<ElectionScore>;
/// Check if the claimed score is sufficient to challenge the current queued solution, if any.
fn ensure_claimed_score_improves(claimed_score: ElectionScore) -> bool;
/// Clear all storage items, there's nothing else to do until further notice.
fn kill();
/// Get a single page of the best verified solution, if any.
///
/// It is the responsibility of the call site to call this function with all appropriate
/// `page` arguments.
fn get_queued_solution_page(page: PageIndex) -> Option<SupportsOfVerifier<Self>>;
/// Perform the feasibility check on the given single-page solution.
///
/// This will perform:
///
/// 1. feasibility-check
/// 2. claimed score is correct and an improvement.
/// 3. bounds are respected
///
/// Corresponding snapshot (represented by `page`) is assumed to be available.
///
/// If all checks pass, the solution is also queued.
fn verify_synchronous(
partial_solution: Self::Solution,
claimed_score: ElectionScore,
page: PageIndex,
) -> Result<(), FeasibilityError> {
Self::verify_synchronous_multi(vec![partial_solution], vec![page], claimed_score)
}
/// Perform synchronous feasibility check on the given multi-page solution.
///
/// Same semantics as [`Self::verify_synchronous`], but for multi-page solutions.
fn verify_synchronous_multi(
partial_solution: Vec<Self::Solution>,
pages: Vec<PageIndex>,
claimed_score: ElectionScore,
) -> Result<(), FeasibilityError>;
/// Force set a single page solution as the valid one.
///
/// Will erase any previous solution. Should only be used in case of emergency fallbacks,
/// trusted governance solutions and so on.
fn force_set_single_page_valid(
partial_supports: SupportsOfVerifier<Self>,
page: PageIndex,
score: ElectionScore,
);
}
/// Simple enum to encapsulate the result of the verification of a candidate solution.
#[derive(Clone, Copy, Debug)]
#[cfg_attr(test, derive(PartialEq, Eq))]
pub enum VerificationResult {
/// Solution is valid and is queued.
Queued,
/// Solution is rejected, for whichever of the multiple reasons that it could be.
Rejected,
}
/// Something that can provide candidate solutions to the verifier.
///
/// In reality, this can be implemented by the [`crate::signed::Pallet`], where signed solutions are
/// queued and sorted based on claimed score, and they are put forth one by one, from best to worse.
pub trait SolutionDataProvider {
/// The opaque solution type.
type Solution;
/// Return the `page`th page of the current best solution that the data provider has in store.
///
/// If no candidate solutions are available, an empty page is returned (i.e., a page that
/// contains no solutions and contributes zero to the final score).
fn get_page(page: PageIndex) -> Self::Solution;
/// Get the claimed score of the current best solution.
///
/// If no score is available, a default/zero score should be returned defensively.
fn get_score() -> ElectionScore;
/// Hook to report back the results of the verification of the current candidate solution that
/// is being exposed via [`Self::get_page`] and [`Self::get_score`].
///
/// Every time that this is called, the verifier [`AsynchronousVerifier`] goes back to the
/// [`Status::Nothing`] state, and it is the responsibility of [`Self`] to call `start` again,
/// if desired.
fn report_result(result: VerificationResult);
}
/// Something that can do the verification asynchronously.
pub trait AsynchronousVerifier: Verifier {
/// The data provider that can provide the candidate solution, and to whom we report back the
/// results.
type SolutionDataProvider: SolutionDataProvider;
/// Get the current stage of the verification process.
fn status() -> Status;
/// Start a verification process.
///
/// Returns `Ok(())` if verification started successfully, and `Err(..)` if a verification is
/// already ongoing and therefore a new one cannot be started.
///
/// From the coming block onwards, the verifier will start and fetch the relevant information
/// and solution pages from [`SolutionDataProvider`]. It is expected that the
/// [`SolutionDataProvider`] is ready before calling [`Self::start`].
///
/// Pages of the solution are fetched sequentially and in order from [`SolutionDataProvider`],
/// from `msp` to `lsp`.
///
/// This ends in either of the two:
///
/// 1. All pages, including the final checks (like score and other facts that can only be
/// derived from a full solution) are valid and the solution is verified. The solution is
/// queued and is ready for further export.
/// 2. The solution checks verification at one of the steps. Nothing is stored inside the
/// verifier pallet and all intermediary data is removed.
///
/// In both cases, the [`SolutionDataProvider`] is informed via
/// [`SolutionDataProvider::report_result`]. It is sensible for the data provide to call `start`
/// again if the verification has failed, and nothing otherwise. Indeed, the
/// [`SolutionDataProvider`] must adjust its internal state such that it returns a new candidate
/// solution after each failure.
fn start() -> Result<(), &'static str>;
}
File diff suppressed because it is too large Load Diff