Merge remote-tracking branch 'origin/cwgoes/check-supply-in-simulation' into jae/check-supply-in-simulation

This commit is contained in:
rigelrozanski 2018-10-22 15:51:52 -04:00
commit c4d7747a56
8 changed files with 21 additions and 19 deletions

View File

@ -3,6 +3,10 @@ package app
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"os"
"sort"
bam "github.com/cosmos/cosmos-sdk/baseapp" bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
@ -19,9 +23,6 @@ import (
dbm "github.com/tendermint/tendermint/libs/db" dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types" tmtypes "github.com/tendermint/tendermint/types"
"io"
"os"
"sort"
) )
const ( const (
@ -334,8 +335,8 @@ var _ sdk.StakingHooks = Hooks{}
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) { func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorCreated(ctx, addr) h.dh.OnValidatorCreated(ctx, addr)
} }
func (h Hooks) OnValidatorCommissionChange(ctx sdk.Context, addr sdk.ValAddress) { func (h Hooks) OnValidatorModified(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorCommissionChange(ctx, addr) h.dh.OnValidatorModified(ctx, addr)
} }
func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) { func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorRemoved(ctx, addr) h.dh.OnValidatorRemoved(ctx, addr)

View File

@ -5,9 +5,9 @@ The staking module allow for the following hooks to be registered with staking e
``` golang ``` golang
// event hooks for staking validator object // event hooks for staking validator object
type StakingHooks interface { type StakingHooks interface {
OnValidatorCreated(ctx Context, address ValAddress) // called when a validator is created OnValidatorCreated(ctx Context, address ValAddress) // Must be called when a validator is created
OnValidatorCommissionChange(ctx Context, address ValAddress) // called when a validator's commission is modified OnValidatorModified(ctx Context, address ValAddress) // Must be called when a validator's state changes
OnValidatorRemoved(ctx Context, address ValAddress) // called when a validator is deleted OnValidatorRemoved(ctx Context, address ValAddress) // Must be called when a validator is deleted
OnValidatorBonded(ctx Context, address ConsAddress) // called when a validator is bonded OnValidatorBonded(ctx Context, address ConsAddress) // called when a validator is bonded
OnValidatorBeginUnbonding(ctx Context, address ConsAddress, operator ValAddress) // called when a validator begins unbonding OnValidatorBeginUnbonding(ctx Context, address ConsAddress, operator ValAddress) // called when a validator begins unbonding

View File

@ -111,9 +111,9 @@ type DelegationSet interface {
// event hooks for staking validator object // event hooks for staking validator object
type StakingHooks interface { type StakingHooks interface {
OnValidatorCreated(ctx Context, address ValAddress) // Must be called when a validator is created OnValidatorCreated(ctx Context, address ValAddress) // Must be called when a validator is created
OnValidatorCommissionChange(ctx Context, address ValAddress) // Must be called when a validator's commission is modified OnValidatorModified(ctx Context, address ValAddress) // Must be called when a validator's state changes
OnValidatorRemoved(ctx Context, address ValAddress) // Must be called when a validator is deleted OnValidatorRemoved(ctx Context, address ValAddress) // Must be called when a validator is deleted
OnValidatorBonded(ctx Context, address ConsAddress) // Must be called when a validator is bonded OnValidatorBonded(ctx Context, address ConsAddress) // Must be called when a validator is bonded
OnValidatorBeginUnbonding(ctx Context, address ConsAddress, operator ValAddress) // Must be called when a validator begins unbonding OnValidatorBeginUnbonding(ctx Context, address ConsAddress, operator ValAddress) // Must be called when a validator begins unbonding

View File

@ -14,9 +14,9 @@ func (k Keeper) onValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
vdi := types.ValidatorDistInfo{ vdi := types.ValidatorDistInfo{
OperatorAddr: addr, OperatorAddr: addr,
FeePoolWithdrawalHeight: height, FeePoolWithdrawalHeight: height,
Pool: types.DecCoins{}, Pool: types.DecCoins{},
PoolCommission: types.DecCoins{}, PoolCommission: types.DecCoins{},
DelAccum: types.NewTotalAccum(height), DelAccum: types.NewTotalAccum(height),
} }
k.SetValidatorDistInfo(ctx, vdi) k.SetValidatorDistInfo(ctx, vdi)
} }
@ -80,7 +80,7 @@ func (k Keeper) Hooks() Hooks { return Hooks{k} }
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) { func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
h.k.onValidatorCreated(ctx, addr) h.k.onValidatorCreated(ctx, addr)
} }
func (h Hooks) OnValidatorCommissionChange(ctx sdk.Context, addr sdk.ValAddress) { func (h Hooks) OnValidatorModified(ctx sdk.Context, addr sdk.ValAddress) {
h.k.onValidatorModified(ctx, addr) h.k.onValidatorModified(ctx, addr)
} }
func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) { func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) {

View File

@ -62,7 +62,7 @@ func (h Hooks) OnValidatorBeginUnbonding(ctx sdk.Context, address sdk.ConsAddres
// nolint - unused hooks // nolint - unused hooks
func (h Hooks) OnValidatorCreated(_ sdk.Context, _ sdk.ValAddress) {} func (h Hooks) OnValidatorCreated(_ sdk.Context, _ sdk.ValAddress) {}
func (h Hooks) OnValidatorCommissionChange(_ sdk.Context, _ sdk.ValAddress) {} func (h Hooks) OnValidatorModified(_ sdk.Context, _ sdk.ValAddress) {}
func (h Hooks) OnValidatorRemoved(_ sdk.Context, _ sdk.ValAddress) {} func (h Hooks) OnValidatorRemoved(_ sdk.Context, _ sdk.ValAddress) {}
func (h Hooks) OnDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) {} func (h Hooks) OnDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) {}
func (h Hooks) OnDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) {} func (h Hooks) OnDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) {}

View File

@ -148,7 +148,7 @@ func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keepe
return err.Result() return err.Result()
} }
validator.Commission = commission validator.Commission = commission
k.OnValidatorCommissionChange(ctx, msg.ValidatorAddr) k.OnValidatorModified(ctx, msg.ValidatorAddr)
} }
k.SetValidator(ctx, validator) k.SetValidator(ctx, validator)

View File

@ -11,9 +11,9 @@ func (k Keeper) OnValidatorCreated(ctx sdk.Context, address sdk.ValAddress) {
k.hooks.OnValidatorCreated(ctx, address) k.hooks.OnValidatorCreated(ctx, address)
} }
} }
func (k Keeper) OnValidatorCommissionChange(ctx sdk.Context, address sdk.ValAddress) { func (k Keeper) OnValidatorModified(ctx sdk.Context, address sdk.ValAddress) {
if k.hooks != nil { if k.hooks != nil {
k.hooks.OnValidatorCommissionChange(ctx, address) k.hooks.OnValidatorModified(ctx, address)
} }
} }

View File

@ -51,6 +51,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh
} }
operatorAddress := validator.GetOperator() operatorAddress := validator.GetOperator()
k.OnValidatorModified(ctx, operatorAddress)
// Track remaining slash amount for the validator // Track remaining slash amount for the validator
// This will decrease when we slash unbondings and // This will decrease when we slash unbondings and