diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index a23bcdc0b55..45857993342 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -121,10 +121,6 @@ lazy_static! { "beacon_block_production_slot_process_seconds", "Time taken to advance the state to the block production slot" ); - pub static ref BLOCK_PRODUCTION_UNAGGREGATED_TIMES: Result = try_create_histogram( - "beacon_block_production_unaggregated_seconds", - "Time taken to import the naive aggregation pool for block production" - ); pub static ref BLOCK_PRODUCTION_ATTESTATION_TIMES: Result = try_create_histogram( "beacon_block_production_attestation_seconds", "Time taken to pack attestations into a block" diff --git a/beacon_node/operation_pool/src/lib.rs b/beacon_node/operation_pool/src/lib.rs index 69bf838df54..33b03443e9a 100644 --- a/beacon_node/operation_pool/src/lib.rs +++ b/beacon_node/operation_pool/src/lib.rs @@ -319,13 +319,9 @@ impl OperationPool { // aggregate unaggregate attestations into the clique aggregates // if compatible if let Some(unaggregate_attestations) = unaggregate_attestations.get(data) { - for attestation in unaggregate_attestations.iter().filter(|indexed| { - validity_filter(&AttestationRef { - checkpoint: checkpoint_key, - data, - indexed, - }) - }) { + // No need to re-run the validity filter, as it has already succeeded for + // this attestation data. + for attestation in unaggregate_attestations { num_valid.fetch_add(1, Ordering::Relaxed); for clique_aggregate in &mut clique_aggregates { if clique_aggregate.signers_disjoint_from(attestation) { @@ -349,16 +345,18 @@ impl OperationPool { && !aggregate_attestations.contains_key(data) }) .for_each(|(data, unaggregates)| { - let mut valid_attestations = unaggregates.iter().filter(|indexed| { - validity_filter(&AttestationRef { + let mut unaggregates = unaggregates.iter(); + if let Some(att) = unaggregates.next() { + if !validity_filter(&AttestationRef { checkpoint: checkpoint_key, data, - indexed, - }) - }); - if let Some(att) = valid_attestations.next() { + indexed: att, + }) { + return; + } + let mut att = att.clone(); - valid_attestations.for_each(|valid_att| att.aggregate(valid_att)); + unaggregates.for_each(|valid_att| att.aggregate(valid_att)); cliques_from_aggregates.push((data, vec![att])) } });