Skip to content

Commit

Permalink
Don't re-run validity filter
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Nov 3, 2023
1 parent fdee0a0 commit b262f27
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
4 changes: 0 additions & 4 deletions beacon_node/beacon_chain/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Histogram> = 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<Histogram> = try_create_histogram(
"beacon_block_production_attestation_seconds",
"Time taken to pack attestations into a block"
Expand Down
26 changes: 12 additions & 14 deletions beacon_node/operation_pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,9 @@ impl<T: EthSpec> OperationPool<T> {
// 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) {
Expand All @@ -349,16 +345,18 @@ impl<T: EthSpec> OperationPool<T> {
&& !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]))
}
});
Expand Down

0 comments on commit b262f27

Please sign in to comment.