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
@@ -4,37 +4,37 @@ import (
"context"
abci "github.com/cometbft/cometbft/abci/types"
tmbytes "github.com/cometbft/cometbft/libs/bytes"
cmtbytes "github.com/cometbft/cometbft/libs/bytes"
rpcclient "github.com/cometbft/cometbft/rpc/client"
rpcclientmock "github.com/cometbft/cometbft/rpc/client/mock"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
tmtypes "github.com/cometbft/cometbft/types"
cmttypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/client"
)
var _ client.TendermintRPC = (*MockTendermintRPC)(nil)
var _ client.CometRPC = (*MockCometRPC)(nil)
type MockTendermintRPC struct {
type MockCometRPC struct {
rpcclientmock.Client
responseQuery abci.ResponseQuery
}
// NewMockTendermintRPC returns a mock TendermintRPC implementation.
// NewMockCometRPC returns a mock CometBFT RPC implementation.
// It is used for CLI testing.
func NewMockTendermintRPC(respQuery abci.ResponseQuery) MockTendermintRPC {
return MockTendermintRPC{responseQuery: respQuery}
func NewMockCometRPC(respQuery abci.ResponseQuery) MockCometRPC {
return MockCometRPC{responseQuery: respQuery}
}
func (MockTendermintRPC) BroadcastTxSync(context.Context, tmtypes.Tx) (*coretypes.ResultBroadcastTx, error) {
func (MockCometRPC) BroadcastTxSync(context.Context, cmttypes.Tx) (*coretypes.ResultBroadcastTx, error) {
return &coretypes.ResultBroadcastTx{Code: 0}, nil
}
func (m MockTendermintRPC) ABCIQueryWithOptions(
func (m MockCometRPC) ABCIQueryWithOptions(
_ context.Context,
_ string,
_ tmbytes.HexBytes,
_ cmtbytes.HexBytes,
_ rpcclient.ABCIQueryOptions,
) (*coretypes.ResultABCIQuery, error) {
return &coretypes.ResultABCIQuery{Response: m.responseQuery}, nil
+3 -3
View File
@@ -4,7 +4,7 @@ import (
"testing"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/stretchr/testify/assert"
@@ -25,7 +25,7 @@ func DefaultContext(key storetypes.StoreKey, tkey storetypes.StoreKey) sdk.Conte
if err != nil {
panic(err)
}
ctx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger())
ctx := sdk.NewContext(cms, cmtproto.Header{}, false, log.NewNopLogger())
return ctx
}
@@ -44,7 +44,7 @@ func DefaultContextWithDB(t *testing.T, key storetypes.StoreKey, tkey storetypes
err := cms.LoadLatestVersion()
assert.NoError(t, err)
ctx := sdk.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger())
ctx := sdk.NewContext(cms, cmtproto.Header{}, false, log.NewNopLogger())
return TestContext{ctx, db, cms}
}
+7 -7
View File
@@ -2,15 +2,15 @@ package mock
import (
"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"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)
var _ tmtypes.PrivValidator = PV{}
var _ cmttypes.PrivValidator = PV{}
// PV implements PrivValidator without any safety or persistence.
// Only use it for testing.
@@ -28,8 +28,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
@@ -39,8 +39,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
+3 -3
View File
@@ -3,7 +3,7 @@ package mock
import (
"testing"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/stretchr/testify/require"
)
@@ -16,7 +16,7 @@ func TestGetPubKey(t *testing.T) {
func TestSignVote(t *testing.T) {
pv := NewPV()
v := tmproto.Vote{}
v := cmtproto.Vote{}
err := pv.SignVote("chain-id", &v)
require.NoError(t, err)
require.NotNil(t, v.Signature)
@@ -24,7 +24,7 @@ func TestSignVote(t *testing.T) {
func TestSignProposal(t *testing.T) {
pv := NewPV()
p := tmproto.Proposal{}
p := cmtproto.Proposal{}
err := pv.SignProposal("chain-id", &p)
require.NoError(t, err)
require.NotNil(t, p.Signature)
+11 -11
View File
@@ -10,15 +10,15 @@ import (
reflect "reflect"
appmodule "cosmossdk.io/core/appmodule"
types "github.com/cometbft/cometbft/abci/types"
client "github.com/cosmos/cosmos-sdk/client"
codec "github.com/cosmos/cosmos-sdk/codec"
types "github.com/cosmos/cosmos-sdk/codec/types"
types0 "github.com/cosmos/cosmos-sdk/types"
types0 "github.com/cosmos/cosmos-sdk/codec/types"
types1 "github.com/cosmos/cosmos-sdk/types"
module "github.com/cosmos/cosmos-sdk/types/module"
gomock "github.com/golang/mock/gomock"
runtime "github.com/grpc-ecosystem/grpc-gateway/runtime"
cobra "github.com/spf13/cobra"
types1 "github.com/cometbft/cometbft/abci/types"
)
// MockAppModuleWithAllExtensions is a mock of AppModuleWithAllExtensions interface.
@@ -45,7 +45,7 @@ func (m *MockAppModuleWithAllExtensions) EXPECT() *MockAppModuleWithAllExtension
}
// BeginBlock mocks base method.
func (m *MockAppModuleWithAllExtensions) BeginBlock(arg0 types0.Context, arg1 types1.RequestBeginBlock) {
func (m *MockAppModuleWithAllExtensions) BeginBlock(arg0 types1.Context, arg1 types.RequestBeginBlock) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "BeginBlock", arg0, arg1)
}
@@ -85,10 +85,10 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) DefaultGenesis(arg0 interf
}
// EndBlock mocks base method.
func (m *MockAppModuleWithAllExtensions) EndBlock(arg0 types0.Context, arg1 types1.RequestEndBlock) []types1.ValidatorUpdate {
func (m *MockAppModuleWithAllExtensions) EndBlock(arg0 types1.Context, arg1 types.RequestEndBlock) []types.ValidatorUpdate {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EndBlock", arg0, arg1)
ret0, _ := ret[0].([]types1.ValidatorUpdate)
ret0, _ := ret[0].([]types.ValidatorUpdate)
return ret0
}
@@ -99,7 +99,7 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) EndBlock(arg0, arg1 interf
}
// ExportGenesis mocks base method.
func (m *MockAppModuleWithAllExtensions) ExportGenesis(arg0 types0.Context, arg1 codec.JSONCodec) json.RawMessage {
func (m *MockAppModuleWithAllExtensions) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
ret0, _ := ret[0].(json.RawMessage)
@@ -141,10 +141,10 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) GetTxCmd() *gomock.Call {
}
// InitGenesis mocks base method.
func (m *MockAppModuleWithAllExtensions) InitGenesis(arg0 types0.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types1.ValidatorUpdate {
func (m *MockAppModuleWithAllExtensions) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
ret0, _ := ret[0].([]types1.ValidatorUpdate)
ret0, _ := ret[0].([]types.ValidatorUpdate)
return ret0
}
@@ -181,7 +181,7 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) RegisterGRPCGatewayRoutes(
}
// RegisterInterfaces mocks base method.
func (m *MockAppModuleWithAllExtensions) RegisterInterfaces(arg0 types.InterfaceRegistry) {
func (m *MockAppModuleWithAllExtensions) RegisterInterfaces(arg0 types0.InterfaceRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
@@ -193,7 +193,7 @@ func (mr *MockAppModuleWithAllExtensionsMockRecorder) RegisterInterfaces(arg0 in
}
// RegisterInvariants mocks base method.
func (m *MockAppModuleWithAllExtensions) RegisterInvariants(arg0 types0.InvariantRegistry) {
func (m *MockAppModuleWithAllExtensions) RegisterInvariants(arg0 types1.InvariantRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInvariants", arg0)
}
+18 -18
View File
@@ -8,15 +8,15 @@ import (
json "encoding/json"
reflect "reflect"
types "github.com/cometbft/cometbft/abci/types"
client "github.com/cosmos/cosmos-sdk/client"
codec "github.com/cosmos/cosmos-sdk/codec"
types "github.com/cosmos/cosmos-sdk/codec/types"
types0 "github.com/cosmos/cosmos-sdk/types"
types0 "github.com/cosmos/cosmos-sdk/codec/types"
types1 "github.com/cosmos/cosmos-sdk/types"
module "github.com/cosmos/cosmos-sdk/types/module"
gomock "github.com/golang/mock/gomock"
runtime "github.com/grpc-ecosystem/grpc-gateway/runtime"
cobra "github.com/spf13/cobra"
types1 "github.com/cometbft/cometbft/abci/types"
)
// MockAppModuleBasic is a mock of AppModuleBasic interface.
@@ -97,7 +97,7 @@ func (mr *MockAppModuleBasicMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1 i
}
// RegisterInterfaces mocks base method.
func (m *MockAppModuleBasic) RegisterInterfaces(arg0 types.InterfaceRegistry) {
func (m *MockAppModuleBasic) RegisterInterfaces(arg0 types0.InterfaceRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
@@ -246,7 +246,7 @@ func (mr *MockAppModuleGenesisMockRecorder) DefaultGenesis(arg0 interface{}) *go
}
// ExportGenesis mocks base method.
func (m *MockAppModuleGenesis) ExportGenesis(arg0 types0.Context, arg1 codec.JSONCodec) json.RawMessage {
func (m *MockAppModuleGenesis) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
ret0, _ := ret[0].(json.RawMessage)
@@ -288,10 +288,10 @@ func (mr *MockAppModuleGenesisMockRecorder) GetTxCmd() *gomock.Call {
}
// InitGenesis mocks base method.
func (m *MockAppModuleGenesis) InitGenesis(arg0 types0.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types1.ValidatorUpdate {
func (m *MockAppModuleGenesis) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
ret0, _ := ret[0].([]types1.ValidatorUpdate)
ret0, _ := ret[0].([]types.ValidatorUpdate)
return ret0
}
@@ -328,7 +328,7 @@ func (mr *MockAppModuleGenesisMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1
}
// RegisterInterfaces mocks base method.
func (m *MockAppModuleGenesis) RegisterInterfaces(arg0 types.InterfaceRegistry) {
func (m *MockAppModuleGenesis) RegisterInterfaces(arg0 types0.InterfaceRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
@@ -403,7 +403,7 @@ func (mr *MockHasGenesisMockRecorder) DefaultGenesis(arg0 interface{}) *gomock.C
}
// ExportGenesis mocks base method.
func (m *MockHasGenesis) ExportGenesis(arg0 types0.Context, arg1 codec.JSONCodec) json.RawMessage {
func (m *MockHasGenesis) ExportGenesis(arg0 types1.Context, arg1 codec.JSONCodec) json.RawMessage {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ExportGenesis", arg0, arg1)
ret0, _ := ret[0].(json.RawMessage)
@@ -417,10 +417,10 @@ func (mr *MockHasGenesisMockRecorder) ExportGenesis(arg0, arg1 interface{}) *gom
}
// InitGenesis mocks base method.
func (m *MockHasGenesis) InitGenesis(arg0 types0.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types1.ValidatorUpdate {
func (m *MockHasGenesis) InitGenesis(arg0 types1.Context, arg1 codec.JSONCodec, arg2 json.RawMessage) []types.ValidatorUpdate {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "InitGenesis", arg0, arg1, arg2)
ret0, _ := ret[0].([]types1.ValidatorUpdate)
ret0, _ := ret[0].([]types.ValidatorUpdate)
return ret0
}
@@ -522,7 +522,7 @@ func (mr *MockAppModuleMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg1 interf
}
// RegisterInterfaces mocks base method.
func (m *MockAppModule) RegisterInterfaces(arg0 types.InterfaceRegistry) {
func (m *MockAppModule) RegisterInterfaces(arg0 types0.InterfaceRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
@@ -569,7 +569,7 @@ func (m *MockHasInvariants) EXPECT() *MockHasInvariantsMockRecorder {
}
// RegisterInvariants mocks base method.
func (m *MockHasInvariants) RegisterInvariants(arg0 types0.InvariantRegistry) {
func (m *MockHasInvariants) RegisterInvariants(arg0 types1.InvariantRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInvariants", arg0)
}
@@ -676,7 +676,7 @@ func (m *MockBeginBlockAppModule) EXPECT() *MockBeginBlockAppModuleMockRecorder
}
// BeginBlock mocks base method.
func (m *MockBeginBlockAppModule) BeginBlock(arg0 types0.Context, arg1 types1.RequestBeginBlock) {
func (m *MockBeginBlockAppModule) BeginBlock(arg0 types1.Context, arg1 types.RequestBeginBlock) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "BeginBlock", arg0, arg1)
}
@@ -742,7 +742,7 @@ func (mr *MockBeginBlockAppModuleMockRecorder) RegisterGRPCGatewayRoutes(arg0, a
}
// RegisterInterfaces mocks base method.
func (m *MockBeginBlockAppModule) RegisterInterfaces(arg0 types.InterfaceRegistry) {
func (m *MockBeginBlockAppModule) RegisterInterfaces(arg0 types0.InterfaceRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
@@ -789,10 +789,10 @@ func (m *MockEndBlockAppModule) EXPECT() *MockEndBlockAppModuleMockRecorder {
}
// EndBlock mocks base method.
func (m *MockEndBlockAppModule) EndBlock(arg0 types0.Context, arg1 types1.RequestEndBlock) []types1.ValidatorUpdate {
func (m *MockEndBlockAppModule) EndBlock(arg0 types1.Context, arg1 types.RequestEndBlock) []types.ValidatorUpdate {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "EndBlock", arg0, arg1)
ret0, _ := ret[0].([]types1.ValidatorUpdate)
ret0, _ := ret[0].([]types.ValidatorUpdate)
return ret0
}
@@ -857,7 +857,7 @@ func (mr *MockEndBlockAppModuleMockRecorder) RegisterGRPCGatewayRoutes(arg0, arg
}
// RegisterInterfaces mocks base method.
func (m *MockEndBlockAppModule) RegisterInterfaces(arg0 types.InterfaceRegistry) {
func (m *MockEndBlockAppModule) RegisterInterfaces(arg0 types0.InterfaceRegistry) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "RegisterInterfaces", arg0)
}
+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
}
+15 -15
View File
@@ -8,10 +8,10 @@ import (
"cosmossdk.io/depinject"
sdkmath "cosmossdk.io/math"
abci "github.com/cometbft/cometbft/abci/types"
tmjson "github.com/cometbft/cometbft/libs/json"
cmtjson "github.com/cometbft/cometbft/libs/json"
"github.com/cometbft/cometbft/libs/log"
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"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/cosmos-sdk/client/flags"
@@ -32,25 +32,25 @@ const DefaultGenTxGas = 10000000
// DefaultConsensusParams defines the default Tendermint consensus params used in
// SimApp testing.
var DefaultConsensusParams = &tmproto.ConsensusParams{
Block: &tmproto.BlockParams{
var DefaultConsensusParams = &cmtproto.ConsensusParams{
Block: &cmtproto.BlockParams{
MaxBytes: 200000,
MaxGas: 2000000,
},
Evidence: &tmproto.EvidenceParams{
Evidence: &cmtproto.EvidenceParams{
MaxAgeNumBlocks: 302400,
MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration
MaxBytes: 10000,
},
Validator: &tmproto.ValidatorParams{
Validator: &cmtproto.ValidatorParams{
PubKeyTypes: []string{
tmtypes.ABCIPubKeyTypeEd25519,
cmttypes.ABCIPubKeyTypeEd25519,
},
},
}
// CreateRandomValidatorSet creates a validator set with one random validator
func CreateRandomValidatorSet() (*tmtypes.ValidatorSet, error) {
func CreateRandomValidatorSet() (*cmttypes.ValidatorSet, error) {
privVal := mock.NewPV()
pubKey, err := privVal.GetPubKey()
if err != nil {
@@ -58,9 +58,9 @@ func CreateRandomValidatorSet() (*tmtypes.ValidatorSet, error) {
}
// create validator set with single validator
validator := tmtypes.NewValidator(pubKey, 1)
validator := cmttypes.NewValidator(pubKey, 1)
return tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}), nil
return cmttypes.NewValidatorSet([]*cmttypes.Validator{validator}), nil
}
type GenesisAccount struct {
@@ -74,7 +74,7 @@ type GenesisAccount struct {
// BaseAppOption defines the additional operations that must be run on baseapp before app start.
// AtGenesis defines if the app started should already have produced block or not.
type StartupConfig struct {
ValidatorSet func() (*tmtypes.ValidatorSet, error)
ValidatorSet func() (*cmttypes.ValidatorSet, error)
BaseAppOption runtime.BaseAppOption
AtGenesis bool
GenesisAccounts []GenesisAccount
@@ -153,7 +153,7 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon
}
// init chain must be called to stop deliverState from being nil
stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ")
stateBytes, err := cmtjson.MarshalIndent(genesisState, "", " ")
if err != nil {
return nil, fmt.Errorf("failed to marshal default genesis state: %w", err)
}
@@ -170,7 +170,7 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon
// commit genesis changes
if !startupConfig.AtGenesis {
app.Commit()
app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{
app.BeginBlock(abci.RequestBeginBlock{Header: cmtproto.Header{
Height: app.LastBlockHeight() + 1,
AppHash: app.LastCommitID().Hash,
ValidatorsHash: valSet.Hash(),
@@ -185,7 +185,7 @@ func SetupWithConfiguration(appConfig depinject.Config, startupConfig StartupCon
func GenesisStateWithValSet(
codec codec.Codec,
genesisState map[string]json.RawMessage,
valSet *tmtypes.ValidatorSet,
valSet *cmttypes.ValidatorSet,
genAccs []authtypes.GenesisAccount,
balances ...banktypes.Balance,
) (map[string]json.RawMessage, error) {