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

Add check before minting empty coins #4681

Merged
merged 4 commits into from
Jul 5, 2019
Merged

Add check before minting empty coins #4681

merged 4 commits into from
Jul 5, 2019

Conversation

fedekunze
Copy link
Collaborator

@fedekunze fedekunze commented Jul 3, 2019

The previous function for inflating the supply on the mint module, InflateSupply wasn't checking for neg amounts, nor 0 amounts. The first is already checked on mint due to the fact that we use NewCoin to initialize the coins from the BlockProvision. This PR fixes the second one where a consensus failure was caused if the minted coins where empty.

Note that this check also exists for the two burn functions in staking/keeper/pool.go.

Fix on Gaia: cosmos/gaia#56

cc: @rigelrozanski @alexanderbez

here's the prev InflateSupply:

// when minting new tokens    
func (k Keeper) InflateSupply(ctx sdk.Context, newTokens sdk.Int) {    
    pool := k.GetPool(ctx)    
    pool.NotBondedTokens = pool.NotBondedTokens.Add(newTokens)    
    k.SetPool(ctx, pool)    
}
  • 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 a relevant changelog entry: clog add [section] [stanza] [message]

  • 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 Jul 3, 2019

Codecov Report

Merging #4681 into master will increase coverage by 0.05%.
The diff coverage is 64.7%.

@@            Coverage Diff             @@
##           master    #4681      +/-   ##
==========================================
+ Coverage   53.99%   54.04%   +0.05%     
==========================================
  Files         271      271              
  Lines       17258    17256       -2     
==========================================
+ Hits         9318     9326       +8     
+ Misses       7255     7251       -4     
+ Partials      685      679       -6

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Added some feedback. Also, I believe this warrants a pending log entry...it's kind of a bug fix.

x/mint/internal/keeper/keeper.go Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK

@alexanderbez alexanderbez merged commit e0b55a8 into master Jul 5, 2019
@alexanderbez alexanderbez deleted the mint-empty branch July 5, 2019 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants