mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Superstruct AggregateAndProof (#5715)
* Upgrade `superstruct` to `0.8.0` * superstruct `AggregateAndProof`
This commit is contained in:
@@ -605,11 +605,11 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
{
|
||||
Ok(()) => {
|
||||
for signed_aggregate_and_proof in signed_aggregate_and_proofs {
|
||||
let attestation = &signed_aggregate_and_proof.message.aggregate;
|
||||
let attestation = signed_aggregate_and_proof.message().aggregate();
|
||||
info!(
|
||||
log,
|
||||
"Successfully published attestation";
|
||||
"aggregator" => signed_aggregate_and_proof.message.aggregator_index,
|
||||
"aggregator" => signed_aggregate_and_proof.message().aggregator_index(),
|
||||
"signatures" => attestation.num_set_aggregation_bits(),
|
||||
"head_block" => format!("{:?}", attestation.data().beacon_block_root),
|
||||
"committee_index" => attestation.data().index,
|
||||
@@ -620,12 +620,12 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
}
|
||||
Err(e) => {
|
||||
for signed_aggregate_and_proof in signed_aggregate_and_proofs {
|
||||
let attestation = &signed_aggregate_and_proof.message.aggregate;
|
||||
let attestation = &signed_aggregate_and_proof.message().aggregate();
|
||||
crit!(
|
||||
log,
|
||||
"Failed to publish attestation";
|
||||
"error" => %e,
|
||||
"aggregator" => signed_aggregate_and_proof.message.aggregator_index,
|
||||
"aggregator" => signed_aggregate_and_proof.message().aggregator_index(),
|
||||
"committee_index" => attestation.data().index,
|
||||
"slot" => attestation.data().slot.as_u64(),
|
||||
"type" => "aggregated",
|
||||
|
||||
@@ -38,7 +38,7 @@ pub enum SignableMessage<'a, E: EthSpec, Payload: AbstractExecPayload<E> = FullP
|
||||
RandaoReveal(Epoch),
|
||||
BeaconBlock(&'a BeaconBlock<E, Payload>),
|
||||
AttestationData(&'a AttestationData),
|
||||
SignedAggregateAndProof(&'a AggregateAndProof<E>),
|
||||
SignedAggregateAndProof(AggregateAndProofRef<'a, E>),
|
||||
SelectionProof(Slot),
|
||||
SyncSelectionProof(&'a SyncAggregatorSelectionData),
|
||||
SyncCommitteeSignature {
|
||||
|
||||
@@ -43,7 +43,7 @@ pub enum Web3SignerObject<'a, E: EthSpec, Payload: AbstractExecPayload<E>> {
|
||||
AggregationSlot {
|
||||
slot: Slot,
|
||||
},
|
||||
AggregateAndProof(&'a AggregateAndProof<E>),
|
||||
AggregateAndProof(AggregateAndProofRef<'a, E>),
|
||||
Attestation(&'a AttestationData),
|
||||
BeaconBlock {
|
||||
version: ForkName,
|
||||
|
||||
@@ -18,12 +18,16 @@ use std::sync::Arc;
|
||||
use task_executor::TaskExecutor;
|
||||
use types::{
|
||||
attestation::Error as AttestationError, graffiti::GraffitiString, AbstractExecPayload, Address,
|
||||
AggregateAndProof, Attestation, BeaconBlock, BlindedPayload, ChainSpec, ContributionAndProof,
|
||||
Domain, Epoch, EthSpec, Fork, ForkName, Graffiti, Hash256, PublicKeyBytes, SelectionProof,
|
||||
Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedRoot,
|
||||
SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncAggregatorSelectionData,
|
||||
SyncCommitteeContribution, SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId,
|
||||
ValidatorRegistrationData, VoluntaryExit,
|
||||
Attestation, BeaconBlock, BlindedPayload, ChainSpec, ContributionAndProof, Domain, Epoch,
|
||||
EthSpec, Fork, ForkName, Graffiti, Hash256, PublicKeyBytes, SelectionProof, Signature,
|
||||
SignedBeaconBlock, SignedContributionAndProof, SignedRoot, SignedValidatorRegistrationData,
|
||||
SignedVoluntaryExit, Slot, SyncAggregatorSelectionData, SyncCommitteeContribution,
|
||||
SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId, ValidatorRegistrationData,
|
||||
VoluntaryExit,
|
||||
};
|
||||
use types::{
|
||||
AggregateAndProof, AggregateAndProofBase, AggregateAndProofElectra, SignedAggregateAndProof,
|
||||
SignedAggregateAndProofBase, SignedAggregateAndProofElectra,
|
||||
};
|
||||
|
||||
pub use crate::doppelganger_service::DoppelgangerStatus;
|
||||
@@ -801,16 +805,23 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
let signing_epoch = aggregate.data().target.epoch;
|
||||
let signing_context = self.signing_context(Domain::AggregateAndProof, signing_epoch);
|
||||
|
||||
let message = AggregateAndProof {
|
||||
aggregator_index,
|
||||
aggregate,
|
||||
selection_proof: selection_proof.into(),
|
||||
let message = match aggregate {
|
||||
Attestation::Base(att) => AggregateAndProof::Base(AggregateAndProofBase {
|
||||
aggregator_index,
|
||||
aggregate: att,
|
||||
selection_proof: selection_proof.into(),
|
||||
}),
|
||||
Attestation::Electra(att) => AggregateAndProof::Electra(AggregateAndProofElectra {
|
||||
aggregator_index,
|
||||
aggregate: att,
|
||||
selection_proof: selection_proof.into(),
|
||||
}),
|
||||
};
|
||||
|
||||
let signing_method = self.doppelganger_checked_signing_method(validator_pubkey)?;
|
||||
let signature = signing_method
|
||||
.get_signature::<E, BlindedPayload<E>>(
|
||||
SignableMessage::SignedAggregateAndProof(&message),
|
||||
SignableMessage::SignedAggregateAndProof(message.to_ref()),
|
||||
signing_context,
|
||||
&self.spec,
|
||||
&self.task_executor,
|
||||
@@ -819,7 +830,17 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
|
||||
metrics::inc_counter_vec(&metrics::SIGNED_AGGREGATES_TOTAL, &[metrics::SUCCESS]);
|
||||
|
||||
Ok(SignedAggregateAndProof { message, signature })
|
||||
match message {
|
||||
AggregateAndProof::Base(message) => {
|
||||
Ok(SignedAggregateAndProof::Base(SignedAggregateAndProofBase {
|
||||
message,
|
||||
signature,
|
||||
}))
|
||||
}
|
||||
AggregateAndProof::Electra(message) => Ok(SignedAggregateAndProof::Electra(
|
||||
SignedAggregateAndProofElectra { message, signature },
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Produces a `SelectionProof` for the `slot`, signed by with corresponding secret key to
|
||||
|
||||
Reference in New Issue
Block a user