@@ -14,6 +14,7 @@ import (
1414 "github.com/onflow/flow-go/model/flow"
1515 "github.com/onflow/flow-go/model/messages"
1616 "github.com/onflow/flow-go/module"
17+ "github.com/onflow/flow-go/module/compliance"
1718 "github.com/onflow/flow-go/module/component"
1819 "github.com/onflow/flow-go/module/irrecoverable"
1920 "github.com/onflow/flow-go/module/metrics"
@@ -31,6 +32,13 @@ func WithChannel(channel channels.Channel) EngineOption {
3132 }
3233}
3334
35+ // WithComplianceConfigOpt applies compliance config opt to internal config
36+ func WithComplianceConfigOpt (opt compliance.Opt ) EngineOption {
37+ return func (e * Engine ) {
38+ opt (& e .config )
39+ }
40+ }
41+
3442// defaultBatchProcessingWorkers number of concurrent workers that process incoming blocks.
3543const defaultBatchProcessingWorkers = 4
3644
@@ -57,6 +65,7 @@ type Engine struct {
5765 me module.Local
5866 engMetrics module.EngineMetrics
5967 con network.Conduit
68+ config compliance.Config
6069 channel channels.Channel
6170 headers storage.Headers
6271 pendingBlocks * fifoqueue.FifoQueue // queue for processing inbound batches of blocks
@@ -90,6 +99,7 @@ func New(
9099 log : log .With ().Str ("engine" , "follower" ).Logger (),
91100 me : me ,
92101 engMetrics : engMetrics ,
102+ config : compliance .DefaultConfig (),
93103 channel : channels .ReceiveBlocks ,
94104 pendingBlocks : pendingBlocks ,
95105 pendingBlocksNotifier : engine .NewNotifier (),
@@ -276,6 +286,13 @@ func (e *Engine) submitConnectedBatch(log zerolog.Logger, latestFinalizedView ui
276286 log .Debug ().Msgf ("dropping range [%d, %d] below finalized view %d" , blocks [0 ].Header .View , lastBlock .View , latestFinalizedView )
277287 return
278288 }
289+ if lastBlock .View > latestFinalizedView + e .config .SkipNewProposalsThreshold {
290+ log .Debug ().
291+ Uint64 ("skip_new_proposals_threshold" , e .config .SkipNewProposalsThreshold ).
292+ Msgf ("dropping range [%d, %d] too far ahead of locally finalized view %d" ,
293+ blocks [0 ].Header .View , lastBlock .View , latestFinalizedView )
294+ return
295+ }
279296 log .Debug ().Msgf ("submitting sub-range with views [%d, %d] for further processing" , blocks [0 ].Header .View , lastBlock .View )
280297
281298 select {
0 commit comments