Skip to content

Commit f39becd

Browse files
committed
added a couple of comments
1 parent a171c59 commit f39becd

File tree

1 file changed

+14
-6
lines changed
  • beacon_node/operation_pool/src

1 file changed

+14
-6
lines changed

beacon_node/operation_pool/src/lib.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ impl<T: EthSpec> OperationPool<T> {
242242
})
243243
}
244244

245+
/// Return a vector of aggregate/unaggregate attestations which are maximal cliques
246+
/// with resepct to the graph with attestations as vertices and an edge encoding
247+
/// compatibility for aggregation.
245248
#[allow(clippy::too_many_arguments)]
246249
fn get_clique_aggregate_attestations_for_epoch<'a>(
247250
&'a self,
@@ -274,10 +277,10 @@ impl<T: EthSpec> OperationPool<T> {
274277
.collect();
275278
*num_valid += aggregates.len() as i64;
276279

280+
// derive cliques for current attestation data
277281
let cliques = bron_kerbosch(&aggregates, is_compatible);
278282

279-
// This assumes that the values from bron_kerbosch are valid indices of
280-
// aggregates.
283+
// aggregate each cliques corresponding attestaiions
281284
let mut clique_aggregates = cliques.iter().map(|clique| {
282285
let mut res_att = aggregates[clique[0]].clone();
283286
for ind in clique.iter().skip(1) {
@@ -286,6 +289,8 @@ impl<T: EthSpec> OperationPool<T> {
286289
res_att
287290
});
288291

292+
// aggregate unaggregate attestations into the clique aggregates
293+
// if compatible
289294
if let Some(unaggregate_attestations) = unaggregate_attestations.get(&data) {
290295
for attestation in unaggregate_attestations.iter().filter(|indexed| {
291296
validity_filter(&AttestationRef {
@@ -309,6 +314,8 @@ impl<T: EthSpec> OperationPool<T> {
309314
cliqued_atts.extend(clique_aggregates.map(|indexed| (data, indexed)));
310315
}
311316
}
317+
// include aggregated attestations from unaggregated attestations whose
318+
// attestation data doesn't appear in aggregated_attestations
312319
for (data, attestations) in unaggregate_attestations {
313320
if data.slot + spec.min_attestation_inclusion_delay <= state.slot()
314321
&& state.slot() <= data.slot + T::slots_per_epoch()
@@ -368,7 +375,8 @@ impl<T: EthSpec> OperationPool<T> {
368375
let mut num_prev_valid = 0_i64;
369376
let mut num_curr_valid = 0_i64;
370377

371-
let prev_cliqued_atts = if prev_epoch_key != curr_epoch_key {
378+
// If we're in the genesis epoch, just use the current epoch attestations.
379+
let prev_epoch_cliqued_atts = if prev_epoch_key != curr_epoch_key {
372380
self.get_clique_aggregate_attestations_for_epoch(
373381
&prev_epoch_key,
374382
&*all_attestations,
@@ -381,7 +389,7 @@ impl<T: EthSpec> OperationPool<T> {
381389
vec![]
382390
};
383391

384-
let prev_epoch_cliqued_atts: Vec<AttMaxCover<T>> = prev_cliqued_atts
392+
let prev_epoch_cliqued_atts: Vec<AttMaxCover<T>> = prev_epoch_cliqued_atts
385393
.iter()
386394
.map(|(data, indexed)| AttestationRef {
387395
checkpoint: &prev_epoch_key,
@@ -393,7 +401,7 @@ impl<T: EthSpec> OperationPool<T> {
393401
})
394402
.collect();
395403

396-
let curr_cliqued_atts = self.get_clique_aggregate_attestations_for_epoch(
404+
let curr_epoch_cliqued_atts = self.get_clique_aggregate_attestations_for_epoch(
397405
&curr_epoch_key,
398406
&*all_attestations,
399407
state,
@@ -402,7 +410,7 @@ impl<T: EthSpec> OperationPool<T> {
402410
spec,
403411
);
404412

405-
let curr_epoch_cliqued_atts: Vec<AttMaxCover<T>> = curr_cliqued_atts
413+
let curr_epoch_cliqued_atts: Vec<AttMaxCover<T>> = curr_epoch_cliqued_atts
406414
.iter()
407415
.map(|(data, indexed)| AttestationRef {
408416
checkpoint: &prev_epoch_key,

0 commit comments

Comments
 (0)