Skip to content

Commit

Permalink
Problem: MsgModuleQuerySafe is not in allowed messages when upgrade (#…
Browse files Browse the repository at this point in the history
…1084)

* Problem: MsgModuleQuerySafe is not in allowed messages when upgrade

* fix

* Update app/upgrades.go

Signed-off-by: mmsqe <[email protected]>

* Apply suggestions from code review

Signed-off-by: mmsqe <[email protected]>

---------

Signed-off-by: mmsqe <[email protected]>
  • Loading branch information
mmsqe authored Oct 14, 2024
1 parent 63c867d commit 452e088
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [#1060](https://github.com/crypto-org-chain/chain-main/pull/1060) Upgrade rocksdb to `v9.2.1` and bump versiondb.
- [#1061](https://github.com/crypto-org-chain/chain-main/pull/1061) Integrate sdk 0.50.
- [#1068](https://github.com/crypto-org-chain/chain-main/pull/1068) Upgrade ibc-go to `v8.3.2` and remove icaauth module.
- [#1084](https://github.com/crypto-org-chain/chain-main/pull/1084) Add MsgModuleQuerySafe in allowed messages for ica host param.

*Dec 6, 2023*

Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ func New(
// upgrade.
app.setPostHandler()

app.RegisterUpgradeHandlers(app.appCodec, app.IBCKeeper.ClientKeeper)
app.RegisterUpgradeHandlers(app.appCodec)

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down
22 changes: 19 additions & 3 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@ package app
import (
"context"
"fmt"
"slices"

storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper"
)

func (app *ChainApp) RegisterUpgradeHandlers(cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) {
func (app *ChainApp) RegisterUpgradeHandlers(cdc codec.BinaryCodec) {
planName := "v5.0"
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx context.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
m, err := app.ModuleManager.RunMigrations(ctx, app.configurator, fromVM)
if err != nil {
return m, err
}
sdkCtx := sdk.UnwrapSDKContext(ctx)
{
params := app.ICAHostKeeper.GetParams(sdkCtx)
msg := "/ibc.applications.interchain_accounts.host.v1.MsgModuleQuerySafe"
if !slices.ContainsFunc(params.AllowMessages, func(allowMsg string) bool {
return allowMsg == "*" || allowMsg == msg
}) {
params.AllowMessages = append(params.AllowMessages, msg)
app.ICAHostKeeper.SetParams(sdkCtx, params)
}
}
return m, nil
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
Expand Down

0 comments on commit 452e088

Please sign in to comment.