This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
622 additions
and
365 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,3 +73,7 @@ std = [ | |
"sp-trie/std", | ||
"xcm/std" | ||
] | ||
|
||
runtime-benchmarks = [ | ||
"sp-runtime/runtime-benchmarks" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use core::marker::PhantomData; | ||
use frame_support::{log, weights::Weight}; | ||
use xcm::latest::prelude::*; | ||
use xcm_executor::traits::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. | ||
/// 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 | ||
} | ||
|
||
// allow reserve transfers to arrive from relay chain | ||
if matches!(origin, MultiLocation { parents: 1, interior: Here }) && | ||
message.0.iter().any(|inst| matches!(inst, ReserveAssetDeposited { .. })) | ||
{ | ||
log::info!( | ||
target: "runtime::xcm-barier", | ||
"Unexpected Reserve Assets Deposited on the relay chain", | ||
); | ||
} | ||
// Permit everything else | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.