From 8c2c2f25b5dc623e621a4b21bd9b62e529aa04db Mon Sep 17 00:00:00 2001 From: William Banfield Date: Tue, 16 Aug 2022 14:34:23 -0400 Subject: [PATCH] additional fixup --- blocksync/reactor.go | 20 +++++----- cmd/tendermint/commands/run_node.go | 2 +- config/config.go | 6 +-- config/toml.go | 8 ++-- consensus/metrics.gen.go | 2 +- consensus/metrics.go | 2 +- consensus/reactor.go | 12 +++--- docs/tendermint-core/block-sync.md | 55 ++++----------------------- docs/tendermint-core/configuration.md | 4 +- docs/tendermint-core/metrics.md | 2 +- node/node.go | 10 ++--- spec/abci/abci.md | 2 +- test/e2e/networks/ci.toml | 2 +- test/e2e/runner/setup.go | 2 +- 14 files changed, 44 insertions(+), 85 deletions(-) diff --git a/blocksync/reactor.go b/blocksync/reactor.go index b922b030b..1f867ca98 100644 --- a/blocksync/reactor.go +++ b/blocksync/reactor.go @@ -30,7 +30,7 @@ const ( ) 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 SwitchToConsensus(state sm.State, skipWAL bool) } @@ -54,7 +54,7 @@ type Reactor struct { blockExec *sm.BlockExecutor store *store.BlockStore pool *BlockPool - fastSync bool + blockSync bool requestsCh <-chan BlockRequest errorsCh <-chan peerError @@ -62,7 +62,7 @@ type Reactor struct { // NewReactor returns new reactor instance. func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore, - fastSync bool) *Reactor { + blockSync bool) *Reactor { if state.LastBlockHeight != store.Height() { panic(fmt.Sprintf("state (%v) and store (%v) height mismatch", state.LastBlockHeight, @@ -85,7 +85,7 @@ func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockS blockExec: blockExec, store: store, pool: pool, - fastSync: fastSync, + blockSync: blockSync, requestsCh: requestsCh, errorsCh: errorsCh, } @@ -101,7 +101,7 @@ func (bcR *Reactor) SetLogger(l log.Logger) { // OnStart implements service.Service. func (bcR *Reactor) OnStart() error { - if bcR.fastSync { + if bcR.blockSync { err := bcR.pool.Start() if err != nil { return err @@ -111,9 +111,9 @@ func (bcR *Reactor) OnStart() error { return nil } -// SwitchToFastSync is called by the state sync reactor when switching to fast sync. -func (bcR *Reactor) SwitchToFastSync(state sm.State) error { - bcR.fastSync = true +// SwitchToBlockSync is called by the state sync reactor when switching to block sync. +func (bcR *Reactor) SwitchToBlockSync(state sm.State) error { + bcR.blockSync = true bcR.initialState = state bcR.pool.height = state.LastBlockHeight + 1 @@ -127,7 +127,7 @@ func (bcR *Reactor) SwitchToFastSync(state sm.State) error { // OnStop implements service.Service. func (bcR *Reactor) OnStop() { - if bcR.fastSync { + if bcR.blockSync { if err := bcR.pool.Stop(); err != nil { bcR.Logger.Error("Error stopping pool", "err", err) } @@ -409,7 +409,7 @@ FOR_LOOP: if blocksSynced%100 == 0 { lastRate = 0.9*lastRate + 0.1*(100/time.Since(lastHundred).Seconds()) - bcR.Logger.Info("Fast Sync Rate", "height", bcR.pool.height, + bcR.Logger.Info("Block Sync Rate", "height", bcR.pool.height, "max_peer_height", bcR.pool.MaxPeerHeight(), "blocks/s", lastRate) lastHundred = time.Now() } diff --git a/cmd/tendermint/commands/run_node.go b/cmd/tendermint/commands/run_node.go index d78eab2c8..ac2984111 100644 --- a/cmd/tendermint/commands/run_node.go +++ b/cmd/tendermint/commands/run_node.go @@ -31,7 +31,7 @@ func AddNodeFlags(cmd *cobra.Command) { "socket address to listen on for connections from external priv_validator process") // node flags - cmd.Flags().Bool("fast_sync", config.FastSyncMode, "fast blockchain syncing") + cmd.Flags().Bool("block_sync", config.BlockSyncMode, "sync the block chain using the blocksync algorithm") cmd.Flags().BytesHexVar( &genesisHash, "genesis_hash", diff --git a/config/config.go b/config/config.go index 385873041..497f80c67 100644 --- a/config/config.go +++ b/config/config.go @@ -170,7 +170,7 @@ type BaseConfig struct { //nolint: maligned // If this node is many blocks behind the tip of the chain, Blocksync // allows them to catchup quickly by downloading blocks in parallel // and verifying their commits - Blocksync bool `mapstructure:"block_sync"` + BlockSyncMode bool `mapstructure:"block_sync"` // Database backend: goleveldb | cleveldb | boltdb | rocksdb // * goleveldb (github.com/syndtr/goleveldb - most popular implementation) @@ -238,7 +238,7 @@ func DefaultBaseConfig() BaseConfig { ABCI: "socket", LogLevel: DefaultLogLevel, LogFormat: LogFormatPlain, - Blocksync: true, + BlockSyncMode: true, FilterPeers: false, DBBackend: "goleveldb", DBPath: "data", @@ -250,7 +250,7 @@ func TestBaseConfig() BaseConfig { cfg := DefaultBaseConfig() cfg.chainID = "tendermint_test" cfg.ProxyApp = "kvstore" - cfg.Blocksync = false + cfg.BlockSyncMode = false cfg.DBBackend = "memdb" return cfg } diff --git a/config/toml.go b/config/toml.go index 02120ed4b..aa2c14ee3 100644 --- a/config/toml.go +++ b/config/toml.go @@ -90,7 +90,7 @@ moniker = "{{ .BaseConfig.Moniker }}" # If this node is many blocks behind the tip of the chain, FastSync # allows them to catchup quickly by downloading blocks in parallel # and verifying their commits -fast_sync = {{ .BaseConfig.FastSyncMode }} +block_sync = {{ .BaseConfig.BlockSyncMode }} # Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb # * goleveldb (github.com/syndtr/goleveldb - most popular implementation) @@ -431,15 +431,15 @@ chunk_fetchers = "{{ .StateSync.ChunkFetchers }}" ####################################################### ### Block Sync Configuration Connections ### ####################################################### -[fastsync] +[blocksync] # Block Sync version to use: # # In v0.37, v1 and v2 of the block sync protocols were deprecated. # Please use v0 instead. # -# 1) "v0" - the default fast sync implementation -version = "{{ .FastSync.Version }}" +# 1) "v0" - the default block sync implementation +version = "{{ .BlockSync.Version }}" ####################################################### ### Consensus Configuration Options ### diff --git a/consensus/metrics.gen.go b/consensus/metrics.gen.go index c87182266..e627dee57 100644 --- a/consensus/metrics.gen.go +++ b/consensus/metrics.gen.go @@ -122,7 +122,7 @@ func PrometheusMetrics(namespace string, labelsAndValues ...string) *Metrics { Namespace: namespace, Subsystem: MetricsSubsystem, 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...), StateSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ Namespace: namespace, diff --git a/consensus/metrics.go b/consensus/metrics.go index 3812cf4d4..2a82d732f 100644 --- a/consensus/metrics.go +++ b/consensus/metrics.go @@ -59,7 +59,7 @@ type Metrics struct { TotalTxs metrics.Gauge // The latest block height. CommittedHeight metrics.Gauge `metrics_name:"latest_block_height"` - // 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. BlockSyncing metrics.Gauge // Whether or not a node is state syncing. 1 if yes, 0 if no. StateSyncing metrics.Gauge diff --git a/consensus/reactor.go b/consensus/reactor.go index 727084eda..c86f21c98 100644 --- a/consensus/reactor.go +++ b/consensus/reactor.go @@ -72,7 +72,7 @@ func NewReactor(consensusState *State, waitSync bool, options ...ReactorOption) } // OnStart implements BaseService by subscribing to events, which later will be -// broadcasted to other peers and starting state if we're not in fast sync. +// broadcasted to other peers and starting state if we're not in block sync. func (conR *Reactor) OnStart() error { conR.Logger.Info("Reactor ", "waitSync", conR.WaitSync()) @@ -104,8 +104,8 @@ func (conR *Reactor) OnStop() { } } -// SwitchToConsensus switches from fast_sync mode to consensus mode. -// It resets the state, turns off fast_sync, and starts the consensus state-machine +// SwitchToConsensus switches from block_sync mode to consensus mode. +// It resets the state, turns off block_sync, and starts the consensus state-machine func (conR *Reactor) SwitchToConsensus(state sm.State, skipWAL bool) { conR.Logger.Info("SwitchToConsensus") @@ -198,7 +198,7 @@ func (conR *Reactor) AddPeer(peer p2p.Peer) { go conR.queryMaj23Routine(peer, peerState) // Send our state to peer. - // If we're fast_syncing, broadcast a RoundStepMessage later upon SwitchToConsensus(). + // If we're block_syncing, broadcast a RoundStepMessage later upon SwitchToConsensus(). if !conR.WaitSync() { conR.sendNewRoundStepMessage(peer) } @@ -218,7 +218,7 @@ func (conR *Reactor) RemovePeer(peer p2p.Peer, reason interface{}) { } // Receive implements Reactor -// NOTE: We process these messages even when we're fast_syncing. +// 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 parallel, but processing of // proposals, block parts, and votes are ordered by the receiveRoutine @@ -386,7 +386,7 @@ func (conR *Reactor) SetEventBus(b *types.EventBus) { conR.conS.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 (conR *Reactor) WaitSync() bool { conR.mtx.RLock() defer conR.mtx.RUnlock() diff --git a/docs/tendermint-core/block-sync.md b/docs/tendermint-core/block-sync.md index 4a2843a59..77388d850 100644 --- a/docs/tendermint-core/block-sync.md +++ b/docs/tendermint-core/block-sync.md @@ -17,9 +17,9 @@ consensus gossip protocol. ## Using Block Sync -To support faster syncing, Tendermint offers a `fast-sync` mode, which +To support faster syncing, Tendermint offers a `block-sync` mode, which is enabled by default, and can be toggled in the `config.toml` or via -`--fast_sync=false`. +`--block_sync=false`. 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 @@ -29,61 +29,20 @@ has at least one peer and it's height is at least as high as the max reported peer height. See [the IsCaughtUp method](https://github.com/tendermint/tendermint/blob/b467515719e686e4678e6da4e102f32a491b85a0/blockchain/pool.go#L128). -<<<<<<< HEAD:docs/tendermint-core/fast-sync.md -Note: There are three versions of fast sync. We recommend using v0 as v1 and v2 are still in beta. -||||||| parent of 6ff4c3139 (blockchain: rename to blocksync service (#6755)):docs/tendermint-core/fast-sync.md -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. ->>>>>>> 6ff4c3139 (blockchain: rename to blocksync service (#6755)):docs/tendermint-core/block-sync.md - If you would like to use a different version you can do so by changing the version in the `config.toml`: +Note: While there have historically been multiple versions of blocksync, v0, v1, and v2, all versions +other than v0 have been deprecated in favor of the simplest and most well understood algorithm. ```toml ####################################################### ### Block Sync Configuration Connections ### ####################################################### -[fastsync] +[blocksync] -<<<<<<< HEAD:docs/tendermint-core/fast-sync.md -# Fast Sync version to use: -# 1) "v0" (default) - the legacy fast sync implementation -# 2) "v1" - refactor of v0 version for better testability -# 2) "v2" - complete redesign of v0, optimized for testability & readability -||||||| parent of 6ff4c3139 (blockchain: rename to blocksync service (#6755)):docs/tendermint-core/fast-sync.md -# Fast Sync version to use: -# 1) "v0" (default) - the legacy fast sync implementation -# 2) "v2" - complete redesign of v0, optimized for testability & readability -======= # Block Sync version to use: -# 1) "v0" (default) - the legacy Block Sync implementation -# 2) "v2" - complete redesign of v0, optimized for testability & readability ->>>>>>> 6ff4c3139 (blockchain: rename to blocksync service (#6755)):docs/tendermint-core/block-sync.md +# 1) "v0" (default) - the legacy fast sync implementation +# All other versions have been deprecated and will error if used. version = "v0" ``` 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). -<<<<<<< HEAD:docs/tendermint-core/fast-sync.md -||||||| parent of 6ff4c3139 (blockchain: rename to blocksync service (#6755)):docs/tendermint-core/fast-sync.md - -## The Fast Sync event -When the tendermint blockchain core launches, it might switch to the `fast-sync` -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 -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`. - -The user can query the events by subscribing `EventQueryFastSyncStatus` -Please check [types](https://pkg.go.dev/github.com/tendermint/tendermint/types?utm_source=godoc#pkg-constants) for the details. -======= - -## The Block Sync event -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 -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 -another event for exposing the fast-sync `complete` status and the state `height`. - -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. ->>>>>>> 6ff4c3139 (blockchain: rename to blocksync service (#6755)):docs/tendermint-core/block-sync.md diff --git a/docs/tendermint-core/configuration.md b/docs/tendermint-core/configuration.md index 120716bfd..3668e331f 100644 --- a/docs/tendermint-core/configuration.md +++ b/docs/tendermint-core/configuration.md @@ -36,10 +36,10 @@ proxy_app = "tcp://127.0.0.1:26658" # A custom human readable name for this node 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 # and verifying their commits -fast_sync = true +block_sync = true # Database backend: goleveldb | cleveldb | boltdb | rocksdb | badgerdb # * goleveldb (github.com/syndtr/goleveldb - most popular implementation) diff --git a/docs/tendermint-core/metrics.md b/docs/tendermint-core/metrics.md index b0f7033ac..8fb0353a0 100644 --- a/docs/tendermint-core/metrics.md +++ b/docs/tendermint-core/metrics.md @@ -37,7 +37,7 @@ The following metrics are available: | consensus_total_txs | Gauge | | Total number of transactions committed | | consensus_block_parts | counter | peer_id | number of blockparts transmitted by peer | | consensus_latest_block_height | gauge | | /status sync_info number | -| consensus_fast_syncing | gauge | | either 0 (not fast syncing) or 1 (syncing) | +| consensus_block_syncing | gauge | | either 0 (not block syncing) or 1 (syncing) | | consensus_state_syncing | gauge | | either 0 (not state syncing) or 1 (syncing) | | consensus_block_size_bytes | Gauge | | Block size in bytes | | consensus_step_duration | Histogram | step | Histogram of durations for each step in the consensus protocol | diff --git a/node/node.go b/node/node.go index 9e3f44dae..36c9acd67 100644 --- a/node/node.go +++ b/node/node.go @@ -133,7 +133,7 @@ func DefaultMetricsProvider(config *cfg.InstrumentationConfig) MetricsProvider { // Option sets a parameter for the node. type Option func(*Node) -// Temporary interface for switching to fast sync, we should get rid of v0 and v1 reactors. +// Temporary interface for switching to block sync, we should get rid of v0 and v1 reactors. // See: https://github.com/tendermint/tendermint/issues/4595 type blockSyncReactor interface { SwitchToBlockSync(sm.State) error @@ -450,7 +450,7 @@ func createBlockchainReactor(config *cfg.Config, case "v0": bcReactor = bc.NewReactor(state.Copy(), blockExec, blockStore, blockSync) case "v1", "v2": - return nil, fmt.Errorf("fast sync version %s has been deprecated. Please use v0", config.BlockSync.Version) + return nil, fmt.Errorf("block sync version %s has been deprecated. Please use v0", config.BlockSync.Version) default: return nil, fmt.Errorf("unknown fastsync version %s", config.BlockSync.Version) } @@ -642,7 +642,7 @@ func createPEXReactorAndAddToSwitch(addrBook pex.AddrBook, config *cfg.Config, return pexReactor } -// 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(ssR *statesync.Reactor, bcR blockSyncReactor, conR *cs.Reactor, stateProvider statesync.StateProvider, config *cfg.StateSyncConfig, blockSync bool, stateStore sm.Store, blockStore *store.BlockStore, state sm.State) error { @@ -688,7 +688,7 @@ func startStateSync(ssR *statesync.Reactor, bcR blockSyncReactor, conR *cs.React conR.Metrics.BlockSyncing.Set(1) err = bcR.SwitchToBlockSync(state) if err != nil { - ssR.Logger.Error("Failed to switch to fast sync", "err", err) + ssR.Logger.Error("Failed to switch to block sync", "err", err) return } } else { @@ -808,7 +808,7 @@ func NewNode(config *cfg.Config, sm.BlockExecutorWithMetrics(smMetrics), ) - // Make BlockchainReactor. Don't start fast sync if we're doing a state sync first. + // Make BlockchainReactor. Don't start block sync if we're doing a state sync first. bcReactor, err := createBlockchainReactor(config, state, blockExec, blockStore, blockSync && !stateSync, logger) if err != nil { return nil, fmt.Errorf("could not create blockchain reactor: %w", err) diff --git a/spec/abci/abci.md b/spec/abci/abci.md index 634daec68..5ce004275 100644 --- a/spec/abci/abci.md +++ b/spec/abci/abci.md @@ -643,7 +643,7 @@ the blockchain's `AppHash` which is verified via [light client verification](../ `Snapshot.Metadata` and/or incrementally verifying contents against `AppHash`. * When all chunks have been accepted, Tendermint will make an ABCI `Info` call to verify that `LastBlockAppHash` and `LastBlockHeight` matches the expected values, and record the - `AppVersion` in the node state. It then switches to fast sync or consensus and joins the + `AppVersion` in the node state. It then switches to block sync or consensus and joins the network. * If Tendermint is unable to retrieve the next chunk after some time (e.g. because no suitable peers are available), it will reject the snapshot and try a different one via `OfferSnapshot`. diff --git a/test/e2e/networks/ci.toml b/test/e2e/networks/ci.toml index 8ff028cb1..f055d6dbb 100644 --- a/test/e2e/networks/ci.toml +++ b/test/e2e/networks/ci.toml @@ -67,7 +67,7 @@ block_sync = "v0" start_at = 1005 # Becomes part of the validator set at 1010 seeds = ["seed02"] database = "cleveldb" -fast_sync = true +block_sync =true mempool_version = "v1" # FIXME: should be grpc, disabled due to https://github.com/tendermint/tendermint/issues/5439 #abci_protocol = "grpc" diff --git a/test/e2e/runner/setup.go b/test/e2e/runner/setup.go index 022e0209d..311b1dda2 100644 --- a/test/e2e/runner/setup.go +++ b/test/e2e/runner/setup.go @@ -285,7 +285,7 @@ func MakeConfig(node *e2e.Node) (*config.Config, error) { } if node.BlockSync == "" { - cfg.FastSyncMode = false + cfg.BlockSyncMode = false } else { cfg.BlockSync.Version = node.BlockSync }