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

Turn staking power reduction into an on-chain param #8505

Merged
merged 30 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fec543d
power reduction as on-chain param
xbuidler Jan 26, 2021
4f476d6
on-chain power reduction param conversion basic work
xbuidler Jan 27, 2021
cb17fed
use on-chain params on tests + fix tests + add new tests for power re…
xbuidler Jan 28, 2021
86844b2
comment update
xbuidler Jan 28, 2021
60c6c0a
legacy genesis migration test and feedbacks
xbuidler Feb 1, 2021
7b5cf61
remove dependency between min deposit tokens and power reduction
xbuidler Feb 1, 2021
1c1e67f
Less function to not use default power reduction
xbuidler Feb 2, 2021
5acdc07
reduce power reduction var name
xbuidler Feb 3, 2021
2ce6d4b
increase gas limit for redelegation only
xbuidler Feb 3, 2021
cc4ef50
Merge cosmos-sdk master
xbuidler Feb 3, 2021
0e6b9a6
Merge branch 'master' into issue#8365/staking_power_reduction_chain_p…
xbuidler Feb 3, 2021
7130544
regen staking.pb.go
xbuidler Feb 3, 2021
36bc29a
golang-ci lint
xbuidler Feb 3, 2021
2a43a2d
reduce legacy code
xbuidler Feb 3, 2021
2c1ef71
Merge pull request #65 from psaradev/issue#8365/staking_power_reducti…
sunnya97 Feb 3, 2021
1f99aa3
merged in master
sunnya97 Mar 21, 2021
be27ec1
started fixing merge conflicts
sunnya97 Mar 21, 2021
ca9bfbd
fix merge conflicts
sunnya97 Mar 21, 2021
83efad3
fixing merge conflicts
sunnya97 Mar 21, 2021
b54e276
simply default power reduction definition
sunnya97 Mar 22, 2021
babe920
added CHANGELOG
sunnya97 Mar 22, 2021
05e2e45
merged in master
sunnya97 Apr 6, 2021
ca34808
merged master
sunnya97 Apr 7, 2021
aee3ca8
fix merge conflict
sunnya97 Apr 7, 2021
61b608f
Merge branch 'master' into powerreduction_param
sunnya97 Apr 7, 2021
04e483d
fixed migrations
sunnya97 Apr 7, 2021
8cf5fe0
add nolint to pb.go files
sunnya97 Apr 8, 2021
cd8186e
fix rosetta-test
sunnya97 Apr 9, 2021
10b2b08
Merge branch 'master' into powerreduction_param
sunnya97 Apr 10, 2021
4b778ab
merged master
sunnya97 Apr 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (x/bank) [\#8656](https://github.com/cosmos/cosmos-sdk/pull/8656) balance and supply are now correctly tracked via `coin_spent`, `coin_received`, `coinbase` and `burn` events.
* (x/bank) [\#8517](https://github.com/cosmos/cosmos-sdk/pull/8517) Supply is now stored and tracked as `sdk.Coins`
* (store) [\#8790](https://github.com/cosmos/cosmos-sdk/pull/8790) Reduce gas costs by 10x for transient store operations.
* (x/staking) [\#8505](https://github.com/cosmos/cosmos-sdk/pull/8505) Convert staking power reduction into an on-chain parameter rather than a hardcoded in-code variable.
* (x/bank) [\#9051](https://github.com/cosmos/cosmos-sdk/pull/9051) Supply value is stored as `sdk.Int` rather than `string`.

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion contrib/rosetta/configuration/bootstrap.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"account_identifier": {
"address":"cosmos1tqpwnlx558r36pmf5h8xxct94qcq00h2p5evag"
"address":"cosmos1kezmr2chzy7w00nhh7qxhpqphdwum3j0mgdaw0"
},
"currency":{
"symbol":"stake",
Expand Down
Binary file modified contrib/rosetta/node/data.tar.gz
Binary file not shown.
1 change: 1 addition & 0 deletions docs/core/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -6425,6 +6425,7 @@ Params defines the parameters for the staking module.
| `max_entries` | [uint32](#uint32) | | max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). |
| `historical_entries` | [uint32](#uint32) | | historical_entries is the number of historical entries to persist. |
| `bond_denom` | [string](#string) | | bond_denom defines the bondable coin denomination. |
| `power_reduction` | [string](#string) | | power_reduction is the amount of staking tokens required for 1 unit of consensus-engine power |



Expand Down
6 changes: 6 additions & 0 deletions proto/cosmos/staking/v1beta1/staking.proto
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@ message Params {
uint32 historical_entries = 4 [(gogoproto.moretags) = "yaml:\"historical_entries\""];
// bond_denom defines the bondable coin denomination.
string bond_denom = 5 [(gogoproto.moretags) = "yaml:\"bond_denom\""];
// power_reduction is the amount of staking tokens required for 1 unit of consensus-engine power
string power_reduction = 6 [
(gogoproto.moretags) = "yaml:\"power_reduction\"",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int",
(gogoproto.nullable) = false
];
}

// DelegationResponse is equivalent to Delegation except that it contains a
Expand Down
6 changes: 3 additions & 3 deletions simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ func InitTestnet(
return err
}

accTokens := sdk.TokensFromConsensusPower(1000)
accStakingTokens := sdk.TokensFromConsensusPower(500)
accTokens := sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction)
accStakingTokens := sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction)
coins := sdk.Coins{
sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), accTokens),
sdk.NewCoin(sdk.DefaultBondDenom, accStakingTokens),
Expand All @@ -206,7 +206,7 @@ func InitTestnet(
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))

valTokens := sdk.TokensFromConsensusPower(100)
valTokens := sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction)
createValMsg, err := stakingtypes.NewMsgCreateValidator(
sdk.ValAddress(addr),
valPubKeys[i],
Expand Down
6 changes: 3 additions & 3 deletions testutil/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func DefaultConfig() Config {
NumValidators: 4,
BondDenom: sdk.DefaultBondDenom,
MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom),
AccountTokens: sdk.TokensFromConsensusPower(1000),
StakingTokens: sdk.TokensFromConsensusPower(500),
BondedTokens: sdk.TokensFromConsensusPower(100),
AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction),
StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction),
BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction),
PruningStrategy: storetypes.PruningOptionNothing,
CleanupDir: true,
SigningAlgo: string(hd.Secp256k1Type),
Expand Down
16 changes: 6 additions & 10 deletions types/staking.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
package types

import (
"math/big"
)

// staking constants
const (

Expand All @@ -22,15 +18,15 @@ const (
ValidatorUpdateDelay int64 = 1
)

// PowerReduction is the amount of staking tokens required for 1 unit of consensus-engine power
var PowerReduction = NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(6), nil))
// DefaultPowerReduction is the default amount of staking tokens required for 1 unit of consensus-engine power
var DefaultPowerReduction = NewIntFromUint64(1000000)

// TokensToConsensusPower - convert input tokens to potential consensus-engine power
func TokensToConsensusPower(tokens Int) int64 {
return (tokens.Quo(PowerReduction)).Int64()
func TokensToConsensusPower(tokens Int, powerReduction Int) int64 {
return (tokens.Quo(powerReduction)).Int64()
}

// TokensFromConsensusPower - convert input power to tokens
func TokensFromConsensusPower(power int64) Int {
return NewInt(power).Mul(PowerReduction)
func TokensFromConsensusPower(power int64, powerReduction Int) Int {
return NewInt(power).Mul(powerReduction)
}
4 changes: 2 additions & 2 deletions types/staking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func (s *stakingTestSuite) SetupSuite() {
}

func (s *stakingTestSuite) TestTokensToConsensusPower() {
s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdk.NewInt(999_999)))
s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdk.NewInt(1_000_000)))
s.Require().Equal(int64(0), sdk.TokensToConsensusPower(sdk.NewInt(999_999), sdk.DefaultPowerReduction))
s.Require().Equal(int64(1), sdk.TokensToConsensusPower(sdk.NewInt(1_000_000), sdk.DefaultPowerReduction))
}
4 changes: 2 additions & 2 deletions x/auth/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() {
account, err := val1.ClientCtx.Keyring.Key("newAccount")
s.Require().NoError(err)

sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10))
sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction))

normalGeneratedTx, err := s.createBankMsg(val1, account.GetAddress(),
sdk.NewCoins(sendTokens), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly))
Expand Down Expand Up @@ -528,7 +528,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignInsufficientCosigners() {
func (s *IntegrationTestSuite) TestCLIEncode() {
val1 := s.network.Validators[0]

sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10))
sendTokens := sdk.NewCoin(s.cfg.BondDenom, sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction))

normalGeneratedTx, err := s.createBankMsg(
val1, val1.Address,
Expand Down
2 changes: 1 addition & 1 deletion x/auth/legacy/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ func dirtyTrackingFields(ctx sdk.Context, vesting exported.VestingAccount, app *
}

func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers int64) (sdk.AccAddress, sdk.ValAddress) {
valTokens := sdk.TokensFromConsensusPower(powers)
valTokens := sdk.TokensFromConsensusPower(powers, sdk.DefaultPowerReduction)
addrs := simapp.AddTestAddrsIncremental(app, ctx, 1, valTokens)
valAddrs := simapp.ConvertAddrsToValAddrs(addrs)
pks := simapp.CreateTestPubKeys(1)
Expand Down
6 changes: 3 additions & 3 deletions x/authz/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (suite *SimTestSuite) TestWeightedOperations() {
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)

initAmt := sdk.TokensFromConsensusPower(200000)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200000)
initCoins := sdk.NewCoins(sdk.NewCoin("foo", initAmt))

// add coins to the accounts
Expand Down Expand Up @@ -132,7 +132,7 @@ func (suite *SimTestSuite) TestSimulateRevokeAuthorization() {
AppHash: suite.app.LastCommitID().Hash,
}})

initAmt := sdk.TokensFromConsensusPower(200000)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200000)
initCoins := sdk.NewCoins(sdk.NewCoin("foo", initAmt))

granter := accounts[0]
Expand Down Expand Up @@ -167,7 +167,7 @@ func (suite *SimTestSuite) TestSimulateExecAuthorization() {
// begin a new block
suite.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}})

initAmt := sdk.TokensFromConsensusPower(200000)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200000)
initCoins := sdk.NewCoins(sdk.NewCoin("foo", initAmt))

granter := accounts[0]
Expand Down
3 changes: 2 additions & 1 deletion x/bank/client/rest/tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/cosmos/cosmos-sdk/testutil/network"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx"
Expand All @@ -23,7 +24,7 @@ func (s *IntegrationTestSuite) TestCoinSend() {

sendReq := generateSendReq(
account,
types.Coins{types.NewCoin(s.cfg.BondDenom, types.TokensFromConsensusPower(1))},
types.Coins{types.NewCoin(s.cfg.BondDenom, types.TokensFromConsensusPower(1, sdk.DefaultPowerReduction))},
)

stdTx, err := submitSendReq(val, sendReq)
Expand Down
5 changes: 3 additions & 2 deletions x/bank/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ var (
multiPermAcc = authtypes.NewEmptyModuleAccount(multiPerm, authtypes.Burner, authtypes.Minter, authtypes.Staking)
randomPermAcc = authtypes.NewEmptyModuleAccount(randomPerm, "random")

initTokens = sdk.TokensFromConsensusPower(initialPower)
// The default power validators are initialized to have within tests
initTokens = sdk.TokensFromConsensusPower(initialPower, sdk.DefaultPowerReduction)
initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens))
)

Expand Down Expand Up @@ -91,7 +92,7 @@ func (suite *IntegrationTestSuite) TestSupply() {
app, ctx := suite.app, suite.ctx

initialPower := int64(100)
initTokens := sdk.TokensFromConsensusPower(initialPower)
initTokens := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, initialPower)

totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens))
suite.NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, totalSupply))
Expand Down
2 changes: 1 addition & 1 deletion x/bank/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() {
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)

initAmt := sdk.TokensFromConsensusPower(200)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200)
initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))

// add coins to the accounts
Expand Down
4 changes: 2 additions & 2 deletions x/bank/types/balance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestBalance_GetAddress(t *testing.T) {

func TestSanitizeBalances(t *testing.T) {
// 1. Generate balances
tokens := sdk.TokensFromConsensusPower(81)
tokens := sdk.TokensFromConsensusPower(81, sdk.DefaultPowerReduction)
coin := sdk.NewCoin("benchcoin", tokens)
coins := sdk.Coins{coin}
addrs, _ := makeRandomAddressesAndPublicKeys(20)
Expand Down Expand Up @@ -158,7 +158,7 @@ func BenchmarkSanitizeBalances1000(b *testing.B) {

func benchmarkSanitizeBalances(b *testing.B, nAddresses int) {
b.ReportAllocs()
tokens := sdk.TokensFromConsensusPower(81)
tokens := sdk.TokensFromConsensusPower(81, sdk.DefaultPowerReduction)
coin := sdk.NewCoin("benchcoin", tokens)
coins := sdk.Coins{coin}
addrs, _ := makeRandomAddressesAndPublicKeys(nAddresses)
Expand Down
14 changes: 7 additions & 7 deletions x/distribution/keeper/delegation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) {
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down Expand Up @@ -175,7 +175,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) {
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down Expand Up @@ -269,11 +269,11 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) {
}

func TestWithdrawDelegationRewardsBasic(t *testing.T) {
balancePower := int64(1000)
balanceTokens := sdk.TokensFromConsensusPower(balancePower)
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})

balancePower := int64(1000)
balanceTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, balancePower)
addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestWithdrawDelegationRewardsBasic(t *testing.T) {
val := app.StakingKeeper.Validator(ctx, valAddrs[0])

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10)
tokens := sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, initial)}

app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
Expand Down Expand Up @@ -375,7 +375,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)

// allocate some rewards
initial := sdk.TokensFromConsensusPower(10).ToDec()
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec()
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down Expand Up @@ -431,7 +431,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
del1 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])

// allocate some rewards
initial := sdk.TokensFromConsensusPower(30).ToDec()
initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 30).ToDec()
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)

Expand Down
2 changes: 1 addition & 1 deletion x/distribution/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestWithdrawValidatorCommission(t *testing.T) {

// check initial balance
balance := app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddrs[0]))
expTokens := sdk.TokensFromConsensusPower(1000)
expTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 1000)
expCoins := sdk.NewCoins(sdk.NewCoin("stake", expTokens))
require.Equal(t, expCoins, balance)

Expand Down
4 changes: 2 additions & 2 deletions x/distribution/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() {
validator0 := suite.getTestingValidator0(accounts)

// setup delegation
delTokens := sdk.TokensFromConsensusPower(2)
delTokens := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 2)
validator0, issuedShares := validator0.AddTokensFromDel(delTokens)
delegator := accounts[1]
delegation := stakingtypes.NewDelegation(delegator.Address, validator0.GetOperator(), issuedShares)
Expand Down Expand Up @@ -222,7 +222,7 @@ func (suite *SimTestSuite) SetupTest() {
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)

initAmt := sdk.TokensFromConsensusPower(200)
initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200)
initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))

// add coins to the accounts
Expand Down
3 changes: 2 additions & 1 deletion x/evidence/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ var (
sdk.ValAddress(pubkeys[2].Address()),
}

initAmt = sdk.TokensFromConsensusPower(200)
// The default power validators are initialized to have within tests
initAmt = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
initCoins = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))
)

Expand Down
4 changes: 2 additions & 2 deletions x/feegrant/simulation/operations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func (suite *SimTestSuite) SetupTest() {
func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account {
accounts := simtypes.RandomAccounts(r, n)

initAmt := sdk.TokensFromConsensusPower(200)
initAmt := sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction)
initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initAmt))

// add coins to the accounts
Expand Down Expand Up @@ -134,7 +134,7 @@ func (suite *SimTestSuite) TestSimulateMsgRevokeFeeAllowance() {
// begin a new block
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash}})

feeAmt := sdk.TokensFromConsensusPower(200000)
feeAmt := app.StakingKeeper.TokensFromConsensusPower(ctx, 200000)
feeCoins := sdk.NewCoins(sdk.NewCoin("foo", feeAmt))

granter, grantee := accounts[0], accounts[1]
Expand Down
6 changes: 3 additions & 3 deletions x/gov/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func TestTickPassedVotingPeriod(t *testing.T) {
require.False(t, activeQueue.Valid())
activeQueue.Close()

proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(5))}
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 5))}
newProposalMsg, err := types.NewMsgSubmitProposal(TestProposal, proposalCoins, addrs[0])
require.NoError(t, err)

Expand Down Expand Up @@ -295,7 +295,7 @@ func TestProposalPassedEndblocker(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, TestProposal)
require.NoError(t, err)

proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(10))}
proposalCoins := sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))}
newDepositMsg := types.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)

handleAndCheck(t, handler, ctx, newDepositMsg)
Expand Down Expand Up @@ -343,7 +343,7 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) {
proposal, err := app.GovKeeper.SubmitProposal(ctx, TestProposal)
require.NoError(t, err)

proposalCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(10)))
proposalCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10)))
newDepositMsg := types.NewMsgDeposit(addrs[0], proposal.ProposalId, proposalCoins)

handleAndCheck(t, gov.NewHandler(app.GovKeeper), ctx, newDepositMsg)
Expand Down
4 changes: 2 additions & 2 deletions x/gov/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

var (
valTokens = sdk.TokensFromConsensusPower(42)
valTokens = sdk.TokensFromConsensusPower(42, sdk.DefaultPowerReduction)
TestProposal = types.NewTextProposal("Test", "description")
TestDescription = stakingtypes.NewDescription("T", "E", "S", "T", "Z")
TestCommissionRates = stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec())
Expand Down Expand Up @@ -82,7 +82,7 @@ func createValidators(t *testing.T, stakingHandler sdk.Handler, ctx sdk.Context,
require.True(t, len(addrs) <= len(pubkeys), "Not enough pubkeys specified at top of file.")

for i := 0; i < len(addrs); i++ {
valTokens := sdk.TokensFromConsensusPower(powerAmt[i])
valTokens := sdk.TokensFromConsensusPower(powerAmt[i], sdk.DefaultPowerReduction)
valCreateMsg, err := stakingtypes.NewMsgCreateValidator(
addrs[i], pubkeys[i], sdk.NewCoin(sdk.DefaultBondDenom, valTokens),
TestDescription, TestCommissionRates, sdk.OneInt(),
Expand Down
Loading