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,37 @@
[package]
name = "pezsp-consensus"
version = "0.32.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "Common utilities for building and using consensus engines in bizinikiwi."
documentation = "https://docs.rs/pezsp-consensus/"
readme = "README.md"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
async-trait = { workspace = true }
futures = { features = ["thread-pool"], workspace = true }
log = { workspace = true, default-features = true }
pezsp-inherents = { workspace = true, default-features = true }
pezsp-runtime = { workspace = true, default-features = true }
pezsp-state-machine = { workspace = true, default-features = true }
thiserror = { workspace = true }
[dev-dependencies]
futures = { workspace = true }
[features]
default = []
runtime-benchmarks = [
"pezsp-inherents/runtime-benchmarks",
"pezsp-runtime/runtime-benchmarks",
"pezsp-state-machine/runtime-benchmarks",
]
@@ -0,0 +1,7 @@
Common utilities for building and using consensus engines in Bizinikiwi.
Much of this crate is _unstable_ and thus the API is likely to undergo
change. Implementors of traits should not rely on the interfaces to remain
the same.
License: Apache-2.0
@@ -0,0 +1,98 @@
// 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.
//! Block announcement validation.
use crate::BlockStatus;
use futures::FutureExt as _;
use pezsp_runtime::traits::Block;
use std::{error::Error, future::Future, pin::Pin, sync::Arc};
/// A type which provides access to chain information.
pub trait Chain<B: Block> {
/// Retrieve the status of the block denoted by the given [`Block::Hash`].
fn block_status(&self, hash: B::Hash) -> Result<BlockStatus, Box<dyn Error + Send>>;
}
impl<T: Chain<B>, B: Block> Chain<B> for Arc<T> {
fn block_status(&self, hash: B::Hash) -> Result<BlockStatus, Box<dyn Error + Send>> {
(&**self).block_status(hash)
}
}
/// Result of `BlockAnnounceValidator::validate`.
#[derive(Debug, PartialEq, Eq)]
pub enum Validation {
/// Valid block announcement.
Success {
/// Is this the new best block of the node?
is_new_best: bool,
},
/// Invalid block announcement.
Failure {
/// Should we disconnect from this peer?
///
/// This should be used if the peer for example send junk to spam us.
disconnect: bool,
},
}
/// Type which checks incoming block announcements.
pub trait BlockAnnounceValidator<B: Block> {
/// Validate the announced header and its associated data.
///
/// # Note
///
/// Returning [`Validation::Failure`] will lead to a decrease of the
/// peers reputation as it sent us invalid data.
///
/// The returned future should only resolve to an error if there was an internal error
/// validating the block announcement. If the block announcement itself is invalid, this should
/// *always* return [`Validation::Failure`].
fn validate(
&mut self,
header: &B::Header,
data: &[u8],
) -> Pin<Box<dyn Future<Output = Result<Validation, Box<dyn Error + Send>>> + Send>>;
}
/// Default implementation of `BlockAnnounceValidator`.
#[derive(Debug)]
pub struct DefaultBlockAnnounceValidator;
impl<B: Block> BlockAnnounceValidator<B> for DefaultBlockAnnounceValidator {
fn validate(
&mut self,
_: &B::Header,
data: &[u8],
) -> Pin<Box<dyn Future<Output = Result<Validation, Box<dyn Error + Send>>> + Send>> {
let is_empty = data.is_empty();
async move {
if !is_empty {
log::debug!(
target: "sync",
"Received unknown data alongside the block announcement.",
);
Ok(Validation::Failure { disconnect: true })
} else {
Ok(Validation::Success { is_new_best: false })
}
}
.boxed()
}
}
@@ -0,0 +1,59 @@
// 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.
//! Error types for consensus modules.
/// Result type alias.
pub type Result<T> = std::result::Result<T, Error>;
/// The error type for consensus-related operations.
#[derive(Debug, thiserror::Error)]
pub enum Error {
/// Missing state at block with given descriptor.
#[error("State unavailable at block {0}")]
StateUnavailable(String),
/// Intermediate missing.
#[error("Missing intermediate")]
NoIntermediate,
/// Intermediate is of wrong type.
#[error("Invalid intermediate")]
InvalidIntermediate,
/// Error checking signature.
#[error("Message signature {0:?} by {1:?} is invalid")]
InvalidSignature(Vec<u8>, Vec<u8>),
/// Invalid authorities set received from the runtime.
#[error("Current state of blockchain has invalid authorities set")]
InvalidAuthoritiesSet,
/// Justification requirements not met.
#[error("Invalid justification")]
InvalidJustification,
/// The justification provided is outdated and corresponds to a previous set.
#[error("Import failed with outdated justification")]
OutdatedJustification,
/// Error from the client while importing.
#[error("Import failed: {0}")]
ClientImport(String),
/// Error from the client while fetching some data from the chain.
#[error("Chain lookup failed: {0}")]
ChainLookup(String),
/// Signing failed.
#[error("Failed to sign: {0}")]
CannotSign(String),
/// Some other error.
#[error(transparent)]
Other(#[from] Box<dyn std::error::Error + Sync + Send + 'static>),
}
@@ -0,0 +1,254 @@
// 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.
//! Common utilities for building and using consensus engines in bizinikiwi.
//!
//! Much of this crate is _unstable_ and thus the API is likely to undergo
//! change. Implementors of traits should not rely on the interfaces to remain
//! the same.
use std::{sync::Arc, time::Duration};
use futures::prelude::*;
use pezsp_runtime::{
traits::{Block as BlockT, HashingFor},
Digest,
};
use pezsp_state_machine::StorageProof;
pub mod block_validation;
pub mod error;
mod select_chain;
pub use self::error::Error;
pub use select_chain::SelectChain;
pub use pezsp_inherents::InherentData;
pub use pezsp_state_machine::Backend as StateBackend;
/// Block status.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum BlockStatus {
/// Added to the import queue.
Queued,
/// Already in the blockchain and the state is available.
InChainWithState,
/// In the blockchain, but the state is not available.
InChainPruned,
/// Block or parent is known to be bad.
KnownBad,
/// Not in the queue or the blockchain.
Unknown,
}
/// Block data origin.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum BlockOrigin {
/// Genesis block built into the client.
Genesis,
/// Block is part of the initial sync with the network.
NetworkInitialSync,
/// Block was broadcasted on the network.
NetworkBroadcast,
/// Block that was received from the network and validated in the consensus process.
ConsensusBroadcast,
/// Block that was collated by this node.
Own,
/// Block was imported from a file.
File,
}
/// Environment for a Consensus instance.
///
/// Creates proposer instance.
pub trait Environment<B: BlockT> {
/// The proposer type this creates.
type Proposer: Proposer<B> + Send + 'static;
/// A future that resolves to the proposer.
type CreateProposer: Future<Output = Result<Self::Proposer, Self::Error>>
+ Send
+ Unpin
+ 'static;
/// Error which can occur upon creation.
type Error: From<Error> + std::error::Error + 'static;
/// Initialize the proposal logic on top of a specific header. Provide
/// the authorities at that header.
fn init(&mut self, parent_header: &B::Header) -> Self::CreateProposer;
}
/// A proposal that is created by a [`Proposer`].
pub struct Proposal<Block: BlockT, Proof> {
/// The block that was build.
pub block: Block,
/// Proof that was recorded while building the block.
pub proof: Proof,
/// The storage changes while building this block.
pub storage_changes: pezsp_state_machine::StorageChanges<HashingFor<Block>>,
}
/// Error that is returned when [`ProofRecording`] requested to record a proof,
/// but no proof was recorded.
#[derive(Debug, thiserror::Error)]
#[error("Proof should be recorded, but no proof was provided.")]
pub struct NoProofRecorded;
/// A trait to express the state of proof recording on type system level.
///
/// This is used by [`Proposer`] to signal if proof recording is enabled. This can be used by
/// downstream users of the [`Proposer`] trait to enforce that proof recording is activated when
/// required. The only two implementations of this trait are [`DisableProofRecording`] and
/// [`EnableProofRecording`].
///
/// This trait is sealed and can not be implemented outside of this crate!
pub trait ProofRecording: Send + Sync + private::Sealed + 'static {
/// The proof type that will be used internally.
type Proof: Send + Sync + 'static;
/// Is proof recording enabled?
const ENABLED: bool;
/// Convert the given `storage_proof` into [`Self::Proof`].
///
/// Internally Bizinikiwi uses `Option<StorageProof>` to express the both states of proof
/// recording (for now) and as [`Self::Proof`] is some different type, we need to provide a
/// function to convert this value.
///
/// If the proof recording was requested, but `None` is given, this will return
/// `Err(NoProofRecorded)`.
fn into_proof(storage_proof: Option<StorageProof>) -> Result<Self::Proof, NoProofRecorded>;
}
/// Express that proof recording is disabled.
///
/// For more information see [`ProofRecording`].
pub struct DisableProofRecording;
impl ProofRecording for DisableProofRecording {
type Proof = ();
const ENABLED: bool = false;
fn into_proof(_: Option<StorageProof>) -> Result<Self::Proof, NoProofRecorded> {
Ok(())
}
}
/// Express that proof recording is enabled.
///
/// For more information see [`ProofRecording`].
pub struct EnableProofRecording;
impl ProofRecording for EnableProofRecording {
type Proof = pezsp_state_machine::StorageProof;
const ENABLED: bool = true;
fn into_proof(proof: Option<StorageProof>) -> Result<Self::Proof, NoProofRecorded> {
proof.ok_or(NoProofRecorded)
}
}
/// Provides `Sealed` trait to prevent implementing trait [`ProofRecording`] outside of this crate.
mod private {
/// Special trait that prevents the implementation of [`super::ProofRecording`] outside of this
/// crate.
pub trait Sealed {}
impl Sealed for super::DisableProofRecording {}
impl Sealed for super::EnableProofRecording {}
}
/// Logic for a proposer.
///
/// This will encapsulate creation and evaluation of proposals at a specific
/// block.
///
/// Proposers are generic over bits of "consensus data" which are engine-specific.
pub trait Proposer<B: BlockT> {
/// Error type which can occur when proposing or evaluating.
type Error: From<Error> + std::error::Error + 'static;
/// Future that resolves to a committed proposal with an optional proof.
type Proposal: Future<Output = Result<Proposal<B, Self::Proof>, Self::Error>>
+ Send
+ Unpin
+ 'static;
/// The supported proof recording by the implementor of this trait. See [`ProofRecording`]
/// for more information.
type ProofRecording: self::ProofRecording<Proof = Self::Proof> + Send + Sync + 'static;
/// The proof type used by [`Self::ProofRecording`].
type Proof: Send + Sync + 'static;
/// Create a proposal.
///
/// Gets the `inherent_data` and `inherent_digests` as input for the proposal. Additionally
/// a maximum duration for building this proposal is given. If building the proposal takes
/// longer than this maximum, the proposal will be very likely discarded.
///
/// If `block_size_limit` is given, the proposer should push transactions until the block size
/// limit is hit. Depending on the `finalize_block` implementation of the runtime, it probably
/// incorporates other operations (that are happening after the block limit is hit). So,
/// when the block size estimation also includes a proof that is recorded alongside the block
/// production, the proof can still grow. This means that the `block_size_limit` should not be
/// the hard limit of what is actually allowed.
///
/// # Return
///
/// Returns a future that resolves to a [`Proposal`] or to [`Error`].
fn propose(
self,
inherent_data: InherentData,
inherent_digests: Digest,
max_duration: Duration,
block_size_limit: Option<usize>,
) -> Self::Proposal;
}
/// An oracle for when major synchronization work is being undertaken.
///
/// Generally, consensus authoring work isn't undertaken while well behind
/// the head of the chain.
pub trait SyncOracle {
/// Whether the synchronization service is undergoing major sync.
/// Returns true if so.
fn is_major_syncing(&self) -> bool;
/// Whether the synchronization service is offline.
/// Returns true if so.
fn is_offline(&self) -> bool;
}
/// A synchronization oracle for when there is no network.
#[derive(Clone, Copy, Debug)]
pub struct NoNetwork;
impl SyncOracle for NoNetwork {
fn is_major_syncing(&self) -> bool {
false
}
fn is_offline(&self) -> bool {
false
}
}
impl<T> SyncOracle for Arc<T>
where
T: ?Sized,
T: SyncOracle,
{
fn is_major_syncing(&self) -> bool {
T::is_major_syncing(self)
}
fn is_offline(&self) -> bool {
T::is_offline(self)
}
}
@@ -0,0 +1,56 @@
// 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::error::Error;
use pezsp_runtime::traits::{Block as BlockT, NumberFor};
/// The SelectChain trait defines the strategy upon which the head is chosen
/// if multiple forks are present for an opaque definition of "best" in the
/// specific chain build.
///
/// The Strategy can be customized for the two use cases of authoring new blocks
/// upon the best chain or which fork to finalize. Unless implemented differently
/// by default finalization methods fall back to use authoring, so as a minimum
/// `_authoring`-functions must be implemented.
///
/// Any particular user must make explicit, however, whether they intend to finalize
/// or author through the using the right function call, as these might differ in
/// some implementations.
///
/// Non-deterministically finalizing chains may only use the `_authoring` functions.
#[async_trait::async_trait]
pub trait SelectChain<Block: BlockT>: Sync + Send + Clone {
/// Get all leaves of the chain, i.e. block hashes that have no children currently.
/// Leaves that can never be finalized will not be returned.
async fn leaves(&self) -> Result<Vec<<Block as BlockT>::Hash>, Error>;
/// Among those `leaves` deterministically pick one chain as the generally
/// best chain to author new blocks upon and probably (but not necessarily)
/// finalize.
async fn best_chain(&self) -> Result<<Block as BlockT>::Header, Error>;
/// Get the best descendent of `base_hash` that we should attempt to
/// finalize next, if any. It is valid to return the given `base_hash`
/// itself if no better descendent exists.
async fn finality_target(
&self,
base_hash: <Block as BlockT>::Hash,
_maybe_max_number: Option<NumberFor<Block>>,
) -> Result<<Block as BlockT>::Hash, Error> {
Ok(base_hash)
}
}