This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix fungible unbalanced trait #12569
Merged
paritytech-processbot
merged 9 commits into
paritytech:master
from
zjb0807:fix-unbalanced-trait
Nov 2, 2022
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e751aff
Fix fungible unbalanced trait
zjb0807 7691522
Add simple decrease_balance test
ggwpez 0accb2f
Fix decrease_balance_at_most
zjb0807 f54544f
Merge branch 'fix-unbalanced-trait' of github.com:zjb0807/substrate i…
zjb0807 45b48de
Fix decrease_balance_at_most in fungibles
zjb0807 e959b42
Rename free_balanceto balance_on_free
zjb0807 ceeb256
Merge remote-tracking branch 'origin/master' into fix-unbalanced-trait
zjb0807 3550a84
Use reducible_balance instead of balance_on_free
zjb0807 94d9e39
Merge remote-tracking branch 'origin/master' into fix-unbalanced-trait
zjb0807 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 assumes that
Unbalanced::set_balance
is always being used with an amount derived fromfree + reserved + amount
. This is incorrect.It would be more correct to separately get/set for both
free
andreserve
within their respective traits. ThenInspectMutate
could have a function for gettingfree + reserve
when it's needed forminimum_balance
/ED requirementsThere 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 trait doesn't really concern itself with "free" and "reserved" - that's a distinction only relevant for the pallet and the
*Hold
traits. I would avoid polluting the base traits with the concern of hold/reserve, as not all that many uses care about them.In short, I think this is a perfectly reasonable fix.
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'd argue that because of the
*Hold
traits, any actions that account forreserve
should only belong to*Hold
traits and that other fungible(s) traits should operate correctly without being concerned withreserve
.Even if this means having
*Hold
traits that overlap some of the functionalities from trait functions that aren't dependent on*Hold
.More plainly,
*Hold
functionality should be an extension of fungible(s) traits and not something at all implemented whiten the regular fungible(s) traits such asMutate
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.
If I'm not mistaken, the purpose of this function is to set the total balance of the supplied account, irrespective of whether the end result is made up of free balances, reserve balances or a mixture of both. The fact that an account previously had held funds should not automatically mean that they suddenly needed to call another function just to modify the total balance -- that would mean users need to keep track of the state of the account in order to call the correct function.
I get the part where it is functionally cleaner if only
*Hold
traits deal with reserve balances, but it is highly inconvenient and an unnecessary distinction from a usability perspective.