Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dot/sync): include block origin and skip extra validation on initialSync #3392

Merged
merged 144 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
f3eb2eb
wip: implementing a poc around warp sync
EclesioMeloJunior Mar 30, 2023
d7c07ef
chore: include informative logs to debug sync
EclesioMeloJunior Apr 6, 2023
428ff13
chore: enable state trace logs and improve error for unfinalized ance…
EclesioMeloJunior Apr 11, 2023
25b30d5
wip: handle workers results
EclesioMeloJunior Apr 13, 2023
d05fdec
wip: handling workers results
EclesioMeloJunior Apr 13, 2023
6e272a6
chore: start ignoring peers + use `idleTicker` to check the pool
EclesioMeloJunior Apr 14, 2023
39dd7c3
fix: use buffered channel for taskQueue + wip: implementing tip sync
EclesioMeloJunior Apr 15, 2023
fc081e1
chore: enable state/grandpa/digest trace to investigate forced changes
EclesioMeloJunior Apr 17, 2023
7bc8038
chore: making changes to handling forced changes
EclesioMeloJunior Apr 18, 2023
0a27158
chore: reset scheduled changes once a forced change applies
EclesioMeloJunior Apr 18, 2023
bf6bb61
chore: rollback basepath
EclesioMeloJunior Apr 19, 2023
59cbaae
chore: wip tip sync
EclesioMeloJunior Apr 19, 2023
f9ca5a4
wip: tip sync impl
EclesioMeloJunior Apr 24, 2023
f9d7e43
chore: complete tip sync adjusts
EclesioMeloJunior Apr 26, 2023
3ba7e4c
chore: rollback modification on .yml files
EclesioMeloJunior Apr 26, 2023
16e8ee6
chore: rollback modifications to digest pkg
EclesioMeloJunior Apr 26, 2023
3eba164
chore: rollback modification to network pkg
EclesioMeloJunior Apr 26, 2023
c30948a
chore: rollback modifications to auth set changes
EclesioMeloJunior Apr 26, 2023
57f433c
chore: remove `internal/sync` pkg
EclesioMeloJunior Apr 26, 2023
a76c0e9
chore: remove unneeded comments
EclesioMeloJunior Apr 26, 2023
0bd8505
chore: remove unneeded fields from sync worker
EclesioMeloJunior Apr 27, 2023
5102e62
chore: remove dead code + add errors wrappers
EclesioMeloJunior Apr 27, 2023
c13b597
chore: address some points
EclesioMeloJunior Apr 27, 2023
f0c667f
chore: fix missing blocks in ascedingBlockRequests
EclesioMeloJunior May 2, 2023
f3cb072
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 2, 2023
2e640ce
chore: delete chainprocessor.go from merge with development
EclesioMeloJunior May 2, 2023
683e331
chore: impl wait/release while validating a worker result
EclesioMeloJunior May 3, 2023
b3d4c8e
wip: tip sync concurrency for bounded requests
EclesioMeloJunior May 5, 2023
c446fc0
wip: bounded requests without blocking the task queue listener
EclesioMeloJunior May 6, 2023
938d001
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 6, 2023
c8f47fa
chore: use versioned config data + enable traces
EclesioMeloJunior May 6, 2023
ce40f14
chore: remove state trace
EclesioMeloJunior May 6, 2023
e33c444
chore: revert changes from `westend-local-spec.json`
EclesioMeloJunior May 6, 2023
f00a242
chore: enable trace to `sync` and `digest`
EclesioMeloJunior May 6, 2023
6e3d2d0
chore: enable pprof to staging env
EclesioMeloJunior May 8, 2023
023df2c
chore: use `l.Lock()` instead of `l.RLock()`
EclesioMeloJunior May 8, 2023
0f661de
chore: change the worker_pool
EclesioMeloJunior May 8, 2023
924d172
chore: small fixes to the `executeRequest` method
EclesioMeloJunior May 9, 2023
6b481c1
chore: remove unneeded comment line + improve func name
EclesioMeloJunior May 9, 2023
539e092
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 18, 2023
9ae3fcb
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 19, 2023
35c9eea
chore: re-written `Test_chainSync_setBlockAnnounce` test
EclesioMeloJunior May 22, 2023
443045c
chore: include a bootstrap sync test with 2 workers
EclesioMeloJunior May 23, 2023
2432324
chore: testing successful sync with workers failing
EclesioMeloJunior May 24, 2023
5c7f983
chore: adjust mocks
EclesioMeloJunior May 24, 2023
17b03b7
chore: avoid ignoring peers whenever we failed to read response bytes
EclesioMeloJunior May 24, 2023
c9d16ce
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 25, 2023
0f69520
chore: add export comment to `AllConnectedPeers`
EclesioMeloJunior May 25, 2023
ae202b9
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior May 25, 2023
e780937
chore: improve readability + ignore peers management
EclesioMeloJunior May 29, 2023
4cd4fe5
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 29, 2023
ae8b367
chore: make the peer discovery everytime
EclesioMeloJunior May 29, 2023
e1b4bd4
chore: use a resource manager to autoscale outbound requests
EclesioMeloJunior May 30, 2023
a26b845
chore: remove `maxRequestsAllowed` restriction
EclesioMeloJunior May 30, 2023
e978240
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 30, 2023
90606ab
chore: remove unneeded deltas on westend chain
EclesioMeloJunior May 30, 2023
795e1b7
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior May 30, 2023
bc88064
chore: addressing comments
EclesioMeloJunior May 30, 2023
9ae5d5a
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 30, 2023
3103fdb
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior May 30, 2023
43ba321
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior May 30, 2023
0e33188
chore: reduce number of max peers
EclesioMeloJunior May 30, 2023
6982f2a
chore: make target number clear on `requesting_4_chunks_of_128_plus_3…
EclesioMeloJunior May 31, 2023
22f62d7
chore: remove unneeded `blockAnnounceCh`
EclesioMeloJunior May 31, 2023
35197c5
chore: reduce the amount of blocks synced at same time
EclesioMeloJunior Jun 1, 2023
576bb72
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jun 2, 2023
1b991b3
chore: merge development
EclesioMeloJunior Jun 5, 2023
c73789a
Merge branch 'development' into eclesio/fix-sync-speed
EclesioMeloJunior Jun 5, 2023
d9b5d19
chore: remove unneeded sync files
EclesioMeloJunior Jun 5, 2023
5bc45f9
EclesioMeloJunior Jun 6, 2023
5fb3070
chore: use highest finalized header instead of best block number
EclesioMeloJunior Jun 6, 2023
6ee8b4a
chore: using finalised header to bootstrap sync
EclesioMeloJunior Jun 6, 2023
c7e145b
chore: use a checkpoint header every time we failed to import blocks
EclesioMeloJunior Jun 6, 2023
a6086d6
chore: fix `all goroutines are asleep - deadlock` problem
EclesioMeloJunior Jun 7, 2023
19606f1
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jun 7, 2023
22699e8
chore: fix punishment
EclesioMeloJunior Jun 7, 2023
e0ea946
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jun 16, 2023
845e42e
chore: fix `executeBootstrapSync` tests
EclesioMeloJunior Jun 16, 2023
61c1a51
chore: revert libp2p resource manager additions
EclesioMeloJunior Jun 16, 2023
f415b90
chore: rename `AllConnectedPeers` to `AllConnectedPeersID`
EclesioMeloJunior Jun 16, 2023
fe132b4
chore: move `ErrReceivedEmptyMessage` to errors file
EclesioMeloJunior Jun 16, 2023
1df21a3
chore: rename `<-done` to `<-stop`
EclesioMeloJunior Jun 16, 2023
eeb5118
chore: create `TestSyncWorkerPool_useConnectedPeers` test
EclesioMeloJunior Jun 20, 2023
10dd486
chore: add methods comments
EclesioMeloJunior Jun 20, 2023
9d2b32d
chore: include `TestSyncWorkerPool_newPeer` test
EclesioMeloJunior Jun 20, 2023
e59228a
chore: rename `l` to `mtx`
EclesioMeloJunior Jun 20, 2023
3e7f420
chore: remove unneeded variable
EclesioMeloJunior Jun 20, 2023
1959231
chore: add `TestSyncWorkerPool__listenForRequests_submitRequest` test
EclesioMeloJunior Jun 20, 2023
4ea26dc
chore: add `TestSyncWorkerPool_listenForRequests_busyWorkers` test
EclesioMeloJunior Jun 20, 2023
a2d45d8
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jun 20, 2023
7fc622b
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jun 20, 2023
16de56f
chore: move request message creation to `network` pkg
EclesioMeloJunior Jun 20, 2023
51a78cf
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior Jun 20, 2023
3c2b14f
chore: fix tests to use `network.MaxBlockResponseSize`
EclesioMeloJunior Jun 20, 2023
beb7f8f
chore: fix lint warns
EclesioMeloJunior Jun 20, 2023
6d7d564
chore: adding license to `worker_pool_test.go`
EclesioMeloJunior Jun 20, 2023
4096823
chore: remove unneeded else branch
EclesioMeloJunior Jun 21, 2023
060dbc6
chore: fix deepsource warns
EclesioMeloJunior Jun 21, 2023
dc82d93
chore: wip `announced_block_while_in_tip_mode` test
EclesioMeloJunior Jun 21, 2023
057bacb
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jun 21, 2023
4a51be3
chore: add `announced_block_while_in_tip_mode` test
EclesioMeloJunior Jun 21, 2023
3d37f61
chore: add `TestChainSync_validateResponse` test
EclesioMeloJunior Jun 21, 2023
b09cdaa
chore: fix `validateBlockResponse` checks
EclesioMeloJunior Jun 21, 2023
1a56e6d
chore: solve all tests failures
EclesioMeloJunior Jun 22, 2023
0f43ae4
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior Jun 22, 2023
2836777
chore: move worker status update from `defer`
EclesioMeloJunior Jun 22, 2023
55ff3f8
chore: solve `lll` lint wanr
EclesioMeloJunior Jun 22, 2023
9ef76cf
chore: improve code coverage by testing failure scenarios
EclesioMeloJunior Jun 22, 2023
7037924
chore: request missing blocks
EclesioMeloJunior Jun 27, 2023
7bbebfd
chore: punish only if is a best block, ignore key not found
EclesioMeloJunior Jul 4, 2023
2a97b9b
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jul 5, 2023
83a553d
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jul 5, 2023
990b9c9
chore: add license
EclesioMeloJunior Jul 5, 2023
3c96c08
chore: remove unneeded nil check and fix `lll` lint warn
EclesioMeloJunior Jul 5, 2023
4047178
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior Jul 5, 2023
8d712ca
chore: fix `dot/sync` integration tests
EclesioMeloJunior Jul 5, 2023
22bb4cb
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jul 5, 2023
4a1905e
chore: fix `TestAscendingBlockRequest` test
EclesioMeloJunior Jul 5, 2023
fbaca64
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior Jul 5, 2023
9e2acb3
chore: fix `TestNewNode` test
EclesioMeloJunior Jul 6, 2023
1610978
chore: fix `TestStartStopNode` test
EclesioMeloJunior Jul 6, 2023
9f540b9
Merge branch 'development' into eclesio/fix-bootstrap-sync
EclesioMeloJunior Jul 6, 2023
bb6e4d7
chore: include `TestChainSync_BootstrapSync_SucessfulSync_ReceivedPar…
EclesioMeloJunior Jul 6, 2023
4741a28
Merge branch 'eclesio/fix-bootstrap-sync' of github.com:ChainSafe/gos…
EclesioMeloJunior Jul 6, 2023
e79f2b4
feat: include block origin in the sync pkg
EclesioMeloJunior Jul 6, 2023
d92e6ce
chore: include get target, remove unneeded print
EclesioMeloJunior Jul 10, 2023
3d21339
chore: wip
EclesioMeloJunior Jul 12, 2023
ef59819
chore: remove unneeded changes
EclesioMeloJunior Jul 19, 2023
fe27c9d
chore: remove unneeded changes
EclesioMeloJunior Jul 19, 2023
c2bdb93
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Aug 16, 2023
cb705fe
chore: address comments
EclesioMeloJunior Aug 16, 2023
de80302
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Aug 16, 2023
286819e
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Aug 17, 2023
ec7da00
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Aug 30, 2023
b67b014
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Sep 11, 2023
9efe2b1
chore: fix lint by adding `nolint:unparam`
EclesioMeloJunior Sep 11, 2023
c5749fa
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Nov 1, 2023
b144850
chore: address comments
EclesioMeloJunior Nov 1, 2023
cee24eb
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Nov 16, 2023
02d6efc
chore: introduce block origin to tests
EclesioMeloJunior Nov 16, 2023
8d812aa
chore: make `waitEnoughPeersAndTarget` a blocking function
EclesioMeloJunior Nov 17, 2023
189e3b3
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Nov 20, 2023
7950d87
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Nov 22, 2023
cfff017
Merge branch 'development' into eclesio/block-origin
EclesioMeloJunior Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 51 additions & 25 deletions dot/sync/chain_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ const (
tip
)

type blockOrigin byte

const (
networkInitialSync blockOrigin = iota
networkBroadcast
)
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved

func (s chainSyncState) String() string {
switch s {
case bootstrap:
Expand Down Expand Up @@ -126,6 +133,7 @@ type chainSync struct {
telemetry Telemetry
badBlocks []string
requestMaker network.RequestMaker
waitPeersDuration time.Duration
}

type chainSyncConfig struct {
Expand All @@ -142,6 +150,7 @@ type chainSyncConfig struct {
blockImportHandler BlockImportHandler
telemetry Telemetry
badBlocks []string
waitPeersDuration time.Duration
}

func newChainSync(cfg chainSyncConfig) *chainSync {
Expand All @@ -166,26 +175,40 @@ func newChainSync(cfg chainSyncConfig) *chainSync {
workerPool: newSyncWorkerPool(cfg.net, cfg.requestMaker),
badBlocks: cfg.badBlocks,
requestMaker: cfg.requestMaker,
waitPeersDuration: cfg.waitPeersDuration,
}
}

func (cs *chainSync) start() {
// since the default status from sync mode is syncMode(tip)
isSyncedGauge.Set(1)
func (cs *chainSync) waitEnoughPeersAndTarget() {
waitPeersTimer := time.NewTimer(cs.waitPeersDuration)

// wait until we have a minimal workers in the sync worker pool
for {
cs.workerPool.useConnectedPeers()
_, err := cs.getTarget()

totalAvailable := cs.workerPool.totalWorkers()
if totalAvailable >= uint(cs.minPeers) {
break
if totalAvailable >= uint(cs.minPeers) && err == nil {
return
}

// TODO: https://github.com/ChainSafe/gossamer/issues/3402
time.Sleep(time.Second)
EclesioMeloJunior marked this conversation as resolved.
Show resolved Hide resolved
select {
case <-waitPeersTimer.C:
waitPeersTimer.Reset(cs.waitPeersDuration)
case <-cs.stopCh:
return
}
}
}

func (cs *chainSync) start() {
// since the default status from sync mode is syncMode(tip)
isSyncedGauge.Set(1)

cs.wg.Add(1)
go cs.pendingBlocks.run(cs.finalisedCh, cs.stopCh, &cs.wg)

// wait until we have a minimal workers in the sync worker pool
cs.waitEnoughPeersAndTarget()
}

func (cs *chainSync) stop() error {
Expand Down Expand Up @@ -265,7 +288,7 @@ func (cs *chainSync) bootstrapSync() {

if isFarFromTarget {
cs.workerPool.useConnectedPeers()
err = cs.requestMaxBlocksFrom(bestBlockHeader)
err = cs.requestMaxBlocksFrom(bestBlockHeader, networkInitialSync)
if err != nil {
logger.Errorf("requesting max blocks from best block header: %s", err)
}
Expand Down Expand Up @@ -424,7 +447,7 @@ func (cs *chainSync) requestChainBlocks(announcedHeader, bestBlockHeader *types.

resultsQueue := make(chan *syncTaskResult)
cs.workerPool.submitRequest(request, &peerWhoAnnounced, resultsQueue)
err := cs.handleWorkersResults(resultsQueue, startAtBlock, totalBlocks)
err := cs.handleWorkersResults(resultsQueue, networkBroadcast, startAtBlock, totalBlocks)
if err != nil {
return fmt.Errorf("while handling workers results: %w", err)
}
Expand Down Expand Up @@ -462,7 +485,7 @@ func (cs *chainSync) requestForkBlocks(bestBlockHeader, highestFinalizedHeader,
resultsQueue := make(chan *syncTaskResult)
cs.workerPool.submitRequest(request, &peerWhoAnnounced, resultsQueue)

err = cs.handleWorkersResults(resultsQueue, startAtBlock, gapLength)
err = cs.handleWorkersResults(resultsQueue, networkBroadcast, startAtBlock, gapLength)
if err != nil {
return fmt.Errorf("while handling workers results: %w", err)
}
Expand Down Expand Up @@ -490,7 +513,7 @@ func (cs *chainSync) requestPendingBlocks(highestFinalizedHeader *types.Header)
}

if parentExists {
err := cs.handleReadyBlock(pendingBlock.toBlockData())
err := cs.handleReadyBlock(pendingBlock.toBlockData(), networkBroadcast)
if err != nil {
return fmt.Errorf("handling ready block: %w", err)
}
Expand All @@ -515,7 +538,7 @@ func (cs *chainSync) requestPendingBlocks(highestFinalizedHeader *types.Header)
// TODO: we should handle the requests concurrently
// a way of achieve that is by constructing a new `handleWorkersResults` for
// handling only tip sync requests
err = cs.handleWorkersResults(resultsQueue, startAtBlock, *descendingGapRequest.Max)
err = cs.handleWorkersResults(resultsQueue, networkBroadcast, startAtBlock, *descendingGapRequest.Max)
if err != nil {
return fmt.Errorf("while handling workers results: %w", err)
}
Expand All @@ -524,7 +547,7 @@ func (cs *chainSync) requestPendingBlocks(highestFinalizedHeader *types.Header)
return nil
}

func (cs *chainSync) requestMaxBlocksFrom(bestBlockHeader *types.Header) error {
func (cs *chainSync) requestMaxBlocksFrom(bestBlockHeader *types.Header, origin blockOrigin) error { //nolint:unparam
startRequestAt := bestBlockHeader.Number + 1

// targetBlockNumber is the virtual target we will request, however
Expand All @@ -551,7 +574,7 @@ func (cs *chainSync) requestMaxBlocksFrom(bestBlockHeader *types.Header) error {
}

resultsQueue := cs.workerPool.submitRequests(requests)
err = cs.handleWorkersResults(resultsQueue, startRequestAt, expectedAmountOfBlocks)
err = cs.handleWorkersResults(resultsQueue, origin, startRequestAt, expectedAmountOfBlocks)
if err != nil {
return fmt.Errorf("while handling workers results: %w", err)
}
Expand Down Expand Up @@ -589,7 +612,7 @@ func (cs *chainSync) getTarget() (uint, error) {
// in the queue and wait for it to completes
// TODO: handle only justification requests
func (cs *chainSync) handleWorkersResults(
workersResults chan *syncTaskResult, startAtBlock uint, expectedSyncedBlocks uint32) error {
workersResults chan *syncTaskResult, origin blockOrigin, startAtBlock uint, expectedSyncedBlocks uint32) error {

startTime := time.Now()
defer func() {
Expand Down Expand Up @@ -739,15 +762,15 @@ taskResultLoop:
// response was validated! place into ready block queue
for _, bd := range syncingChain {
// block is ready to be processed!
if err := cs.handleReadyBlock(bd); err != nil {
if err := cs.handleReadyBlock(bd, origin); err != nil {
return fmt.Errorf("while handling ready block: %w", err)
}
}

return nil
}

func (cs *chainSync) handleReadyBlock(bd *types.BlockData) error {
func (cs *chainSync) handleReadyBlock(bd *types.BlockData, origin blockOrigin) error {
// if header was not requested, get it from the pending set
// if we're expecting headers, validate should ensure we have a header
if bd.Header == nil {
Expand Down Expand Up @@ -779,7 +802,7 @@ func (cs *chainSync) handleReadyBlock(bd *types.BlockData) error {
bd.Header = block.header
}

err := cs.processBlockData(*bd)
err := cs.processBlockData(*bd, origin)
if err != nil {
// depending on the error, we might want to save this block for later
logger.Errorf("block data processing for block with hash %s failed: %s", bd.Hash, err)
Expand All @@ -793,7 +816,7 @@ func (cs *chainSync) handleReadyBlock(bd *types.BlockData) error {
// processBlockData processes the BlockData from a BlockResponse and
// returns the index of the last BlockData it handled on success,
// or the index of the block data that errored on failure.
func (cs *chainSync) processBlockData(blockData types.BlockData) error {
func (cs *chainSync) processBlockData(blockData types.BlockData, origin blockOrigin) error {
// while in bootstrap mode we don't need to broadcast block announcements
announceImportedBlock := cs.getSyncMode() == tip
var blockDataJustification []byte
Expand All @@ -808,7 +831,7 @@ func (cs *chainSync) processBlockData(blockData types.BlockData) error {
}

if blockData.Body != nil {
err = cs.processBlockDataWithHeaderAndBody(blockData, announceImportedBlock)
err = cs.processBlockDataWithHeaderAndBody(blockData, origin, announceImportedBlock)
if err != nil {
return fmt.Errorf("processing block data with header and body: %w", err)
}
Expand Down Expand Up @@ -842,10 +865,13 @@ func (cs *chainSync) verifyJustification(headerHash common.Hash, justification [
}

func (cs *chainSync) processBlockDataWithHeaderAndBody(blockData types.BlockData,
announceImportedBlock bool) (err error) {
err = cs.babeVerifier.VerifyBlock(blockData.Header)
if err != nil {
return fmt.Errorf("babe verifying block: %w", err)
origin blockOrigin, announceImportedBlock bool) (err error) {

if origin != networkInitialSync {
err = cs.babeVerifier.VerifyBlock(blockData.Header)
if err != nil {
return fmt.Errorf("babe verifying block: %w", err)
}
}

cs.handleBody(blockData.Body)
Expand Down
Loading
Loading