Skip to content
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

Fix issue with InitiateTransfer and UnpaidExecution #7423

Merged
merged 30 commits into from
Feb 18, 2025

Conversation

franciscoaguirre
Copy link
Contributor

@franciscoaguirre franciscoaguirre commented Feb 2, 2025

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.

@franciscoaguirre franciscoaguirre added the T6-XCM This PR/Issue is related to XCM. label Feb 2, 2025
@franciscoaguirre franciscoaguirre self-assigned this Feb 2, 2025
@franciscoaguirre franciscoaguirre requested a review from a team as a code owner February 2, 2025 23:39
@franciscoaguirre franciscoaguirre added the A4-needs-backport Pull request must be backported to all maintained releases. label Feb 2, 2025
@franciscoaguirre
Copy link
Contributor Author

/cmd prdoc --audience runtime_dev --bump patch

@franciscoaguirre
Copy link
Contributor Author

/cmd fmt

@franciscoaguirre
Copy link
Contributor Author

/cmd fmt

Copy link
Contributor

@acatangiu acatangiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The executor implementation looks good, just some code factoring comments.

The barrier isn't correct/complete:

  • needs to verify against altered origin and not physical origin (unless it relies on other barriers to alter the physical origin to the computed one)
  • needs to allow multiple asset transfer instructions before origin alter and unpaid exec instructions

Please also add regression tests for above scenarios ^ before fixing them

@franciscoaguirre
Copy link
Contributor Author

/cmd fmt

@franciscoaguirre franciscoaguirre added this pull request to the merge queue Feb 18, 2025
github-merge-queue bot pushed a commit that referenced this pull request Feb 18, 2025
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 <[email protected]>
@franciscoaguirre franciscoaguirre removed this pull request from the merge queue due to a manual request Feb 18, 2025
@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/13390690915
Failed job name: fmt

@franciscoaguirre
Copy link
Contributor Author

/cmd fmt

@franciscoaguirre franciscoaguirre added this pull request to the merge queue Feb 18, 2025
Merged via the queue into master with commit c4b4145 Feb 18, 2025
189 of 232 checks passed
@franciscoaguirre franciscoaguirre deleted the initiate-transfer-unpaid-execution branch February 18, 2025 14:23
@paritytech-cmd-bot-polkadot-sdk

Created backport PR for stable2407:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-7423-to-stable2407
git worktree add --checkout .worktree/backport-7423-to-stable2407 backport-7423-to-stable2407
cd .worktree/backport-7423-to-stable2407
git reset --hard HEAD^
git cherry-pick -x c4b41457ccc7a4a81e8b188dfbc14957cdfc002b
git push --force-with-lease

@paritytech-cmd-bot-polkadot-sdk

Created backport PR for stable2409:

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin backport-7423-to-stable2409
git worktree add --checkout .worktree/backport-7423-to-stable2409 backport-7423-to-stable2409
cd .worktree/backport-7423-to-stable2409
git reset --hard HEAD^
git cherry-pick -x c4b41457ccc7a4a81e8b188dfbc14957cdfc002b
git push --force-with-lease

github-actions bot pushed a commit that referenced this pull request Feb 18, 2025
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 <[email protected]>
(cherry picked from commit c4b4145)
@paritytech-cmd-bot-polkadot-sdk

Successfully created backport PR for stable2412:

EgorPopelyaev pushed a commit that referenced this pull request Feb 18, 2025
Backport #7423 into `stable2412` from franciscoaguirre.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Co-authored-by: Francisco Aguirre <[email protected]>
clangenb pushed a commit to clangenb/polkadot-sdk that referenced this pull request Feb 19, 2025
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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A4-needs-backport Pull request must be backported to all maintained releases. T6-XCM This PR/Issue is related to XCM.
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

3 participants