mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +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:
@@ -15,8 +15,8 @@ use std::sync::Arc;
|
||||
use tokio::time::{sleep, sleep_until, Duration, Instant};
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
AggregateSignature, Attestation, AttestationData, BitList, ChainSpec, CommitteeIndex, EthSpec,
|
||||
Slot,
|
||||
attestation::AttestationBase, AggregateSignature, Attestation, AttestationData, BitList,
|
||||
ChainSpec, CommitteeIndex, EthSpec, Slot,
|
||||
};
|
||||
|
||||
/// Builds an `AttestationService`.
|
||||
@@ -378,11 +378,11 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut attestation = Attestation {
|
||||
let mut attestation = 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
|
||||
@@ -610,10 +610,10 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
log,
|
||||
"Successfully published attestation";
|
||||
"aggregator" => signed_aggregate_and_proof.message.aggregator_index,
|
||||
"signatures" => attestation.aggregation_bits.num_set_bits(),
|
||||
"head_block" => format!("{:?}", attestation.data.beacon_block_root),
|
||||
"committee_index" => attestation.data.index,
|
||||
"slot" => attestation.data.slot.as_u64(),
|
||||
"signatures" => attestation.num_set_aggregation_bits(),
|
||||
"head_block" => format!("{:?}", attestation.data().beacon_block_root),
|
||||
"committee_index" => attestation.data().index,
|
||||
"slot" => attestation.data().slot.as_u64(),
|
||||
"type" => "aggregated",
|
||||
);
|
||||
}
|
||||
@@ -626,8 +626,8 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
|
||||
"Failed to publish attestation";
|
||||
"error" => %e,
|
||||
"aggregator" => signed_aggregate_and_proof.message.aggregator_index,
|
||||
"committee_index" => attestation.data.index,
|
||||
"slot" => attestation.data.slot.as_u64(),
|
||||
"committee_index" => attestation.data().index,
|
||||
"slot" => attestation.data().slot.as_u64(),
|
||||
"type" => "aggregated",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use rand::{rngs::SmallRng, Rng, SeedableRng};
|
||||
use slashing_protection::interchange::{Interchange, InterchangeMetadata};
|
||||
use std::{collections::HashMap, path::Path};
|
||||
use tokio::runtime::Handle;
|
||||
use types::Address;
|
||||
use types::{attestation::AttestationBase, Address};
|
||||
|
||||
fn new_keystore(password: ZeroizeString) -> Keystore {
|
||||
let keypair = Keypair::random();
|
||||
@@ -1094,7 +1094,7 @@ async fn generic_migration_test(
|
||||
// Sign attestations on VC1.
|
||||
for (validator_index, mut attestation) in first_vc_attestations {
|
||||
let public_key = keystore_pubkey(&keystores[validator_index]);
|
||||
let current_epoch = attestation.data.target.epoch;
|
||||
let current_epoch = attestation.data().target.epoch;
|
||||
tester1
|
||||
.validator_store
|
||||
.sign_attestation(public_key, 0, &mut attestation, current_epoch)
|
||||
@@ -1170,7 +1170,7 @@ async fn generic_migration_test(
|
||||
// Sign attestations on the second VC.
|
||||
for (validator_index, mut attestation, should_succeed) in second_vc_attestations {
|
||||
let public_key = keystore_pubkey(&keystores[validator_index]);
|
||||
let current_epoch = attestation.data.target.epoch;
|
||||
let current_epoch = attestation.data().target.epoch;
|
||||
match tester2
|
||||
.validator_store
|
||||
.sign_attestation(public_key, 0, &mut attestation, current_epoch)
|
||||
@@ -1236,7 +1236,7 @@ async fn delete_nonexistent_keystores() {
|
||||
}
|
||||
|
||||
fn make_attestation(source_epoch: u64, target_epoch: u64) -> Attestation<E> {
|
||||
Attestation {
|
||||
Attestation::Base(AttestationBase {
|
||||
aggregation_bits: BitList::with_capacity(
|
||||
<E as EthSpec>::MaxValidatorsPerCommittee::to_usize(),
|
||||
)
|
||||
@@ -1253,7 +1253,7 @@ fn make_attestation(source_epoch: u64, target_epoch: u64) -> Attestation<E> {
|
||||
..AttestationData::default()
|
||||
},
|
||||
signature: AggregateSignature::empty(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -647,9 +647,9 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
current_epoch: Epoch,
|
||||
) -> Result<(), Error> {
|
||||
// Make sure the target epoch is not higher than the current epoch to avoid potential attacks.
|
||||
if attestation.data.target.epoch > current_epoch {
|
||||
if attestation.data().target.epoch > current_epoch {
|
||||
return Err(Error::GreaterThanCurrentEpoch {
|
||||
epoch: attestation.data.target.epoch,
|
||||
epoch: attestation.data().target.epoch,
|
||||
current_epoch,
|
||||
});
|
||||
}
|
||||
@@ -658,7 +658,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
let signing_method = self.doppelganger_checked_signing_method(validator_pubkey)?;
|
||||
|
||||
// Checking for slashing conditions.
|
||||
let signing_epoch = attestation.data.target.epoch;
|
||||
let signing_epoch = attestation.data().target.epoch;
|
||||
let signing_context = self.signing_context(Domain::BeaconAttester, signing_epoch);
|
||||
let domain_hash = signing_context.domain_hash(&self.spec);
|
||||
let slashing_status = if signing_method
|
||||
@@ -666,7 +666,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
{
|
||||
self.slashing_protection.check_and_insert_attestation(
|
||||
&validator_pubkey,
|
||||
&attestation.data,
|
||||
attestation.data(),
|
||||
domain_hash,
|
||||
)
|
||||
} else {
|
||||
@@ -678,7 +678,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
Ok(Safe::Valid) => {
|
||||
let signature = signing_method
|
||||
.get_signature::<E, BlindedPayload<E>>(
|
||||
SignableMessage::AttestationData(&attestation.data),
|
||||
SignableMessage::AttestationData(attestation.data()),
|
||||
signing_context,
|
||||
&self.spec,
|
||||
&self.task_executor,
|
||||
@@ -720,7 +720,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
crit!(
|
||||
self.log,
|
||||
"Not signing slashable attestation";
|
||||
"attestation" => format!("{:?}", attestation.data),
|
||||
"attestation" => format!("{:?}", attestation.data()),
|
||||
"error" => format!("{:?}", e)
|
||||
);
|
||||
metrics::inc_counter_vec(
|
||||
@@ -798,7 +798,7 @@ impl<T: SlotClock + 'static, E: EthSpec> ValidatorStore<T, E> {
|
||||
aggregate: Attestation<E>,
|
||||
selection_proof: SelectionProof,
|
||||
) -> Result<SignedAggregateAndProof<E>, Error> {
|
||||
let signing_epoch = aggregate.data.target.epoch;
|
||||
let signing_epoch = aggregate.data().target.epoch;
|
||||
let signing_context = self.signing_context(Domain::AggregateAndProof, signing_epoch);
|
||||
|
||||
let message = AggregateAndProof {
|
||||
|
||||
Reference in New Issue
Block a user