Skip to content

Integrate token swap pallet into Millau runtime#1099

Merged
svyatonik merged 2 commits intomasterfrom
integrate-token-swap-pallet-into-millau-runtime
Sep 15, 2021
Merged

Integrate token swap pallet into Millau runtime#1099
svyatonik merged 2 commits intomasterfrom
integrate-token-swap-pallet-into-millau-runtime

Conversation

@svyatonik
Copy link
Copy Markdown
Contributor

on top of #1087

This still needs to be tested (=> another relay-related PR), so it'll be in draft state for some time. Opening it to not to lose this work somewhere among my local 363 branches.

@svyatonik svyatonik force-pushed the integrate-token-swap-pallet-into-millau-runtime branch from 289ee1b to fb3ea9f Compare September 13, 2021 08:21
origin: OriginFor<T>,
swap: TokenSwapOf<T, I>,
target_public_at_bridged_chain: BridgedAccountPublicOf<T, I>,
swap_delivery_and_dispatch_fee: ThisChainBalance<T, I>,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you elaborate on why the fee is now being declared by the user? What happens if too low value is declared (I'm assuming the message lane pallet should reject that, right?)
Is there so much variation in the possible fees or is it there to make sure users can pay an extra "tip"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TBH I was not thinking about extra "tip" - it's just the inconsistency I've met between ability to specify message dispatch weight (#944 (comment)) and the fact that message fee is now 'hardcoded' in token-swap pallet (

type MessageDeliveryAndDispatchFee: Get<<Self::ThisCurrency as Currency<Self::AccountId>>::Balance>;
). So I've made signature of this method to look like usual send_message call of the messages pallet, where use can specify both message weight and fee. Could remove it and change MessageDeliveryAndDispatchFee() -> Balance to something like MessageDeliveryAndDispatchFee(DispatchWeight, Size) -> Balance if you think it's better.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My initial idea was for the token swap pallet to be "simpler to use", i.e. not requiring sophisticated UI logic to estimate the costs, but rather have the pallet do that for you. That said, I'm fine to start with this API and let's see how it evolves.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, let's replace it with MessageDeliveryAndDispatchFee(DispatchWeight, Size) -> Balance

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

On second thought I think it is better to keep this as an external argument. I've recently seen an issue (#1138) where actual conversion rate has been larger than the rate that is stored within the runtime. So I'm proposing (apart from fixing pauses described in #1138) to add RPC call that estimates 'rational' message delivery and dispatch fee - e.g. you'll call it with custom conversion rate (which you may compute from offchain data) and it'll use max(external_conversion_rate, stored_conversion_rate). If we'll remove this argument, then some messages may stuck (because we'll fail to update rate on time). We have a solution for stuck messages (increase_message_fee or altruistic relayers), but better not to use it.

@svyatonik svyatonik marked this pull request as ready for review September 15, 2021 11:50
@svyatonik svyatonik merged commit 5d03a20 into master Sep 15, 2021
@svyatonik svyatonik deleted the integrate-token-swap-pallet-into-millau-runtime branch September 15, 2021 12:08
svyatonik pushed a commit that referenced this pull request Jul 17, 2023
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Mar 27, 2024
* integrate token swap pallet into Millau runtime

* set OnDeliveryConfirmed callback in Millau runtime
serban300 pushed a commit to serban300/parity-bridges-common that referenced this pull request Apr 8, 2024
* integrate token swap pallet into Millau runtime

* set OnDeliveryConfirmed callback in Millau runtime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants