From a62c886a8605d4b0035aa114147513fb6062f529 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Fri, 27 Aug 2021 15:06:47 +0200 Subject: [PATCH] clean up initial height bug --- internal/statesync/reactor.go | 35 ++++++++++++++++++----------------- node/node.go | 4 +--- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/internal/statesync/reactor.go b/internal/statesync/reactor.go index 9967f33c3..85aedbe29 100644 --- a/internal/statesync/reactor.go +++ b/internal/statesync/reactor.go @@ -178,22 +178,23 @@ func NewReactor( tempDir string, ) *Reactor { r := &Reactor{ - chainID: chainID, - cfg: cfg, - conn: conn, - connQuery: connQuery, - snapshotCh: snapshotCh, - chunkCh: chunkCh, - blockCh: blockCh, - paramsCh: paramsCh, - peerUpdates: peerUpdates, - closeCh: make(chan struct{}), - tempDir: tempDir, - stateStore: stateStore, - blockStore: blockStore, - peers: newPeerList(), - dispatcher: NewDispatcher(blockCh.Out, lightBlockResponseTimeout), - providers: make(map[types.NodeID]*BlockProvider), + chainID: chainID, + initialHeight: initialHeight, + cfg: cfg, + conn: conn, + connQuery: connQuery, + snapshotCh: snapshotCh, + chunkCh: chunkCh, + blockCh: blockCh, + paramsCh: paramsCh, + peerUpdates: peerUpdates, + closeCh: make(chan struct{}), + tempDir: tempDir, + stateStore: stateStore, + blockStore: blockStore, + peers: newPeerList(), + dispatcher: NewDispatcher(blockCh.Out, lightBlockResponseTimeout), + providers: make(map[types.NodeID]*BlockProvider), } r.BaseService = *service.NewBaseService(logger, "StateSync", r) @@ -346,7 +347,7 @@ func (r *Reactor) backfill( stopTime time.Time, ) error { r.Logger.Info("starting backfill process...", "startHeight", startHeight, - "stopHeight", stopHeight, "trustedBlockID", trustedBlockID) + "stopHeight", stopHeight, "stopTime", stopTime, "trustedBlockID", trustedBlockID) const sleepTime = 1 * time.Second var ( diff --git a/node/node.go b/node/node.go index ebc6fcbd9..461766b86 100644 --- a/node/node.go +++ b/node/node.go @@ -687,11 +687,9 @@ func (n *nodeImpl) OnStart() error { return fmt.Errorf("unable to derive state: %w", err) } - n.Logger.Info("starting state sync...") - // TODO: we may want to move these events within the respective // reactors. - // at the beginning of the statesync start, we use the initialHeight as the event height + // At the beginning of the statesync start, we use the initialHeight as the event height // because of the statesync doesn't have the concreate state height before fetched the snapshot. d := types.EventDataStateSyncStatus{Complete: false, Height: state.InitialHeight} if err := n.eventBus.PublishEventStateSyncStatus(d); err != nil {