From faa7a9c2fe219a27a42ce69e44738e4b429dec9a Mon Sep 17 00:00:00 2001 From: Masanori Yoshida Date: Wed, 11 Sep 2024 12:53:27 +0900 Subject: [PATCH] apply IBC_CHANNEL_UPGRADE_TIMEOUT patch to simd and improve test-channel-upgrade for tm2eth Signed-off-by: Masanori Yoshida --- tests/cases/docker-compose-test.yaml | 2 ++ .../cases/tm2eth/scripts/test-channel-upgrade | 23 ++++++++++--------- tests/chains/tendermint/simapp/app.go | 10 +++++++- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tests/cases/docker-compose-test.yaml b/tests/cases/docker-compose-test.yaml index 1eda9cd..524554a 100644 --- a/tests/cases/docker-compose-test.yaml +++ b/tests/cases/docker-compose-test.yaml @@ -39,11 +39,13 @@ services: container_name: tendermint-chain0-mock environment: USE_MOCK_CLIENT: 1 + IBC_CHANNEL_UPGRADE_TIMEOUT: 30000000000 tendermint-chain1-mock: <<: *tendermint-chain1 container_name: tendermint-chain1-mock environment: USE_MOCK_CLIENT: 1 + IBC_CHANNEL_UPGRADE_TIMEOUT: 30000000000 # Ethereum ethereum-geth0: diff --git a/tests/cases/tm2eth/scripts/test-channel-upgrade b/tests/cases/tm2eth/scripts/test-channel-upgrade index faca812..03e2159 100755 --- a/tests/cases/tm2eth/scripts/test-channel-upgrade +++ b/tests/cases/tm2eth/scripts/test-channel-upgrade @@ -181,18 +181,19 @@ checkResult orig mockapp-5 echo '##### case 8 #####' fields="$ALT_FIELDS --version mockapp-6" +$RLY tx channel-upgrade init ibc01 ibc0 $fields +$RLY eth upgrade propose ibc01 ibc1 $fields $TIMEOUT_FLAGS +$RLY tx channel-upgrade init ibc01 ibc1 $fields +retry 10 $RLY tx channel-upgrade execute ibc01 --target-src-state FLUSHCOMPLETE --target-dst-state FLUSHING +sleep 30 # ibc1 exceeds upgrade.timeout.timestamp +retry 10 $RLY tx channel-upgrade execute ibc01 # ibc0 <= chanUpgradeTimeout, ibc1 <= chanUpgradeCancel +checkResult orig mockapp-5 + +echo '##### case 9 #####' +$RLY tx channel-upgrade init ibc01 ibc0 $fields $RLY eth upgrade propose ibc01 ibc1 $fields --timeout-height 0-0 --timeout-timestamp `date -d 30sec +%s%N` $RLY tx channel-upgrade init ibc01 ibc1 $fields retry 10 $RLY tx channel-upgrade execute ibc01 --target-src-state FLUSHING --target-dst-state FLUSHING -sleep 30 # ibc0 exceeds upgrade.timeout.timestamp -retry 10 $RLY tx channel-upgrade execute ibc01 # ibc1 <= chanUpgradeTimeout, ibc0 <= chanUpgradeCancel +sleep 30 # Both chains exceed upgrade.timeout.timestamp +retry 10 $RLY tx channel-upgrade execute ibc01 # ibc0,ibc1 <= chanUpgradeTimeout checkResult orig mockapp-5 - -# echo '##### case 9 #####' -# $RLY tx channel-upgrade init ibc01 ibc0 $altSrcOpts -# $RLY eth upgrade propose ibc01 ibc1 $altDstOpts $TIMEOUT_FLAGS -# $RLY tx channel-upgrade init ibc01 ibc1 $altDstOpts -# retry 10 $RLY tx channel-upgrade execute ibc01 --target-src-state FLUSHING --target-dst-state FLUSHING -# sleep 20 # Both chains exceed upgrade.timeout.timestamp -# retry 10 $RLY tx channel-upgrade execute ibc01 # ibc0,ibc1 <= chanUpgradeTimeout -# checkResult orig diff --git a/tests/chains/tendermint/simapp/app.go b/tests/chains/tendermint/simapp/app.go index 80bf722..ee73ca1 100644 --- a/tests/chains/tendermint/simapp/app.go +++ b/tests/chains/tendermint/simapp/app.go @@ -6,6 +6,7 @@ import ( "io" "os" "path/filepath" + "strconv" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" @@ -896,8 +897,15 @@ func (app *SimApp) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*ab ibcGenesisState.ClientGenesis.Params.AllowedClients = append( ibcGenesisState.ClientGenesis.Params.AllowedClients, mockclienttypes.Mock) - genesisState[ibcexported.ModuleName] = app.appCodec.MustMarshalJSON(&ibcGenesisState) } + if upgTimeout := os.Getenv("IBC_CHANNEL_UPGRADE_TIMEOUT"); len(upgTimeout) > 0 { + upgTimeoutTimestampNsec, err := strconv.ParseInt(upgTimeout, 10, 64) + if err != nil { + panic(err) + } + ibcGenesisState.ChannelGenesis.Params.UpgradeTimeout.Timestamp = uint64(upgTimeoutTimestampNsec) + } + genesisState[ibcexported.ModuleName] = app.appCodec.MustMarshalJSON(&ibcGenesisState) } if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()); err != nil {