Skip to content

Commit

Permalink
type rework
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacholme7 committed Dec 19, 2024
1 parent de5be8d commit 69652e7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
34 changes: 19 additions & 15 deletions anchor/common/ssv_types/src/cluster.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,42 @@
use crate::OperatorId;
use crate::Share;
use derive_more::{Deref, From};
use std::collections::HashSet;
use std::collections::HashMap;
use types::{Address, Graffiti, PublicKey};

/// Unique identifier for a cluster
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, From, Deref)]
pub struct ClusterId(pub u64);

/// A Cluster is a group of Operators that are acting on behalf of a Validator
/// A Cluster is a group of Operators that are acting on behalf of one or more Validators
///
/// Each cluster is owned by a unqiue EOA and only that Address may perform operators on the
/// Cluster.
#[derive(Debug, Clone)]
pub struct Cluster {
/// Unique identifier for a Cluster
pub cluster_id: ClusterId,
/// All of the members of this Cluster
pub cluster_members: Vec<ClusterMember>,
/// The owner of the cluster and all of the validators
pub owner: Address,
/// The Eth1 fee address for all validators in the cluster
pub fee_recipient: Address,
/// The number of faulty operator in the Cluster
pub faulty: u64,
/// If the Cluster is liquidated or active
pub liquidated: bool,
/// Metadata about the validator this committee represents
pub validator_metadata: ValidatorMetadata,
/// Operators in this cluster
pub cluster_members: HashSet<OperatorId>,
}

/// A member of a Cluster. This is just an Operator that holds onto a share of the Validator key
/// A member of a Cluster.
/// This is an Operator that holds a piece of the keyshare for each validator in the cluster
#[derive(Debug, Clone)]
pub struct ClusterMember {
/// Unique identifier for the Operator this member represents
pub operator_id: OperatorId,
/// Unique identifier for the Cluster this member is a part of
pub cluster_id: ClusterId,
/// The Share this member is responsible for
pub share: Share,
}

/// Index of the validator in the validator registry.
Expand All @@ -40,14 +46,12 @@ pub struct ValidatorIndex(pub usize);
/// General Metadata about a Validator
#[derive(Debug, Clone)]
pub struct ValidatorMetadata {
/// Index of the validator
pub validator_index: ValidatorIndex,
/// Public key of the validator
pub validator_pubkey: PublicKey,
/// Eth1 fee address
pub fee_recipient: Address,
pub public_key: PublicKey,
/// The cluster that is responsible for this validator
pub cluster_id: ClusterId,
/// Index of the validator
pub index: ValidatorIndex,
/// Graffiti
pub graffiti: Graffiti,
/// The owner of the validator
pub owner: Address,
}
5 changes: 5 additions & 0 deletions anchor/common/ssv_types/src/share.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
use crate::{ClusterId, OperatorId};
use types::PublicKey;

/// One of N shares of a split validator key.
#[derive(Debug, Clone)]
pub struct Share {
/// Operator this share belongs to
pub operator_id: OperatorId,
/// Cluster the operator who owns this share belongs to
pub cluster_id: ClusterId,
/// The public key of this Share
pub share_pubkey: PublicKey,
/// The encrypted private key of the share
Expand Down

0 comments on commit 69652e7

Please sign in to comment.