From 9a2f5315d1f8b2f4ab1352e367f4ac53a5acb274 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Wed, 27 Sep 2023 09:28:08 +0800 Subject: [PATCH] fix migrate fix test fix lint test param --- integration_tests/test_upgrade.py | 1 + x/cronos/exported/exported.go | 2 +- x/cronos/migrations/v2/migrate.go | 6 ++++-- x/cronos/migrations/v2/migrate_test.go | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index 02f6100250..4513d141ab 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -186,6 +186,7 @@ def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory): rsp = cli.query_params("icaauth") assert rsp["params"]["min_timeout_duration"] == "3600s", rsp + assert cli.query_params()["max_callback_gas"] == "300000", rsp # migrate to sdk v0.47 custom_cronos.supervisorctl("stop", "all") diff --git a/x/cronos/exported/exported.go b/x/cronos/exported/exported.go index 000114e619..64dc23a561 100644 --- a/x/cronos/exported/exported.go +++ b/x/cronos/exported/exported.go @@ -13,6 +13,6 @@ type ( // // NOTE: This is used solely for migration of x/params managed parameters. Subspace interface { - GetParamSet(ctx sdk.Context, ps ParamSet) + GetParamSetIfExists(ctx sdk.Context, ps ParamSet) } ) diff --git a/x/cronos/migrations/v2/migrate.go b/x/cronos/migrations/v2/migrate.go index 438bca6a14..2f0a383a4c 100644 --- a/x/cronos/migrations/v2/migrate.go +++ b/x/cronos/migrations/v2/migrate.go @@ -13,12 +13,14 @@ import ( // module state. func Migrate(ctx sdk.Context, store sdk.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error { var currParams types.Params - legacySubspace.GetParamSet(ctx, &currParams) + legacySubspace.GetParamSetIfExists(ctx, &currParams) if err := currParams.Validate(); err != nil { return err } - + if currParams.GetMaxCallbackGas() == 0 { + currParams.MaxCallbackGas = types.MaxCallbackGasDefaultValue + } bz := cdc.MustMarshal(&currParams) store.Set(types.ParamsKey, bz) diff --git a/x/cronos/migrations/v2/migrate_test.go b/x/cronos/migrations/v2/migrate_test.go index aff338f375..5240f3f2fa 100644 --- a/x/cronos/migrations/v2/migrate_test.go +++ b/x/cronos/migrations/v2/migrate_test.go @@ -20,7 +20,7 @@ func newMockSubspace(ps types.Params) mockSubspace { return mockSubspace{ps: ps} } -func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) { +func (ms mockSubspace) GetParamSetIfExists(ctx sdk.Context, ps exported.ParamSet) { *ps.(*types.Params) = ms.ps }