mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
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:
@@ -80,7 +80,7 @@ impl<E: EthSpec> IndexedAttesterRecord<E> {
|
||||
|
||||
#[derive(Debug, Clone, Encode, Decode, TreeHash)]
|
||||
struct IndexedAttestationHeader<E: EthSpec> {
|
||||
pub attesting_indices: VariableList<u64, E::MaxValidatorsPerCommitteePerSlot>,
|
||||
pub attesting_indices: VariableList<u64, E::MaxValidatorsPerSlot>,
|
||||
pub data_root: Hash256,
|
||||
pub signature: AggregateSignature,
|
||||
}
|
||||
@@ -106,15 +106,15 @@ impl<E: EthSpec> From<IndexedAttestation<E>> for AttesterRecord {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::test_utils::indexed_att;
|
||||
use crate::test_utils::indexed_att_electra;
|
||||
|
||||
// Check correctness of fast hashing
|
||||
#[test]
|
||||
fn fast_hash() {
|
||||
let data = vec![
|
||||
indexed_att(vec![], 0, 0, 0),
|
||||
indexed_att(vec![1, 2, 3], 12, 14, 1),
|
||||
indexed_att(vec![4], 0, 5, u64::MAX),
|
||||
indexed_att_electra(vec![], 0, 0, 0),
|
||||
indexed_att_electra(vec![1, 2, 3], 12, 14, 1),
|
||||
indexed_att_electra(vec![4], 0, 5, u64::MAX),
|
||||
];
|
||||
for att in data {
|
||||
assert_eq!(
|
||||
|
||||
@@ -1,12 +1,38 @@
|
||||
use std::collections::HashSet;
|
||||
use types::{
|
||||
indexed_attestation::IndexedAttestationBase, AggregateSignature, AttestationData,
|
||||
AttesterSlashing, AttesterSlashingBase, AttesterSlashingElectra, BeaconBlockHeader, Checkpoint,
|
||||
Epoch, Hash256, IndexedAttestation, MainnetEthSpec, Signature, SignedBeaconBlockHeader, Slot,
|
||||
indexed_attestation::{IndexedAttestationBase, IndexedAttestationElectra},
|
||||
AggregateSignature, AttestationData, AttesterSlashing, AttesterSlashingBase,
|
||||
AttesterSlashingElectra, BeaconBlockHeader, Checkpoint, Epoch, Hash256, IndexedAttestation,
|
||||
MainnetEthSpec, Signature, SignedBeaconBlockHeader, Slot,
|
||||
};
|
||||
|
||||
pub type E = MainnetEthSpec;
|
||||
|
||||
pub fn indexed_att_electra(
|
||||
attesting_indices: impl AsRef<[u64]>,
|
||||
source_epoch: u64,
|
||||
target_epoch: u64,
|
||||
target_root: u64,
|
||||
) -> IndexedAttestation<E> {
|
||||
IndexedAttestation::Electra(IndexedAttestationElectra {
|
||||
attesting_indices: attesting_indices.as_ref().to_vec().into(),
|
||||
data: AttestationData {
|
||||
slot: Slot::new(0),
|
||||
index: 0,
|
||||
beacon_block_root: Hash256::zero(),
|
||||
source: Checkpoint {
|
||||
epoch: Epoch::new(source_epoch),
|
||||
root: Hash256::from_low_u64_be(0),
|
||||
},
|
||||
target: Checkpoint {
|
||||
epoch: Epoch::new(target_epoch),
|
||||
root: Hash256::from_low_u64_be(target_root),
|
||||
},
|
||||
},
|
||||
signature: AggregateSignature::empty(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn indexed_att(
|
||||
attesting_indices: impl AsRef<[u64]>,
|
||||
source_epoch: u64,
|
||||
|
||||
Reference in New Issue
Block a user