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

Rename tm prefixed packages to cmt #5158

Merged
merged 2 commits into from
Nov 22, 2023
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
40 changes: 20 additions & 20 deletions e2e/tests/core/02-client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (
paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"

"github.com/cometbft/cometbft/crypto/tmhash"
tmjson "github.com/cometbft/cometbft/libs/json"
cmtjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/privval"
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"

"github.com/cosmos/ibc-go/e2e/dockerutil"
"github.com/cosmos/ibc-go/e2e/testsuite"
Expand Down Expand Up @@ -339,8 +339,8 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
latestHeight clienttypes.Height
clientState ibcexported.ClientState
header testsuite.Header
signers []tmtypes.PrivValidator
validatorSet []*tmtypes.Validator
signers []cmttypes.PrivValidator
validatorSet []*cmttypes.Validator
maliciousHeader *ibctm.Header
err error
)
Expand Down Expand Up @@ -401,7 +401,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
pubKey, err := pv.GetPubKey()
s.Require().NoError(err)

validator := tmtypes.NewValidator(pubKey, validators[i].VotingPower)
validator := cmttypes.NewValidator(pubKey, validators[i].VotingPower)

validatorSet = append(validatorSet, validator)
signers = append(signers, pv)
Expand All @@ -410,7 +410,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
})

t.Run("create malicious header", func(t *testing.T) {
valSet := tmtypes.NewValidatorSet(validatorSet)
valSet := cmttypes.NewValidatorSet(validatorSet)
maliciousHeader, err = createMaliciousTMHeader(chainB.Config().ChainID, int64(latestHeight.GetRevisionHeight()), trustedHeight,
header.GetTime(), valSet, valSet, signers, header)
s.Require().NoError(err)
Expand Down Expand Up @@ -465,7 +465,7 @@ func (s *ClientTestSuite) TestAllowedClientsParam() {
msg := clienttypes.NewMsgUpdateParams(authority.String(), clienttypes.NewParams(allowedClient))
s.ExecuteAndPassGovV1Proposal(ctx, msg, chainA, chainAWallet)
} else {
value, err := tmjson.Marshal([]string{allowedClient})
value, err := cmtjson.Marshal([]string{allowedClient})
s.Require().NoError(err)
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange(ibcexported.ModuleName, string(clienttypes.KeyAllowedClients), string(value)),
Expand All @@ -488,14 +488,14 @@ func (s *ClientTestSuite) TestAllowedClientsParam() {
})
}

// extractChainPrivateKeys returns a slice of tmtypes.PrivValidator which hold the private keys for all validator
// extractChainPrivateKeys returns a slice of cmttypes.PrivValidator which hold the private keys for all validator
// nodes for a given chain.
func (s *ClientTestSuite) extractChainPrivateKeys(ctx context.Context, chain ibc.Chain) []tmtypes.PrivValidator {
func (s *ClientTestSuite) extractChainPrivateKeys(ctx context.Context, chain ibc.Chain) []cmttypes.PrivValidator {
testContainers, err := dockerutil.GetTestContainers(ctx, s.T(), s.DockerClient)
s.Require().NoError(err)

var filePvs []privval.FilePVKey
var pvs []tmtypes.PrivValidator
var pvs []cmttypes.PrivValidator
for _, container := range testContainers {
isNodeForDifferentChain := !strings.Contains(container.Names[0], chain.Config().ChainID)
isFullNode := strings.Contains(container.Names[0], fmt.Sprintf("%s-fn", chain.Config().ChainID))
Expand All @@ -508,7 +508,7 @@ func (s *ClientTestSuite) extractChainPrivateKeys(ctx context.Context, chain ibc
s.Require().NoError(err)

var filePV privval.FilePVKey
err = tmjson.Unmarshal(privKeyFileContents, &filePV)
err = cmtjson.Unmarshal(privKeyFileContents, &filePV)
s.Require().NoError(err)
filePvs = append(filePvs, filePV)
}
Expand All @@ -529,9 +529,9 @@ func (s *ClientTestSuite) extractChainPrivateKeys(ctx context.Context, chain ibc
}

// createMaliciousTMHeader creates a header with the provided trusted height with an invalid app hash.
func createMaliciousTMHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, tmTrustedVals *tmtypes.ValidatorSet, signers []tmtypes.PrivValidator, oldHeader testsuite.Header) (*ibctm.Header, error) {
tmHeader := tmtypes.Header{
Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2},
func createMaliciousTMHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, tmTrustedVals *cmttypes.ValidatorSet, signers []cmttypes.PrivValidator, oldHeader testsuite.Header) (*ibctm.Header, error) {
tmHeader := cmttypes.Header{
Version: cmtprotoversion.Consensus{Block: cmtversion.BlockProtocol, App: 2},
ChainID: chainID,
Height: blockHeight,
Time: timestamp,
Expand All @@ -549,14 +549,14 @@ func createMaliciousTMHeader(chainID string, blockHeight int64, trustedHeight cl

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

extCommit, err := tmtypes.MakeExtCommit(blockID, blockHeight, 1, voteSet, signers, timestamp, false)
extCommit, err := cmttypes.MakeExtCommit(blockID, blockHeight, 1, voteSet, signers, timestamp, false)
if err != nil {
return nil, err
}

signedHeader := &tmproto.SignedHeader{
signedHeader := &cmtproto.SignedHeader{
Header: tmHeader.ToProto(),
Commit: extCommit.ToCommit().ToProto(),
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/testsuite/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

tmjson "github.com/cometbft/cometbft/libs/json"
cmtjson "github.com/cometbft/cometbft/libs/json"

"github.com/cosmos/ibc-go/e2e/relayer"
"github.com/cosmos/ibc-go/e2e/semverutil"
Expand Down Expand Up @@ -560,7 +560,7 @@ func defaultGovv1ModifyGenesis(version string) func(ibc.ChainConfig, []byte) ([]
// in older version < v8, tmjson marshal must be used.
// regular json marshalling must be used for v8 and above as the
// sdk is de-coupled from comet.
marshalIndentFn := tmjson.MarshalIndent
marshalIndentFn := cmtjson.MarshalIndent
if stdlibJSONMarshalling.IsSupported(version) {
marshalIndentFn = json.MarshalIndent
}
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/transfer/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

tmbytes "github.com/cometbft/cometbft/libs/bytes"
cmtbytes "github.com/cometbft/cometbft/libs/bytes"

capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
Expand Down Expand Up @@ -140,7 +140,7 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
}

// GetDenomTrace retreives the full identifiers trace and base denomination from the store.
func (k Keeper) GetDenomTrace(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) (types.DenomTrace, bool) {
func (k Keeper) GetDenomTrace(ctx sdk.Context, denomTraceHash cmtbytes.HexBytes) (types.DenomTrace, bool) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.DenomTraceKey)
bz := store.Get(denomTraceHash)
if len(bz) == 0 {
Expand All @@ -152,7 +152,7 @@ func (k Keeper) GetDenomTrace(ctx sdk.Context, denomTraceHash tmbytes.HexBytes)
}

// HasDenomTrace checks if a the key with the given denomination trace hash exists on the store.
func (k Keeper) HasDenomTrace(ctx sdk.Context, denomTraceHash tmbytes.HexBytes) bool {
func (k Keeper) HasDenomTrace(ctx sdk.Context, denomTraceHash cmtbytes.HexBytes) bool {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.DenomTraceKey)
return store.Has(denomTraceHash)
}
Expand Down
10 changes: 5 additions & 5 deletions modules/apps/transfer/types/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

tmbytes "github.com/cometbft/cometbft/libs/bytes"
tmtypes "github.com/cometbft/cometbft/types"
cmtbytes "github.com/cometbft/cometbft/libs/bytes"
cmttypes "github.com/cometbft/cometbft/types"

channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
host "github.com/cosmos/ibc-go/v8/modules/core/24-host"
Expand Down Expand Up @@ -48,7 +48,7 @@ func ParseDenomTrace(rawDenom string) DenomTrace {
// Hash returns the hex bytes of the SHA256 hash of the DenomTrace fields using the following formula:
//
// hash = sha256(tracePath + "/" + baseDenom)
func (dt DenomTrace) Hash() tmbytes.HexBytes {
func (dt DenomTrace) Hash() cmtbytes.HexBytes {
hash := sha256.Sum256([]byte(dt.GetFullDenomPath()))
return hash[:]
}
Expand Down Expand Up @@ -242,13 +242,13 @@ func ValidateIBCDenom(denom string) error {
}

// ParseHexHash parses a hex hash in string format to bytes and validates its correctness.
func ParseHexHash(hexHash string) (tmbytes.HexBytes, error) {
func ParseHexHash(hexHash string) (cmtbytes.HexBytes, error) {
hash, err := hex.DecodeString(hexHash)
if err != nil {
return nil, err
}

if err := tmtypes.ValidateHash(hash); err != nil {
if err := cmttypes.ValidateHash(hash); err != nil {
return nil, err
}

Expand Down
4 changes: 2 additions & 2 deletions modules/capability/capability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"

"github.com/cosmos/ibc-go/modules/capability"
"github.com/cosmos/ibc-go/modules/capability/keeper"
Expand Down Expand Up @@ -60,7 +60,7 @@ func (suite *CapabilityTestSuite) NewTestContext() sdk.Context {
err := cms.LoadLatestVersion()
suite.Require().NoError(err)

return sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger())
return sdk.NewContext(cms, cmtproto.Header{}, false, log.NewNopLogger())
}

// The following test case mocks a specific bug discovered in https://github.com/cosmos/cosmos-sdk/issues/9800
Expand Down
6 changes: 3 additions & 3 deletions modules/core/02-client/abci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"

client "github.com/cosmos/ibc-go/v8/modules/core/02-client"
"github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Expand Down Expand Up @@ -60,7 +60,7 @@ func (suite *ClientTestSuite) TestBeginBlockerConsensusState() {
store.Set(upgradetypes.PlanKey(), bz)

nextValsHash := []byte("nextValsHash")
newCtx := suite.chainA.GetContext().WithBlockHeader(tmproto.Header{
newCtx := suite.chainA.GetContext().WithBlockHeader(cmtproto.Header{
ChainID: suite.chainA.ChainID,
Height: suite.chainA.GetContext().BlockHeight(),
NextValidatorsHash: nextValsHash,
Expand Down Expand Up @@ -91,7 +91,7 @@ func (suite *ClientTestSuite) TestBeginBlockerUpgradeEvents() {
store.Set(upgradetypes.PlanKey(), bz)

nextValsHash := []byte("nextValsHash")
newCtx := suite.chainA.GetContext().WithBlockHeader(tmproto.Header{
newCtx := suite.chainA.GetContext().WithBlockHeader(cmtproto.Header{
Height: suite.chainA.GetContext().BlockHeight(),
NextValidatorsHash: nextValsHash,
})
Expand Down
6 changes: 3 additions & 3 deletions modules/core/02-client/client/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"

tmtypes "github.com/cometbft/cometbft/types"
cmttypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
Expand Down Expand Up @@ -153,7 +153,7 @@ func QueryTendermintHeader(clientCtx client.Context) (ibctm.Header, int64, error
}

protoCommit := commit.SignedHeader.ToProto()
protoValset, err := tmtypes.NewValidatorSet(validators.Validators).ToProto()
protoValset, err := cmttypes.NewValidatorSet(validators.Validators).ToProto()
if err != nil {
return ibctm.Header{}, 0, err
}
Expand Down Expand Up @@ -203,7 +203,7 @@ func QuerySelfConsensusState(clientCtx client.Context) (*ibctm.ConsensusState, i
state := &ibctm.ConsensusState{
Timestamp: commit.Time,
Root: commitmenttypes.NewMerkleRoot(commit.AppHash),
NextValidatorsHash: tmtypes.NewValidatorSet(nextVals.Validators).Hash(),
NextValidatorsHash: cmttypes.NewValidatorSet(nextVals.Validators).Hash(),
}

return state, height, nil
Expand Down
18 changes: 9 additions & 9 deletions modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

tmbytes "github.com/cometbft/cometbft/libs/bytes"
tmtypes "github.com/cometbft/cometbft/types"
cmtbytes "github.com/cometbft/cometbft/libs/bytes"
cmttypes "github.com/cometbft/cometbft/types"

"github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper"
"github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Expand Down Expand Up @@ -61,14 +61,14 @@ type KeeperTestSuite struct {
ctx sdk.Context
keeper *keeper.Keeper
consensusState *ibctm.ConsensusState
valSet *tmtypes.ValidatorSet
valSetHash tmbytes.HexBytes
privVal tmtypes.PrivValidator
valSet *cmttypes.ValidatorSet
valSetHash cmtbytes.HexBytes
privVal cmttypes.PrivValidator
now time.Time
past time.Time
solomachine *ibctesting.Solomachine

signers map[string]tmtypes.PrivValidator
signers map[string]cmttypes.PrivValidator
}

func (suite *KeeperTestSuite) SetupTest() {
Expand All @@ -89,11 +89,11 @@ func (suite *KeeperTestSuite) SetupTest() {
pubKey, err := suite.privVal.GetPubKey()
suite.Require().NoError(err)

validator := tmtypes.NewValidator(pubKey, 1)
suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{validator})
validator := cmttypes.NewValidator(pubKey, 1)
suite.valSet = cmttypes.NewValidatorSet([]*cmttypes.Validator{validator})
suite.valSetHash = suite.valSet.Hash()

suite.signers = make(map[string]tmtypes.PrivValidator, 1)
suite.signers = make(map[string]cmttypes.PrivValidator, 1)
suite.signers[validator.Address.String()] = suite.privVal

suite.consensusState = ibctm.NewConsensusState(suite.now, commitmenttypes.NewMerkleRoot([]byte("hash")), suite.valSetHash)
Expand Down
8 changes: 4 additions & 4 deletions modules/core/02-client/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package types_test
import (
"time"

tmtypes "github.com/cometbft/cometbft/types"
cmttypes "github.com/cometbft/cometbft/types"

client "github.com/cosmos/ibc-go/v8/modules/core/02-client"
"github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Expand Down Expand Up @@ -51,10 +51,10 @@ func (suite *TypesTestSuite) TestValidateGenesis() {

now := time.Now().UTC()

val := tmtypes.NewValidator(pubKey, 10)
valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{val})
val := cmttypes.NewValidator(pubKey, 10)
valSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{val})

signers := make(map[string]tmtypes.PrivValidator)
signers := make(map[string]cmttypes.PrivValidator)
signers[val.Address.String()] = privVal

heightMinus1 := types.NewHeight(1, height-1)
Expand Down
8 changes: 4 additions & 4 deletions modules/core/04-channel/types/acknowledgement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"

abcitypes "github.com/cometbft/cometbft/abci/types"
tmstate "github.com/cometbft/cometbft/state"
cmtstate "github.com/cometbft/cometbft/state"

"github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors"
Expand Down Expand Up @@ -116,9 +116,9 @@ func (suite *TypesTestSuite) TestABCICodeDeterminism() {
deliverTxDifferentABCICode := sdkerrors.ResponseExecTxResultWithEvents(errDifferentABCICode, gasUsed, gasWanted, []abcitypes.Event{}, false)
resultsDifferentABCICode := []*abcitypes.ExecTxResult{deliverTxDifferentABCICode}

hash := tmstate.TxResultsHash(execTxResults)
hashSameABCICode := tmstate.TxResultsHash(resultsSameABCICode)
hashDifferentABCICode := tmstate.TxResultsHash(resultsDifferentABCICode)
hash := cmtstate.TxResultsHash(execTxResults)
hashSameABCICode := cmtstate.TxResultsHash(resultsSameABCICode)
hashDifferentABCICode := cmtstate.TxResultsHash(resultsDifferentABCICode)

suite.Require().Equal(hash, hashSameABCICode)
suite.Require().NotEqual(hash, hashDifferentABCICode)
Expand Down
4 changes: 2 additions & 2 deletions modules/core/23-commitment/types/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

errorsmod "cosmossdk.io/errors"

tmcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"
cmtcrypto "github.com/cometbft/cometbft/proto/tendermint/crypto"

"github.com/cosmos/ibc-go/v8/modules/core/exported"
)
Expand Down Expand Up @@ -243,7 +243,7 @@ func verifyChainedMembershipProof(root []byte, specs []*ics23.ProofSpec, proofs
// and are declared as globals to avoid having to unnecessarily re-allocate on every comparison.
var (
blankMerkleProof = &MerkleProof{}
blankProofOps = &tmcrypto.ProofOps{}
blankProofOps = &cmtcrypto.ProofOps{}
)

// Empty returns true if the root is empty
Expand Down
Loading
Loading