blockchain: rename to blocksync service (#6755)

This commit is contained in:
Callum Waters
2021-07-28 17:25:42 +02:00
committed by GitHub
parent e87b0391cb
commit 6ff4c3139c
54 changed files with 278 additions and 286 deletions

View File

@@ -72,6 +72,8 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi
- [crypto/sr25519] \#6526 Do not re-execute the Ed25519-style key derivation step when doing signing and verification. The derivation is now done once and only once. This breaks `sr25519.GenPrivKeyFromSecret` output compatibility. (@Yawning) - [crypto/sr25519] \#6526 Do not re-execute the Ed25519-style key derivation step when doing signing and verification. The derivation is now done once and only once. This breaks `sr25519.GenPrivKeyFromSecret` output compatibility. (@Yawning)
- [types] \#6627 Move `NodeKey` to types to make the type public. - [types] \#6627 Move `NodeKey` to types to make the type public.
- [config] \#6627 Extend `config` to contain methods `LoadNodeKeyID` and `LoadorGenNodeKeyID` - [config] \#6627 Extend `config` to contain methods `LoadNodeKeyID` and `LoadorGenNodeKeyID`
- [blocksync] \#6755 Rename `FastSync` and `Blockchain` package to `BlockSync`
(@cmwaters)
- Blockchain Protocol - Blockchain Protocol

View File

@@ -17,7 +17,7 @@ This guide provides instructions for upgrading to specific versions of Tendermin
### Config Changes ### Config Changes
* `fast_sync = "v1"` is no longer supported. Please use `v2` instead. * `fast_sync = "v1"` and `fast_sync = "v2"` are no longer supported. Please use `v0` instead.
* All config parameters are now hyphen-case (also known as kebab-case) instead of snake_case. Before restarting the node make sure * All config parameters are now hyphen-case (also known as kebab-case) instead of snake_case. Before restarting the node make sure
you have updated all the variables in your `config.toml` file. you have updated all the variables in your `config.toml` file.
@@ -29,10 +29,11 @@ This guide provides instructions for upgrading to specific versions of Tendermin
`Seeds`. Bootstrap peers are connected with on startup if needed for peer discovery. Unlike `Seeds`. Bootstrap peers are connected with on startup if needed for peer discovery. Unlike
persistent peers, there's no gaurantee that the node will remain connected with these peers. persistent peers, there's no gaurantee that the node will remain connected with these peers.
- configuration values starting with `priv-validator-` have moved to the new * configuration values starting with `priv-validator-` have moved to the new
`priv-validator` section, without the `priv-validator-` prefix. `priv-validator` section, without the `priv-validator-` prefix.
* Fast Sync v2 has been deprecated, please use v0 to sync a node. * The fast sync process as well as the blockchain package and service has all
been renamed to block sync
### CLI Changes ### CLI Changes

View File

@@ -29,8 +29,8 @@ const (
ModeValidator = "validator" ModeValidator = "validator"
ModeSeed = "seed" ModeSeed = "seed"
BlockchainV0 = "v0" BlockSyncV0 = "v0"
BlockchainV2 = "v2" BlockSyncV2 = "v2"
MempoolV0 = "v0" MempoolV0 = "v0"
MempoolV1 = "v1" MempoolV1 = "v1"
@@ -76,7 +76,7 @@ type Config struct {
P2P *P2PConfig `mapstructure:"p2p"` P2P *P2PConfig `mapstructure:"p2p"`
Mempool *MempoolConfig `mapstructure:"mempool"` Mempool *MempoolConfig `mapstructure:"mempool"`
StateSync *StateSyncConfig `mapstructure:"statesync"` StateSync *StateSyncConfig `mapstructure:"statesync"`
FastSync *FastSyncConfig `mapstructure:"fastsync"` BlockSync *BlockSyncConfig `mapstructure:"fastsync"`
Consensus *ConsensusConfig `mapstructure:"consensus"` Consensus *ConsensusConfig `mapstructure:"consensus"`
TxIndex *TxIndexConfig `mapstructure:"tx-index"` TxIndex *TxIndexConfig `mapstructure:"tx-index"`
Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"` Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"`
@@ -91,7 +91,7 @@ func DefaultConfig() *Config {
P2P: DefaultP2PConfig(), P2P: DefaultP2PConfig(),
Mempool: DefaultMempoolConfig(), Mempool: DefaultMempoolConfig(),
StateSync: DefaultStateSyncConfig(), StateSync: DefaultStateSyncConfig(),
FastSync: DefaultFastSyncConfig(), BlockSync: DefaultBlockSyncConfig(),
Consensus: DefaultConsensusConfig(), Consensus: DefaultConsensusConfig(),
TxIndex: DefaultTxIndexConfig(), TxIndex: DefaultTxIndexConfig(),
Instrumentation: DefaultInstrumentationConfig(), Instrumentation: DefaultInstrumentationConfig(),
@@ -114,7 +114,7 @@ func TestConfig() *Config {
P2P: TestP2PConfig(), P2P: TestP2PConfig(),
Mempool: TestMempoolConfig(), Mempool: TestMempoolConfig(),
StateSync: TestStateSyncConfig(), StateSync: TestStateSyncConfig(),
FastSync: TestFastSyncConfig(), BlockSync: TestBlockSyncConfig(),
Consensus: TestConsensusConfig(), Consensus: TestConsensusConfig(),
TxIndex: TestTxIndexConfig(), TxIndex: TestTxIndexConfig(),
Instrumentation: TestInstrumentationConfig(), Instrumentation: TestInstrumentationConfig(),
@@ -151,7 +151,7 @@ func (cfg *Config) ValidateBasic() error {
if err := cfg.StateSync.ValidateBasic(); err != nil { if err := cfg.StateSync.ValidateBasic(); err != nil {
return fmt.Errorf("error in [statesync] section: %w", err) return fmt.Errorf("error in [statesync] section: %w", err)
} }
if err := cfg.FastSync.ValidateBasic(); err != nil { if err := cfg.BlockSync.ValidateBasic(); err != nil {
return fmt.Errorf("error in [fastsync] section: %w", err) return fmt.Errorf("error in [fastsync] section: %w", err)
} }
if err := cfg.Consensus.ValidateBasic(); err != nil { if err := cfg.Consensus.ValidateBasic(); err != nil {
@@ -197,6 +197,7 @@ type BaseConfig struct { //nolint: maligned
// If this node is many blocks behind the tip of the chain, FastSync // If this node is many blocks behind the tip of the chain, FastSync
// allows them to catchup quickly by downloading blocks in parallel // allows them to catchup quickly by downloading blocks in parallel
// and verifying their commits // and verifying their commits
// TODO: This should be moved to the blocksync config
FastSyncMode bool `mapstructure:"fast-sync"` FastSyncMode bool `mapstructure:"fast-sync"`
// Database backend: goleveldb | cleveldb | boltdb | rocksdb // Database backend: goleveldb | cleveldb | boltdb | rocksdb
@@ -911,7 +912,7 @@ func DefaultStateSyncConfig() *StateSyncConfig {
} }
} }
// TestFastSyncConfig returns a default configuration for the state sync service // TestStateSyncConfig returns a default configuration for the state sync service
func TestStateSyncConfig() *StateSyncConfig { func TestStateSyncConfig() *StateSyncConfig {
return DefaultStateSyncConfig() return DefaultStateSyncConfig()
} }
@@ -967,34 +968,33 @@ func (cfg *StateSyncConfig) ValidateBasic() error {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// FastSyncConfig
// FastSyncConfig defines the configuration for the Tendermint fast sync service // BlockSyncConfig (formerly known as FastSync) defines the configuration for the Tendermint block sync service
type FastSyncConfig struct { type BlockSyncConfig struct {
Version string `mapstructure:"version"` Version string `mapstructure:"version"`
} }
// DefaultFastSyncConfig returns a default configuration for the fast sync service // DefaultBlockSyncConfig returns a default configuration for the block sync service
func DefaultFastSyncConfig() *FastSyncConfig { func DefaultBlockSyncConfig() *BlockSyncConfig {
return &FastSyncConfig{ return &BlockSyncConfig{
Version: BlockchainV0, Version: BlockSyncV0,
} }
} }
// TestFastSyncConfig returns a default configuration for the fast sync. // TestBlockSyncConfig returns a default configuration for the block sync.
func TestFastSyncConfig() *FastSyncConfig { func TestBlockSyncConfig() *BlockSyncConfig {
return DefaultFastSyncConfig() return DefaultBlockSyncConfig()
} }
// ValidateBasic performs basic validation. // ValidateBasic performs basic validation.
func (cfg *FastSyncConfig) ValidateBasic() error { func (cfg *BlockSyncConfig) ValidateBasic() error {
switch cfg.Version { switch cfg.Version {
case BlockchainV0: case BlockSyncV0:
return nil return nil
case BlockchainV2: case BlockSyncV2:
return errors.New("fastsync version v2 is no longer supported. Please use v0") return errors.New("blocksync version v2 is no longer supported. Please use v0")
default: default:
return fmt.Errorf("unknown fastsync version %s", cfg.Version) return fmt.Errorf("unknown blocksync version %s", cfg.Version)
} }
} }

View File

@@ -125,8 +125,8 @@ func TestStateSyncConfigValidateBasic(t *testing.T) {
require.NoError(t, cfg.ValidateBasic()) require.NoError(t, cfg.ValidateBasic())
} }
func TestFastSyncConfigValidateBasic(t *testing.T) { func TestBlockSyncConfigValidateBasic(t *testing.T) {
cfg := TestFastSyncConfig() cfg := TestBlockSyncConfig()
assert.NoError(t, cfg.ValidateBasic()) assert.NoError(t, cfg.ValidateBasic())
// tamper with version // tamper with version

View File

@@ -452,14 +452,14 @@ chunk-request-timeout = "{{ .StateSync.ChunkRequestTimeout }}"
fetchers = "{{ .StateSync.Fetchers }}" fetchers = "{{ .StateSync.Fetchers }}"
####################################################### #######################################################
### Fast Sync Configuration Connections ### ### Block Sync Configuration Connections ###
####################################################### #######################################################
[fastsync] [fastsync]
# Fast Sync version to use: # Block Sync version to use:
# 1) "v0" (default) - the legacy fast sync implementation # 1) "v0" (default) - the legacy block sync implementation
# 2) "v2" - DEPRECATED, please use v0 # 2) "v2" - DEPRECATED, please use v0
version = "{{ .FastSync.Version }}" version = "{{ .BlockSync.Version }}"
####################################################### #######################################################
### Consensus Configuration Options ### ### Consensus Configuration Options ###

View File

@@ -36,7 +36,7 @@ proxy-app = "tcp://127.0.0.1:26658"
# A custom human readable name for this node # A custom human readable name for this node
moniker = "anonymous" moniker = "anonymous"
# If this node is many blocks behind the tip of the chain, FastSync # If this node is many blocks behind the tip of the chain, BlockSync
# allows them to catchup quickly by downloading blocks in parallel # allows them to catchup quickly by downloading blocks in parallel
# and verifying their commits # and verifying their commits
fast-sync = true fast-sync = true
@@ -354,12 +354,12 @@ discovery-time = "15s"
temp-dir = "" temp-dir = ""
####################################################### #######################################################
### Fast Sync Configuration Connections ### ### BlockSync Configuration Connections ###
####################################################### #######################################################
[fastsync] [fastsync]
# Fast Sync version to use: # Block Sync version to use:
# 1) "v0" (default) - the legacy fast sync implementation # 1) "v0" (default) - the legacy block sync implementation
# 2) "v2" - complete redesign of v0, optimized for testability & readability # 2) "v2" - complete redesign of v0, optimized for testability & readability
version = "v0" version = "v0"

View File

@@ -14,7 +14,7 @@ This section dives into the internals of Go-Tendermint.
- [Subscribing to events](./subscription.md) - [Subscribing to events](./subscription.md)
- [Block Structure](./block-structure.md) - [Block Structure](./block-structure.md)
- [RPC](./rpc.md) - [RPC](./rpc.md)
- [Fast Sync](./fast-sync.md) - [Block Sync](./block-sync.md)
- [State Sync](./state-sync.md) - [State Sync](./state-sync.md)
- [Mempool](./mempool.md) - [Mempool](./mempool.md)
- [Light Client](./light-client.md) - [Light Client](./light-client.md)

View File

@@ -2,7 +2,8 @@
order: 10 order: 10
--- ---
# Fast Sync # Block Sync
*Formerly known as Fast Sync*
In a proof of work blockchain, syncing with the chain is the same In a proof of work blockchain, syncing with the chain is the same
process as staying up-to-date with the consensus: download blocks, and process as staying up-to-date with the consensus: download blocks, and
@@ -14,7 +15,7 @@ scratch can take a very long time. It's much faster to just download
blocks and check the merkle tree of validators than to run the real-time blocks and check the merkle tree of validators than to run the real-time
consensus gossip protocol. consensus gossip protocol.
## Using Fast Sync ## Using Block Sync
To support faster syncing, Tendermint offers a `fast-sync` mode, which To support faster syncing, Tendermint offers a `fast-sync` mode, which
is enabled by default, and can be toggled in the `config.toml` or via is enabled by default, and can be toggled in the `config.toml` or via
@@ -22,36 +23,36 @@ is enabled by default, and can be toggled in the `config.toml` or via
In this mode, the Tendermint daemon will sync hundreds of times faster In this mode, the Tendermint daemon will sync hundreds of times faster
than if it used the real-time consensus process. Once caught up, the than if it used the real-time consensus process. Once caught up, the
daemon will switch out of fast sync and into the normal consensus mode. daemon will switch out of Block Sync and into the normal consensus mode.
After running for some time, the node is considered `caught up` if it After running for some time, the node is considered `caught up` if it
has at least one peer and it's height is at least as high as the max has at least one peer and it's height is at least as high as the max
reported peer height. See [the IsCaughtUp reported peer height. See [the IsCaughtUp
method](https://github.com/tendermint/tendermint/blob/b467515719e686e4678e6da4e102f32a491b85a0/blockchain/pool.go#L128). method](https://github.com/tendermint/tendermint/blob/b467515719e686e4678e6da4e102f32a491b85a0/blockchain/pool.go#L128).
Note: There are three versions of fast sync. We recommend using v0 as v2 is still in beta. Note: There are two versions of Block Sync. We recommend using v0 as v2 is still in beta.
If you would like to use a different version you can do so by changing the version in the `config.toml`: If you would like to use a different version you can do so by changing the version in the `config.toml`:
```toml ```toml
####################################################### #######################################################
### Fast Sync Configuration Connections ### ### Block Sync Configuration Connections ###
####################################################### #######################################################
[fastsync] [fastsync]
# Fast Sync version to use: # Block Sync version to use:
# 1) "v0" (default) - the legacy fast sync implementation # 1) "v0" (default) - the legacy Block Sync implementation
# 2) "v2" - complete redesign of v0, optimized for testability & readability # 2) "v2" - complete redesign of v0, optimized for testability & readability
version = "v0" version = "v0"
``` ```
If we're lagging sufficiently, we should go back to fast syncing, but If we're lagging sufficiently, we should go back to block syncing, but
this is an [open issue](https://github.com/tendermint/tendermint/issues/129). this is an [open issue](https://github.com/tendermint/tendermint/issues/129).
## The Fast Sync event ## The Block Sync event
When the tendermint blockchain core launches, it might switch to the `fast-sync` When the tendermint blockchain core launches, it might switch to the `block-sync`
mode to catch up the states to the current network best height. the core will emits mode to catch up the states to the current network best height. the core will emits
a fast-sync event to expose the current status and the sync height. Once it catched a fast-sync event to expose the current status and the sync height. Once it catched
the network best height, it will switches to the state sync mechanism and then emit the network best height, it will switches to the state sync mechanism and then emit
another event for exposing the fast-sync `complete` status and the state `height`. another event for exposing the fast-sync `complete` status and the state `height`.
The user can query the events by subscribing `EventQueryFastSyncStatus` The user can query the events by subscribing `EventQueryBlockSyncStatus`
Please check [types](https://pkg.go.dev/github.com/tendermint/tendermint/types?utm_source=godoc#pkg-constants) for the details. Please check [types](https://pkg.go.dev/github.com/tendermint/tendermint/types?utm_source=godoc#pkg-constants) for the details.

View File

@@ -4,7 +4,7 @@ order: 11
# State Sync # State Sync
With fast sync a node is downloading all of the data of an application from genesis and verifying it. With block sync a node is downloading all of the data of an application from genesis and verifying it.
With state sync your node will download data related to the head or near the head of the chain and verify the data. With state sync your node will download data related to the head or near the head of the chain and verify the data.
This leads to drastically shorter times for joining a network. This leads to drastically shorter times for joining a network.

View File

@@ -1,19 +1,19 @@
/* /*
Package blockchain implements two versions of a reactor Service that are Package blocksync implements two versions of a reactor Service that are
responsible for block propagation and gossip between peers. This mechanism is responsible for block propagation and gossip between peers. This mechanism was
more formally known as fast-sync. formerly known as fast-sync.
In order for a full node to successfully participate in consensus, it must have In order for a full node to successfully participate in consensus, it must have
the latest view of state. The fast-sync protocol is a mechanism in which peers the latest view of state. The blocksync protocol is a mechanism in which peers
may exchange and gossip entire blocks with one another, in a request/response may exchange and gossip entire blocks with one another, in a request/response
type model, until they've successfully synced to the latest head block. Once type model, until they've successfully synced to the latest head block. Once
succussfully synced, the full node can switch to an active role in consensus and succussfully synced, the full node can switch to an active role in consensus and
will no longer fast-sync and thus no longer run the fast-sync process. will no longer blocksync and thus no longer run the blocksync process.
Note, the blockchain reactor Service gossips entire block and relevant data such Note, the blocksync reactor Service gossips entire block and relevant data such
that each receiving peer may construct the entire view of the blockchain state. that each receiving peer may construct the entire view of the blocksync state.
There are two versions of the blockchain reactor Service, i.e. fast-sync: There are currently two versions of the blocksync reactor Service:
- v0: The initial implementation that is battle-tested, but whose test coverage - v0: The initial implementation that is battle-tested, but whose test coverage
is lacking and is not formally verifiable. is lacking and is not formally verifiable.
@@ -22,7 +22,7 @@ There are two versions of the blockchain reactor Service, i.e. fast-sync:
is known to have various bugs that could make it unreliable in production is known to have various bugs that could make it unreliable in production
environments. environments.
The v0 blockchain reactor Service has one p2p channel, BlockchainChannel. This The v0 blocksync reactor Service has one p2p channel, BlockchainChannel. This
channel is responsible for handling messages that both request blocks and respond channel is responsible for handling messages that both request blocks and respond
to block requests from peers. For every block request from a peer, the reactor to block requests from peers. For every block request from a peer, the reactor
will execute respondToPeer which will fetch the block from the node's state store will execute respondToPeer which will fetch the block from the node's state store
@@ -33,4 +33,4 @@ Internally, v0 runs a poolRoutine that constantly checks for what blocks it need
and requests them. The poolRoutine is also responsible for taking blocks from the and requests them. The poolRoutine is also responsible for taking blocks from the
pool, saving and executing each block. pool, saving and executing each block.
*/ */
package blockchain package blocksync

View File

@@ -1,7 +1,7 @@
package blockchain package blocksync
import ( import (
bcproto "github.com/tendermint/tendermint/proto/tendermint/blockchain" bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )

View File

@@ -65,7 +65,7 @@ type BlockRequest struct {
PeerID types.NodeID PeerID types.NodeID
} }
// BlockPool keeps track of the fast sync peers, block requests and block responses. // BlockPool keeps track of the block sync peers, block requests and block responses.
type BlockPool struct { type BlockPool struct {
service.BaseService service.BaseService
lastAdvance time.Time lastAdvance time.Time

View File

@@ -6,13 +6,13 @@ import (
"sync" "sync"
"time" "time"
bc "github.com/tendermint/tendermint/internal/blockchain" bc "github.com/tendermint/tendermint/internal/blocksync"
cons "github.com/tendermint/tendermint/internal/consensus" cons "github.com/tendermint/tendermint/internal/consensus"
"github.com/tendermint/tendermint/internal/p2p" "github.com/tendermint/tendermint/internal/p2p"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/service" "github.com/tendermint/tendermint/libs/service"
tmSync "github.com/tendermint/tendermint/libs/sync" tmSync "github.com/tendermint/tendermint/libs/sync"
bcproto "github.com/tendermint/tendermint/proto/tendermint/blockchain" bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/store" "github.com/tendermint/tendermint/store"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
@@ -60,7 +60,7 @@ const (
) )
type consensusReactor interface { type consensusReactor interface {
// For when we switch from blockchain reactor and fast sync to the consensus // For when we switch from blockchain reactor and block sync to the consensus
// machine. // machine.
SwitchToConsensus(state sm.State, skipWAL bool) SwitchToConsensus(state sm.State, skipWAL bool)
} }
@@ -85,7 +85,7 @@ type Reactor struct {
store *store.BlockStore store *store.BlockStore
pool *BlockPool pool *BlockPool
consReactor consensusReactor consReactor consensusReactor
fastSync *tmSync.AtomicBool blockSync *tmSync.AtomicBool
blockchainCh *p2p.Channel blockchainCh *p2p.Channel
// blockchainOutBridgeCh defines a channel that acts as a bridge between sending Envelope // blockchainOutBridgeCh defines a channel that acts as a bridge between sending Envelope
@@ -121,7 +121,7 @@ func NewReactor(
consReactor consensusReactor, consReactor consensusReactor,
blockchainCh *p2p.Channel, blockchainCh *p2p.Channel,
peerUpdates *p2p.PeerUpdates, peerUpdates *p2p.PeerUpdates,
fastSync bool, blockSync bool,
metrics *cons.Metrics, metrics *cons.Metrics,
) (*Reactor, error) { ) (*Reactor, error) {
if state.LastBlockHeight != store.Height() { if state.LastBlockHeight != store.Height() {
@@ -142,7 +142,7 @@ func NewReactor(
store: store, store: store,
pool: NewBlockPool(startHeight, requestsCh, errorsCh), pool: NewBlockPool(startHeight, requestsCh, errorsCh),
consReactor: consReactor, consReactor: consReactor,
fastSync: tmSync.NewBool(fastSync), blockSync: tmSync.NewBool(blockSync),
requestsCh: requestsCh, requestsCh: requestsCh,
errorsCh: errorsCh, errorsCh: errorsCh,
blockchainCh: blockchainCh, blockchainCh: blockchainCh,
@@ -162,10 +162,10 @@ func NewReactor(
// messages on that p2p channel accordingly. The caller must be sure to execute // messages on that p2p channel accordingly. The caller must be sure to execute
// OnStop to ensure the outbound p2p Channels are closed. // OnStop to ensure the outbound p2p Channels are closed.
// //
// If fastSync is enabled, we also start the pool and the pool processing // If blockSync is enabled, we also start the pool and the pool processing
// goroutine. If the pool fails to start, an error is returned. // goroutine. If the pool fails to start, an error is returned.
func (r *Reactor) OnStart() error { func (r *Reactor) OnStart() error {
if r.fastSync.IsSet() { if r.blockSync.IsSet() {
if err := r.pool.Start(); err != nil { if err := r.pool.Start(); err != nil {
return err return err
} }
@@ -183,7 +183,7 @@ func (r *Reactor) OnStart() error {
// OnStop stops the reactor by signaling to all spawned goroutines to exit and // OnStop stops the reactor by signaling to all spawned goroutines to exit and
// blocking until they all exit. // blocking until they all exit.
func (r *Reactor) OnStop() { func (r *Reactor) OnStop() {
if r.fastSync.IsSet() { if r.blockSync.IsSet() {
if err := r.pool.Stop(); err != nil { if err := r.pool.Stop(); err != nil {
r.Logger.Error("failed to stop pool", "err", err) r.Logger.Error("failed to stop pool", "err", err)
} }
@@ -371,10 +371,10 @@ func (r *Reactor) processPeerUpdates() {
} }
} }
// SwitchToFastSync is called by the state sync reactor when switching to fast // SwitchToBlockSync is called by the state sync reactor when switching to fast
// sync. // sync.
func (r *Reactor) SwitchToFastSync(state sm.State) error { func (r *Reactor) SwitchToBlockSync(state sm.State) error {
r.fastSync.Set() r.blockSync.Set()
r.initialState = state r.initialState = state
r.pool.height = state.LastBlockHeight + 1 r.pool.height = state.LastBlockHeight + 1
@@ -496,7 +496,7 @@ FOR_LOOP:
r.Logger.Error("failed to stop pool", "err", err) r.Logger.Error("failed to stop pool", "err", err)
} }
r.fastSync.UnSet() r.blockSync.UnSet()
if r.consReactor != nil { if r.consReactor != nil {
r.consReactor.SwitchToConsensus(state, blocksSynced > 0 || stateSynced) r.consReactor.SwitchToConsensus(state, blocksSynced > 0 || stateSynced)
@@ -591,7 +591,7 @@ FOR_LOOP:
if blocksSynced%100 == 0 { if blocksSynced%100 == 0 {
lastRate = 0.9*lastRate + 0.1*(100/time.Since(lastHundred).Seconds()) lastRate = 0.9*lastRate + 0.1*(100/time.Since(lastHundred).Seconds())
r.Logger.Info( r.Logger.Info(
"fast sync rate", "block sync rate",
"height", r.pool.height, "height", r.pool.height,
"max_peer_height", r.pool.MaxPeerHeight(), "max_peer_height", r.pool.MaxPeerHeight(),
"blocks/s", lastRate, "blocks/s", lastRate,
@@ -614,14 +614,14 @@ func (r *Reactor) GetMaxPeerBlockHeight() int64 {
} }
func (r *Reactor) GetTotalSyncedTime() time.Duration { func (r *Reactor) GetTotalSyncedTime() time.Duration {
if !r.fastSync.IsSet() || r.syncStartTime.IsZero() { if !r.blockSync.IsSet() || r.syncStartTime.IsZero() {
return time.Duration(0) return time.Duration(0)
} }
return time.Since(r.syncStartTime) return time.Since(r.syncStartTime)
} }
func (r *Reactor) GetRemainingSyncTime() time.Duration { func (r *Reactor) GetRemainingSyncTime() time.Duration {
if !r.fastSync.IsSet() { if !r.blockSync.IsSet() {
return time.Duration(0) return time.Duration(0)
} }

View File

@@ -15,7 +15,7 @@ import (
"github.com/tendermint/tendermint/internal/p2p/p2ptest" "github.com/tendermint/tendermint/internal/p2p/p2ptest"
"github.com/tendermint/tendermint/internal/test/factory" "github.com/tendermint/tendermint/internal/test/factory"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
bcproto "github.com/tendermint/tendermint/proto/tendermint/blockchain" bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
sf "github.com/tendermint/tendermint/state/test/factory" sf "github.com/tendermint/tendermint/state/test/factory"
@@ -36,7 +36,7 @@ type reactorTestSuite struct {
peerChans map[types.NodeID]chan p2p.PeerUpdate peerChans map[types.NodeID]chan p2p.PeerUpdate
peerUpdates map[types.NodeID]*p2p.PeerUpdates peerUpdates map[types.NodeID]*p2p.PeerUpdates
fastSync bool blockSync bool
} }
func setup( func setup(
@@ -61,7 +61,7 @@ func setup(
blockchainChannels: make(map[types.NodeID]*p2p.Channel, numNodes), blockchainChannels: make(map[types.NodeID]*p2p.Channel, numNodes),
peerChans: make(map[types.NodeID]chan p2p.PeerUpdate, numNodes), peerChans: make(map[types.NodeID]chan p2p.PeerUpdate, numNodes),
peerUpdates: make(map[types.NodeID]*p2p.PeerUpdates, numNodes), peerUpdates: make(map[types.NodeID]*p2p.PeerUpdates, numNodes),
fastSync: true, blockSync: true,
} }
chDesc := p2p.ChannelDescriptor{ID: byte(BlockchainChannel)} chDesc := p2p.ChannelDescriptor{ID: byte(BlockchainChannel)}
@@ -163,7 +163,7 @@ func (rts *reactorTestSuite) addNode(t *testing.T,
nil, nil,
rts.blockchainChannels[nodeID], rts.blockchainChannels[nodeID],
rts.peerUpdates[nodeID], rts.peerUpdates[nodeID],
rts.fastSync, rts.blockSync,
cons.NopMetrics()) cons.NopMetrics())
require.NoError(t, err) require.NoError(t, err)

View File

@@ -4,7 +4,7 @@ import (
"sync" "sync"
"testing" "testing"
bh "github.com/tendermint/tendermint/internal/blockchain/v2/internal/behavior" bh "github.com/tendermint/tendermint/internal/blocksync/v2/internal/behavior"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )

View File

@@ -5,7 +5,7 @@ import (
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
"github.com/tendermint/tendermint/internal/p2p" "github.com/tendermint/tendermint/internal/p2p"
bcproto "github.com/tendermint/tendermint/proto/tendermint/blockchain" bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
"github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )
@@ -42,7 +42,7 @@ const (
) )
type consensusReactor interface { type consensusReactor interface {
// for when we switch from blockchain reactor and fast sync to // for when we switch from blockchain reactor and block sync to
// the consensus machine // the consensus machine
SwitchToConsensus(state state.State, skipWAL bool) SwitchToConsensus(state state.State, skipWAL bool)
} }

View File

@@ -7,14 +7,14 @@ import (
proto "github.com/gogo/protobuf/proto" proto "github.com/gogo/protobuf/proto"
bc "github.com/tendermint/tendermint/internal/blockchain" bc "github.com/tendermint/tendermint/internal/blocksync"
"github.com/tendermint/tendermint/internal/blockchain/v2/internal/behavior" "github.com/tendermint/tendermint/internal/blocksync/v2/internal/behavior"
cons "github.com/tendermint/tendermint/internal/consensus" cons "github.com/tendermint/tendermint/internal/consensus"
tmsync "github.com/tendermint/tendermint/internal/libs/sync" tmsync "github.com/tendermint/tendermint/internal/libs/sync"
"github.com/tendermint/tendermint/internal/p2p" "github.com/tendermint/tendermint/internal/p2p"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/sync" "github.com/tendermint/tendermint/libs/sync"
bcproto "github.com/tendermint/tendermint/proto/tendermint/blockchain" bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
"github.com/tendermint/tendermint/state" "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )
@@ -31,12 +31,12 @@ type blockStore interface {
Height() int64 Height() int64
} }
// BlockchainReactor handles fast sync protocol. // BlockchainReactor handles block sync protocol.
type BlockchainReactor struct { type BlockchainReactor struct {
p2p.BaseReactor p2p.BaseReactor
fastSync *sync.AtomicBool // enable fast sync on start when it's been Set blockSync *sync.AtomicBool // enable block sync on start when it's been Set
stateSynced bool // set to true when SwitchToFastSync is called by state sync stateSynced bool // set to true when SwitchToBlockSync is called by state sync
scheduler *Routine scheduler *Routine
processor *Routine processor *Routine
logger log.Logger logger log.Logger
@@ -44,7 +44,7 @@ type BlockchainReactor struct {
mtx tmsync.RWMutex mtx tmsync.RWMutex
maxPeerHeight int64 maxPeerHeight int64
syncHeight int64 syncHeight int64
events chan Event // non-nil during a fast sync events chan Event // non-nil during a block sync
reporter behavior.Reporter reporter behavior.Reporter
io iIO io iIO
@@ -61,7 +61,7 @@ type blockApplier interface {
// XXX: unify naming in this package around tmState // XXX: unify naming in this package around tmState
func newReactor(state state.State, store blockStore, reporter behavior.Reporter, func newReactor(state state.State, store blockStore, reporter behavior.Reporter,
blockApplier blockApplier, fastSync bool, metrics *cons.Metrics) *BlockchainReactor { blockApplier blockApplier, blockSync bool, metrics *cons.Metrics) *BlockchainReactor {
initHeight := state.LastBlockHeight + 1 initHeight := state.LastBlockHeight + 1
if initHeight == 1 { if initHeight == 1 {
initHeight = state.InitialHeight initHeight = state.InitialHeight
@@ -78,7 +78,7 @@ func newReactor(state state.State, store blockStore, reporter behavior.Reporter,
store: store, store: store,
reporter: reporter, reporter: reporter,
logger: log.NewNopLogger(), logger: log.NewNopLogger(),
fastSync: sync.NewBool(fastSync), blockSync: sync.NewBool(blockSync),
syncStartHeight: initHeight, syncStartHeight: initHeight,
syncStartTime: time.Time{}, syncStartTime: time.Time{},
lastSyncRate: 0, lastSyncRate: 0,
@@ -90,10 +90,10 @@ func NewBlockchainReactor(
state state.State, state state.State,
blockApplier blockApplier, blockApplier blockApplier,
store blockStore, store blockStore,
fastSync bool, blockSync bool,
metrics *cons.Metrics) *BlockchainReactor { metrics *cons.Metrics) *BlockchainReactor {
reporter := behavior.NewMockReporter() reporter := behavior.NewMockReporter()
return newReactor(state, store, reporter, blockApplier, fastSync, metrics) return newReactor(state, store, reporter, blockApplier, blockSync, metrics)
} }
// SetSwitch implements Reactor interface. // SetSwitch implements Reactor interface.
@@ -137,22 +137,22 @@ func (r *BlockchainReactor) SetLogger(logger log.Logger) {
// Start implements cmn.Service interface // Start implements cmn.Service interface
func (r *BlockchainReactor) Start() error { func (r *BlockchainReactor) Start() error {
r.reporter = behavior.NewSwitchReporter(r.BaseReactor.Switch) r.reporter = behavior.NewSwitchReporter(r.BaseReactor.Switch)
if r.fastSync.IsSet() { if r.blockSync.IsSet() {
err := r.startSync(nil) err := r.startSync(nil)
if err != nil { if err != nil {
return fmt.Errorf("failed to start fast sync: %w", err) return fmt.Errorf("failed to start block sync: %w", err)
} }
} }
return nil return nil
} }
// startSync begins a fast sync, signaled by r.events being non-nil. If state is non-nil, // startSync begins a block sync, signaled by r.events being non-nil. If state is non-nil,
// the scheduler and processor is updated with this state on startup. // the scheduler and processor is updated with this state on startup.
func (r *BlockchainReactor) startSync(state *state.State) error { func (r *BlockchainReactor) startSync(state *state.State) error {
r.mtx.Lock() r.mtx.Lock()
defer r.mtx.Unlock() defer r.mtx.Unlock()
if r.events != nil { if r.events != nil {
return errors.New("fast sync already in progress") return errors.New("block sync already in progress")
} }
r.events = make(chan Event, chBufferSize) r.events = make(chan Event, chBufferSize)
go r.scheduler.start() go r.scheduler.start()
@@ -167,7 +167,7 @@ func (r *BlockchainReactor) startSync(state *state.State) error {
return nil return nil
} }
// endSync ends a fast sync // endSync ends a block sync
func (r *BlockchainReactor) endSync() { func (r *BlockchainReactor) endSync() {
r.mtx.Lock() r.mtx.Lock()
defer r.mtx.Unlock() defer r.mtx.Unlock()
@@ -179,8 +179,8 @@ func (r *BlockchainReactor) endSync() {
r.processor.stop() r.processor.stop()
} }
// SwitchToFastSync is called by the state sync reactor when switching to fast sync. // SwitchToBlockSync is called by the state sync reactor when switching to block sync.
func (r *BlockchainReactor) SwitchToFastSync(state state.State) error { func (r *BlockchainReactor) SwitchToBlockSync(state state.State) error {
r.stateSynced = true r.stateSynced = true
state = state.Copy() state = state.Copy()
@@ -434,7 +434,7 @@ func (r *BlockchainReactor) demux(events <-chan Event) {
} else { } else {
r.lastSyncRate = 0.9*r.lastSyncRate + 0.1*newSyncRate r.lastSyncRate = 0.9*r.lastSyncRate + 0.1*newSyncRate
} }
r.logger.Info("Fast Sync Rate", "height", r.syncHeight, r.logger.Info("block sync Rate", "height", r.syncHeight,
"max_peer_height", r.maxPeerHeight, "blocks/s", r.lastSyncRate) "max_peer_height", r.maxPeerHeight, "blocks/s", r.lastSyncRate)
lastHundred = time.Now() lastHundred = time.Now()
} }
@@ -442,12 +442,12 @@ func (r *BlockchainReactor) demux(events <-chan Event) {
case pcBlockVerificationFailure: case pcBlockVerificationFailure:
r.scheduler.send(event) r.scheduler.send(event)
case pcFinished: case pcFinished:
r.logger.Info("Fast sync complete, switching to consensus") r.logger.Info("block sync complete, switching to consensus")
if !r.io.trySwitchToConsensus(event.tmState, event.blocksSynced > 0 || r.stateSynced) { if !r.io.trySwitchToConsensus(event.tmState, event.blocksSynced > 0 || r.stateSynced) {
r.logger.Error("Failed to switch to consensus reactor") r.logger.Error("Failed to switch to consensus reactor")
} }
r.endSync() r.endSync()
r.fastSync.UnSet() r.blockSync.UnSet()
return return
case noOpEvent: case noOpEvent:
default: default:
@@ -617,14 +617,14 @@ func (r *BlockchainReactor) GetMaxPeerBlockHeight() int64 {
} }
func (r *BlockchainReactor) GetTotalSyncedTime() time.Duration { func (r *BlockchainReactor) GetTotalSyncedTime() time.Duration {
if !r.fastSync.IsSet() || r.syncStartTime.IsZero() { if !r.blockSync.IsSet() || r.syncStartTime.IsZero() {
return time.Duration(0) return time.Duration(0)
} }
return time.Since(r.syncStartTime) return time.Since(r.syncStartTime)
} }
func (r *BlockchainReactor) GetRemainingSyncTime() time.Duration { func (r *BlockchainReactor) GetRemainingSyncTime() time.Duration {
if !r.fastSync.IsSet() { if !r.blockSync.IsSet() {
return time.Duration(0) return time.Duration(0)
} }

View File

@@ -15,7 +15,7 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/internal/blockchain/v2/internal/behavior" "github.com/tendermint/tendermint/internal/blocksync/v2/internal/behavior"
cons "github.com/tendermint/tendermint/internal/consensus" cons "github.com/tendermint/tendermint/internal/consensus"
"github.com/tendermint/tendermint/internal/mempool/mock" "github.com/tendermint/tendermint/internal/mempool/mock"
"github.com/tendermint/tendermint/internal/p2p" "github.com/tendermint/tendermint/internal/p2p"
@@ -23,7 +23,7 @@ import (
"github.com/tendermint/tendermint/internal/test/factory" "github.com/tendermint/tendermint/internal/test/factory"
"github.com/tendermint/tendermint/libs/log" "github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/libs/service" "github.com/tendermint/tendermint/libs/service"
bcproto "github.com/tendermint/tendermint/proto/tendermint/blockchain" bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
"github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state" sm "github.com/tendermint/tendermint/state"
sf "github.com/tendermint/tendermint/state/test/factory" sf "github.com/tendermint/tendermint/state/test/factory"

View File

@@ -163,7 +163,7 @@ type scheduler struct {
height int64 height int64
// lastAdvance tracks the last time a block execution happened. // lastAdvance tracks the last time a block execution happened.
// syncTimeout is the maximum time the scheduler waits to advance in the fast sync process before finishing. // syncTimeout is the maximum time the scheduler waits to advance in the block sync process before finishing.
// This covers the cases where there are no peers or all peers have a lower height. // This covers the cases where there are no peers or all peers have a lower height.
lastAdvance time.Time lastAdvance time.Time
syncTimeout time.Duration syncTimeout time.Duration

View File

@@ -54,8 +54,8 @@ type Metrics struct {
TotalTxs metrics.Gauge TotalTxs metrics.Gauge
// The latest block height. // The latest block height.
CommittedHeight metrics.Gauge CommittedHeight metrics.Gauge
// Whether or not a node is fast syncing. 1 if yes, 0 if no. // Whether or not a node is block syncing. 1 if yes, 0 if no.
FastSyncing metrics.Gauge BlockSyncing metrics.Gauge
// Whether or not a node is state syncing. 1 if yes, 0 if no. // Whether or not a node is state syncing. 1 if yes, 0 if no.
StateSyncing metrics.Gauge StateSyncing metrics.Gauge
@@ -169,11 +169,11 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics {
Name: "latest_block_height", Name: "latest_block_height",
Help: "The latest block height.", Help: "The latest block height.",
}, labels).With(labelsAndValues...), }, labels).With(labelsAndValues...),
FastSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ BlockSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace, Namespace: namespace,
Subsystem: MetricsSubsystem, Subsystem: MetricsSubsystem,
Name: "fast_syncing", Name: "block_syncing",
Help: "Whether or not a node is fast syncing. 1 if yes, 0 if no.", Help: "Whether or not a node is block syncing. 1 if yes, 0 if no.",
}, labels).With(labelsAndValues...), }, labels).With(labelsAndValues...),
StateSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ StateSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{
Namespace: namespace, Namespace: namespace,
@@ -214,7 +214,7 @@ func NopMetrics() *Metrics {
BlockSizeBytes: discard.NewHistogram(), BlockSizeBytes: discard.NewHistogram(),
TotalTxs: discard.NewGauge(), TotalTxs: discard.NewGauge(),
CommittedHeight: discard.NewGauge(), CommittedHeight: discard.NewGauge(),
FastSyncing: discard.NewGauge(), BlockSyncing: discard.NewGauge(),
StateSyncing: discard.NewGauge(), StateSyncing: discard.NewGauge(),
BlockParts: discard.NewCounter(), BlockParts: discard.NewCounter(),
} }

View File

@@ -12,8 +12,8 @@ type ConsSyncReactor struct {
mock.Mock mock.Mock
} }
// SetFastSyncingMetrics provides a mock function with given fields: _a0 // SetBlockSyncingMetrics provides a mock function with given fields: _a0
func (_m *ConsSyncReactor) SetFastSyncingMetrics(_a0 float64) { func (_m *ConsSyncReactor) SetBlockSyncingMetrics(_a0 float64) {
_m.Called(_a0) _m.Called(_a0)
} }

View File

@@ -9,13 +9,13 @@ import (
time "time" time "time"
) )
// FastSyncReactor is an autogenerated mock type for the FastSyncReactor type // BlockSyncReactor is an autogenerated mock type for the BlockSyncReactor type
type FastSyncReactor struct { type BlockSyncReactor struct {
mock.Mock mock.Mock
} }
// GetMaxPeerBlockHeight provides a mock function with given fields: // GetMaxPeerBlockHeight provides a mock function with given fields:
func (_m *FastSyncReactor) GetMaxPeerBlockHeight() int64 { func (_m *BlockSyncReactor) GetMaxPeerBlockHeight() int64 {
ret := _m.Called() ret := _m.Called()
var r0 int64 var r0 int64
@@ -29,7 +29,7 @@ func (_m *FastSyncReactor) GetMaxPeerBlockHeight() int64 {
} }
// GetRemainingSyncTime provides a mock function with given fields: // GetRemainingSyncTime provides a mock function with given fields:
func (_m *FastSyncReactor) GetRemainingSyncTime() time.Duration { func (_m *BlockSyncReactor) GetRemainingSyncTime() time.Duration {
ret := _m.Called() ret := _m.Called()
var r0 time.Duration var r0 time.Duration
@@ -43,7 +43,7 @@ func (_m *FastSyncReactor) GetRemainingSyncTime() time.Duration {
} }
// GetTotalSyncedTime provides a mock function with given fields: // GetTotalSyncedTime provides a mock function with given fields:
func (_m *FastSyncReactor) GetTotalSyncedTime() time.Duration { func (_m *BlockSyncReactor) GetTotalSyncedTime() time.Duration {
ret := _m.Called() ret := _m.Called()
var r0 time.Duration var r0 time.Duration
@@ -56,8 +56,8 @@ func (_m *FastSyncReactor) GetTotalSyncedTime() time.Duration {
return r0 return r0
} }
// SwitchToFastSync provides a mock function with given fields: _a0 // SwitchToBlockSync provides a mock function with given fields: _a0
func (_m *FastSyncReactor) SwitchToFastSync(_a0 state.State) error { func (_m *BlockSyncReactor) SwitchToBlockSync(_a0 state.State) error {
ret := _m.Called(_a0) ret := _m.Called(_a0)
var r0 error var r0 error

View File

@@ -96,18 +96,18 @@ const (
type ReactorOption func(*Reactor) type ReactorOption func(*Reactor)
// Temporary interface for switching to fast sync, we should get rid of v0. // NOTE: Temporary interface for switching to block sync, we should get rid of v0.
// See: https://github.com/tendermint/tendermint/issues/4595 // See: https://github.com/tendermint/tendermint/issues/4595
type FastSyncReactor interface { type BlockSyncReactor interface {
SwitchToFastSync(sm.State) error SwitchToBlockSync(sm.State) error
GetMaxPeerBlockHeight() int64 GetMaxPeerBlockHeight() int64
// GetTotalSyncedTime returns the time duration since the fastsync starting. // GetTotalSyncedTime returns the time duration since the blocksync starting.
GetTotalSyncedTime() time.Duration GetTotalSyncedTime() time.Duration
// GetRemainingSyncTime returns the estimating time the node will be fully synced, // GetRemainingSyncTime returns the estimating time the node will be fully synced,
// if will return 0 if the fastsync does not perform or the number of block synced is // if will return 0 if the blocksync does not perform or the number of block synced is
// too small (less than 100). // too small (less than 100).
GetRemainingSyncTime() time.Duration GetRemainingSyncTime() time.Duration
} }
@@ -117,7 +117,7 @@ type FastSyncReactor interface {
type ConsSyncReactor interface { type ConsSyncReactor interface {
SwitchToConsensus(sm.State, bool) SwitchToConsensus(sm.State, bool)
SetStateSyncingMetrics(float64) SetStateSyncingMetrics(float64)
SetFastSyncingMetrics(float64) SetBlockSyncingMetrics(float64)
} }
// Reactor defines a reactor for the consensus service. // Reactor defines a reactor for the consensus service.
@@ -265,7 +265,7 @@ func (r *Reactor) SetEventBus(b *types.EventBus) {
r.state.SetEventBus(b) r.state.SetEventBus(b)
} }
// WaitSync returns whether the consensus reactor is waiting for state/fast sync. // WaitSync returns whether the consensus reactor is waiting for state/block sync.
func (r *Reactor) WaitSync() bool { func (r *Reactor) WaitSync() bool {
r.mtx.RLock() r.mtx.RLock()
defer r.mtx.RUnlock() defer r.mtx.RUnlock()
@@ -278,8 +278,8 @@ func ReactorMetrics(metrics *Metrics) ReactorOption {
return func(r *Reactor) { r.Metrics = metrics } return func(r *Reactor) { r.Metrics = metrics }
} }
// SwitchToConsensus switches from fast-sync mode to consensus mode. It resets // SwitchToConsensus switches from block-sync mode to consensus mode. It resets
// the state, turns off fast-sync, and starts the consensus state-machine. // the state, turns off block-sync, and starts the consensus state-machine.
func (r *Reactor) SwitchToConsensus(state sm.State, skipWAL bool) { func (r *Reactor) SwitchToConsensus(state sm.State, skipWAL bool) {
r.Logger.Info("switching to consensus") r.Logger.Info("switching to consensus")
@@ -296,7 +296,7 @@ func (r *Reactor) SwitchToConsensus(state sm.State, skipWAL bool) {
r.waitSync = false r.waitSync = false
r.mtx.Unlock() r.mtx.Unlock()
r.Metrics.FastSyncing.Set(0) r.Metrics.BlockSyncing.Set(0)
r.Metrics.StateSyncing.Set(0) r.Metrics.StateSyncing.Set(0)
if skipWAL { if skipWAL {
@@ -313,9 +313,9 @@ conR:
%+v`, err, r.state, r)) %+v`, err, r.state, r))
} }
d := types.EventDataFastSyncStatus{Complete: true, Height: state.LastBlockHeight} d := types.EventDataBlockSyncStatus{Complete: true, Height: state.LastBlockHeight}
if err := r.eventBus.PublishEventFastSyncStatus(d); err != nil { if err := r.eventBus.PublishEventBlockSyncStatus(d); err != nil {
r.Logger.Error("failed to emit the fastsync complete event", "err", err) r.Logger.Error("failed to emit the blocksync complete event", "err", err)
} }
} }
@@ -969,7 +969,7 @@ func (r *Reactor) processPeerUpdate(peerUpdate p2p.PeerUpdate) {
go r.gossipVotesRoutine(ps) go r.gossipVotesRoutine(ps)
go r.queryMaj23Routine(ps) go r.queryMaj23Routine(ps)
// Send our state to the peer. If we're fast-syncing, broadcast a // Send our state to the peer. If we're block-syncing, broadcast a
// RoundStepMessage later upon SwitchToConsensus(). // RoundStepMessage later upon SwitchToConsensus().
if !r.waitSync { if !r.waitSync {
go r.sendNewRoundStepMessage(ps.peerID) go r.sendNewRoundStepMessage(ps.peerID)
@@ -1219,7 +1219,7 @@ func (r *Reactor) handleVoteSetBitsMessage(envelope p2p.Envelope, msgI Message)
// It will handle errors and any possible panics gracefully. A caller can handle // It will handle errors and any possible panics gracefully. A caller can handle
// any error returned by sending a PeerError on the respective channel. // any error returned by sending a PeerError on the respective channel.
// //
// NOTE: We process these messages even when we're fast_syncing. Messages affect // NOTE: We process these messages even when we're block syncing. Messages affect
// either a peer state or the consensus state. Peer state updates can happen in // either a peer state or the consensus state. Peer state updates can happen in
// parallel, but processing of proposals, block parts, and votes are ordered by // parallel, but processing of proposals, block parts, and votes are ordered by
// the p2p channel. // the p2p channel.
@@ -1442,6 +1442,6 @@ func (r *Reactor) SetStateSyncingMetrics(v float64) {
r.Metrics.StateSyncing.Set(v) r.Metrics.StateSyncing.Set(v)
} }
func (r *Reactor) SetFastSyncingMetrics(v float64) { func (r *Reactor) SetBlockSyncingMetrics(v float64) {
r.Metrics.FastSyncing.Set(v) r.Metrics.BlockSyncing.Set(v)
} }

View File

@@ -43,7 +43,7 @@ type reactorTestSuite struct {
states map[types.NodeID]*State states map[types.NodeID]*State
reactors map[types.NodeID]*Reactor reactors map[types.NodeID]*Reactor
subs map[types.NodeID]types.Subscription subs map[types.NodeID]types.Subscription
fastsyncSubs map[types.NodeID]types.Subscription blocksyncSubs map[types.NodeID]types.Subscription
stateChannels map[types.NodeID]*p2p.Channel stateChannels map[types.NodeID]*p2p.Channel
dataChannels map[types.NodeID]*p2p.Channel dataChannels map[types.NodeID]*p2p.Channel
voteChannels map[types.NodeID]*p2p.Channel voteChannels map[types.NodeID]*p2p.Channel
@@ -60,11 +60,11 @@ func setup(t *testing.T, numNodes int, states []*State, size int) *reactorTestSu
t.Helper() t.Helper()
rts := &reactorTestSuite{ rts := &reactorTestSuite{
network: p2ptest.MakeNetwork(t, p2ptest.NetworkOptions{NumNodes: numNodes}), network: p2ptest.MakeNetwork(t, p2ptest.NetworkOptions{NumNodes: numNodes}),
states: make(map[types.NodeID]*State), states: make(map[types.NodeID]*State),
reactors: make(map[types.NodeID]*Reactor, numNodes), reactors: make(map[types.NodeID]*Reactor, numNodes),
subs: make(map[types.NodeID]types.Subscription, numNodes), subs: make(map[types.NodeID]types.Subscription, numNodes),
fastsyncSubs: make(map[types.NodeID]types.Subscription, numNodes), blocksyncSubs: make(map[types.NodeID]types.Subscription, numNodes),
} }
rts.stateChannels = rts.network.MakeChannelsNoCleanup(t, chDesc(StateChannel), new(tmcons.Message), size) rts.stateChannels = rts.network.MakeChannelsNoCleanup(t, chDesc(StateChannel), new(tmcons.Message), size)
@@ -94,13 +94,13 @@ func setup(t *testing.T, numNodes int, states []*State, size int) *reactorTestSu
blocksSub, err := state.eventBus.Subscribe(context.Background(), testSubscriber, types.EventQueryNewBlock, size) blocksSub, err := state.eventBus.Subscribe(context.Background(), testSubscriber, types.EventQueryNewBlock, size)
require.NoError(t, err) require.NoError(t, err)
fsSub, err := state.eventBus.Subscribe(context.Background(), testSubscriber, types.EventQueryFastSyncStatus, size) fsSub, err := state.eventBus.Subscribe(context.Background(), testSubscriber, types.EventQueryBlockSyncStatus, size)
require.NoError(t, err) require.NoError(t, err)
rts.states[nodeID] = state rts.states[nodeID] = state
rts.subs[nodeID] = blocksSub rts.subs[nodeID] = blocksSub
rts.reactors[nodeID] = reactor rts.reactors[nodeID] = reactor
rts.fastsyncSubs[nodeID] = fsSub rts.blocksyncSubs[nodeID] = fsSub
// simulate handle initChain in handshake // simulate handle initChain in handshake
if state.state.LastBlockHeight == 0 { if state.state.LastBlockHeight == 0 {
@@ -263,9 +263,9 @@ func waitForBlockWithUpdatedValsAndValidateIt(
wg.Wait() wg.Wait()
} }
func ensureFastSyncStatus(t *testing.T, msg tmpubsub.Message, complete bool, height int64) { func ensureBlockSyncStatus(t *testing.T, msg tmpubsub.Message, complete bool, height int64) {
t.Helper() t.Helper()
status, ok := msg.Data().(types.EventDataFastSyncStatus) status, ok := msg.Data().(types.EventDataBlockSyncStatus)
require.True(t, ok) require.True(t, ok)
require.Equal(t, complete, status.Complete) require.Equal(t, complete, status.Complete)
@@ -301,14 +301,14 @@ func TestReactorBasic(t *testing.T) {
wg.Wait() wg.Wait()
for _, sub := range rts.fastsyncSubs { for _, sub := range rts.blocksyncSubs {
wg.Add(1) wg.Add(1)
// wait till everyone makes the consensus switch // wait till everyone makes the consensus switch
go func(s types.Subscription) { go func(s types.Subscription) {
defer wg.Done() defer wg.Done()
msg := <-s.Out() msg := <-s.Out()
ensureFastSyncStatus(t, msg, true, 0) ensureBlockSyncStatus(t, msg, true, 0)
}(sub) }(sub)
} }

View File

@@ -66,7 +66,7 @@ type nodeImpl struct {
eventBus *types.EventBus // pub/sub for services eventBus *types.EventBus // pub/sub for services
stateStore sm.Store stateStore sm.Store
blockStore *store.BlockStore // store the blockchain to disk blockStore *store.BlockStore // store the blockchain to disk
bcReactor service.Service // for fast-syncing bcReactor service.Service // for block-syncing
mempoolReactor service.Service // for gossipping transactions mempoolReactor service.Service // for gossipping transactions
mempool mempool.Mempool mempool mempool.Mempool
stateSync bool // whether the node should state sync on startup stateSync bool // whether the node should state sync on startup
@@ -225,9 +225,9 @@ func makeNode(config *cfg.Config,
} }
} }
// Determine whether we should do fast sync. This must happen after the handshake, since the // Determine whether we should do block sync. This must happen after the handshake, since the
// app may modify the validator set, specifying ourself as the only validator. // app may modify the validator set, specifying ourself as the only validator.
fastSync := config.FastSyncMode && !onlyValidatorIsUs(state, pubKey) blockSync := config.FastSyncMode && !onlyValidatorIsUs(state, pubKey)
logNodeStartupInfo(state, pubKey, logger, consensusLogger, config.Mode) logNodeStartupInfo(state, pubKey, logger, consensusLogger, config.Mode)
@@ -281,15 +281,15 @@ func makeNode(config *cfg.Config,
csReactorShim, csReactor, csState := createConsensusReactor( csReactorShim, csReactor, csState := createConsensusReactor(
config, state, blockExec, blockStore, mp, evPool, config, state, blockExec, blockStore, mp, evPool,
privValidator, csMetrics, stateSync || fastSync, eventBus, privValidator, csMetrics, stateSync || blockSync, eventBus,
peerManager, router, consensusLogger, peerManager, router, consensusLogger,
) )
// Create the blockchain reactor. Note, we do not start fast sync if we're // Create the blockchain reactor. Note, we do not start block sync if we're
// doing a state sync first. // doing a state sync first.
bcReactorShim, bcReactor, err := createBlockchainReactor( bcReactorShim, bcReactor, err := createBlockchainReactor(
logger, config, state, blockExec, blockStore, csReactor, logger, config, state, blockExec, blockStore, csReactor,
peerManager, router, fastSync && !stateSync, csMetrics, peerManager, router, blockSync && !stateSync, csMetrics,
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("could not create blockchain reactor: %w", err) return nil, fmt.Errorf("could not create blockchain reactor: %w", err)
@@ -303,16 +303,16 @@ func makeNode(config *cfg.Config,
bcReactorForSwitch = bcReactor.(p2p.Reactor) bcReactorForSwitch = bcReactor.(p2p.Reactor)
} }
// Make ConsensusReactor. Don't enable fully if doing a state sync and/or fast sync first. // Make ConsensusReactor. Don't enable fully if doing a state sync and/or block sync first.
// FIXME We need to update metrics here, since other reactors don't have access to them. // FIXME We need to update metrics here, since other reactors don't have access to them.
if stateSync { if stateSync {
csMetrics.StateSyncing.Set(1) csMetrics.StateSyncing.Set(1)
} else if fastSync { } else if blockSync {
csMetrics.FastSyncing.Set(1) csMetrics.BlockSyncing.Set(1)
} }
// Set up state sync reactor, and schedule a sync if requested. // Set up state sync reactor, and schedule a sync if requested.
// FIXME The way we do phased startups (e.g. replay -> fast sync -> consensus) is very messy, // FIXME The way we do phased startups (e.g. replay -> block sync -> consensus) is very messy,
// we should clean this whole thing up. See: // we should clean this whole thing up. See:
// https://github.com/tendermint/tendermint/issues/4644 // https://github.com/tendermint/tendermint/issues/4644
var ( var (
@@ -610,7 +610,7 @@ func (n *nodeImpl) OnStart() error {
} }
if n.config.Mode != cfg.ModeSeed { if n.config.Mode != cfg.ModeSeed {
if n.config.FastSync.Version == cfg.BlockchainV0 { if n.config.BlockSync.Version == cfg.BlockSyncV0 {
// Start the real blockchain reactor separately since the switch uses the shim. // Start the real blockchain reactor separately since the switch uses the shim.
if err := n.bcReactor.Start(); err != nil { if err := n.bcReactor.Start(); err != nil {
return err return err
@@ -653,7 +653,7 @@ func (n *nodeImpl) OnStart() error {
// Run state sync // Run state sync
if n.stateSync { if n.stateSync {
bcR, ok := n.bcReactor.(cs.FastSyncReactor) bcR, ok := n.bcReactor.(cs.BlockSyncReactor)
if !ok { if !ok {
return fmt.Errorf("this blockchain reactor does not support switching from state sync") return fmt.Errorf("this blockchain reactor does not support switching from state sync")
} }
@@ -695,7 +695,7 @@ func (n *nodeImpl) OnStop() {
if n.config.Mode != cfg.ModeSeed { if n.config.Mode != cfg.ModeSeed {
// now stop the reactors // now stop the reactors
if n.config.FastSync.Version == cfg.BlockchainV0 { if n.config.BlockSync.Version == cfg.BlockSyncV0 {
// Stop the real blockchain reactor separately since the switch uses the shim. // Stop the real blockchain reactor separately since the switch uses the shim.
if err := n.bcReactor.Stop(); err != nil { if err := n.bcReactor.Stop(); err != nil {
n.Logger.Error("failed to stop the blockchain reactor", "err", err) n.Logger.Error("failed to stop the blockchain reactor", "err", err)
@@ -788,8 +788,8 @@ func (n *nodeImpl) ConfigureRPC() (*rpccore.Environment, error) {
Logger: n.Logger.With("module", "rpc"), Logger: n.Logger.With("module", "rpc"),
Config: *n.config.RPC, Config: *n.config.RPC,
FastSyncReactor: n.bcReactor.(cs.FastSyncReactor), BlockSyncReactor: n.bcReactor.(cs.BlockSyncReactor),
} }
if n.config.Mode == cfg.ModeValidator { if n.config.Mode == cfg.ModeValidator {
pubKey, err := n.privValidator.GetPubKey(context.TODO()) pubKey, err := n.privValidator.GetPubKey(context.TODO())
@@ -1033,14 +1033,14 @@ func (n *nodeImpl) NodeInfo() types.NodeInfo {
return n.nodeInfo return n.nodeInfo
} }
// startStateSync starts an asynchronous state sync process, then switches to fast sync mode. // startStateSync starts an asynchronous state sync process, then switches to block sync mode.
func startStateSync( func startStateSync(
ssR statesync.SyncReactor, ssR statesync.SyncReactor,
bcR cs.FastSyncReactor, bcR cs.BlockSyncReactor,
conR cs.ConsSyncReactor, conR cs.ConsSyncReactor,
sp statesync.StateProvider, sp statesync.StateProvider,
config *cfg.StateSyncConfig, config *cfg.StateSyncConfig,
fastSync bool, blockSync bool,
stateInitHeight int64, stateInitHeight int64,
eb *types.EventBus, eb *types.EventBus,
) error { ) error {
@@ -1074,17 +1074,17 @@ func startStateSync(
stateSyncLogger.Error("failed to emit the statesync start event", "err", err) stateSyncLogger.Error("failed to emit the statesync start event", "err", err)
} }
if fastSync { if blockSync {
// FIXME Very ugly to have these metrics bleed through here. // FIXME Very ugly to have these metrics bleed through here.
conR.SetFastSyncingMetrics(1) conR.SetBlockSyncingMetrics(1)
if err := bcR.SwitchToFastSync(state); err != nil { if err := bcR.SwitchToBlockSync(state); err != nil {
stateSyncLogger.Error("failed to switch to fast sync", "err", err) stateSyncLogger.Error("failed to switch to block sync", "err", err)
return return
} }
d := types.EventDataFastSyncStatus{Complete: false, Height: state.LastBlockHeight} d := types.EventDataBlockSyncStatus{Complete: false, Height: state.LastBlockHeight}
if err := eb.PublishEventFastSyncStatus(d); err != nil { if err := eb.PublishEventBlockSyncStatus(d); err != nil {
stateSyncLogger.Error("failed to emit the fastsync starting event", "err", err) stateSyncLogger.Error("failed to emit the block sync starting event", "err", err)
} }
} else { } else {

View File

@@ -659,7 +659,7 @@ func loadStatefromGenesis(t *testing.T) sm.State {
func TestNodeStartStateSync(t *testing.T) { func TestNodeStartStateSync(t *testing.T) {
mockSSR := &statesync.MockSyncReactor{} mockSSR := &statesync.MockSyncReactor{}
mockFSR := &consmocks.FastSyncReactor{} mockFSR := &consmocks.BlockSyncReactor{}
mockCSR := &consmocks.ConsSyncReactor{} mockCSR := &consmocks.ConsSyncReactor{}
mockSP := &ssmocks.StateProvider{} mockSP := &ssmocks.StateProvider{}
state := loadStatefromGenesis(t) state := loadStatefromGenesis(t)

View File

@@ -16,8 +16,8 @@ import (
abci "github.com/tendermint/tendermint/abci/types" abci "github.com/tendermint/tendermint/abci/types"
cfg "github.com/tendermint/tendermint/config" cfg "github.com/tendermint/tendermint/config"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
bcv0 "github.com/tendermint/tendermint/internal/blockchain/v0" bcv0 "github.com/tendermint/tendermint/internal/blocksync/v0"
bcv2 "github.com/tendermint/tendermint/internal/blockchain/v2" bcv2 "github.com/tendermint/tendermint/internal/blocksync/v2"
cs "github.com/tendermint/tendermint/internal/consensus" cs "github.com/tendermint/tendermint/internal/consensus"
"github.com/tendermint/tendermint/internal/evidence" "github.com/tendermint/tendermint/internal/evidence"
"github.com/tendermint/tendermint/internal/mempool" "github.com/tendermint/tendermint/internal/mempool"
@@ -337,14 +337,14 @@ func createBlockchainReactor(
csReactor *cs.Reactor, csReactor *cs.Reactor,
peerManager *p2p.PeerManager, peerManager *p2p.PeerManager,
router *p2p.Router, router *p2p.Router,
fastSync bool, blockSync bool,
metrics *cs.Metrics, metrics *cs.Metrics,
) (*p2p.ReactorShim, service.Service, error) { ) (*p2p.ReactorShim, service.Service, error) {
logger = logger.With("module", "blockchain") logger = logger.With("module", "blockchain")
switch config.FastSync.Version { switch config.BlockSync.Version {
case cfg.BlockchainV0: case cfg.BlockSyncV0:
reactorShim := p2p.NewReactorShim(logger, "BlockchainShim", bcv0.ChannelShims) reactorShim := p2p.NewReactorShim(logger, "BlockchainShim", bcv0.ChannelShims)
var ( var (
@@ -362,7 +362,7 @@ func createBlockchainReactor(
reactor, err := bcv0.NewReactor( reactor, err := bcv0.NewReactor(
logger, state.Copy(), blockExec, blockStore, csReactor, logger, state.Copy(), blockExec, blockStore, csReactor,
channels[bcv0.BlockchainChannel], peerUpdates, fastSync, channels[bcv0.BlockchainChannel], peerUpdates, blockSync,
metrics, metrics,
) )
if err != nil { if err != nil {
@@ -371,11 +371,11 @@ func createBlockchainReactor(
return reactorShim, reactor, nil return reactorShim, reactor, nil
case cfg.BlockchainV2: case cfg.BlockSyncV2:
return nil, nil, errors.New("fastsync version v2 is no longer supported. Please use v0") return nil, nil, errors.New("block sync version v2 is no longer supported. Please use v0")
default: default:
return nil, nil, fmt.Errorf("unknown fastsync version %s", config.FastSync.Version) return nil, nil, fmt.Errorf("unknown block sync version %s", config.BlockSync.Version)
} }
} }
@@ -725,15 +725,15 @@ func makeNodeInfo(
} }
var bcChannel byte var bcChannel byte
switch config.FastSync.Version { switch config.BlockSync.Version {
case cfg.BlockchainV0: case cfg.BlockSyncV0:
bcChannel = byte(bcv0.BlockchainChannel) bcChannel = byte(bcv0.BlockchainChannel)
case cfg.BlockchainV2: case cfg.BlockSyncV2:
bcChannel = bcv2.BlockchainChannel bcChannel = bcv2.BlockchainChannel
default: default:
return types.NodeInfo{}, fmt.Errorf("unknown fastsync version %s", config.FastSync.Version) return types.NodeInfo{}, fmt.Errorf("unknown blocksync version %s", config.BlockSync.Version)
} }
nodeInfo := types.NodeInfo{ nodeInfo := types.NodeInfo{

View File

@@ -1,4 +1,4 @@
package blockchain package blocksync
import ( import (
"errors" "errors"

View File

@@ -1,4 +1,4 @@
package blockchain_test package blocksync_test
import ( import (
"encoding/hex" "encoding/hex"
@@ -8,7 +8,7 @@ import (
proto "github.com/gogo/protobuf/proto" proto "github.com/gogo/protobuf/proto"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
bcproto "github.com/tendermint/tendermint/proto/tendermint/blockchain" bcproto "github.com/tendermint/tendermint/proto/tendermint/blocksync"
"github.com/tendermint/tendermint/types" "github.com/tendermint/tendermint/types"
) )

View File

@@ -1,7 +1,7 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: tendermint/blockchain/types.proto // source: tendermint/blocksync/types.proto
package blockchain package blocksync
import ( import (
fmt "fmt" fmt "fmt"
@@ -32,7 +32,7 @@ func (m *BlockRequest) Reset() { *m = BlockRequest{} }
func (m *BlockRequest) String() string { return proto.CompactTextString(m) } func (m *BlockRequest) String() string { return proto.CompactTextString(m) }
func (*BlockRequest) ProtoMessage() {} func (*BlockRequest) ProtoMessage() {}
func (*BlockRequest) Descriptor() ([]byte, []int) { func (*BlockRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_2927480384e78499, []int{0} return fileDescriptor_19b397c236e0fa07, []int{0}
} }
func (m *BlockRequest) XXX_Unmarshal(b []byte) error { func (m *BlockRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@@ -77,7 +77,7 @@ func (m *NoBlockResponse) Reset() { *m = NoBlockResponse{} }
func (m *NoBlockResponse) String() string { return proto.CompactTextString(m) } func (m *NoBlockResponse) String() string { return proto.CompactTextString(m) }
func (*NoBlockResponse) ProtoMessage() {} func (*NoBlockResponse) ProtoMessage() {}
func (*NoBlockResponse) Descriptor() ([]byte, []int) { func (*NoBlockResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_2927480384e78499, []int{1} return fileDescriptor_19b397c236e0fa07, []int{1}
} }
func (m *NoBlockResponse) XXX_Unmarshal(b []byte) error { func (m *NoBlockResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@@ -122,7 +122,7 @@ func (m *BlockResponse) Reset() { *m = BlockResponse{} }
func (m *BlockResponse) String() string { return proto.CompactTextString(m) } func (m *BlockResponse) String() string { return proto.CompactTextString(m) }
func (*BlockResponse) ProtoMessage() {} func (*BlockResponse) ProtoMessage() {}
func (*BlockResponse) Descriptor() ([]byte, []int) { func (*BlockResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_2927480384e78499, []int{2} return fileDescriptor_19b397c236e0fa07, []int{2}
} }
func (m *BlockResponse) XXX_Unmarshal(b []byte) error { func (m *BlockResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@@ -166,7 +166,7 @@ func (m *StatusRequest) Reset() { *m = StatusRequest{} }
func (m *StatusRequest) String() string { return proto.CompactTextString(m) } func (m *StatusRequest) String() string { return proto.CompactTextString(m) }
func (*StatusRequest) ProtoMessage() {} func (*StatusRequest) ProtoMessage() {}
func (*StatusRequest) Descriptor() ([]byte, []int) { func (*StatusRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_2927480384e78499, []int{3} return fileDescriptor_19b397c236e0fa07, []int{3}
} }
func (m *StatusRequest) XXX_Unmarshal(b []byte) error { func (m *StatusRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@@ -205,7 +205,7 @@ func (m *StatusResponse) Reset() { *m = StatusResponse{} }
func (m *StatusResponse) String() string { return proto.CompactTextString(m) } func (m *StatusResponse) String() string { return proto.CompactTextString(m) }
func (*StatusResponse) ProtoMessage() {} func (*StatusResponse) ProtoMessage() {}
func (*StatusResponse) Descriptor() ([]byte, []int) { func (*StatusResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_2927480384e78499, []int{4} return fileDescriptor_19b397c236e0fa07, []int{4}
} }
func (m *StatusResponse) XXX_Unmarshal(b []byte) error { func (m *StatusResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@@ -262,7 +262,7 @@ func (m *Message) Reset() { *m = Message{} }
func (m *Message) String() string { return proto.CompactTextString(m) } func (m *Message) String() string { return proto.CompactTextString(m) }
func (*Message) ProtoMessage() {} func (*Message) ProtoMessage() {}
func (*Message) Descriptor() ([]byte, []int) { func (*Message) Descriptor() ([]byte, []int) {
return fileDescriptor_2927480384e78499, []int{5} return fileDescriptor_19b397c236e0fa07, []int{5}
} }
func (m *Message) XXX_Unmarshal(b []byte) error { func (m *Message) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@@ -373,42 +373,41 @@ func (*Message) XXX_OneofWrappers() []interface{} {
} }
func init() { func init() {
proto.RegisterType((*BlockRequest)(nil), "tendermint.blockchain.BlockRequest") proto.RegisterType((*BlockRequest)(nil), "tendermint.blocksync.BlockRequest")
proto.RegisterType((*NoBlockResponse)(nil), "tendermint.blockchain.NoBlockResponse") proto.RegisterType((*NoBlockResponse)(nil), "tendermint.blocksync.NoBlockResponse")
proto.RegisterType((*BlockResponse)(nil), "tendermint.blockchain.BlockResponse") proto.RegisterType((*BlockResponse)(nil), "tendermint.blocksync.BlockResponse")
proto.RegisterType((*StatusRequest)(nil), "tendermint.blockchain.StatusRequest") proto.RegisterType((*StatusRequest)(nil), "tendermint.blocksync.StatusRequest")
proto.RegisterType((*StatusResponse)(nil), "tendermint.blockchain.StatusResponse") proto.RegisterType((*StatusResponse)(nil), "tendermint.blocksync.StatusResponse")
proto.RegisterType((*Message)(nil), "tendermint.blockchain.Message") proto.RegisterType((*Message)(nil), "tendermint.blocksync.Message")
} }
func init() { proto.RegisterFile("tendermint/blockchain/types.proto", fileDescriptor_2927480384e78499) } func init() { proto.RegisterFile("tendermint/blocksync/types.proto", fileDescriptor_19b397c236e0fa07) }
var fileDescriptor_2927480384e78499 = []byte{ var fileDescriptor_19b397c236e0fa07 = []byte{
// 370 bytes of a gzipped FileDescriptorProto // 368 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0xc1, 0x4e, 0xfa, 0x40, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0x4d, 0x4f, 0xfa, 0x40,
0x10, 0xc6, 0xdb, 0x7f, 0x81, 0x7f, 0x32, 0x50, 0x1a, 0x9b, 0xa8, 0xc4, 0x98, 0x46, 0xab, 0x12, 0x10, 0xc6, 0xdb, 0x7f, 0x81, 0x7f, 0x32, 0x50, 0x1a, 0x1b, 0xa3, 0xc4, 0x98, 0x86, 0xd4, 0x97,
0x3d, 0xd8, 0x26, 0x78, 0x25, 0x1e, 0x38, 0x11, 0x13, 0x8c, 0xa9, 0xc6, 0x83, 0x17, 0xd2, 0xe2, 0xe8, 0xc1, 0x36, 0xc1, 0xa3, 0xc6, 0x03, 0x27, 0x4c, 0x7c, 0x49, 0x4a, 0xbc, 0x78, 0x21, 0x14,
0x86, 0x36, 0x4a, 0x17, 0xd9, 0xed, 0xc1, 0xb7, 0xf0, 0x19, 0x7c, 0x1a, 0x8f, 0x1c, 0x3d, 0x1a, 0x37, 0x40, 0x94, 0x2e, 0x32, 0xdb, 0x03, 0xdf, 0xc2, 0x2f, 0xe0, 0xf7, 0xf1, 0xc8, 0xd1, 0xa3,
0x78, 0x11, 0xc3, 0x6c, 0x29, 0x4b, 0x03, 0xf5, 0xb6, 0x3b, 0xfd, 0xe6, 0x37, 0xdf, 0x7e, 0x99, 0x81, 0x2f, 0x62, 0x98, 0x2d, 0x65, 0x69, 0xb0, 0xb7, 0xdd, 0xe9, 0x33, 0xbf, 0x79, 0xfa, 0x64,
0xc2, 0x31, 0x27, 0xf1, 0x33, 0x99, 0x8c, 0xa2, 0x98, 0xbb, 0xc1, 0x2b, 0x1d, 0xbc, 0x0c, 0x42, 0x16, 0xea, 0x82, 0x45, 0x2f, 0x6c, 0x32, 0x1a, 0x46, 0xc2, 0x0f, 0xdf, 0x78, 0xef, 0x15, 0xa7,
0x3f, 0x8a, 0x5d, 0xfe, 0x3e, 0x26, 0xcc, 0x19, 0x4f, 0x28, 0xa7, 0xe6, 0xee, 0x4a, 0xe2, 0xac, 0x51, 0xcf, 0x17, 0xd3, 0x31, 0x43, 0x6f, 0x3c, 0xe1, 0x82, 0xdb, 0xbb, 0x6b, 0x85, 0x97, 0x2a,
0x24, 0x07, 0x87, 0x52, 0x27, 0xca, 0x45, 0xbf, 0x68, 0xb2, 0x9b, 0x50, 0xeb, 0x2c, 0xae, 0x1e, 0x0e, 0x0e, 0x95, 0x3e, 0x52, 0xcb, 0x6e, 0xd9, 0xe3, 0x9e, 0x42, 0xa5, 0xb9, 0xbc, 0x06, 0xec,
0x79, 0x4b, 0x08, 0xe3, 0xe6, 0x1e, 0x54, 0x42, 0x12, 0x0d, 0x43, 0xde, 0x50, 0x8f, 0xd4, 0x73, 0x3d, 0x66, 0x28, 0xec, 0x3d, 0x28, 0x0d, 0xd8, 0xb0, 0x3f, 0x10, 0x35, 0xbd, 0xae, 0x9f, 0x19,
0xcd, 0x4b, 0x6f, 0xf6, 0x05, 0x18, 0xb7, 0x34, 0x55, 0xb2, 0x31, 0x8d, 0x19, 0xd9, 0x2a, 0xbd, 0x41, 0x72, 0x73, 0xcf, 0xc1, 0x7a, 0xe0, 0x89, 0x12, 0xc7, 0x3c, 0x42, 0xf6, 0xa7, 0xf4, 0x06,
0x06, 0x7d, 0x5d, 0x78, 0x09, 0x65, 0x1c, 0x89, 0xba, 0x6a, 0x6b, 0xdf, 0x91, 0x8c, 0x8a, 0x07, 0xcc, 0x4d, 0xe1, 0x05, 0x14, 0x69, 0x24, 0xe9, 0xca, 0x8d, 0x7d, 0x4f, 0xf1, 0x29, 0xfd, 0x4b,
0x08, 0xbd, 0x50, 0xd9, 0x06, 0xe8, 0xf7, 0xdc, 0xe7, 0x09, 0x4b, 0x3d, 0xd9, 0x6d, 0xa8, 0x2f, 0xbd, 0x54, 0xb9, 0x16, 0x98, 0x6d, 0xd1, 0x15, 0x31, 0x26, 0x9e, 0xdc, 0x6b, 0xa8, 0xae, 0x0a,
0x0b, 0xc5, 0xa3, 0x4d, 0x13, 0x4a, 0x81, 0xcf, 0x48, 0xe3, 0x1f, 0x56, 0xf1, 0x6c, 0x7f, 0x6a, 0xf9, 0xa3, 0x6d, 0x1b, 0x0a, 0x61, 0x17, 0x59, 0xed, 0x1f, 0x55, 0xe9, 0xec, 0x7e, 0x1a, 0xf0,
0xf0, 0xbf, 0x47, 0x18, 0xf3, 0x87, 0xc4, 0xbc, 0x01, 0x1d, 0x67, 0xf4, 0x27, 0x02, 0x9d, 0x3a, 0xff, 0x9e, 0x21, 0x76, 0xfb, 0xcc, 0xbe, 0x05, 0x93, 0x66, 0x74, 0x26, 0x12, 0x9d, 0x38, 0x72,
0x3a, 0x71, 0x36, 0x46, 0xe7, 0xc8, 0xc9, 0x74, 0x15, 0xaf, 0x16, 0xc8, 0x49, 0x3d, 0xc0, 0x4e, 0xbd, 0x6d, 0xc9, 0x79, 0x6a, 0x30, 0x2d, 0x2d, 0xa8, 0x84, 0x6a, 0x50, 0x6d, 0xd8, 0x89, 0x78,
0x4c, 0xfb, 0x4b, 0x9c, 0x30, 0x86, 0x83, 0xab, 0xad, 0xe6, 0x16, 0x5e, 0x2e, 0xc1, 0xae, 0xe2, 0x67, 0x45, 0x93, 0xbe, 0x68, 0x6e, 0xb9, 0x71, 0xb2, 0x1d, 0x97, 0xc9, 0xaf, 0xa5, 0x05, 0x56,
0x19, 0x71, 0x2e, 0xd4, 0x1e, 0xd4, 0x73, 0x48, 0x0d, 0x91, 0xa7, 0xc5, 0x16, 0x33, 0xa0, 0x1e, 0x94, 0x89, 0xf4, 0x0e, 0xaa, 0x19, 0xa2, 0x41, 0xc4, 0xa3, 0x5c, 0x83, 0x29, 0xcf, 0x0c, 0xb3,
0xe4, 0x71, 0x0c, 0xa3, 0xcb, 0x5e, 0x5c, 0x2a, 0xc4, 0xad, 0x05, 0xbf, 0xc0, 0x31, 0xb9, 0x60, 0x34, 0xa4, 0xdc, 0xd2, 0xdf, 0x2d, 0xe4, 0xd1, 0x36, 0x42, 0x5f, 0xd2, 0x50, 0x2d, 0xd8, 0x8f,
0xde, 0x81, 0x91, 0xe1, 0x52, 0x7b, 0x65, 0xe4, 0x9d, 0xfd, 0xc1, 0xcb, 0xfc, 0xd5, 0xd9, 0x5a, 0x60, 0xa5, 0xb4, 0xc4, 0x5c, 0x91, 0x70, 0xc7, 0xf9, 0xb8, 0xd4, 0x5d, 0x15, 0x37, 0x2a, 0xcd,
0xa5, 0x53, 0x06, 0x8d, 0x25, 0xa3, 0xce, 0xe3, 0xd7, 0xcc, 0x52, 0xa7, 0x33, 0x4b, 0xfd, 0x99, 0x22, 0x18, 0x18, 0x8f, 0x9a, 0x4f, 0x5f, 0x73, 0x47, 0x9f, 0xcd, 0x1d, 0xfd, 0x67, 0xee, 0xe8,
0x59, 0xea, 0xc7, 0xdc, 0x52, 0xa6, 0x73, 0x4b, 0xf9, 0x9e, 0x5b, 0xca, 0x53, 0x7b, 0x18, 0xf1, 0x1f, 0x0b, 0x47, 0x9b, 0x2d, 0x1c, 0xed, 0x7b, 0xe1, 0x68, 0xcf, 0x57, 0xfd, 0xa1, 0x18, 0xc4,
0x30, 0x09, 0x9c, 0x01, 0x1d, 0xb9, 0xf2, 0x26, 0xaf, 0x8e, 0xb8, 0xc8, 0xee, 0xc6, 0xff, 0x23, 0xa1, 0xd7, 0xe3, 0x23, 0x5f, 0x5d, 0xe2, 0xf5, 0x91, 0x76, 0xd8, 0xdf, 0xf6, 0x30, 0xc2, 0x12,
0xa8, 0xe0, 0xc7, 0xab, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5e, 0x59, 0x07, 0xbd, 0x3f, 0x03, 0x7d, 0xbb, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xf5, 0x1c, 0xa3, 0x45, 0x37, 0x03, 0x00, 0x00,
0x00, 0x00,
} }
func (m *BlockRequest) Marshal() (dAtA []byte, err error) { func (m *BlockRequest) Marshal() (dAtA []byte, err error) {

View File

@@ -1,7 +1,7 @@
syntax = "proto3"; syntax = "proto3";
package tendermint.blockchain; package tendermint.blocksync;
option go_package = "github.com/tendermint/tendermint/proto/tendermint/blockchain"; option go_package = "github.com/tendermint/tendermint/proto/tendermint/blocksync";
import "tendermint/types/block.proto"; import "tendermint/types/block.proto";

View File

@@ -81,7 +81,7 @@ type Environment struct {
ConsensusReactor *consensus.Reactor ConsensusReactor *consensus.Reactor
EventBus *types.EventBus // thread safe EventBus *types.EventBus // thread safe
Mempool mempl.Mempool Mempool mempl.Mempool
FastSyncReactor consensus.FastSyncReactor BlockSyncReactor consensus.BlockSyncReactor
Logger log.Logger Logger log.Logger

View File

@@ -69,10 +69,10 @@ func (env *Environment) Status(ctx *rpctypes.Context) (*ctypes.ResultStatus, err
EarliestAppHash: earliestAppHash, EarliestAppHash: earliestAppHash,
EarliestBlockHeight: earliestBlockHeight, EarliestBlockHeight: earliestBlockHeight,
EarliestBlockTime: time.Unix(0, earliestBlockTimeNano), EarliestBlockTime: time.Unix(0, earliestBlockTimeNano),
MaxPeerBlockHeight: env.FastSyncReactor.GetMaxPeerBlockHeight(), MaxPeerBlockHeight: env.BlockSyncReactor.GetMaxPeerBlockHeight(),
CatchingUp: env.ConsensusReactor.WaitSync(), CatchingUp: env.ConsensusReactor.WaitSync(),
TotalSyncedTime: env.FastSyncReactor.GetTotalSyncedTime(), TotalSyncedTime: env.BlockSyncReactor.GetTotalSyncedTime(),
RemainingTime: env.FastSyncReactor.GetRemainingSyncTime(), RemainingTime: env.BlockSyncReactor.GetRemainingSyncTime(),
}, },
ValidatorInfo: validatorInfo, ValidatorInfo: validatorInfo,
} }

View File

@@ -23,7 +23,7 @@ The above should hold for any arbitrary, valid network configuration, and that c
A testnet configuration is specified as a TOML testnet manifest (see below). The testnet runner uses the manifest to configure a set of Docker containers and start them in some order. The manifests can be written manually (to test specific configurations) or generated randomly by the testnet generator (to test a wide range of configuration permutations). A testnet configuration is specified as a TOML testnet manifest (see below). The testnet runner uses the manifest to configure a set of Docker containers and start them in some order. The manifests can be written manually (to test specific configurations) or generated randomly by the testnet generator (to test a wide range of configuration permutations).
When running a testnet, the runner will first start the Docker nodes in some sequence, submit random transactions, and wait for the nodes to come online and the first blocks to be produced. This may involve e.g. waiting for nodes to fast sync and/or state sync. If specified, it will then run any misbehaviors (e.g. double-signing) and perturbations (e.g. killing or disconnecting nodes). It then waits for the testnet to stabilize, with all nodes online and having reached the latest height. When running a testnet, the runner will first start the Docker nodes in some sequence, submit random transactions, and wait for the nodes to come online and the first blocks to be produced. This may involve e.g. waiting for nodes to block sync and/or state sync. If specified, it will then run any misbehaviors (e.g. double-signing) and perturbations (e.g. killing or disconnecting nodes). It then waits for the testnet to stabilize, with all nodes online and having reached the latest height.
Once the testnet stabilizes, a set of Go end-to-end tests are run against the live testnet to verify network invariants (for example that blocks are identical across nodes). These use the RPC client to interact with the network, and should consider the entire network as a black box (i.e. it should not test any network or node internals, only externally visible behavior via RPC). The tests may use the `testNode()` helper to run parallel tests against each individual testnet node, and/or inspect the full blockchain history via `fetchBlockChain()`. Once the testnet stabilizes, a set of Go end-to-end tests are run against the live testnet to verify network invariants (for example that blocks are identical across nodes). These use the RPC client to interact with the network, and should consider the entire network as a black box (i.e. it should not test any network or node internals, only externally visible behavior via RPC). The tests may use the `testNode()` helper to run parallel tests against each individual testnet node, and/or inspect the full blockchain history via `fetchBlockChain()`.

View File

@@ -30,7 +30,7 @@ var (
nodeABCIProtocols = uniformChoice{"unix", "tcp", "builtin", "grpc"} nodeABCIProtocols = uniformChoice{"unix", "tcp", "builtin", "grpc"}
nodePrivvalProtocols = uniformChoice{"file", "unix", "tcp", "grpc"} nodePrivvalProtocols = uniformChoice{"file", "unix", "tcp", "grpc"}
// FIXME: v2 disabled due to flake // FIXME: v2 disabled due to flake
nodeFastSyncs = uniformChoice{"v0"} // "v2" nodeBlockSyncs = uniformChoice{"v0"} // "v2"
nodeMempools = uniformChoice{"v0", "v1"} nodeMempools = uniformChoice{"v0", "v1"}
nodeStateSyncs = uniformChoice{false, true} nodeStateSyncs = uniformChoice{false, true}
nodePersistIntervals = uniformChoice{0, 1, 5} nodePersistIntervals = uniformChoice{0, 1, 5}
@@ -273,7 +273,7 @@ func generateNode(
Database: nodeDatabases.Choose(r).(string), Database: nodeDatabases.Choose(r).(string),
ABCIProtocol: nodeABCIProtocols.Choose(r).(string), ABCIProtocol: nodeABCIProtocols.Choose(r).(string),
PrivvalProtocol: nodePrivvalProtocols.Choose(r).(string), PrivvalProtocol: nodePrivvalProtocols.Choose(r).(string),
FastSync: nodeFastSyncs.Choose(r).(string), BlockSync: nodeBlockSyncs.Choose(r).(string),
Mempool: nodeMempools.Choose(r).(string), Mempool: nodeMempools.Choose(r).(string),
StateSync: nodeStateSyncs.Choose(r).(bool) && startAt > 0, StateSync: nodeStateSyncs.Choose(r).(bool) && startAt > 0,
PersistInterval: ptrUint64(uint64(nodePersistIntervals.Choose(r).(int))), PersistInterval: ptrUint64(uint64(nodePersistIntervals.Choose(r).(int))),
@@ -311,7 +311,7 @@ func generateNode(
} }
if node.StateSync { if node.StateSync {
node.FastSync = "v0" node.BlockSync = "v0"
} }
return &node return &node

View File

@@ -30,11 +30,6 @@ validator05 = 50
[node.seed01] [node.seed01]
mode = "seed" mode = "seed"
perturb = ["restart"] perturb = ["restart"]
seeds = ["seed02"]
[node.seed02]
mode = "seed"
seeds = ["seed01"]
[node.validator01] [node.validator01]
perturb = ["disconnect"] perturb = ["disconnect"]
@@ -47,7 +42,7 @@ database = "boltdb"
persist_interval = 0 persist_interval = 0
perturb = ["restart"] perturb = ["restart"]
privval_protocol = "tcp" privval_protocol = "tcp"
seeds = ["seed02"] seeds = ["seed01"]
[node.validator03] [node.validator03]
database = "badgerdb" database = "badgerdb"
@@ -66,29 +61,21 @@ perturb = ["pause"]
[node.validator05] [node.validator05]
database = "cleveldb" database = "cleveldb"
fast_sync = "v0" block_sync = "v0"
seeds = ["seed02"] seeds = ["seed01"]
start_at = 1005 # Becomes part of the validator set at 1010 start_at = 1005 # Becomes part of the validator set at 1010
abci_protocol = "grpc" abci_protocol = "grpc"
perturb = ["kill", "pause", "disconnect", "restart"] perturb = ["pause", "disconnect", "restart"]
privval_protocol = "tcp" privval_protocol = "tcp"
[node.full01] [node.full01]
mode = "full" mode = "full"
start_at = 1010 start_at = 1010
# FIXME: should be v2, disabled due to flake # FIXME: should be v2, disabled due to flake
fast_sync = "v0" block_sync = "v0"
persistent_peers = ["validator01", "validator02", "validator03", "validator04", "validator05"] persistent_peers = ["validator01", "validator02", "validator03", "validator04", "validator05"]
perturb = ["restart"] perturb = ["restart"]
retain_blocks = 7 retain_blocks = 7
[node.full02]
mode = "full"
start_at = 1015
# FIXME: should be v2, disabled due to flake
fast_sync = "v0"
perturb = ["restart"]
seeds = ["seed01"]
state_sync = true state_sync = true
[node.light01] [node.light01]

View File

@@ -106,9 +106,9 @@ type ManifestNode struct {
// runner will wait for the network to reach at least this block height. // runner will wait for the network to reach at least this block height.
StartAt int64 `toml:"start_at"` StartAt int64 `toml:"start_at"`
// FastSync specifies the fast sync mode: "" (disable), "v0" or "v2". // BlockSync specifies the block sync mode: "" (disable), "v0" or "v2".
// Defaults to disabled. // Defaults to disabled.
FastSync string `toml:"fast_sync"` BlockSync string `toml:"block_sync"`
// Mempool specifies which version of mempool to use. Either "v0" or "v1" // Mempool specifies which version of mempool to use. Either "v0" or "v1"
Mempool string `toml:"mempool_version"` Mempool string `toml:"mempool_version"`

View File

@@ -79,7 +79,7 @@ type Node struct {
IP net.IP IP net.IP
ProxyPort uint32 ProxyPort uint32
StartAt int64 StartAt int64
FastSync string BlockSync string
Mempool string Mempool string
StateSync bool StateSync bool
Database string Database string
@@ -168,7 +168,7 @@ func LoadTestnet(file string) (*Testnet, error) {
ABCIProtocol: ProtocolBuiltin, ABCIProtocol: ProtocolBuiltin,
PrivvalProtocol: ProtocolFile, PrivvalProtocol: ProtocolFile,
StartAt: nodeManifest.StartAt, StartAt: nodeManifest.StartAt,
FastSync: nodeManifest.FastSync, BlockSync: nodeManifest.BlockSync,
Mempool: nodeManifest.Mempool, Mempool: nodeManifest.Mempool,
StateSync: nodeManifest.StateSync, StateSync: nodeManifest.StateSync,
PersistInterval: 1, PersistInterval: 1,
@@ -328,10 +328,10 @@ func (n Node) Validate(testnet Testnet) error {
} }
} }
} }
switch n.FastSync { switch n.BlockSync {
case "", "v0", "v2": case "", "v0", "v2":
default: default:
return fmt.Errorf("invalid fast sync setting %q", n.FastSync) return fmt.Errorf("invalid block sync setting %q", n.BlockSync)
} }
switch n.Mempool { switch n.Mempool {
case "", "v0", "v1": case "", "v0", "v1":

View File

@@ -296,10 +296,10 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) {
cfg.Mempool.Version = node.Mempool cfg.Mempool.Version = node.Mempool
} }
if node.FastSync == "" { if node.BlockSync == "" {
cfg.FastSyncMode = false cfg.FastSyncMode = false
} else { } else {
cfg.FastSync.Version = node.FastSync cfg.BlockSync.Version = node.BlockSync
} }
if node.StateSync { if node.StateSync {

View File

@@ -153,8 +153,8 @@ func (b *EventBus) PublishEventValidBlock(data EventDataRoundState) error {
return b.Publish(EventValidBlockValue, data) return b.Publish(EventValidBlockValue, data)
} }
func (b *EventBus) PublishEventFastSyncStatus(data EventDataFastSyncStatus) error { func (b *EventBus) PublishEventBlockSyncStatus(data EventDataBlockSyncStatus) error {
return b.Publish(EventFastSyncStatusValue, data) return b.Publish(EventBlockSyncStatusValue, data)
} }
func (b *EventBus) PublishEventStateSyncStatus(data EventDataStateSyncStatus) error { func (b *EventBus) PublishEventStateSyncStatus(data EventDataStateSyncStatus) error {
@@ -317,7 +317,7 @@ func (NopEventBus) PublishEventValidatorSetUpdates(data EventDataValidatorSetUpd
return nil return nil
} }
func (NopEventBus) PublishEventFastSyncStatus(data EventDataFastSyncStatus) error { func (NopEventBus) PublishEventBlockSyncStatus(data EventDataBlockSyncStatus) error {
return nil return nil
} }

View File

@@ -370,7 +370,7 @@ func TestEventBusPublish(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
err = eventBus.PublishEventValidatorSetUpdates(EventDataValidatorSetUpdates{}) err = eventBus.PublishEventValidatorSetUpdates(EventDataValidatorSetUpdates{})
require.NoError(t, err) require.NoError(t, err)
err = eventBus.PublishEventFastSyncStatus(EventDataFastSyncStatus{}) err = eventBus.PublishEventBlockSyncStatus(EventDataBlockSyncStatus{})
require.NoError(t, err) require.NoError(t, err)
err = eventBus.PublishEventStateSyncStatus(EventDataStateSyncStatus{}) err = eventBus.PublishEventStateSyncStatus(EventDataStateSyncStatus{})
require.NoError(t, err) require.NoError(t, err)
@@ -480,7 +480,7 @@ var events = []string{
EventRelockValue, EventRelockValue,
EventTimeoutWaitValue, EventTimeoutWaitValue,
EventVoteValue, EventVoteValue,
EventFastSyncStatusValue, EventBlockSyncStatusValue,
EventStateSyncStatusValue, EventStateSyncStatusValue,
} }
@@ -502,7 +502,9 @@ var queries = []tmpubsub.Query{
EventQueryRelock, EventQueryRelock,
EventQueryTimeoutWait, EventQueryTimeoutWait,
EventQueryVote, EventQueryVote,
EventQueryFastSyncStatus} EventQueryBlockSyncStatus,
EventQueryStateSyncStatus,
}
func randQuery() tmpubsub.Query { func randQuery() tmpubsub.Query {
return queries[mrand.Intn(len(queries))] return queries[mrand.Intn(len(queries))]

View File

@@ -27,9 +27,9 @@ const (
// These are used for testing the consensus state machine. // These are used for testing the consensus state machine.
// They can also be used to build real-time consensus visualizers. // They can also be used to build real-time consensus visualizers.
EventCompleteProposalValue = "CompleteProposal" EventCompleteProposalValue = "CompleteProposal"
// The FastSyncStatus event will be emitted when the node switching // The BlockSyncStatus event will be emitted when the node switching
// state sync mechanism between the consensus reactor and the fastsync reactor. // state sync mechanism between the consensus reactor and the blocksync reactor.
EventFastSyncStatusValue = "FastSyncStatus" EventBlockSyncStatusValue = "BlockSyncStatus"
EventLockValue = "Lock" EventLockValue = "Lock"
EventNewRoundValue = "NewRound" EventNewRoundValue = "NewRound"
EventNewRoundStepValue = "NewRoundStep" EventNewRoundStepValue = "NewRoundStep"
@@ -104,7 +104,7 @@ func init() {
tmjson.RegisterType(EventDataVote{}, "tendermint/event/Vote") tmjson.RegisterType(EventDataVote{}, "tendermint/event/Vote")
tmjson.RegisterType(EventDataValidatorSetUpdates{}, "tendermint/event/ValidatorSetUpdates") tmjson.RegisterType(EventDataValidatorSetUpdates{}, "tendermint/event/ValidatorSetUpdates")
tmjson.RegisterType(EventDataString(""), "tendermint/event/ProposalString") tmjson.RegisterType(EventDataString(""), "tendermint/event/ProposalString")
tmjson.RegisterType(EventDataFastSyncStatus{}, "tendermint/event/FastSyncStatus") tmjson.RegisterType(EventDataBlockSyncStatus{}, "tendermint/event/FastSyncStatus")
tmjson.RegisterType(EventDataStateSyncStatus{}, "tendermint/event/StateSyncStatus") tmjson.RegisterType(EventDataStateSyncStatus{}, "tendermint/event/StateSyncStatus")
} }
@@ -176,9 +176,9 @@ type EventDataValidatorSetUpdates struct {
ValidatorUpdates []*Validator `json:"validator_updates"` ValidatorUpdates []*Validator `json:"validator_updates"`
} }
// EventDataFastSyncStatus shows the fastsync status and the // EventDataBlockSyncStatus shows the fastsync status and the
// height when the node state sync mechanism changes. // height when the node state sync mechanism changes.
type EventDataFastSyncStatus struct { type EventDataBlockSyncStatus struct {
Complete bool `json:"complete"` Complete bool `json:"complete"`
Height int64 `json:"height"` Height int64 `json:"height"`
} }
@@ -227,7 +227,7 @@ var (
EventQueryValidatorSetUpdates = QueryForEvent(EventValidatorSetUpdatesValue) EventQueryValidatorSetUpdates = QueryForEvent(EventValidatorSetUpdatesValue)
EventQueryValidBlock = QueryForEvent(EventValidBlockValue) EventQueryValidBlock = QueryForEvent(EventValidBlockValue)
EventQueryVote = QueryForEvent(EventVoteValue) EventQueryVote = QueryForEvent(EventVoteValue)
EventQueryFastSyncStatus = QueryForEvent(EventFastSyncStatusValue) EventQueryBlockSyncStatus = QueryForEvent(EventBlockSyncStatusValue)
EventQueryStateSyncStatus = QueryForEvent(EventStateSyncStatusValue) EventQueryStateSyncStatus = QueryForEvent(EventStateSyncStatusValue)
) )