mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Diff reduction in tests
This commit is contained in:
@@ -1354,36 +1354,25 @@ where
|
|||||||
let fork_name = self.spec.fork_name_at_slot::<E>(slot);
|
let fork_name = self.spec.fork_name_at_slot::<E>(slot);
|
||||||
|
|
||||||
let aggregate = if fork_name.electra_enabled() {
|
let aggregate = if fork_name.electra_enabled() {
|
||||||
self.chain
|
self.chain.get_aggregated_attestation_electra(
|
||||||
.get_aggregated_attestation_electra(
|
slot,
|
||||||
slot,
|
&attestation.data().tree_hash_root(),
|
||||||
&attestation.data().tree_hash_root(),
|
bc.index,
|
||||||
bc.index,
|
)
|
||||||
)
|
|
||||||
.unwrap()
|
|
||||||
.unwrap_or_else(|| {
|
|
||||||
committee_attestations.iter().skip(1).fold(
|
|
||||||
attestation.clone(),
|
|
||||||
|mut agg, (att, _)| {
|
|
||||||
agg.aggregate(att.to_ref());
|
|
||||||
agg
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
self.chain
|
self.chain
|
||||||
.get_aggregated_attestation_base(attestation.data())
|
.get_aggregated_attestation_base(attestation.data())
|
||||||
.unwrap()
|
}
|
||||||
.unwrap_or_else(|| {
|
.unwrap()
|
||||||
committee_attestations.iter().skip(1).fold(
|
.unwrap_or_else(|| {
|
||||||
attestation.clone(),
|
committee_attestations.iter().skip(1).fold(
|
||||||
|mut agg, (att, _)| {
|
attestation.clone(),
|
||||||
agg.aggregate(att.to_ref());
|
|mut agg, (att, _)| {
|
||||||
agg
|
agg.aggregate(att.to_ref());
|
||||||
},
|
agg
|
||||||
)
|
},
|
||||||
})
|
)
|
||||||
};
|
});
|
||||||
|
|
||||||
// If the chain is able to produce an aggregate, use that. Otherwise, build an
|
// If the chain is able to produce an aggregate, use that. Otherwise, build an
|
||||||
// aggregate locally.
|
// aggregate locally.
|
||||||
@@ -1518,40 +1507,29 @@ where
|
|||||||
|
|
||||||
let fork_name = self.spec.fork_name_at_slot::<E>(Slot::new(0));
|
let fork_name = self.spec.fork_name_at_slot::<E>(Slot::new(0));
|
||||||
|
|
||||||
|
let data = AttestationData {
|
||||||
|
slot: Slot::new(0),
|
||||||
|
index: 0,
|
||||||
|
beacon_block_root: Hash256::zero(),
|
||||||
|
target: Checkpoint {
|
||||||
|
root: Hash256::zero(),
|
||||||
|
epoch: target1.unwrap_or(fork.epoch),
|
||||||
|
},
|
||||||
|
source: Checkpoint {
|
||||||
|
root: Hash256::zero(),
|
||||||
|
epoch: source1.unwrap_or(Epoch::new(0)),
|
||||||
|
},
|
||||||
|
};
|
||||||
let mut attestation_1 = if fork_name.electra_enabled() {
|
let mut attestation_1 = if fork_name.electra_enabled() {
|
||||||
IndexedAttestation::Electra(IndexedAttestationElectra {
|
IndexedAttestation::Electra(IndexedAttestationElectra {
|
||||||
attesting_indices: VariableList::new(validator_indices).unwrap(),
|
attesting_indices: VariableList::new(validator_indices).unwrap(),
|
||||||
data: AttestationData {
|
data,
|
||||||
slot: Slot::new(0),
|
|
||||||
index: 0,
|
|
||||||
beacon_block_root: Hash256::zero(),
|
|
||||||
target: Checkpoint {
|
|
||||||
root: Hash256::zero(),
|
|
||||||
epoch: target1.unwrap_or(fork.epoch),
|
|
||||||
},
|
|
||||||
source: Checkpoint {
|
|
||||||
root: Hash256::zero(),
|
|
||||||
epoch: source1.unwrap_or(Epoch::new(0)),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
signature: AggregateSignature::infinity(),
|
signature: AggregateSignature::infinity(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
IndexedAttestation::Base(IndexedAttestationBase {
|
IndexedAttestation::Base(IndexedAttestationBase {
|
||||||
attesting_indices: VariableList::new(validator_indices).unwrap(),
|
attesting_indices: VariableList::new(validator_indices).unwrap(),
|
||||||
data: AttestationData {
|
data,
|
||||||
slot: Slot::new(0),
|
|
||||||
index: 0,
|
|
||||||
beacon_block_root: Hash256::zero(),
|
|
||||||
target: Checkpoint {
|
|
||||||
root: Hash256::zero(),
|
|
||||||
epoch: target1.unwrap_or(fork.epoch),
|
|
||||||
},
|
|
||||||
source: Checkpoint {
|
|
||||||
root: Hash256::zero(),
|
|
||||||
epoch: source1.unwrap_or(Epoch::new(0)),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
signature: AggregateSignature::infinity(),
|
signature: AggregateSignature::infinity(),
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -190,30 +190,17 @@ async fn produces_attestations() {
|
|||||||
.produce_unaggregated_attestation(slot, index)
|
.produce_unaggregated_attestation(slot, index)
|
||||||
.expect("should produce attestation");
|
.expect("should produce attestation");
|
||||||
|
|
||||||
match &attestation {
|
let (aggregation_bits_len, aggregation_bits_zero) = match &attestation {
|
||||||
Attestation::Base(att) => {
|
Attestation::Base(att) => {
|
||||||
assert_eq!(
|
(att.aggregation_bits.len(), att.aggregation_bits.is_zero())
|
||||||
att.aggregation_bits.len(),
|
|
||||||
committee_len,
|
|
||||||
"bad committee len"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
att.aggregation_bits.is_zero(),
|
|
||||||
"some committee bits are set"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
Attestation::Electra(att) => {
|
Attestation::Electra(att) => {
|
||||||
assert_eq!(
|
(att.aggregation_bits.len(), att.aggregation_bits.is_zero())
|
||||||
att.aggregation_bits.len(),
|
|
||||||
committee_len,
|
|
||||||
"bad committee len"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
att.aggregation_bits.is_zero(),
|
|
||||||
"some committee bits are set"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
assert_eq!(aggregation_bits_len, committee_len, "bad committee len");
|
||||||
|
assert!(aggregation_bits_zero, "some committee bits are set");
|
||||||
|
|
||||||
let data = attestation.data();
|
let data = attestation.data();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
Reference in New Issue
Block a user