From 4af43afe6d3caf2628f06a9a349a87c3cdaca192 Mon Sep 17 00:00:00 2001 From: Jasmina Malicevic Date: Wed, 11 May 2022 17:03:25 +0200 Subject: [PATCH] blocksync: fixed issues after merge --- internal/blocksync/pool.go | 2 +- internal/blocksync/reactor.go | 11 +++++++---- internal/blocksync/verify.go | 6 ++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/blocksync/pool.go b/internal/blocksync/pool.go index c6b4dfd17..ba1be8a39 100644 --- a/internal/blocksync/pool.go +++ b/internal/blocksync/pool.go @@ -690,7 +690,7 @@ OUTER_LOOP: } peer = wreq.pool.pickIncrAvailableWitness(wreq.height) if peer == nil { - time.Sleep(requestIntervalMS * time.Millisecond) + time.Sleep(requestInterval * time.Millisecond) continue PICK_PEER_LOOP } break PICK_PEER_LOOP diff --git a/internal/blocksync/reactor.go b/internal/blocksync/reactor.go index 07903cb2c..8b3ca4413 100644 --- a/internal/blocksync/reactor.go +++ b/internal/blocksync/reactor.go @@ -638,11 +638,11 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh } continue // was return previously } - - } - if err := r.verifyWithWitnesses(newBlock); err != nil { - r.logger.Debug("Witness verificatio nfailed") + r.lastTrustedBlock = &BlockResponse{} } + // if err := r.verifyWithWitnesses(newBlock); err != nil { + // r.logger.Debug("Witness verificatio nfailed") + // } var err error // validate the block before we persist it err = r.blockExec.ValidateBlock(ctx, state, newBlock) @@ -678,6 +678,9 @@ func (r *Reactor) poolRoutine(ctx context.Context, stateSynced bool, blockSyncCh panic(fmt.Sprintf("failed to process committed block (%d:%X): %v", newBlock.Height, newBlock.Hash(), err)) } + r.lastTrustedBlock.block = newBlock + r.lastTrustedBlock.commit = r.store.LoadSeenCommit() + r.metrics.RecordConsMetrics(newBlock) blocksSynced++ diff --git a/internal/blocksync/verify.go b/internal/blocksync/verify.go index fdfc3c98a..23db253d6 100644 --- a/internal/blocksync/verify.go +++ b/internal/blocksync/verify.go @@ -87,8 +87,10 @@ func VerifyNextBlock(newBlock *types.Block, newBlockID types.BlockID, verifyBloc // If the blockID in LastCommit of NewBlock does not match the trusted block // we can assume NewBlock is not correct - if !(newBlock.LastCommit.BlockID.Equals(trustedCommit.BlockID)) { - return ErrBlockIDDiff{} + if trustedCommit != nil { + if !(newBlock.LastCommit.BlockID.Equals(trustedCommit.BlockID)) { + return ErrBlockIDDiff{} + } } // Todo: Verify verifyBlock.LastCommit validators against state.NextValidators