mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-06 10:11:44 +00:00
Single attestation "Full" implementation (#7444)
#6970 This allows for us to receive `SingleAttestation` over gossip and process it without converting. There is still a conversion to `Attestation` as a final step in the attestation verification process, but by then the `SingleAttestation` is fully verified. I've also fully removed the `submitPoolAttestationsV1` endpoint as its been deprecated I've also pre-emptively deprecated supporting `Attestation` in `submitPoolAttestationsV2` endpoint. See here for more info: https://github.com/ethereum/beacon-APIs/pull/531 I tried to the minimize the diff here by only making the "required" changes. There are some unnecessary complexities with the way we manage the different attestation verification wrapper types. We could probably consolidate this to one wrapper type and refactor this even further. We could leave that to a separate PR if we feel like cleaning things up in the future. Note that I've also updated the test harness to always submit `SingleAttestation` regardless of fork variant. I don't see a problem in that approach and it allows us to delete more code :)
This commit is contained in:
@@ -149,10 +149,41 @@ async fn attestations_across_fork_with_skip_slots() {
|
||||
.flat_map(|(atts, _)| atts.iter().map(|(att, _)| att.clone()))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let unaggregated_attestations = unaggregated_attestations
|
||||
.into_iter()
|
||||
.map(|attn| {
|
||||
let aggregation_bits = attn.get_aggregation_bits();
|
||||
|
||||
if aggregation_bits.len() != 1 {
|
||||
panic!("Must be an unaggregated attestation")
|
||||
}
|
||||
|
||||
let aggregation_bit = *aggregation_bits.first().unwrap();
|
||||
|
||||
let committee = fork_state
|
||||
.get_beacon_committee(attn.data().slot, attn.committee_index().unwrap())
|
||||
.unwrap();
|
||||
|
||||
let attester_index = committee
|
||||
.committee
|
||||
.iter()
|
||||
.enumerate()
|
||||
.find_map(|(i, &index)| {
|
||||
if aggregation_bit as usize == i {
|
||||
return Some(index);
|
||||
}
|
||||
None
|
||||
})
|
||||
.unwrap();
|
||||
attn.to_single_attestation_with_attester_index(attester_index as u64)
|
||||
.unwrap()
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert!(!unaggregated_attestations.is_empty());
|
||||
let fork_name = harness.spec.fork_name_at_slot::<E>(fork_slot);
|
||||
client
|
||||
.post_beacon_pool_attestations_v1(&unaggregated_attestations)
|
||||
.post_beacon_pool_attestations_v2::<E>(unaggregated_attestations, fork_name)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user