Skip to content

Commit

Permalink
format and sort
Browse files Browse the repository at this point in the history
  • Loading branch information
dknopik committed Feb 18, 2025
1 parent 87a4a50 commit 6c60b16
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
8 changes: 6 additions & 2 deletions anchor/common/ssv_types/src/cluster.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::committee::CommitteeId;
use crate::OperatorId;
use derive_more::{Deref, From};
use indexmap::IndexSet;
use ssz_derive::{Decode, Encode};
use types::{Address, Graffiti, PublicKeyBytes};
use crate::committee::CommitteeId;

/// Unique identifier for a cluster
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, From, Deref)]
Expand Down Expand Up @@ -39,7 +39,11 @@ impl Cluster {
}

pub fn committee_id(&self) -> CommitteeId {
self.cluster_members.iter().cloned().collect::<Vec<_>>().into()
self.cluster_members
.iter()
.cloned()
.collect::<Vec<_>>()
.into()
}
}

Expand Down
2 changes: 1 addition & 1 deletion anchor/common/ssv_types/src/committee.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::OperatorId;
use alloy::primitives::keccak256;
use derive_more::{Deref, From};
use crate::OperatorId;

const COMMITTEE_ID_LEN: usize = 32;

Expand Down
18 changes: 11 additions & 7 deletions anchor/common/ssv_types/src/msgid.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use derive_more::From;
use crate::committee::CommitteeId;
use crate::domain_type::DomainType;
use derive_more::From;
use ssz::{Decode, DecodeError, Encode};
use types::PublicKeyBytes;

Expand Down Expand Up @@ -54,8 +54,12 @@ impl MessageId {
id[0..4].copy_from_slice(&domain.0);
id[4..8].copy_from_slice(&<[u8; 4]>::from(role));
match duty_executor {
DutyExecutor::Committee(committee_id) => id[24..].copy_from_slice(committee_id.as_slice()),
DutyExecutor::Validator(public_key) => id[8..].copy_from_slice(public_key.as_serialized()),
DutyExecutor::Committee(committee_id) => {
id[24..].copy_from_slice(committee_id.as_slice())
}
DutyExecutor::Validator(public_key) => {
id[8..].copy_from_slice(public_key.as_serialized())
}
}

MessageId(id)
Expand All @@ -76,11 +80,11 @@ impl MessageId {
pub fn duty_executor(&self) -> Option<DutyExecutor> {
// which kind of executor we need to get depends on the role
match self.role()? {
Role::Committee => {
self.0[24..].try_into().ok().map(DutyExecutor::Committee)
}
Role::Committee => self.0[24..].try_into().ok().map(DutyExecutor::Committee),
Role::Aggregator | Role::Proposer | Role::SyncCommittee => {
PublicKeyBytes::deserialize(&self.0[8..]).ok().map(DutyExecutor::Validator)
PublicKeyBytes::deserialize(&self.0[8..])
.ok()
.map(DutyExecutor::Validator)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion anchor/common/ssv_types/src/partial_sig.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{OperatorId, ValidatorIndex};
use ssz::{Decode, DecodeError, Encode};
use ssz_derive::{Decode, Encode};
use types::{Hash256, Signature, Slot};
use crate::{OperatorId, ValidatorIndex};

#[derive(Clone, Copy, Debug)]
pub enum PartialSignatureKind {
Expand Down
4 changes: 2 additions & 2 deletions anchor/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ libp2p = { version = "0.54", default-features = false, features = [
"request-response",
] }
lighthouse_network = { workspace = true }
qbft_manager = { workspace = true }
quick-protobuf = "0.8.1"
serde = { workspace = true }
serde_json = "1.0.137"
ssv_types = { workspace = true }
qbft_manager = { workspace = true }
signature_collector = { workspace = true }
slot_clock = { workspace = true }
ssv_types = { workspace = true }
ssz_types = "0.8"
subnet_tracker = { workspace = true }
task_executor = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion anchor/qbft_manager/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use processor::Senders;
use slot_clock::{ManualSlotClock, SlotClock};
use ssv_types::consensus::{BeaconVote, QbftMessage, QbftMessageType};
use ssv_types::message::SignedSSVMessage;
use ssv_types::{Cluster, committee::CommitteeId, OperatorId, ClusterId};
use ssv_types::{committee::CommitteeId, Cluster, ClusterId, OperatorId};
use ssz::Decode;
use std::collections::HashMap;
use std::sync::LazyLock;
Expand Down
8 changes: 2 additions & 6 deletions anchor/subnet_tracker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use alloy::primitives::ruint::aliases::U256;
use database::{NetworkState, UniqueIndex};
use log::warn;
use serde::{Deserialize, Serialize};
use ssv_types::committee::CommitteeId;
use ssv_types::Cluster;
use std::collections::HashSet;
use std::ops::Deref;
Expand All @@ -10,7 +11,6 @@ use task_executor::TaskExecutor;
use tokio::sync::{mpsc, watch};
use tokio::time::sleep;
use tracing::debug;
use ssv_types::committee::CommitteeId;

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(transparent)]
Expand Down Expand Up @@ -121,11 +121,7 @@ async fn subnet_tracker(
}

fn get_committee_id(cluster: &Cluster) -> U256 {
let operator_ids = cluster
.cluster_members
.iter()
.cloned()
.collect::<Vec<_>>();
let operator_ids = cluster.cluster_members.iter().cloned().collect::<Vec<_>>();
let id = CommitteeId::from(operator_ids);
U256::from_be_bytes(*id)
}
Expand Down

0 comments on commit 6c60b16

Please sign in to comment.