Skip to content

Commit

Permalink
Blockchain: Clique-recently-signed False Positive Fix (#1931)
Browse files Browse the repository at this point in the history
* Blockchain: fixed a bug in Clique-related recently signed check to only compare on recently signed counts if block numbers are consecutive
* Update packages/blockchain/src/index.ts
Co-authored-by: Ryan Ghods <ryan@ryanio.com>
  • Loading branch information
holgerd77 authored Jun 2, 2022
1 parent 5e266ff commit 3e4e7be
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/blockchain/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ export default class Blockchain implements BlockchainInterface {
// construct recent block signers list with this block
let signers = this._cliqueLatestBlockSigners
signers = signers.slice(signers.length < limit ? 0 : 1)
if (signers.length > 0 && !signers[signers.length - 1][0].eq(header.number.subn(1))) {
// if the last signed block is not one minus the head we are trying to compare
// we do not have a complete picture of the state to verify if too recently signed
return false
}
signers.push([header.number, header.cliqueSigner()])
const seen = signers.filter((s) => s[1].equals(header.cliqueSigner())).length
return seen > 1
Expand Down

0 comments on commit 3e4e7be

Please sign in to comment.