Skip to content

Commit

Permalink
refactor: rename commands to match consensus engine name (#14956)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Feb 8, 2023
1 parent 0c35d7a commit c17c3ca
Show file tree
Hide file tree
Showing 82 changed files with 384 additions and 331 deletions.
12 changes: 10 additions & 2 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ This guide provides instructions for upgrading to specific versions of Cosmos SD
### Consensus Engine

The Cosmos SDK has migrated to CometBFT as its default consensus engine.
This is a breaking changes that needs chains to re-generate their protos.
Some functions has been renamed to reflect the naming change, following an exhaustive list:
CometBFT is an implementation of the Tendermint consensus algorithm, and the successor of Tendermint Core.
Due to the import changes, this is a breaking change that needs chains to re-generate their protos.
Some functions have been renamed to reflect the naming change, following an exhaustive list:

* `client.TendermintRPC` -> `client.CometRPC`
* `clitestutil.MockTendermintRPC` -> `clitestutil.MockCometRPC`
* `clitestutilgenutil.CreateDefaultTendermintConfig` -> `clitestutilgenutil.CreateDefaultCometConfig`
* Package `client/grpc/tmservice` -> `client/grpc/cmtservice`

Additionally, the commands and flags mentionning `tendermint` have been renamed to `comet`.
However, these commands and flags is still supported for backward compatibility.

For backward compatibility, the `**/tendermint/**` gRPC services are still supported.

### Configuration

Expand Down
2 changes: 1 addition & 1 deletion api/cosmos/bank/v1beta1/query.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions client/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ func (ctx Context) BroadcastTx(txBytes []byte) (res *sdk.TxResponse, err error)
return res, err
}

// CheckTendermintError checks if the error returned from BroadcastTx is a
// Deprecated: Use CheckCometError instead.
func CheckTendermintError(err error, tx cmttypes.Tx) *sdk.TxResponse {
return CheckCometError(err, tx)
}

// CheckCometError checks if the error returned from BroadcastTx is a
// CometBFT error that is returned before the tx is submitted due to
// precondition checks that failed. If an CometBFT error is detected, this
// function returns the correct code back in TxResponse.
//
// TODO: Avoid brittle string matching in favor of error matching. This requires
// a change to CometBFT's RPCError type to allow retrieval or matching against
// a concrete error type.
func CheckTendermintError(err error, tx cmttypes.Tx) *sdk.TxResponse {
func CheckCometError(err error, tx cmttypes.Tx) *sdk.TxResponse {
if err == nil {
return nil
}
Expand Down Expand Up @@ -87,7 +92,7 @@ func (ctx Context) BroadcastTxSync(txBytes []byte) (*sdk.TxResponse, error) {
}

res, err := node.BroadcastTxSync(context.Background(), txBytes)
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
if errRes := CheckCometError(err, txBytes); errRes != nil {
return errRes, nil
}

Expand All @@ -103,7 +108,7 @@ func (ctx Context) BroadcastTxAsync(txBytes []byte) (*sdk.TxResponse, error) {
}

res, err := node.BroadcastTxAsync(context.Background(), txBytes)
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
if errRes := CheckCometError(err, txBytes); errRes != nil {
return errRes, nil
}

Expand Down
2 changes: 1 addition & 1 deletion client/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func AddTxFlagsToCmd(cmd *cobra.Command) {
f.String(FlagNote, "", "Note to add a description to the transaction (previously --memo)")
f.String(FlagFees, "", "Fees to pay along with transaction; eg: 10uatom")
f.String(FlagGasPrices, "", "Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom)")
f.String(FlagNode, "tcp://localhost:26657", "<host>:<port> to cometbft rpc interface for this chain")
f.String(FlagNode, "tcp://localhost:26657", "<host>:<port> to CometBFT rpc interface for this chain")
f.Bool(FlagUseLedger, false, "Use a connected Ledger device")
f.Float64(FlagGasAdjustment, DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ")
f.StringP(FlagBroadcastMode, "b", BroadcastSync, "Transaction broadcasting mode (sync|async)")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tmservice
package cmtservice

import (
"context"
Expand Down

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tmservice
package cmtservice

import (
"context"
Expand Down Expand Up @@ -33,7 +33,7 @@ type (
}
)

// NewQueryServer creates a new tendermint query server.
// NewQueryServer creates a new CometBFT query server.
func NewQueryServer(
clientCtx client.Context,
interfaceRegistry codectypes.InterfaceRegistry,
Expand Down Expand Up @@ -245,7 +245,7 @@ func (s queryServer) ABCIQuery(ctx context.Context, req *ABCIQueryRequest) (*ABC
return FromABCIResponseQuery(res), nil
}

// RegisterTendermintService registers the tendermint queries on the gRPC router.
// RegisterTendermintService registers the CometBFT queries on the gRPC router.
func RegisterTendermintService(
clientCtx client.Context,
server gogogrpc.Server,
Expand All @@ -255,7 +255,7 @@ func RegisterTendermintService(
RegisterServiceServer(server, NewQueryServer(clientCtx, iRegistry, queryFn))
}

// RegisterGRPCGatewayRoutes mounts the tendermint service's GRPC-gateway routes on the
// RegisterGRPCGatewayRoutes mounts the CometBFT service's GRPC-gateway routes on the
// given Mux.
func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) {
_ = RegisterServiceHandlerClient(context.Background(), mux, NewServiceClient(clientConn))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tmservice
package cmtservice

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package tmservice
package cmtservice

import (
abci "github.com/cometbft/cometbft/abci/types"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions client/grpc/tmservice/util.go → client/grpc/cmtservice/util.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package tmservice
package cmtservice

import (
tmprototypes "github.com/cometbft/cometbft/proto/tendermint/types"
cmtprototypes "github.com/cometbft/cometbft/proto/tendermint/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// convertHeader converts tendermint header to sdk header
func convertHeader(h tmprototypes.Header) Header {
// convertHeader converts CometBFT header to sdk header
func convertHeader(h cmtprototypes.Header) Header {
return Header{
Version: h.Version,
ChainID: h.ChainID,
Expand All @@ -25,8 +25,8 @@ func convertHeader(h tmprototypes.Header) Header {
}
}

// convertBlock converts tendermint block to sdk block
func convertBlock(tmblock *tmprototypes.Block) *Block {
// convertBlock converts CometBFT block to sdk block
func convertBlock(tmblock *cmtprototypes.Block) *Block {
b := new(Block)

b.Header = convertHeader(tmblock.Header)
Expand Down
2 changes: 1 addition & 1 deletion client/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var fallBackCodec = codec.NewProtoCodec(failingInterfaceRegistry{})
// Invoke implements the grpc ClientConn.Invoke method
func (ctx Context) Invoke(grpcCtx gocontext.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) {
// Two things can happen here:
// 1. either we're broadcasting a Tx, in which call we call Tendermint's broadcast endpoint directly,
// 1. either we're broadcasting a Tx, in which call we call CometBFT's broadcast endpoint directly,
// 2-1. or we are querying for state, in which case we call grpc if grpc client set.
// 2-2. or we are querying for state, in which case we call ABCI's Query if grpc client not set.

Expand Down
2 changes: 1 addition & 1 deletion client/keys/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Commands(defaultNodeHome string) *cobra.Command {
Use: "keys",
Short: "Manage your application's keys",
Long: `Keyring management commands. These keys may be in any format supported by the
Tendermint crypto library and can be used by light-clients, full nodes, or any other application
CometBFT crypto library and can be used by light-clients, full nodes, or any other application
that needs to sign with a private key.
The keyring supports the following backends:
Expand Down
6 changes: 3 additions & 3 deletions client/rpc/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)

// ValidatorInfo is info about the node's validator, same as Tendermint,
// ValidatorInfo is info about the node's validator, same as CometBFT,
// except that we use our own PubKey.
type validatorInfo struct {
Address bytes.HexBytes
PubKey cryptotypes.PubKey
VotingPower int64
}

// ResultStatus is node's info, same as Tendermint, except that we use our own
// ResultStatus is node's info, same as CometBFT, except that we use our own
// PubKey.
type resultStatus struct {
NodeInfo p2p.DefaultNodeInfo
Expand All @@ -50,7 +50,7 @@ func StatusCommand() *cobra.Command {
var pk cryptotypes.PubKey
// `status` has TM pubkeys, we need to convert them to our pubkeys.
if status.ValidatorInfo.PubKey != nil {
pk, err = cryptocodec.FromTmPubKeyInterface(status.ValidatorInfo.PubKey)
pk, err = cryptocodec.FromCmtPubKeyInterface(status.ValidatorInfo.PubKey)
if err != nil {
return err
}
Expand Down
9 changes: 5 additions & 4 deletions client/rpc/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
// ValidatorCommand returns the validator set for a given height
func ValidatorCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "tendermint-validator-set [height]",
Short: "Get the full tendermint validator set at given height",
Args: cobra.MaximumNArgs(1),
Use: "comet-validator-set [height]",
Aliases: []string{"cometbft-validator-set", "tendermint-validator-set"},
Short: "Get the full CometBFT validator set at given height",
Args: cobra.MaximumNArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
Expand Down Expand Up @@ -101,7 +102,7 @@ func (rvo ResultValidatorsOutput) String() string {
}

func validatorOutput(validator *cmttypes.Validator) (ValidatorOutput, error) {
pk, err := cryptocodec.FromTmPubKeyInterface(validator.PubKey)
pk, err := cryptocodec.FromCmtPubKeyInterface(validator.PubKey)
if err != nil {
return ValidatorOutput{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error {
return err
}

// broadcast to a Tendermint node
// broadcast to a CometBFT node
res, err := clientCtx.BroadcastTx(txBytes)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion client/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func ReadPageRequest(flagSet *pflag.FlagSet) (*query.PageRequest, error) {
}, nil
}

// NewClientFromNode sets up Client implementation that communicates with a Tendermint node over
// NewClientFromNode sets up Client implementation that communicates with a CometBFT node over
// JSON RPC and WebSockets
func NewClientFromNode(nodeURI string) (*rpchttp.HTTP, error) {
return rpchttp.New(nodeURI, "/websocket")
Expand Down
2 changes: 1 addition & 1 deletion codec/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func NewLegacyAmino() *LegacyAmino {
return &LegacyAmino{amino.NewCodec()}
}

// RegisterEvidences registers Tendermint evidence types with the provided Amino
// RegisterEvidences registers CometBFT evidence types with the provided Amino
// codec.
func RegisterEvidences(cdc *LegacyAmino) {
cdc.Amino.RegisterInterface((*cmttypes.Evidence)(nil), nil)
Expand Down
2 changes: 1 addition & 1 deletion codec/legacy/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// Cdc defines a global generic sealed Amino codec to be used throughout sdk. It
// has all Tendermint crypto and evidence types registered.
// has all CometBFT crypto and evidence types registered.
//
// TODO: Deprecated - remove this global.
var Cdc = codec.NewLegacyAmino()
Expand Down
Loading

0 comments on commit c17c3ca

Please sign in to comment.