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:
@@ -0,0 +1,51 @@
|
||||
[package]
|
||||
name = "pezpallet-authorship"
|
||||
version = "28.0.0"
|
||||
description = "Block and Uncle Author tracking for the FRAME"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
readme = "README.md"
|
||||
|
||||
[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 }
|
||||
impl-trait-for-tuples = { workspace = true }
|
||||
scale-info = { features = ["derive"], workspace = true }
|
||||
pezsp-runtime = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
pezsp-core = { workspace = true, default-features = true }
|
||||
pezsp-io = { workspace = true, default-features = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezframe-support/std",
|
||||
"pezframe-system/std",
|
||||
"scale-info/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-io/std",
|
||||
"pezsp-runtime/std",
|
||||
]
|
||||
try-runtime = [
|
||||
"pezframe-support/try-runtime",
|
||||
"pezframe-system/try-runtime",
|
||||
"pezsp-runtime/try-runtime",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezframe-system/runtime-benchmarks",
|
||||
"pezsp-io/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
Authorship tracking for FRAME runtimes.
|
||||
|
||||
This tracks the current author of the block and recent uncles.
|
||||
|
||||
License: Apache-2.0
|
||||
@@ -0,0 +1,177 @@
|
||||
// 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.
|
||||
|
||||
//! Authorship tracking for FRAME runtimes.
|
||||
//!
|
||||
//! This tracks the current author of the block.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use pezframe_support::traits::FindAuthor;
|
||||
|
||||
pub use pallet::*;
|
||||
|
||||
/// An event handler for the authorship pallet. There is a dummy implementation
|
||||
/// for `()`, which does nothing.
|
||||
#[impl_trait_for_tuples::impl_for_tuples(30)]
|
||||
pub trait EventHandler<Author, BlockNumber> {
|
||||
/// Note that the given account ID is the author of the current block.
|
||||
fn note_author(author: Author);
|
||||
}
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
use pezframe_system::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
/// Find the author of a block.
|
||||
type FindAuthor: FindAuthor<Self::AccountId>;
|
||||
/// An event handler for authored blocks.
|
||||
type EventHandler: EventHandler<Self::AccountId, BlockNumberFor<Self>>;
|
||||
}
|
||||
|
||||
#[pallet::pallet]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::hooks]
|
||||
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
|
||||
fn on_initialize(_: BlockNumberFor<T>) -> Weight {
|
||||
if let Some(author) = Self::author() {
|
||||
T::EventHandler::note_author(author);
|
||||
}
|
||||
|
||||
Weight::zero()
|
||||
}
|
||||
|
||||
fn on_finalize(_: BlockNumberFor<T>) {
|
||||
// ensure we never go to trie with these values.
|
||||
<Author<T>>::kill();
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::storage]
|
||||
#[pallet::whitelist_storage]
|
||||
/// Author of current block.
|
||||
pub(super) type Author<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
/// Fetch the author of the block.
|
||||
///
|
||||
/// This is safe to invoke in `on_initialize` implementations, as well
|
||||
/// as afterwards.
|
||||
pub fn author() -> Option<T::AccountId> {
|
||||
// Check the memorized storage value.
|
||||
if let Some(author) = <Author<T>>::get() {
|
||||
return Some(author);
|
||||
}
|
||||
|
||||
let digest = <pezframe_system::Pallet<T>>::digest();
|
||||
let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime());
|
||||
T::FindAuthor::find_author(pre_runtime_digests).inspect(|a| {
|
||||
<Author<T>>::put(&a);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate as pezpallet_authorship;
|
||||
use codec::{Decode, Encode};
|
||||
use pezframe_support::{derive_impl, ConsensusEngineId};
|
||||
use pezsp_core::H256;
|
||||
use pezsp_runtime::{
|
||||
generic::DigestItem, testing::Header, traits::Header as HeaderT, BuildStorage,
|
||||
};
|
||||
|
||||
type Block = pezframe_system::mocking::MockBlock<Test>;
|
||||
|
||||
pezframe_support::construct_runtime!(
|
||||
pub enum Test
|
||||
{
|
||||
System: pezframe_system,
|
||||
Authorship: pezpallet_authorship,
|
||||
}
|
||||
);
|
||||
|
||||
#[derive_impl(pezframe_system::config_preludes::TestDefaultConfig)]
|
||||
impl pezframe_system::Config for Test {
|
||||
type Block = Block;
|
||||
}
|
||||
|
||||
impl pallet::Config for Test {
|
||||
type FindAuthor = AuthorGiven;
|
||||
type EventHandler = ();
|
||||
}
|
||||
|
||||
const TEST_ID: ConsensusEngineId = [1, 2, 3, 4];
|
||||
|
||||
pub struct AuthorGiven;
|
||||
|
||||
impl FindAuthor<u64> for AuthorGiven {
|
||||
fn find_author<'a, I>(digests: I) -> Option<u64>
|
||||
where
|
||||
I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,
|
||||
{
|
||||
for (id, mut data) in digests {
|
||||
if id == TEST_ID {
|
||||
return u64::decode(&mut data).ok();
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn seal_header(mut header: Header, author: u64) -> Header {
|
||||
{
|
||||
let digest = header.digest_mut();
|
||||
digest.logs.push(DigestItem::PreRuntime(TEST_ID, author.encode()));
|
||||
digest.logs.push(DigestItem::Seal(TEST_ID, author.encode()));
|
||||
}
|
||||
|
||||
header
|
||||
}
|
||||
|
||||
fn create_header(number: u64, parent_hash: H256, state_root: H256) -> Header {
|
||||
Header::new(number, Default::default(), state_root, parent_hash, Default::default())
|
||||
}
|
||||
|
||||
fn new_test_ext() -> pezsp_io::TestExternalities {
|
||||
let t = pezframe_system::GenesisConfig::<Test>::default().build_storage().unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sets_author_lazily() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let author = 42;
|
||||
let mut header =
|
||||
seal_header(create_header(1, Default::default(), [1; 32].into()), author);
|
||||
|
||||
header.digest_mut().pop(); // pop the seal off.
|
||||
System::reset_events();
|
||||
System::initialize(&1, &Default::default(), header.digest());
|
||||
|
||||
assert_eq!(Authorship::author(), Some(author));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user