mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-20 13:24:44 +00:00
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:
@@ -1,7 +1,8 @@
|
||||
use std::collections::HashSet;
|
||||
use types::{
|
||||
AggregateSignature, AttestationData, AttesterSlashing, BeaconBlockHeader, Checkpoint, Epoch,
|
||||
Hash256, IndexedAttestation, MainnetEthSpec, Signature, SignedBeaconBlockHeader, Slot,
|
||||
indexed_attestation::IndexedAttestationBase, AggregateSignature, AttestationData,
|
||||
AttesterSlashing, BeaconBlockHeader, Checkpoint, Epoch, Hash256, IndexedAttestation,
|
||||
MainnetEthSpec, Signature, SignedBeaconBlockHeader, Slot,
|
||||
};
|
||||
|
||||
pub type E = MainnetEthSpec;
|
||||
@@ -12,7 +13,8 @@ pub fn indexed_att(
|
||||
target_epoch: u64,
|
||||
target_root: u64,
|
||||
) -> IndexedAttestation<E> {
|
||||
IndexedAttestation {
|
||||
// TODO(electra) make fork-agnostic
|
||||
IndexedAttestation::Base(IndexedAttestationBase {
|
||||
attesting_indices: attesting_indices.as_ref().to_vec().into(),
|
||||
data: AttestationData {
|
||||
slot: Slot::new(0),
|
||||
@@ -28,7 +30,7 @@ pub fn indexed_att(
|
||||
},
|
||||
},
|
||||
signature: AggregateSignature::empty(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn att_slashing(
|
||||
@@ -66,7 +68,9 @@ pub fn slashed_validators_from_slashings(slashings: &HashSet<AttesterSlashing<E>
|
||||
"invalid slashing: {:#?}",
|
||||
slashing
|
||||
);
|
||||
hashset_intersection(&att1.attesting_indices, &att2.attesting_indices)
|
||||
let attesting_indices_1 = att1.attesting_indices_to_vec();
|
||||
let attesting_indices_2 = att2.attesting_indices_to_vec();
|
||||
hashset_intersection(&attesting_indices_1, &attesting_indices_2)
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
@@ -82,10 +86,14 @@ pub fn slashed_validators_from_attestations(
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO(electra) in a nested loop, copying to vecs feels bad
|
||||
let attesting_indices_1 = att1.attesting_indices_to_vec();
|
||||
let attesting_indices_2 = att2.attesting_indices_to_vec();
|
||||
|
||||
if att1.is_double_vote(att2) || att1.is_surround_vote(att2) {
|
||||
slashed_validators.extend(hashset_intersection(
|
||||
&att1.attesting_indices,
|
||||
&att2.attesting_indices,
|
||||
&attesting_indices_1,
|
||||
&attesting_indices_2,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user