node: don't attempt fast sync when InitChain sets self as only validator (#5211)

Fixes #5178.
This commit is contained in:
Erik Grinaker
2020-08-06 19:50:20 +02:00
committed by GitHub
parent 2a98ef8af1
commit 3413a0dbd8
2 changed files with 6 additions and 3 deletions

View File

@@ -17,3 +17,4 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
### BUG FIXES:
- [evidence] [\#5170](https://github.com/tendermint/tendermint/pull/5170) change abci evidence time to the time the infraction happened not the time the evidence was committed on the block (@cmwaters)
- [node] Don't attempt fast sync when the ABCI application specifies ourself as the only validator via `InitChain` (@erikgrinaker)

View File

@@ -666,9 +666,7 @@ func NewNode(config *cfg.Config,
return nil, fmt.Errorf("can't get pubkey: %w", err)
}
// Determine whether we should do state and/or fast sync.
// We don't fast-sync when the only validator is us.
fastSync := config.FastSyncMode && !onlyValidatorIsUs(state, pubKey)
// Determine whether we should attempt state sync.
stateSync := config.StateSync.Enable && !onlyValidatorIsUs(state, pubKey)
if stateSync && state.LastBlockHeight > 0 {
logger.Info("Found local state with non-zero height, skipping state sync")
@@ -689,6 +687,10 @@ func NewNode(config *cfg.Config,
state = sm.LoadState(stateDB)
}
// Determine whether we should do fast sync. This must happen after the handshake, since the
// app may modify the validator set, specifying ourself as the only validator.
fastSync := config.FastSyncMode && !onlyValidatorIsUs(state, pubKey)
logNodeStartupInfo(state, pubKey, logger, consensusLogger)
csMetrics, p2pMetrics, memplMetrics, smMetrics := metricsProvider(genDoc.ChainID)