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

@@ -435,7 +435,7 @@ impl ForkChoiceTest {
let validator_committee_index = 0;
let validator_index = *head
.beacon_state
.get_beacon_committee(current_slot, attestation.data.index)
.get_beacon_committee(current_slot, attestation.data().index)
.expect("should get committees")
.committee
.get(validator_committee_index)
@@ -831,7 +831,7 @@ async fn invalid_attestation_empty_bitfield() {
.apply_attestation_to_chain(
MutationDelay::NoDelay,
|attestation, _| {
attestation.attesting_indices = vec![].into();
*attestation.attesting_indices_base_mut().unwrap() = vec![].into();
},
|result| {
assert_invalid_attestation!(result, InvalidAttestation::EmptyAggregationBitfield)
@@ -853,7 +853,7 @@ async fn invalid_attestation_future_epoch() {
.apply_attestation_to_chain(
MutationDelay::NoDelay,
|attestation, _| {
attestation.data.target.epoch = Epoch::new(2);
attestation.data_mut().target.epoch = Epoch::new(2);
},
|result| {
assert_invalid_attestation!(
@@ -879,7 +879,7 @@ async fn invalid_attestation_past_epoch() {
.apply_attestation_to_chain(
MutationDelay::NoDelay,
|attestation, _| {
attestation.data.target.epoch = Epoch::new(0);
attestation.data_mut().target.epoch = Epoch::new(0);
},
|result| {
assert_invalid_attestation!(
@@ -903,7 +903,7 @@ async fn invalid_attestation_target_epoch() {
.apply_attestation_to_chain(
MutationDelay::NoDelay,
|attestation, _| {
attestation.data.slot = Slot::new(1);
attestation.data_mut().slot = Slot::new(1);
},
|result| {
assert_invalid_attestation!(
@@ -929,7 +929,7 @@ async fn invalid_attestation_unknown_target_root() {
.apply_attestation_to_chain(
MutationDelay::NoDelay,
|attestation, _| {
attestation.data.target.root = junk;
attestation.data_mut().target.root = junk;
},
|result| {
assert_invalid_attestation!(
@@ -955,7 +955,7 @@ async fn invalid_attestation_unknown_beacon_block_root() {
.apply_attestation_to_chain(
MutationDelay::NoDelay,
|attestation, _| {
attestation.data.beacon_block_root = junk;
attestation.data_mut().beacon_block_root = junk;
},
|result| {
assert_invalid_attestation!(
@@ -979,7 +979,7 @@ async fn invalid_attestation_future_block() {
.apply_attestation_to_chain(
MutationDelay::Blocks(1),
|attestation, chain| {
attestation.data.beacon_block_root = chain
attestation.data_mut().beacon_block_root = chain
.block_at_slot(chain.slot().unwrap(), WhenSlotSkipped::Prev)
.unwrap()
.unwrap()
@@ -1010,13 +1010,13 @@ async fn invalid_attestation_inconsistent_ffg_vote() {
.apply_attestation_to_chain(
MutationDelay::NoDelay,
|attestation, chain| {
attestation.data.target.root = chain
attestation.data_mut().target.root = chain
.block_at_slot(Slot::new(1), WhenSlotSkipped::Prev)
.unwrap()
.unwrap()
.canonical_root();
*attestation_opt.lock().unwrap() = Some(attestation.data.target.root);
*attestation_opt.lock().unwrap() = Some(attestation.data().target.root);
*local_opt.lock().unwrap() = Some(
chain
.block_at_slot(Slot::new(0), WhenSlotSkipped::Prev)
@@ -1069,8 +1069,8 @@ async fn valid_attestation_skip_across_epoch() {
MutationDelay::NoDelay,
|attestation, _chain| {
assert_eq!(
attestation.data.target.root,
attestation.data.beacon_block_root
attestation.data().target.root,
attestation.data().beacon_block_root
)
},
|result| result.unwrap(),