mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Validator monitor support for sync committees (#2476)
## Issue Addressed N/A ## Proposed Changes Add functionality in the validator monitor to provide sync committee related metrics for monitored validators. Co-authored-by: Michael Sproul <michael@sigmaprime.io>
This commit is contained in:
@@ -5,8 +5,8 @@ use beacon_chain::sync_committee_verification::{
|
||||
Error as SyncVerificationError, VerifiedSyncCommitteeMessage,
|
||||
};
|
||||
use beacon_chain::{
|
||||
BeaconChain, BeaconChainError, BeaconChainTypes, StateSkipConfig,
|
||||
MAXIMUM_GOSSIP_CLOCK_DISPARITY,
|
||||
validator_monitor::timestamp_now, BeaconChain, BeaconChainError, BeaconChainTypes,
|
||||
StateSkipConfig, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
|
||||
};
|
||||
use eth2::types::{self as api_types};
|
||||
use eth2_libp2p::PubsubMessage;
|
||||
@@ -130,6 +130,8 @@ pub fn process_sync_committee_signatures<T: BeaconChainTypes>(
|
||||
) -> Result<(), warp::reject::Rejection> {
|
||||
let mut failures = vec![];
|
||||
|
||||
let seen_timestamp = timestamp_now();
|
||||
|
||||
for (i, sync_committee_signature) in sync_committee_signatures.iter().enumerate() {
|
||||
let subnet_positions = match get_subnet_positions_for_sync_committee_message(
|
||||
sync_committee_signature,
|
||||
@@ -168,6 +170,16 @@ pub fn process_sync_committee_signatures<T: BeaconChainTypes>(
|
||||
))),
|
||||
)?;
|
||||
|
||||
// Register with validator monitor
|
||||
chain
|
||||
.validator_monitor
|
||||
.read()
|
||||
.register_api_sync_committee_message(
|
||||
seen_timestamp,
|
||||
verified.sync_message(),
|
||||
&chain.slot_clock,
|
||||
);
|
||||
|
||||
verified_for_pool = Some(verified);
|
||||
}
|
||||
Err(e) => {
|
||||
@@ -231,6 +243,8 @@ pub fn process_signed_contribution_and_proofs<T: BeaconChainTypes>(
|
||||
let mut verified_contributions = Vec::with_capacity(signed_contribution_and_proofs.len());
|
||||
let mut failures = vec![];
|
||||
|
||||
let seen_timestamp = timestamp_now();
|
||||
|
||||
// Verify contributions & broadcast to the network.
|
||||
for (index, contribution) in signed_contribution_and_proofs.into_iter().enumerate() {
|
||||
let aggregator_index = contribution.message.aggregator_index;
|
||||
@@ -246,7 +260,17 @@ pub fn process_signed_contribution_and_proofs<T: BeaconChainTypes>(
|
||||
)),
|
||||
)?;
|
||||
|
||||
// FIXME(altair): notify validator monitor
|
||||
// Register with validator monitor
|
||||
chain
|
||||
.validator_monitor
|
||||
.read()
|
||||
.register_api_sync_committee_contribution(
|
||||
seen_timestamp,
|
||||
verified_contribution.aggregate(),
|
||||
verified_contribution.participant_pubkeys(),
|
||||
&chain.slot_clock,
|
||||
);
|
||||
|
||||
verified_contributions.push((index, verified_contribution));
|
||||
}
|
||||
// If we already know the contribution, don't broadcast it or attempt to
|
||||
|
||||
@@ -27,7 +27,7 @@ fn end_of_epoch_state<T: BeaconChainTypes>(
|
||||
fn get_epoch_processing_summary<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<EpochProcessingSummary, warp::reject::Rejection> {
|
||||
) -> Result<EpochProcessingSummary<T>, warp::reject::Rejection> {
|
||||
process_epoch(state, spec)
|
||||
.map_err(|e| warp_utils::reject::custom_server_error(format!("{:?}", e)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user