Verify sig every 100 blocks during state sync

pull/1626/head
Rongjian Lan 5 years ago
parent 9f65d99b78
commit 9be5b9e163
  1. 11
      api/service/syncing/syncing.go

@ -546,9 +546,18 @@ func (ss *StateSync) updateBlockAndStatus(block *types.Block, bc *core.BlockChai
// Verify block signatures
// TODO chao: only when block is verified against last commit sigs, we can update the block and status
if block.NumberU64() > 1 {
err := bc.Engine().VerifyHeader(bc, block.Header(), true)
verifySig := false
if block.NumberU64()%100 == 0 {
// Verify signature every 100 blocks
verifySig = true
}
err := bc.Engine().VerifyHeader(bc, block.Header(), verifySig)
if err != nil {
utils.Logger().Error().Err(err).Msgf("[SYNC] failed verifying signatures for new block %d", block.NumberU64())
utils.Logger().Debug().Interface("block", bc.CurrentBlock()).Msg("[SYNC] Rolling back last 99 blocks!")
for i := 0; i < 99; i++ {
bc.Rollback([]common.Hash{bc.CurrentBlock().Hash()})
}
return false
}
}

Loading…
Cancel
Save