mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-10 22:10:11 +00:00
make the rest of the code compile
This commit is contained in:
56
node/node.go
56
node/node.go
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/rs/cors"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
cs "github.com/tendermint/tendermint/internal/consensus"
|
||||
@@ -30,6 +29,10 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/strings"
|
||||
tmtime "github.com/tendermint/tendermint/libs/time"
|
||||
"github.com/tendermint/tendermint/light"
|
||||
"github.com/tendermint/tendermint/pkg/abci"
|
||||
"github.com/tendermint/tendermint/pkg/consensus"
|
||||
"github.com/tendermint/tendermint/pkg/events"
|
||||
p2ptypes "github.com/tendermint/tendermint/pkg/p2p"
|
||||
"github.com/tendermint/tendermint/privval"
|
||||
tmgrpc "github.com/tendermint/tendermint/privval/grpc"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
@@ -39,7 +42,6 @@ import (
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/state/indexer"
|
||||
"github.com/tendermint/tendermint/store"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// nodeImpl is the highest level interface to a full Tendermint node.
|
||||
@@ -49,8 +51,8 @@ type nodeImpl struct {
|
||||
|
||||
// config
|
||||
config *cfg.Config
|
||||
genesisDoc *types.GenesisDoc // initial validator set
|
||||
privValidator types.PrivValidator // local node's validator key
|
||||
genesisDoc *consensus.GenesisDoc // initial validator set
|
||||
privValidator consensus.PrivValidator // local node's validator key
|
||||
|
||||
// network
|
||||
transport *p2p.MConnTransport
|
||||
@@ -58,12 +60,12 @@ type nodeImpl struct {
|
||||
peerManager *p2p.PeerManager
|
||||
router *p2p.Router
|
||||
addrBook pex.AddrBook // known peers
|
||||
nodeInfo types.NodeInfo
|
||||
nodeKey types.NodeKey // our node privkey
|
||||
nodeInfo p2ptypes.NodeInfo
|
||||
nodeKey p2ptypes.NodeKey // our node privkey
|
||||
isListening bool
|
||||
|
||||
// services
|
||||
eventBus *types.EventBus // pub/sub for services
|
||||
eventBus *events.EventBus // pub/sub for services
|
||||
stateStore sm.Store
|
||||
blockStore *store.BlockStore // store the blockchain to disk
|
||||
bcReactor service.Service // for block-syncing
|
||||
@@ -88,7 +90,7 @@ type nodeImpl struct {
|
||||
// PrivValidator, ClientCreator, GenesisDoc, and DBProvider.
|
||||
// It implements NodeProvider.
|
||||
func newDefaultNode(config *cfg.Config, logger log.Logger) (service.Service, error) {
|
||||
nodeKey, err := types.LoadOrGenNodeKey(config.NodeKeyFile())
|
||||
nodeKey, err := p2ptypes.LoadOrGenNodeKey(config.NodeKeyFile())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load or gen node key %s: %w", config.NodeKeyFile(), err)
|
||||
}
|
||||
@@ -124,8 +126,8 @@ func newDefaultNode(config *cfg.Config, logger log.Logger) (service.Service, err
|
||||
|
||||
// makeNode returns a new, ready to go, Tendermint Node.
|
||||
func makeNode(config *cfg.Config,
|
||||
privValidator types.PrivValidator,
|
||||
nodeKey types.NodeKey,
|
||||
privValidator consensus.PrivValidator,
|
||||
nodeKey p2ptypes.NodeKey,
|
||||
clientCreator proxy.ClientCreator,
|
||||
genesisDocProvider genesisDocProvider,
|
||||
dbProvider cfg.DBProvider,
|
||||
@@ -459,7 +461,7 @@ func makeNode(config *cfg.Config,
|
||||
// makeSeedNode returns a new seed node, containing only p2p, pex reactor
|
||||
func makeSeedNode(config *cfg.Config,
|
||||
dbProvider cfg.DBProvider,
|
||||
nodeKey types.NodeKey,
|
||||
nodeKey p2ptypes.NodeKey,
|
||||
genesisDocProvider genesisDocProvider,
|
||||
logger log.Logger,
|
||||
) (service.Service, error) {
|
||||
@@ -586,7 +588,7 @@ func (n *nodeImpl) OnStart() error {
|
||||
}
|
||||
|
||||
// Start the transport.
|
||||
addr, err := types.NewNetAddressString(n.nodeKey.ID.AddressString(n.config.P2P.ListenAddress))
|
||||
addr, err := p2ptypes.NewNetAddressString(n.nodeKey.ID.AddressString(n.config.P2P.ListenAddress))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -986,18 +988,18 @@ func (n *nodeImpl) EvidencePool() *evidence.Pool {
|
||||
}
|
||||
|
||||
// EventBus returns the Node's EventBus.
|
||||
func (n *nodeImpl) EventBus() *types.EventBus {
|
||||
func (n *nodeImpl) EventBus() *events.EventBus {
|
||||
return n.eventBus
|
||||
}
|
||||
|
||||
// PrivValidator returns the Node's PrivValidator.
|
||||
// XXX: for convenience only!
|
||||
func (n *nodeImpl) PrivValidator() types.PrivValidator {
|
||||
func (n *nodeImpl) PrivValidator() consensus.PrivValidator {
|
||||
return n.privValidator
|
||||
}
|
||||
|
||||
// GenesisDoc returns the Node's GenesisDoc.
|
||||
func (n *nodeImpl) GenesisDoc() *types.GenesisDoc {
|
||||
func (n *nodeImpl) GenesisDoc() *consensus.GenesisDoc {
|
||||
return n.genesisDoc
|
||||
}
|
||||
|
||||
@@ -1029,7 +1031,7 @@ func (n *nodeImpl) IsListening() bool {
|
||||
}
|
||||
|
||||
// NodeInfo returns the Node's Info from the Switch.
|
||||
func (n *nodeImpl) NodeInfo() types.NodeInfo {
|
||||
func (n *nodeImpl) NodeInfo() p2ptypes.NodeInfo {
|
||||
return n.nodeInfo
|
||||
}
|
||||
|
||||
@@ -1042,7 +1044,7 @@ func startStateSync(
|
||||
config *cfg.StateSyncConfig,
|
||||
blockSync bool,
|
||||
stateInitHeight int64,
|
||||
eb *types.EventBus,
|
||||
eb *events.EventBus,
|
||||
) error {
|
||||
stateSyncLogger := eb.Logger.With("module", "statesync")
|
||||
|
||||
@@ -1050,7 +1052,7 @@ func startStateSync(
|
||||
|
||||
// at the beginning of the statesync start, we use the initialHeight as the event height
|
||||
// because of the statesync doesn't have the concreate state height before fetched the snapshot.
|
||||
d := types.EventDataStateSyncStatus{Complete: false, Height: stateInitHeight}
|
||||
d := events.EventDataStateSyncStatus{Complete: false, Height: stateInitHeight}
|
||||
if err := eb.PublishEventStateSyncStatus(d); err != nil {
|
||||
stateSyncLogger.Error("failed to emit the statesync start event", "err", err)
|
||||
}
|
||||
@@ -1069,7 +1071,7 @@ func startStateSync(
|
||||
|
||||
conR.SetStateSyncingMetrics(0)
|
||||
|
||||
d := types.EventDataStateSyncStatus{Complete: true, Height: state.LastBlockHeight}
|
||||
d := events.EventDataStateSyncStatus{Complete: true, Height: state.LastBlockHeight}
|
||||
if err := eb.PublishEventStateSyncStatus(d); err != nil {
|
||||
stateSyncLogger.Error("failed to emit the statesync start event", "err", err)
|
||||
}
|
||||
@@ -1082,7 +1084,7 @@ func startStateSync(
|
||||
return
|
||||
}
|
||||
|
||||
d := types.EventDataBlockSyncStatus{Complete: false, Height: state.LastBlockHeight}
|
||||
d := events.EventDataBlockSyncStatus{Complete: false, Height: state.LastBlockHeight}
|
||||
if err := eb.PublishEventBlockSyncStatus(d); err != nil {
|
||||
stateSyncLogger.Error("failed to emit the block sync starting event", "err", err)
|
||||
}
|
||||
@@ -1097,13 +1099,13 @@ func startStateSync(
|
||||
// genesisDocProvider returns a GenesisDoc.
|
||||
// It allows the GenesisDoc to be pulled from sources other than the
|
||||
// filesystem, for instance from a distributed key-value store cluster.
|
||||
type genesisDocProvider func() (*types.GenesisDoc, error)
|
||||
type genesisDocProvider func() (*consensus.GenesisDoc, error)
|
||||
|
||||
// defaultGenesisDocProviderFunc returns a GenesisDocProvider that loads
|
||||
// the GenesisDoc from the config.GenesisFile() on the filesystem.
|
||||
func defaultGenesisDocProviderFunc(config *cfg.Config) genesisDocProvider {
|
||||
return func() (*types.GenesisDoc, error) {
|
||||
return types.GenesisDocFromFile(config.GenesisFile())
|
||||
return func() (*consensus.GenesisDoc, error) {
|
||||
return consensus.GenesisDocFromFile(config.GenesisFile())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1131,7 +1133,7 @@ func defaultMetricsProvider(config *cfg.InstrumentationConfig) metricsProvider {
|
||||
// returns the genesis doc loaded through the given provider.
|
||||
func loadStateFromDBOrGenesisDocProvider(
|
||||
stateStore sm.Store,
|
||||
genDoc *types.GenesisDoc,
|
||||
genDoc *consensus.GenesisDoc,
|
||||
) (sm.State, error) {
|
||||
|
||||
// 1. Attempt to load state form the database
|
||||
@@ -1155,7 +1157,7 @@ func createAndStartPrivValidatorSocketClient(
|
||||
listenAddr,
|
||||
chainID string,
|
||||
logger log.Logger,
|
||||
) (types.PrivValidator, error) {
|
||||
) (consensus.PrivValidator, error) {
|
||||
|
||||
pve, err := privval.NewSignerListener(listenAddr, logger)
|
||||
if err != nil {
|
||||
@@ -1186,7 +1188,7 @@ func createAndStartPrivValidatorGRPCClient(
|
||||
config *cfg.Config,
|
||||
chainID string,
|
||||
logger log.Logger,
|
||||
) (types.PrivValidator, error) {
|
||||
) (consensus.PrivValidator, error) {
|
||||
pvsc, err := tmgrpc.DialRemoteSigner(
|
||||
config.PrivValidator,
|
||||
chainID,
|
||||
@@ -1216,7 +1218,7 @@ func getRouterConfig(conf *cfg.Config, proxyApp proxy.AppConns) p2p.RouterOption
|
||||
}
|
||||
|
||||
if conf.FilterPeers && proxyApp != nil {
|
||||
opts.FilterPeerByID = func(ctx context.Context, id types.NodeID) error {
|
||||
opts.FilterPeerByID = func(ctx context.Context, id p2ptypes.NodeID) error {
|
||||
res, err := proxyApp.Query().QuerySync(context.Background(), abci.RequestQuery{
|
||||
Path: fmt.Sprintf("/p2p/filter/id/%s", id),
|
||||
})
|
||||
|
||||
@@ -22,23 +22,27 @@ import (
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
consmocks "github.com/tendermint/tendermint/internal/consensus/mocks"
|
||||
ssmocks "github.com/tendermint/tendermint/internal/statesync/mocks"
|
||||
|
||||
"github.com/tendermint/tendermint/internal/evidence"
|
||||
"github.com/tendermint/tendermint/internal/mempool"
|
||||
mempoolv0 "github.com/tendermint/tendermint/internal/mempool/v0"
|
||||
statesync "github.com/tendermint/tendermint/internal/statesync"
|
||||
ssmocks "github.com/tendermint/tendermint/internal/statesync/mocks"
|
||||
"github.com/tendermint/tendermint/internal/test/factory"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
tmtime "github.com/tendermint/tendermint/libs/time"
|
||||
"github.com/tendermint/tendermint/pkg/block"
|
||||
"github.com/tendermint/tendermint/pkg/consensus"
|
||||
"github.com/tendermint/tendermint/pkg/events"
|
||||
evtypes "github.com/tendermint/tendermint/pkg/evidence"
|
||||
"github.com/tendermint/tendermint/pkg/metadata"
|
||||
p2ptypes "github.com/tendermint/tendermint/pkg/p2p"
|
||||
"github.com/tendermint/tendermint/privval"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
"github.com/tendermint/tendermint/state/indexer"
|
||||
"github.com/tendermint/tendermint/store"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
func TestNodeStartStop(t *testing.T) {
|
||||
@@ -56,7 +60,7 @@ func TestNodeStartStop(t *testing.T) {
|
||||
t.Logf("Started node %v", n.sw.NodeInfo())
|
||||
|
||||
// wait for the node to produce a block
|
||||
blocksSub, err := n.EventBus().Subscribe(context.Background(), "node_test", types.EventQueryNewBlock)
|
||||
blocksSub, err := n.EventBus().Subscribe(context.Background(), "node_test", events.EventQueryNewBlock)
|
||||
require.NoError(t, err)
|
||||
select {
|
||||
case <-blocksSub.Out():
|
||||
@@ -148,7 +152,7 @@ func TestNodeSetPrivValTCP(t *testing.T) {
|
||||
signerServer := privval.NewSignerServer(
|
||||
dialerEndpoint,
|
||||
config.ChainID(),
|
||||
types.NewMockPV(),
|
||||
consensus.NewMockPV(),
|
||||
)
|
||||
|
||||
go func() {
|
||||
@@ -193,7 +197,7 @@ func TestNodeSetPrivValIPC(t *testing.T) {
|
||||
pvsc := privval.NewSignerServer(
|
||||
dialerEndpoint,
|
||||
config.ChainID(),
|
||||
types.NewMockPV(),
|
||||
consensus.NewMockPV(),
|
||||
)
|
||||
|
||||
go func() {
|
||||
@@ -257,14 +261,14 @@ func TestCreateProposalBlock(t *testing.T) {
|
||||
// than can fit in a block
|
||||
var currentBytes int64 = 0
|
||||
for currentBytes <= maxEvidenceBytes {
|
||||
ev := types.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain")
|
||||
ev := evtypes.NewMockDuplicateVoteEvidenceWithValidator(height, time.Now(), privVals[0], "test-chain")
|
||||
currentBytes += int64(len(ev.Bytes()))
|
||||
evidencePool.ReportConflictingVotes(ev.VoteA, ev.VoteB)
|
||||
}
|
||||
|
||||
evList, size := evidencePool.PendingEvidence(state.ConsensusParams.Evidence.MaxBytes)
|
||||
require.Less(t, size, state.ConsensusParams.Evidence.MaxBytes+1)
|
||||
evData := &types.EvidenceData{Evidence: evList}
|
||||
evData := &block.EvidenceData{Evidence: evList}
|
||||
require.EqualValues(t, size, evData.ByteSize())
|
||||
|
||||
// fill the mempool with more txs
|
||||
@@ -285,7 +289,7 @@ func TestCreateProposalBlock(t *testing.T) {
|
||||
blockStore,
|
||||
)
|
||||
|
||||
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
|
||||
commit := metadata.NewCommit(height-1, 0, metadata.BlockID{}, nil)
|
||||
block, _ := blockExec.CreateProposalBlock(
|
||||
height,
|
||||
state, commit,
|
||||
@@ -296,7 +300,7 @@ func TestCreateProposalBlock(t *testing.T) {
|
||||
partSet := block.MakePartSet(partSize)
|
||||
assert.Less(t, partSet.ByteSize(), int64(maxBytes))
|
||||
|
||||
partSetFromHeader := types.NewPartSetFromHeader(partSet.Header())
|
||||
partSetFromHeader := metadata.NewPartSetFromHeader(partSet.Header())
|
||||
for partSetFromHeader.Count() < partSetFromHeader.Total() {
|
||||
added, err := partSetFromHeader.AddPart(partSet.GetPart(int(partSetFromHeader.Count())))
|
||||
require.NoError(t, err)
|
||||
@@ -340,7 +344,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) {
|
||||
mp.SetLogger(logger)
|
||||
|
||||
// fill the mempool with one txs just below the maximum size
|
||||
txLength := int(types.MaxDataBytesNoEvidence(maxBytes, 1))
|
||||
txLength := int(block.MaxDataBytesNoEvidence(maxBytes, 1))
|
||||
tx := tmrand.Bytes(txLength - 4) // to account for the varint
|
||||
err = mp.CheckTx(context.Background(), tx, nil, mempool.TxInfo{})
|
||||
assert.NoError(t, err)
|
||||
@@ -354,7 +358,7 @@ func TestMaxTxsProposalBlockSize(t *testing.T) {
|
||||
blockStore,
|
||||
)
|
||||
|
||||
commit := types.NewCommit(height-1, 0, types.BlockID{}, nil)
|
||||
commit := metadata.NewCommit(height-1, 0, metadata.BlockID{}, nil)
|
||||
block, _ := blockExec.CreateProposalBlock(
|
||||
height,
|
||||
state, commit,
|
||||
@@ -381,7 +385,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
|
||||
|
||||
logger := log.TestingLogger()
|
||||
|
||||
state, stateDB, _ := state(types.MaxVotesCount, int64(1))
|
||||
state, stateDB, _ := state(consensus.MaxVotesCount, int64(1))
|
||||
stateStore := sm.NewStore(stateDB)
|
||||
blockStore := store.NewBlockStore(dbm.NewMemDB())
|
||||
const maxBytes int64 = 1024 * 1024 * 2
|
||||
@@ -400,7 +404,7 @@ func TestMaxProposalBlockSize(t *testing.T) {
|
||||
mp.SetLogger(logger)
|
||||
|
||||
// fill the mempool with one txs just below the maximum size
|
||||
txLength := int(types.MaxDataBytesNoEvidence(maxBytes, types.MaxVotesCount))
|
||||
txLength := int(block.MaxDataBytesNoEvidence(maxBytes, consensus.MaxVotesCount))
|
||||
tx := tmrand.Bytes(txLength - 6) // to account for the varint
|
||||
err = mp.CheckTx(context.Background(), tx, nil, mempool.TxInfo{})
|
||||
assert.NoError(t, err)
|
||||
@@ -421,9 +425,9 @@ func TestMaxProposalBlockSize(t *testing.T) {
|
||||
blockStore,
|
||||
)
|
||||
|
||||
blockID := types.BlockID{
|
||||
blockID := metadata.BlockID{
|
||||
Hash: tmhash.Sum([]byte("blockID_hash")),
|
||||
PartSetHeader: types.PartSetHeader{
|
||||
PartSetHeader: metadata.PartSetHeader{
|
||||
Total: math.MaxInt32,
|
||||
Hash: tmhash.Sum([]byte("blockID_part_set_header_hash")),
|
||||
},
|
||||
@@ -439,26 +443,26 @@ func TestMaxProposalBlockSize(t *testing.T) {
|
||||
state.Version.Consensus.Block = math.MaxInt64
|
||||
state.Version.Consensus.App = math.MaxInt64
|
||||
maxChainID := ""
|
||||
for i := 0; i < types.MaxChainIDLen; i++ {
|
||||
for i := 0; i < metadata.MaxChainIDLen; i++ {
|
||||
maxChainID += "𠜎"
|
||||
}
|
||||
state.ChainID = maxChainID
|
||||
|
||||
cs := types.CommitSig{
|
||||
BlockIDFlag: types.BlockIDFlagNil,
|
||||
cs := metadata.CommitSig{
|
||||
BlockIDFlag: metadata.BlockIDFlagNil,
|
||||
ValidatorAddress: crypto.AddressHash([]byte("validator_address")),
|
||||
Timestamp: timestamp,
|
||||
Signature: crypto.CRandBytes(types.MaxSignatureSize),
|
||||
Signature: crypto.CRandBytes(metadata.MaxSignatureSize),
|
||||
}
|
||||
|
||||
commit := &types.Commit{
|
||||
commit := &metadata.Commit{
|
||||
Height: math.MaxInt64,
|
||||
Round: math.MaxInt32,
|
||||
BlockID: blockID,
|
||||
}
|
||||
|
||||
// add maximum amount of signatures to a single commit
|
||||
for i := 0; i < types.MaxVotesCount; i++ {
|
||||
for i := 0; i < consensus.MaxVotesCount; i++ {
|
||||
commit.Signatures = append(commit.Signatures, cs)
|
||||
}
|
||||
|
||||
@@ -475,8 +479,8 @@ func TestMaxProposalBlockSize(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// require that the header and commit be the max possible size
|
||||
require.Equal(t, int64(pb.Header.Size()), types.MaxHeaderBytes)
|
||||
require.Equal(t, int64(pb.LastCommit.Size()), types.MaxCommitBytes(types.MaxVotesCount))
|
||||
require.Equal(t, int64(pb.Header.Size()), metadata.MaxHeaderBytes)
|
||||
require.Equal(t, int64(pb.LastCommit.Size()), metadata.MaxCommitBytes(consensus.MaxVotesCount))
|
||||
// make sure that the block is less than the max possible size
|
||||
assert.Equal(t, int64(pb.Size()), maxBytes)
|
||||
// because of the proto overhead we expect the part set bytes to be equal or
|
||||
@@ -490,7 +494,7 @@ func TestNodeNewSeedNode(t *testing.T) {
|
||||
config.Mode = cfg.ModeSeed
|
||||
defer os.RemoveAll(config.RootDir)
|
||||
|
||||
nodeKey, err := types.LoadOrGenNodeKey(config.NodeKeyFile())
|
||||
nodeKey, err := p2ptypes.LoadOrGenNodeKey(config.NodeKeyFile())
|
||||
require.NoError(t, err)
|
||||
|
||||
ns, err := makeSeedNode(config,
|
||||
@@ -594,20 +598,20 @@ func TestNodeSetEventSink(t *testing.T) {
|
||||
assert.Equal(t, e, err)
|
||||
}
|
||||
|
||||
func state(nVals int, height int64) (sm.State, dbm.DB, []types.PrivValidator) {
|
||||
privVals := make([]types.PrivValidator, nVals)
|
||||
vals := make([]types.GenesisValidator, nVals)
|
||||
func state(nVals int, height int64) (sm.State, dbm.DB, []consensus.PrivValidator) {
|
||||
privVals := make([]consensus.PrivValidator, nVals)
|
||||
vals := make([]consensus.GenesisValidator, nVals)
|
||||
for i := 0; i < nVals; i++ {
|
||||
privVal := types.NewMockPV()
|
||||
privVal := consensus.NewMockPV()
|
||||
privVals[i] = privVal
|
||||
vals[i] = types.GenesisValidator{
|
||||
vals[i] = consensus.GenesisValidator{
|
||||
Address: privVal.PrivKey.PubKey().Address(),
|
||||
PubKey: privVal.PrivKey.PubKey(),
|
||||
Power: 1000,
|
||||
Name: fmt.Sprintf("test%d", i),
|
||||
}
|
||||
}
|
||||
s, _ := sm.MakeGenesisState(&types.GenesisDoc{
|
||||
s, _ := sm.MakeGenesisState(&consensus.GenesisDoc{
|
||||
ChainID: "test-chain",
|
||||
Validators: vals,
|
||||
AppHash: nil,
|
||||
@@ -674,7 +678,7 @@ func TestNodeStartStateSync(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, eventBus)
|
||||
|
||||
sub, err := eventBus.Subscribe(context.Background(), "test-client", types.EventQueryStateSyncStatus, 10)
|
||||
sub, err := eventBus.Subscribe(context.Background(), "test-client", events.EventQueryStateSyncStatus, 10)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, sub)
|
||||
|
||||
@@ -712,7 +716,7 @@ func TestNodeStartStateSync(t *testing.T) {
|
||||
|
||||
func ensureStateSyncStatus(t *testing.T, msg tmpubsub.Message, complete bool, height int64) {
|
||||
t.Helper()
|
||||
status, ok := msg.Data().(types.EventDataStateSyncStatus)
|
||||
status, ok := msg.Data().(events.EventDataStateSyncStatus)
|
||||
|
||||
require.True(t, ok)
|
||||
require.Equal(t, complete, status.Complete)
|
||||
|
||||
@@ -7,9 +7,10 @@ import (
|
||||
"github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/pkg/consensus"
|
||||
"github.com/tendermint/tendermint/pkg/p2p"
|
||||
"github.com/tendermint/tendermint/privval"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// NewDefault constructs a tendermint node service for use in go
|
||||
@@ -29,9 +30,9 @@ func NewDefault(conf *config.Config, logger log.Logger) (service.Service, error)
|
||||
func New(conf *config.Config,
|
||||
logger log.Logger,
|
||||
cf proxy.ClientCreator,
|
||||
gen *types.GenesisDoc,
|
||||
gen *consensus.GenesisDoc,
|
||||
) (service.Service, error) {
|
||||
nodeKey, err := types.LoadOrGenNodeKey(conf.NodeKeyFile())
|
||||
nodeKey, err := p2p.LoadOrGenNodeKey(conf.NodeKeyFile())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to load or gen node key %s: %w", conf.NodeKeyFile(), err)
|
||||
}
|
||||
@@ -41,7 +42,7 @@ func New(conf *config.Config,
|
||||
case nil:
|
||||
genProvider = defaultGenesisDocProviderFunc(conf)
|
||||
default:
|
||||
genProvider = func() (*types.GenesisDoc, error) { return gen, nil }
|
||||
genProvider = func() (*consensus.GenesisDoc, error) { return gen, nil }
|
||||
}
|
||||
|
||||
switch conf.Mode {
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
cfg "github.com/tendermint/tendermint/config"
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
bcv0 "github.com/tendermint/tendermint/internal/blocksync/v0"
|
||||
@@ -29,6 +28,10 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
tmstrings "github.com/tendermint/tendermint/libs/strings"
|
||||
"github.com/tendermint/tendermint/pkg/abci"
|
||||
"github.com/tendermint/tendermint/pkg/consensus"
|
||||
"github.com/tendermint/tendermint/pkg/events"
|
||||
p2ptypes "github.com/tendermint/tendermint/pkg/p2p"
|
||||
protop2p "github.com/tendermint/tendermint/proto/tendermint/p2p"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
sm "github.com/tendermint/tendermint/state"
|
||||
@@ -37,7 +40,6 @@ import (
|
||||
null "github.com/tendermint/tendermint/state/indexer/sink/null"
|
||||
psql "github.com/tendermint/tendermint/state/indexer/sink/psql"
|
||||
"github.com/tendermint/tendermint/store"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tendermint/version"
|
||||
)
|
||||
|
||||
@@ -62,8 +64,8 @@ func createAndStartProxyAppConns(clientCreator proxy.ClientCreator, logger log.L
|
||||
return proxyApp, nil
|
||||
}
|
||||
|
||||
func createAndStartEventBus(logger log.Logger) (*types.EventBus, error) {
|
||||
eventBus := types.NewEventBus()
|
||||
func createAndStartEventBus(logger log.Logger) (*events.EventBus, error) {
|
||||
eventBus := events.NewEventBus()
|
||||
eventBus.SetLogger(logger.With("module", "events"))
|
||||
if err := eventBus.Start(); err != nil {
|
||||
return nil, err
|
||||
@@ -74,7 +76,7 @@ func createAndStartEventBus(logger log.Logger) (*types.EventBus, error) {
|
||||
func createAndStartIndexerService(
|
||||
config *cfg.Config,
|
||||
dbProvider cfg.DBProvider,
|
||||
eventBus *types.EventBus,
|
||||
eventBus *events.EventBus,
|
||||
logger log.Logger,
|
||||
chainID string,
|
||||
) (*indexer.Service, []indexer.EventSink, error) {
|
||||
@@ -144,8 +146,8 @@ func doHandshake(
|
||||
stateStore sm.Store,
|
||||
state sm.State,
|
||||
blockStore sm.BlockStore,
|
||||
genDoc *types.GenesisDoc,
|
||||
eventBus types.BlockEventPublisher,
|
||||
genDoc *consensus.GenesisDoc,
|
||||
eventBus events.BlockEventPublisher,
|
||||
proxyApp proxy.AppConns,
|
||||
consensusLogger log.Logger) error {
|
||||
|
||||
@@ -386,10 +388,10 @@ func createConsensusReactor(
|
||||
blockStore sm.BlockStore,
|
||||
mp mempool.Mempool,
|
||||
evidencePool *evidence.Pool,
|
||||
privValidator types.PrivValidator,
|
||||
privValidator consensus.PrivValidator,
|
||||
csMetrics *cs.Metrics,
|
||||
waitSync bool,
|
||||
eventBus *types.EventBus,
|
||||
eventBus *events.EventBus,
|
||||
peerManager *p2p.PeerManager,
|
||||
router *p2p.Router,
|
||||
logger log.Logger,
|
||||
@@ -458,7 +460,7 @@ func createPeerManager(
|
||||
config *cfg.Config,
|
||||
dbProvider cfg.DBProvider,
|
||||
p2pLogger log.Logger,
|
||||
nodeID types.NodeID,
|
||||
nodeID p2ptypes.NodeID,
|
||||
) (*p2p.PeerManager, error) {
|
||||
|
||||
var maxConns uint16
|
||||
@@ -484,9 +486,9 @@ func createPeerManager(
|
||||
maxConns = 64
|
||||
}
|
||||
|
||||
privatePeerIDs := make(map[types.NodeID]struct{})
|
||||
privatePeerIDs := make(map[p2ptypes.NodeID]struct{})
|
||||
for _, id := range tmstrings.SplitAndTrimEmpty(config.P2P.PrivatePeerIDs, ",", " ") {
|
||||
privatePeerIDs[types.NodeID(id)] = struct{}{}
|
||||
privatePeerIDs[p2ptypes.NodeID(id)] = struct{}{}
|
||||
}
|
||||
|
||||
options := p2p.PeerManagerOptions{
|
||||
@@ -541,7 +543,7 @@ func createPeerManager(
|
||||
func createRouter(
|
||||
p2pLogger log.Logger,
|
||||
p2pMetrics *p2p.Metrics,
|
||||
nodeInfo types.NodeInfo,
|
||||
nodeInfo p2ptypes.NodeInfo,
|
||||
privKey crypto.PrivKey,
|
||||
peerManager *p2p.PeerManager,
|
||||
transport p2p.Transport,
|
||||
@@ -569,8 +571,8 @@ func createSwitch(
|
||||
consensusReactor *p2p.ReactorShim,
|
||||
evidenceReactor *p2p.ReactorShim,
|
||||
proxyApp proxy.AppConns,
|
||||
nodeInfo types.NodeInfo,
|
||||
nodeKey types.NodeKey,
|
||||
nodeInfo p2ptypes.NodeInfo,
|
||||
nodeKey p2ptypes.NodeKey,
|
||||
p2pLogger log.Logger,
|
||||
) *p2p.Switch {
|
||||
|
||||
@@ -648,21 +650,21 @@ func createSwitch(
|
||||
}
|
||||
|
||||
func createAddrBookAndSetOnSwitch(config *cfg.Config, sw *p2p.Switch,
|
||||
p2pLogger log.Logger, nodeKey types.NodeKey) (pex.AddrBook, error) {
|
||||
p2pLogger log.Logger, nodeKey p2ptypes.NodeKey) (pex.AddrBook, error) {
|
||||
|
||||
addrBook := pex.NewAddrBook(config.P2P.AddrBookFile(), config.P2P.AddrBookStrict)
|
||||
addrBook.SetLogger(p2pLogger.With("book", config.P2P.AddrBookFile()))
|
||||
|
||||
// Add ourselves to addrbook to prevent dialing ourselves
|
||||
if config.P2P.ExternalAddress != "" {
|
||||
addr, err := types.NewNetAddressString(nodeKey.ID.AddressString(config.P2P.ExternalAddress))
|
||||
addr, err := p2ptypes.NewNetAddressString(nodeKey.ID.AddressString(config.P2P.ExternalAddress))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("p2p.external_address is incorrect: %w", err)
|
||||
}
|
||||
addrBook.AddOurAddress(addr)
|
||||
}
|
||||
if config.P2P.ListenAddress != "" {
|
||||
addr, err := types.NewNetAddressString(nodeKey.ID.AddressString(config.P2P.ListenAddress))
|
||||
addr, err := p2ptypes.NewNetAddressString(nodeKey.ID.AddressString(config.P2P.ListenAddress))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("p2p.laddr is incorrect: %w", err)
|
||||
}
|
||||
@@ -713,11 +715,11 @@ func createPEXReactorV2(
|
||||
|
||||
func makeNodeInfo(
|
||||
config *cfg.Config,
|
||||
nodeKey types.NodeKey,
|
||||
nodeKey p2ptypes.NodeKey,
|
||||
eventSinks []indexer.EventSink,
|
||||
genDoc *types.GenesisDoc,
|
||||
genDoc *consensus.GenesisDoc,
|
||||
state sm.State,
|
||||
) (types.NodeInfo, error) {
|
||||
) (p2ptypes.NodeInfo, error) {
|
||||
txIndexerStatus := "off"
|
||||
|
||||
if indexer.IndexingEnabled(eventSinks) {
|
||||
@@ -733,11 +735,11 @@ func makeNodeInfo(
|
||||
bcChannel = bcv2.BlockchainChannel
|
||||
|
||||
default:
|
||||
return types.NodeInfo{}, fmt.Errorf("unknown blocksync version %s", config.BlockSync.Version)
|
||||
return p2ptypes.NodeInfo{}, fmt.Errorf("unknown blocksync version %s", config.BlockSync.Version)
|
||||
}
|
||||
|
||||
nodeInfo := types.NodeInfo{
|
||||
ProtocolVersion: types.ProtocolVersion{
|
||||
nodeInfo := p2ptypes.NodeInfo{
|
||||
ProtocolVersion: p2ptypes.ProtocolVersion{
|
||||
P2P: version.P2PProtocol, // global
|
||||
Block: state.Version.Consensus.Block,
|
||||
App: state.Version.Consensus.App,
|
||||
@@ -758,7 +760,7 @@ func makeNodeInfo(
|
||||
byte(statesync.LightBlockChannel),
|
||||
},
|
||||
Moniker: config.Moniker,
|
||||
Other: types.NodeInfoOther{
|
||||
Other: p2ptypes.NodeInfoOther{
|
||||
TxIndex: txIndexerStatus,
|
||||
RPCAddress: config.RPC.ListenAddress,
|
||||
},
|
||||
@@ -782,12 +784,12 @@ func makeNodeInfo(
|
||||
|
||||
func makeSeedNodeInfo(
|
||||
config *cfg.Config,
|
||||
nodeKey types.NodeKey,
|
||||
genDoc *types.GenesisDoc,
|
||||
nodeKey p2ptypes.NodeKey,
|
||||
genDoc *consensus.GenesisDoc,
|
||||
state sm.State,
|
||||
) (types.NodeInfo, error) {
|
||||
nodeInfo := types.NodeInfo{
|
||||
ProtocolVersion: types.ProtocolVersion{
|
||||
) (p2ptypes.NodeInfo, error) {
|
||||
nodeInfo := p2ptypes.NodeInfo{
|
||||
ProtocolVersion: p2ptypes.ProtocolVersion{
|
||||
P2P: version.P2PProtocol, // global
|
||||
Block: state.Version.Consensus.Block,
|
||||
App: state.Version.Consensus.App,
|
||||
@@ -797,7 +799,7 @@ func makeSeedNodeInfo(
|
||||
Version: version.TMVersion,
|
||||
Channels: []byte{},
|
||||
Moniker: config.Moniker,
|
||||
Other: types.NodeInfoOther{
|
||||
Other: p2ptypes.NodeInfoOther{
|
||||
TxIndex: "off",
|
||||
RPCAddress: config.RPC.ListenAddress,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user