Skip to content

Commit

Permalink
feat: add version to the header (#6099)
Browse files Browse the repository at this point in the history
* feat: add version to the header

* chore: adding changelog

---------

Co-authored-by: DimitrisJim <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
  • Loading branch information
3 people authored May 6, 2024
1 parent bbf1066 commit a89bb2f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Bug Fixes

## [v6.2.2](https://github.com/cosmos/ibc-go/releases/tag/v6.2.2) - 2024-05-06

### Improvements

* (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.

## [v6.2.1](https://github.com/cosmos/ibc-go/releases/tag/v6.2.1) - 2023-10-20

### Bug Fixes
Expand Down
10 changes: 9 additions & 1 deletion testing/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"github.com/tendermint/tendermint/proto/tendermint/version"
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

Expand Down Expand Up @@ -61,6 +62,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 *abci.ConsensusParams, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp {
app, genesisState := DefaultTestingAppInit()

// set genesis accounts
Expand Down Expand Up @@ -123,7 +128,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
abci.RequestInitChain{
ChainId: chainID,
Validators: []abci.ValidatorUpdate{},
ConsensusParams: simapp.DefaultConsensusParams,
ConsensusParams: consensusParams,
AppStateBytes: stateBytes,
},
)
Expand All @@ -133,6 +138,9 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
app.BeginBlock(
abci.RequestBeginBlock{
Header: tmproto.Header{
Version: version.Consensus{
App: consensusParams.Version.AppVersion,
},
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 @@ -124,6 +124,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 @@ -285,6 +288,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 @@ -456,7 +460,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 @@ -34,6 +34,8 @@ import (
"github.com/cosmos/ibc-go/v6/testing/simapp/helpers"
)

var DefaultAppVersion uint64 = 1

// DefaultConsensusParams defines the default Tendermint consensus params used in
// SimApp testing.
var DefaultConsensusParams = &abci.ConsensusParams{
Expand All @@ -51,6 +53,9 @@ var DefaultConsensusParams = &abci.ConsensusParams{
tmtypes.ABCIPubKeyTypeEd25519,
},
},
Version: &tmproto.VersionParams{
AppVersion: DefaultAppVersion,
},
}

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

0 comments on commit a89bb2f

Please sign in to comment.