mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-02 12:24:29 +00:00
Fix broken attestation verification test
This commit is contained in:
@@ -87,7 +87,7 @@ fn get_valid_unaggregated_attestation<T: BeaconChainTypes>(
|
|||||||
|
|
||||||
fn get_valid_aggregated_attestation<T: BeaconChainTypes>(
|
fn get_valid_aggregated_attestation<T: BeaconChainTypes>(
|
||||||
chain: &BeaconChain<T>,
|
chain: &BeaconChain<T>,
|
||||||
aggregate: Attestation<T::EthSpec>,
|
mut aggregate: Attestation<T::EthSpec>,
|
||||||
) -> (SignedAggregateAndProof<T::EthSpec>, usize, SecretKey) {
|
) -> (SignedAggregateAndProof<T::EthSpec>, usize, SecretKey) {
|
||||||
let state = &chain.head().expect("should get head").beacon_state;
|
let state = &chain.head().expect("should get head").beacon_state;
|
||||||
let current_slot = chain.slot().expect("should get slot");
|
let current_slot = chain.slot().expect("should get slot");
|
||||||
@@ -97,10 +97,11 @@ fn get_valid_aggregated_attestation<T: BeaconChainTypes>(
|
|||||||
.expect("should get committees");
|
.expect("should get committees");
|
||||||
let committee_len = committee.committee.len();
|
let committee_len = committee.committee.len();
|
||||||
|
|
||||||
let (aggregator_index, aggregator_sk) = committee
|
let (aggregator_committee_pos, aggregator_index, aggregator_sk) = committee
|
||||||
.committee
|
.committee
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|&val_index| {
|
.enumerate()
|
||||||
|
.find_map(|(committee_pos, &val_index)| {
|
||||||
let aggregator_sk = generate_deterministic_keypair(val_index).sk;
|
let aggregator_sk = generate_deterministic_keypair(val_index).sk;
|
||||||
|
|
||||||
let proof = SelectionProof::new::<T::EthSpec>(
|
let proof = SelectionProof::new::<T::EthSpec>(
|
||||||
@@ -112,13 +113,26 @@ fn get_valid_aggregated_attestation<T: BeaconChainTypes>(
|
|||||||
);
|
);
|
||||||
|
|
||||||
if proof.is_aggregator(committee_len, &chain.spec).unwrap() {
|
if proof.is_aggregator(committee_len, &chain.spec).unwrap() {
|
||||||
Some((val_index, aggregator_sk))
|
Some((committee_pos, val_index, aggregator_sk))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.expect("should find aggregator for committee");
|
.expect("should find aggregator for committee");
|
||||||
|
|
||||||
|
// FIXME(v0.12): this can be removed once the verification rules are updated for v0.12
|
||||||
|
// I needed to add it because the test only *happened* to work because aggregator and attester
|
||||||
|
// indices were the same before!
|
||||||
|
aggregate
|
||||||
|
.sign(
|
||||||
|
&aggregator_sk,
|
||||||
|
aggregator_committee_pos,
|
||||||
|
&state.fork,
|
||||||
|
chain.genesis_validators_root,
|
||||||
|
&chain.spec,
|
||||||
|
)
|
||||||
|
.expect("should sign attestation");
|
||||||
|
|
||||||
let signed_aggregate = SignedAggregateAndProof::from_aggregate(
|
let signed_aggregate = SignedAggregateAndProof::from_aggregate(
|
||||||
aggregator_index as u64,
|
aggregator_index as u64,
|
||||||
aggregate,
|
aggregate,
|
||||||
|
|||||||
Reference in New Issue
Block a user