-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dev/ica_host
- Loading branch information
Showing
8 changed files
with
381 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package v9 | ||
|
||
import ( | ||
"fmt" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
ibcchanneltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" | ||
) | ||
|
||
// MsgFilterDecorator defines an AnteHandler decorator for the v9 upgrade that | ||
// provide height-gated message filtering acceptance. | ||
type MsgFilterDecorator struct{} | ||
|
||
// AnteHandle performs an AnteHandler check that returns an error if the tx contains a message | ||
// that is blocked. | ||
// Right now, we block MsgTimeoutOnClose due to incorrect behavior that could occur if a packet is re-enabled. | ||
func (mfd MsgFilterDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { | ||
if hasInvalidMsgs(tx.GetMsgs()) { | ||
currHeight := ctx.BlockHeight() | ||
return ctx, fmt.Errorf("tx contains unsupported message types at height %d", currHeight) | ||
} | ||
|
||
return next(ctx, tx, simulate) | ||
} | ||
|
||
func hasInvalidMsgs(msgs []sdk.Msg) bool { | ||
for _, msg := range msgs { | ||
switch msg.(type) { | ||
case *ibcchanneltypes.MsgTimeoutOnClose: | ||
return true | ||
} | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package v9_test | ||
|
||
import ( | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
ibcchanneltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" | ||
|
||
"github.com/osmosis-labs/osmosis/v7/app" | ||
v8 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v8" | ||
v9 "github.com/osmosis-labs/osmosis/v7/app/upgrades/v9" | ||
) | ||
|
||
func noOpAnteDecorator() sdk.AnteHandler { | ||
return func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) { | ||
return ctx, nil | ||
} | ||
} | ||
|
||
func TestMsgFilterDecorator(t *testing.T) { | ||
handler := v9.MsgFilterDecorator{} | ||
txCfg := app.MakeEncodingConfig().TxConfig | ||
|
||
addr1 := sdk.AccAddress([]byte("addr1_______________")) | ||
addr2 := sdk.AccAddress([]byte("addr2_______________")) | ||
|
||
testCases := []struct { | ||
name string | ||
ctx sdk.Context | ||
msgs []sdk.Msg | ||
expectErr bool | ||
}{ | ||
{ | ||
name: "valid tx", | ||
ctx: sdk.Context{}.WithBlockHeight(v8.UpgradeHeight - 1), | ||
msgs: []sdk.Msg{ | ||
banktypes.NewMsgSend(addr1, addr2, sdk.NewCoins(sdk.NewInt64Coin("foo", 5))), | ||
}, | ||
expectErr: false, | ||
}, | ||
{ | ||
name: "invalid tx", | ||
ctx: sdk.Context{}.WithBlockHeight(v8.UpgradeHeight), | ||
msgs: []sdk.Msg{ | ||
banktypes.NewMsgSend(addr1, addr2, sdk.NewCoins(sdk.NewInt64Coin("foo", 5))), | ||
&ibcchanneltypes.MsgTimeoutOnClose{}, | ||
}, | ||
expectErr: true, | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
tc := tc | ||
|
||
t.Run(tc.name, func(t *testing.T) { | ||
txBuilder := txCfg.NewTxBuilder() | ||
require.NoError(t, txBuilder.SetMsgs(tc.msgs...)) | ||
|
||
_, err := handler.AnteHandle(tc.ctx, txBuilder.GetTx(), false, noOpAnteDecorator()) | ||
if tc.expectErr { | ||
require.Error(t, err) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package docker | ||
|
||
// ImageConfig contains all images and their respective tags | ||
// needed for running e2e tests. | ||
type ImageConfig struct { | ||
InitRepository string | ||
InitTag string | ||
|
||
OsmosisRepository string | ||
OsmosisTag string | ||
|
||
RelayerRepository string | ||
RelayerTag string | ||
} | ||
|
||
const ( | ||
// Local osmosis repo/version. | ||
// It is used when skipping upgrade by setting OSMOSIS_E2E_SKIP_UPGRADE to true). | ||
// This image should be pre-built with `make docker-build-debug` either in CI or locally. | ||
LocalOsmoRepository = "osmosis" | ||
LocalOsmoTag = "debug" | ||
// Local osmosis repo/version for osmosis initialization. | ||
// It is used when skipping upgrade by setting OSMOSIS_E2E_SKIP_UPGRADE to true). | ||
// This image should be pre-built with `make docker-build-e2e-chain-init` either in CI or locally. | ||
localInitRepository = "osmosis-e2e-chain-init" | ||
localInitTag = "debug" | ||
// Pre-upgrade osmosis repo/tag to pull. | ||
// It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset | ||
// for this functionality to be used. | ||
previousVersionOsmoRepository = "osmolabs/osmosis-dev" | ||
previousVersionOsmoTag = "v8.0.0-debug" | ||
// Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion) | ||
previousVersionInitRepository = "osmolabs/osmosis-init" | ||
previousVersionInitTag = "v8.0.0" | ||
// Hermes repo/version for relayer | ||
relayerRepository = "osmolabs/hermes" | ||
relayerTag = "0.13.0" | ||
) | ||
|
||
// Returns ImageConfig needed for running e2e test. | ||
// If isUpgrade is true, returns images for running the upgrade | ||
// Otherwise, returns images for running non-upgrade e2e tests. | ||
func NewImageConfig(isUpgrade bool) *ImageConfig { | ||
config := &ImageConfig{ | ||
RelayerRepository: relayerRepository, | ||
RelayerTag: relayerTag, | ||
} | ||
|
||
if isUpgrade { | ||
config.InitRepository = previousVersionInitRepository | ||
config.InitTag = previousVersionInitTag | ||
|
||
config.OsmosisRepository = previousVersionOsmoRepository | ||
config.OsmosisTag = previousVersionOsmoTag | ||
} else { | ||
config.InitRepository = localInitRepository | ||
config.InitTag = localInitTag | ||
|
||
config.OsmosisRepository = LocalOsmoRepository | ||
config.OsmosisTag = LocalOsmoTag | ||
} | ||
|
||
return config | ||
} |
Oops, something went wrong.