-
Notifications
You must be signed in to change notification settings - Fork 803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[XCM] Investigate better support for filtering XCM programs with Barrier
#7148
Open
Comments
3 tasks
bkontur
added
the
C1-mentor
A task where a mentor is available. Please indicate in the issue who the mentor could be.
label
Jan 14, 2025
#7169 for the fix |
I found a very old similar issue: #837 |
This was referenced Jan 15, 2025
This was
linked to
pull requests
Jan 21, 2025
2 tasks
github-merge-queue bot
pushed a commit
that referenced
this issue
Jan 27, 2025
Resolves (partially): #7148 (see _Problem 1 - `ShouldExecute` tuple implementation and `Deny` filter tuple_) This PR changes the behavior of `DenyThenTry` from the pattern `DenyIfAllMatch` to `DenyIfAnyMatch` for the tuple. I would expect the latter is the right behavior so make the fix in place, but we can also add a dedicated Impl with the legacy one untouched. ## TODO - [x] add unit-test for `DenyReserveTransferToRelayChain` - [x] add test and investigate/check `DenyThenTry` as discussed [here](#6838 (comment)) and update documentation if needed --------- Co-authored-by: Branislav Kontur <[email protected]> Co-authored-by: Francisco Aguirre <[email protected]> Co-authored-by: command-bot <> Co-authored-by: Clara van Staden <[email protected]> Co-authored-by: Adrian Catangiu <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Imagine we have a barrier like the one below. For example, we want to add new rules:
LockAsset
(no real scenario, just for testing purposes to showcase XCM filtering).ExportMessage
from a particular originxyz
.Actually, we can use
DenyThenTry
e.g.:But this
DenyAndTry
has some problems mentioned below.Problem 1 -
ShouldExecute
tuple implementation andDeny
filter tupleThe tuple implementation for
ShouldExecute
returnsOk(())
immediately when one of the tuple items passesTuple::should_execute()
.Relates to comment.
This is problematic for the
Deny
filter becauseDeny
requires all items in the tuple to be checked. For example, ifDenyCase1
is okay (meaning it does not deny execution), the tuple will returnOk(())
[here](https://github.com/paritytech/polkadot-sdk/blob/master/polkadot/xcm/xcm-executor/src/traits/should_execute.rs#L63-L74). However,DenyCase2
andDenyCase3
will be skipped, which is not the desired behavior.Solution
#7169
Problem 2 -
Barrier
vs nested XCM validationInstructions like
SetErrorHandler(xcm)
,SetAppendix(xcm)
, andExecuteWithOrigin { xcm, .. }
are meant to be executed on the local chain, but their innerxcm
is not actually checked against theBarrier
.We do not have specific barriers for these instructions, which means they could potentially bypass the
Barrier
.DenyReserveTransferToRelayChain
is just one example (below). We may encounter different cases in the future. For instance, Snowbridge already has a specific case: #6838.Example:
For example, all our system parachain barriers are structured like this barrier below.
Ok, we can deny the instruction
TransferReserveAsset { dest: Location { parents: 1, interior: Here }, .. }
usingDenyReserveTransferToRelayChain
on the incoming XCM for system parachains. However, nothing prevents us from wrappingTransferReserveAsset { dest: Location { parents: 1, interior: Here }, .. }
withSetAppendix
orExecuteWithOrigin
orSetErrorHandler
.Possible solution - be explicit
Adding new
DenyInstructionsWithXcmFor
barrier which checks nested XCM forSetErrorHandler(xcm)
,SetAppendix(xcm)
, andExecuteWithOrigin { xcm, .. }
instruction.See PoC for
DenyInstructionsWithXcmFor
This will also require #7169 to be fixed/merged.
Related another potential problem in
xcm-executor
I think another potential problem could be in the
xcm-executor
, where we recursively triggerself.process(..)
.Barrier
only once duringXcmExecutor::execute(message)
here.let result = vm.process(message);
here.Ok
orErr
), we take the XCM fromSetAppendix
orSetErrorHandler
and again triggerlet result = vm.process(message);
.ExecuteWithOrigin
, where we again triggerself.process(message)
.An easy solution seems to be to trigger
Config::Barrier::should_execute(nested_xcm)
inside or beforeself.process(message)
orvm.process(message)
. However, this won't work because, as seen in the example Barrier above, it would require every nested XCM to containUnpaidExecution
orBuyExecution/PayFees
.Therefore, we may need another Barrier/Filter specifically for nested XCM in the
XcmExecutor
, or we need to adjust the existing Barrier logic.The text was updated successfully, but these errors were encountered: