From 4a78fda997012696930def5d0161705aee0c0422 Mon Sep 17 00:00:00 2001 From: Tumas Date: Wed, 15 May 2024 12:24:56 +0300 Subject: [PATCH] add debug info --- validator/src/validator.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/validator/src/validator.rs b/validator/src/validator.rs index 8134bec..672d022 100644 --- a/validator/src/validator.rs +++ b/validator/src/validator.rs @@ -115,7 +115,8 @@ use types::{ }, preset::Preset, traits::{ - BeaconState as _, PostAltairBeaconState, PostBellatrixBeaconState, SignedBeaconBlock as _, + BeaconState as BeaconStateTrait, PostAltairBeaconState, PostBellatrixBeaconState, + SignedBeaconBlock as _, }, }; @@ -1270,10 +1271,12 @@ impl Validator { .filter_map(|attestation| convert_to_electra_attestation(attestation).ok()) .group_by(|attestation| attestation.data); + let state = slot_head.beacon_state.as_ref(); + let attestations = attestations .into_iter() .filter_map(|(_, attestations)| { - Self::compute_on_chain_aggregate(attestations).ok() + Self::compute_on_chain_aggregate(state, attestations).ok() }) .take(P::MaxAttestationsElectra::USIZE); @@ -1348,8 +1351,11 @@ impl Validator { } pub fn compute_on_chain_aggregate( + state: &impl BeaconStateTrait

, attestations: impl Iterator>, ) -> Result> { + log::info!("COMPUTE ON CHAIN AGGREGTES"); + let aggregates = attestations .sorted_by_key(|attestation| { misc::get_committee_indices::

(attestation.committee_bits).next() @@ -1371,6 +1377,26 @@ impl Validator { let mut signature = AggregateSignature::default(); for aggregate in aggregates { + let committee_indices = misc::get_committee_indices::

(aggregate.committee_bits); + let mut committee_offset = 0; + + for index in committee_indices { + let committee = accessors::beacon_committee(state, aggregate.data.slot, index)?; + + let committee_attesters = committee + .into_iter() + .enumerate() + .filter_map(|(i, index)| { + (aggregate.aggregation_bits.get(committee_offset + i)?).then_some(index) + }) + .collect::>(); + + log::info!("GET ATTESTING INDICES FOR AGGREGATE ATTESTATIONS: {aggregate:#?}"); + log::info!("COMMITTEE {index} ATTESTERS: {committee_attesters:#?}"); + + committee_offset += committee.len(); + } + for committee_index in misc::get_committee_indices::

(aggregate.committee_bits) { let index = committee_index.try_into()?; committee_bits.set(index, true);