superstruct the AttesterSlashing (#5636)

* `superstruct` Attester Fork Variants

* Push a little further

* Deal with Encode / Decode of AttesterSlashing

* not so sure about this..

* Stop Encode/Decode Bounds from Propagating Out

* Tons of Changes..

* More Conversions to AttestationRef

* Add AsReference trait (#15)

* Add AsReference trait

* Fix some snafus

* Got it Compiling! :D

* Got Tests Building

* Get beacon chain tests compiling

---------

Co-authored-by: Michael Sproul <micsproul@gmail.com>
This commit is contained in:
ethDreamer
2024-05-02 18:00:21 -05:00
committed by GitHub
parent 3b7132bc0d
commit e6c7f145dd
53 changed files with 1405 additions and 437 deletions

View File

@@ -8,7 +8,9 @@ use beacon_chain::{metrics, StateSkipConfig, WhenSlotSkipped};
use lazy_static::lazy_static;
use std::sync::Arc;
use tree_hash::TreeHash;
use types::{AggregateSignature, EthSpec, Keypair, MainnetEthSpec, RelativeEpoch, Slot};
use types::{
AggregateSignature, Attestation, EthSpec, Keypair, MainnetEthSpec, RelativeEpoch, Slot,
};
pub const VALIDATOR_COUNT: usize = 16;
@@ -188,20 +190,35 @@ async fn produces_attestations() {
.produce_unaggregated_attestation(slot, index)
.expect("should produce attestation");
let data = &attestation.data;
match &attestation {
Attestation::Base(att) => {
assert_eq!(
att.aggregation_bits.len(),
committee_len,
"bad committee len"
);
assert!(
att.aggregation_bits.is_zero(),
"some committee bits are set"
);
}
Attestation::Electra(att) => {
assert_eq!(
att.aggregation_bits.len(),
committee_len,
"bad committee len"
);
assert!(
att.aggregation_bits.is_zero(),
"some committee bits are set"
);
}
}
let data = attestation.data();
assert_eq!(
attestation.aggregation_bits.len(),
committee_len,
"bad committee len"
);
assert!(
attestation.aggregation_bits.is_zero(),
"some committee bits are set"
);
assert_eq!(
attestation.signature,
AggregateSignature::empty(),
attestation.signature(),
&AggregateSignature::empty(),
"bad signature"
);
assert_eq!(data.index, index, "bad index");
@@ -329,10 +346,10 @@ async fn early_attester_cache_old_request() {
.produce_unaggregated_attestation(attest_slot, 0)
.unwrap();
assert_eq!(attestation.data.slot, attest_slot);
assert_eq!(attestation.data().slot, attest_slot);
let attested_block = harness
.chain
.get_blinded_block(&attestation.data.beacon_block_root)
.get_blinded_block(&attestation.data().beacon_block_root)
.unwrap()
.unwrap();
assert_eq!(attested_block.slot(), attest_slot);

View File

@@ -125,7 +125,7 @@ fn get_valid_unaggregated_attestation<T: BeaconChainTypes>(
let validator_committee_index = 0;
let validator_index = *head
.beacon_state
.get_beacon_committee(current_slot, valid_attestation.data.index)
.get_beacon_committee(current_slot, valid_attestation.data().index)
.expect("should get committees")
.committee
.get(validator_committee_index)
@@ -144,7 +144,7 @@ fn get_valid_unaggregated_attestation<T: BeaconChainTypes>(
.expect("should sign attestation");
let subnet_id = SubnetId::compute_subnet_for_attestation_data::<E>(
&valid_attestation.data,
valid_attestation.data(),
head.beacon_state
.get_committee_count_at_slot(current_slot)
.expect("should get committee count"),
@@ -170,7 +170,7 @@ fn get_valid_aggregated_attestation<T: BeaconChainTypes>(
let current_slot = chain.slot().expect("should get slot");
let committee = state
.get_beacon_committee(current_slot, aggregate.data.index)
.get_beacon_committee(current_slot, aggregate.data().index)
.expect("should get committees");
let committee_len = committee.committee.len();
@@ -181,7 +181,7 @@ fn get_valid_aggregated_attestation<T: BeaconChainTypes>(
let aggregator_sk = generate_deterministic_keypair(val_index).sk;
let proof = SelectionProof::new::<T::EthSpec>(
aggregate.data.slot,
aggregate.data().slot,
&aggregator_sk,
&state.fork(),
chain.genesis_validators_root,
@@ -220,7 +220,7 @@ fn get_non_aggregator<T: BeaconChainTypes>(
let current_slot = chain.slot().expect("should get slot");
let committee = state
.get_beacon_committee(current_slot, aggregate.data.index)
.get_beacon_committee(current_slot, aggregate.data().index)
.expect("should get committees");
let committee_len = committee.committee.len();
@@ -231,7 +231,7 @@ fn get_non_aggregator<T: BeaconChainTypes>(
let aggregator_sk = generate_deterministic_keypair(val_index).sk;
let proof = SelectionProof::new::<T::EthSpec>(
aggregate.data.slot,
aggregate.data().slot,
&aggregator_sk,
&state.fork(),
chain.genesis_validators_root,
@@ -301,7 +301,7 @@ impl GossipTester {
get_valid_aggregated_attestation(&harness.chain, valid_attestation.clone());
let mut invalid_attestation = valid_attestation.clone();
invalid_attestation.data.beacon_block_root = Hash256::repeat_byte(13);
invalid_attestation.data_mut().beacon_block_root = Hash256::repeat_byte(13);
let (mut invalid_aggregate, _, _) =
get_valid_aggregated_attestation(&harness.chain, invalid_attestation.clone());
@@ -490,7 +490,7 @@ async fn aggregated_gossip_verification() {
*/
.inspect_aggregate_err(
"aggregate from future slot",
|tester, a| a.message.aggregate.data.slot = tester.slot() + 1,
|tester, a| a.message.aggregate.data_mut().slot = tester.slot() + 1,
|tester, err| {
assert!(matches!(
err,
@@ -504,8 +504,9 @@ async fn aggregated_gossip_verification() {
"aggregate from past slot",
|tester, a| {
let too_early_slot = tester.earliest_valid_attestation_slot() - 1;
a.message.aggregate.data.slot = too_early_slot;
a.message.aggregate.data.target.epoch = too_early_slot.epoch(E::slots_per_epoch());
a.message.aggregate.data_mut().slot = too_early_slot;
a.message.aggregate.data_mut().target.epoch =
too_early_slot.epoch(E::slots_per_epoch());
},
|tester, err| {
let valid_early_slot = tester.earliest_valid_attestation_slot();
@@ -529,7 +530,7 @@ async fn aggregated_gossip_verification() {
*/
.inspect_aggregate_err(
"attestation with invalid target epoch",
|_, a| a.message.aggregate.data.target.epoch += 1,
|_, a| a.message.aggregate.data_mut().target.epoch += 1,
|_, err| assert!(matches!(err, AttnError::InvalidTargetEpoch { .. })),
)
/*
@@ -538,7 +539,7 @@ async fn aggregated_gossip_verification() {
*/
.inspect_aggregate_err(
"attestation with invalid target root",
|_, a| a.message.aggregate.data.target.root = Hash256::repeat_byte(42),
|_, a| a.message.aggregate.data_mut().target.root = Hash256::repeat_byte(42),
|_, err| assert!(matches!(err, AttnError::InvalidTargetRoot { .. })),
)
/*
@@ -548,7 +549,7 @@ async fn aggregated_gossip_verification() {
*/
.inspect_aggregate_err(
"aggregate with unknown head block",
|_, a| a.message.aggregate.data.beacon_block_root = Hash256::repeat_byte(42),
|_, a| a.message.aggregate.data_mut().beacon_block_root = Hash256::repeat_byte(42),
|_, err| {
assert!(matches!(
err,
@@ -567,10 +568,19 @@ async fn aggregated_gossip_verification() {
.inspect_aggregate_err(
"aggregate with no participants",
|_, a| {
let aggregation_bits = &mut a.message.aggregate.aggregation_bits;
aggregation_bits.difference_inplace(&aggregation_bits.clone());
assert!(aggregation_bits.is_zero());
a.message.aggregate.signature = AggregateSignature::infinity();
match &mut a.message.aggregate {
Attestation::Base(ref mut att) => {
let aggregation_bits = &mut att.aggregation_bits;
aggregation_bits.difference_inplace(&aggregation_bits.clone());
assert!(aggregation_bits.is_zero());
}
Attestation::Electra(ref mut att) => {
let aggregation_bits = &mut att.aggregation_bits;
aggregation_bits.difference_inplace(&aggregation_bits.clone());
assert!(aggregation_bits.is_zero());
}
}
*a.message.aggregate.signature_mut() = AggregateSignature::infinity();
},
|_, err| assert!(matches!(err, AttnError::EmptyAggregationBitfield)),
)
@@ -598,7 +608,7 @@ async fn aggregated_gossip_verification() {
.chain
.head_snapshot()
.beacon_state
.get_beacon_committee(tester.slot(), a.message.aggregate.data.index)
.get_beacon_committee(tester.slot(), a.message.aggregate.data().index)
.expect("should get committees")
.committee
.len();
@@ -634,7 +644,7 @@ async fn aggregated_gossip_verification() {
|tester, a| {
let mut agg_sig = AggregateSignature::infinity();
agg_sig.add_assign(&tester.aggregator_sk.sign(Hash256::repeat_byte(42)));
a.message.aggregate.signature = agg_sig;
*a.message.aggregate.signature_mut() = agg_sig;
},
|_, err| assert!(matches!(err, AttnError::InvalidSignature)),
)
@@ -729,7 +739,7 @@ async fn aggregated_gossip_verification() {
assert!(matches!(
err,
AttnError::AttestationSupersetKnown(hash)
if hash == tester.valid_aggregate.message.aggregate.data.tree_hash_root()
if hash == tester.valid_aggregate.message.aggregate.data().tree_hash_root()
))
},
)
@@ -741,7 +751,7 @@ async fn aggregated_gossip_verification() {
*/
.inspect_aggregate_err(
"aggregate from aggregator that has already been seen",
|_, a| a.message.aggregate.data.beacon_block_root = Hash256::repeat_byte(42),
|_, a| a.message.aggregate.data_mut().beacon_block_root = Hash256::repeat_byte(42),
|tester, err| {
assert!(matches!(
err,
@@ -766,12 +776,12 @@ async fn unaggregated_gossip_verification() {
.inspect_unaggregate_err(
"attestation with invalid committee index",
|tester, a, _| {
a.data.index = tester
a.data_mut().index = tester
.harness
.chain
.head_snapshot()
.beacon_state
.get_committee_count_at_slot(a.data.slot)
.get_committee_count_at_slot(a.data().slot)
.unwrap()
},
|_, err| assert!(matches!(err, AttnError::NoCommitteeForSlotAndIndex { .. })),
@@ -806,7 +816,7 @@ async fn unaggregated_gossip_verification() {
*/
.inspect_unaggregate_err(
"attestation from future slot",
|tester, a, _| a.data.slot = tester.slot() + 1,
|tester, a, _| a.data_mut().slot = tester.slot() + 1,
|tester, err| {
assert!(matches!(
err,
@@ -822,8 +832,8 @@ async fn unaggregated_gossip_verification() {
"attestation from past slot",
|tester, a, _| {
let too_early_slot = tester.earliest_valid_attestation_slot() - 1;
a.data.slot = too_early_slot;
a.data.target.epoch = too_early_slot.epoch(E::slots_per_epoch());
a.data_mut().slot = too_early_slot;
a.data_mut().target.epoch = too_early_slot.epoch(E::slots_per_epoch());
},
|tester, err| {
let valid_early_slot = tester.earliest_valid_attestation_slot();
@@ -847,7 +857,7 @@ async fn unaggregated_gossip_verification() {
*/
.inspect_unaggregate_err(
"attestation with invalid target epoch",
|_, a, _| a.data.target.epoch += 1,
|_, a, _| a.data_mut().target.epoch += 1,
|_, err| {
assert!(matches!(
err,
@@ -863,15 +873,29 @@ async fn unaggregated_gossip_verification() {
*/
.inspect_unaggregate_err(
"attestation without any aggregation bits set",
|tester, a, _| {
a.aggregation_bits
.set(tester.attester_committee_index, false)
.expect("should unset aggregation bit");
assert_eq!(
a.aggregation_bits.num_set_bits(),
0,
"test requires no set bits"
);
|tester, mut a, _| {
match &mut a {
Attestation::Base(ref mut att) => {
att.aggregation_bits
.set(tester.attester_committee_index, false)
.expect("should unset aggregation bit");
assert_eq!(
att.aggregation_bits.num_set_bits(),
0,
"test requires no set bits"
);
}
Attestation::Electra(ref mut att) => {
att.aggregation_bits
.set(tester.attester_committee_index, false)
.expect("should unset aggregation bit");
assert_eq!(
att.aggregation_bits.num_set_bits(),
0,
"test requires no set bits"
);
}
}
},
|_, err| {
assert!(matches!(
@@ -882,10 +906,19 @@ async fn unaggregated_gossip_verification() {
)
.inspect_unaggregate_err(
"attestation with two aggregation bits set",
|tester, a, _| {
a.aggregation_bits
.set(tester.attester_committee_index + 1, true)
.expect("should set second aggregation bit");
|tester, mut a, _| {
match &mut a {
Attestation::Base(ref mut att) => {
att.aggregation_bits
.set(tester.attester_committee_index + 1, true)
.expect("should set second aggregation bit");
}
Attestation::Electra(ref mut att) => {
att.aggregation_bits
.set(tester.attester_committee_index + 1, true)
.expect("should set second aggregation bit");
}
}
},
|_, err| {
assert!(matches!(
@@ -903,11 +936,22 @@ async fn unaggregated_gossip_verification() {
*/
.inspect_unaggregate_err(
"attestation with invalid bitfield",
|_, a, _| {
let bits = a.aggregation_bits.iter().collect::<Vec<_>>();
a.aggregation_bits = BitList::with_capacity(bits.len() + 1).unwrap();
for (i, bit) in bits.into_iter().enumerate() {
a.aggregation_bits.set(i, bit).unwrap();
|_, mut a, _| {
match &mut a {
Attestation::Base(ref mut att) => {
let bits = att.aggregation_bits.iter().collect::<Vec<_>>();
att.aggregation_bits = BitList::with_capacity(bits.len() + 1).unwrap();
for (i, bit) in bits.into_iter().enumerate() {
att.aggregation_bits.set(i, bit).unwrap();
}
}
Attestation::Electra(ref mut att) => {
let bits = att.aggregation_bits.iter().collect::<Vec<_>>();
att.aggregation_bits = BitList::with_capacity(bits.len() + 1).unwrap();
for (i, bit) in bits.into_iter().enumerate() {
att.aggregation_bits.set(i, bit).unwrap();
}
}
}
},
|_, err| {
@@ -927,7 +971,7 @@ async fn unaggregated_gossip_verification() {
.inspect_unaggregate_err(
"attestation with unknown head block",
|_, a, _| {
a.data.beacon_block_root = Hash256::repeat_byte(42);
a.data_mut().beacon_block_root = Hash256::repeat_byte(42);
},
|_, err| {
assert!(matches!(
@@ -949,7 +993,7 @@ async fn unaggregated_gossip_verification() {
.inspect_unaggregate_err(
"attestation with invalid target root",
|_, a, _| {
a.data.target.root = Hash256::repeat_byte(42);
a.data_mut().target.root = Hash256::repeat_byte(42);
},
|_, err| {
assert!(matches!(
@@ -968,7 +1012,7 @@ async fn unaggregated_gossip_verification() {
|tester, a, _| {
let mut agg_sig = AggregateSignature::infinity();
agg_sig.add_assign(&tester.attester_sk.sign(Hash256::repeat_byte(42)));
a.signature = agg_sig;
*a.signature_mut() = agg_sig;
},
|_, err| {
assert!(matches!(
@@ -1055,7 +1099,7 @@ async fn attestation_that_skips_epochs() {
.cloned()
.expect("should have at least one attestation in committee");
let block_root = attestation.data.beacon_block_root;
let block_root = attestation.data().beacon_block_root;
let block_slot = harness
.chain
.store
@@ -1066,7 +1110,7 @@ async fn attestation_that_skips_epochs() {
.slot();
assert!(
attestation.data.slot - block_slot > E::slots_per_epoch() * 2,
attestation.data().slot - block_slot > E::slots_per_epoch() * 2,
"the attestation must skip more than two epochs"
);
@@ -1228,7 +1272,7 @@ async fn attestation_to_finalized_block() {
.first()
.cloned()
.expect("should have at least one attestation in committee");
assert_eq!(attestation.data.beacon_block_root, earlier_block_root);
assert_eq!(attestation.data().beacon_block_root, earlier_block_root);
// Attestation should be rejected for attesting to a pre-finalization block.
let res = harness
@@ -1281,7 +1325,7 @@ async fn verify_aggregate_for_gossip_doppelganger_detection() {
.verify_aggregated_attestation_for_gossip(&valid_aggregate)
.expect("should verify aggregate attestation");
let epoch = valid_aggregate.message.aggregate.data.target.epoch;
let epoch = valid_aggregate.message.aggregate.data().target.epoch;
let index = valid_aggregate.message.aggregator_index as usize;
assert!(harness.chain.validator_seen_at_epoch(index, epoch));
@@ -1338,7 +1382,7 @@ async fn verify_attestation_for_gossip_doppelganger_detection() {
.verify_unaggregated_attestation_for_gossip(&valid_attestation, Some(subnet_id))
.expect("should verify attestation");
let epoch = valid_attestation.data.target.epoch;
let epoch = valid_attestation.data().target.epoch;
assert!(harness.chain.validator_seen_at_epoch(index, epoch));
// Check the correct beacon cache is populated

View File

@@ -664,7 +664,7 @@ async fn invalid_signature_attester_slashing() {
for &block_index in BLOCK_INDICES {
let harness = get_invalid_sigs_harness(&chain_segment).await;
let mut snapshots = chain_segment.clone();
let indexed_attestation = IndexedAttestation {
let indexed_attestation = IndexedAttestationBase {
attesting_indices: vec![0].into(),
data: AttestationData {
slot: Slot::new(0),
@@ -681,7 +681,7 @@ async fn invalid_signature_attester_slashing() {
},
signature: junk_aggregate_signature(),
};
let attester_slashing = AttesterSlashing {
let attester_slashing = AttesterSlashingBase {
attestation_1: indexed_attestation.clone(),
attestation_2: indexed_attestation,
};
@@ -690,11 +690,36 @@ async fn invalid_signature_attester_slashing() {
.as_ref()
.clone()
.deconstruct();
block
.body_mut()
.attester_slashings_mut()
.push(attester_slashing)
.expect("should update attester slashing");
match &mut block.body_mut() {
BeaconBlockBodyRefMut::Base(ref mut blk) => {
blk.attester_slashings
.push(attester_slashing)
.expect("should update attester slashing");
}
BeaconBlockBodyRefMut::Altair(ref mut blk) => {
blk.attester_slashings
.push(attester_slashing)
.expect("should update attester slashing");
}
BeaconBlockBodyRefMut::Merge(ref mut blk) => {
blk.attester_slashings
.push(attester_slashing)
.expect("should update attester slashing");
}
BeaconBlockBodyRefMut::Capella(ref mut blk) => {
blk.attester_slashings
.push(attester_slashing)
.expect("should update attester slashing");
}
BeaconBlockBodyRefMut::Deneb(ref mut blk) => {
blk.attester_slashings
.push(attester_slashing)
.expect("should update attester slashing");
}
BeaconBlockBodyRefMut::Electra(_) => {
panic!("electra test not implemented!");
}
}
snapshots[block_index].beacon_block =
Arc::new(SignedBeaconBlock::from_block(block, signature));
update_parent_roots(&mut snapshots, &mut chain_segment_blobs);
@@ -724,8 +749,34 @@ async fn invalid_signature_attestation() {
.as_ref()
.clone()
.deconstruct();
if let Some(attestation) = block.body_mut().attestations_mut().get_mut(0) {
attestation.signature = junk_aggregate_signature();
match &mut block.body_mut() {
BeaconBlockBodyRefMut::Base(ref mut blk) => blk
.attestations
.get_mut(0)
.map(|att| att.signature = junk_aggregate_signature()),
BeaconBlockBodyRefMut::Altair(ref mut blk) => blk
.attestations
.get_mut(0)
.map(|att| att.signature = junk_aggregate_signature()),
BeaconBlockBodyRefMut::Merge(ref mut blk) => blk
.attestations
.get_mut(0)
.map(|att| att.signature = junk_aggregate_signature()),
BeaconBlockBodyRefMut::Capella(ref mut blk) => blk
.attestations
.get_mut(0)
.map(|att| att.signature = junk_aggregate_signature()),
BeaconBlockBodyRefMut::Deneb(ref mut blk) => blk
.attestations
.get_mut(0)
.map(|att| att.signature = junk_aggregate_signature()),
BeaconBlockBodyRefMut::Electra(ref mut blk) => blk
.attestations
.get_mut(0)
.map(|att| att.signature = junk_aggregate_signature()),
};
if block.body().attestations_len() > 0 {
snapshots[block_index].beacon_block =
Arc::new(SignedBeaconBlock::from_block(block, signature));
update_parent_roots(&mut snapshots, &mut chain_segment_blobs);
@@ -1187,9 +1238,13 @@ async fn verify_block_for_gossip_doppelganger_detection() {
let state = harness.get_current_state();
let ((block, _), _) = harness.make_block(state.clone(), Slot::new(1)).await;
let attestations = block
.message()
.body()
.attestations()
.map(|att| att.clone_as_attestation())
.collect::<Vec<_>>();
let verified_block = harness.chain.verify_block_for_gossip(block).await.unwrap();
let attestations = verified_block.block.message().body().attestations().clone();
harness
.chain
.process_block(
@@ -1202,37 +1257,69 @@ async fn verify_block_for_gossip_doppelganger_detection() {
.unwrap();
for att in attestations.iter() {
let epoch = att.data.target.epoch;
let epoch = att.data().target.epoch;
let committee = state
.get_beacon_committee(att.data.slot, att.data.index)
.get_beacon_committee(att.data().slot, att.data().index)
.unwrap();
let indexed_attestation = get_indexed_attestation(committee.committee, att).unwrap();
let indexed_attestation =
get_indexed_attestation(committee.committee, att.to_ref()).unwrap();
for &index in &indexed_attestation.attesting_indices {
let index = index as usize;
match indexed_attestation {
IndexedAttestation::Base(indexed_attestation) => {
for &index in &indexed_attestation.attesting_indices {
let index = index as usize;
assert!(harness.chain.validator_seen_at_epoch(index, epoch));
assert!(harness.chain.validator_seen_at_epoch(index, epoch));
// Check the correct beacon cache is populated
assert!(harness
.chain
.observed_block_attesters
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if block attester was observed"));
assert!(!harness
.chain
.observed_gossip_attesters
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if gossip attester was observed"));
assert!(!harness
.chain
.observed_aggregators
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if gossip aggregator was observed"));
}
// Check the correct beacon cache is populated
assert!(harness
.chain
.observed_block_attesters
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if block attester was observed"));
assert!(!harness
.chain
.observed_gossip_attesters
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if gossip attester was observed"));
assert!(!harness
.chain
.observed_aggregators
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if gossip aggregator was observed"));
}
}
IndexedAttestation::Electra(indexed_attestation) => {
for &index in &indexed_attestation.attesting_indices {
let index = index as usize;
assert!(harness.chain.validator_seen_at_epoch(index, epoch));
// Check the correct beacon cache is populated
assert!(harness
.chain
.observed_block_attesters
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if block attester was observed"));
assert!(!harness
.chain
.observed_gossip_attesters
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if gossip attester was observed"));
assert!(!harness
.chain
.observed_aggregators
.read()
.validator_has_been_observed(epoch, index)
.expect("should check if gossip aggregator was observed"));
}
}
};
}
}

View File

@@ -1191,9 +1191,17 @@ async fn attesting_to_optimistic_head() {
.produce_unaggregated_attestation(Slot::new(0), 0)
.unwrap();
attestation.aggregation_bits.set(0, true).unwrap();
attestation.data.slot = slot;
attestation.data.beacon_block_root = root;
match &mut attestation {
Attestation::Base(ref mut att) => {
att.aggregation_bits.set(0, true).unwrap();
}
Attestation::Electra(ref mut att) => {
att.aggregation_bits.set(0, true).unwrap();
}
}
attestation.data_mut().slot = slot;
attestation.data_mut().beacon_block_root = root;
rig.harness
.chain
@@ -1214,15 +1222,15 @@ async fn attesting_to_optimistic_head() {
let get_aggregated = || {
rig.harness
.chain
.get_aggregated_attestation(&attestation.data)
.get_aggregated_attestation(attestation.data())
};
let get_aggregated_by_slot_and_root = || {
rig.harness
.chain
.get_aggregated_attestation_by_slot_and_root(
attestation.data.slot,
&attestation.data.tree_hash_root(),
attestation.data().slot,
&attestation.data().tree_hash_root(),
)
};

View File

@@ -606,7 +606,7 @@ async fn epoch_boundary_state_attestation_processing() {
for (attestation, subnet_id) in late_attestations.into_iter().flatten() {
// load_epoch_boundary_state is idempotent!
let block_root = attestation.data.beacon_block_root;
let block_root = attestation.data().beacon_block_root;
let block = store
.get_blinded_block(&block_root)
.unwrap()
@@ -629,7 +629,7 @@ async fn epoch_boundary_state_attestation_processing() {
.verify_unaggregated_attestation_for_gossip(&attestation, Some(subnet_id));
let current_slot = harness.chain.slot().expect("should get slot");
let expected_attestation_slot = attestation.data.slot;
let expected_attestation_slot = attestation.data().slot;
// Extra -1 to handle gossip clock disparity.
let expected_earliest_permissible_slot = current_slot - E::slots_per_epoch() - 1;
@@ -1028,8 +1028,7 @@ async fn multiple_attestations_per_block() {
.as_ref()
.message()
.body()
.attestations()
.len() as u64,
.attestations_len() as u64,
if slot <= 1 { 0 } else { committees_per_slot }
);
}

View File

@@ -573,7 +573,7 @@ async fn attestations_with_increasing_slots() {
.verify_unaggregated_attestation_for_gossip(&attestation, Some(subnet_id));
let current_slot = harness.chain.slot().expect("should get slot");
let expected_attestation_slot = attestation.data.slot;
let expected_attestation_slot = attestation.data().slot;
let expected_earliest_permissible_slot =
current_slot - MinimalEthSpec::slots_per_epoch() - 1;