mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-15 09:48:20 +00:00
Clean ups
This commit is contained in:
@@ -140,11 +140,6 @@ struct RejectedAggregate<E: EthSpec> {
|
||||
error: AttnError,
|
||||
}
|
||||
|
||||
struct RejectedPayloadAttestation {
|
||||
payload_attestation_message: Box<PayloadAttestationMessage>,
|
||||
error: PayloadAttestationError,
|
||||
}
|
||||
|
||||
/// Data for an aggregated or unaggregated attestation that failed verification.
|
||||
enum FailedAtt<E: EthSpec> {
|
||||
Unaggregate {
|
||||
@@ -4111,25 +4106,20 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
peer_id: PeerId,
|
||||
payload_attestation_message: Box<PayloadAttestationMessage>,
|
||||
) {
|
||||
let result = match self
|
||||
let message_slot = payload_attestation_message.data.slot;
|
||||
let result = self
|
||||
.chain
|
||||
.verify_payload_attestation_message_for_gossip(*payload_attestation_message.clone())
|
||||
{
|
||||
Ok(verified) => Ok(verified),
|
||||
Err(error) => Err(RejectedPayloadAttestation {
|
||||
payload_attestation_message: payload_attestation_message.clone(),
|
||||
error,
|
||||
}),
|
||||
};
|
||||
.verify_payload_attestation_message_for_gossip(*payload_attestation_message);
|
||||
|
||||
self.process_gossip_payload_attestation_result(result, message_id, peer_id);
|
||||
self.process_gossip_payload_attestation_result(result, message_id, peer_id, message_slot);
|
||||
}
|
||||
|
||||
fn process_gossip_payload_attestation_result(
|
||||
self: &Arc<Self>,
|
||||
result: Result<VerifiedPayloadAttestationMessage<T>, RejectedPayloadAttestation>,
|
||||
result: Result<VerifiedPayloadAttestationMessage<T>, PayloadAttestationError>,
|
||||
message_id: MessageId,
|
||||
peer_id: PeerId,
|
||||
message_slot: Slot,
|
||||
) {
|
||||
match result {
|
||||
Ok(verified) => {
|
||||
@@ -4165,15 +4155,12 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(RejectedPayloadAttestation {
|
||||
payload_attestation_message,
|
||||
error,
|
||||
}) => {
|
||||
Err(error) => {
|
||||
self.handle_payload_attestation_verification_failure(
|
||||
peer_id,
|
||||
message_id,
|
||||
error,
|
||||
payload_attestation_message.data.slot,
|
||||
message_slot,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,16 +217,20 @@ impl<E: EthSpec> OperationPool<E> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Build aggregated `PayloadAttestation`s from stored messages for block production.
|
||||
/// Build `PayloadAttestation`s from stored messages for block production.
|
||||
///
|
||||
/// `parent_block_root` is the root of the parent block (the block PTC members attested to).
|
||||
/// Returns up to `MAX_PAYLOAD_ATTESTATIONS` attestations for the previous slot.
|
||||
/// Returns one `PayloadAttestation` per distinct `PayloadAttestationData`. With two boolean
|
||||
/// fields this yields at most 4, which equals `MAX_PAYLOAD_ATTESTATIONS`.
|
||||
pub fn get_payload_attestations(
|
||||
&self,
|
||||
state: &BeaconState<E>,
|
||||
parent_block_root: Hash256,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Vec<PayloadAttestation<E>>, OpPoolError> {
|
||||
if state.slot() == 0 {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
let target_slot = state.slot().saturating_sub(1u64);
|
||||
|
||||
let ptc = state
|
||||
@@ -249,13 +253,12 @@ impl<E: EthSpec> OperationPool<E> {
|
||||
.0
|
||||
.iter()
|
||||
.position(|&idx| idx == msg.validator_index as usize)
|
||||
&& !aggregation_bits.get(pos).unwrap_or(false)
|
||||
{
|
||||
if !aggregation_bits.get(pos).unwrap_or(false) {
|
||||
aggregation_bits
|
||||
.set(pos, true)
|
||||
.map_err(|_| OpPoolError::PayloadAttestationBitError)?;
|
||||
aggregate_sig.add_assign(&msg.signature);
|
||||
}
|
||||
aggregation_bits
|
||||
.set(pos, true)
|
||||
.map_err(|_| OpPoolError::PayloadAttestationBitError)?;
|
||||
aggregate_sig.add_assign(&msg.signature);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user