mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 04:01:51 +00:00
Attestation superstruct changes for EIP 7549 (#5644)
* update * experiment * superstruct changes * revert * superstruct changes * fix tests * indexed attestation * indexed attestation superstruct * updated TODOs
This commit is contained in:
@@ -10,8 +10,8 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::Arc;
|
||||
use types::{
|
||||
BeaconCommittee, BeaconState, BeaconStateError, BlindedPayload, ChainSpec, Epoch, EthSpec,
|
||||
Hash256, OwnedBeaconCommittee, RelativeEpoch, SignedBeaconBlock, Slot,
|
||||
Attestation, BeaconCommittee, BeaconState, BeaconStateError, BlindedPayload, ChainSpec, Epoch,
|
||||
EthSpec, Hash256, OwnedBeaconCommittee, RelativeEpoch, SignedBeaconBlock, Slot,
|
||||
};
|
||||
use warp_utils::reject::{beacon_chain_error, custom_bad_request, custom_server_error};
|
||||
|
||||
@@ -112,21 +112,29 @@ impl<E: EthSpec> PackingEfficiencyHandler<E> {
|
||||
|
||||
let mut attestations_in_block = HashMap::new();
|
||||
for attestation in attestations.iter() {
|
||||
for (position, voted) in attestation.aggregation_bits.iter().enumerate() {
|
||||
if voted {
|
||||
let unique_attestation = UniqueAttestation {
|
||||
slot: attestation.data.slot,
|
||||
committee_index: attestation.data.index,
|
||||
committee_position: position,
|
||||
};
|
||||
let inclusion_distance: u64 = block
|
||||
.slot()
|
||||
.as_u64()
|
||||
.checked_sub(attestation.data.slot.as_u64())
|
||||
.ok_or(PackingEfficiencyError::InvalidAttestationError)?;
|
||||
match attestation {
|
||||
Attestation::Base(attn) => {
|
||||
for (position, voted) in attn.aggregation_bits.iter().enumerate() {
|
||||
if voted {
|
||||
let unique_attestation = UniqueAttestation {
|
||||
slot: attn.data.slot,
|
||||
committee_index: attn.data.index,
|
||||
committee_position: position,
|
||||
};
|
||||
let inclusion_distance: u64 = block
|
||||
.slot()
|
||||
.as_u64()
|
||||
.checked_sub(attn.data.slot.as_u64())
|
||||
.ok_or(PackingEfficiencyError::InvalidAttestationError)?;
|
||||
|
||||
self.available_attestations.remove(&unique_attestation);
|
||||
attestations_in_block.insert(unique_attestation, inclusion_distance);
|
||||
self.available_attestations.remove(&unique_attestation);
|
||||
attestations_in_block.insert(unique_attestation, inclusion_distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO(electra) implement electra variant
|
||||
Attestation::Electra(_) => {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1799,7 +1799,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.naive_aggregation_pool
|
||||
.read()
|
||||
.iter()
|
||||
.filter(|&att| query_filter(&att.data))
|
||||
.filter(|&att| query_filter(att.data()))
|
||||
.cloned(),
|
||||
);
|
||||
Ok(api_types::GenericResponse::from(attestations))
|
||||
@@ -3162,7 +3162,7 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|
||||
chain
|
||||
.produce_unaggregated_attestation(query.slot, query.committee_index)
|
||||
.map(|attestation| attestation.data)
|
||||
.map(|attestation| attestation.data().clone())
|
||||
.map(api_types::GenericResponse::from)
|
||||
.map_err(warp_utils::reject::beacon_chain_error)
|
||||
})
|
||||
@@ -3364,8 +3364,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
"error" => format!("{:?}", e),
|
||||
"request_index" => index,
|
||||
"aggregator_index" => aggregate.message.aggregator_index,
|
||||
"attestation_index" => aggregate.message.aggregate.data.index,
|
||||
"attestation_slot" => aggregate.message.aggregate.data.slot,
|
||||
"attestation_index" => aggregate.message.aggregate.data().index,
|
||||
"attestation_slot" => aggregate.message.aggregate.data().slot,
|
||||
);
|
||||
failures.push(api_types::Failure::new(index, format!("Verification: {:?}", e)));
|
||||
}
|
||||
@@ -3385,8 +3385,8 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
"error" => format!("{:?}", e),
|
||||
"request_index" => index,
|
||||
"aggregator_index" => verified_aggregate.aggregate().message.aggregator_index,
|
||||
"attestation_index" => verified_aggregate.attestation().data.index,
|
||||
"attestation_slot" => verified_aggregate.attestation().data.slot,
|
||||
"attestation_index" => verified_aggregate.attestation().data().index,
|
||||
"attestation_slot" => verified_aggregate.attestation().data().slot,
|
||||
);
|
||||
failures.push(api_types::Failure::new(index, format!("Fork choice: {:?}", e)));
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ pub async fn publish_attestations<T: BeaconChainTypes>(
|
||||
// move the `attestations` vec into the blocking task, so this small overhead is unavoidable.
|
||||
let attestation_metadata = attestations
|
||||
.iter()
|
||||
.map(|att| (att.data.slot, att.data.index))
|
||||
.map(|att| (att.data().slot, att.data().index))
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Gossip validate and publish attestations that can be immediately processed.
|
||||
|
||||
Reference in New Issue
Block a user