Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imp: add version to tm headers in ibctesting (release/v7.5.x) #6180

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions testing/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions testing/simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -44,6 +46,9 @@ var DefaultConsensusParams = &tmproto.ConsensusParams{
tmtypes.ABCIPubKeyTypeEd25519,
},
},
Version: &tmproto.VersionParams{
App: DefaultAppVersion,
},
}

func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {
Expand Down
Loading