Skip to content

Commit c0eec30

Browse files
rigelrozanskicwgoes
authored andcommitted
Merge PR #3654: x/mint now uses total supply instead of bonded supply
1 parent 8371095 commit c0eec30

File tree

8 files changed

+17
-10
lines changed

8 files changed

+17
-10
lines changed

PENDING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,6 @@ BUG FIXES
6363
* Gaia
6464

6565
* SDK
66+
* \#3646 `x/mint` now uses total token supply instead of total bonded tokens to calculate inflation
6667

6768
* Tendermint

types/stake.go renamed to types/staking.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ type ValidatorSet interface {
100100

101101
Validator(Context, ValAddress) Validator // get a particular validator by operator address
102102
ValidatorByConsAddr(Context, ConsAddress) Validator // get a particular validator by consensus address
103-
TotalPower(Context) Int // total power of the validator set
103+
TotalBondedTokens(Context) Int // total bonded tokens within the validator set
104+
TotalTokens(Context) Int // total token supply
104105

105106
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
106107
Slash(Context, ConsAddress, int64, int64, Dec)

x/distribution/types/expected_keepers.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ type StakingKeeper interface {
99
Delegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation
1010
Validator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Validator
1111
ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) sdk.Validator
12-
TotalPower(ctx sdk.Context) sdk.Int
1312
GetLastTotalPower(ctx sdk.Context) sdk.Int
1413
GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64
1514

x/gov/tally.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ func tally(ctx sdk.Context, keeper Keeper, proposal Proposal) (passes bool, tall
103103

104104
// TODO: Upgrade the spec to cover all of these cases & remove pseudocode.
105105
// If there is no staked coins, the proposal fails
106-
if keeper.vs.TotalPower(ctx).IsZero() {
106+
if keeper.vs.TotalBondedTokens(ctx).IsZero() {
107107
return false, tallyResults
108108
}
109109
// If there is not enough quorum of votes, the proposal fails
110-
percentVoting := totalVotingPower.Quo(sdk.NewDecFromInt(keeper.vs.TotalPower(ctx)))
110+
percentVoting := totalVotingPower.Quo(sdk.NewDecFromInt(keeper.vs.TotalBondedTokens(ctx)))
111111
if percentVoting.LT(tallyParams.Quorum) {
112112
return false, tallyResults
113113
}

x/mint/abci_app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ func BeginBlocker(ctx sdk.Context, k Keeper) {
1212
params := k.GetParams(ctx)
1313

1414
// recalculate inflation rate
15-
totalSupply := k.sk.TotalPower(ctx)
15+
totalSupply := k.sk.TotalTokens(ctx)
1616
bondedRatio := k.sk.BondedRatio(ctx)
1717
minter.Inflation = minter.NextInflationRate(params, bondedRatio)
1818
minter.AnnualProvisions = minter.NextAnnualProvisions(params, totalSupply)

x/mint/expected_keepers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66

77
// expected staking keeper
88
type StakingKeeper interface {
9-
TotalPower(ctx sdk.Context) sdk.Int
9+
TotalTokens(ctx sdk.Context) sdk.Int
1010
BondedRatio(ctx sdk.Context) sdk.Dec
1111
InflateSupply(ctx sdk.Context, newTokens sdk.Int)
1212
}

x/staking/keeper/alias_functions.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ func (k Keeper) ValidatorByConsAddr(ctx sdk.Context, addr sdk.ConsAddress) sdk.V
8787
return val
8888
}
8989

90-
// total power from the bond (not last, but current)
91-
func (k Keeper) TotalPower(ctx sdk.Context) sdk.Int {
90+
// total staking tokens supply which is bonded
91+
func (k Keeper) TotalBondedTokens(ctx sdk.Context) sdk.Int {
9292
pool := k.GetPool(ctx)
9393
return pool.BondedTokens
9494
}
9595

96-
// total power from the bond
96+
// total staking tokens supply bonded and unbonded
97+
func (k Keeper) TotalTokens(ctx sdk.Context) sdk.Int {
98+
pool := k.GetPool(ctx)
99+
return pool.TokenSupply()
100+
}
101+
102+
// the fraction of the staking tokens which are currently bonded
97103
func (k Keeper) BondedRatio(ctx sdk.Context) sdk.Dec {
98104
pool := k.GetPool(ctx)
99105
return pool.BondedRatio()

x/staking/types/validator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func (v Validator) BondedTokens() sdk.Int {
416416
}
417417

418418
// get the Tendermint Power
419-
// a reduction of 10^9 from validator tokens is applied
419+
// a reduction of 10^6 from validator tokens is applied
420420
func (v Validator) TendermintPower() int64 {
421421
if v.Status == sdk.Bonded {
422422
return v.PotentialTendermintPower()

0 commit comments

Comments
 (0)