cosmos-sdk/x/distribution/keeper/delegation_test.go

628 lines
23 KiB
Go
Raw Normal View History

package keeper_test
2018-10-04 18:37:40 -07:00
2018-10-09 10:58:59 -07:00
import (
"testing"
2020-03-20 10:14:14 -07:00
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
2020-03-20 10:14:14 -07:00
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
2019-01-11 12:08:01 -08:00
"github.com/cosmos/cosmos-sdk/x/staking"
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
2018-10-09 10:58:59 -07:00
)
2018-10-04 18:37:40 -07:00
2019-01-16 13:38:05 -08:00
func TestCalculateRewardsBasic(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
2019-01-16 13:38:05 -08:00
// end block to bond validator and start new block
staking.EndBlocker(ctx, app.StakingKeeper)
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
tstaking.Ctx = ctx
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
del := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// historical count should be 2 (once for validator init, once for delegation init)
require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))
2019-01-16 13:38:05 -08:00
// end period
endingPeriod := app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// historical count should be 2 still
require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards := app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be zero
require.True(t, rewards.IsZero())
// allocate some rewards
initial := int64(10)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial)}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod = app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be half the tokens
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be the other half
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission)
2018-10-10 23:14:06 -07:00
}
2019-01-16 13:38:05 -08:00
func TestCalculateRewardsAfterSlash(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
valPower := int64(100)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
2019-01-16 13:38:05 -08:00
// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
del := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// end period
endingPeriod := app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards := app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be zero
require.True(t, rewards.IsZero())
// start out block height
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// slash the validator by 50%
app.StakingKeeper.Slash(ctx, valConsAddr1, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
2019-01-16 13:38:05 -08:00
// retrieve validator
val = app.StakingKeeper.Validator(ctx, valAddrs[0])
2019-01-16 13:38:05 -08:00
// increase block height
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod = app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be half the tokens
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoRaw(2).ToDec()}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be the other half
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoRaw(2).ToDec()}},
app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission)
2018-10-04 18:37:40 -07:00
}
2019-01-16 13:38:05 -08:00
func TestCalculateRewardsAfterManySlashes(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
valPower := int64(100)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
2019-01-16 13:38:05 -08:00
// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
del := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// end period
endingPeriod := app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards := app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be zero
require.True(t, rewards.IsZero())
// start out block height
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// slash the validator by 50%
app.StakingKeeper.Slash(ctx, valConsAddr1, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
2019-01-16 13:38:05 -08:00
// fetch the validator again
val = app.StakingKeeper.Validator(ctx, valAddrs[0])
2019-01-16 13:38:05 -08:00
// increase block height
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// slash the validator by 50% again
app.StakingKeeper.Slash(ctx, valConsAddr1, ctx.BlockHeight(), valPower/2, sdk.NewDecWithPrec(5, 1))
2019-01-16 13:38:05 -08:00
// fetch the validator again
val = app.StakingKeeper.Validator(ctx, valAddrs[0])
2019-01-16 13:38:05 -08:00
// increase block height
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// allocate some more rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod = app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be half the tokens
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be the other half
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}},
app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission)
}
2019-01-16 13:38:05 -08:00
func TestCalculateRewardsMultiDelegator(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(100000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
2019-01-16 13:38:05 -08:00
// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
del1 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// allocate some rewards
initial := int64(20)
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial)}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// second delegation
tstaking.Ctx = ctx
tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdk.NewInt(100))
del2 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[1]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// fetch updated validator
val = app.StakingKeeper.Validator(ctx, valAddrs[0])
2019-01-16 13:38:05 -08:00
// end block
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// allocate some more rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod := app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del1
rewards := app.DistrKeeper.CalculateDelegationRewards(ctx, val, del1, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del1 should be 3/4 initial
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial * 3 / 4)}}, rewards)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del2
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del2, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del2 should be 1/4 initial
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial * 1 / 4)}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be equal to initial (50% twice)
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial)}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission)
2018-10-04 18:37:40 -07:00
}
2019-01-16 13:38:05 -08:00
func TestWithdrawDelegationRewardsBasic(t *testing.T) {
balancePower := int64(1000)
balanceTokens := sdk.TokensFromConsensusPower(balancePower)
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
2019-06-28 13:11:27 -07:00
// set module account coins
distrAcc := app.DistrKeeper.GetDistributionAccount(ctx)
[Bank] Remove the unsafe balance changing API (#8473) * temp commit * setbalance now is internal * remove set balances in genesis * feedback test commit * update tests * fix: genesis panic message * fix not bonded pool * fix(staking): genesis test * fix(simapp): rollback state fix change * fix(staking): genesis large val set test * [Bank Refactor] Frojdi jonathan/remove setsupply (#8491) * init supply in a different way * remove external usage of set supply * change(staking): replace SetSupply with MintCoins in tests * change(evidence): replace SetSupply with MintCoins in tests * change(crisis): remove SetSupply in tests * change(bank): remove set supply from genesis tests * change(bank): remove set supply from keeper tests * change(bank): remove remaining set supply usage from keeper tests * change(bank): remove set supply usage from grpc query and querier tests * change(bank): remove SetSupply from keeper interface Co-authored-by: Frojdi Dymylja <frojdi.dymylja@gmail.com> * remove setbalances from genesis in gov * remove keyring * add init genesis state * change(staking): make genesis checks coherent and add tests * remove setbalances on distribution * fix(staking): genesis tests * [Bank Refactor]: Remove SetBalances usage from the code and tests (#8509) * change(distribution): remove SetBalances usage from keeper tests * add(simapp): FundAccount utility function * chore(staking): use FundAccount in keeper tests * change(staking): remove usage of SetBalance in allocation tests * change(staking): remove usage of SetBalance in delegation tests * change(staking): remove usage of SetBalance in proposal handler tests * change(staking): remove usage of SetBalances in grpc query tests * change(staking): remove usage of SetBalances in operations tests * change(distribution): remove usage of SetBalances in genesis * change(authz): remove usage of SetBalances keeper and operations test * fix(authz): TestKeeperFees failing test * change(slashing): remove SetBalances from expected BankKeeper * change(slashing): remove usage of SetBalances in tests * change(distribution): remove SetBalances from expected BankKeeper * change(genutil): remove usage of SetBalances from tests * change(gov): remove SetBalances from expected BankKeeper * change(gov): remove usage of SetBalances from tests * change(staking): remove usage of SetBalances from slash tests * change(staking): remove SetBalances from expected BankKeeper * change(staking): remove usage of SetBalances from delegation tests * change(staking): remove usage of SetBalances from operations tests * change(staking): remove usage of SetBalances from validator tests * change(bank): remove usage of SetBalances from app tests * change(bank): remove usage of SetBalances from bench tests * change(bank): remove usage of SetBalances from querier tests * change(bank): remove usage of SetBalances from grpc query tests * change(bank): remove usage of SetBalances from operations tests * change(bank): partially remove usage of SetBalances from keeper tests * change(bank): finalize removal of usage of SetBalances from keeper tests * change(auth): remove usage of SetBalances from verify tests * change(auth): partially remove usage of SetBalances from tests * [Bank refactor]: finalize removal of setbalances from auth (#8527) * add tests with is check tx * temp commit * fix test * fix other test and remove setbalances * change(auth): remove usage of SetBalances is vesting tests Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> * change(types): remove usage of SetBalances in queries * fix(types): pagination tests * [Bank refactor] fix pagination tests (#8550) * fix tests * lint * change(bank): remove SetBalances from keeper public API Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> * change(bank): remove SubtractCoins from keeper public API * change(ibc/transfer): remove AddCoins from relay tests * change(bank): remove AddCoins from public keeper API * fix imports * remove set balances * fix fee test * remove set balances * fix(staking): remove dependency on minter authorization for staking pools * chore: update CHANGELOG.md * update: x/distribution/keeper/keeper_test.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update simapp/test_helpers.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update x/staking/genesis_test.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * fix(simapp): FundAccount amount variable name * fix some PR issues Co-authored-by: Frojdi Dymylja <frojdi.dymylja@gmail.com> Co-authored-by: Frojdi Dymylja <33157909+fdymylja@users.noreply.github.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-02-17 10:20:33 -08:00
require.NoError(t, simapp.FundAccount(app, ctx, distrAcc.GetAddress(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, balanceTokens))))
app.AccountKeeper.SetModuleAccount(ctx, distrAcc)
2019-06-28 13:11:27 -07:00
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
power := int64(100)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
valTokens := tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, power, true)
2019-01-16 13:38:05 -08:00
// assert correct initial balance
expTokens := balanceTokens.Sub(valTokens)
require.Equal(t,
sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, expTokens)},
app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddrs[0])),
)
2019-01-16 13:38:05 -08:00
// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
2019-01-16 13:38:05 -08:00
// allocate some rewards
initial := sdk.TokensFromConsensusPower(10)
tokens := sdk.DecCoins{sdk.NewDecCoin(sdk.DefaultBondDenom, initial)}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// historical count should be 2 (initial + latest for delegation)
require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))
2019-01-16 13:38:05 -08:00
// withdraw rewards
_, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
require.Nil(t, err)
2019-01-16 13:38:05 -08:00
// historical count should still be 2 (added one record, cleared one)
require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))
2019-01-16 13:38:05 -08:00
// assert correct balance
exp := balanceTokens.Sub(valTokens).Add(initial.QuoRaw(2))
require.Equal(t,
sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, exp)},
app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddrs[0])),
)
2019-01-16 13:38:05 -08:00
// withdraw commission
_, err = app.DistrKeeper.WithdrawValidatorCommission(ctx, valAddrs[0])
require.Nil(t, err)
2019-01-16 13:38:05 -08:00
// assert correct balance
exp = balanceTokens.Sub(valTokens).Add(initial)
require.Equal(t,
sdk.Coins{sdk.NewCoin(sdk.DefaultBondDenom, exp)},
app.BankKeeper.GetAllBalances(ctx, sdk.AccAddress(valAddrs[0])),
)
2019-01-16 13:38:05 -08:00
}
func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
addr := simapp.AddTestAddrs(app, ctx, 1, sdk.NewInt(1000000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
valPower := int64(100)
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
2019-01-16 13:38:05 -08:00
// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
del := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// end period
endingPeriod := app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards := app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be zero
require.True(t, rewards.IsZero())
// start out block height
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// allocate some rewards
initial := sdk.TokensFromConsensusPower(10).ToDec()
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// slash the validator by 50%
app.StakingKeeper.Slash(ctx, valConsAddr1, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
2019-01-16 13:38:05 -08:00
// slash the validator by 50% again
app.StakingKeeper.Slash(ctx, valConsAddr1, ctx.BlockHeight(), valPower/2, sdk.NewDecWithPrec(5, 1))
2019-01-16 13:38:05 -08:00
// fetch the validator again
val = app.StakingKeeper.Validator(ctx, valAddrs[0])
2019-01-16 13:38:05 -08:00
// increase block height
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// allocate some more rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod = app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards should be half the tokens
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be the other half
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission)
2019-01-16 13:38:05 -08:00
}
func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
valPower := int64(100)
tstaking.CreateValidatorWithValPower(valAddrs[0], valConsPk1, valPower, true)
2019-01-16 13:38:05 -08:00
// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
del1 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// allocate some rewards
initial := sdk.TokensFromConsensusPower(30).ToDec()
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// slash the validator
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
app.StakingKeeper.Slash(ctx, valConsAddr1, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
2019-01-16 13:38:05 -08:00
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// second delegation
tstaking.DelegateWithPower(sdk.AccAddress(valAddrs[1]), valAddrs[0], 100)
del2 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[1]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// end block
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// allocate some more rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// slash the validator again
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
app.StakingKeeper.Slash(ctx, valConsAddr1, ctx.BlockHeight(), valPower, sdk.NewDecWithPrec(5, 1))
2019-01-16 13:38:05 -08:00
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3)
// fetch updated validator
val = app.StakingKeeper.Validator(ctx, valAddrs[0])
2019-01-16 13:38:05 -08:00
// end period
endingPeriod := app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del1
rewards := app.DistrKeeper.CalculateDelegationRewards(ctx, val, del1, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del1 should be 2/3 initial (half initial first period, 1/6 initial second period)
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoInt64(2).Add(initial.QuoInt64(6))}}, rewards)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del2
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del2, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del2 should be initial / 3
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoInt64(3)}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be equal to initial (twice 50% commission, unaffected by slashing)
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission)
2019-01-16 13:38:05 -08:00
}
func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) {
app := simapp.Setup(false)
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
tstaking := teststaking.NewHelper(t, ctx, app.StakingKeeper)
addr := simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000))
valAddrs := simapp.ConvertAddrsToValAddrs(addr)
initial := int64(20)
2019-06-28 13:11:27 -07:00
// set module account coins
distrAcc := app.DistrKeeper.GetDistributionAccount(ctx)
[Bank] Remove the unsafe balance changing API (#8473) * temp commit * setbalance now is internal * remove set balances in genesis * feedback test commit * update tests * fix: genesis panic message * fix not bonded pool * fix(staking): genesis test * fix(simapp): rollback state fix change * fix(staking): genesis large val set test * [Bank Refactor] Frojdi jonathan/remove setsupply (#8491) * init supply in a different way * remove external usage of set supply * change(staking): replace SetSupply with MintCoins in tests * change(evidence): replace SetSupply with MintCoins in tests * change(crisis): remove SetSupply in tests * change(bank): remove set supply from genesis tests * change(bank): remove set supply from keeper tests * change(bank): remove remaining set supply usage from keeper tests * change(bank): remove set supply usage from grpc query and querier tests * change(bank): remove SetSupply from keeper interface Co-authored-by: Frojdi Dymylja <frojdi.dymylja@gmail.com> * remove setbalances from genesis in gov * remove keyring * add init genesis state * change(staking): make genesis checks coherent and add tests * remove setbalances on distribution * fix(staking): genesis tests * [Bank Refactor]: Remove SetBalances usage from the code and tests (#8509) * change(distribution): remove SetBalances usage from keeper tests * add(simapp): FundAccount utility function * chore(staking): use FundAccount in keeper tests * change(staking): remove usage of SetBalance in allocation tests * change(staking): remove usage of SetBalance in delegation tests * change(staking): remove usage of SetBalance in proposal handler tests * change(staking): remove usage of SetBalances in grpc query tests * change(staking): remove usage of SetBalances in operations tests * change(distribution): remove usage of SetBalances in genesis * change(authz): remove usage of SetBalances keeper and operations test * fix(authz): TestKeeperFees failing test * change(slashing): remove SetBalances from expected BankKeeper * change(slashing): remove usage of SetBalances in tests * change(distribution): remove SetBalances from expected BankKeeper * change(genutil): remove usage of SetBalances from tests * change(gov): remove SetBalances from expected BankKeeper * change(gov): remove usage of SetBalances from tests * change(staking): remove usage of SetBalances from slash tests * change(staking): remove SetBalances from expected BankKeeper * change(staking): remove usage of SetBalances from delegation tests * change(staking): remove usage of SetBalances from operations tests * change(staking): remove usage of SetBalances from validator tests * change(bank): remove usage of SetBalances from app tests * change(bank): remove usage of SetBalances from bench tests * change(bank): remove usage of SetBalances from querier tests * change(bank): remove usage of SetBalances from grpc query tests * change(bank): remove usage of SetBalances from operations tests * change(bank): partially remove usage of SetBalances from keeper tests * change(bank): finalize removal of usage of SetBalances from keeper tests * change(auth): remove usage of SetBalances from verify tests * change(auth): partially remove usage of SetBalances from tests * [Bank refactor]: finalize removal of setbalances from auth (#8527) * add tests with is check tx * temp commit * fix test * fix other test and remove setbalances * change(auth): remove usage of SetBalances is vesting tests Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> * change(types): remove usage of SetBalances in queries * fix(types): pagination tests * [Bank refactor] fix pagination tests (#8550) * fix tests * lint * change(bank): remove SetBalances from keeper public API Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> * change(bank): remove SubtractCoins from keeper public API * change(ibc/transfer): remove AddCoins from relay tests * change(bank): remove AddCoins from public keeper API * fix imports * remove set balances * fix fee test * remove set balances * fix(staking): remove dependency on minter authorization for staking pools * chore: update CHANGELOG.md * update: x/distribution/keeper/keeper_test.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update simapp/test_helpers.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update x/staking/genesis_test.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * fix(simapp): FundAccount amount variable name * fix some PR issues Co-authored-by: Frojdi Dymylja <frojdi.dymylja@gmail.com> Co-authored-by: Frojdi Dymylja <33157909+fdymylja@users.noreply.github.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-02-17 10:20:33 -08:00
require.NoError(t, simapp.FundAccount(app, ctx, distrAcc.GetAddress(), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)))))
app.AccountKeeper.SetModuleAccount(ctx, distrAcc)
2019-06-28 13:11:27 -07:00
tokens := sdk.DecCoins{sdk.NewDecCoinFromDec(sdk.DefaultBondDenom, sdk.NewDec(initial))}
2019-01-16 13:38:05 -08:00
// create validator with 50% commission
tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
tstaking.CreateValidator(valAddrs[0], valConsPk1, sdk.NewInt(100), true)
2019-01-16 13:38:05 -08:00
// end block to bond validator
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// fetch validator and delegation
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
del1 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// allocate some rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// historical count should be 2 (validator init, delegation init)
require.Equal(t, uint64(2), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))
2019-01-16 13:38:05 -08:00
// second delegation
tstaking.Delegate(sdk.AccAddress(valAddrs[1]), valAddrs[0], sdk.NewInt(100))
2019-01-16 13:38:05 -08:00
// historical count should be 3 (second delegation init)
require.Equal(t, uint64(3), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))
2019-01-16 13:38:05 -08:00
// fetch updated validator
val = app.StakingKeeper.Validator(ctx, valAddrs[0])
del2 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[1]), valAddrs[0])
2019-01-16 13:38:05 -08:00
// end block
staking.EndBlocker(ctx, app.StakingKeeper)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// allocate some more rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// first delegator withdraws
[Bank] Remove the unsafe balance changing API (#8473) * temp commit * setbalance now is internal * remove set balances in genesis * feedback test commit * update tests * fix: genesis panic message * fix not bonded pool * fix(staking): genesis test * fix(simapp): rollback state fix change * fix(staking): genesis large val set test * [Bank Refactor] Frojdi jonathan/remove setsupply (#8491) * init supply in a different way * remove external usage of set supply * change(staking): replace SetSupply with MintCoins in tests * change(evidence): replace SetSupply with MintCoins in tests * change(crisis): remove SetSupply in tests * change(bank): remove set supply from genesis tests * change(bank): remove set supply from keeper tests * change(bank): remove remaining set supply usage from keeper tests * change(bank): remove set supply usage from grpc query and querier tests * change(bank): remove SetSupply from keeper interface Co-authored-by: Frojdi Dymylja <frojdi.dymylja@gmail.com> * remove setbalances from genesis in gov * remove keyring * add init genesis state * change(staking): make genesis checks coherent and add tests * remove setbalances on distribution * fix(staking): genesis tests * [Bank Refactor]: Remove SetBalances usage from the code and tests (#8509) * change(distribution): remove SetBalances usage from keeper tests * add(simapp): FundAccount utility function * chore(staking): use FundAccount in keeper tests * change(staking): remove usage of SetBalance in allocation tests * change(staking): remove usage of SetBalance in delegation tests * change(staking): remove usage of SetBalance in proposal handler tests * change(staking): remove usage of SetBalances in grpc query tests * change(staking): remove usage of SetBalances in operations tests * change(distribution): remove usage of SetBalances in genesis * change(authz): remove usage of SetBalances keeper and operations test * fix(authz): TestKeeperFees failing test * change(slashing): remove SetBalances from expected BankKeeper * change(slashing): remove usage of SetBalances in tests * change(distribution): remove SetBalances from expected BankKeeper * change(genutil): remove usage of SetBalances from tests * change(gov): remove SetBalances from expected BankKeeper * change(gov): remove usage of SetBalances from tests * change(staking): remove usage of SetBalances from slash tests * change(staking): remove SetBalances from expected BankKeeper * change(staking): remove usage of SetBalances from delegation tests * change(staking): remove usage of SetBalances from operations tests * change(staking): remove usage of SetBalances from validator tests * change(bank): remove usage of SetBalances from app tests * change(bank): remove usage of SetBalances from bench tests * change(bank): remove usage of SetBalances from querier tests * change(bank): remove usage of SetBalances from grpc query tests * change(bank): remove usage of SetBalances from operations tests * change(bank): partially remove usage of SetBalances from keeper tests * change(bank): finalize removal of usage of SetBalances from keeper tests * change(auth): remove usage of SetBalances from verify tests * change(auth): partially remove usage of SetBalances from tests * [Bank refactor]: finalize removal of setbalances from auth (#8527) * add tests with is check tx * temp commit * fix test * fix other test and remove setbalances * change(auth): remove usage of SetBalances is vesting tests Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> * change(types): remove usage of SetBalances in queries * fix(types): pagination tests * [Bank refactor] fix pagination tests (#8550) * fix tests * lint * change(bank): remove SetBalances from keeper public API Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> * change(bank): remove SubtractCoins from keeper public API * change(ibc/transfer): remove AddCoins from relay tests * change(bank): remove AddCoins from public keeper API * fix imports * remove set balances * fix fee test * remove set balances * fix(staking): remove dependency on minter authorization for staking pools * chore: update CHANGELOG.md * update: x/distribution/keeper/keeper_test.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update simapp/test_helpers.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update x/staking/genesis_test.go Co-authored-by: Robert Zaremba <robert@zaremba.ch> * fix(simapp): FundAccount amount variable name * fix some PR issues Co-authored-by: Frojdi Dymylja <frojdi.dymylja@gmail.com> Co-authored-by: Frojdi Dymylja <33157909+fdymylja@users.noreply.github.com> Co-authored-by: SaReN <sahithnarahari@gmail.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Robert Zaremba <robert@zaremba.ch>
2021-02-17 10:20:33 -08:00
_, err := app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
require.NoError(t, err)
2019-01-16 13:38:05 -08:00
// second delegator withdraws
_, err = app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[1]), valAddrs[0])
require.NoError(t, err)
2019-01-16 13:38:05 -08:00
// historical count should be 3 (validator init + two delegations)
require.Equal(t, uint64(3), app.DistrKeeper.GetValidatorHistoricalReferenceCount(ctx))
2019-01-16 13:38:05 -08:00
// validator withdraws commission
_, err = app.DistrKeeper.WithdrawValidatorCommission(ctx, valAddrs[0])
require.NoError(t, err)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod := app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del1
rewards := app.DistrKeeper.CalculateDelegationRewards(ctx, val, del1, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del1 should be zero
require.True(t, rewards.IsZero())
// calculate delegation rewards for del2
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del2, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del2 should be zero
require.True(t, rewards.IsZero())
// commission should be zero
require.True(t, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission.IsZero())
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// allocate some more rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// first delegator withdraws again
_, err = app.DistrKeeper.WithdrawDelegationRewards(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0])
require.NoError(t, err)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod = app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del1
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del1, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del1 should be zero
require.True(t, rewards.IsZero())
// calculate delegation rewards for del2
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del2, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del2 should be 1/4 initial
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 4)}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be half initial
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission)
2019-01-16 13:38:05 -08:00
// next block
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
2019-01-16 13:38:05 -08:00
// allocate some more rewards
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
2019-01-16 13:38:05 -08:00
// withdraw commission
_, err = app.DistrKeeper.WithdrawValidatorCommission(ctx, valAddrs[0])
require.NoError(t, err)
2019-01-16 13:38:05 -08:00
// end period
endingPeriod = app.DistrKeeper.IncrementValidatorPeriod(ctx, val)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del1
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del1, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del1 should be 1/4 initial
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 4)}}, rewards)
2019-01-16 13:38:05 -08:00
// calculate delegation rewards for del2
rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del2, endingPeriod)
2019-01-16 13:38:05 -08:00
// rewards for del2 should be 1/2 initial
require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, rewards)
2019-01-16 13:38:05 -08:00
// commission should be zero
require.True(t, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission.IsZero())
2018-10-04 18:37:40 -07:00
}