From 4101d472604fbf4c6cb18774582c06f400b1be70 Mon Sep 17 00:00:00 2001 From: Simon Noetzlin Date: Wed, 16 Nov 2022 10:59:50 +0100 Subject: [PATCH] remove stakingtypes.TStoreKey Update x/staking/keeper/val_state_change.go Update x/slashing/keeper/infractions.go --- simapp/app.go | 4 ++-- x/auth/legacy/v043/store_test.go | 1 - x/gov/keeper/common_test.go | 1 - x/slashing/keeper/infractions.go | 2 +- x/slashing/keeper/signing_info.go | 2 +- x/staking/common_test.go | 1 - x/staking/keeper/common_test.go | 1 - x/staking/keeper/grpc_query_test.go | 1 - x/staking/keeper/keeper.go | 28 +++++++++++++--------------- x/staking/keeper/unbonding_test.go | 1 - x/staking/keeper/val_state_change.go | 10 ++++------ x/staking/types/keys.go | 3 --- 12 files changed, 21 insertions(+), 34 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index c094d8dea555..806c2156c2b4 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -209,7 +209,7 @@ func NewSimApp( evidencetypes.StoreKey, capabilitytypes.StoreKey, authzkeeper.StoreKey, ) - tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, stakingtypes.TStoreKey) + tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) // NOTE: The testingkey is just mounted for testing purposes. Actual applications should // not include this key. @@ -250,7 +250,7 @@ func NewSimApp( appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), ) stakingKeeper := stakingkeeper.NewKeeper( - appCodec, keys[stakingtypes.StoreKey], tkeys[stakingtypes.TStoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), + appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), ) app.MintKeeper = mintkeeper.NewKeeper( appCodec, keys[minttypes.StoreKey], app.GetSubspace(minttypes.ModuleName), &stakingKeeper, diff --git a/x/auth/legacy/v043/store_test.go b/x/auth/legacy/v043/store_test.go index 3b633869dfe6..fb593c14ba7c 100644 --- a/x/auth/legacy/v043/store_test.go +++ b/x/auth/legacy/v043/store_test.go @@ -655,7 +655,6 @@ func createValidator(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers i app.StakingKeeper = stakingkeeper.NewKeeper( cdc, app.GetKey(stakingtypes.StoreKey), - app.GetTKey(stakingtypes.TStoreKey), app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index 19a3665d8047..7b002b1324dd 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -24,7 +24,6 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers app.StakingKeeper = stakingkeeper.NewKeeper( cdc, app.GetKey(stakingtypes.StoreKey), - app.GetTKey(stakingtypes.TStoreKey), app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName), diff --git a/x/slashing/keeper/infractions.go b/x/slashing/keeper/infractions.go index 9d5888984c53..509448b35507 100644 --- a/x/slashing/keeper/infractions.go +++ b/x/slashing/keeper/infractions.go @@ -104,7 +104,7 @@ func (k Keeper) HandleValidatorSignature(ctx sdk.Context, addr cryptotypes.Addre // We need to reset the counter & array so that the validator won't be immediately slashed for downtime upon rebonding. signInfo.MissedBlocksCounter = 0 signInfo.IndexOffset = 0 - k.ClearValidatorMissedBlockBitArray(ctx, consAddr) + k.clearValidatorMissedBlockBitArray(ctx, consAddr) logger.Info( "slashing and jailing validator due to liveness fault", diff --git a/x/slashing/keeper/signing_info.go b/x/slashing/keeper/signing_info.go index 0cab2c389e88..d65b773ebc66 100644 --- a/x/slashing/keeper/signing_info.go +++ b/x/slashing/keeper/signing_info.go @@ -148,7 +148,7 @@ func (k Keeper) SetValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.Con } // clearValidatorMissedBlockBitArray deletes every instance of ValidatorMissedBlockBitArray in the store -func (k Keeper) ClearValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.ConsAddress) { +func (k Keeper) clearValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.ConsAddress) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.ValidatorMissedBlockBitArrayPrefixKey(address)) defer iter.Close() diff --git a/x/staking/common_test.go b/x/staking/common_test.go index d87b27c74487..5d8897b1c0a8 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -44,7 +44,6 @@ func getBaseSimappWithCustomKeeper() (*codec.LegacyAmino, *simapp.SimApp, sdk.Co app.StakingKeeper = keeper.NewKeeper( appCodec, app.GetKey(types.StoreKey), - app.GetTKey(types.TStoreKey), app.AccountKeeper, app.BankKeeper, app.GetSubspace(types.ModuleName), diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index 70b9a3f91c31..99c3d2b27a78 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -28,7 +28,6 @@ func createTestInput() (*codec.LegacyAmino, *simapp.SimApp, sdk.Context) { app.StakingKeeper = keeper.NewKeeper( app.AppCodec(), app.GetKey(types.StoreKey), - app.GetTKey(types.TStoreKey), app.AccountKeeper, app.BankKeeper, app.GetSubspace(types.ModuleName), diff --git a/x/staking/keeper/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index 4d0079170104..13155bd660fa 100644 --- a/x/staking/keeper/grpc_query_test.go +++ b/x/staking/keeper/grpc_query_test.go @@ -793,7 +793,6 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers app.StakingKeeper = keeper.NewKeeper( cdc, app.GetKey(types.StoreKey), - app.GetTKey(types.TStoreKey), app.AccountKeeper, app.BankKeeper, app.GetSubspace(types.ModuleName), diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 3b9319c44503..7f120af196f0 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -20,18 +20,17 @@ var _ types.DelegationSet = Keeper{} // keeper of the staking store type Keeper struct { - storeKey sdk.StoreKey - transientKey sdk.StoreKey - cdc codec.BinaryCodec - authKeeper types.AccountKeeper - bankKeeper types.BankKeeper - hooks types.StakingHooks - paramstore paramtypes.Subspace + storeKey sdk.StoreKey + cdc codec.BinaryCodec + authKeeper types.AccountKeeper + bankKeeper types.BankKeeper + hooks types.StakingHooks + paramstore paramtypes.Subspace } // NewKeeper creates a new staking Keeper instance func NewKeeper( - cdc codec.BinaryCodec, key, tKey sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, + cdc codec.BinaryCodec, key sdk.StoreKey, ak types.AccountKeeper, bk types.BankKeeper, ps paramtypes.Subspace, ) Keeper { // set KeyTable if it has not already been set @@ -49,13 +48,12 @@ func NewKeeper( } return Keeper{ - storeKey: key, - transientKey: tKey, - cdc: cdc, - authKeeper: ak, - bankKeeper: bk, - paramstore: ps, - hooks: nil, + storeKey: key, + cdc: cdc, + authKeeper: ak, + bankKeeper: bk, + paramstore: ps, + hooks: nil, } } diff --git a/x/staking/keeper/unbonding_test.go b/x/staking/keeper/unbonding_test.go index ff6aa720ad81..1a06ea451837 100644 --- a/x/staking/keeper/unbonding_test.go +++ b/x/staking/keeper/unbonding_test.go @@ -29,7 +29,6 @@ func setup(t *testing.T, hookCalled *bool, ubdeID *uint64) ( stakingKeeper := keeper.NewKeeper( app.AppCodec(), app.GetKey(types.StoreKey), - app.GetKey(types.StoreKey), app.AccountKeeper, app.BankKeeper, app.GetSubspace(types.ModuleName), diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index 193507a64eca..8bb8b19a256f 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -172,8 +172,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab // update the validator set if power has changed if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) { - update := validator.ABCIValidatorUpdate(powerReduction) - updates = append(updates, update) + updates = append(updates, validator.ABCIValidatorUpdate(powerReduction)) // set the validator update and power k.SetLastValidatorPower(ctx, valAddr, newPower) } @@ -190,8 +189,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab } for _, valAddrBytes := range noLongerBonded { - valAddr := sdk.ValAddress(valAddrBytes) - validator := k.mustGetValidator(ctx, valAddr) + validator := k.mustGetValidator(ctx, sdk.ValAddress(valAddrBytes)) validator, err = k.bondedToUnbonding(ctx, validator) if err != nil { return nil, err @@ -261,7 +259,7 @@ func (k Keeper) UnbondingToUnbonded(ctx sdk.Context, validator types.Validator) panic(fmt.Sprintf("bad state transition unbondingToBonded, validator: %v\n", validator)) } - return k.CompleteUnbondingValidator(ctx, validator) + return k.completeUnbondingValidator(ctx, validator) } // send a validator to jail @@ -354,7 +352,7 @@ func (k Keeper) BeginUnbondingValidator(ctx sdk.Context, validator types.Validat } // perform all the store operations for when a validator status becomes unbonded -func (k Keeper) CompleteUnbondingValidator(ctx sdk.Context, validator types.Validator) types.Validator { +func (k Keeper) completeUnbondingValidator(ctx sdk.Context, validator types.Validator) types.Validator { validator = validator.UpdateStatus(types.Unbonded) k.SetValidator(ctx, validator) diff --git a/x/staking/types/keys.go b/x/staking/types/keys.go index 187e98bee3de..da653338c3c5 100644 --- a/x/staking/types/keys.go +++ b/x/staking/types/keys.go @@ -19,9 +19,6 @@ const ( // StoreKey is the string store representation StoreKey = ModuleName - // TStoreKey is the string transient store representation - TStoreKey = "transient_staking" - // QuerierRoute is the querier route for the staking module QuerierRoute = ModuleName