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,223 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Schema for slots in the aux-db.
use codec::{Decode, Encode};
use pezsc_client_api::backend::AuxStore;
use pezsp_blockchain::{Error as ClientError, Result as ClientResult};
use pezsp_consensus_slots::{EquivocationProof, Slot};
use pezsp_runtime::traits::Header;
const SLOT_HEADER_MAP_KEY: &[u8] = b"slot_header_map";
const SLOT_HEADER_START: &[u8] = b"slot_header_start";
/// We keep at least this number of slots in database.
pub const MAX_SLOT_CAPACITY: u64 = 1000;
/// We prune slots when they reach this number.
pub const PRUNING_BOUND: u64 = 2 * MAX_SLOT_CAPACITY;
fn load_decode<C, T>(backend: &C, key: &[u8]) -> ClientResult<Option<T>>
where
C: AuxStore,
T: Decode,
{
match backend.get_aux(key)? {
None => Ok(None),
Some(t) => T::decode(&mut &t[..])
.map_err(|e| {
ClientError::Backend(format!("Slots DB is corrupted. Decode error: {}", e))
})
.map(Some),
}
}
/// Checks if the header is an equivocation and returns the proof in that case.
///
/// Note: it detects equivocations only when slot_now - slot <= MAX_SLOT_CAPACITY.
pub fn check_equivocation<C, H, P>(
backend: &C,
slot_now: Slot,
slot: Slot,
header: &H,
signer: &P,
) -> ClientResult<Option<EquivocationProof<H, P>>>
where
H: Header,
C: AuxStore,
P: Clone + Encode + Decode + PartialEq,
{
// We don't check equivocations for old headers out of our capacity.
if slot_now.saturating_sub(*slot) > MAX_SLOT_CAPACITY {
return Ok(None);
}
// Key for this slot.
let mut curr_slot_key = SLOT_HEADER_MAP_KEY.to_vec();
slot.using_encoded(|s| curr_slot_key.extend(s));
// Get headers of this slot.
let mut headers_with_sig =
load_decode::<_, Vec<(H, P)>>(backend, &curr_slot_key[..])?.unwrap_or_else(Vec::new);
// Get first slot saved.
let slot_header_start = SLOT_HEADER_START.to_vec();
let first_saved_slot = load_decode::<_, Slot>(backend, &slot_header_start[..])?.unwrap_or(slot);
if slot_now < first_saved_slot {
// The code below assumes that slots will be visited sequentially.
return Ok(None);
}
for (prev_header, prev_signer) in headers_with_sig.iter() {
// A proof of equivocation consists of two headers:
// 1) signed by the same voter,
if prev_signer == signer {
// 2) with different hash
return if header.hash() != prev_header.hash() {
Ok(Some(EquivocationProof {
slot,
offender: signer.clone(),
first_header: prev_header.clone(),
second_header: header.clone(),
}))
} else {
// We don't need to continue in case of duplicated header,
// since it's already saved and a possible equivocation
// would have been detected before.
Ok(None)
};
}
}
let mut keys_to_delete = vec![];
let mut new_first_saved_slot = first_saved_slot;
if *slot_now - *first_saved_slot >= PRUNING_BOUND {
let prefix = SLOT_HEADER_MAP_KEY.to_vec();
new_first_saved_slot = slot_now.saturating_sub(MAX_SLOT_CAPACITY);
for s in u64::from(first_saved_slot)..new_first_saved_slot.into() {
let mut p = prefix.clone();
s.using_encoded(|s| p.extend(s));
keys_to_delete.push(p);
}
}
headers_with_sig.push((header.clone(), signer.clone()));
backend.insert_aux(
&[
(&curr_slot_key[..], headers_with_sig.encode().as_slice()),
(&slot_header_start[..], new_first_saved_slot.encode().as_slice()),
],
&keys_to_delete.iter().map(|k| &k[..]).collect::<Vec<&[u8]>>()[..],
)?;
Ok(None)
}
#[cfg(test)]
mod test {
use pezsp_core::{hash::H256, sr25519, Pair};
use pezsp_runtime::testing::{Digest as DigestTest, Header as HeaderTest};
use bizinikiwi_test_runtime_client;
use super::{check_equivocation, MAX_SLOT_CAPACITY, PRUNING_BOUND};
fn create_header(number: u64) -> HeaderTest {
// so that different headers for the same number get different hashes
let parent_hash = H256::random();
let header = HeaderTest {
parent_hash,
number,
state_root: Default::default(),
extrinsics_root: Default::default(),
digest: DigestTest { logs: vec![] },
};
header
}
#[test]
fn check_equivocation_works() {
let client = bizinikiwi_test_runtime_client::new();
let (pair, _seed) = sr25519::Pair::generate();
let public = pair.public();
let header1 = create_header(1); // @ slot 2
let header2 = create_header(2); // @ slot 2
let header3 = create_header(2); // @ slot 4
let header4 = create_header(3); // @ slot MAX_SLOT_CAPACITY + 4
let header5 = create_header(4); // @ slot MAX_SLOT_CAPACITY + 4
let header6 = create_header(3); // @ slot 4
// It's ok to sign same headers.
assert!(check_equivocation(&client, 2.into(), 2.into(), &header1, &public)
.unwrap()
.is_none(),);
assert!(check_equivocation(&client, 3.into(), 2.into(), &header1, &public)
.unwrap()
.is_none(),);
// But not two different headers at the same slot.
assert!(check_equivocation(&client, 4.into(), 2.into(), &header2, &public)
.unwrap()
.is_some(),);
// Different slot is ok.
assert!(check_equivocation(&client, 5.into(), 4.into(), &header3, &public)
.unwrap()
.is_none(),);
// Here we trigger pruning and save header 4.
assert!(check_equivocation(
&client,
(PRUNING_BOUND + 2).into(),
(MAX_SLOT_CAPACITY + 4).into(),
&header4,
&public,
)
.unwrap()
.is_none(),);
// This fails because header 5 is an equivocation of header 4.
assert!(check_equivocation(
&client,
(PRUNING_BOUND + 3).into(),
(MAX_SLOT_CAPACITY + 4).into(),
&header5,
&public,
)
.unwrap()
.is_some(),);
// This is ok because we pruned the corresponding header. Shows that we are pruning.
assert!(check_equivocation(
&client,
(PRUNING_BOUND + 4).into(),
4.into(),
&header6,
&public,
)
.unwrap()
.is_none(),);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,196 @@
// This file is part of Bizinikiwi.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Utility stream for yielding slots in a loop.
//!
//! This is used instead of `futures_timer::Interval` because it was unreliable.
use super::{InherentDataProviderExt, Slot, LOG_TARGET};
use pezsp_consensus::{SelectChain, SyncOracle};
use pezsp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use pezsp_runtime::traits::{Block as BlockT, Header as HeaderT};
use futures_timer::Delay;
use std::time::{Duration, Instant};
/// Returns current duration since unix epoch.
pub fn duration_now() -> Duration {
use std::time::SystemTime;
let now = SystemTime::now();
now.duration_since(SystemTime::UNIX_EPOCH).unwrap_or_else(|e| {
panic!("Current time {:?} is before unix epoch. Something is wrong: {:?}", now, e)
})
}
/// Returns the duration until the next slot from now.
pub fn time_until_next_slot(slot_duration: Duration) -> Duration {
let now = duration_now().as_millis();
let next_slot = (now + slot_duration.as_millis()) / slot_duration.as_millis();
let remaining_millis = next_slot * slot_duration.as_millis() - now;
Duration::from_millis(remaining_millis as u64)
}
/// Information about a slot.
pub struct SlotInfo<B: BlockT> {
/// The slot number as found in the inherent data.
pub slot: Slot,
/// The instant at which the slot ends.
pub ends_at: Instant,
/// The inherent data provider.
pub create_inherent_data: Box<dyn InherentDataProvider>,
/// Slot duration.
pub duration: Duration,
/// The chain header this slot is based on.
pub chain_head: B::Header,
/// Some potential block size limit for the block to be authored at this slot.
///
/// For more information see [`Proposer::propose`](pezsp_consensus::Proposer::propose).
pub block_size_limit: Option<usize>,
}
impl<B: BlockT> SlotInfo<B> {
/// Create a new [`SlotInfo`].
///
/// `ends_at` is calculated using `timestamp` and `duration`.
pub fn new(
slot: Slot,
create_inherent_data: Box<dyn InherentDataProvider>,
duration: Duration,
chain_head: B::Header,
block_size_limit: Option<usize>,
) -> Self {
Self {
slot,
create_inherent_data,
duration,
chain_head,
block_size_limit,
ends_at: Instant::now() + time_until_next_slot(duration),
}
}
}
/// A stream that returns every time there is a new slot.
pub(crate) struct Slots<Block, SC, IDP, SO> {
last_slot: Slot,
slot_duration: Duration,
until_next_slot: Option<Delay>,
create_inherent_data_providers: IDP,
select_chain: SC,
sync_oracle: SO,
_phantom: std::marker::PhantomData<Block>,
}
impl<Block, SC, IDP, SO> Slots<Block, SC, IDP, SO> {
/// Create a new `Slots` stream.
pub fn new(
slot_duration: Duration,
create_inherent_data_providers: IDP,
select_chain: SC,
sync_oracle: SO,
) -> Self {
Slots {
last_slot: 0.into(),
slot_duration,
until_next_slot: None,
create_inherent_data_providers,
select_chain,
sync_oracle,
_phantom: Default::default(),
}
}
}
impl<Block, SC, IDP, SO> Slots<Block, SC, IDP, SO>
where
Block: BlockT,
SC: SelectChain<Block>,
IDP: CreateInherentDataProviders<Block, ()> + 'static,
IDP::InherentDataProviders: crate::InherentDataProviderExt,
SO: SyncOracle,
{
/// Returns a future that fires when the next slot starts.
pub async fn next_slot(&mut self) -> SlotInfo<Block> {
loop {
// Wait for slot timeout
self.until_next_slot
.take()
.unwrap_or_else(|| {
// Schedule first timeout.
let wait_dur = time_until_next_slot(self.slot_duration);
Delay::new(wait_dur)
})
.await;
// Schedule delay for next slot.
let wait_dur = time_until_next_slot(self.slot_duration);
self.until_next_slot = Some(Delay::new(wait_dur));
if self.sync_oracle.is_major_syncing() {
log::debug!(target: LOG_TARGET, "Skipping slot: major sync is in progress.");
continue;
}
let chain_head = match self.select_chain.best_chain().await {
Ok(x) => x,
Err(e) => {
log::warn!(
target: LOG_TARGET,
"Unable to author block in slot. No best block header: {}",
e,
);
// Let's retry at the next slot.
continue;
},
};
let inherent_data_providers = match self
.create_inherent_data_providers
.create_inherent_data_providers(chain_head.hash(), ())
.await
{
Ok(x) => x,
Err(e) => {
log::warn!(
target: LOG_TARGET,
"Unable to author block in slot. Failure creating inherent data provider: {}",
e,
);
// Let's retry at the next slot.
continue;
},
};
let slot = inherent_data_providers.slot();
// Never yield the same slot twice.
if slot > self.last_slot {
self.last_slot = slot;
break SlotInfo::new(
slot,
Box::new(inherent_data_providers),
self.slot_duration,
chain_head,
None,
);
}
}
}
}