Skip to content

Commit b19c092

Browse files
committed
filter invalidly signed commitments at call site
only correctly signed commitments that equivocate should be reported. If the signature is invalid, we should skip the validator from the equivocation report and only report those who have validly signed the equivocation (i.e. if signature on vote is invalid not report it at all).
1 parent 20968b1 commit b19c092

File tree

1 file changed

+24
-3
lines changed
  • substrate/client/consensus/beefy/src/communication

1 file changed

+24
-3
lines changed

substrate/client/consensus/beefy/src/communication/fisherman.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ pub(crate) trait BeefyFisherman<B: Block>: Send + Sync {
4747
vote: VoteMessage<NumberFor<B>, AuthorityId, Signature>,
4848
) -> Result<(), Error>;
4949

50-
/// Check `signed_commitment` for contained block against canonical payload. If an equivocation is detected,
51-
/// this should also report it.
50+
/// Check `signed_commitment` for contained block against canonical payload. If an equivocation
51+
/// is detected, this should also report it.
5252
fn check_signed_commitment(
5353
&self,
5454
signed_commitment: SignedCommitment<NumberFor<B>, Signature>,
@@ -240,6 +240,14 @@ where
240240
vote: VoteMessage<NumberFor<B>, AuthorityId, Signature>,
241241
) -> Result<(), Error> {
242242
let number = vote.commitment.block_number;
243+
// if the vote's commitment has not been signed by the purported signer, we ignore it
244+
if !sp_consensus_beefy::check_commitment_signature(
245+
&vote.commitment,
246+
&vote.id,
247+
&vote.signature,
248+
) {
249+
return Ok(())
250+
};
243251
// if the vote is for a block number exceeding our best block number, there shouldn't even
244252
// be a payload to sign yet, hence we assume it is an equivocation and report it
245253
if number > self.backend.blockchain().info().best_number {
@@ -302,7 +310,20 @@ where
302310
.iter()
303311
.cloned()
304312
.zip(signatures.into_iter())
305-
.filter_map(|(id, signature)| signature.map(|sig| (id, sig)))
313+
.filter_map(|(id, signature)| match signature {
314+
Some(sig) =>
315+
if sp_consensus_beefy::check_commitment_signature::<
316+
_,
317+
_,
318+
BeefySignatureHasher,
319+
>(&commitment, &id, &sig)
320+
{
321+
Some((id, sig))
322+
} else {
323+
None
324+
},
325+
None => None,
326+
})
306327
.collect();
307328
if signatories.len() > 0 {
308329
let proof = ForkEquivocationProof {

0 commit comments

Comments
 (0)