@@ -242,6 +242,9 @@ impl<T: EthSpec> OperationPool<T> {
242
242
} )
243
243
}
244
244
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.
245
248
#[ allow( clippy:: too_many_arguments) ]
246
249
fn get_clique_aggregate_attestations_for_epoch < ' a > (
247
250
& ' a self ,
@@ -274,10 +277,10 @@ impl<T: EthSpec> OperationPool<T> {
274
277
. collect ( ) ;
275
278
* num_valid += aggregates. len ( ) as i64 ;
276
279
280
+ // derive cliques for current attestation data
277
281
let cliques = bron_kerbosch ( & aggregates, is_compatible) ;
278
282
279
- // This assumes that the values from bron_kerbosch are valid indices of
280
- // aggregates.
283
+ // aggregate each cliques corresponding attestaiions
281
284
let mut clique_aggregates = cliques. iter ( ) . map ( |clique| {
282
285
let mut res_att = aggregates[ clique[ 0 ] ] . clone ( ) ;
283
286
for ind in clique. iter ( ) . skip ( 1 ) {
@@ -286,6 +289,8 @@ impl<T: EthSpec> OperationPool<T> {
286
289
res_att
287
290
} ) ;
288
291
292
+ // aggregate unaggregate attestations into the clique aggregates
293
+ // if compatible
289
294
if let Some ( unaggregate_attestations) = unaggregate_attestations. get ( & data) {
290
295
for attestation in unaggregate_attestations. iter ( ) . filter ( |indexed| {
291
296
validity_filter ( & AttestationRef {
@@ -309,6 +314,8 @@ impl<T: EthSpec> OperationPool<T> {
309
314
cliqued_atts. extend ( clique_aggregates. map ( |indexed| ( data, indexed) ) ) ;
310
315
}
311
316
}
317
+ // include aggregated attestations from unaggregated attestations whose
318
+ // attestation data doesn't appear in aggregated_attestations
312
319
for ( data, attestations) in unaggregate_attestations {
313
320
if data. slot + spec. min_attestation_inclusion_delay <= state. slot ( )
314
321
&& state. slot ( ) <= data. slot + T :: slots_per_epoch ( )
@@ -368,7 +375,8 @@ impl<T: EthSpec> OperationPool<T> {
368
375
let mut num_prev_valid = 0_i64 ;
369
376
let mut num_curr_valid = 0_i64 ;
370
377
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 {
372
380
self . get_clique_aggregate_attestations_for_epoch (
373
381
& prev_epoch_key,
374
382
& * all_attestations,
@@ -381,7 +389,7 @@ impl<T: EthSpec> OperationPool<T> {
381
389
vec ! [ ]
382
390
} ;
383
391
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
385
393
. iter ( )
386
394
. map ( |( data, indexed) | AttestationRef {
387
395
checkpoint : & prev_epoch_key,
@@ -393,7 +401,7 @@ impl<T: EthSpec> OperationPool<T> {
393
401
} )
394
402
. collect ( ) ;
395
403
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 (
397
405
& curr_epoch_key,
398
406
& * all_attestations,
399
407
state,
@@ -402,7 +410,7 @@ impl<T: EthSpec> OperationPool<T> {
402
410
spec,
403
411
) ;
404
412
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
406
414
. iter ( )
407
415
. map ( |( data, indexed) | AttestationRef {
408
416
checkpoint : & prev_epoch_key,
0 commit comments