Skip to content

Commit

Permalink
feat: add ica authorized messages in upgrade handler (#5380)
Browse files Browse the repository at this point in the history
* add ica auth messages

* append instead

* check if message is in list before adding

* updates

---------

Co-authored-by: Roman <[email protected]>
  • Loading branch information
czarcas7ic and p0mvn authored Jun 2, 2023
1 parent 1dcacd7 commit 692462a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
26 changes: 24 additions & 2 deletions app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
"github.com/osmosis-labs/osmosis/v15/app/keepers"
"github.com/osmosis-labs/osmosis/v15/app/upgrades"

distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
cosmwasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"

cltypes "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types"
superfluidtypes "github.com/osmosis-labs/osmosis/v15/x/superfluid/types"
Expand Down Expand Up @@ -77,6 +78,27 @@ func CreateUpgradeHandler(
return nil, err
}

// Add both MsgExecuteContract and MsgInstantiateContract to the list of allowed messages.
hostParams := keepers.ICAHostKeeper.GetParams(ctx)
msgExecuteContractExists := false
msgInstantiateContractExists := false
for _, msg := range hostParams.AllowMessages {
if msg == sdk.MsgTypeURL(&cosmwasmtypes.MsgExecuteContract{}) {
msgExecuteContractExists = true
}
if msg == sdk.MsgTypeURL(&cosmwasmtypes.MsgInstantiateContract{}) {
msgInstantiateContractExists = true
}
}
if !msgExecuteContractExists {
hostParams.AllowMessages = append(hostParams.AllowMessages, sdk.MsgTypeURL(&cosmwasmtypes.MsgExecuteContract{}))
}

if !msgInstantiateContractExists {
hostParams.AllowMessages = append(hostParams.AllowMessages, sdk.MsgTypeURL(&cosmwasmtypes.MsgInstantiateContract{}))
}
keepers.ICAHostKeeper.SetParams(ctx, hostParams)

// Although parameters are set on InitGenesis() in RunMigrations(), we reset them here
// for visibility of the final configuration.
defaultConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx)
Expand All @@ -98,7 +120,7 @@ func CreateUpgradeHandler(
// Create a position to initialize the balancerPool.

// Get community pool and DAI/OSMO pool address.
communityPoolAddress := keepers.AccountKeeper.GetModuleAddress(distributiontypes.ModuleName)
communityPoolAddress := keepers.AccountKeeper.GetModuleAddress(distrtypes.ModuleName)
daiOsmoPool, err := keepers.PoolManagerKeeper.GetPool(ctx, DaiOsmoPoolId)
if err != nil {
return nil, err
Expand Down
6 changes: 6 additions & 0 deletions app/upgrades/v16/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"testing"

cosmwasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/cosmos-sdk/store/prefix"
Expand Down Expand Up @@ -123,6 +124,11 @@ func (suite *UpgradeTestSuite) TestUpgrade() {

// Ensure that the protorev upgrade was successful
verifyProtorevUpdateSuccess(suite)

// Validate MsgExecuteContract and MsgInstantiateContract were added to the whitelist
icaHostAllowList := suite.App.ICAHostKeeper.GetParams(suite.Ctx)
suite.Require().Contains(icaHostAllowList.AllowMessages, sdk.MsgTypeURL(&cosmwasmtypes.MsgExecuteContract{}))
suite.Require().Contains(icaHostAllowList.AllowMessages, sdk.MsgTypeURL(&cosmwasmtypes.MsgInstantiateContract{}))
},
func() {
// Validate that tokenfactory params have been updated
Expand Down

0 comments on commit 692462a

Please sign in to comment.