Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
64 changes: 32 additions & 32 deletions testing/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import (

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/crypto/tmhash"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version"
tmtypes "github.com/cometbft/cometbft/types"
tmversion "github.com/cometbft/cometbft/version"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtprotoversion "github.com/cometbft/cometbft/proto/tendermint/version"
cmttypes "github.com/cometbft/cometbft/types"
cmtversion "github.com/cometbft/cometbft/version"

capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
Expand Down Expand Up @@ -57,21 +57,21 @@ type TestChain struct {
Coordinator *Coordinator
App TestingApp
ChainID string
LastHeader *ibctm.Header // header for last block height committed
CurrentHeader tmproto.Header // header for current block height
LastHeader *ibctm.Header // header for last block height committed
CurrentHeader cmtproto.Header // header for current block height
QueryServer types.QueryServer
TxConfig client.TxConfig
Codec codec.BinaryCodec

Vals *tmtypes.ValidatorSet
NextVals *tmtypes.ValidatorSet
Vals *cmttypes.ValidatorSet
NextVals *cmttypes.ValidatorSet

// Signers is a map from validator address to the PrivValidator
// The map is converted into an array that is the same order as the validators right before signing commit
// This ensures that signers will always be in correct order even as validator powers change.
// If a test adds a new validator after chain creation, then the signer map must be updated to include
// the new PrivValidator entry.
Signers map[string]tmtypes.PrivValidator
Signers map[string]cmttypes.PrivValidator

// autogenerated sender private key
SenderPrivKey cryptotypes.PrivKey
Expand Down Expand Up @@ -99,7 +99,7 @@ type TestChain struct {
//
// CONTRACT: Validator array must be provided in the order expected by Tendermint.
// i.e. sorted first by power and then lexicographically by address.
func NewTestChainWithValSet(tb testing.TB, coord *Coordinator, chainID string, valSet *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator) *TestChain {
func NewTestChainWithValSet(tb testing.TB, coord *Coordinator, chainID string, valSet *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *TestChain {
tb.Helper()
genAccs := []authtypes.GenesisAccount{}
genBals := []banktypes.Balance{}
Expand Down Expand Up @@ -132,7 +132,7 @@ func NewTestChainWithValSet(tb testing.TB, coord *Coordinator, chainID string, v
app := SetupWithGenesisValSet(tb, valSet, genAccs, chainID, sdk.DefaultPowerReduction, genBals...)

// create current header and call begin block
header := tmproto.Header{
header := cmtproto.Header{
ChainID: chainID,
Height: 1,
Time: coord.CurrentTime.UTC(),
Expand Down Expand Up @@ -170,22 +170,22 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string) *TestChain {
// generate validators private/public key
var (
validatorsPerChain = 4
validators []*tmtypes.Validator
signersByAddress = make(map[string]tmtypes.PrivValidator, validatorsPerChain)
validators []*cmttypes.Validator
signersByAddress = make(map[string]cmttypes.PrivValidator, validatorsPerChain)
)

for i := 0; i < validatorsPerChain; i++ {
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey()
require.NoError(t, err)
validators = append(validators, tmtypes.NewValidator(pubKey, 1))
validators = append(validators, cmttypes.NewValidator(pubKey, 1))
signersByAddress[pubKey.Address().String()] = privVal
}

// construct validator set;
// Note that the validators are sorted by voting power
// or, if equal, by address lexical order
valSet := tmtypes.NewValidatorSet(validators)
valSet := cmttypes.NewValidatorSet(validators)

return NewTestChainWithValSet(t, coord, chainID, valSet, signersByAddress)
}
Expand Down Expand Up @@ -299,7 +299,7 @@ func (chain *TestChain) NextBlock() {
chain.NextVals = ApplyValSetChanges(chain.TB, chain.Vals, res.ValidatorUpdates)

// increment the current header
chain.CurrentHeader = tmproto.Header{
chain.CurrentHeader = cmtproto.Header{
ChainID: chain.ChainID,
Height: chain.App.LastBlockHeight() + 1,
AppHash: chain.App.LastCommitID().Hash,
Expand Down Expand Up @@ -375,7 +375,7 @@ func (chain *TestChain) GetConsensusState(clientID string, height exported.Heigh

// GetValsAtHeight will return the validator set of the chain at a given height. It will return
// a success boolean depending on if the validator set exists or not at that height.
func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bool) {
func (chain *TestChain) GetValsAtHeight(height int64) (*cmttypes.ValidatorSet, bool) {
histInfo, ok := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height)
if !ok {
return nil, false
Expand All @@ -387,7 +387,7 @@ func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bo
if err != nil {
panic(err)
}
return tmtypes.NewValidatorSet(tmValidators), true
return cmttypes.NewValidatorSet(tmValidators), true
}

// GetAcknowledgement retrieves an acknowledgement for the provided packet. If the
Expand Down Expand Up @@ -419,7 +419,7 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa
trustedHeight = chain.GetClientState(clientID).GetLatestHeight().(clienttypes.Height)
}
var (
tmTrustedVals *tmtypes.ValidatorSet
tmTrustedVals *cmttypes.ValidatorSet
ok bool
)
// Once we get TrustedHeight from client, we must query the validators from the counterparty chain
Expand Down Expand Up @@ -464,15 +464,15 @@ func (chain *TestChain) CurrentTMClientHeader() *ibctm.Header {

// CreateTMClientHeader creates a TM header to update the TM client. Args are passed in to allow
// caller flexibility to use params that differ from the chain.
func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, nextVals, tmTrustedVals *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator) *ibctm.Header {
func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, nextVals, tmTrustedVals *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *ibctm.Header {
var (
valSet *tmproto.ValidatorSet
trustedVals *tmproto.ValidatorSet
valSet *cmtproto.ValidatorSet
trustedVals *cmtproto.ValidatorSet
)
require.NotNil(chain.TB, tmValSet)

tmHeader := tmtypes.Header{
Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2},
tmHeader := cmttypes.Header{
Version: cmtprotoversion.Consensus{Block: cmtversion.BlockProtocol, App: 2},
ChainID: chainID,
Height: blockHeight,
Time: timestamp,
Expand All @@ -490,20 +490,20 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64,

hhash := tmHeader.Hash()
blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set")))
voteSet := tmtypes.NewVoteSet(chainID, blockHeight, 1, tmproto.PrecommitType, tmValSet)
voteSet := cmttypes.NewVoteSet(chainID, blockHeight, 1, cmtproto.PrecommitType, tmValSet)

// MakeCommit expects a signer array in the same order as the validator array.
// Thus we iterate over the ordered validator set and construct a signer array
// from the signer map in the same order.
var signerArr []tmtypes.PrivValidator //nolint:prealloc // using prealloc here would be needlessly complex
var signerArr []cmttypes.PrivValidator //nolint:prealloc // using prealloc here would be needlessly complex
for _, v := range tmValSet.Validators { //nolint:staticcheck // need to check for nil validator set
signerArr = append(signerArr, signers[v.Address.String()])
}

commit, err := tmtypes.MakeCommit(blockID, blockHeight, 1, voteSet, signerArr, timestamp)
commit, err := cmttypes.MakeCommit(blockID, blockHeight, 1, voteSet, signerArr, timestamp)
require.NoError(chain.TB, err)

signedHeader := &tmproto.SignedHeader{
signedHeader := &cmtproto.SignedHeader{
Header: tmHeader.ToProto(),
Commit: commit.ToProto(),
}
Expand All @@ -528,11 +528,11 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64,
}
}

// MakeBlockID copied unimported test functions from tmtypes to use them here
func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.BlockID {
return tmtypes.BlockID{
// MakeBlockID copied unimported test functions from cmttypes to use them here
func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) cmttypes.BlockID {
return cmttypes.BlockID{
Hash: hash,
PartSetHeader: tmtypes.PartSetHeader{
PartSetHeader: cmttypes.PartSetHeader{
Total: partSetSize,
Hash: partSetHash,
},
Expand Down
8 changes: 4 additions & 4 deletions testing/simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"

dbm "github.com/cometbft/cometbft-db"
tmcfg "github.com/cometbft/cometbft/config"
cmtcfg "github.com/cometbft/cometbft/config"
"github.com/cometbft/cometbft/libs/log"

"github.com/cosmos/ibc-go/v7/testing/simapp"
Expand Down Expand Up @@ -91,9 +91,9 @@ func NewRootCmd() *cobra.Command {
}

// initTendermintConfig helps to override default Tendermint Config values.
// return tmcfg.DefaultConfig if no custom configuration is required for the application.
func initTendermintConfig() *tmcfg.Config {
cfg := tmcfg.DefaultConfig()
// return cmtcfg.DefaultConfig if no custom configuration is required for the application.
func initTendermintConfig() *cmtcfg.Config {
cfg := cmtcfg.DefaultConfig()

// these values put a higher strain on node memory
// cfg.P2P.MaxNumInboundPeers = 100
Expand Down
8 changes: 4 additions & 4 deletions testing/simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
tmtypes "github.com/cometbft/cometbft/types"
cmttypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/ibc-go/v7/testing/mock"
)
Expand Down Expand Up @@ -61,8 +61,8 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp {
require.NoError(t, err)

// create validator set with single validator
validator := tmtypes.NewValidator(pubKey, 1)
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
validator := cmttypes.NewValidator(pubKey, 1)
valSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{validator})

// generate genesis account
senderPrivKey := secp256k1.GenPrivKey()
Expand All @@ -81,7 +81,7 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp {
// that also act as delegators. For simplicity, each validator is bonded with a delegation
// of one consensus engine unit 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, balances ...banktypes.Balance) *SimApp {
func SetupWithGenesisValSet(t *testing.T, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp {
t.Helper()

app, genesisState := setup(true, 5)
Expand Down