Skip to content

Commit

Permalink
chore: remove old migration code
Browse files Browse the repository at this point in the history
  • Loading branch information
PaddyMc committed Sep 30, 2024
1 parent d4e20fe commit 4837dc4
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 260 deletions.
2 changes: 1 addition & 1 deletion tests/integration/staking/keeper/determinstic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func TestGRPCValidatorDelegations(t *testing.T) {
ValidatorAddr: validator.OperatorAddress,
}

testdata.DeterministicIterations(f.ctx, t, req, f.queryClient.ValidatorDelegations, 17484, false)
testdata.DeterministicIterations(f.ctx, t, req, f.queryClient.ValidatorDelegations, 14475, false)
}

func TestGRPCValidatorUnbondingDelegations(t *testing.T) {
Expand Down
13 changes: 13 additions & 0 deletions x/bank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@ func (k BaseSendKeeper) InputOutputCoins(ctx context.Context, input types.Input,
return err
}

for _, out := range outputs {
outAddress, err := k.ak.AddressCodec().StringToBytes(out.Address)
if err != nil {
return err
}

if err := k.BlockBeforeSend(ctx, inAddress, outAddress, out.Coins); err != nil {
return err
}

k.TrackBeforeSend(ctx, inAddress, outAddress, out.Coins)
}

err = k.subUnlockedCoins(ctx, inAddress, input.Coins)
if err != nil {
return err
Expand Down
14 changes: 0 additions & 14 deletions x/staking/keeper/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/staking/types"
)

Expand All @@ -21,18 +20,5 @@ func (k *Keeper) BeginBlocker(ctx context.Context) error {
func (k *Keeper) EndBlocker(ctx context.Context) ([]abci.ValidatorUpdate, error) {
defer telemetry.ModuleMeasureSince(types.ModuleName, telemetry.Now(), telemetry.MetricKeyEndBlocker)

// TODO: Remove migration code and panic catch in the next upgrade
// Wrap the migration call in a function that can recover from panics
func() {
defer func() {
if r := recover(); r != nil {
k.Logger(sdk.UnwrapSDKContext(ctx)).Error("Panic in MigrateDelegationsByValidatorIndex", "recover", r)
}
}()

// Only migrate 10000 items per block to make the migration as fast as possible
k.MigrateDelegationsByValidatorIndex(sdk.UnwrapSDKContext(ctx), 10000)
}()

return k.BlockValidatorUpdates(ctx)
}
7 changes: 0 additions & 7 deletions x/staking/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"fmt"
"strings"

"google.golang.org/grpc/codes"
Expand Down Expand Up @@ -109,12 +108,6 @@ func (k Querier) ValidatorDelegations(ctx context.Context, req *types.QueryValid
pageRes *query.PageResponse
)
pageRes, err = query.Paginate(delStore, req.Pagination, func(delAddr, value []byte) error {
// Check the store to see if there is a value stored under the key
key := store.Get(types.NextMigrateDelegationsByValidatorIndexKey)
if key != nil {
// Users will never see this error as if there is an error the function defaults to the legacy implementation below
return fmt.Errorf("store migration is not finished, try again later")
}
bz := store.Get(types.GetDelegationKey(delAddr, valAddr))

var delegation types.Delegation
Expand Down
86 changes: 0 additions & 86 deletions x/staking/keeper/validator_index.go

This file was deleted.

150 changes: 0 additions & 150 deletions x/staking/keeper/validator_index_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions x/staking/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ var (
ParamsKey = []byte{0x51} // prefix for parameters for module x/staking

DelegationByValIndexKey = []byte{0x71} // key for delegations by a validator

NextMigrateDelegationsByValidatorIndexKey = []byte{0x81} // key used to migrate to the new validator index
)

// UnbondingType defines the type of unbonding operation
Expand Down

0 comments on commit 4837dc4

Please sign in to comment.