-
Notifications
You must be signed in to change notification settings - Fork 744
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 DepositReserveAsset
fees payment
#3340
Conversation
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.
Test?
What test would you like to see? It failing without the changes? You can go to #3339 , undo the
It will fail due to the reason explained in this PR. In any case, upon examining the code, it seems that the failure is potentially expected because the beforehand calculated fee is based on non-reanchored assets, while the actual calculation is performed for the reanchored assets |
I see there is a test for it in a different branch, but it is preferred I think (helps with review and ensures no regression can occur) to bundle the test with the fix when merging to master. |
@liamaharon @acatangiu I added a regression test. I'll merge the PR unless you request further changes. |
/// Regression test for `DepostiReserveAsset` changes in | ||
/// <https://github.com/paritytech/polkadot-sdk/pull/3340> | ||
#[test] | ||
fn deposit_reserve_asset_works_for_any_xcm_sender() { |
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.
this new test is failing in CI following merge from master
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.
The previous PriceForMessageDelivery
was flaky returning different prices.
Primarily, it was designed to return the same price for identical messages. However, reanchored messages weren't actually the same.
- First price calculation is done for a message with the full asset amount in
ReserveAssetDeposited
- Actual price calculation during
send()
is done for a message wheretransport_fee
has been deducted from the initial asset amount.
It does not explain by itself why the test was flaky. The reason for this flakiness is that the appended SetTopic(id)
is calculated using the previous block as entropy. This is why any change in the runtime led to changes in the final message which might or might not generate enough transport fees to be paid.
All of this made me realise that the current method of setting aside the transport_fee
for DepositReserveAsset
will never be infallible for any possible PriceForMessageDelivery
implementation. There is a circular dependency where it is impossible to know the actual DepositReserveAsset
amount that will finally be included in the message from which the transport_fee
is calculated. @acatangiu @franciscoaguirre
I followed a different approach to fix the test.
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.
Can you expand a bit on the transport cost variance?
The actual amount (scalar value) of the asset within the message changes/impacts the message weight? I.e. An instruction containing asset: 2 DOT is more expensive than same instruction with asset: 3 DOT? Did I understand that correctly?
Or is it an issue with SetTopic(id)
whose transport cost is not correctly calculated during execution of ReserveAssetDeposited
? Looking at the code I'm missing where this cost changes between when we calculate and when it is charged..
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.
An instruction containing asset: 2 DOT is more expensive than same instruction with asset: 3 DOT? Did I understand that correctly?
Not for our PriceForMessageDelivery
implementation, because it only depends on the message size, that is why it was failing when the asset was not reanchored.
I am just saying that potentially, a third party could make use of the xcm-executor
with a different PriceForMessageDelivery
implementation, and we can not guarantee that the set aside transport_fee
approach for DepositReserveAsset
will be infalible. It is just something to be aware of in case the design can be improved, not a big deal, not even probable to ever happen, and something that shouldn't block this PR.
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.
I'll proceed to merge it if the new test looks ok to you.
This pull request has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/improve-xcm-development-and-release-process/6497/1 |
Backport of #3340 It was backported to `v1.7.0` but changes didn't make it to `v1.8.0`
The
fee
should be calculated with the reanchored asset, otherwise it could lead to a failure where the set aside fee ends up not being enough.@acatangiu