refactor: rename to CometBFT (#14914)

This commit is contained in:
Julien Robert
2023-02-06 18:11:14 +00:00
committed by GitHub
parent 88909d6f2b
commit 80dd55f79b
274 changed files with 1506 additions and 1514 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ A typical testing flow might look like the following:
baseURL := val.APIAddress
// Use baseURL to make API HTTP requests or use val.RPCClient to make direct
// Tendermint RPC calls.
// CometBFT RPC calls.
// ...
}
+29 -29
View File
@@ -17,10 +17,10 @@ import (
"cosmossdk.io/depinject"
sdkmath "cosmossdk.io/math"
tmlog "github.com/cometbft/cometbft/libs/log"
tmrand "github.com/cometbft/cometbft/libs/rand"
cmtlog "github.com/cometbft/cometbft/libs/log"
cmtrand "github.com/cometbft/cometbft/libs/rand"
"github.com/cometbft/cometbft/node"
tmclient "github.com/cometbft/cometbft/rpc/client"
cmtclient "github.com/cometbft/cometbft/rpc/client"
dbm "github.com/cosmos/cosmos-db"
"github.com/spf13/cobra"
"google.golang.org/grpc"
@@ -85,7 +85,7 @@ func init() {
}
// AppConstructor defines a function which accepts a network configuration and
// creates an ABCI Application to provide to Tendermint.
// creates an ABCI Application to provide to CometBFT.
type (
AppConstructor = func(val ValidatorI) servertypes.Application
TestFixtureFactory = func() TestFixture
@@ -118,7 +118,7 @@ type Config struct {
StakingTokens sdkmath.Int // the amount of tokens each validator has available to stake
BondedTokens sdkmath.Int // the amount of tokens each validator stakes
PruningStrategy string // the pruning strategy each validator will have
EnableTMLogging bool // enable Tendermint logging to STDOUT
EnableTMLogging bool // enable CometBFT logging to STDOUT
CleanupDir bool // remove base temporary directory during cleanup
SigningAlgo string // signing algorithm for keys
KeyringOptions []keyring.Option // keyring configuration options
@@ -142,7 +142,7 @@ func DefaultConfig(factory TestFixtureFactory) Config {
AppConstructor: fixture.AppConstructor,
GenesisState: fixture.GenesisState,
TimeoutCommit: 2 * time.Second,
ChainID: "chain-" + tmrand.Str(6),
ChainID: "chain-" + cmtrand.Str(6),
NumValidators: 4,
BondDenom: sdk.DefaultBondDenom,
MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom),
@@ -229,7 +229,7 @@ type (
// clients. Typically, this test network would be used in client and integration
// testing where user input is expected.
//
// Note, due to Tendermint constraints in regards to RPC functionality, there
// Note, due to CometBFT constraints in regards to RPC functionality, there
// may only be one test network running at a time. Thus, any caller must be
// sure to Cleanup after testing is finished in order to allow other tests
// to create networks. In addition, only the first validator will have a valid
@@ -242,7 +242,7 @@ type (
Config Config
}
// Validator defines an in-process Tendermint validator node. Through this object,
// Validator defines an in-process CometBFT validator node. Through this object,
// a client can make RPC and API calls and interact with any client command
// or handler.
Validator struct {
@@ -258,7 +258,7 @@ type (
P2PAddress string
Address sdk.AccAddress
ValAddress sdk.ValAddress
RPCClient tmclient.Client
RPCClient cmtclient.Client
tmNode *node.Node
api *api.Server
@@ -351,13 +351,13 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
appCfg.Telemetry.Enabled = false
ctx := server.NewDefaultContext()
tmCfg := ctx.Config
tmCfg.Consensus.TimeoutCommit = cfg.TimeoutCommit
cmtCfg := ctx.Config
cmtCfg.Consensus.TimeoutCommit = cfg.TimeoutCommit
// Only allow the first validator to expose an RPC, API and gRPC
// server/client due to Tendermint in-process constraints.
// server/client due to CometBFT in-process constraints.
apiAddr := ""
tmCfg.RPC.ListenAddress = ""
cmtCfg.RPC.ListenAddress = ""
appCfg.GRPC.Enable = false
appCfg.GRPCWeb.Enable = false
apiListenAddr := ""
@@ -380,13 +380,13 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
apiAddr = fmt.Sprintf("http://%s:%s", apiURL.Hostname(), apiURL.Port())
if cfg.RPCAddress != "" {
tmCfg.RPC.ListenAddress = cfg.RPCAddress
cmtCfg.RPC.ListenAddress = cfg.RPCAddress
} else {
if len(portPool) == 0 {
return nil, fmt.Errorf("failed to get port for RPC server")
}
port := <-portPool
tmCfg.RPC.ListenAddress = fmt.Sprintf("tcp://0.0.0.0:%s", port)
cmtCfg.RPC.ListenAddress = fmt.Sprintf("tcp://0.0.0.0:%s", port)
}
if cfg.GRPCAddress != "" {
@@ -402,9 +402,9 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
appCfg.GRPCWeb.Enable = true
}
logger := tmlog.NewNopLogger()
logger := cmtlog.NewNopLogger()
if cfg.EnableTMLogging {
logger = tmlog.NewTMLogger(tmlog.NewSyncWriter(os.Stdout))
logger = cmtlog.NewTMLogger(cmtlog.NewSyncWriter(os.Stdout))
}
ctx.Logger = logger
@@ -424,8 +424,8 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
return nil, err
}
tmCfg.SetRoot(nodeDir)
tmCfg.Moniker = nodeDirName
cmtCfg.SetRoot(nodeDir)
cmtCfg.Moniker = nodeDirName
monikers[i] = nodeDirName
if len(portPool) == 0 {
@@ -433,18 +433,18 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
}
port := <-portPool
proxyAddr := fmt.Sprintf("tcp://0.0.0.0:%s", port)
tmCfg.ProxyApp = proxyAddr
cmtCfg.ProxyApp = proxyAddr
if len(portPool) == 0 {
return nil, fmt.Errorf("failed to get port for Proxy server")
}
port = <-portPool
p2pAddr := fmt.Sprintf("tcp://0.0.0.0:%s", port)
tmCfg.P2P.ListenAddress = p2pAddr
tmCfg.P2P.AddrBookStrict = false
tmCfg.P2P.AllowDuplicateIP = true
cmtCfg.P2P.ListenAddress = p2pAddr
cmtCfg.P2P.AddrBookStrict = false
cmtCfg.P2P.AllowDuplicateIP = true
nodeID, pubKey, err := genutil.InitializeNodeValidatorFiles(tmCfg)
nodeID, pubKey, err := genutil.InitializeNodeValidatorFiles(cmtCfg)
if err != nil {
return nil, err
}
@@ -496,7 +496,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
sdk.NewCoin(cfg.BondDenom, cfg.StakingTokens),
)
genFiles = append(genFiles, tmCfg.GenesisFile())
genFiles = append(genFiles, cmtCfg.GenesisFile())
genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: balances.Sort()})
genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0))
@@ -559,7 +559,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
clientCtx := client.Context{}.
WithKeyringDir(clientDir).
WithKeyring(kb).
WithHomeDir(tmCfg.RootDir).
WithHomeDir(cmtCfg.RootDir).
WithChainID(cfg.ChainID).
WithInterfaceRegistry(cfg.InterfaceRegistry).
WithCodec(cfg.Codec).
@@ -575,8 +575,8 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
NodeID: nodeID,
PubKey: pubKey,
Moniker: nodeDirName,
RPCAddress: tmCfg.RPC.ListenAddress,
P2PAddress: tmCfg.P2P.ListenAddress,
RPCAddress: cmtCfg.RPC.ListenAddress,
P2PAddress: cmtCfg.P2P.ListenAddress,
APIAddress: apiAddr,
Address: addr,
ValAddress: sdk.ValAddress(addr),
@@ -721,7 +721,7 @@ func (n *Network) WaitForNextBlock() error {
}
// Cleanup removes the root testing (temporary) directory and stops both the
// Tendermint and API services. It allows other callers to create and start
// CometBFT and API services. It allows other callers to create and start
// test networks. This method must be called when a test is finished, typically
// in a defer.
func (n *Network) Cleanup() {
+14 -14
View File
@@ -14,7 +14,7 @@ import (
"github.com/cometbft/cometbft/proxy"
"github.com/cometbft/cometbft/rpc/client/local"
"github.com/cometbft/cometbft/types"
tmtime "github.com/cometbft/cometbft/types/time"
cmttime "github.com/cometbft/cometbft/types/time"
"github.com/cosmos/cosmos-sdk/server/api"
servergrpc "github.com/cosmos/cosmos-sdk/server/grpc"
@@ -27,29 +27,29 @@ import (
func startInProcess(cfg Config, val *Validator) error {
logger := val.Ctx.Logger
tmCfg := val.Ctx.Config
tmCfg.Instrumentation.Prometheus = false
cmtCfg := val.Ctx.Config
cmtCfg.Instrumentation.Prometheus = false
if err := val.AppConfig.ValidateBasic(); err != nil {
return err
}
nodeKey, err := p2p.LoadOrGenNodeKey(tmCfg.NodeKeyFile())
nodeKey, err := p2p.LoadOrGenNodeKey(cmtCfg.NodeKeyFile())
if err != nil {
return err
}
app := cfg.AppConstructor(*val)
genDocProvider := node.DefaultGenesisDocProviderFunc(tmCfg)
genDocProvider := node.DefaultGenesisDocProviderFunc(cmtCfg)
tmNode, err := node.NewNode( //resleak:notresource
tmCfg,
pvm.LoadOrGenFilePV(tmCfg.PrivValidatorKeyFile(), tmCfg.PrivValidatorStateFile()),
cmtCfg,
pvm.LoadOrGenFilePV(cmtCfg.PrivValidatorKeyFile(), cmtCfg.PrivValidatorStateFile()),
nodeKey,
proxy.NewLocalClientCreator(app),
genDocProvider,
node.DefaultDBProvider,
node.DefaultMetricsProvider(tmCfg.Instrumentation),
node.DefaultMetricsProvider(cmtCfg.Instrumentation),
logger.With("module", val.Moniker),
)
if err != nil {
@@ -109,27 +109,27 @@ func startInProcess(cfg Config, val *Validator) error {
}
func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error {
genTime := tmtime.Now()
genTime := cmttime.Now()
for i := 0; i < cfg.NumValidators; i++ {
tmCfg := vals[i].Ctx.Config
cmtCfg := vals[i].Ctx.Config
nodeDir := filepath.Join(outputDir, vals[i].Moniker, "simd")
gentxsDir := filepath.Join(outputDir, "gentxs")
tmCfg.Moniker = vals[i].Moniker
tmCfg.SetRoot(nodeDir)
cmtCfg.Moniker = vals[i].Moniker
cmtCfg.SetRoot(nodeDir)
initCfg := genutiltypes.NewInitConfig(cfg.ChainID, gentxsDir, vals[i].NodeID, vals[i].PubKey)
genFile := tmCfg.GenesisFile()
genFile := cmtCfg.GenesisFile()
genDoc, err := types.GenesisDocFromFile(genFile)
if err != nil {
return err
}
appState, err := genutil.GenAppStateFromConfig(cfg.Codec, cfg.TxConfig,
tmCfg, initCfg, *genDoc, banktypes.GenesisBalancesIterator{}, genutiltypes.DefaultMessageValidator)
cmtCfg, initCfg, *genDoc, banktypes.GenesisBalancesIterator{}, genutiltypes.DefaultMessageValidator)
if err != nil {
return err
}