This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
Fix fungible and fungibles set_balance return value #13851
Merged
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 is a bug in the calculation of the return value of the
fungible
andfungibles
set_balance
default implementation.The doc comment says it should return the new balance, but instead it returns
requested_balance +/- balance_change
.I have tests in this PR that show the incorrect return value.
This test
shows
and this test
shows
Luckily (and I guess why this was not caught earlier), I couldn't find anywhere in Substrate or Polkadot that the return value for
set_balance
is used, so unless there is concern about ecosystem projects relying on the incorrect behavior I think this is safe to merge.