From 71fe6443f6da3225c5f4c676bc21f274f6fc1511 Mon Sep 17 00:00:00 2001 From: DimitrisJim Date: Wed, 22 Nov 2023 04:07:51 +0200 Subject: [PATCH] chore: tm -> cmt. --- e2e/tests/core/02-client/client_test.go | 40 +++++++++---------- e2e/testsuite/testconfig.go | 4 +- modules/apps/transfer/keeper/keeper.go | 6 +-- modules/apps/transfer/types/trace.go | 10 ++--- modules/capability/capability_test.go | 4 +- modules/core/02-client/abci_test.go | 6 +-- modules/core/02-client/client/utils/utils.go | 6 +-- modules/core/02-client/keeper/keeper_test.go | 18 ++++----- modules/core/02-client/types/genesis_test.go | 8 ++-- .../04-channel/types/acknowledgement_test.go | 8 ++-- modules/core/23-commitment/types/merkle.go | 4 +- .../07-tendermint/client_state.go | 8 ++-- .../07-tendermint/consensus_state.go | 8 ++-- .../light-clients/07-tendermint/fraction.go | 8 ++-- modules/light-clients/07-tendermint/header.go | 6 +-- .../07-tendermint/header_test.go | 4 +- .../07-tendermint/misbehaviour.go | 14 +++---- .../07-tendermint/misbehaviour_handle.go | 10 ++--- .../07-tendermint/misbehaviour_handle_test.go | 14 +++---- .../07-tendermint/misbehaviour_test.go | 22 +++++----- .../07-tendermint/tendermint_test.go | 28 ++++++------- modules/light-clients/07-tendermint/update.go | 14 +++---- .../07-tendermint/update_test.go | 12 +++--- .../08-wasm/keeper/snapshotter.go | 6 +-- .../08-wasm/keeper/snapshotter_test.go | 8 ++-- .../light-clients/08-wasm/types/genesis.go | 4 +- .../08-wasm/types/update_test.go | 10 ++--- testing/app.go | 4 +- testing/chain.go | 24 +++++------ testing/mock/privval.go | 18 ++++----- testing/mock/privval_test.go | 12 +++--- testing/utils.go | 8 ++-- 32 files changed, 178 insertions(+), 178 deletions(-) diff --git a/e2e/tests/core/02-client/client_test.go b/e2e/tests/core/02-client/client_test.go index 02b28517e81..b212d2a67a3 100644 --- a/e2e/tests/core/02-client/client_test.go +++ b/e2e/tests/core/02-client/client_test.go @@ -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" @@ -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 ) @@ -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) @@ -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) @@ -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)), @@ -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)) @@ -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) } @@ -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, @@ -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(), } diff --git a/e2e/testsuite/testconfig.go b/e2e/testsuite/testconfig.go index c7c5f320c9a..67ad16c4038 100644 --- a/e2e/testsuite/testconfig.go +++ b/e2e/testsuite/testconfig.go @@ -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" @@ -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 } diff --git a/modules/apps/transfer/keeper/keeper.go b/modules/apps/transfer/keeper/keeper.go index 04704a1f53b..78a0be057dc 100644 --- a/modules/apps/transfer/keeper/keeper.go +++ b/modules/apps/transfer/keeper/keeper.go @@ -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" @@ -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 { @@ -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) } diff --git a/modules/apps/transfer/types/trace.go b/modules/apps/transfer/types/trace.go index 221b190e040..93aa7ee14bf 100644 --- a/modules/apps/transfer/types/trace.go +++ b/modules/apps/transfer/types/trace.go @@ -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" @@ -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[:] } @@ -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 } diff --git a/modules/capability/capability_test.go b/modules/capability/capability_test.go index 77c7170401d..01c627db652 100644 --- a/modules/capability/capability_test.go +++ b/modules/capability/capability_test.go @@ -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" @@ -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 diff --git a/modules/core/02-client/abci_test.go b/modules/core/02-client/abci_test.go index a77f0a31ffd..b5a78320ad1 100644 --- a/modules/core/02-client/abci_test.go +++ b/modules/core/02-client/abci_test.go @@ -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" @@ -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, @@ -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, }) diff --git a/modules/core/02-client/client/utils/utils.go b/modules/core/02-client/client/utils/utils.go index 8b8cd8ceb74..84037192760 100644 --- a/modules/core/02-client/client/utils/utils.go +++ b/modules/core/02-client/client/utils/utils.go @@ -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" @@ -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 } @@ -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 diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 1a73391bd4d..cd7d197983b 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -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" @@ -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() { @@ -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) diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index c98d0a1d99c..2e1714434f3 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -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" @@ -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) diff --git a/modules/core/04-channel/types/acknowledgement_test.go b/modules/core/04-channel/types/acknowledgement_test.go index 71234065321..1db3476ad47 100644 --- a/modules/core/04-channel/types/acknowledgement_test.go +++ b/modules/core/04-channel/types/acknowledgement_test.go @@ -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" @@ -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) diff --git a/modules/core/23-commitment/types/merkle.go b/modules/core/23-commitment/types/merkle.go index 751ae81677a..668311f8271 100644 --- a/modules/core/23-commitment/types/merkle.go +++ b/modules/core/23-commitment/types/merkle.go @@ -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" ) @@ -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 diff --git a/modules/light-clients/07-tendermint/client_state.go b/modules/light-clients/07-tendermint/client_state.go index 47a3eb8e4bc..c5c70cdf1a8 100644 --- a/modules/light-clients/07-tendermint/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -13,7 +13,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cometbft/cometbft/light" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" @@ -118,13 +118,13 @@ func (cs ClientState) Validate() error { return errorsmod.Wrap(ErrInvalidChainID, "chain id cannot be empty string") } - // NOTE: the value of tmtypes.MaxChainIDLen may change in the future. + // NOTE: the value of cmttypes.MaxChainIDLen may change in the future. // If this occurs, the code here must account for potential difference // between the tendermint version being run by the counterparty chain // and the tendermint version used by this light client. // https://github.com/cosmos/ibc-go/issues/177 - if len(cs.ChainId) > tmtypes.MaxChainIDLen { - return errorsmod.Wrapf(ErrInvalidChainID, "chainID is too long; got: %d, max: %d", len(cs.ChainId), tmtypes.MaxChainIDLen) + if len(cs.ChainId) > cmttypes.MaxChainIDLen { + return errorsmod.Wrapf(ErrInvalidChainID, "chainID is too long; got: %d, max: %d", len(cs.ChainId), cmttypes.MaxChainIDLen) } if err := light.ValidateTrustLevel(cs.TrustLevel.ToTendermint()); err != nil { diff --git a/modules/light-clients/07-tendermint/consensus_state.go b/modules/light-clients/07-tendermint/consensus_state.go index e494d295727..c7ee1ff0eeb 100644 --- a/modules/light-clients/07-tendermint/consensus_state.go +++ b/modules/light-clients/07-tendermint/consensus_state.go @@ -5,8 +5,8 @@ import ( errorsmod "cosmossdk.io/errors" - 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" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" @@ -20,7 +20,7 @@ const SentinelRoot = "sentinel_root" // NewConsensusState creates a new ConsensusState instance. func NewConsensusState( - timestamp time.Time, root commitmenttypes.MerkleRoot, nextValsHash tmbytes.HexBytes, + timestamp time.Time, root commitmenttypes.MerkleRoot, nextValsHash cmtbytes.HexBytes, ) *ConsensusState { return &ConsensusState{ Timestamp: timestamp, @@ -51,7 +51,7 @@ func (cs ConsensusState) ValidateBasic() error { if cs.Root.Empty() { return errorsmod.Wrap(clienttypes.ErrInvalidConsensus, "root cannot be empty") } - if err := tmtypes.ValidateHash(cs.NextValidatorsHash); err != nil { + if err := cmttypes.ValidateHash(cs.NextValidatorsHash); err != nil { return errorsmod.Wrap(err, "next validators hash is invalid") } if cs.Timestamp.Unix() <= 0 { diff --git a/modules/light-clients/07-tendermint/fraction.go b/modules/light-clients/07-tendermint/fraction.go index f9b750e7ecc..e5ea0a29210 100644 --- a/modules/light-clients/07-tendermint/fraction.go +++ b/modules/light-clients/07-tendermint/fraction.go @@ -1,7 +1,7 @@ package tendermint import ( - tmmath "github.com/cometbft/cometbft/libs/math" + cmtmath "github.com/cometbft/cometbft/libs/math" "github.com/cometbft/cometbft/light" ) @@ -9,7 +9,7 @@ import ( var DefaultTrustLevel = NewFractionFromTm(light.DefaultTrustLevel) // NewFractionFromTm returns a new Fraction instance from a tmmath.Fraction -func NewFractionFromTm(f tmmath.Fraction) Fraction { +func NewFractionFromTm(f cmtmath.Fraction) Fraction { return Fraction{ Numerator: f.Numerator, Denominator: f.Denominator, @@ -17,8 +17,8 @@ func NewFractionFromTm(f tmmath.Fraction) Fraction { } // ToTendermint converts Fraction to tmmath.Fraction -func (f Fraction) ToTendermint() tmmath.Fraction { - return tmmath.Fraction{ +func (f Fraction) ToTendermint() cmtmath.Fraction { + return cmtmath.Fraction{ Numerator: f.Numerator, Denominator: f.Denominator, } diff --git a/modules/light-clients/07-tendermint/header.go b/modules/light-clients/07-tendermint/header.go index 5ad78882aab..d144e9cff08 100644 --- a/modules/light-clients/07-tendermint/header.go +++ b/modules/light-clients/07-tendermint/header.go @@ -6,7 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" @@ -55,7 +55,7 @@ func (h Header) ValidateBasic() error { if h.Header == nil { return errorsmod.Wrap(clienttypes.ErrInvalidHeader, "tendermint header cannot be nil") } - tmSignedHeader, err := tmtypes.SignedHeaderFromProto(h.SignedHeader) + tmSignedHeader, err := cmttypes.SignedHeaderFromProto(h.SignedHeader) if err != nil { return errorsmod.Wrap(err, "header is not a tendermint header") } @@ -72,7 +72,7 @@ func (h Header) ValidateBasic() error { if h.ValidatorSet == nil { return errorsmod.Wrap(clienttypes.ErrInvalidHeader, "validator set is nil") } - tmValset, err := tmtypes.ValidatorSetFromProto(h.ValidatorSet) + tmValset, err := cmttypes.ValidatorSetFromProto(h.ValidatorSet) if err != nil { return errorsmod.Wrap(err, "validator set is not tendermint validator set") } diff --git a/modules/light-clients/07-tendermint/header_test.go b/modules/light-clients/07-tendermint/header_test.go index c473ff7998d..c9df1044d22 100644 --- a/modules/light-clients/07-tendermint/header_test.go +++ b/modules/light-clients/07-tendermint/header_test.go @@ -3,7 +3,7 @@ package tendermint_test import ( "time" - tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" + cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -48,7 +48,7 @@ func (suite *TendermintTestSuite) TestHeaderValidateBasic() { header.ValidatorSet = nil }, false}, {"ValidatorSetFromProto failed", func() { - header.ValidatorSet.Validators[0].PubKey = tmprotocrypto.PublicKey{} + header.ValidatorSet.Validators[0].PubKey = cmtprotocrypto.PublicKey{} }, false}, {"header validator hash does not equal hash of validator set", func() { // use chainB's randomly generated validator set diff --git a/modules/light-clients/07-tendermint/misbehaviour.go b/modules/light-clients/07-tendermint/misbehaviour.go index fc002fc9bff..8a6616b1937 100644 --- a/modules/light-clients/07-tendermint/misbehaviour.go +++ b/modules/light-clients/07-tendermint/misbehaviour.go @@ -5,8 +5,8 @@ import ( errorsmod "cosmossdk.io/errors" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v8/modules/core/24-host" @@ -89,11 +89,11 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { return errorsmod.Wrapf(clienttypes.ErrInvalidMisbehaviour, "Header1 height is less than Header2 height (%s < %s)", misbehaviour.Header1.GetHeight(), misbehaviour.Header2.GetHeight()) } - blockID1, err := tmtypes.BlockIDFromProto(&misbehaviour.Header1.SignedHeader.Commit.BlockID) + blockID1, err := cmttypes.BlockIDFromProto(&misbehaviour.Header1.SignedHeader.Commit.BlockID) if err != nil { return errorsmod.Wrap(err, "invalid block ID from header 1 in misbehaviour") } - blockID2, err := tmtypes.BlockIDFromProto(&misbehaviour.Header2.SignedHeader.Commit.BlockID) + blockID2, err := cmttypes.BlockIDFromProto(&misbehaviour.Header2.SignedHeader.Commit.BlockID) if err != nil { return errorsmod.Wrap(err, "invalid block ID from header 2 in misbehaviour") } @@ -107,12 +107,12 @@ func (misbehaviour Misbehaviour) ValidateBasic() error { } // validCommit checks if the given commit is a valid commit from the passed-in validatorset -func validCommit(chainID string, blockID tmtypes.BlockID, commit *tmproto.Commit, valSet *tmproto.ValidatorSet) (err error) { - tmCommit, err := tmtypes.CommitFromProto(commit) +func validCommit(chainID string, blockID cmttypes.BlockID, commit *cmtproto.Commit, valSet *cmtproto.ValidatorSet) (err error) { + tmCommit, err := cmttypes.CommitFromProto(commit) if err != nil { return errorsmod.Wrap(err, "commit is not tendermint commit type") } - tmValset, err := tmtypes.ValidatorSetFromProto(valSet) + tmValset, err := cmttypes.ValidatorSetFromProto(valSet) if err != nil { return errorsmod.Wrap(err, "validator set is not tendermint validator set type") } diff --git a/modules/light-clients/07-tendermint/misbehaviour_handle.go b/modules/light-clients/07-tendermint/misbehaviour_handle.go index 013efd908e5..ae9806e9108 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_handle.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -57,12 +57,12 @@ func (ClientState) CheckForMisbehaviour(ctx sdk.Context, cdc codec.BinaryCodec, // if heights are equal check that this is valid misbehaviour of a fork // otherwise if heights are unequal check that this is valid misbehavior of BFT time violation if msg.Header1.GetHeight().EQ(msg.Header2.GetHeight()) { - blockID1, err := tmtypes.BlockIDFromProto(&msg.Header1.SignedHeader.Commit.BlockID) + blockID1, err := cmttypes.BlockIDFromProto(&msg.Header1.SignedHeader.Commit.BlockID) if err != nil { return false } - blockID2, err := tmtypes.BlockIDFromProto(&msg.Header2.SignedHeader.Commit.BlockID) + blockID2, err := cmttypes.BlockIDFromProto(&msg.Header2.SignedHeader.Commit.BlockID) if err != nil { return false } @@ -128,12 +128,12 @@ func (cs *ClientState) verifyMisbehaviour(ctx sdk.Context, clientStore storetype func checkMisbehaviourHeader( clientState *ClientState, consState *ConsensusState, header *Header, currentTimestamp time.Time, ) error { - tmTrustedValset, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) + tmTrustedValset, err := cmttypes.ValidatorSetFromProto(header.TrustedValidators) if err != nil { return errorsmod.Wrap(err, "trusted validator set is not tendermint validator set type") } - tmCommit, err := tmtypes.CommitFromProto(header.Commit) + tmCommit, err := cmttypes.CommitFromProto(header.Commit) if err != nil { return errorsmod.Wrap(err, "commit is not tendermint commit type") } diff --git a/modules/light-clients/07-tendermint/misbehaviour_handle_test.go b/modules/light-clients/07-tendermint/misbehaviour_handle_test.go index 0f01eaeefcc..d4719ab016b 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_handle_test.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle_test.go @@ -5,7 +5,7 @@ import ( "strings" "time" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -22,10 +22,10 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { suite.Require().NoError(err) // create modified heights to use for test-cases - altVal := tmtypes.NewValidator(altPubKey, 100) + altVal := cmttypes.NewValidator(altPubKey, 100) // Create alternative validator set with only altVal, invalid update (too much change in valSet) - altValSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{altVal}) + altValSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{altVal}) altSigners := getAltSigners(altVal, altPrivVal) var ( @@ -194,7 +194,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) // Create bothValSet with both suite validator and altVal - bothValSet := tmtypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altValSet.Proposer)) + bothValSet := cmttypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altValSet.Proposer)) bothSigners := suite.chainB.Signers bothSigners[altValSet.Proposer.Address.String()] = altPrivVal @@ -370,10 +370,10 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { suite.Require().NoError(err) // create modified heights to use for test-cases - altVal := tmtypes.NewValidator(altPubKey, 100) + altVal := cmttypes.NewValidator(altPubKey, 100) // Create alternative validator set with only altVal, invalid update (too much change in valSet) - altValSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{altVal}) + altValSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{altVal}) altSigners := getAltSigners(altVal, altPrivVal) var ( @@ -481,7 +481,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) // Create bothValSet with both suite validator and altVal - bothValSet := tmtypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altValSet.Proposer)) + bothValSet := cmttypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altValSet.Proposer)) bothSigners := suite.chainB.Signers bothSigners[altValSet.Proposer.Address.String()] = altPrivVal diff --git a/modules/light-clients/07-tendermint/misbehaviour_test.go b/modules/light-clients/07-tendermint/misbehaviour_test.go index c4ceb9e4c0a..757111b5f46 100644 --- a/modules/light-clients/07-tendermint/misbehaviour_test.go +++ b/modules/light-clients/07-tendermint/misbehaviour_test.go @@ -4,8 +4,8 @@ import ( "time" "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" "github.com/cosmos/ibc-go/v8/modules/core/exported" @@ -33,15 +33,15 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { revisionHeight := int64(height.RevisionHeight) - altVal := tmtypes.NewValidator(altPubKey, revisionHeight) + altVal := cmttypes.NewValidator(altPubKey, revisionHeight) // Create alternative validator set with only altVal - altValSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{altVal}) + altValSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{altVal}) // Create signer array and ensure it is in same order as bothValSet bothValSet, bothSigners := getBothSigners(suite, altVal, altPrivVal) - altSignerArr := []tmtypes.PrivValidator{altPrivVal} + altSignerArr := []cmttypes.PrivValidator{altPrivVal} heightMinus1 := clienttypes.NewHeight(0, height.RevisionHeight-1) @@ -172,13 +172,13 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { }, func(misbehaviour *ibctm.Misbehaviour) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) - wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header1.GetHeight().GetRevisionHeight()), 1, tmproto.PrecommitType, altValSet) - blockID, err := tmtypes.BlockIDFromProto(&misbehaviour.Header1.Commit.BlockID) + wrongVoteSet := cmttypes.NewVoteSet(chainID, int64(misbehaviour.Header1.GetHeight().GetRevisionHeight()), 1, cmtproto.PrecommitType, altValSet) + blockID, err := cmttypes.BlockIDFromProto(&misbehaviour.Header1.Commit.BlockID) if err != nil { return err } - extCommit, err := tmtypes.MakeExtCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetRevisionHeight()), misbehaviour.Header1.Commit.Round, wrongVoteSet, altSignerArr, suite.now, false) + extCommit, err := cmttypes.MakeExtCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetRevisionHeight()), misbehaviour.Header1.Commit.Round, wrongVoteSet, altSignerArr, suite.now, false) misbehaviour.Header1.Commit = extCommit.ToCommit().ToProto() return err }, @@ -193,13 +193,13 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { }, func(misbehaviour *ibctm.Misbehaviour) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) - wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header2.GetHeight().GetRevisionHeight()), 1, tmproto.PrecommitType, altValSet) - blockID, err := tmtypes.BlockIDFromProto(&misbehaviour.Header2.Commit.BlockID) + wrongVoteSet := cmttypes.NewVoteSet(chainID, int64(misbehaviour.Header2.GetHeight().GetRevisionHeight()), 1, cmtproto.PrecommitType, altValSet) + blockID, err := cmttypes.BlockIDFromProto(&misbehaviour.Header2.Commit.BlockID) if err != nil { return err } - extCommit, err := tmtypes.MakeExtCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetRevisionHeight()), misbehaviour.Header2.Commit.Round, wrongVoteSet, altSignerArr, suite.now, false) + extCommit, err := cmttypes.MakeExtCommit(*blockID, int64(misbehaviour.Header2.GetHeight().GetRevisionHeight()), misbehaviour.Header2.Commit.Round, wrongVoteSet, altSignerArr, suite.now, false) misbehaviour.Header2.Commit = extCommit.ToCommit().ToProto() return err }, diff --git a/modules/light-clients/07-tendermint/tendermint_test.go b/modules/light-clients/07-tendermint/tendermint_test.go index 73354be0461..16f55f14fa1 100644 --- a/modules/light-clients/07-tendermint/tendermint_test.go +++ b/modules/light-clients/07-tendermint/tendermint_test.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" 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" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" @@ -47,10 +47,10 @@ type TendermintTestSuite struct { // TODO: deprecate usage in favor of testing package ctx sdk.Context cdc codec.Codec - privVal tmtypes.PrivValidator - valSet *tmtypes.ValidatorSet - signers map[string]tmtypes.PrivValidator - valsHash tmbytes.HexBytes + privVal cmttypes.PrivValidator + valSet *cmttypes.ValidatorSet + signers map[string]cmttypes.PrivValidator + valsHash cmtbytes.HexBytes header *ibctm.Header now time.Time headerTime time.Time @@ -85,25 +85,25 @@ func (suite *TendermintTestSuite) SetupTest() { heightMinus1 := clienttypes.NewHeight(0, height.RevisionHeight-1) - val := tmtypes.NewValidator(pubKey, 10) - suite.signers = make(map[string]tmtypes.PrivValidator) + val := cmttypes.NewValidator(pubKey, 10) + suite.signers = make(map[string]cmttypes.PrivValidator) suite.signers[val.Address.String()] = suite.privVal - suite.valSet = tmtypes.NewValidatorSet([]*tmtypes.Validator{val}) + suite.valSet = cmttypes.NewValidatorSet([]*cmttypes.Validator{val}) suite.valsHash = suite.valSet.Hash() suite.header = suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers) suite.ctx = app.BaseApp.NewContext(checkTx) } -func getAltSigners(altVal *tmtypes.Validator, altPrivVal tmtypes.PrivValidator) map[string]tmtypes.PrivValidator { - return map[string]tmtypes.PrivValidator{altVal.Address.String(): altPrivVal} +func getAltSigners(altVal *cmttypes.Validator, altPrivVal cmttypes.PrivValidator) map[string]cmttypes.PrivValidator { + return map[string]cmttypes.PrivValidator{altVal.Address.String(): altPrivVal} } -func getBothSigners(suite *TendermintTestSuite, altVal *tmtypes.Validator, altPrivVal tmtypes.PrivValidator) (*tmtypes.ValidatorSet, map[string]tmtypes.PrivValidator) { +func getBothSigners(suite *TendermintTestSuite, altVal *cmttypes.Validator, altPrivVal cmttypes.PrivValidator) (*cmttypes.ValidatorSet, map[string]cmttypes.PrivValidator) { // Create bothValSet with both suite validator and altVal. Would be valid update - bothValSet := tmtypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) + bothValSet := cmttypes.NewValidatorSet(append(suite.valSet.Validators, altVal)) // Create signer array and ensure it is in same order as bothValSet _, suiteVal := suite.valSet.GetByIndex(0) - bothSigners := map[string]tmtypes.PrivValidator{ + bothSigners := map[string]cmttypes.PrivValidator{ suiteVal.Address.String(): suite.privVal, altVal.Address.String(): altPrivVal, } diff --git a/modules/light-clients/07-tendermint/update.go b/modules/light-clients/07-tendermint/update.go index c884b4bfba9..092d1161401 100644 --- a/modules/light-clients/07-tendermint/update.go +++ b/modules/light-clients/07-tendermint/update.go @@ -11,7 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cometbft/cometbft/light" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" @@ -68,17 +68,17 @@ func (cs *ClientState) verifyHeader( ) } - tmTrustedValidators, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) + tmTrustedValidators, err := cmttypes.ValidatorSetFromProto(header.TrustedValidators) if err != nil { return errorsmod.Wrap(err, "trusted validator set in not tendermint validator set type") } - tmSignedHeader, err := tmtypes.SignedHeaderFromProto(header.SignedHeader) + tmSignedHeader, err := cmttypes.SignedHeaderFromProto(header.SignedHeader) if err != nil { return errorsmod.Wrap(err, "signed header in not tendermint signed header type") } - tmValidatorSet, err := tmtypes.ValidatorSetFromProto(header.ValidatorSet) + tmValidatorSet, err := cmttypes.ValidatorSetFromProto(header.ValidatorSet) if err != nil { return errorsmod.Wrap(err, "validator set in not tendermint validator set type") } @@ -94,13 +94,13 @@ func (cs *ClientState) verifyHeader( // Construct a trusted header using the fields in consensus state // Only Height, Time, and NextValidatorsHash are necessary for verification // NOTE: updates must be within the same revision - trustedHeader := tmtypes.Header{ + trustedHeader := cmttypes.Header{ ChainID: cs.GetChainID(), Height: int64(header.TrustedHeight.RevisionHeight), Time: consState.Timestamp, NextValidatorsHash: consState.NextValidatorsHash, } - signedHeader := tmtypes.SignedHeader{ + signedHeader := cmttypes.SignedHeader{ Header: &trustedHeader, } @@ -207,7 +207,7 @@ func (cs ClientState) UpdateStateOnMisbehaviour(ctx sdk.Context, cdc codec.Binar // checkTrustedHeader checks that consensus state matches trusted fields of Header func checkTrustedHeader(header *Header, consState *ConsensusState) error { - tmTrustedValidators, err := tmtypes.ValidatorSetFromProto(header.TrustedValidators) + tmTrustedValidators, err := cmttypes.ValidatorSetFromProto(header.TrustedValidators) if err != nil { return errorsmod.Wrap(err, "trusted validator set in not tendermint validator set type") } diff --git a/modules/light-clients/07-tendermint/update_test.go b/modules/light-clients/07-tendermint/update_test.go index d6b8de6e091..44850ef7337 100644 --- a/modules/light-clients/07-tendermint/update_test.go +++ b/modules/light-clients/07-tendermint/update_test.go @@ -5,7 +5,7 @@ import ( storetypes "cosmossdk.io/store/types" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" @@ -30,9 +30,9 @@ func (suite *TendermintTestSuite) TestVerifyHeader() { revisionHeight := int64(height.RevisionHeight) // create modified heights to use for test-cases - altVal := tmtypes.NewValidator(altPubKey, 100) + altVal := cmttypes.NewValidator(altPubKey, 100) // Create alternative validator set with only altVal, invalid update (too much change in valSet) - altValSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{altVal}) + altValSet := cmttypes.NewValidatorSet([]*cmttypes.Validator{altVal}) altSigners := getAltSigners(altVal, altPrivVal) testCases := []struct { @@ -73,7 +73,7 @@ func (suite *TendermintTestSuite) TestVerifyHeader() { suite.Require().True(found) // Create bothValSet with both suite validator and altVal - bothValSet := tmtypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altVal)) + bothValSet := cmttypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altVal)) bothSigners := suite.chainB.Signers bothSigners[altVal.Address.String()] = altPrivVal @@ -90,7 +90,7 @@ func (suite *TendermintTestSuite) TestVerifyHeader() { suite.Require().True(found) // Create bothValSet with both suite validator and altVal - bothValSet := tmtypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altVal)) + bothValSet := cmttypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altVal)) bothSigners := suite.chainB.Signers bothSigners[altVal.Address.String()] = altPrivVal @@ -104,7 +104,7 @@ func (suite *TendermintTestSuite) TestVerifyHeader() { trustedHeight := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) // Create bothValSet with both suite validator and altVal - bothValSet := tmtypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altVal)) + bothValSet := cmttypes.NewValidatorSet(append(suite.chainB.Vals.Validators, altVal)) bothSigners := suite.chainB.Signers bothSigners[altVal.Address.String()] = altPrivVal diff --git a/modules/light-clients/08-wasm/keeper/snapshotter.go b/modules/light-clients/08-wasm/keeper/snapshotter.go index 0d0eb564f0a..adc16490290 100644 --- a/modules/light-clients/08-wasm/keeper/snapshotter.go +++ b/modules/light-clients/08-wasm/keeper/snapshotter.go @@ -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" "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/internal/ibcwasm" "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/types" @@ -65,7 +65,7 @@ func (ws *WasmSnapshotter) SnapshotExtension(height uint64, payloadWriter snapsh return err } - ctx := sdk.NewContext(cacheMS, tmproto.Header{}, false, nil) + ctx := sdk.NewContext(cacheMS, cmtproto.Header{}, false, nil) checksums, err := types.GetAllChecksums(ctx) if err != nil { @@ -129,7 +129,7 @@ func (ws *WasmSnapshotter) processAllItems( payloadReader snapshot.ExtensionPayloadReader, cb func(sdk.Context, *Keeper, []byte) error, ) error { - ctx := sdk.NewContext(ws.cms, tmproto.Header{Height: int64(height)}, false, nil) + ctx := sdk.NewContext(ws.cms, cmtproto.Header{Height: int64(height)}, false, nil) for { payload, err := payloadReader() if err == io.EOF { diff --git a/modules/light-clients/08-wasm/keeper/snapshotter_test.go b/modules/light-clients/08-wasm/keeper/snapshotter_test.go index 6cb6d81e769..2a8977a079c 100644 --- a/modules/light-clients/08-wasm/keeper/snapshotter_test.go +++ b/modules/light-clients/08-wasm/keeper/snapshotter_test.go @@ -7,7 +7,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" wasmtesting "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing" "github.com/cosmos/ibc-go/modules/light-clients/08-wasm/testing/simapp" @@ -39,7 +39,7 @@ func (suite *KeeperTestSuite) TestSnapshotter() { t := suite.T() wasmClientApp := suite.SetupSnapshotterWithMockVM() - ctx := wasmClientApp.NewUncachedContext(false, tmproto.Header{ + ctx := wasmClientApp.NewUncachedContext(false, cmtproto.Header{ ChainID: "foo", Height: wasmClientApp.LastBlockHeight() + 1, Time: time.Now(), @@ -73,7 +73,7 @@ func (suite *KeeperTestSuite) TestSnapshotter() { // setup dest app with snapshot imported destWasmClientApp := simapp.SetupWithEmptyStore(t, suite.mockVM) - destCtx := destWasmClientApp.NewUncachedContext(false, tmproto.Header{ + destCtx := destWasmClientApp.NewUncachedContext(false, cmtproto.Header{ ChainID: "bar", Height: destWasmClientApp.LastBlockHeight() + 1, Time: time.Now(), @@ -99,7 +99,7 @@ func (suite *KeeperTestSuite) TestSnapshotter() { var allDestAppChecksumsInWasmVMStore []byte // check wasm contracts are imported - ctx = destWasmClientApp.NewUncachedContext(false, tmproto.Header{ + ctx = destWasmClientApp.NewUncachedContext(false, cmtproto.Header{ ChainID: "foo", Height: destWasmClientApp.LastBlockHeight() + 1, Time: time.Now(), diff --git a/modules/light-clients/08-wasm/types/genesis.go b/modules/light-clients/08-wasm/types/genesis.go index 3cba401a98a..2b93f168623 100644 --- a/modules/light-clients/08-wasm/types/genesis.go +++ b/modules/light-clients/08-wasm/types/genesis.go @@ -8,7 +8,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" "github.com/cosmos/ibc-go/v8/modules/core/exported" ) @@ -37,7 +37,7 @@ func (cs ClientState) ExportMetadata(store storetypes.KVStore) []exported.Genesi ExportMetadata: &ExportMetadataMsg{}, } - ctx := sdk.NewContext(nil, tmproto.Header{Height: 1, Time: time.Now()}, true, nil) // context with infinite gas meter + ctx := sdk.NewContext(nil, cmtproto.Header{Height: 1, Time: time.Now()}, true, nil) // context with infinite gas meter result, err := wasmQuery[ExportMetadataResult](ctx, store, &cs, payload) if err != nil { panic(err) diff --git a/modules/light-clients/08-wasm/types/update_test.go b/modules/light-clients/08-wasm/types/update_test.go index 27a82a2612c..c4f08707fef 100644 --- a/modules/light-clients/08-wasm/types/update_test.go +++ b/modules/light-clients/08-wasm/types/update_test.go @@ -15,7 +15,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v8/modules/core/24-host" "github.com/cosmos/ibc-go/v8/modules/core/exported" - tmtypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" + cmttypes "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v8/testing" ) @@ -113,9 +113,9 @@ func (suite *TypesTestSuite) TestUpdateState() { "failure: invalid ClientMessage type", func() { // SudoCallback left nil because clientMsg is checked by 08-wasm before callbackFn is called. - clientMsg = &tmtypes.Misbehaviour{} + clientMsg = &cmttypes.Misbehaviour{} }, - fmt.Errorf("expected type %T, got %T", (*types.ClientMessage)(nil), (*tmtypes.Misbehaviour)(nil)), + fmt.Errorf("expected type %T, got %T", (*types.ClientMessage)(nil), (*cmttypes.Misbehaviour)(nil)), nil, }, { @@ -234,10 +234,10 @@ func (suite *TypesTestSuite) TestUpdateStateOnMisbehaviour() { { "failure: invalid client message", func() { - clientMsg = &tmtypes.Header{} + clientMsg = &cmttypes.Header{} // we will not register the callback here because this test case does not reach the VM }, - fmt.Errorf("expected type %T, got %T", (*types.ClientMessage)(nil), (*tmtypes.Header)(nil)), + fmt.Errorf("expected type %T, got %T", (*types.ClientMessage)(nil), (*cmttypes.Header)(nil)), nil, }, { diff --git a/testing/app.go b/testing/app.go index 14a30f5ce68..8cd87f1d69a 100644 --- a/testing/app.go +++ b/testing/app.go @@ -25,7 +25,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper" "github.com/cosmos/ibc-go/v8/modules/core/keeper" @@ -63,7 +63,7 @@ func SetupTestingApp() (TestingApp, map[string]json.RawMessage) { // that also act as delegators. For simplicity, each validator is bonded with a delegation // 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(tb testing.TB, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction sdkmath.Int, balances ...banktypes.Balance) TestingApp { +func SetupWithGenesisValSet(tb testing.TB, valSet *cmttypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction sdkmath.Int, balances ...banktypes.Balance) TestingApp { tb.Helper() app, genesisState := DefaultTestingAppInit() diff --git a/testing/chain.go b/testing/chain.go index 77580935e57..f7d672b7470 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -458,11 +458,11 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa trustedHeight = chain.GetClientState(clientID).GetLatestHeight().(clienttypes.Height) } var ( - tmTrustedVals *cmttypes.ValidatorSet - ok bool + cmtTrustedVals *cmttypes.ValidatorSet + ok bool ) - tmTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight)) + cmtTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight)) if !ok { return nil, errorsmod.Wrapf(ibctm.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight) } @@ -471,11 +471,11 @@ func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterpa // for now assume revision number is 0 header.TrustedHeight = trustedHeight - trustedVals, err := tmTrustedVals.ToProto() + trustedVals, err := cmtTrustedVals.ToProto() if err != nil { return nil, err } - trustedVals.TotalVotingPower = tmTrustedVals.TotalVotingPower() + trustedVals.TotalVotingPower = cmtTrustedVals.TotalVotingPower() header.TrustedValidators = trustedVals return header, nil @@ -504,14 +504,14 @@ 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, cmtValSet, nextVals, tmTrustedVals *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *ibctm.Header { +func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, cmtValSet, nextVals, cmtTrustedVals *cmttypes.ValidatorSet, signers map[string]cmttypes.PrivValidator) *ibctm.Header { var ( valSet *cmtproto.ValidatorSet trustedVals *cmtproto.ValidatorSet ) require.NotNil(chain.TB, cmtValSet) - tmHeader := cmttypes.Header{ + cmtHeader := cmttypes.Header{ Version: cmtprotoversion.Consensus{Block: cmtversion.BlockProtocol, App: 2}, ChainID: chainID, Height: blockHeight, @@ -528,7 +528,7 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, ProposerAddress: cmtValSet.Proposer.Address, //nolint:staticcheck } - hhash := tmHeader.Hash() + hhash := cmtHeader.Hash() blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) voteSet := cmttypes.NewVoteSet(chainID, blockHeight, 1, cmtproto.PrecommitType, cmtValSet) @@ -544,7 +544,7 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, require.NoError(chain.TB, err) signedHeader := &cmtproto.SignedHeader{ - Header: tmHeader.ToProto(), + Header: cmtHeader.ToProto(), Commit: extCommit.ToCommit().ToProto(), } @@ -554,10 +554,10 @@ func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, valSet.TotalVotingPower = cmtValSet.TotalVotingPower() } - if tmTrustedVals != nil { - trustedVals, err = tmTrustedVals.ToProto() + if cmtTrustedVals != nil { + trustedVals, err = cmtTrustedVals.ToProto() require.NoError(chain.TB, err) - trustedVals.TotalVotingPower = tmTrustedVals.TotalVotingPower() + trustedVals.TotalVotingPower = cmtTrustedVals.TotalVotingPower() } // The trusted fields may be nil. They may be filled before relaying messages to a client. diff --git a/testing/mock/privval.go b/testing/mock/privval.go index 0fc09423507..7abc6341ead 100644 --- a/testing/mock/privval.go +++ b/testing/mock/privval.go @@ -8,11 +8,11 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cometbft/cometbft/crypto" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmttypes "github.com/cometbft/cometbft/types" ) -var _ tmtypes.PrivValidator = PV{} +var _ cmttypes.PrivValidator = PV{} // MockPV implements PrivValidator without any safety or persistence. // Only use it for testing. @@ -30,8 +30,8 @@ func (pv PV) GetPubKey() (crypto.PubKey, error) { } // SignVote implements PrivValidator interface -func (pv PV) SignVote(chainID string, vote *tmproto.Vote) error { - signBytes := tmtypes.VoteSignBytes(chainID, vote) +func (pv PV) SignVote(chainID string, vote *cmtproto.Vote) error { + signBytes := cmttypes.VoteSignBytes(chainID, vote) sig, err := pv.PrivKey.Sign(signBytes) if err != nil { return err @@ -40,8 +40,8 @@ func (pv PV) SignVote(chainID string, vote *tmproto.Vote) error { var extSig []byte // We only sign vote extensions for non-nil precommits - if vote.Type == tmproto.PrecommitType && !tmtypes.ProtoBlockIDIsNil(&vote.BlockID) { - extSignBytes := tmtypes.VoteExtensionSignBytes(chainID, vote) + if vote.Type == cmtproto.PrecommitType && !cmttypes.ProtoBlockIDIsNil(&vote.BlockID) { + extSignBytes := cmttypes.VoteExtensionSignBytes(chainID, vote) extSig, err = pv.PrivKey.Sign(extSignBytes) if err != nil { return err @@ -54,8 +54,8 @@ func (pv PV) SignVote(chainID string, vote *tmproto.Vote) error { } // SignProposal implements PrivValidator interface -func (pv PV) SignProposal(chainID string, proposal *tmproto.Proposal) error { - signBytes := tmtypes.ProposalSignBytes(chainID, proposal) +func (pv PV) SignProposal(chainID string, proposal *cmtproto.Proposal) error { + signBytes := cmttypes.ProposalSignBytes(chainID, proposal) sig, err := pv.PrivKey.Sign(signBytes) if err != nil { return err diff --git a/testing/mock/privval_test.go b/testing/mock/privval_test.go index b80d84e5109..3184370661d 100644 --- a/testing/mock/privval_test.go +++ b/testing/mock/privval_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" + cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" + cmttypes "github.com/cometbft/cometbft/types" "github.com/cosmos/ibc-go/v8/testing/mock" ) @@ -24,11 +24,11 @@ func TestSignVote(t *testing.T) { pv := mock.NewPV() pk, _ := pv.GetPubKey() - vote := &tmproto.Vote{Height: 2} + vote := &cmtproto.Vote{Height: 2} err := pv.SignVote(chainID, vote) require.NoError(t, err) - msg := tmtypes.VoteSignBytes(chainID, vote) + msg := cmttypes.VoteSignBytes(chainID, vote) ok := pk.VerifySignature(msg, vote.Signature) require.True(t, ok) } @@ -37,11 +37,11 @@ func TestSignProposal(t *testing.T) { pv := mock.NewPV() pk, _ := pv.GetPubKey() - proposal := &tmproto.Proposal{Round: 2} + proposal := &cmtproto.Proposal{Round: 2} err := pv.SignProposal(chainID, proposal) require.NoError(t, err) - msg := tmtypes.ProposalSignBytes(chainID, proposal) + msg := cmttypes.ProposalSignBytes(chainID, proposal) ok := pk.VerifySignature(msg, proposal.Signature) require.True(t, ok) } diff --git a/testing/utils.go b/testing/utils.go index a1178929e3f..16bf2492248 100644 --- a/testing/utils.go +++ b/testing/utils.go @@ -7,14 +7,14 @@ import ( "github.com/stretchr/testify/require" abci "github.com/cometbft/cometbft/abci/types" - tmtypes "github.com/cometbft/cometbft/types" + cmttypes "github.com/cometbft/cometbft/types" ) -// ApplyValSetChanges takes in tmtypes.ValidatorSet and []abci.ValidatorUpdate and will return a new tmtypes.ValidatorSet which has the +// ApplyValSetChanges takes in cmttypes.ValidatorSet and []abci.ValidatorUpdate and will return a new cmttypes.ValidatorSet which has the // provided validator updates applied to the provided validator set. -func ApplyValSetChanges(tb testing.TB, valSet *tmtypes.ValidatorSet, valUpdates []abci.ValidatorUpdate) *tmtypes.ValidatorSet { +func ApplyValSetChanges(tb testing.TB, valSet *cmttypes.ValidatorSet, valUpdates []abci.ValidatorUpdate) *cmttypes.ValidatorSet { tb.Helper() - updates, err := tmtypes.PB2TM.ValidatorUpdates(valUpdates) + updates, err := cmttypes.PB2TM.ValidatorUpdates(valUpdates) require.NoError(tb, err) // must copy since validator set will mutate with UpdateWithChangeSet