Skip to content

Commit e2c6ff8

Browse files
author
Mdominykas
committed
Added sort to greedy attestation packing
1 parent a8f4cf2 commit e2c6ff8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

operation_pools/src/attestation_agg_pool/attestation_packer.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ impl<P: Preset> AttestationPacker<P> {
138138
// - <https://en.wikipedia.org/wiki/Set_packing>
139139
// - <https://cstheory.stackexchange.com/questions/21448/set-packing-with-maximum-coverage-objective>
140140
// We use a greedy algorithm.
141+
142+
candidates.sort_by_cached_key(|attestation| {
143+
self.added_weight(
144+
attestation,
145+
&previous_epoch_participation,
146+
&current_epoch_participation,
147+
)
148+
.ok()
149+
});
150+
141151
let attestations = core::iter::from_fn(move || {
142152
let attestation = candidates.pop()?;
143153

0 commit comments

Comments
 (0)