Skip to content

Commit

Permalink
add back qbft_message validation
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Feb 26, 2025
1 parent e09372d commit ca76591
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions anchor/common/qbft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ where
&self,
wrapped_msg: &WrappedQbftMessage,
) -> Option<(Option<ValidData<D>>, OperatorId)> {
// Validate the qbft message
if !wrapped_msg.qbft_message.validate() {
warn!("Invalid qbft_message");
return None;
}

// Ensure that this message is for the correct round
let current_round = self.current_round.get();
if (wrapped_msg.qbft_message.round < current_round as u64)
Expand Down
10 changes: 10 additions & 0 deletions anchor/common/ssv_types/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ pub struct QbftMessage {
pub prepare_justification: Vec<SignedSSVMessage>, // always without full_data
}

impl QbftMessage {
/// Do QBFTMessage specific validation
pub fn validate(&self) -> bool {
if self.qbft_message_type > QbftMessageType::RoundChange {
return false;
}
true
}
}

/// Different states the QBFT Message may represent
#[derive(Clone, Debug, PartialEq, PartialOrd, Copy)]
pub enum QbftMessageType {
Expand Down

0 comments on commit ca76591

Please sign in to comment.