Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 26 additions & 19 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ members = [
"anchor/common/ssv_types",
"anchor/common/version",
"anchor/database",
"anchor/duties_tracker",
"anchor/eth",
"anchor/fuzz",
"anchor/http_api",
Expand All @@ -25,7 +26,6 @@ members = [
"anchor/signature_collector",
"anchor/subnet_tracker",
"anchor/validator_store",
"anchor/voluntary_exit",
]

resolver = "2"
Expand All @@ -40,6 +40,7 @@ api_types = { path = "anchor/common/api_types" }
bls_lagrange = { path = "anchor/common/bls_lagrange" }
client = { path = "anchor/client" }
database = { path = "anchor/database" }
duties_tracker = { path = "anchor/duties_tracker" }
eth = { path = "anchor/eth" }
http_api = { path = "anchor/http_api" }
http_metrics = { path = "anchor/http_metrics" }
Expand All @@ -58,7 +59,6 @@ ssv_network_config = { path = "anchor/common/ssv_network_config" }
ssv_types = { path = "anchor/common/ssv_types" }
subnet_tracker = { path = "anchor/subnet_tracker" }
version = { path = "anchor/common/version" }
voluntary_exit = { path = "anchor/voluntary_exit" }

beacon_node_fallback = { git = "https://github.com/sigp/lighthouse", rev = "2c153d7e" }
bls = { git = "https://github.com/sigp/lighthouse", rev = "2c153d7e" }
Expand Down
2 changes: 1 addition & 1 deletion anchor/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ beacon_node_fallback = { workspace = true }
clap = { workspace = true }
database = { workspace = true }
dirs = { workspace = true }
duties_tracker = { workspace = true }
eth = { workspace = true }
eth2 = { workspace = true }
ethereum_hashing = "0.7.0"
Expand Down Expand Up @@ -50,5 +51,4 @@ unused_port = { workspace = true }
validator_metrics = { workspace = true }
validator_services = { workspace = true }
version = { workspace = true }
voluntary_exit = { workspace = true }
zeroize = { workspace = true }
11 changes: 6 additions & 5 deletions anchor/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ use beacon_node_fallback::{
pub use cli::Node;
use config::Config;
use database::NetworkDatabase;
use eth::index_sync::start_validator_index_syncer;
use duties_tracker::{duties_tracker::DutiesTracker, voluntary_exit_tracker::VoluntaryExitTracker};
use eth::{
index_sync::start_validator_index_syncer, voluntary_exit_processor::start_exit_processor,
};
use eth2::{
BeaconNodeHttpClient, Timeouts,
reqwest::{Certificate, ClientBuilder},
};
use keygen::{Keygen, encryption::decrypt, run_keygen};
use message_receiver::NetworkMessageReceiver;
use message_sender::{MessageSender, NetworkMessageSender, impostor::ImpostorMessageSender};
use message_validator::{DutiesTracker, Validator};
use message_validator::Validator;
use network::Network;
use openssl::{pkey::Private, rsa::Rsa};
use parking_lot::RwLock;
Expand Down Expand Up @@ -57,9 +60,6 @@ use validator_services::{
preparation_service::PreparationServiceBuilder,
sync_committee_service::SyncCommitteeService,
};
use voluntary_exit::{
voluntary_exit_processor::start_exit_processor, voluntary_exit_tracker::VoluntaryExitTracker,
};
use zeroize::Zeroizing;

/// The filename within the `validators` directory that contains the slashing protection DB.
Expand Down Expand Up @@ -396,6 +396,7 @@ impl Client {
let (network_tx, network_rx) = mpsc::channel::<(SubnetId, Vec<u8>)>(9001);

let duties_tracker = Arc::new(DutiesTracker::new(
voluntary_exit_tracker.clone(),
beacon_nodes.clone(),
spec.clone(),
E::slots_per_epoch(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
[package]
name = "voluntary_exit"
name = "duties_tracker"
version = "0.1.0"
edition = { workspace = true }
authors = ["Sigma Prime <contact@sigmaprime.io>"]

[dependencies]
anchor_validator_store = { workspace = true }
beacon_node_fallback = { workspace = true }
bls = { workspace = true }
dashmap = { workspace = true }
database = { workspace = true }
eth2 = { workspace = true }
parking_lot = { workspace = true }
safe_arith = { workspace = true }
slot_clock = { workspace = true }
ssv_types = { workspace = true }
task_executor = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
types = { workspace = true }
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{future::Future, sync::Arc};

use beacon_node_fallback::BeaconNodeFallback;
use bls::PublicKeyBytes;
use database::NetworkState;
use safe_arith::ArithError;
use slot_clock::SlotClock;
Expand All @@ -11,7 +12,7 @@ use tokio::{sync::watch, time::sleep};
use tracing::{debug, error, info, trace, warn};
use types::{ChainSpec, Epoch, Slot};

use crate::duties::{Duties, DutiesProvider};
use crate::{Duties, DutiesProvider, voluntary_exit_tracker::VoluntaryExitTracker};

/// Only retain `HISTORICAL_DUTIES_EPOCHS` duties prior to the current epoch.
const HISTORICAL_DUTIES_EPOCHS: u64 = 2;
Expand All @@ -29,6 +30,8 @@ pub enum Error {
pub struct DutiesTracker<T: SlotClock + 'static> {
/// Duties data structures
duties: Duties,
/// The voluntary exit tracker
voluntary_exit_tracker: Arc<VoluntaryExitTracker>,
/// The beacon node fallback clients
beacon_nodes: Arc<BeaconNodeFallback<T>>,
/// The chain spec
Expand All @@ -43,6 +46,7 @@ pub struct DutiesTracker<T: SlotClock + 'static> {

impl<T: SlotClock + 'static> DutiesTracker<T> {
pub fn new(
voluntary_exit_tracker: Arc<VoluntaryExitTracker>,
beacon_nodes: Arc<BeaconNodeFallback<T>>,
spec: Arc<ChainSpec>,
slots_per_epoch: u64,
Expand All @@ -51,6 +55,7 @@ impl<T: SlotClock + 'static> DutiesTracker<T> {
) -> Self {
Self {
duties: Duties::new(),
voluntary_exit_tracker,
beacon_nodes,
spec,
slots_per_epoch,
Expand Down Expand Up @@ -331,6 +336,10 @@ impl<T: SlotClock + 'static> DutiesProvider for DutiesTracker<T> {
})
.unwrap_or_default()
}

fn get_voluntary_exit_duty_count(&self, slot: Slot, pubkey: &PublicKeyBytes) -> u64 {
self.voluntary_exit_tracker.get_duty_count(slot, pubkey)
}
}

/// Number of epochs to wait from the start of the period before actually fetching duties.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::collections::{HashMap, HashSet};

use bls::PublicKeyBytes;
use dashmap::DashMap;
use eth2::types::ProposerData;
use parking_lot::RwLock;
use ssv_types::ValidatorIndex;
use types::{Epoch, Slot};

pub mod duties_tracker;
pub mod voluntary_exit_tracker;

/// Top-level data-structure containing sync duty information.
///
Expand Down Expand Up @@ -100,4 +102,6 @@ pub trait DutiesProvider: Sync + Send + 'static {
fn is_epoch_known_for_proposers(&self, epoch: Epoch) -> bool;

fn is_validator_proposer_at_slot(&self, slot: Slot, validator_index: ValidatorIndex) -> bool;

fn get_voluntary_exit_duty_count(&self, slot: Slot, pubkey: &PublicKeyBytes) -> u64;
}
3 changes: 2 additions & 1 deletion anchor/eth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ authors = ["Sigma Prime <contact@sigmaprime.io>"]

[dependencies]
alloy = { workspace = true }
anchor_validator_store = { workspace = true }
beacon_node_fallback = { workspace = true }
database = { workspace = true }
duties_tracker = { workspace = true }
eth2 = { workspace = true }
fastrand = "2.3.0"
futures = { workspace = true }
Expand All @@ -24,4 +26,3 @@ tokio = { workspace = true }
tower = "0.5.2"
tracing = { workspace = true }
types = { workspace = true }
voluntary_exit = { workspace = true }
7 changes: 5 additions & 2 deletions anchor/eth/src/event_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ use eth2::types::PublicKeyBytes;
use indexmap::IndexSet;
use ssv_types::{Cluster, ClusterId, Operator, OperatorId, ValidatorIndex};
use tracing::{debug, error, info, instrument, trace, warn};
use voluntary_exit::voluntary_exit_processor::{ExitRequest, ExitTx};

use crate::{
error::ExecutionError, event_parser::EventDecoder, generated::SSVContract, index_sync, metrics,
error::ExecutionError,
event_parser::EventDecoder,
generated::SSVContract,
index_sync, metrics,
util::*,
voluntary_exit_processor::{ExitRequest, ExitTx},
};

/// Configures event processing behaviour.
Expand Down
2 changes: 2 additions & 0 deletions anchor/eth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ mod metrics;
mod network_actions;
mod sync;
mod util;
pub mod voluntary_exit_processor;
pub use metrics::EXECUTION_EVENTS_PROCESSED;
2 changes: 1 addition & 1 deletion anchor/eth/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ use sensitive_url::SensitiveUrl;
use ssv_network_config::SsvNetworkConfig;
use tokio::{sync::oneshot::Sender, time::Duration};
use tracing::{debug, error, info, instrument, warn};
use voluntary_exit::voluntary_exit_processor::ExitTx;

use crate::{
error::ExecutionError,
event_processor::{EventProcessor, Mode},
generated::SSVContract,
index_sync, metrics,
util::http_with_timeout_and_fallback,
voluntary_exit_processor::ExitTx,
};

/// SSV contract events needed to come up to date with the network
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{sync::Arc, time::Duration};

use anchor_validator_store::AnchorValidatorStore;
use beacon_node_fallback::BeaconNodeFallback;
use duties_tracker::voluntary_exit_tracker::{ExitDuty, VoluntaryExitTracker};
use slot_clock::SlotClock;
use ssv_types::ValidatorIndex;
use task_executor::TaskExecutor;
Expand All @@ -12,7 +13,7 @@ use tokio::{
use tracing::{debug, error, info};
use types::{EthSpec, PublicKeyBytes, voluntary_exit};

use crate::voluntary_exit_tracker::{ExitDuty, VoluntaryExitTracker};
use crate::EXECUTION_EVENTS_PROCESSED;

// Message type for exit requests
pub struct ExitRequest {
Expand Down Expand Up @@ -230,10 +231,7 @@ async fn process_single_exit<E: EthSpec, T: SlotClock + 'static>(
validator_pubkey = %validator_pubkey,
"Successfully submitted voluntary exit to beacon node"
);
// metrics::inc_counter_vec(
// &metrics::EXECUTION_EVENTS_PROCESSED,
// &["validator_exited"],
// );
metrics::inc_counter_vec(&EXECUTION_EVENTS_PROCESSED, &["validator_exited"]);
true // Exit processed successfully
}
Err(e) => {
Expand Down
5 changes: 5 additions & 0 deletions anchor/fuzz/fuzz_targets/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
time::Duration,
};

use bls::PublicKeyBytes;
use database::NetworkDatabase;
use message_receiver::{NetworkMessageReceiver, Outcome};
use message_sender::{MessageSender, NetworkMessageSender};
Expand Down Expand Up @@ -44,6 +45,10 @@ impl DutiesProvider for MockDutiesProvider {
fn is_validator_proposer_at_slot(&self, _slot: Slot, _validator_index: ValidatorIndex) -> bool {
true
}

fn get_voluntary_exit_duty_count(&self, _slot: Slot, _pubkey: &PublicKeyBytes) -> u64 {
0
}
}

type MessageQueue = Arc<Mutex<VecDeque<(OperatorId, UnsignedWrappedQbftMessage)>>>;
Expand Down
1 change: 1 addition & 0 deletions anchor/message_validator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ beacon_node_fallback = { workspace = true }
bls = { workspace = true }
dashmap = { workspace = true }
database = { workspace = true }
duties_tracker = { workspace = true }
eth2 = { workspace = true }
ethereum_ssz = { workspace = true }
gossipsub = { workspace = true }
Expand Down
Loading
Loading