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,53 @@
|
||||
[package]
|
||||
name = "bridge-hub-common"
|
||||
version = "0.1.0"
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
description = "Bridge hub common utilities"
|
||||
license = "Apache-2.0"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
codec = { features = ["derive"], workspace = true }
|
||||
pezcumulus-primitives-core = { workspace = true }
|
||||
pezframe-support = { workspace = true }
|
||||
pezpallet-message-queue = { workspace = true }
|
||||
scale-info = { features = ["derive"], workspace = true }
|
||||
snowbridge-core = { workspace = true }
|
||||
pezsp-core = { workspace = true }
|
||||
pezsp-runtime = { workspace = true }
|
||||
pezsp-std = { workspace = true }
|
||||
xcm = { workspace = true }
|
||||
xcm-builder = { workspace = true }
|
||||
xcm-executor = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"pezcumulus-primitives-core/std",
|
||||
"pezframe-support/std",
|
||||
"pezpallet-message-queue/std",
|
||||
"scale-info/std",
|
||||
"snowbridge-core/std",
|
||||
"pezsp-core/std",
|
||||
"pezsp-runtime/std",
|
||||
"pezsp-std/std",
|
||||
"xcm-builder/std",
|
||||
"xcm-executor/std",
|
||||
"xcm/std",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"pezcumulus-primitives-core/runtime-benchmarks",
|
||||
"pezframe-support/runtime-benchmarks",
|
||||
"pezpallet-message-queue/runtime-benchmarks",
|
||||
"snowbridge-core/runtime-benchmarks",
|
||||
"pezsp-runtime/runtime-benchmarks",
|
||||
"xcm-builder/runtime-benchmarks",
|
||||
"xcm-executor/runtime-benchmarks",
|
||||
"xcm/runtime-benchmarks",
|
||||
]
|
||||
@@ -0,0 +1,57 @@
|
||||
// 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 core::{marker::PhantomData, ops::ControlFlow};
|
||||
use cumulus_primitives_core::Weight;
|
||||
use pezframe_support::traits::{Contains, ProcessMessageError};
|
||||
use xcm::prelude::{ExportMessage, Instruction, Location, NetworkId};
|
||||
|
||||
use xcm_builder::{CreateMatcher, MatchXcm};
|
||||
use xcm_executor::traits::{DenyExecution, Properties};
|
||||
|
||||
/// Deny execution if the message contains instruction `ExportMessage` with
|
||||
/// a. origin is contained in `FromOrigin` (i.e.`FromOrigin::Contains(origin)`)
|
||||
/// b. network is contained in `ToGlobalConsensus`, (i.e. `ToGlobalConsensus::contains(network)`)
|
||||
pub struct DenyExportMessageFrom<FromOrigin, ToGlobalConsensus>(
|
||||
PhantomData<(FromOrigin, ToGlobalConsensus)>,
|
||||
);
|
||||
|
||||
impl<FromOrigin, ToGlobalConsensus> DenyExecution
|
||||
for DenyExportMessageFrom<FromOrigin, ToGlobalConsensus>
|
||||
where
|
||||
FromOrigin: Contains<Location>,
|
||||
ToGlobalConsensus: Contains<NetworkId>,
|
||||
{
|
||||
fn deny_execution<RuntimeCall>(
|
||||
origin: &Location,
|
||||
message: &mut [Instruction<RuntimeCall>],
|
||||
_max_weight: Weight,
|
||||
_properties: &mut Properties,
|
||||
) -> Result<(), ProcessMessageError> {
|
||||
// This barrier only cares about messages with `origin` matching `FromOrigin`.
|
||||
if !FromOrigin::contains(origin) {
|
||||
return Ok(());
|
||||
}
|
||||
message.matcher().match_next_inst_while(
|
||||
|_| true,
|
||||
|inst| match inst {
|
||||
ExportMessage { network, .. } if ToGlobalConsensus::contains(network) =>
|
||||
Err(ProcessMessageError::Unsupported),
|
||||
_ => Ok(ControlFlow::Continue(())),
|
||||
},
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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.
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
pub mod barriers;
|
||||
pub mod message_queue;
|
||||
pub mod xcm_version;
|
||||
|
||||
pub use barriers::DenyExportMessageFrom;
|
||||
pub use message_queue::{
|
||||
AggregateMessageOrigin, BridgeHubDualMessageRouter, BridgeHubMessageRouter,
|
||||
};
|
||||
@@ -0,0 +1,197 @@
|
||||
// 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.
|
||||
//! Runtime configuration for MessageQueue pallet
|
||||
use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
|
||||
use core::marker::PhantomData;
|
||||
use cumulus_primitives_core::{AggregateMessageOrigin as CumulusAggregateMessageOrigin, ParaId};
|
||||
use pezframe_support::{
|
||||
traits::{ProcessMessage, ProcessMessageError, QueueFootprint, QueuePausedQuery},
|
||||
weights::WeightMeter,
|
||||
};
|
||||
use pezpallet_message_queue::OnQueueChanged;
|
||||
use scale_info::TypeInfo;
|
||||
use snowbridge_core::ChannelId;
|
||||
use pezsp_core::H256;
|
||||
use xcm::latest::prelude::{Junction, Location};
|
||||
|
||||
/// The aggregate origin of an inbound message.
|
||||
/// This is specialized for BridgeHub, as the snowbridge-outbound-queue-pallet is also using
|
||||
/// the shared MessageQueue pallet.
|
||||
#[derive(
|
||||
Encode,
|
||||
Decode,
|
||||
DecodeWithMemTracking,
|
||||
Copy,
|
||||
MaxEncodedLen,
|
||||
Clone,
|
||||
Eq,
|
||||
PartialEq,
|
||||
TypeInfo,
|
||||
Debug,
|
||||
)]
|
||||
pub enum AggregateMessageOrigin {
|
||||
/// The message came from the para-chain itself.
|
||||
Here,
|
||||
/// The message came from the relay-chain.
|
||||
///
|
||||
/// This is used by the DMP queue.
|
||||
Parent,
|
||||
/// The message came from a sibling para-chain.
|
||||
///
|
||||
/// This is used by the HRMP queue.
|
||||
Sibling(ParaId),
|
||||
/// The message came from a snowbridge channel.
|
||||
///
|
||||
/// This is used by Snowbridge inbound queue.
|
||||
Snowbridge(ChannelId),
|
||||
SnowbridgeV2(H256),
|
||||
}
|
||||
|
||||
impl From<AggregateMessageOrigin> for Location {
|
||||
fn from(origin: AggregateMessageOrigin) -> Self {
|
||||
use AggregateMessageOrigin::*;
|
||||
match origin {
|
||||
Here => Location::here(),
|
||||
Parent => Location::parent(),
|
||||
Sibling(id) => Location::new(1, Junction::Teyrchain(id.into())),
|
||||
// NOTE: We don't need this conversion for Snowbridge. However, we have to
|
||||
// implement it anyway as xcm_builder::ProcessXcmMessage requires it.
|
||||
_ => Location::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CumulusAggregateMessageOrigin> for AggregateMessageOrigin {
|
||||
fn from(origin: CumulusAggregateMessageOrigin) -> Self {
|
||||
match origin {
|
||||
CumulusAggregateMessageOrigin::Here => Self::Here,
|
||||
CumulusAggregateMessageOrigin::Parent => Self::Parent,
|
||||
CumulusAggregateMessageOrigin::Sibling(id) => Self::Sibling(id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<H256> for AggregateMessageOrigin {
|
||||
fn from(hash: H256) -> Self {
|
||||
Self::SnowbridgeV2(hash)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
impl From<u32> for AggregateMessageOrigin {
|
||||
fn from(x: u32) -> Self {
|
||||
match x {
|
||||
0 => Self::Here,
|
||||
1 => Self::Parent,
|
||||
p => Self::Sibling(ParaId::from(p)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Routes messages to either the XCMP or Snowbridge processor.
|
||||
pub struct BridgeHubMessageRouter<XcmpProcessor, SnowbridgeProcessor>(
|
||||
PhantomData<(XcmpProcessor, SnowbridgeProcessor)>,
|
||||
)
|
||||
where
|
||||
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
|
||||
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>;
|
||||
impl<XcmpProcessor, SnowbridgeProcessor> ProcessMessage
|
||||
for BridgeHubMessageRouter<XcmpProcessor, SnowbridgeProcessor>
|
||||
where
|
||||
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
|
||||
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
|
||||
{
|
||||
type Origin = AggregateMessageOrigin;
|
||||
fn process_message(
|
||||
message: &[u8],
|
||||
origin: Self::Origin,
|
||||
meter: &mut WeightMeter,
|
||||
id: &mut [u8; 32],
|
||||
) -> Result<bool, ProcessMessageError> {
|
||||
use AggregateMessageOrigin::*;
|
||||
match origin {
|
||||
Here | Parent | Sibling(_) =>
|
||||
XcmpProcessor::process_message(message, origin, meter, id),
|
||||
Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id),
|
||||
SnowbridgeV2(_) => Err(ProcessMessageError::Unsupported),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Routes messages to either the XCMP|Snowbridge V1 processor|Snowbridge V2 processor
|
||||
pub struct BridgeHubDualMessageRouter<XcmpProcessor, SnowbridgeProcessor, SnowbridgeProcessorV2>(
|
||||
PhantomData<(XcmpProcessor, SnowbridgeProcessor, SnowbridgeProcessorV2)>,
|
||||
)
|
||||
where
|
||||
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
|
||||
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>;
|
||||
|
||||
impl<XcmpProcessor, SnowbridgeProcessor, SnowbridgeProcessorV2> ProcessMessage
|
||||
for BridgeHubDualMessageRouter<XcmpProcessor, SnowbridgeProcessor, SnowbridgeProcessorV2>
|
||||
where
|
||||
XcmpProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
|
||||
SnowbridgeProcessor: ProcessMessage<Origin = AggregateMessageOrigin>,
|
||||
SnowbridgeProcessorV2: ProcessMessage<Origin = AggregateMessageOrigin>,
|
||||
{
|
||||
type Origin = AggregateMessageOrigin;
|
||||
|
||||
fn process_message(
|
||||
message: &[u8],
|
||||
origin: Self::Origin,
|
||||
meter: &mut WeightMeter,
|
||||
id: &mut [u8; 32],
|
||||
) -> Result<bool, ProcessMessageError> {
|
||||
use AggregateMessageOrigin::*;
|
||||
match origin {
|
||||
Here | Parent | Sibling(_) =>
|
||||
XcmpProcessor::process_message(message, origin, meter, id),
|
||||
Snowbridge(_) => SnowbridgeProcessor::process_message(message, origin, meter, id),
|
||||
SnowbridgeV2(_) => SnowbridgeProcessorV2::process_message(message, origin, meter, id),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Narrow the scope of the `Inner` query from `AggregateMessageOrigin` to `ParaId`.
|
||||
///
|
||||
/// All non-`Sibling` variants will be ignored.
|
||||
pub struct NarrowOriginToSibling<Inner>(PhantomData<Inner>);
|
||||
impl<Inner: QueuePausedQuery<ParaId>> QueuePausedQuery<AggregateMessageOrigin>
|
||||
for NarrowOriginToSibling<Inner>
|
||||
{
|
||||
fn is_paused(origin: &AggregateMessageOrigin) -> bool {
|
||||
match origin {
|
||||
AggregateMessageOrigin::Sibling(id) => Inner::is_paused(id),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<Inner: OnQueueChanged<ParaId>> OnQueueChanged<AggregateMessageOrigin>
|
||||
for NarrowOriginToSibling<Inner>
|
||||
{
|
||||
fn on_queue_changed(origin: AggregateMessageOrigin, fp: QueueFootprint) {
|
||||
if let AggregateMessageOrigin::Sibling(id) = origin {
|
||||
Inner::on_queue_changed(id, fp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert a sibling `ParaId` to an `AggregateMessageOrigin`.
|
||||
pub struct ParaIdToSibling;
|
||||
impl pezsp_runtime::traits::Convert<ParaId, AggregateMessageOrigin> for ParaIdToSibling {
|
||||
fn convert(para_id: ParaId) -> AggregateMessageOrigin {
|
||||
AggregateMessageOrigin::Sibling(para_id)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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.
|
||||
|
||||
//! Custom XCM implementation.
|
||||
|
||||
use pezframe_support::traits::Get;
|
||||
use xcm::{
|
||||
latest::prelude::*,
|
||||
prelude::{GetVersion, XcmVersion},
|
||||
};
|
||||
|
||||
/// Adapter for the implementation of `GetVersion`, which attempts to find the minimal
|
||||
/// configured XCM version between the destination `dest` and the bridge hub location provided as
|
||||
/// `Get<Location>`.
|
||||
pub struct XcmVersionOfDestAndRemoteBridge<Version, RemoteBridge>(
|
||||
pezsp_std::marker::PhantomData<(Version, RemoteBridge)>,
|
||||
);
|
||||
impl<Version: GetVersion, RemoteBridge: Get<Location>> GetVersion
|
||||
for XcmVersionOfDestAndRemoteBridge<Version, RemoteBridge>
|
||||
{
|
||||
fn get_version_for(dest: &Location) -> Option<XcmVersion> {
|
||||
let dest_version = Version::get_version_for(dest);
|
||||
let bridge_hub_version = Version::get_version_for(&RemoteBridge::get());
|
||||
|
||||
match (dest_version, bridge_hub_version) {
|
||||
(Some(dv), Some(bhv)) => Some(pezsp_std::cmp::min(dv, bhv)),
|
||||
(Some(dv), None) => Some(dv),
|
||||
(None, Some(bhv)) => Some(bhv),
|
||||
(None, None) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezcumulus.
|
||||
// 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.
|
||||
|
||||
#![cfg(test)]
|
||||
use bridge_hub_common::DenyExportMessageFrom;
|
||||
use pezframe_support::{
|
||||
parameter_types,
|
||||
traits::{Equals, EverythingBut, ProcessMessageError::Unsupported},
|
||||
};
|
||||
use xcm::prelude::{
|
||||
AliasOrigin, ByGenesis, ExportMessage, Here, Instruction, Location, NetworkId, Teyrchain,
|
||||
Weight,
|
||||
};
|
||||
use xcm_executor::traits::{DenyExecution, Properties};
|
||||
|
||||
#[test]
|
||||
fn test_deny_export_message_from() {
|
||||
parameter_types! {
|
||||
pub Source1: Location = Location::new(1, Teyrchain(1));
|
||||
pub Source2: Location = Location::new(1, Teyrchain(2));
|
||||
pub Remote1: NetworkId = ByGenesis([1;32]);
|
||||
pub Remote2: NetworkId = ByGenesis([2;32]);
|
||||
}
|
||||
|
||||
// Deny ExportMessage when both of the conditions met:
|
||||
// 1: source != Source1
|
||||
// 2: network == Remote1
|
||||
pub type Denied = DenyExportMessageFrom<EverythingBut<Equals<Source1>>, Equals<Remote1>>;
|
||||
|
||||
let assert_deny_execution = |mut xcm: Vec<Instruction<()>>, origin, expected_result| {
|
||||
assert_eq!(
|
||||
Denied::deny_execution(
|
||||
&origin,
|
||||
&mut xcm,
|
||||
Weight::zero(),
|
||||
&mut Properties { weight_credit: Weight::zero(), message_id: None }
|
||||
),
|
||||
expected_result
|
||||
);
|
||||
};
|
||||
|
||||
// A message without an `ExportMessage` should pass
|
||||
assert_deny_execution(vec![AliasOrigin(Here.into())], Source1::get(), Ok(()));
|
||||
|
||||
// `ExportMessage` from source1 and remote1 should pass
|
||||
assert_deny_execution(
|
||||
vec![ExportMessage { network: Remote1::get(), destination: Here, xcm: Default::default() }],
|
||||
Source1::get(),
|
||||
Ok(()),
|
||||
);
|
||||
|
||||
// `ExportMessage` from source1 and remote2 should pass
|
||||
assert_deny_execution(
|
||||
vec![ExportMessage { network: Remote2::get(), destination: Here, xcm: Default::default() }],
|
||||
Source1::get(),
|
||||
Ok(()),
|
||||
);
|
||||
|
||||
// `ExportMessage` from source2 and remote2 should pass
|
||||
assert_deny_execution(
|
||||
vec![ExportMessage { network: Remote2::get(), destination: Here, xcm: Default::default() }],
|
||||
Source2::get(),
|
||||
Ok(()),
|
||||
);
|
||||
|
||||
// `ExportMessage` from source2 and remote1 should be banned
|
||||
assert_deny_execution(
|
||||
vec![ExportMessage { network: Remote1::get(), destination: Here, xcm: Default::default() }],
|
||||
Source2::get(),
|
||||
Err(Unsupported),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user