-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R4R: Added bank module's total supply feature #2939
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2939 +/- ##
==========================================
- Coverage 54.83% 51.8% -3.04%
==========================================
Files 133 137 +4
Lines 9559 9702 +143
==========================================
- Hits 5242 5026 -216
- Misses 3996 4343 +347
- Partials 321 333 +12 |
We need to readd the total supply check invariant, but this needs some discussion on the preferred way to do this ( |
SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) | ||
InputOutputCoins(ctx sdk.Context, inputs []Input, outputs []Output) (sdk.Tags, sdk.Error) |
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 don't think we want I/O coins on a SendKeeper
. What was the motivation for moving these methods from Keeper
to SendKeeper
?
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'm not sure why it wouldn't be here. Like SendCoins, InputOutputCoins sends.
Went ahead and merged the first PR to develop and retargeted this; should make review a bit easier. |
Looks like this needs a rebase, happy to review after (if ready)! |
Still needs a rebase (lots of changes with no apparent relation to this PR), still happy to review after. |
@cwgoes all the changes in |
Still some conflicts here. |
bump @sunnya97 |
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.
needs a decent merge of develop.
I don't understand the usage of denom decimals... As far as I understand it decimals of a token should never exist... except for in the situation of decimal coins being created through minting - and those should probably just stay within minting until withdrawn as whole coins? It doesn't really seem reasonable to track those decimal portions within the bank keeper as I would hope that that total supply which includes decimals is really not used in any of the mechanisms of our system besides in minting/distribution. If there is a way we can get around not implementing that, I think it will clean up the code... Also this comment is made more relevant via the Validator Dec->Int PR which should be merged imminently
I have a feeling we need this PR. Are there changes that would be required by F1 here? How do we get this in shape to merge? |
Needs a rebase thanks to #3280, will review after. |
@@ -382,7 +377,7 @@ func (keeper Keeper) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAdd | |||
} | |||
|
|||
// Send coins from depositor's account to DepositedCoinsAccAddr account | |||
_, err := keeper.ck.SendCoins(ctx, depositorAddr, DepositedCoinsAccAddr, depositAmount) | |||
_, _, err := keeper.ck.SubtractCoins(ctx, depositorAddr, depositAmount) |
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 prefer that we have the DepositedCoinsAccAddr... it's weird that a deposit would change an invariant of the total number of coins.
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.
It's also useful to be able to query for the total number of deposited coins, etc.
- calling subtract/add is dangerous... e.g. a bug in this code could result in hyperinflation. The Send method ensures that only a limit is sent.
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 you're concerned about the hash collision, we have bigger problems if there's a hash collision. It's strictly OK to create human-readable addresses, we also bumped up the []byte to 32, so lets make use of that.
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 don't think than an account is not the right place to be storing this data. The sum total of all deposits isn't "an account". One suggestion we had instead was that we could have a function that all keepers expose that allow them to declare how many coins they have under their control. That way we could still have an invariant that checks the total supply is still correct.
AddCoins
and SubtractCoins
can't change the coin's supply, only MintAddCoins
and BurnSubtractCoins
can.
And yeah, not worried about a hash collision, but just the general abstraction here.
@@ -427,7 +422,7 @@ func (keeper Keeper) RefundDeposits(ctx sdk.Context, proposalID uint64) { | |||
deposit := &Deposit{} | |||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), deposit) | |||
|
|||
_, err := keeper.ck.SendCoins(ctx, DepositedCoinsAccAddr, deposit.Depositor, deposit.Amount) | |||
_, _, err := keeper.ck.AddCoins(ctx, deposit.Depositor, deposit.Amount) |
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.
Ditto
@@ -447,7 +442,7 @@ func (keeper Keeper) DeleteDeposits(ctx sdk.Context, proposalID uint64) { | |||
deposit := &Deposit{} | |||
keeper.cdc.MustUnmarshalBinaryLengthPrefixed(depositsIterator.Value(), deposit) | |||
|
|||
_, err := keeper.ck.SendCoins(ctx, DepositedCoinsAccAddr, BurnedDepositCoinsAccAddr, deposit.Amount) | |||
err := keeper.ck.BurnCoins(ctx, deposit.Amount) |
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.
ditto
After discussion with @jaekwon we decided to push this off to post-launch. |
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added entries in
PENDING.md
with issue #rereviewed
Files changed
in the github PR explorerFor Admin Use: