Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove old migration code #627

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just leaving a comment since I don't remember it from top of my head, is it ok to use same keys in the future per module?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is, this key has been fully removed from the store now

)

// UnbondingType defines the type of unbonding operation
Expand Down
Loading