Browse Source

node: fix genesis state propagation to state sync (#5302)

State sync broke in #5231 since the genesis state is not propagated explicitly from `NewNode()` to `Node.OnStart()` and further into the state sync initialization. This is a hack until we can clean up the node startup process.
pull/5309/head
Erik Grinaker 4 years ago
committed by GitHub
parent
commit
49efd44faa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions
  1. +2
    -0
      CHANGELOG_PENDING.md
  2. +4
    -3
      node/node.go

+ 2
- 0
CHANGELOG_PENDING.md View File

@ -20,3 +20,5 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi
## BUG FIXES
- [blockchain] \#5249 Fix fast sync halt with initial height > 1 (@erikgrinaker)
- [statesync] \#5302 Fix genesis state propagation to state sync routine (@erikgrinaker)

+ 4
- 3
node/node.go View File

@ -193,6 +193,7 @@ type Node struct {
stateSync bool // whether the node should state sync on startup
stateSyncReactor *statesync.Reactor // for hosting and restoring state sync snapshots
stateSyncProvider statesync.StateProvider // provides state data for bootstrapping a node
stateSyncGenesis sm.State // provides the genesis state for state sync
consensusState *cs.State // latest consensus state
consensusReactor *cs.Reactor // for participating in the consensus
pexReactor *pex.Reactor // for exchanging peer addresses
@ -558,10 +559,9 @@ func createPEXReactorAndAddToSwitch(addrBook pex.AddrBook, config *cfg.Config,
// startStateSync starts an asynchronous state sync process, then switches to fast sync mode.
func startStateSync(ssR *statesync.Reactor, bcR fastSyncReactor, conR *cs.Reactor,
stateProvider statesync.StateProvider, config *cfg.StateSyncConfig, fastSync bool,
stateDB dbm.DB, blockStore *store.BlockStore) error {
stateDB dbm.DB, blockStore *store.BlockStore, state sm.State) error {
ssR.Logger.Info("Starting state sync")
state := sm.LoadState(stateDB)
if stateProvider == nil {
var err error
stateProvider, err = statesync.NewLightClientStateProvider(
@ -813,6 +813,7 @@ func NewNode(config *cfg.Config,
consensusReactor: consensusReactor,
stateSyncReactor: stateSyncReactor,
stateSync: stateSync,
stateSyncGenesis: state, // Shouldn't be necessary, but need a way to pass the genesis state
pexReactor: pexReactor,
evidencePool: evidencePool,
proxyApp: proxyApp,
@ -893,7 +894,7 @@ func (n *Node) OnStart() error {
return fmt.Errorf("this blockchain reactor does not support switching from state sync")
}
err := startStateSync(n.stateSyncReactor, bcR, n.consensusReactor, n.stateSyncProvider,
n.config.StateSync, n.config.FastSyncMode, n.stateDB, n.blockStore)
n.config.StateSync, n.config.FastSyncMode, n.stateDB, n.blockStore, n.stateSyncGenesis)
if err != nil {
return fmt.Errorf("failed to start state sync: %w", err)
}


Loading…
Cancel
Save