EIP7549 get_attestation_indices (#5657)

* get attesting indices electra impl

* fmt

* get tests to pass

* fmt

* fix some beacon chain tests

* fmt

* fix slasher test

* fmt got me again

* fix more tests

* fix tests
This commit is contained in:
Eitan Seri-Levi
2024-05-08 09:32:44 -07:00
committed by GitHub
parent 2c2e44c4ed
commit 90179d4a88
33 changed files with 844 additions and 319 deletions

View File

@@ -1032,21 +1032,40 @@ where
*state.get_block_root(target_slot)?
};
// TODO(electra) make test fork-agnostic
Ok(Attestation::Base(AttestationBase {
aggregation_bits: BitList::with_capacity(committee_len)?,
data: AttestationData {
slot,
index,
beacon_block_root,
source: state.current_justified_checkpoint(),
target: Checkpoint {
epoch,
root: target_root,
if self.spec.fork_name_at_slot::<E>(slot) >= ForkName::Electra {
let mut committee_bits = BitVector::default();
committee_bits.set(index as usize, true)?;
Ok(Attestation::Electra(AttestationElectra {
aggregation_bits: BitList::with_capacity(committee_len)?,
committee_bits,
data: AttestationData {
slot,
index: 0u64,
beacon_block_root,
source: state.current_justified_checkpoint(),
target: Checkpoint {
epoch,
root: target_root,
},
},
},
signature: AggregateSignature::empty(),
}))
signature: AggregateSignature::empty(),
}))
} else {
Ok(Attestation::Base(AttestationBase {
aggregation_bits: BitList::with_capacity(committee_len)?,
data: AttestationData {
slot,
index,
beacon_block_root,
source: state.current_justified_checkpoint(),
target: Checkpoint {
epoch,
root: target_root,
},
},
signature: AggregateSignature::empty(),
}))
}
}
/// A list of attestations for each committee for the given slot.
@@ -1121,11 +1140,14 @@ where
)
.unwrap();
attestation
.aggregation_bits_base_mut()
.unwrap()
.set(i, true)
.unwrap();
match attestation {
Attestation::Base(ref mut att) => {
att.aggregation_bits.set(i, true).unwrap()
}
Attestation::Electra(ref mut att) => {
att.aggregation_bits.set(i, true).unwrap()
}
}
*attestation.signature_mut() = {
let domain = self.spec.get_domain(
@@ -1366,7 +1388,7 @@ where
let signed_aggregate = SignedAggregateAndProof::from_aggregate(
aggregator_index as u64,
aggregate,
aggregate.to_ref(),
None,
&self.validator_keypairs[aggregator_index].sk,
&fork,