Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions anchor/message_validator/src/consensus_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ pub(crate) fn validate_consensus_message_semantics(
});
}

validate_justifications(consensus_message, operator_pub_keys)?;
validate_justifications(consensus_message, operator_pub_keys, true)?;

Ok(())
}

pub(crate) fn validate_justifications(
consensus_message: &QbftMessage,
operator_pub_keys: &HashMap<OperatorId, Rsa<Public>>,
check_inner_justifications: bool,
) -> Result<(), ValidationFailure> {
// Rule: Can only exist for Proposal messages
let prepare_justifications = &consensus_message.prepare_justification;
Expand All @@ -172,7 +173,17 @@ pub(crate) fn validate_justifications(
.iter()
.chain(round_change_justifications.iter())
.try_for_each(|signed_message| {
verify_message_signatures(signed_message, operator_pub_keys)
verify_message_signatures(signed_message, operator_pub_keys)?;
// Also check the justifications' justifications
if check_inner_justifications {
validate_justifications(
&QbftMessage::from_ssz_bytes(signed_message.ssv_message().data())
.map_err(|_| ValidationFailure::MalformedJustifications)?,
operator_pub_keys,
false,
)?;
}
Ok(())
})?;

Ok(())
Expand Down
3 changes: 1 addition & 2 deletions anchor/message_validator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,8 @@ pub enum ValidationFailure {
want: usize,
},
DifferentProposalData,
MalformedPrepareJustifications,
MalformedJustifications,
UnexpectedPrepareJustifications,
MalformedRoundChangeJustifications,
UnexpectedRoundChangeJustifications,
NoPartialSignatureMessages,
NoValidators,
Expand Down
Loading