Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix transaction payment fee/tip unbalanceds #8860

Merged
merged 2 commits into from
May 19, 2021

Conversation

gui1117
Copy link
Contributor

@gui1117 gui1117 commented May 19, 2021

Fix #8854

contrary to the doc, the on unbalanced handler is given the tip first and then the fee. This PR fix it, and test it.

@github-actions github-actions bot added the A0-please_review Pull request needs code review. label May 19, 2021
@gui1117 gui1117 added B3-apinoteworthy C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels May 19, 2021
Comment on lines +727 to +730
impl OnUnbalanced<pallet_balances::NegativeImbalance<Runtime>> for DealWithFees {
fn on_unbalanceds<B>(
mut fees_then_tips: impl Iterator<Item=pallet_balances::NegativeImbalance<Runtime>>
) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we not make this "smarter", aka better.

trait OnUnbalanced<V, R> where R: IntoIterator<Item=V> {
     fn on_unbalanceds<B>(whatever: R) {}
}

So we could have:

struct TransactionPayment {
    pub fees,
    pub tips,
}

Than we could in DealWithFees directly use this struct? While others could still use the generic approach with the iterator?

Do you understand what I want to do? :D

Copy link
Member

Choose a reason for hiding this comment

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

And R would be TransactionPayment

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, good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gavofyork
Copy link
Member

Merging for now since it's an important one. Can refactor in a second PR.

@gavofyork gavofyork merged commit 0bda865 into master May 19, 2021
@gavofyork gavofyork deleted the gui-fix-transaction-payment-fee-tip-split branch May 19, 2021 16:44
sorpaas added a commit to neatcoin/neatcoin that referenced this pull request May 20, 2021
nazar-pc pushed a commit to autonomys/substrate that referenced this pull request Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect ordering of fees and tips in Transaction Payment
3 participants