Skip to content

Commit

Permalink
consensus/bor: handle unauthorized signer in consensus.Prepare (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
manav2401 authored Feb 16, 2023
1 parent d7ac762 commit 9ce8c7d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions consensus/bor/bor.go
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,13 @@ func (c *Bor) Prepare(chain consensus.ChainHeaderReader, header *types.Header) e

currentSigner := *c.authorizedSigner.Load()

// Bail out early if we're unauthorized to sign a block. This check also takes
// place before block is signed in `Seal`.
if !snap.ValidatorSet.HasAddress(currentSigner.signer) {
// Check the UnauthorizedSignerError.Error() msg to see why we pass number-1
return &UnauthorizedSignerError{number - 1, currentSigner.signer.Bytes()}
}

// Set the correct difficulty
header.Difficulty = new(big.Int).SetUint64(Difficulty(snap.ValidatorSet, currentSigner.signer))

Expand Down

0 comments on commit 9ce8c7d

Please sign in to comment.