diff --git a/engine/verification/requester/requester.go b/engine/verification/requester/requester.go index 468a5980bb3..9854c8a5039 100644 --- a/engine/verification/requester/requester.go +++ b/engine/verification/requester/requester.go @@ -7,6 +7,7 @@ import ( "github.com/opentracing/opentracing-go" "github.com/rs/zerolog" + "github.com/rs/zerolog/log" "golang.org/x/exp/rand" "github.com/onflow/flow-go/engine" @@ -48,6 +49,7 @@ type Engine struct { unit *engine.Unit state protocol.State // used to check the last sealed height. con network.Conduit // used to send the chunk data request, and receive the response. + net module.Network // monitoring tracer module.Tracer @@ -86,14 +88,9 @@ func New(log zerolog.Logger, pendingRequests: pendingRequests, reqUpdaterFunc: reqUpdaterFunc, reqQualifierFunc: reqQualifierFunc, + net: net, } - con, err := net.Register(engine.RequestChunks, e) - if err != nil { - return nil, fmt.Errorf("could not register chunk data pack provider engine: %w", err) - } - e.con = con - return e, nil } @@ -134,10 +131,19 @@ func (e *Engine) Process(originID flow.Identifier, event interface{}) error { // Ready initializes the engine and returns a channel that is closed when the initialization is done. func (e *Engine) Ready() <-chan struct{} { if e.handler == nil { + // we should crash the node with fatal-level log if handler is missing e.log.Fatal().Msg("could not start requester engine with missing chunk data pack handler") } + con, err := e.net.Register(engine.RequestChunks, e) + if err != nil { + // we should crash the node with fatal-level log if network module is missing + log.Fatal().Err(err).Msg("could not register requester engine on network") + } + e.con = con + delay := time.Duration(0) + // run a periodic check to retry requesting chunk data packs. // if onTimer takes longer than retryInterval, the next call will be blocked until the previous // call has finished.