From c98c75eb8465112a7d125841d7f2e3e7bf9a5cdb Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Thu, 9 Feb 2023 17:07:56 -0300 Subject: [PATCH 1/2] Add RejectReason to barriers --- parachains/common/src/xcm_config.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parachains/common/src/xcm_config.rs b/parachains/common/src/xcm_config.rs index ac4cd8858e7..ede60b3fcbd 100644 --- a/parachains/common/src/xcm_config.rs +++ b/parachains/common/src/xcm_config.rs @@ -7,7 +7,7 @@ use frame_support::{ }; use sp_runtime::traits::Get; use xcm::latest::prelude::*; -use xcm_executor::traits::ShouldExecute; +use xcm_executor::traits::{RejectReason, ShouldExecute}; //TODO: move DenyThenTry to polkadot's xcm module. /// Deny executing the XCM if it matches any of the Deny filter regardless of anything else. @@ -27,7 +27,7 @@ where message: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, - ) -> Result<(), ()> { + ) -> Result<(), RejectReason> { Deny::should_execute(origin, message, max_weight, weight_credit)?; Allow::should_execute(origin, message, max_weight, weight_credit) } @@ -41,7 +41,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { message: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, - ) -> Result<(), ()> { + ) -> Result<(), RejectReason> { if message.iter().any(|inst| { matches!( inst, @@ -55,7 +55,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { } ) }) { - return Err(()) // Deny + return Err(RejectReason::ForbiddenInstructions) // Deny } // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve` From 7bb41d725c053215be30e3abf3927976ee79e995 Mon Sep 17 00:00:00 2001 From: Keith Yeung Date: Fri, 10 Feb 2023 00:52:41 -0300 Subject: [PATCH 2/2] Fixes --- parachain-template/runtime/src/xcm_config.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parachain-template/runtime/src/xcm_config.rs b/parachain-template/runtime/src/xcm_config.rs index fa056fc65d3..7a1f5798c2e 100644 --- a/parachain-template/runtime/src/xcm_config.rs +++ b/parachain-template/runtime/src/xcm_config.rs @@ -19,7 +19,7 @@ use xcm_builder::{ SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WithComputedOrigin, }; -use xcm_executor::{traits::ShouldExecute, XcmExecutor}; +use xcm_executor::{traits::{RejectReason, ShouldExecute}, XcmExecutor}; parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); @@ -107,7 +107,7 @@ where message: &mut [Instruction], max_weight: Weight, weight_credit: &mut Weight, - ) -> Result<(), ()> { + ) -> Result<(), RejectReason> { Deny::should_execute(origin, message, max_weight, weight_credit)?; Allow::should_execute(origin, message, max_weight, weight_credit) } @@ -121,7 +121,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { message: &mut [Instruction], _max_weight: Weight, _weight_credit: &mut Weight, - ) -> Result<(), ()> { + ) -> Result<(), RejectReason> { if message.iter().any(|inst| { matches!( inst, @@ -135,7 +135,7 @@ impl ShouldExecute for DenyReserveTransferToRelayChain { } ) }) { - return Err(()) // Deny + return Err(RejectReason::ForbiddenInstructions) // Deny } // An unexpected reserve transfer has arrived from the Relay Chain. Generally, `IsReserve`