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

Add migration handler for disabling seqno #394

Merged
merged 2 commits into from
Jan 11, 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
6 changes: 6 additions & 0 deletions x/auth/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {

return iterErr
}

func (m Migrator) Migrate2to3(ctx sdk.Context) error {
defaultParams := types.DefaultParams()
m.keeper.SetParams(ctx, defaultParams)
return nil
}
28 changes: 28 additions & 0 deletions x/auth/keeper/v2_to_v3_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package keeper_test

import (
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/stretchr/testify/require"
"testing"
)

func TestMigrate2to3(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice!

app, ctx := createTestApp(true)

prevParams := types.Params{
MaxMemoCharacters: types.DefaultMaxMemoCharacters,
TxSigLimit: types.DefaultTxSigLimit,
TxSizeCostPerByte: types.DefaultTxSizeCostPerByte,
SigVerifyCostED25519: types.DefaultSigVerifyCostED25519,
SigVerifyCostSecp256k1: types.DefaultSigVerifyCostSecp256k1,
}

app.AccountKeeper.SetParams(ctx, prevParams)
// migrate to default params
m := keeper.NewMigrator(app.AccountKeeper, app.GRPCQueryRouter())
err := m.Migrate2to3(ctx)
require.NoError(t, err)
params := app.AccountKeeper.GetParams(ctx)
require.Equal(t, params.DisableSeqnoCheck, false)
}
6 changes: 5 additions & 1 deletion x/auth/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
if err != nil {
panic(err)
}
err = cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3)
if err != nil {
panic(err)
}
}

// InitGenesis performs genesis initialization for the auth module. It returns
Expand All @@ -153,7 +157,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 2 }
func (AppModule) ConsensusVersion() uint64 { return 3 }

// AppModuleSimulation functions

Expand Down
Loading