-
Notifications
You must be signed in to change notification settings - Fork 2.6k
decouple transaction payment and currency #6912
Conversation
@weichweich it looks like you have not signed our contributor license aggreement yet. Please visit this link to sign our agreement. This pull request cannot be merged until the agrement is signed. |
@weichweich, Your signature has been received. |
Where can I see the multi-currency pallet you want to integrate? Have you considered implementing your own payment pallet for your needs rather than modifying ours? |
It's the token pallet from the ORML.
Yes I considered that, but adjusting your payment pallet was easier, I think. I would rather maintain our changed version of the transaction payment pallet than writing everything from scratch. For us it would just be more convenient to have this as part of substrate and maybe someone wants a more flexible payment pallet too? 😅 But it's also an option to maintain our own version. |
Is it not possible to implement a |
It is possible to implement |
As xlc said, the imbalances make this rather complicated. We also want to be able to pay the transaction fees in different currencies depending on the transaction (e.g. if you transfer a multi-currency, you pay the fees in the same currency). That's why we can't just drop in a currency implementation. We inspect the call and then decide which currency is used to pay the fees. |
I see. Fair enough, then. |
I'm ok with the general direction. Haven't done a deep review of the logic though. |
@weichweich FYI orml-tokens now can implement |
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 think this is almost ready. My only complaint is about naming and documentation on the trait.
improved documentation Co-authored-by: Alexander Theißen <alex.theissen@me.com>
Apply suggestions from code review Co-authored-by: Alexander Theißen <alex.theissen@me.com>
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.
Looks good to me now. You need to create a polkadot companion. If there are errors unrelated to your changes in the gitlab-check-polkadot-companion-build
CI job you may need to merge master in this PR.
if fee.is_zero() { | ||
return Ok(None); | ||
} |
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 is already checked in the call site, but anyways good.
/// Note: The `fee` already includes the `tip`. | ||
fn withdraw_fee( | ||
who: &T::AccountId, | ||
_call: &T::Call, |
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.
why are we passing the call here if it is not used? what is the future proof argument?
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 guess the answer is this:
We also want to be able to pay the transaction fees in different currencies depending on the transaction (e.g. if you transfer a multi-currency, you pay the fees in the same currency). That's why we can't just drop in a currency implementation. We inspect the call and then decide which currency is used to pay the fees.
But honestly I don't get how you can achieve this in your multi-currency runtime. You still have one currency types passed in as C
here. How can you implement something where you deduct from different currencies based on the call?
I am have not worked with such a multi currency pallet yet, so I might be missing some background info here.
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.
We have another implementation of the OnChargeTransaction
Trait. Our implementation doesn't require a Currency
, but a multi currency.
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.
All in all looks good, I just want to see a few questions that I had answered as well.
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
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.
looks good to me
Audit is done, sorry for delay. |
bot merge |
Trying merge. |
* adjustments for substrate PR paritytech/substrate#6912 * Update runtime/kusama/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply suggestions from code review Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * update substrate Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* adjustments for substrate PR paritytech/substrate#6912 * Update runtime/kusama/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply suggestions from code review Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * update substrate Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* adjustments for substrate PR paritytech/substrate#6912 * Update runtime/kusama/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Apply suggestions from code review Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * update substrate Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
polkadot companion: paritytech/polkadot#1784
Hi, we wanted to use the transaction payment pallet with a multi-currency pallet. We therefore needed to remove the Currency dependency from the transaction payment pallet. Is this something that could get merged?
This PR introduces an OnChargeTransaction trait that must be implemented and added to the
pallet_transaction_payment::Trait
. OnChargeTransaction implements how transaction fees are withdrawn and deposited. To keep the original behavior, I implementedOnChargeTransaction
for aCurrencyAdapter
which does the same as the implementation before.These changes would break the API, because all chains need to change the implementation of the
pallet_transaction_payment::Trait
.Before:
After: