Skip to content

Commit

Permalink
Use TendermintProposal for internal sorting of DoubleProposalProof
Browse files Browse the repository at this point in the history
This means that two different `TendermintProposal`s with the same
`MacroHeader` are now also considered a violation.
  • Loading branch information
hrxi committed Nov 11, 2024
1 parent 5d80816 commit 771ec53
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions primitives/block/src/equivocation_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ impl DoubleProposalProof {
mut proposal2: TendermintProposal<MacroHeader>,
mut justification2: SchnorrSignature,
) -> DoubleProposalProof {
let hash1: Blake2bHash = proposal1.proposal.hash();
let hash2: Blake2bHash = proposal2.proposal.hash();
let hash1: Blake2sHash = proposal1.hash();
let hash2: Blake2sHash = proposal2.hash();
if hash1 > hash2 {
mem::swap(&mut proposal1, &mut proposal2);
mem::swap(&mut justification1, &mut justification2);
Expand Down Expand Up @@ -388,8 +388,8 @@ impl DoubleProposalProof {
&self,
signing_key: &SchnorrPublicKey,
) -> Result<(), EquivocationProofError> {
let hash1: Blake2bHash = self.proposal1.proposal.hash();
let hash2: Blake2bHash = self.proposal2.proposal.hash();
let hash1: Blake2sHash = self.proposal1.hash();
let hash2: Blake2sHash = self.proposal2.hash();

// Check that the headers are not equal and in the right order:
match hash1.cmp(&hash2) {
Expand All @@ -410,8 +410,8 @@ impl DoubleProposalProof {
}

// Check that the justifications are valid.
if !signing_key.verify(&self.justification1, self.proposal1.hash().as_slice())
|| !signing_key.verify(&self.justification2, self.proposal2.hash().as_slice())
if !signing_key.verify(&self.justification1, hash1.as_slice())
|| !signing_key.verify(&self.justification2, hash2.as_slice())
{
return Err(EquivocationProofError::InvalidJustification);
}
Expand Down

0 comments on commit 771ec53

Please sign in to comment.