debugging

This commit is contained in:
Eitan Seri-Levi
2025-02-15 12:14:58 +02:00
parent 7eb040c70e
commit cdbdb5226d
23 changed files with 252 additions and 157 deletions

View File

@@ -13,7 +13,7 @@ use beacon_node_fallback::{ApiTopic, BeaconNodeFallback};
use doppelganger_service::DoppelgangerStatus;
use environment::RuntimeContext;
use eth2::types::{
AttesterData, BeaconCommitteeSubscription, DutiesResponse, InclusionListDutyData, ProposerData,
AttesterData, BeaconCommitteeSubscription, DutiesResponse, InclusionListDuty, ProposerData,
StateId, ValidatorId,
};
use futures::{stream, StreamExt};
@@ -207,7 +207,7 @@ type DependentRoot = Hash256;
type AttesterMap = HashMap<PublicKeyBytes, HashMap<Epoch, (DependentRoot, DutyAndProof)>>;
type ProposerMap = HashMap<Epoch, (DependentRoot, Vec<ProposerData>)>;
type InclusionListDutiesMap =
HashMap<PublicKeyBytes, HashMap<Epoch, (DependentRoot, InclusionListDutyData)>>;
HashMap<PublicKeyBytes, HashMap<Epoch, (DependentRoot, InclusionListDuty)>>;
/// See the module-level documentation.
pub struct DutiesService<T, E: EthSpec> {
@@ -334,8 +334,8 @@ impl<T: SlotClock + 'static, E: EthSpec> DutiesService<T, E> {
.collect()
}
/// Returns all `InclusionListDutyData` for the given `slot`.
pub fn inclusion_list_duties(&self, slot: Slot) -> Vec<InclusionListDutyData> {
/// Returns all `InclusionListDuty` for the given `slot`.
pub fn inclusion_list_duties(&self, slot: Slot) -> Vec<InclusionListDuty> {
let epoch = slot.epoch(E::slots_per_epoch());
if !self.spec.is_focil_enabled_for_epoch(epoch) {
@@ -1370,7 +1370,7 @@ async fn poll_beacon_inclusion_list_duties_for_epoch<T: SlotClock + 'static, E:
return Ok(());
}
// TODO: add fetch metric
// TODO(focil): add fetch metric
// Request duties for all uninitialized validators. If there isn't any, we will just request for
// `INITIAL_DUTIES_QUERY_SIZE` validators. We use the `dependent_root` in the response to
@@ -1387,6 +1387,12 @@ async fn poll_beacon_inclusion_list_duties_for_epoch<T: SlotClock + 'static, E:
let response =
post_validator_duties_inclusion_list(duties_service, epoch, initial_indices_to_request)
.await?;
debug!(
log,
"inclusion list duties";
"count" => response.data.len(),
);
let dependent_root = response.dependent_root;
// Find any validators which have conflicting (epoch, dependent_root) values or missing duties for the epoch.
@@ -1443,7 +1449,7 @@ async fn poll_beacon_inclusion_list_duties_for_epoch<T: SlotClock + 'static, E:
"num_new_duties" => new_duties.len(),
);
// Update the duties service with the new `InclusionListDutyData` messages.
// Update the duties service with the new `InclusionListDuty` messages.
let mut inclusion_list_duties = duties_service.inclusion_list_duties.write();
// TODO(focil) this variable is unused at the moment
let _current_slot = duties_service
@@ -1490,7 +1496,7 @@ async fn post_validator_duties_inclusion_list<T: SlotClock + 'static, E: EthSpec
duties_service: &Arc<DutiesService<T, E>>,
epoch: Epoch,
validator_indices: &[u64],
) -> Result<DutiesResponse<Vec<InclusionListDutyData>>, Error> {
) -> Result<DutiesResponse<Vec<InclusionListDuty>>, Error> {
duties_service
.beacon_nodes
.first_success(|beacon_node| async move {

View File

@@ -1,14 +1,13 @@
use crate::duties_service::DutiesService;
use beacon_node_fallback::{ApiTopic, BeaconNodeFallback};
use environment::RuntimeContext;
use eth2::types::InclusionListDutyData;
use futures::future::join_all;
use slog::{crit, error, info, trace, warn};
use slog::{crit, debug, error, info, trace, warn};
use slot_clock::SlotClock;
use std::ops::Deref;
use std::sync::Arc;
use tokio::time::{sleep, Duration};
use types::{ChainSpec, EthSpec, Slot};
use types::{ChainSpec, EthSpec, InclusionList, InclusionListDuty, Slot};
use validator_store::{Error as ValidatorStoreError, ValidatorStore};
/// Helper to minimise `Arc` usage.
@@ -118,9 +117,18 @@ impl<T: SlotClock + 'static, E: EthSpec> InclusionListService<T, E> {
_slot_duration: Duration,
spec: &ChainSpec,
) -> Result<(), String> {
debug!(
self.context.log(),
"Spawning inclusion list task";
);
let next_slot = self.slot_clock.now().ok_or("Failed to read slot clock")? + 1;
if !spec.is_focil_enabled_for_epoch(next_slot.epoch(E::slots_per_epoch())) {
debug!(
self.context.log(),
"FOCIL not enabled";
);
return Ok(());
}
@@ -153,7 +161,7 @@ impl<T: SlotClock + 'static, E: EthSpec> InclusionListService<T, E> {
async fn produce_and_publish_inclusion_lists(
self,
slot: Slot,
validator_duties: Vec<InclusionListDutyData>,
validator_duties: Vec<InclusionListDuty>,
) -> Result<(), ()> {
let log = self.context.log();
let validator_store = self.validator_store.clone();
@@ -178,12 +186,12 @@ impl<T: SlotClock + 'static, E: EthSpec> InclusionListService<T, E> {
)
})?;
let inclusion_list = self
let inclusion_list_transactions = self
.beacon_nodes
.first_success(|beacon_node| async move {
// TODO(focil) add timer metric
beacon_node
.get_validator_inclusion_list(slot)
.get_validator_inclusion_list::<E>(slot)
.await
.map_err(|e| format!("Failed to produce inclusion list: {:?}", e))
.map(|result| result.ok_or("Inclusion list unavailable".to_string()))?
@@ -201,6 +209,12 @@ impl<T: SlotClock + 'static, E: EthSpec> InclusionListService<T, E> {
// Create futures to produce signed `InclusionList` objects.
let signing_futures = validator_duties.iter().map(|duty| {
let inclusion_list = InclusionList {
slot,
transactions: inclusion_list_transactions.clone(),
inclusion_list_committee_root: duty.committee_root,
validator_index: duty.validator_index,
};
let inclusion_list = inclusion_list.clone();
let validator_store = Arc::clone(&validator_store);
async move {