66 "sync"
77 "time"
88
9+ cfg "github.com/cometbft/cometbft/config"
910 "github.com/cometbft/cometbft/crypto"
1011 "github.com/cometbft/cometbft/libs/log"
1112 "github.com/cometbft/cometbft/libs/trace"
@@ -64,6 +65,7 @@ type Reactor struct {
6465 traceClient trace.Tracer
6566 blockSync bool
6667 localAddr crypto.Address
68+ config * cfg.BlockSyncConfig
6769 poolRoutineWg sync.WaitGroup
6870
6971 requestsCh <- chan BlockRequest
@@ -78,13 +80,17 @@ type Reactor struct {
7880func NewReactor (state sm.State , blockExec * sm.BlockExecutor , store * store.BlockStore ,
7981 blockSync bool , metrics * Metrics , offlineStateSyncHeight int64 ,
8082) * Reactor {
81- return NewReactorWithAddr (state , blockExec , store , blockSync , nil , metrics , offlineStateSyncHeight , trace .NoOpTracer ())
83+ return NewReactorWithAddr (state , blockExec , store , blockSync , nil , metrics , offlineStateSyncHeight , trace .NoOpTracer (), nil )
8284}
8385
8486// Function added to keep existing API.
8587func NewReactorWithAddr (state sm.State , blockExec * sm.BlockExecutor , store * store.BlockStore ,
86- blockSync bool , localAddr crypto.Address , metrics * Metrics , offlineStateSyncHeight int64 , traceClient trace.Tracer ,
88+ blockSync bool , localAddr crypto.Address , metrics * Metrics , offlineStateSyncHeight int64 , traceClient trace.Tracer , config * cfg. BlockSyncConfig ,
8789) * Reactor {
90+ // Use default config if nil
91+ if config == nil {
92+ config = cfg .DefaultBlockSyncConfig ()
93+ }
8894
8995 storeHeight := store .Height ()
9096 if storeHeight == 0 {
@@ -121,6 +127,7 @@ func NewReactorWithAddr(state sm.State, blockExec *sm.BlockExecutor, store *stor
121127 pool : pool ,
122128 blockSync : blockSync ,
123129 localAddr : localAddr ,
130+ config : config ,
124131 requestsCh : requestsCh ,
125132 errorsCh : errorsCh ,
126133 metrics : metrics ,
@@ -514,7 +521,7 @@ FOR_LOOP:
514521 err = bcR .blockExec .ValidateBlock (state , first )
515522 }
516523
517- if err == nil {
524+ if err == nil && bcR . config . VerifyDataRoot {
518525 var stateMachineValid bool
519526 // Block sync doesn't check that the `Data` in a block is valid.
520527 // Since celestia-core can't determine if the `Data` in a block
0 commit comments