From 82858bc04e2f40df489f8b35fc36b1dc721470f2 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Mon, 13 May 2024 10:18:17 +0300 Subject: [PATCH 1/3] Send unagg attestation based on fork --- validator_client/src/attestation_service.rs | 32 +++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/validator_client/src/attestation_service.rs b/validator_client/src/attestation_service.rs index 5b7f31867bb..f6cc4629634 100644 --- a/validator_client/src/attestation_service.rs +++ b/validator_client/src/attestation_service.rs @@ -18,6 +18,7 @@ use types::{ attestation::AttestationBase, AggregateSignature, Attestation, AttestationData, BitList, ChainSpec, CommitteeIndex, EthSpec, Slot, }; +use types::{AttestationElectra, BitVector, ForkName}; /// Builds an `AttestationService`. pub struct AttestationServiceBuilder { @@ -378,11 +379,32 @@ impl AttestationService { return None; } - let mut attestation = Attestation::Base(AttestationBase { - aggregation_bits: BitList::with_capacity(duty.committee_length as usize).unwrap(), - data: attestation_data.clone(), - signature: AggregateSignature::infinity(), - }); + let fork_name = self + .context + .eth2_config + .spec + .fork_name_at_slot::(attestation_data.slot); + + let mut attestation = if fork_name >= ForkName::Electra { + let mut committee_bits: BitVector = BitVector::default(); + committee_bits + .set(duty.committee_index as usize, true) + .unwrap(); + Attestation::Electra(AttestationElectra { + aggregation_bits: BitList::with_capacity(duty.committee_length as usize) + .unwrap(), + data: attestation_data.clone(), + committee_bits, + signature: AggregateSignature::infinity(), + }) + } else { + Attestation::Base(AttestationBase { + aggregation_bits: BitList::with_capacity(duty.committee_length as usize) + .unwrap(), + data: attestation_data.clone(), + signature: AggregateSignature::infinity(), + }) + }; match self .validator_store From 154b7a7b8a9a12cbe19cd55288acfa111f36486b Mon Sep 17 00:00:00 2001 From: Mark Mackey Date: Wed, 15 May 2024 15:50:38 +0300 Subject: [PATCH 2/3] Publish all aggregates --- validator_client/src/attestation_service.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/validator_client/src/attestation_service.rs b/validator_client/src/attestation_service.rs index f6cc4629634..c172399fd3f 100644 --- a/validator_client/src/attestation_service.rs +++ b/validator_client/src/attestation_service.rs @@ -363,9 +363,15 @@ impl AttestationService { let duty = &duty_and_proof.duty; let attestation_data = attestation_data_ref; + let fork_name = self + .context + .eth2_config + .spec + .fork_name_at_slot::(attestation_data.slot); + // Ensure that the attestation matches the duties. #[allow(clippy::suspicious_operation_groupings)] - if duty.slot != attestation_data.slot || duty.committee_index != attestation_data.index + if duty.slot != attestation_data.slot || (fork_name < ForkName::Electra && duty.committee_index != attestation_data.index) { crit!( log, @@ -379,12 +385,6 @@ impl AttestationService { return None; } - let fork_name = self - .context - .eth2_config - .spec - .fork_name_at_slot::(attestation_data.slot); - let mut attestation = if fork_name >= ForkName::Electra { let mut committee_bits: BitVector = BitVector::default(); committee_bits From bb734afa1d781382248c67b06b5b6c8f23c1ddbf Mon Sep 17 00:00:00 2001 From: Mark Mackey Date: Wed, 15 May 2024 17:05:40 +0300 Subject: [PATCH 3/3] just one more check bro plz.. --- validator_client/src/attestation_service.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/validator_client/src/attestation_service.rs b/validator_client/src/attestation_service.rs index c172399fd3f..4213edc4392 100644 --- a/validator_client/src/attestation_service.rs +++ b/validator_client/src/attestation_service.rs @@ -371,7 +371,8 @@ impl AttestationService { // Ensure that the attestation matches the duties. #[allow(clippy::suspicious_operation_groupings)] - if duty.slot != attestation_data.slot || (fork_name < ForkName::Electra && duty.committee_index != attestation_data.index) + if duty.slot != attestation_data.slot + || (fork_name < ForkName::Electra && duty.committee_index != attestation_data.index) { crit!( log, @@ -553,6 +554,12 @@ impl AttestationService { .await .map_err(|e| e.to_string())?; + let fork_name = self + .context + .eth2_config + .spec + .fork_name_at_slot::(attestation_data.slot); + // Create futures to produce the signed aggregated attestations. let signing_futures = validator_duties.iter().map(|duty_and_proof| async move { let duty = &duty_and_proof.duty; @@ -561,7 +568,9 @@ impl AttestationService { let slot = attestation_data.slot; let committee_index = attestation_data.index; - if duty.slot != slot || duty.committee_index != committee_index { + if duty.slot != slot + || (fork_name < ForkName::Electra && duty.committee_index != committee_index) + { crit!(log, "Inconsistent validator duties during signing"); return None; }