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 (
"encoding/json"
"fmt"
"io"
"os"
"sort"
bam "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -19,9 +23,6 @@ import (
dbm "github.com/tendermint/tendermint/libs/db"
"github.com/tendermint/tendermint/libs/log"
tmtypes "github.com/tendermint/tendermint/types"
"io"
"os"
"sort"
)
const (
@ -334,8 +335,8 @@ var _ sdk.StakingHooks = Hooks{}
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorCreated(ctx, addr)
}
func (h Hooks) OnValidatorCommissionChange(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorCommissionChange(ctx, addr)
func (h Hooks) OnValidatorModified(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorModified(ctx, addr)
}
func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) {
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
// event hooks for staking validator object
type StakingHooks interface {
OnValidatorCreated(ctx Context, address ValAddress) // called when a validator is created
OnValidatorCommissionChange(ctx Context, address ValAddress) // called when a validator's commission is modified
OnValidatorRemoved(ctx Context, address ValAddress) // called when a validator is deleted
OnValidatorCreated(ctx Context, address ValAddress) // Must be called when a validator is created
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
OnValidatorBonded(ctx Context, address ConsAddress) // called when a validator is bonded
OnValidatorBeginUnbonding(ctx Context, address ConsAddress, operator ValAddress) // called when a validator begins unbonding

View File

@ -112,7 +112,7 @@ type DelegationSet interface {
// event hooks for staking validator object
type StakingHooks interface {
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
OnValidatorBonded(ctx Context, address ConsAddress) // Must be called when a validator is bonded

View File

@ -80,7 +80,7 @@ func (k Keeper) Hooks() Hooks { return Hooks{k} }
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
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)
}
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
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) OnDelegationCreated(_ 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()
}
validator.Commission = commission
k.OnValidatorCommissionChange(ctx, msg.ValidatorAddr)
k.OnValidatorModified(ctx, msg.ValidatorAddr)
}
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)
}
}
func (k Keeper) OnValidatorCommissionChange(ctx sdk.Context, address sdk.ValAddress) {
func (k Keeper) OnValidatorModified(ctx sdk.Context, address sdk.ValAddress) {
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()
k.OnValidatorModified(ctx, operatorAddress)
// Track remaining slash amount for the validator
// This will decrease when we slash unbondings and