blocksync: drop support for enabled=false (#8912)

This commit is contained in:
Sam Kleinman
2022-07-14 13:19:12 -04:00
committed by GitHub
parent 7971514b55
commit f8d15fc682
6 changed files with 22 additions and 33 deletions

View File

@@ -250,7 +250,7 @@ func makeNode(cfg *config.Config,
// 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.
blockSync := cfg.BlockSync.Enable && !onlyValidatorIsUs(state, pubKey)
blockSync := !onlyValidatorIsUs(state, pubKey)
logNodeStartupInfo(state, pubKey, logger, consensusLogger, cfg.Mode)
@@ -777,30 +777,25 @@ func (n *nodeImpl) OnStart() error {
n.consensusReactor.SetStateSyncingMetrics(0)
d := types.EventDataStateSyncStatus{Complete: true, Height: state.LastBlockHeight}
if err := n.eventBus.PublishEventStateSyncStatus(d); err != nil {
if err := n.eventBus.PublishEventStateSyncStatus(
types.EventDataStateSyncStatus{Complete: true, Height: state.LastBlockHeight},
); err != nil {
n.eventBus.Logger.Error("failed to emit the statesync start event", "err", err)
}
// TODO: Some form of orchestrator is needed here between the state
// advancing reactors to be able to control which one of the three
// is running
if n.config.BlockSync.Enable {
// FIXME Very ugly to have these metrics bleed through here.
n.consensusReactor.SetBlockSyncingMetrics(1)
if err := bcR.SwitchToBlockSync(state); err != nil {
n.Logger.Error("failed to switch to block sync", "err", err)
return
}
d := types.EventDataBlockSyncStatus{Complete: false, Height: state.LastBlockHeight}
if err := n.eventBus.PublishEventBlockSyncStatus(d); err != nil {
n.eventBus.Logger.Error("failed to emit the block sync starting event", "err", err)
}
} else {
n.consensusReactor.SwitchToConsensus(state, true)
// FIXME Very ugly to have these metrics bleed through here.
n.consensusReactor.SetBlockSyncingMetrics(1)
if err := bcR.SwitchToBlockSync(state); err != nil {
n.Logger.Error("failed to switch to block sync", "err", err)
return
}
if err := n.eventBus.PublishEventBlockSyncStatus(
types.EventDataBlockSyncStatus{Complete: false, Height: state.LastBlockHeight},
); err != nil {
n.eventBus.Logger.Error("failed to emit the block sync starting event", "err", err)
}
}()
}

View File

@@ -338,6 +338,10 @@ func createBlockchainReactor(
metrics *consensus.Metrics,
) (*p2p.ReactorShim, service.Service, error) {
if !cfg.BlockSync.Enable {
logger.Error("blocksync.enable = false, but Tendermint no longer allows blocksync to be disabled. This setting is now ignored and will be removed in the next version.")
}
logger = logger.With("module", "blockchain")
switch cfg.BlockSync.Version {