diff --git a/x/stake/genesis.go b/x/stake/genesis.go index 45754f34309d..fa81cc03bc6f 100644 --- a/x/stake/genesis.go +++ b/x/stake/genesis.go @@ -34,10 +34,6 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [ // Manually set indexes for the first time keeper.SetValidatorByConsAddr(ctx, validator) keeper.SetValidatorByPowerIndex(ctx, validator, data.Pool) - - if validator.Status == sdk.Bonded { - keeper.SetValidatorBondedIndex(ctx, validator) - } } for _, bond := range data.Bonds { diff --git a/x/stake/keeper/key.go b/x/stake/keeper/key.go index f6e38a23071a..c6b3b6b55082 100644 --- a/x/stake/keeper/key.go +++ b/x/stake/keeper/key.go @@ -25,7 +25,6 @@ var ( RedelegationKey = []byte{0x0A} // key for a redelegation RedelegationByValSrcIndexKey = []byte{0x0B} // prefix for each key for an redelegation, by source validator operator RedelegationByValDstIndexKey = []byte{0x0C} // prefix for each key for an redelegation, by destination validator operator - BondedValidatorsIndexKey = []byte{0x0D} // prefix for each key to the bonded validator set ) const maxDigitsForAccount = 12 // ~220,000,000 atoms created at launch @@ -42,12 +41,6 @@ func GetValidatorByConsAddrKey(addr sdk.ConsAddress) []byte { return append(ValidatorsByConsAddrKey, addr.Bytes()...) } -// gets the key for the current validator group -// VALUE: none (key rearrangement with GetValKeyFromValBondedIndexKey) -func GetValidatorsBondedIndexKey(operatorAddr sdk.ValAddress) []byte { - return append(ValidatorsBondedIndexKey, operatorAddr.Bytes()...) -} - // Get the validator operator address from ValBondedIndexKey func GetAddressFromValBondedIndexKey(IndexKey []byte) []byte { return IndexKey[1:] // remove prefix bytes @@ -64,7 +57,7 @@ func GetBondedValidatorsByPowerIndexKey(validator types.Validator, pool types.Po // get the bonded validator index key for an operator address func GetBondedValidatorIndexKey(operator sdk.ValAddress) []byte { - return append(BondedValidatorsIndexKey, operator...) + return append(ValidatorsBondedIndexKey, operator...) } // get the power ranking of a validator diff --git a/x/stake/keeper/val_state_change.go b/x/stake/keeper/val_state_change.go index 06782634f062..0fbc729787de 100644 --- a/x/stake/keeper/val_state_change.go +++ b/x/stake/keeper/val_state_change.go @@ -162,7 +162,6 @@ func (k Keeper) UnjailValidator(ctx sdk.Context, validator types.Validator) { // perform all the store operations for when a validator status becomes bonded func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types.Validator { - store := ctx.KVStore(k.storeKey) pool := k.GetPool(ctx) k.DeleteValidatorByPowerIndex(ctx, validator, pool) @@ -175,7 +174,6 @@ func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types. // save the now bonded validator record to the three referenced stores k.SetValidator(ctx, validator) - store.Set(GetValidatorsBondedIndexKey(validator.OperatorAddr), []byte{}) k.SetValidatorByPowerIndex(ctx, validator, pool) @@ -190,7 +188,6 @@ func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types. // perform all the store operations for when a validator status begins unbonding func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validator) types.Validator { - store := ctx.KVStore(k.storeKey) pool := k.GetPool(ctx) params := k.GetParams(ctx) @@ -211,9 +208,6 @@ func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validat // save the now unbonded validator record k.SetValidator(ctx, validator) - // also remove from the Bonded types.Validators Store - store.Delete(GetValidatorsBondedIndexKey(validator.OperatorAddr)) - k.SetValidatorByPowerIndex(ctx, validator, pool) // call the unbond hook if present @@ -237,7 +231,7 @@ func (k Keeper) completeUnbondingValidator(ctx sdk.Context, validator types.Vali func (k Keeper) retrieveLastValidatorSet(ctx sdk.Context) map[[sdk.AddrLen]byte][]byte { last := make(map[[sdk.AddrLen]byte][]byte) store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, BondedValidatorsIndexKey) + iterator := sdk.KVStorePrefixIterator(store, ValidatorsBondedIndexKey) for ; iterator.Valid(); iterator.Next() { var operator [sdk.AddrLen]byte copy(operator[:], iterator.Key()[1:]) diff --git a/x/stake/keeper/validator.go b/x/stake/keeper/validator.go index 0b78f2cbf2ec..705c33b7ed7e 100644 --- a/x/stake/keeper/validator.go +++ b/x/stake/keeper/validator.go @@ -119,12 +119,6 @@ func (k Keeper) SetNewValidatorByPowerIndex(ctx sdk.Context, validator types.Val store.Set(GetBondedValidatorsByPowerIndexKey(validator, pool), validator.OperatorAddr) } -// validator index -func (k Keeper) SetValidatorBondedIndex(ctx sdk.Context, validator types.Validator) { - store := ctx.KVStore(k.storeKey) - store.Set(GetValidatorsBondedIndexKey(validator.OperatorAddr), []byte{}) -} - //___________________________________________________________________________ // Update the tokens of an existing validator, update the validators power index key @@ -201,12 +195,6 @@ func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.ValAddress) { store.Delete(GetValidatorByConsAddrKey(sdk.ConsAddress(validator.ConsPubKey.Address()))) store.Delete(GetBondedValidatorsByPowerIndexKey(validator, pool)) - // delete from the current and power weighted validator groups if the validator - // is bonded - and add validator with zero power to the validator updates - if store.Get(GetValidatorsBondedIndexKey(validator.OperatorAddr)) == nil { - return - } - store.Delete(GetValidatorsBondedIndexKey(validator.OperatorAddr)) } //___________________________________________________________________________ diff --git a/x/stake/stake.go b/x/stake/stake.go index 817f73ca311d..b7ed8be4d027 100644 --- a/x/stake/stake.go +++ b/x/stake/stake.go @@ -37,7 +37,6 @@ var ( GetValidatorKey = keeper.GetValidatorKey GetValidatorByConsAddrKey = keeper.GetValidatorByConsAddrKey - GetValidatorsBondedIndexKey = keeper.GetValidatorsBondedIndexKey GetBondedValidatorsByPowerIndexKey = keeper.GetBondedValidatorsByPowerIndexKey GetDelegationKey = keeper.GetDelegationKey GetDelegationsKey = keeper.GetDelegationsKey