Skip to content

Commit a89bb2f

Browse files
ninabarbakadzeDimitrisJimdamiannolan
authored
feat: add version to the header (#6099)
* feat: add version to the header * chore: adding changelog --------- Co-authored-by: DimitrisJim <[email protected]> Co-authored-by: Damian Nolan <[email protected]>
1 parent bbf1066 commit a89bb2f

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ Ref: https://keepachangelog.com/en/1.0.0/
4848

4949
### Bug Fixes
5050

51+
## [v6.2.2](https://github.com/cosmos/ibc-go/releases/tag/v6.2.2) - 2024-05-06
52+
53+
### Improvements
54+
55+
* (testing) [\#https://github.com/cosmos/ibc-go/pull/6099](https://github.com/cosmos/ibc-go/pull/6099) Add `Version` to tendermint abci headers in ibctesting.
56+
5157
## [v6.2.1](https://github.com/cosmos/ibc-go/releases/tag/v6.2.1) - 2023-10-20
5258

5359
### Bug Fixes

testing/app.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
abci "github.com/tendermint/tendermint/abci/types"
2222
"github.com/tendermint/tendermint/libs/log"
2323
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
24+
"github.com/tendermint/tendermint/proto/tendermint/version"
2425
tmtypes "github.com/tendermint/tendermint/types"
2526
dbm "github.com/tendermint/tm-db"
2627

@@ -61,6 +62,10 @@ func SetupTestingApp() (TestingApp, map[string]json.RawMessage) {
6162
// of one consensus engine unit (10^6) in the default token of the simapp from first genesis
6263
// account. A Nop logger is set in SimApp.
6364
func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp {
65+
return SetupWithGenesisValSetAndConsensusParams(t, simapp.DefaultConsensusParams, valSet, genAccs, chainID, powerReduction, balances...)
66+
}
67+
68+
func SetupWithGenesisValSetAndConsensusParams(t *testing.T, consensusParams *abci.ConsensusParams, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp {
6469
app, genesisState := DefaultTestingAppInit()
6570

6671
// set genesis accounts
@@ -123,7 +128,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
123128
abci.RequestInitChain{
124129
ChainId: chainID,
125130
Validators: []abci.ValidatorUpdate{},
126-
ConsensusParams: simapp.DefaultConsensusParams,
131+
ConsensusParams: consensusParams,
127132
AppStateBytes: stateBytes,
128133
},
129134
)
@@ -133,6 +138,9 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
133138
app.BeginBlock(
134139
abci.RequestBeginBlock{
135140
Header: tmproto.Header{
141+
Version: version.Consensus{
142+
App: consensusParams.Version.AppVersion,
143+
},
136144
ChainID: chainID,
137145
Height: app.LastBlockHeight() + 1,
138146
AppHash: app.LastCommitID().Hash,

testing/chain.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ func NewTestChainWithValSet(t *testing.T, coord *Coordinator, chainID string, va
124124

125125
// create current header and call begin block
126126
header := tmproto.Header{
127+
Version: tmprotoversion.Consensus{
128+
App: simapp.DefaultAppVersion,
129+
},
127130
ChainID: chainID,
128131
Height: 1,
129132
Time: coord.CurrentTime.UTC(),
@@ -285,6 +288,7 @@ func (chain *TestChain) NextBlock() {
285288
chain.CurrentHeader = tmproto.Header{
286289
ChainID: chain.ChainID,
287290
Height: chain.App.LastBlockHeight() + 1,
291+
Version: chain.CurrentHeader.Version,
288292
AppHash: chain.App.LastCommitID().Hash,
289293
// NOTE: the time is increased by the coordinator to maintain time synchrony amongst
290294
// chains.
@@ -456,7 +460,7 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64,
456460
nextValHash := nextVals.Hash()
457461

458462
tmHeader := tmtypes.Header{
459-
Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2},
463+
Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: simapp.DefaultAppVersion},
460464
ChainID: chainID,
461465
Height: blockHeight,
462466
Time: timestamp,

testing/simapp/test_helpers.go

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import (
3434
"github.com/cosmos/ibc-go/v6/testing/simapp/helpers"
3535
)
3636

37+
var DefaultAppVersion uint64 = 1
38+
3739
// DefaultConsensusParams defines the default Tendermint consensus params used in
3840
// SimApp testing.
3941
var DefaultConsensusParams = &abci.ConsensusParams{
@@ -51,6 +53,9 @@ var DefaultConsensusParams = &abci.ConsensusParams{
5153
tmtypes.ABCIPubKeyTypeEd25519,
5254
},
5355
},
56+
Version: &tmproto.VersionParams{
57+
AppVersion: DefaultAppVersion,
58+
},
5459
}
5560

5661
func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) {

0 commit comments

Comments
 (0)