Skip to content

Commit

Permalink
[Bump] sdk version to v0.43.0-rc0 (#507)
Browse files Browse the repository at this point in the history
* bump sdk version to v0.43.0-rc0

* reuse app creator

* fix estimate_fee request interface unpacker

* remove unused files

* remove unused files

* fix to use new app config at testnet launch

* register all message amino codec to legacy.Cdc because authz module use this to get signbytes

* prevent register codec multiple times

* update cosmos proto for swagger update

* register feegrant amino codec to support legacy service

* change upgrade name to use -rc0
  • Loading branch information
yys authored Jul 12, 2021
1 parent 1a0c58e commit a2471e3
Show file tree
Hide file tree
Showing 38 changed files with 1,586 additions and 415 deletions.
11 changes: 5 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ import (
customcrisis "github.com/terra-money/core/custom/crisis"
customdistr "github.com/terra-money/core/custom/distribution"
customevidence "github.com/terra-money/core/custom/evidence"
customfeegrant "github.com/terra-money/core/custom/feegrant"
customgov "github.com/terra-money/core/custom/gov"
custommint "github.com/terra-money/core/custom/mint"
customparams "github.com/terra-money/core/custom/params"
Expand Down Expand Up @@ -169,7 +170,7 @@ var (
customparams.AppModuleBasic{},
customcrisis.AppModuleBasic{},
customslashing.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
customfeegrant.AppModuleBasic{},
ibc.AppModuleBasic{},
customupgrade.AppModuleBasic{},
customevidence.AppModuleBasic{},
Expand Down Expand Up @@ -346,8 +347,9 @@ func NewTerraApp(
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)

// clear SoftwareUpgradeProposal
app.UpgradeKeeper.SetUpgradeHandler("v0.5.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
app.UpgradeKeeper.SetUpgradeHandler("v0.5.0-rc0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// Just pass current version map, no migration required
return app.mm.RunMigrations(ctx, app.configurator, app.mm.GetVersionMap())
})

// register the staking hooks
Expand Down Expand Up @@ -609,9 +611,6 @@ func (app *TerraApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abc
panic(err)
}

// store initial module version maps to upgrade keeper
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())

return app.mm.InitGenesis(ctx, app.appCodec, genesisState)
}

Expand Down
12 changes: 12 additions & 0 deletions app/encoding.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
package app

import (
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/std"

"github.com/terra-money/core/app/params"
)

var legacyCodecRegistered = false

// MakeEncodingConfig creates an EncodingConfig for testing
func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)
ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)

if !legacyCodecRegistered {
// authz module use this codec to get signbytes.
// authz MsgExec can execute all message types,
// so legacy.Cdc need to register all amino messages to get proper signature
ModuleBasics.RegisterLegacyAminoCodec(legacy.Cdc)
legacyCodecRegistered = true
}

return encodingConfig
}
18 changes: 9 additions & 9 deletions app/legacy/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ $ terrad migrate /path/to/genesis.json --chain-id=cosmoshub-4 --genesis-time=201

var bankGenesis banktypes.GenesisState

clientCtx.JSONCodec.MustUnmarshalJSON(newGenState[banktypes.ModuleName], &bankGenesis)
clientCtx.Codec.MustUnmarshalJSON(newGenState[banktypes.ModuleName], &bankGenesis)

var oracleGenesis oracletypes.GenesisState
clientCtx.JSONCodec.MustUnmarshalJSON(newGenState[oracletypes.ModuleName], &oracleGenesis)
clientCtx.Codec.MustUnmarshalJSON(newGenState[oracletypes.ModuleName], &oracleGenesis)

// Register whitelist denom list
denomMetadata := make([]banktypes.Metadata, len(oracleGenesis.Params.Whitelist)+1)
Expand Down Expand Up @@ -119,11 +119,11 @@ $ terrad migrate /path/to/genesis.json --chain-id=cosmoshub-4 --genesis-time=201
}

bankGenesis.DenomMetadata = denomMetadata
newGenState[banktypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&bankGenesis)
newGenState[banktypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(&bankGenesis)

var stakingGenesis staking.GenesisState

clientCtx.JSONCodec.MustUnmarshalJSON(newGenState[staking.ModuleName], &stakingGenesis)
clientCtx.Codec.MustUnmarshalJSON(newGenState[staking.ModuleName], &stakingGenesis)

ibcTransferGenesis := ibcxfertypes.DefaultGenesisState()
ibcCoreGenesis := ibccoretypes.DefaultGenesisState()
Expand All @@ -136,11 +136,11 @@ $ terrad migrate /path/to/genesis.json --chain-id=cosmoshub-4 --genesis-time=201
ibcCoreGenesis.ClientGenesis.Params.AllowedClients = []string{exported.Tendermint}
stakingGenesis.Params.HistoricalEntries = 10000

newGenState[ibcxfertypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(ibcTransferGenesis)
newGenState[host.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(ibcCoreGenesis)
newGenState[captypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(capGenesis)
newGenState[evtypes.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(evGenesis)
newGenState[staking.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&stakingGenesis)
newGenState[ibcxfertypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(ibcTransferGenesis)
newGenState[host.ModuleName] = clientCtx.Codec.MustMarshalJSON(ibcCoreGenesis)
newGenState[captypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(capGenesis)
newGenState[evtypes.ModuleName] = clientCtx.Codec.MustMarshalJSON(evGenesis)
newGenState[staking.ModuleName] = clientCtx.Codec.MustMarshalJSON(&stakingGenesis)

genDoc.AppState, err = json.Marshal(newGenState)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions app/legacy/pubkey_replacement.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func loadKeydataFromFile(clientCtx client.Context, replacementrJSON string, genD
var stakingGenesis staking.GenesisState
var slashingGenesis slashing.GenesisState

clientCtx.JSONCodec.MustUnmarshalJSON(state[staking.ModuleName], &stakingGenesis)
clientCtx.JSONCodec.MustUnmarshalJSON(state[slashing.ModuleName], &slashingGenesis)
clientCtx.Codec.MustUnmarshalJSON(state[staking.ModuleName], &stakingGenesis)
clientCtx.Codec.MustUnmarshalJSON(state[slashing.ModuleName], &slashingGenesis)

for i, val := range stakingGenesis.Validators {
idx, replacement := replacementKeys.isReplacedValidator(val.OperatorAddress)
Expand All @@ -71,7 +71,7 @@ func loadKeydataFromFile(clientCtx client.Context, replacementrJSON string, genD
toReplaceValConsAddress, _ := val.GetConsAddr()

var consPubKey cryptotypes.PubKey
if err := clientCtx.JSONCodec.UnmarshalInterfaceJSON([]byte(replacement.ConsensusPubkey), &consPubKey); err != nil {
if err := clientCtx.Codec.UnmarshalInterfaceJSON([]byte(replacement.ConsensusPubkey), &consPubKey); err != nil {
log.Fatal(fmt.Errorf("failed to decode key:%s %w", replacement.ConsensusPubkey, err))
}

Expand Down Expand Up @@ -109,8 +109,8 @@ func loadKeydataFromFile(clientCtx client.Context, replacementrJSON string, genD
}

}
state[staking.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&stakingGenesis)
state[slashing.ModuleName] = clientCtx.JSONCodec.MustMarshalJSON(&slashingGenesis)
state[staking.ModuleName] = clientCtx.Codec.MustMarshalJSON(&stakingGenesis)
state[slashing.ModuleName] = clientCtx.Codec.MustMarshalJSON(&slashingGenesis)

genDoc.AppState, err = json.Marshal(state)

Expand Down
5 changes: 2 additions & 3 deletions app/legacy/v05/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/legacy/v040"
v038staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v038"
v040staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v040"
v043staking "github.com/cosmos/cosmos-sdk/x/staking/legacy/v043"

v039authcustom "github.com/terra-money/core/custom/auth/legacy/v039"
v040authcustom "github.com/terra-money/core/custom/auth/legacy/v040"
Expand Down Expand Up @@ -65,7 +64,7 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {
v036paramscustom.RegisterLegacyAminoCodec(v04Codec)
v038upgradecustom.RegisterLegacyAminoCodec(v04Codec)

v05Codec := clientCtx.JSONCodec
v05Codec := clientCtx.Codec

if appState[v038bank.ModuleName] != nil {
// unmarshal relative source genesis application state
Expand Down Expand Up @@ -214,7 +213,7 @@ func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap {

// Migrate relative source genesis application state and marshal it into
// the respective key.
appState[v040staking.ModuleName] = v05Codec.MustMarshalJSON(v043staking.MigrateJSON(v040staking.Migrate(stakingGenState)))
appState[v040staking.ModuleName] = v05Codec.MustMarshalJSON(v040staking.Migrate(stakingGenState))
}

// Migrate x/genutil
Expand Down
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

Loading

0 comments on commit a2471e3

Please sign in to comment.