Skip to content

Commit

Permalink
Fix tests and create migration logic for compute
Browse files Browse the repository at this point in the history
  • Loading branch information
iKapitonau committed Dec 4, 2024
1 parent 8132332 commit 5a82dc2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 12 additions & 0 deletions x/compute/internal/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ func (m Migrator) Migrate4to5(ctx sdk.Context) error {
return nil
}

func (m Migrator) Migrate5to6(ctx sdk.Context) error {
store := m.keeper.storeService.OpenKVStore(ctx)
defaultParams := types.DefaultParams()
bz, err := m.keeper.cdc.Marshal(&defaultParams)
if err != nil {
return err
}
store.Set(types.ParamsKey, bz)

Check failure on line 145 in x/compute/internal/keeper/migrations.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `store.Set` is not checked (errcheck)

Check failure on line 145 in x/compute/internal/keeper/migrations.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `store.Set` is not checked (errcheck)

return nil
}

const progressPartSize = 1000

func logMigrationProgress(ctx sdk.Context, formatter *message.Printer, migratedContracts uint64, totalContracts uint64, previousTime int64) {
Expand Down
1 change: 1 addition & 0 deletions x/compute/internal/keeper/test_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ func CreateTestInput(t *testing.T, isCheckTx bool, supportedFeatures string, enc
random := make([]byte, 32)
_, _ = rand.Read(random)
keeper.SetRandomSeed(ctx, random)
keeper.SetParams(ctx, wasmtypes.DefaultParams())

Check failure on line 610 in x/compute/internal/keeper/test_common.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `keeper.SetParams` is not checked (errcheck)

Check failure on line 610 in x/compute/internal/keeper/test_common.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `keeper.SetParams` is not checked (errcheck)

govSubSp, _ := paramsKeeper.GetSubspace(govtypes.ModuleName)

Expand Down
6 changes: 5 additions & 1 deletion x/compute/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func NewAppModule(keeper Keeper) AppModule {
}

// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 5 }
func (AppModule) ConsensusVersion() uint64 { return 6 }

func (am AppModule) RegisterServices(configurator module.Configurator) {
types.RegisterMsgServer(configurator.MsgServer(), keeper.NewMsgServerImpl(am.keeper))
Expand All @@ -118,6 +118,10 @@ func (am AppModule) RegisterServices(configurator module.Configurator) {
if err != nil {
panic(err)
}
err = configurator.RegisterMigration(types.ModuleName, 5, m.Migrate5to6)
if err != nil {
panic(err)
}
}

// InitGenesis performs genesis initialization for the compute module. It returns
Expand Down

0 comments on commit 5a82dc2

Please sign in to comment.