mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-09 02:28:05 +00:00
Merge remote-tracking branch 'origin' into gav-xcm-v3
This commit is contained in:
@@ -9,6 +9,7 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
mod weights;
|
||||
pub mod xcm_config;
|
||||
|
||||
use cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
|
||||
use smallvec::smallvec;
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_core::{crypto::KeyTypeId, OpaqueMetadata};
|
||||
@@ -353,6 +354,7 @@ parameter_types! {
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type Event = Event;
|
||||
type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, ()>;
|
||||
type WeightToFee = WeightToFee;
|
||||
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
|
||||
@@ -369,11 +371,12 @@ impl cumulus_pallet_parachain_system::Config for Runtime {
|
||||
type Event = Event;
|
||||
type OnSystemEvent = ();
|
||||
type SelfParaId = parachain_info::Pallet<Runtime>;
|
||||
type OutboundXcmpMessageSource = XcmpQueue;
|
||||
type DmpMessageHandler = DmpQueue;
|
||||
type ReservedDmpWeight = ReservedDmpWeight;
|
||||
type OutboundXcmpMessageSource = XcmpQueue;
|
||||
type XcmpMessageHandler = XcmpQueue;
|
||||
type ReservedXcmpWeight = ReservedXcmpWeight;
|
||||
type CheckAssociatedRelayNumber = RelayNumberStrictlyIncreases;
|
||||
}
|
||||
|
||||
impl parachain_info::Config for Runtime {}
|
||||
@@ -474,7 +477,7 @@ construct_runtime!(
|
||||
|
||||
// Monetary stuff.
|
||||
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 10,
|
||||
TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 11,
|
||||
TransactionPayment: pallet_transaction_payment::{Pallet, Storage, Event<T>} = 11,
|
||||
|
||||
// Collator support. The order of these 4 are important and shall not change.
|
||||
Authorship: pallet_authorship::{Pallet, Call, Storage} = 20,
|
||||
|
||||
@@ -2,8 +2,9 @@ use super::{
|
||||
AccountId, Balances, Call, Event, Origin, ParachainInfo, ParachainSystem, PolkadotXcm, Runtime,
|
||||
WeightToFee, XcmpQueue,
|
||||
};
|
||||
use core::marker::PhantomData;
|
||||
use frame_support::{
|
||||
match_types, parameter_types,
|
||||
log, match_types, parameter_types,
|
||||
traits::{ConstU32, Everything, Nothing},
|
||||
weights::Weight,
|
||||
};
|
||||
@@ -18,7 +19,7 @@ use xcm_builder::{
|
||||
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
|
||||
UsingComponents,
|
||||
};
|
||||
use xcm_executor::XcmExecutor;
|
||||
use xcm_executor::{traits::ShouldExecute, XcmExecutor};
|
||||
|
||||
parameter_types! {
|
||||
pub const RelayLocation: MultiLocation = MultiLocation::parent();
|
||||
@@ -88,12 +89,79 @@ match_types! {
|
||||
};
|
||||
}
|
||||
|
||||
pub type Barrier = (
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// ^^^ Parent and its exec plurality get free execution
|
||||
);
|
||||
//TODO: move DenyThenTry to polkadot's xcm module.
|
||||
/// Deny executing the xcm message if it matches any of the Deny filter regardless of anything else.
|
||||
/// If it passes the Deny, and matches one of the Allow cases then it is let through.
|
||||
pub struct DenyThenTry<Deny, Allow>(PhantomData<Deny>, PhantomData<Allow>)
|
||||
where
|
||||
Deny: ShouldExecute,
|
||||
Allow: ShouldExecute;
|
||||
|
||||
impl<Deny, Allow> ShouldExecute for DenyThenTry<Deny, Allow>
|
||||
where
|
||||
Deny: ShouldExecute,
|
||||
Allow: ShouldExecute,
|
||||
{
|
||||
fn should_execute<Call>(
|
||||
origin: &MultiLocation,
|
||||
message: &mut Xcm<Call>,
|
||||
max_weight: Weight,
|
||||
weight_credit: &mut Weight,
|
||||
) -> Result<(), ()> {
|
||||
Deny::should_execute(origin, message, max_weight, weight_credit)?;
|
||||
Allow::should_execute(origin, message, max_weight, weight_credit)
|
||||
}
|
||||
}
|
||||
|
||||
// See issue #5233
|
||||
pub struct DenyReserveTransferToRelayChain;
|
||||
impl ShouldExecute for DenyReserveTransferToRelayChain {
|
||||
fn should_execute<Call>(
|
||||
origin: &MultiLocation,
|
||||
message: &mut Xcm<Call>,
|
||||
_max_weight: Weight,
|
||||
_weight_credit: &mut Weight,
|
||||
) -> Result<(), ()> {
|
||||
if message.0.iter().any(|inst| {
|
||||
matches!(
|
||||
inst,
|
||||
InitiateReserveWithdraw {
|
||||
reserve: MultiLocation { parents: 1, interior: Here },
|
||||
..
|
||||
} | DepositReserveAsset { dest: MultiLocation { parents: 1, interior: Here }, .. } |
|
||||
TransferReserveAsset {
|
||||
dest: MultiLocation { parents: 1, interior: Here },
|
||||
..
|
||||
}
|
||||
)
|
||||
}) {
|
||||
return Err(()) // Deny
|
||||
}
|
||||
|
||||
// An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve`
|
||||
// should not allow this, but we just log it here.
|
||||
if matches!(origin, MultiLocation { parents: 1, interior: Here }) &&
|
||||
message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. }))
|
||||
{
|
||||
log::warn!(
|
||||
target: "xcm::barriers",
|
||||
"Unexpected ReserveAssetDeposited from the Relay Chain",
|
||||
);
|
||||
}
|
||||
// Permit everything else
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub type Barrier = DenyThenTry<
|
||||
DenyReserveTransferToRelayChain,
|
||||
(
|
||||
TakeWeightCredit,
|
||||
AllowTopLevelPaidExecutionFrom<Everything>,
|
||||
AllowUnpaidExecutionFrom<ParentOrParentsExecutivePlurality>,
|
||||
// ^^^ Parent and its exec plurality get free execution
|
||||
),
|
||||
>;
|
||||
|
||||
pub struct XcmConfig;
|
||||
impl xcm_executor::Config for XcmConfig {
|
||||
|
||||
Reference in New Issue
Block a user