node start up phases

This commit is contained in:
Callum Waters
2022-11-01 11:26:46 +01:00
parent a2610a9998
commit 933256c862
35 changed files with 644 additions and 518 deletions

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"time"
"github.com/tendermint/tendermint/blocksync"
cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/consensus"
"github.com/tendermint/tendermint/crypto"
@@ -16,6 +17,7 @@ import (
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/state/indexer"
"github.com/tendermint/tendermint/state/txindex"
"github.com/tendermint/tendermint/statesync"
"github.com/tendermint/tendermint/types"
)
@@ -91,6 +93,8 @@ type Environment struct {
TxIndexer txindex.TxIndexer
BlockIndexer indexer.BlockIndexer
ConsensusReactor *consensus.Reactor
BlocksyncReactor *blocksync.Reactor
StatesyncReactor *statesync.Reactor
EventBus *types.EventBus // thread safe
Mempool mempl.Mempool
@@ -199,9 +203,5 @@ func getHeight(latestHeight int64, heightPtr *int64) (int64, error) {
}
func latestUncommittedHeight() int64 {
nodeIsSyncing := env.ConsensusReactor.WaitSync()
if nodeIsSyncing {
return env.BlockStore.Height()
}
return env.BlockStore.Height() + 1
}

View File

@@ -51,6 +51,16 @@ func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
votingPower = val.VotingPower
}
phase := "initializing"
switch {
case env.StatesyncReactor.IsSyncing():
phase = "statesync"
case env.BlocksyncReactor.IsSyncing():
phase = "blocksync"
case env.ConsensusReactor.IsConsensusRunning():
phase = "consensus"
}
result := &ctypes.ResultStatus{
NodeInfo: env.P2PTransport.NodeInfo().(p2p.DefaultNodeInfo),
SyncInfo: ctypes.SyncInfo{
@@ -62,7 +72,7 @@ func Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, error) {
EarliestAppHash: earliestAppHash,
EarliestBlockHeight: earliestBlockHeight,
EarliestBlockTime: time.Unix(0, earliestBlockTimeNano),
CatchingUp: env.ConsensusReactor.WaitSync(),
Phase: phase,
},
ValidatorInfo: ctypes.ValidatorInfo{
Address: env.PubKey.Address(),

View File

@@ -86,7 +86,9 @@ type SyncInfo struct {
EarliestBlockHeight int64 `json:"earliest_block_height"`
EarliestBlockTime time.Time `json:"earliest_block_time"`
CatchingUp bool `json:"catching_up"`
// Phase inidicates which processes are advancing state:
// Either statesync, blocksync or consensus
Phase string `json:"phase"`
}
// Info about the node's validator