From 86de5011f27cfbca691fdd838c497939d9f32046 Mon Sep 17 00:00:00 2001 From: Nick DeLuca Date: Fri, 27 May 2022 16:31:28 -0700 Subject: [PATCH] Fix validate-genesis for kava 10 by updatine usdx debt limit to be valid (#1257) (#1258) --- migrate/v0_17/kava.go | 12 ++++++++++++ migrate/v0_17/migrate_test.go | 9 +++++++++ migrate/v0_17/testdata/genesis-v17.json | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/migrate/v0_17/kava.go b/migrate/v0_17/kava.go index 2de00933..932ec42e 100644 --- a/migrate/v0_17/kava.go +++ b/migrate/v0_17/kava.go @@ -19,6 +19,7 @@ import ( auctiontypes "github.com/kava-labs/kava/x/auction/types" v017bep3 "github.com/kava-labs/kava/x/bep3/legacy/v0_17" bep3types "github.com/kava-labs/kava/x/bep3/types" + cdptypes "github.com/kava-labs/kava/x/cdp/types" committeetypes "github.com/kava-labs/kava/x/committee/types" incentivetypes "github.com/kava-labs/kava/x/incentive/types" savingstypes "github.com/kava-labs/kava/x/savings/types" @@ -76,6 +77,17 @@ func migrateAppState(appState genutiltypes.AppMap, clientCtx client.Context) { authzState := authz.DefaultGenesisState() appState[authz.ModuleName] = codec.MustMarshalJSON(authzState) + // x/cdp + if appState[cdptypes.ModuleName] != nil { + var genState cdptypes.GenesisState + codec.MustUnmarshalJSON(appState[cdptypes.ModuleName], &genState) + + genState.Params.GlobalDebtLimit = sdk.NewCoin("usdx", sdk.NewInt(393000000000000)) + encodedState := codec.MustMarshalJSON(&genState) + + appState[cdptypes.ModuleName] = encodedState + } + // x/auction if appState[auctiontypes.ModuleName] != nil { var v16GenState v016auction.GenesisState diff --git a/migrate/v0_17/migrate_test.go b/migrate/v0_17/migrate_test.go index 49cb7e04..1dde6eeb 100644 --- a/migrate/v0_17/migrate_test.go +++ b/migrate/v0_17/migrate_test.go @@ -20,6 +20,7 @@ import ( feemarkettypes "github.com/tharsis/ethermint/x/feemarket/types" auctiontypes "github.com/kava-labs/kava/x/auction/types" + cdptypes "github.com/kava-labs/kava/x/cdp/types" evmutiltypes "github.com/kava-labs/kava/x/evmutil/types" incentivetypes "github.com/kava-labs/kava/x/incentive/types" savingstypes "github.com/kava-labs/kava/x/savings/types" @@ -68,6 +69,14 @@ func TestMigrateEvm(t *testing.T) { }, genstate.Params) } +func TestMigrateCDP(t *testing.T) { + appMap, ctx := migrateToV17AndGetAppMap(t) + var genstate cdptypes.GenesisState + err := ctx.Codec.UnmarshalJSON(appMap[cdptypes.ModuleName], &genstate) + assert.NoError(t, err) + assert.Equal(t, genstate.Params.GlobalDebtLimit, sdk.NewCoin("usdx", sdk.NewInt(393000000000000))) +} + func TestMigrateAuction(t *testing.T) { appMap, ctx := migrateToV17AndGetAppMap(t) var genstate auctiontypes.GenesisState diff --git a/migrate/v0_17/testdata/genesis-v17.json b/migrate/v0_17/testdata/genesis-v17.json index 1c802ac3..752890e5 100644 --- a/migrate/v0_17/testdata/genesis-v17.json +++ b/migrate/v0_17/testdata/genesis-v17.json @@ -639,7 +639,7 @@ "conversion_factor": "6", "debt_floor": "10000000" }, - "global_debt_limit": { "denom": "usdx", "amount": "43000000000000" }, + "global_debt_limit": { "denom": "usdx", "amount": "393000000000000" }, "surplus_auction_threshold": "500000000000", "surplus_auction_lot": "10000000000", "debt_auction_threshold": "100000000000",