Skip to content

Commit

Permalink
Remove ssv_types dependency on qbft (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacholme7 authored Jan 16, 2025
1 parent e967107 commit 71bdc41
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 61 deletions.
84 changes: 42 additions & 42 deletions 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 anchor/common/qbft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = { workspace = true }
[dependencies]
derive_more = { workspace = true }
indexmap = { workspace = true }
ssv_types = { workspace = true }
tracing = { workspace = true }

[dev-dependencies]
Expand Down
11 changes: 2 additions & 9 deletions anchor/common/qbft/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
pub use config::{Config, ConfigBuilder};
use std::cmp::Eq;
use std::collections::{HashMap, HashSet};
use std::fmt::Debug;
use std::hash::Hash;
use tracing::{debug, error, warn};
pub use validation::{validate_consensus_data, ValidatedData, ValidationError};

Expand All @@ -12,6 +9,8 @@ pub use types::{
Message, OperatorId, Round,
};

use ssv_types::message::Data;

mod config;
mod error;
mod types;
Expand All @@ -22,12 +21,6 @@ mod tests;

type RoundChangeMap<D> = HashMap<OperatorId, Option<ConsensusData<D>>>;

pub trait Data: Debug + Clone {
type Hash: Debug + Clone + Eq + Hash;

fn hash(&self) -> Self::Hash;
}

/// The structure that defines the Quorum Based Fault Tolerance (QBFT) instance.
///
/// This builds and runs an entire QBFT process until it completes. It can complete either
Expand Down
1 change: 0 additions & 1 deletion anchor/common/ssv_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ authors = ["Sigma Prime <contact@sigmaprime.io>"]
base64 = { workspace = true }
derive_more = { workspace = true }
openssl = { workspace = true }
qbft = { workspace = true }
rusqlite = { workspace = true }
tree_hash = { workspace = true }
tree_hash_derive = { workspace = true }
Expand Down
16 changes: 12 additions & 4 deletions anchor/common/ssv_types/src/message.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::msgid::MsgId;
use crate::{OperatorId, ValidatorIndex};
use std::fmt::Debug;
use std::hash::Hash;
use tree_hash::{PackedEncoding, TreeHash, TreeHashType};
use tree_hash_derive::TreeHash;
use types::typenum::U13;
Expand All @@ -12,6 +14,12 @@ use types::{
// it needs some work to actually serialize to the same stuff on wire, and I feel like we can name
// the fields better

pub trait Data: Debug + Clone {
type Hash: Debug + Clone + Eq + Hash;

fn hash(&self) -> Self::Hash;
}

#[derive(Clone, Debug)]
pub struct SignedSsvMessage<E: EthSpec> {
pub signatures: Vec<[u8; 256]>,
Expand All @@ -24,7 +32,7 @@ pub struct SignedSsvMessage<E: EthSpec> {
pub struct SsvMessage<E: EthSpec> {
pub msg_type: MsgType,
pub msg_id: MsgId,
pub data: Data<E>,
pub data: SsvData<E>,
}

#[derive(Clone, Debug)]
Expand All @@ -34,7 +42,7 @@ pub enum MsgType {
}

#[derive(Clone, Debug)]
pub enum Data<E: EthSpec> {
pub enum SsvData<E: EthSpec> {
QbftMessage(QbftMessage<E>),
PartialSignatureMessage(PartialSignatureMessage),
}
Expand Down Expand Up @@ -80,7 +88,7 @@ pub struct ValidatorConsensusData<E: EthSpec> {
pub data_ssz: Box<DataSsz<E>>,
}

impl<E: EthSpec> qbft::Data for ValidatorConsensusData<E> {
impl<E: EthSpec> Data for ValidatorConsensusData<E> {
type Hash = Hash256;

fn hash(&self) -> Self::Hash {
Expand Down Expand Up @@ -181,7 +189,7 @@ pub struct BeaconVote {
pub target: Checkpoint,
}

impl qbft::Data for BeaconVote {
impl Data for BeaconVote {
type Hash = Hash256;

fn hash(&self) -> Self::Hash {
Expand Down
Loading

0 comments on commit 71bdc41

Please sign in to comment.