fix revoke validator bug
This commit is contained in:
parent
3b4aa4d0ae
commit
c8133a0f6a
|
@ -59,7 +59,7 @@ func (ctx CoreContext) QuerySubspace(cdc *wire.Codec, subspace []byte, storeName
|
||||||
|
|
||||||
// Query from Tendermint with the provided storename and path
|
// Query from Tendermint with the provided storename and path
|
||||||
func (ctx CoreContext) query(key cmn.HexBytes, storeName, endPath string) (res []byte, err error) {
|
func (ctx CoreContext) query(key cmn.HexBytes, storeName, endPath string) (res []byte, err error) {
|
||||||
path := fmt.Sprintf("/store/%s/key", storeName)
|
path := fmt.Sprintf("/store/%s/%s", storeName, endPath)
|
||||||
node, err := ctx.GetNode()
|
node, err := ctx.GetNode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
|
|
|
@ -220,8 +220,12 @@ func (k Keeper) updateValidator(ctx sdk.Context, validator Validator) Validator
|
||||||
oldValidator, oldFound := k.GetValidator(ctx, ownerAddr)
|
oldValidator, oldFound := k.GetValidator(ctx, ownerAddr)
|
||||||
|
|
||||||
if validator.Revoked && oldValidator.Status() == sdk.Bonded {
|
if validator.Revoked && oldValidator.Status() == sdk.Bonded {
|
||||||
validator, pool = validator.UpdateStatus(pool, sdk.Unbonded)
|
k.unbondValidator(ctx, store, validator)
|
||||||
k.setPool(ctx, pool)
|
|
||||||
|
// need to also clear the cliff validator spot because the revoke has
|
||||||
|
// opened up a new spot which will be filled when
|
||||||
|
// updateValidatorsBonded is called
|
||||||
|
k.clearCliffValidator(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
powerIncreasing := false
|
powerIncreasing := false
|
||||||
|
@ -674,6 +678,13 @@ func (k Keeper) setCliffValidator(ctx sdk.Context, validator Validator, pool Poo
|
||||||
store.Set(ValidatorCliffKey, validator.Owner)
|
store.Set(ValidatorCliffKey, validator.Owner)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// clear the current validator and power of the validator on the cliff
|
||||||
|
func (k Keeper) clearCliffValidator(ctx sdk.Context) {
|
||||||
|
store := ctx.KVStore(k.storeKey)
|
||||||
|
store.Set(ValidatorPowerCliffKey, nil)
|
||||||
|
store.Set(ValidatorCliffKey, nil)
|
||||||
|
}
|
||||||
|
|
||||||
//__________________________________________________________________________
|
//__________________________________________________________________________
|
||||||
|
|
||||||
// Implements ValidatorSet
|
// Implements ValidatorSet
|
||||||
|
|
Loading…
Reference in New Issue