Fix issue with InitiateTransfer and UnpaidExecution (#7423)
Fix issue where setting the `remote_fees` field of `InitiateTransfer` to `None` could lead to unintended bypassing of fees in certain conditions. Changes made to fix this: - `remote_fees: None` now results in the `UnpaidExecution` instruction being appended *after* the origin altering instruction, be it `AliasOrigin` or `ClearOrigin`. This means `preserve_origin: true` must be set if you want to have any chance of not paying for fees. - The `AliasOrigin` instruction is not appended if the executor is called with the root location (`Here`) since it would alias to itself. Although this self-aliasing could be done, it needs the ecosystem to add a new aliasing instruction, so we just skip it. - Tweaked the `AllowExplicitUnpaidExecutionFrom` barrier to allow receiving assets (via teleport or reserve asset transfer) and altering the origin before actually using `UnpaidExecution`. This is to allow unpaid teleports to work with `InitiateTransfer`. - For this, the barrier now executes origin altering instructions and keeps track of the modified origin. It then checks if this final origin has enough permissions to not pay for fees. In order to follow the `AliasOrigin` instruction it now takes a new generic `Aliasers` that should be set to the XCM config item of the same name. This new generic has a default value of `()`, effectively disallowing the use of `AliasOrigin`. --------- Co-authored-by:cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by:
Adrian Catangiu <adrian@parity.io>
Showing
- polkadot/xcm/xcm-builder/src/barriers.rs 81 additions, 10 deletionspolkadot/xcm/xcm-builder/src/barriers.rs
- polkadot/xcm/xcm-builder/src/matcher.rs 14 additions, 0 deletionspolkadot/xcm/xcm-builder/src/matcher.rs
- polkadot/xcm/xcm-builder/src/tests/barriers.rs 367 additions, 7 deletionspolkadot/xcm/xcm-builder/src/tests/barriers.rs
- polkadot/xcm/xcm-builder/src/tests/mock.rs 7 additions, 4 deletionspolkadot/xcm/xcm-builder/src/tests/mock.rs
- polkadot/xcm/xcm-executor/src/lib.rs 27 additions, 15 deletionspolkadot/xcm/xcm-executor/src/lib.rs
- polkadot/xcm/xcm-executor/src/tests/initiate_transfer.rs 113 additions, 0 deletionspolkadot/xcm/xcm-executor/src/tests/initiate_transfer.rs
- polkadot/xcm/xcm-executor/src/tests/mock.rs 26 additions, 3 deletionspolkadot/xcm/xcm-executor/src/tests/mock.rs
- prdoc/pr_7423.prdoc 17 additions, 0 deletionsprdoc/pr_7423.prdoc