blocksync: fixed issues after merge

This commit is contained in:
Jasmina Malicevic
2022-05-11 17:03:25 +02:00
parent 6e125e3ea7
commit 4af43afe6d
3 changed files with 12 additions and 7 deletions
+1 -1
View File
@@ -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
+7 -4
View File
@@ -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++
+4 -2
View File
@@ -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