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