Skip to content

Commit

Permalink
fix:handle empty block punish logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mindcarver committed Sep 14, 2023
1 parent 7c10cff commit e220b48
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
18 changes: 7 additions & 11 deletions consensus/istanbul/ibft/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,19 +1106,15 @@ func (e *Engine) pickEvilValidatorsV2(bc *core.BlockChain, ea *types.EvilAction)
return totalSigners
}

if canonicalHeader.Coinbase == (common.Address{}) {
log.Info("the standard block is an empty block and will not be processed", "height", canonicalNo)
return totalSigners
}

canonicalSigners, err := e.Signers(canonicalHeader)
if err != nil {
log.Error("failed to recover block signers", "height", canonicalNo)
return totalSigners
if canonicalHeader.Coinbase != (common.Address{}) {
canonicalSigners, err := e.Signers(canonicalHeader)
if err != nil {
log.Error("failed to recover block signers", "height", canonicalNo)
return totalSigners
}
totalSigners = append(totalSigners, canonicalSigners...)
}

totalSigners = append(totalSigners, canonicalSigners...)

for _, header := range ea.EvilHeaders {
log.Info("pickEvilValidators", "evil-no", header.Number.Uint64(), "evil-hash", header.Hash().Hex())
signers, err := e.Signers(header)
Expand Down
4 changes: 0 additions & 4 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1346,10 +1346,6 @@ func (s *PublicBlockChainAPI) GetPunishedInfo(ctx context.Context, number rpc.Bl
return nil, errors.New("invalid block number")
}

if canonicalHeader.Coinbase == (common.Address{}) {
return nil, nil
}

return pickEvilValidatorsV2(ctx, canonicalHeader, evilAction, engine)
}

Expand Down

0 comments on commit e220b48

Please sign in to comment.