Skip to content

Commit

Permalink
remove stakingtypes.TStoreKey
Browse files Browse the repository at this point in the history
Update x/staking/keeper/val_state_change.go
Update x/slashing/keeper/infractions.go
  • Loading branch information
sainoe committed Nov 16, 2022
1 parent 66f4b7f commit 4101d47
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 34 deletions.
4 changes: 2 additions & 2 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion x/auth/legacy/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion x/gov/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/keeper/infractions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/keeper/signing_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion x/staking/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion x/staking/keeper/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 0 additions & 1 deletion x/staking/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
28 changes: 13 additions & 15 deletions x/staking/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
}

Expand Down
1 change: 0 additions & 1 deletion x/staking/keeper/unbonding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 4 additions & 6 deletions x/staking/keeper/val_state_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 0 additions & 3 deletions x/staking/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4101d47

Please sign in to comment.