diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d65308beab..cf6c1d6f7bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * (apps/27-interchain-accounts) [\#6147](https://github.com/cosmos/ibc-go/pull/6147) Emit an event signalling that the host submodule is disabled. +* (testing) [\#6180](https://github.com/cosmos/ibc-go/pull/6180) Add version to tm abci headers in ibctesting. ### Features diff --git a/testing/app.go b/testing/app.go index 0df23c4312a..bf97e4248bb 100644 --- a/testing/app.go +++ b/testing/app.go @@ -10,6 +10,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version" tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" @@ -62,6 +63,10 @@ func SetupTestingApp() (TestingApp, map[string]json.RawMessage) { // of one consensus engine unit (10^6) in the default token of the simapp from first genesis // account. A Nop logger is set in SimApp. func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp { + return SetupWithGenesisValSetAndConsensusParams(t, simapp.DefaultConsensusParams, valSet, genAccs, chainID, powerReduction, balances...) +} + +func SetupWithGenesisValSetAndConsensusParams(t *testing.T, consensusParams *tmproto.ConsensusParams, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp { app, genesisState := DefaultTestingAppInit() // ensure baseapp has a chain-id set before running InitChain @@ -136,6 +141,9 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs app.BeginBlock( abci.RequestBeginBlock{ Header: tmproto.Header{ + Version: tmprotoversion.Consensus{ + App: consensusParams.Version.App, + }, ChainID: chainID, Height: app.LastBlockHeight() + 1, AppHash: app.LastCommitID().Hash, diff --git a/testing/chain.go b/testing/chain.go index 3c60aa86d39..b34003adc2d 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -128,6 +128,9 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, chainID string, va // create current header and call begin block header := tmproto.Header{ + Version: tmprotoversion.Consensus{ + App: simapp.DefaultAppVersion, + }, ChainID: chainID, Height: 1, Time: coord.CurrentTime.UTC(), @@ -296,6 +299,7 @@ func (chain *TestChain) NextBlock() { chain.CurrentHeader = tmproto.Header{ ChainID: chain.ChainID, Height: chain.App.LastBlockHeight() + 1, + Version: chain.CurrentHeader.Version, AppHash: chain.App.LastCommitID().Hash, // NOTE: the time is increased by the coordinator to maintain time synchrony amongst // chains. @@ -476,7 +480,7 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, nextValHash := nextVals.Hash() tmHeader := tmtypes.Header{ - Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2}, + Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: simapp.DefaultAppVersion}, ChainID: chainID, Height: blockHeight, Time: timestamp, diff --git a/testing/simapp/test_helpers.go b/testing/simapp/test_helpers.go index 6c61a000727..48d93cd5c47 100644 --- a/testing/simapp/test_helpers.go +++ b/testing/simapp/test_helpers.go @@ -27,6 +27,8 @@ import ( "github.com/cosmos/ibc-go/v7/testing/mock" ) +var DefaultAppVersion uint64 = 1 + // DefaultConsensusParams defines the default Tendermint consensus params used in // SimApp testing. var DefaultConsensusParams = &tmproto.ConsensusParams{ @@ -44,6 +46,9 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{ tmtypes.ABCIPubKeyTypeEd25519, }, }, + Version: &tmproto.VersionParams{ + App: DefaultAppVersion, + }, } func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {