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 delivery fees issue in Kusama #3075

Closed

Conversation

franciscoaguirre
Copy link
Contributor

@franciscoaguirre franciscoaguirre commented Jan 26, 2024

This fix aims to solve an issue in Kusama that resulted in failed reserve asset transfers.
It will be ported later to master as well.
The issue is that during multi-hop XCMs, like reserve asset transfers where the reserve is not the sender nor the destination, there are no assets available to pay for delivery fees.
This fix makes sure to deduct delivery fees from the assets being transferred.

@franciscoaguirre franciscoaguirre changed the base branch from master to release-crates-io-v1.3.0 January 26, 2024 11:06
self.send(dest, Xcm(message), FeeReason::DepositReserveAsset)?;
Ok(())
},
InitiateReserveWithdraw { assets, reserve, xcm } => {
// we need to do this take/put cycle to solve wildcards and get exact assets to be
Copy link
Contributor

Choose a reason for hiding this comment

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

This is less of a problem since it happens on the origin chain, and not the intermediary chain. We could thus use JIT withdrawal to resolve this.

However, we may want a consistent UX, which would require us to not use JIT withdrawal and remove the SetFeesMode instruction when executing the initial teleport or reserve asset transfer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing with jit withdrawal is that it's not expected.
Users pay assets and expect execution fees to be deducted from that amount.
With jit withdrawal we are deducting delivery fees from the user's account itself, which might not have more assets after the transfer.
So user has to make sure they pay assets and also have enough for delivery fees.
This makes it so they only pay assets and both execution and delivery fees are deducted from that amount.

Copy link
Contributor

Choose a reason for hiding this comment

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

this is definitely needed for InitiateReserveWithdraw too but not for the current scenario where the intermediary chain is the reserve - I say we keep it, but add a check if jit_withdraw is set - if it is, then we can skip it and let it withdraw from origin's account instead of holding

(maybe we do this jit check for all of them, but honestly I would just deprecate JIT_WITHDRAW altogether, it just introduces extra complexity and error cases)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the SetFeesMode { jit_withdraw: true } instruction from the teleport and reserve asset transfer extrinsics and re-run the benchmarks. It should only charge for the fees once now and in a more consistent way.

Copy link
Contributor

Choose a reason for hiding this comment

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

that's true for pallet-xcm, but what about other xcm pallets (e.g. xtokens who surfaced this)?

we can't assume in executor that no one will use SetFeesMode { jit_withdraw: true } - as long as we have it, we have to assume it can/will be used

Choose a reason for hiding this comment

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

@franciscoaguirre, just to confirm; this means that we can't just send now (as an example) USDT to a para chain from AssetHub. We also have to include KSM and AT LEAST the amount of the XCM delivery fee? And then whatever we put over the min XCM Delivery Fee amount will be delivered to the target account in the target chain?

@franciscoaguirre franciscoaguirre added the R0-silent Changes should not be mentioned in any release notes label Jan 26, 2024
@franciscoaguirre franciscoaguirre marked this pull request as ready for review January 26, 2024 11:40
@franciscoaguirre franciscoaguirre requested a review from a team as a code owner January 26, 2024 11:40
@franciscoaguirre
Copy link
Contributor Author

bot fmt

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5038910 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh". Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 3-4cc381c2-808a-4104-a37f-ba56f879f19d to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre Command "$PIPELINE_SCRIPTS_DIR/commands/fmt/fmt.sh" has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5038910 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5038910/artifacts/download.

@franciscoaguirre
Copy link
Contributor Author

bot help

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

Here's a link to docs

@franciscoaguirre
Copy link
Contributor Author

bot bench polkadot-pallet --runtime westend --subcommand xcm --pallet pallet_xcm
bot bench polkadot-pallet --runtime rococo --subcommand xcm --pallet pallet_xcm

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040093 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm. Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 4-9fcf7df8-fec4-48be-9307-006ff135c1cb to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040094 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" --subcommand=xcm --runtime=rococo --target_dir=polkadot --pallet=pallet_xcm. Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 5-dd6a5fc0-bc34-4db5-b0b7-d8e7477a6fea to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre Command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" --subcommand=xcm --runtime=rococo --target_dir=polkadot --pallet=pallet_xcm has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040094 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040094/artifacts/download.

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre Command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040093 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040093/artifacts/download.

@franciscoaguirre
Copy link
Contributor Author

bot bench polkadot-pallet --runtime westend --subcommand xcm --pallet pallet_xcm
bot bench polkadot-pallet --runtime rococo --subcommand xcm --pallet pallet_xcm

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040237 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm. Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 6-ba321867-5816-4dc0-89f3-414b0ffe5e1a to cancel this command or bot cancel to cancel all commands in this pull request.

@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040238 was started for your command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" --subcommand=xcm --runtime=rococo --target_dir=polkadot --pallet=pallet_xcm. Check out https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/pipelines?page=1&scope=all&username=group_605_bot to know what else is being executed currently.

Comment bot cancel 7-49ae40d8-d88e-4247-bcd5-b3d63036fb15 to cancel this command or bot cancel to cancel all commands in this pull request.

…stend --target_dir=polkadot --pallet=pallet_xcm
@command-bot
Copy link

command-bot bot commented Jan 26, 2024

@franciscoaguirre Command "$PIPELINE_SCRIPTS_DIR/commands/bench/bench.sh" --subcommand=xcm --runtime=westend --target_dir=polkadot --pallet=pallet_xcm has finished. Result: https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040237 has finished. If any artifacts were generated, you can download them from https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/5040237/artifacts/download.

…coco --target_dir=polkadot --pallet=pallet_xcm
@franciscoaguirre
Copy link
Contributor Author

@acatangiu Users can accomplish the same thing with DepositReserveAsset, which is the main thing in this fix. In order to release it sooner rather than later, I think we can do without changing TransferReserveAsset. What do you think?

let mut message_to_weigh =
vec![WithdrawAsset(to_weigh.into()), ClearOrigin];
message_to_weigh.extend(xcm.0.clone().into_iter());
let (_, fee) = validate_send::<Config::XcmSender>(reserve, Xcm(message_to_weigh))?;
Copy link

@ERussel ERussel Jan 26, 2024

Choose a reason for hiding this comment

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

As I understand fee is calculated in the native asset (for example, KSM). How will it work for the cases when, for example, RMRK or USDT is transferred from the Kusama Asset Hub and no KSM in the holding? Will the extrinsic itself fail on the Asset Hub and the state will be rolled back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Until fees can be paid in another asset, there should always be enough KSM to pay for fees, not only for delivery, also for execution.

Copy link

Choose a reason for hiding this comment

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

Does this mean that KSM must be included into the xcm together with the sending token (USDT)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It should've always been the case in order to pay for the regular execution fees.

@franciscoaguirre franciscoaguirre changed the base branch from release-crates-io-v1.3.0 to master January 26, 2024 15:02
@franciscoaguirre franciscoaguirre requested review from a team January 26, 2024 15:02
@franciscoaguirre franciscoaguirre requested a review from a team January 26, 2024 15:02
@franciscoaguirre franciscoaguirre requested review from koute and a team as code owners January 26, 2024 15:02
@franciscoaguirre franciscoaguirre changed the base branch from master to release-crates-io-v1.3.0 January 26, 2024 15:13
Signed-off-by: Adrian Catangiu <adrian@parity.io>
let (_, fee) =
validate_send::<Config::XcmSender>(reserve, Xcm(message_to_weigh))?;
// set aside fee to be charged by XcmSender
Some(self.holding.saturating_take(fee.into()))
Copy link

@ERussel ERussel Jan 26, 2024

Choose a reason for hiding this comment

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

Can trader be used to address cases for fee payment in asset available in holding as implemented in BuyExecution? Almost all dapps rely on logic that is if self sufficient token is sent to/from Asset Hub then the execution fee can be paid in this token. And as I understand that logic is changed now: there must be additional KSM asset in the holding to pay new fees.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This PR is not changing that logic at all. If fee payment is allowed in USDT, which I think is the case in asset hub because it's a sufficient asset, then you can send only that, same with KSM.

@franciscoaguirre
Copy link
Contributor Author

Closing in favor of #3085

@bkchr
Copy link
Member

bkchr commented Jan 29, 2024

@michalisFr can you help here please.

@rageruun
Copy link

can anyone help? Tokens stuck in parachain bridge when transmitted from the Kusama network to the Moonriver (xcKSM) image hash https://kusama.subscan.io/extrinsic/0x37b705c316c4b4b8d552964a130a552e06bad1f55171fca693e4b4e1917dd336?tab=event

@rageruun
Copy link

rageruun commented Jan 29, 2024 via email

@albertov19
Copy link

@rageruun please do not spam this issue.

The Moonbeam is working on indexing all the failed transactions and it will be submitting a governance proposal to help in the cases were assets are being held by the Moonriver owned account in other chains

@rageruun
Copy link

rageruun commented Jan 29, 2024 via email

@michalisFr
Copy link

@michalisFr can you help here please.

@gpestana What could I help with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants