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 380
Deny using relay chain for reserve transfers #1169
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a46c63b
Deny using relay chain for reserve transfers
gilescope 976d97e
match on junction as well.
gilescope aa7162f
PR feedback
gilescope 2c9dffa
cargp fmt
gilescope 3c6bca4
Update polkadot-parachains/parachains-common/src/xcm_config.rs
gilescope 7b5ae32
Update polkadot-parachains/parachains-common/src/xcm_config.rs
gilescope d273913
Use Err to signal deny
gilescope d1b7a2c
avoid parachains-common dep
gilescope 53c7c41
remove dupe
gilescope 23dca6f
Deny depisiting reserved assets + fmt
gilescope a40a794
Allow DepositReserveAssets from relay chain
gilescope 6506216
Rather than allow DepositReserveAsset,
gilescope 8a13804
Update polkadot-parachains/parachains-common/src/xcm_config.rs
gilescope 514e0b9
don't reference common parachains.
gilescope 8d1b9a4
Update parachain-template/runtime/src/xcm_config.rs
gilescope 4e68004
Warn if reserve asset deposited msg detected.
gilescope File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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", | ||
KiChjang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"Unexpected Reserve Assets Deposited on the relay chain", | ||
); | ||
} | ||
// Permit everything else | ||
Ok(()) | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be paritytech/polkadot#5233
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, meant to make a follow up PR to docs in parachain-template. Will fix this too.