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
+61
View File
@@ -0,0 +1,61 @@
[package]
name = "pezpallet-statement"
version = "10.0.0"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
homepage.workspace = true
repository.workspace = true
description = "FRAME pallet for statement store"
[lints]
workspace = true
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { features = ["derive"], workspace = true }
pezframe-support = { workspace = true }
pezframe-system = { workspace = true }
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
pezsp-api = { workspace = true }
pezsp-core = { workspace = true }
pezsp-io = { workspace = true }
pezsp-runtime = { workspace = true }
pezsp-statement-store = { workspace = true }
[dev-dependencies]
pezpallet-balances = { workspace = true, default-features = true }
[features]
default = ["std"]
std = [
"codec/std",
"pezframe-support/std",
"pezframe-system/std",
"log/std",
"pezpallet-balances/std",
"scale-info/std",
"pezsp-api/std",
"pezsp-core/std",
"pezsp-io/std",
"pezsp-runtime/std",
"pezsp-statement-store/std",
]
try-runtime = [
"pezframe-support/try-runtime",
"pezframe-system/try-runtime",
"pezpallet-balances/try-runtime",
"pezsp-runtime/try-runtime",
]
runtime-benchmarks = [
"pezframe-support/runtime-benchmarks",
"pezframe-system/runtime-benchmarks",
"pezpallet-balances/runtime-benchmarks",
"pezsp-api/runtime-benchmarks",
"pezsp-io/runtime-benchmarks",
"pezsp-runtime/runtime-benchmarks",
"pezsp-statement-store/runtime-benchmarks",
]
+225
View File
@@ -0,0 +1,225 @@
// 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.
//! Supporting pallet for the statement store.
//!
//! - [`Pallet`]
//!
//! ## Overview
//!
//! The Statement pallet provides means to create and validate statements for the statement store.
//!
//! For each statement validation function calculates the following three values based on the
//! statement author balance:
//! `max_count`: Maximum number of statements allowed for the author (signer) of this statement.
//! `max_size`: Maximum total size of statements allowed for the author (signer) of this statement.
//!
//! This pallet also contains an offchain worker that turns on-chain statement events into
//! statements. These statements are placed in the store and propagated over the network.
#![cfg_attr(not(feature = "std"), no_std)]
use pezframe_support::{
pezpallet_prelude::*,
pezsp_runtime::{traits::CheckedDiv, SaturatedConversion},
traits::fungible::Inspect,
};
use pezframe_system::pezpallet_prelude::*;
use pezsp_statement_store::{
runtime_api::{InvalidStatement, StatementSource, ValidStatement},
Proof, SignatureVerificationResult, Statement,
};
#[cfg(test)]
// We do not declare all features used by `construct_runtime`
#[allow(unexpected_cfgs)]
mod mock;
#[cfg(test)]
mod tests;
pub use pallet::*;
const LOG_TARGET: &str = "runtime::statement";
#[pezframe_support::pallet]
pub mod pallet {
use super::*;
pub type BalanceOf<T> =
<<T as Config>::Currency as Inspect<<T as pezframe_system::Config>::AccountId>>::Balance;
pub type AccountIdOf<T> = <T as pezframe_system::Config>::AccountId;
#[pallet::config]
pub trait Config: pezframe_system::Config
where
<Self as pezframe_system::Config>::AccountId: From<pezsp_statement_store::AccountId>,
{
/// The overarching event type.
#[allow(deprecated)]
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
/// The currency which is used to calculate account limits.
type Currency: Inspect<Self::AccountId>;
/// Min balance for priority statements.
#[pallet::constant]
type StatementCost: Get<BalanceOf<Self>>;
/// Cost of data byte used for priority calculation.
#[pallet::constant]
type ByteCost: Get<BalanceOf<Self>>;
/// Minimum number of statements allowed per account.
#[pallet::constant]
type MinAllowedStatements: Get<u32>;
/// Maximum number of statements allowed per account.
#[pallet::constant]
type MaxAllowedStatements: Get<u32>;
/// Minimum data bytes allowed per account.
#[pallet::constant]
type MinAllowedBytes: Get<u32>;
/// Maximum data bytes allowed per account.
#[pallet::constant]
type MaxAllowedBytes: Get<u32>;
}
#[pallet::pallet]
pub struct Pallet<T>(core::marker::PhantomData<T>);
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
pub enum Event<T: Config>
where
<T as pezframe_system::Config>::AccountId: From<pezsp_statement_store::AccountId>,
{
/// A new statement is submitted
NewStatement { account: T::AccountId, statement: Statement },
}
#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T>
where
<T as pezframe_system::Config>::AccountId: From<pezsp_statement_store::AccountId>,
pezsp_statement_store::AccountId: From<<T as pezframe_system::Config>::AccountId>,
<T as pezframe_system::Config>::RuntimeEvent: From<pallet::Event<T>>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pallet::Event<T>>,
pezsp_statement_store::BlockHash: From<<T as pezframe_system::Config>::Hash>,
{
fn offchain_worker(now: BlockNumberFor<T>) {
log::trace!(target: LOG_TARGET, "Collecting statements at #{:?}", now);
Pallet::<T>::collect_statements();
}
}
}
impl<T: Config> Pallet<T>
where
<T as pezframe_system::Config>::AccountId: From<pezsp_statement_store::AccountId>,
pezsp_statement_store::AccountId: From<<T as pezframe_system::Config>::AccountId>,
<T as pezframe_system::Config>::RuntimeEvent: From<pallet::Event<T>>,
<T as pezframe_system::Config>::RuntimeEvent: TryInto<pallet::Event<T>>,
pezsp_statement_store::BlockHash: From<<T as pezframe_system::Config>::Hash>,
{
/// Validate a statement against current state. This is supposed to be called by the statement
/// store on the host side.
pub fn validate_statement(
_source: StatementSource,
mut statement: Statement,
) -> Result<ValidStatement, InvalidStatement> {
pezsp_io::init_tracing();
log::debug!(target: LOG_TARGET, "Validating statement {:?}", statement);
let account: T::AccountId = match statement.proof() {
Some(Proof::OnChain { who, block_hash, event_index }) => {
if pezframe_system::Pallet::<T>::parent_hash().as_ref() != block_hash.as_slice() {
log::debug!(target: LOG_TARGET, "Bad block hash.");
return Err(InvalidStatement::BadProof);
}
let account: T::AccountId = (*who).into();
match pezframe_system::Pallet::<T>::event_no_consensus(*event_index as usize) {
Some(e) => {
statement.remove_proof();
if let Ok(Event::NewStatement { account: a, statement: s }) = e.try_into() {
if a != account || s != statement {
log::debug!(target: LOG_TARGET, "Event data mismatch");
return Err(InvalidStatement::BadProof);
}
} else {
log::debug!(target: LOG_TARGET, "Event type mismatch");
return Err(InvalidStatement::BadProof);
}
},
_ => {
log::debug!(target: LOG_TARGET, "Bad event index");
return Err(InvalidStatement::BadProof);
},
}
account
},
_ => match statement.verify_signature() {
SignatureVerificationResult::Valid(account) => account.into(),
SignatureVerificationResult::Invalid => {
log::debug!(target: LOG_TARGET, "Bad statement signature.");
return Err(InvalidStatement::BadProof);
},
SignatureVerificationResult::NoSignature => {
log::debug!(target: LOG_TARGET, "Missing statement signature.");
return Err(InvalidStatement::NoProof);
},
},
};
let statement_cost = T::StatementCost::get();
let byte_cost = T::ByteCost::get();
let balance = <T::Currency as Inspect<AccountIdOf<T>>>::balance(&account);
let min_allowed_statements = T::MinAllowedStatements::get();
let max_allowed_statements = T::MaxAllowedStatements::get();
let min_allowed_bytes = T::MinAllowedBytes::get();
let max_allowed_bytes = T::MaxAllowedBytes::get();
let max_count = balance
.checked_div(&statement_cost)
.unwrap_or_default()
.saturated_into::<u32>()
.clamp(min_allowed_statements, max_allowed_statements);
let max_size = balance
.checked_div(&byte_cost)
.unwrap_or_default()
.saturated_into::<u32>()
.clamp(min_allowed_bytes, max_allowed_bytes);
Ok(ValidStatement { max_count, max_size })
}
/// Submit a statement event. The statement will be picked up by the offchain worker and
/// broadcast to the network.
pub fn submit_statement(account: T::AccountId, statement: Statement) {
Self::deposit_event(Event::NewStatement { account, statement });
}
fn collect_statements() {
// Find `NewStatement` events and submit them to the store
for (index, event) in pezframe_system::Pallet::<T>::read_events_no_consensus().enumerate() {
if let Ok(Event::<T>::NewStatement { account, mut statement }) = event.event.try_into()
{
if statement.proof().is_none() {
let proof = Proof::OnChain {
who: account.into(),
block_hash: pezframe_system::Pallet::<T>::parent_hash().into(),
event_index: index as u64,
};
statement.set_proof(proof);
}
pezsp_statement_store::runtime_api::statement_store::submit_statement(statement);
}
}
}
}
+89
View File
@@ -0,0 +1,89 @@
// 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.
//! # Statement pallet test environment.
use super::*;
use crate as pezpallet_statement;
use pezframe_support::{
derive_impl, ord_parameter_types,
traits::{ConstU32, ConstU64},
};
use pezsp_core::Pair;
use pezsp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage};
type Block = pezframe_system::mocking::MockBlock<Test>;
pub const MIN_ALLOWED_STATEMENTS: u32 = 4;
pub const MAX_ALLOWED_STATEMENTS: u32 = 10;
pub const MIN_ALLOWED_BYTES: u32 = 1024;
pub const MAX_ALLOWED_BYTES: u32 = 4096;
pezframe_support::construct_runtime!(
pub enum Test
{
System: pezframe_system,
Balances: pezpallet_balances,
Statement: pezpallet_statement,
}
);
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
impl pezframe_system::Config for Test {
type AccountId = AccountId32;
type Lookup = IdentityLookup<Self::AccountId>;
type Block = Block;
type AccountData = pezpallet_balances::AccountData<u64>;
}
#[derive_impl(pezpallet_balances::config_preludes::TestDefaultConfig)]
impl pezpallet_balances::Config for Test {
type ExistentialDeposit = ConstU64<5>;
type AccountStore = System;
}
ord_parameter_types! {
pub const One: u64 = 1;
}
impl Config for Test {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type StatementCost = ConstU64<1000>;
type ByteCost = ConstU64<2>;
type MinAllowedStatements = ConstU32<MIN_ALLOWED_STATEMENTS>;
type MaxAllowedStatements = ConstU32<MAX_ALLOWED_STATEMENTS>;
type MinAllowedBytes = ConstU32<MIN_ALLOWED_BYTES>;
type MaxAllowedBytes = ConstU32<MAX_ALLOWED_BYTES>;
}
pub fn new_test_ext() -> pezsp_io::TestExternalities {
let mut t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let balances = pezpallet_balances::GenesisConfig::<Test> {
balances: vec![
(pezsp_core::sr25519::Pair::from_string("//Alice", None).unwrap().public().into(), 6000),
(
pezsp_core::sr25519::Pair::from_string("//Charlie", None).unwrap().public().into(),
500000,
),
],
..Default::default()
};
balances.assimilate_storage(&mut t).unwrap();
t.into()
}
+159
View File
@@ -0,0 +1,159 @@
// 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.
//! # Statement runtime support tests.
#![cfg(test)]
use super::*;
use crate::mock::*;
use pezsp_core::Pair;
use pezsp_runtime::AccountId32;
use pezsp_statement_store::{
runtime_api::{InvalidStatement, StatementSource, ValidStatement},
Proof, Statement,
};
#[test]
fn sign_and_validate_no_balance() {
new_test_ext().execute_with(|| {
let pair = pezsp_core::sr25519::Pair::from_string("//Bob", None).unwrap();
let mut statement = Statement::new();
statement.sign_sr25519_private(&pair);
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(
Ok(ValidStatement { max_count: MIN_ALLOWED_STATEMENTS, max_size: MIN_ALLOWED_BYTES }),
result
);
let pair = pezsp_core::ed25519::Pair::from_string("//Bob", None).unwrap();
let mut statement = Statement::new();
statement.sign_ed25519_private(&pair);
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(
Ok(ValidStatement { max_count: MIN_ALLOWED_STATEMENTS, max_size: MIN_ALLOWED_BYTES }),
result
);
let pair = pezsp_core::ecdsa::Pair::from_string("//Bob", None).unwrap();
let mut statement = Statement::new();
statement.sign_ecdsa_private(&pair);
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(
Ok(ValidStatement { max_count: MIN_ALLOWED_STATEMENTS, max_size: MIN_ALLOWED_BYTES }),
result
);
});
}
#[test]
fn validate_with_balance() {
new_test_ext().execute_with(|| {
let pair = pezsp_core::sr25519::Pair::from_string("//Alice", None).unwrap();
let mut statement = Statement::new();
statement.sign_sr25519_private(&pair);
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(Ok(ValidStatement { max_count: 6, max_size: 3000 }), result);
let pair = pezsp_core::sr25519::Pair::from_string("//Charlie", None).unwrap();
let mut statement = Statement::new();
statement.sign_sr25519_private(&pair);
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(
Ok(ValidStatement { max_count: MAX_ALLOWED_STATEMENTS, max_size: MAX_ALLOWED_BYTES }),
result
);
});
}
#[test]
fn validate_no_proof_fails() {
new_test_ext().execute_with(|| {
let statement = Statement::new();
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(Err(InvalidStatement::NoProof), result);
});
}
#[test]
fn validate_bad_signature_fails() {
new_test_ext().execute_with(|| {
let statement = Statement::new_with_proof(Proof::Sr25519 {
signature: [0u8; 64],
signer: Default::default(),
});
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(Err(InvalidStatement::BadProof), result);
});
}
#[test]
fn validate_event() {
new_test_ext().execute_with(|| {
let parent_hash = pezsp_core::H256::random();
System::reset_events();
System::initialize(&1, &parent_hash, &Default::default());
let mut statement = Statement::new();
let pair = pezsp_core::sr25519::Pair::from_string("//Alice", None).unwrap();
let account: AccountId32 = pair.public().into();
Pallet::<Test>::submit_statement(account.clone(), statement.clone());
statement.set_proof(Proof::OnChain {
who: account.clone().into(),
event_index: 0,
block_hash: parent_hash.into(),
});
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement.clone());
assert_eq!(Ok(ValidStatement { max_count: 6, max_size: 3000 }), result);
// Use wrong event index
statement.set_proof(Proof::OnChain {
who: account.clone().into(),
event_index: 1,
block_hash: parent_hash.into(),
});
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement.clone());
assert_eq!(Err(InvalidStatement::BadProof), result);
// Use wrong block hash
statement.set_proof(Proof::OnChain {
who: account.clone().into(),
event_index: 0,
block_hash: pezsp_core::H256::random().into(),
});
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement.clone());
assert_eq!(Err(InvalidStatement::BadProof), result);
});
}
#[test]
fn validate_no_event_fails() {
new_test_ext().execute_with(|| {
let parent_hash = pezsp_core::H256::random();
System::reset_events();
System::initialize(&1, &parent_hash, &Default::default());
let mut statement = Statement::new();
let pair = pezsp_core::sr25519::Pair::from_string("//Alice", None).unwrap();
let account: AccountId32 = pair.public().into();
statement.set_proof(Proof::OnChain {
who: account.into(),
event_index: 0,
block_hash: parent_hash.into(),
});
let result = Pallet::<Test>::validate_statement(StatementSource::Chain, statement);
assert_eq!(Err(InvalidStatement::BadProof), result);
});
}