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,189 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Bizinikiwi 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.
|
||||
|
||||
// Bizinikiwi 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 Bizinikiwi. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Teyrchain runtime mock.
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
|
||||
use pezframe_support::weights::Weight;
|
||||
use pezkuwi_primitives::BlockNumber as RelayBlockNumber;
|
||||
use pezkuwi_teyrchain_primitives::primitives::{
|
||||
DmpMessageHandler, Id as ParaId, XcmpMessageFormat, XcmpMessageHandler,
|
||||
};
|
||||
use pezsp_runtime::traits::{Get, Hash};
|
||||
|
||||
use xcm::{latest::prelude::*, VersionedXcm};
|
||||
|
||||
#[pezframe_support::pallet]
|
||||
pub mod pallet {
|
||||
use super::*;
|
||||
use pezframe_support::pezpallet_prelude::*;
|
||||
|
||||
#[pallet::config]
|
||||
pub trait Config: pezframe_system::Config {
|
||||
#[allow(deprecated)]
|
||||
type RuntimeEvent: From<Event<Self>> + IsType<<Self as pezframe_system::Config>::RuntimeEvent>;
|
||||
type XcmExecutor: ExecuteXcm<Self::RuntimeCall>;
|
||||
}
|
||||
|
||||
#[pallet::call]
|
||||
impl<T: Config> Pallet<T> {}
|
||||
|
||||
#[pallet::pallet]
|
||||
#[pallet::without_storage_info]
|
||||
pub struct Pallet<T>(_);
|
||||
|
||||
#[pallet::storage]
|
||||
pub(super) type TeyrchainId<T: Config> = StorageValue<_, ParaId, ValueQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
/// A queue of received DMP messages
|
||||
pub(super) type ReceivedDmp<T: Config> = StorageValue<_, Vec<Xcm<T::RuntimeCall>>, ValueQuery>;
|
||||
|
||||
impl<T: Config> Get<ParaId> for Pallet<T> {
|
||||
fn get() -> ParaId {
|
||||
TeyrchainId::<T>::get()
|
||||
}
|
||||
}
|
||||
|
||||
pub type MessageId = [u8; 32];
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config> {
|
||||
/// Some XCM was executed OK.
|
||||
Success(Option<T::Hash>),
|
||||
/// Some XCM failed.
|
||||
Fail(Option<T::Hash>, XcmError),
|
||||
/// Bad XCM version used.
|
||||
BadVersion(Option<T::Hash>),
|
||||
/// Bad XCM format used.
|
||||
BadFormat(Option<T::Hash>),
|
||||
|
||||
// DMP
|
||||
/// Downward message is invalid XCM.
|
||||
InvalidFormat(MessageId),
|
||||
/// Downward message is unsupported version of XCM.
|
||||
UnsupportedVersion(MessageId),
|
||||
/// Downward message executed with the given outcome.
|
||||
ExecutedDownward(MessageId, Outcome),
|
||||
}
|
||||
|
||||
impl<T: Config> Pallet<T> {
|
||||
pub fn set_para_id(para_id: ParaId) {
|
||||
TeyrchainId::<T>::put(para_id);
|
||||
}
|
||||
|
||||
pub fn teyrchain_id() -> ParaId {
|
||||
TeyrchainId::<T>::get()
|
||||
}
|
||||
|
||||
pub fn received_dmp() -> Vec<Xcm<T::RuntimeCall>> {
|
||||
ReceivedDmp::<T>::get()
|
||||
}
|
||||
|
||||
fn handle_xcmp_message(
|
||||
sender: ParaId,
|
||||
_sent_at: RelayBlockNumber,
|
||||
xcm: VersionedXcm<T::RuntimeCall>,
|
||||
max_weight: Weight,
|
||||
) -> Result<Weight, XcmError> {
|
||||
let hash = Encode::using_encoded(&xcm, T::Hashing::hash);
|
||||
let mut message_hash = Encode::using_encoded(&xcm, pezsp_io::hashing::blake2_256);
|
||||
let (result, event) = match Xcm::<T::RuntimeCall>::try_from(xcm) {
|
||||
Ok(xcm) => {
|
||||
let location = (Parent, Teyrchain(sender.into()));
|
||||
match T::XcmExecutor::prepare_and_execute(
|
||||
location,
|
||||
xcm,
|
||||
&mut message_hash,
|
||||
max_weight,
|
||||
Weight::zero(),
|
||||
) {
|
||||
Outcome::Error(InstructionError { error, .. }) =>
|
||||
(Err(error), Event::Fail(Some(hash), error)),
|
||||
Outcome::Complete { used } => (Ok(used), Event::Success(Some(hash))),
|
||||
// As far as the caller is concerned, this was dispatched without error, so
|
||||
// we just report the weight used.
|
||||
Outcome::Incomplete {
|
||||
used, error: InstructionError { error, .. }, ..
|
||||
} => (Ok(used), Event::Fail(Some(hash), error)),
|
||||
}
|
||||
},
|
||||
Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))),
|
||||
};
|
||||
Self::deposit_event(event);
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> XcmpMessageHandler for Pallet<T> {
|
||||
fn handle_xcmp_messages<'a, I: Iterator<Item = (ParaId, RelayBlockNumber, &'a [u8])>>(
|
||||
iter: I,
|
||||
max_weight: Weight,
|
||||
) -> Weight {
|
||||
for (sender, sent_at, data) in iter {
|
||||
let mut data_ref = data;
|
||||
let _ = XcmpMessageFormat::decode(&mut data_ref)
|
||||
.expect("Simulator encodes with versioned xcm format; qed");
|
||||
|
||||
let mut remaining_fragments = data_ref;
|
||||
while !remaining_fragments.is_empty() {
|
||||
if let Ok(xcm) =
|
||||
VersionedXcm::<T::RuntimeCall>::decode(&mut remaining_fragments)
|
||||
{
|
||||
let _ = Self::handle_xcmp_message(sender, sent_at, xcm, max_weight);
|
||||
} else {
|
||||
debug_assert!(false, "Invalid incoming XCMP message data");
|
||||
}
|
||||
}
|
||||
}
|
||||
max_weight
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Config> DmpMessageHandler for Pallet<T> {
|
||||
fn handle_dmp_messages(
|
||||
iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
|
||||
limit: Weight,
|
||||
) -> Weight {
|
||||
for (_i, (_sent_at, data)) in iter.enumerate() {
|
||||
let mut id = pezsp_io::hashing::blake2_256(&data[..]);
|
||||
let maybe_versioned = VersionedXcm::<T::RuntimeCall>::decode(&mut &data[..]);
|
||||
match maybe_versioned {
|
||||
Err(_) => {
|
||||
Self::deposit_event(Event::InvalidFormat(id));
|
||||
},
|
||||
Ok(versioned) => match Xcm::try_from(versioned) {
|
||||
Err(()) => Self::deposit_event(Event::UnsupportedVersion(id)),
|
||||
Ok(x) => {
|
||||
let outcome = T::XcmExecutor::prepare_and_execute(
|
||||
Parent,
|
||||
x.clone(),
|
||||
&mut id,
|
||||
limit,
|
||||
Weight::zero(),
|
||||
);
|
||||
ReceivedDmp::<T>::append(x);
|
||||
Self::deposit_event(Event::ExecutedDownward(id, outcome));
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
limit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Bizinikiwi.
|
||||
|
||||
// Bizinikiwi 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.
|
||||
|
||||
// Bizinikiwi 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 Bizinikiwi. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use pezframe_support::{parameter_types, weights::Weight};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_simulator::{
|
||||
AggregateMessageOrigin, ProcessMessage, ProcessMessageError, UmpQueueId, WeightMeter,
|
||||
};
|
||||
|
||||
use crate::relay_chain::{RuntimeCall, XcmConfig};
|
||||
|
||||
parameter_types! {
|
||||
/// Amount of weight that can be spent per block to service messages.
|
||||
pub MessageQueueServiceWeight: Weight = Weight::from_parts(1_000_000_000, 1_000_000);
|
||||
pub const MessageQueueHeapSize: u32 = 65_536;
|
||||
pub const MessageQueueMaxStale: u32 = 16;
|
||||
}
|
||||
|
||||
/// Message processor to handle any messages that were enqueued into the `MessageQueue` pallet.
|
||||
pub struct MessageProcessor;
|
||||
impl ProcessMessage for MessageProcessor {
|
||||
type Origin = AggregateMessageOrigin;
|
||||
|
||||
fn process_message(
|
||||
message: &[u8],
|
||||
origin: Self::Origin,
|
||||
meter: &mut WeightMeter,
|
||||
id: &mut [u8; 32],
|
||||
) -> Result<bool, ProcessMessageError> {
|
||||
let para = match origin {
|
||||
AggregateMessageOrigin::Ump(UmpQueueId::Para(para)) => para,
|
||||
};
|
||||
xcm_builder::ProcessXcmMessage::<
|
||||
Junction,
|
||||
xcm_executor::XcmExecutor<XcmConfig>,
|
||||
RuntimeCall,
|
||||
>::process_message(message, Junction::Teyrchain(para.into()), meter, id)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user