Skip to content

Commit

Permalink
SignedSSVMessage and SSVMessage validation
Browse files Browse the repository at this point in the history
  • Loading branch information
diegomrsantos committed Feb 25, 2025
1 parent 8d2ae13 commit cf10d55
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 139 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ serde = { version = "1.0.208", features = ["derive"] }
serde_yaml = "0.9"
sha2 = "0.10.8"
strum = { version = "0.26.3", features = ["derive"] }
thiserror = "2.0.11"
tokio = { version = "1.39.2", features = [
"rt",
"rt-multi-thread",
Expand Down
6 changes: 0 additions & 6 deletions anchor/common/qbft/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,6 @@ where
&self,
wrapped_msg: &WrappedQbftMessage,
) -> Option<(Option<ValidData<D>>, OperatorId)> {
// Validate the wrapped message. This will validate the SignedSsvMessage and the QbftMessage
if !wrapped_msg.validate() {
warn!("Message validation unsuccessful");
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
7 changes: 0 additions & 7 deletions anchor/common/qbft/src/qbft_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ pub struct WrappedQbftMessage {
pub qbft_message: QbftMessage,
}

impl WrappedQbftMessage {
// Validate that the message is well formed
pub fn validate(&self) -> bool {
self.signed_message.validate() && self.qbft_message.validate()
}
}

/// This represents an individual round, these change on regular time intervals
#[derive(Clone, Copy, Debug, Deref, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Round(NonZeroUsize);
Expand Down
2 changes: 1 addition & 1 deletion anchor/common/qbft/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn convert_unsigned_to_wrapped(
) -> WrappedQbftMessage {
// Create a signed message containing just this operator
let signed_message = SignedSSVMessage::new(
vec![vec![0; 96]], // Test signature of 96 bytes
vec![vec![0; 256]],
vec![OperatorId(*operator_id)],
msg.ssv_message.clone(),
msg.full_data,
Expand Down
1 change: 1 addition & 0 deletions anchor/common/ssv_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ sha2 = { workspace = true }
tree_hash = { workspace = true }
tree_hash_derive = { workspace = true }
types = { workspace = true }
thiserror = { workspace = true }
10 changes: 0 additions & 10 deletions anchor/common/ssv_types/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,6 @@ 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
Loading

0 comments on commit cf10d55

Please sign in to comment.