From 5f3da0732f076d62278f88f15b468c5012a21836 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 10 Mar 2019 08:31:40 +1100 Subject: [PATCH] Fix attestations bug in block builder. It was previously producing too many attestations in some scenarios. --- .../benching_utils/src/beacon_block_bencher.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/eth2/state_processing/benching_utils/src/beacon_block_bencher.rs b/eth2/state_processing/benching_utils/src/beacon_block_bencher.rs index 3eafdc0c9..46e822baa 100644 --- a/eth2/state_processing/benching_utils/src/beacon_block_bencher.rs +++ b/eth2/state_processing/benching_utils/src/beacon_block_bencher.rs @@ -92,18 +92,20 @@ impl BeaconBlockBencher { // - The slot is too old to be included in a block at this slot. // - The `MAX_ATTESTATIONS`. loop { - if attestations_added == spec.max_attestations { - break; - } if state.slot >= slot + spec.slots_per_epoch { break; } for (committee, shard) in state.get_crosslink_committees_at_slot(slot, spec)? { - committees.push((slot, committee.clone(), committee.clone(), *shard)) + if attestations_added >= spec.max_attestations { + break; + } + + committees.push((slot, committee.clone(), committee.clone(), *shard)); + + attestations_added += 1; } - attestations_added += 1; slot -= 1; }