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:
Eitan Seri-Levi
2024-04-30 19:49:08 +03:00
committed by GitHub
parent 4a48d7b546
commit 3b7132bc0d
56 changed files with 943 additions and 429 deletions

View File

@@ -389,7 +389,7 @@ async fn invalid_attestation_no_committee_for_index() {
.deconstruct()
.0;
head_block.to_mut().body_mut().attestations_mut()[0]
.data
.data_mut()
.index += 1;
let mut ctxt = ConsensusContext::new(state.slot());
let result = process_operations::process_attestations(
@@ -423,11 +423,11 @@ async fn invalid_attestation_wrong_justified_checkpoint() {
.clone()
.deconstruct()
.0;
let old_justified_checkpoint = head_block.body().attestations()[0].data.source;
let old_justified_checkpoint = head_block.body().attestations()[0].data().source;
let mut new_justified_checkpoint = old_justified_checkpoint;
new_justified_checkpoint.epoch += Epoch::new(1);
head_block.to_mut().body_mut().attestations_mut()[0]
.data
.data_mut()
.source = new_justified_checkpoint;
let mut ctxt = ConsensusContext::new(state.slot());
@@ -467,8 +467,9 @@ async fn invalid_attestation_bad_aggregation_bitfield_len() {
.clone()
.deconstruct()
.0;
head_block.to_mut().body_mut().attestations_mut()[0].aggregation_bits =
Bitfield::with_capacity(spec.target_committee_size).unwrap();
*head_block.to_mut().body_mut().attestations_mut()[0]
.aggregation_bits_base_mut()
.unwrap() = Bitfield::with_capacity(spec.target_committee_size).unwrap();
let mut ctxt = ConsensusContext::new(state.slot());
let result = process_operations::process_attestations(
@@ -501,7 +502,8 @@ async fn invalid_attestation_bad_signature() {
.clone()
.deconstruct()
.0;
head_block.to_mut().body_mut().attestations_mut()[0].signature = AggregateSignature::empty();
*head_block.to_mut().body_mut().attestations_mut()[0].signature_mut() =
AggregateSignature::empty();
let mut ctxt = ConsensusContext::new(state.slot());
let result = process_operations::process_attestations(
@@ -536,10 +538,10 @@ async fn invalid_attestation_included_too_early() {
.clone()
.deconstruct()
.0;
let new_attesation_slot = head_block.body().attestations()[0].data.slot
let new_attesation_slot = head_block.body().attestations()[0].data().slot
+ Slot::new(MainnetEthSpec::slots_per_epoch());
head_block.to_mut().body_mut().attestations_mut()[0]
.data
.data_mut()
.slot = new_attesation_slot;
let mut ctxt = ConsensusContext::new(state.slot());
@@ -579,10 +581,10 @@ async fn invalid_attestation_included_too_late() {
.clone()
.deconstruct()
.0;
let new_attesation_slot = head_block.body().attestations()[0].data.slot
let new_attesation_slot = head_block.body().attestations()[0].data().slot
- Slot::new(MainnetEthSpec::slots_per_epoch());
head_block.to_mut().body_mut().attestations_mut()[0]
.data
.data_mut()
.slot = new_attesation_slot;
let mut ctxt = ConsensusContext::new(state.slot());
@@ -620,7 +622,7 @@ async fn invalid_attestation_target_epoch_slot_mismatch() {
.deconstruct()
.0;
head_block.to_mut().body_mut().attestations_mut()[0]
.data
.data_mut()
.target
.epoch += Epoch::new(1);
@@ -699,7 +701,10 @@ async fn invalid_attester_slashing_1_invalid() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT).await;
let mut attester_slashing = harness.make_attester_slashing(vec![1, 2]);
attester_slashing.attestation_1.attesting_indices = VariableList::from(vec![2, 1]);
*attester_slashing
.attestation_1
.attesting_indices_base_mut()
.unwrap() = VariableList::from(vec![2, 1]);
let mut state = harness.get_current_state();
let mut ctxt = ConsensusContext::new(state.slot());
@@ -730,7 +735,10 @@ async fn invalid_attester_slashing_2_invalid() {
let harness = get_harness::<MainnetEthSpec>(EPOCH_OFFSET, VALIDATOR_COUNT).await;
let mut attester_slashing = harness.make_attester_slashing(vec![1, 2]);
attester_slashing.attestation_2.attesting_indices = VariableList::from(vec![2, 1]);
*attester_slashing
.attestation_2
.attesting_indices_base_mut()
.unwrap() = VariableList::from(vec![2, 1]);
let mut state = harness.get_current_state();
let mut ctxt = ConsensusContext::new(state.slot());