Add debug logging

This commit is contained in:
Tan Chee Keong
2025-03-27 14:35:12 +08:00
parent b21451fc11
commit 7ac6867c5b
2 changed files with 24 additions and 17 deletions

View File

@@ -13,6 +13,7 @@ use ssz_types::typenum::Unsigned;
use std::cmp; use std::cmp;
#[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone, Serialize, Deserialize)] #[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone, Serialize, Deserialize)]
#[serde(transparent)]
pub struct SyncSelectionProof(Signature); pub struct SyncSelectionProof(Signature);
impl SyncSelectionProof { impl SyncSelectionProof {

View File

@@ -568,8 +568,17 @@ pub async fn fill_in_aggregation_proofs<T: SlotClock + 'static, E: EthSpec>(
validator_index: duty.validator_index, validator_index: duty.validator_index,
slot: proof_slot, slot: proof_slot,
subcommittee_index: subnet_id, subcommittee_index: subnet_id,
selection_proof: proof.into(), selection_proof: proof.clone().into(),
}; };
// Add log for debugging
debug!(
log,
"Partial sync selection proof";
"validator_index" => duty.validator_index,
"slot" => proof_slot,
"subcommittee_index" => subnet_id,
"partial selection proof" => ?proof,
);
Some(sync_committee_selection) Some(sync_committee_selection)
} }
Err(ValidatorStoreError::UnknownPubkey(pubkey)) => { Err(ValidatorStoreError::UnknownPubkey(pubkey)) => {
@@ -647,13 +656,10 @@ pub async fn fill_in_aggregation_proofs<T: SlotClock + 'static, E: EthSpec>(
let validators = committee_duties.validators.read(); let validators = committee_duties.validators.read();
// Process each response // Process each response
for (i, selection_response) in response.data.iter().enumerate() { for selection_response in response.data.iter() {
if i >= valid_results.len() { let validator_index = selection_response.validator_index;
break; let slot = selection_response.slot;
} let subcommittee_index = selection_response.subcommittee_index;
let selection = &valid_results[i];
let subnet_id = SyncSubnetId::new(selection.subcommittee_index);
// Convert the response to a SyncSelectionProof // Convert the response to a SyncSelectionProof
let proof = SyncSelectionProof::from( let proof = SyncSelectionProof::from(
@@ -663,22 +669,22 @@ pub async fn fill_in_aggregation_proofs<T: SlotClock + 'static, E: EthSpec>(
// Check if the validator is an aggregator // Check if the validator is an aggregator
match proof.is_aggregator::<E>() { match proof.is_aggregator::<E>() {
Ok(true) => { Ok(true) => {
if let Some(Some(duty)) = if let Some(Some(duty)) = validators.get(&validator_index) {
validators.get(&selection.validator_index)
{
debug!( debug!(
log, log,
"Validator is sync aggregator"; "Validator is sync aggregator";
"validator_index" => selection.validator_index, "validator_index" => validator_index,
"slot" => selection.slot, "slot" => slot,
"subnet_id" => %subnet_id, "subnet_id" => subcommittee_index,
// log full selection proof for debugging
"full selection proof" => ?proof,
); );
// Store the proof // Store the proof
duty.aggregation_duties duty.aggregation_duties
.proofs .proofs
.write() .write()
.insert((selection.slot, subnet_id), proof); .insert((slot, subcommittee_index.into()), proof);
} }
} }
Ok(false) => { Ok(false) => {
@@ -688,8 +694,8 @@ pub async fn fill_in_aggregation_proofs<T: SlotClock + 'static, E: EthSpec>(
warn!( warn!(
log, log,
"Error determining is_aggregator"; "Error determining is_aggregator";
"validator_index" => selection.validator_index, "validator_index" => validator_index,
"slot" => selection.slot, "slot" => slot,
"error" => ?e, "error" => ?e,
); );
} }