Skip to content
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

Closed
wants to merge 24 commits into from

Conversation

sunnya97
Copy link
Member

  • 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 explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented Nov 29, 2018

Codecov Report

Merging #2939 into develop will decrease coverage by 3.03%.
The diff coverage is 37.5%.

@@            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

@sunnya97
Copy link
Member Author

We need to readd the total supply check invariant, but this needs some discussion on the preferred way to do this (GetControlledCoins function on Keepers, Keepers have Accounts, better abstraction in bank, etc).

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)
Copy link
Contributor

@alexanderbez alexanderbez Nov 29, 2018

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?

Copy link
Contributor

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.

@cwgoes cwgoes changed the base branch from cwgoes/bank-spec-code-consistency to develop November 29, 2018 21:56
@cwgoes
Copy link
Contributor

cwgoes commented Nov 29, 2018

Went ahead and merged the first PR to develop and retargeted this; should make review a bit easier.

@cwgoes
Copy link
Contributor

cwgoes commented Dec 5, 2018

Looks like this needs a rebase, happy to review after (if ready)!

@cwgoes
Copy link
Contributor

cwgoes commented Dec 12, 2018

Still needs a rebase (lots of changes with no apparent relation to this PR), still happy to review after.

@sunnya97
Copy link
Member Author

@cwgoes all the changes in Files Changed are intended for this PR. I'll fix merge conflicts though.

@jackzampolin
Copy link
Member

Still some conflicts here.

@alexanderbez
Copy link
Contributor

bump @sunnya97

@sunnya97 sunnya97 changed the title WIP: Added bank module's total supply feature R4R: Added bank module's total supply feature Dec 18, 2018
@alexanderbez
Copy link
Contributor

This has some merge conflicts needing resolution @sunnya97 + this is gonna have merge conflicts with #2996 :-(

Copy link
Contributor

@rigelrozanski rigelrozanski left a 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

@jackzampolin
Copy link
Member

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?

@cwgoes
Copy link
Contributor

cwgoes commented Jan 14, 2019

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)
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@sunnya97
Copy link
Member Author

After discussion with @jaekwon we decided to push this off to post-launch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants