Skip to content

Commit 58d1a1f

Browse files
committed
Remove disable-committee-aware-packing flag
1 parent ff6e27c commit 58d1a1f

File tree

5 files changed

+3
-238
lines changed

5 files changed

+3
-238
lines changed

beacon-chain/rpc/prysm/v1alpha1/validator/proposer_attestations.go

-71
Original file line numberDiff line numberDiff line change
@@ -188,73 +188,6 @@ func (a proposerAtts) filter(ctx context.Context, st state.BeaconState) (propose
188188
return validAtts, invalidAtts
189189
}
190190

191-
// sortByProfitabilityUsingMaxCover orders attestations by highest slot and by highest aggregation bit count.
192-
// Duplicate bits are counted only once, using max-cover algorithm.
193-
func (a proposerAtts) sortByProfitabilityUsingMaxCover() (proposerAtts, error) {
194-
// Separate attestations by slot, as slot number takes higher precedence when sorting.
195-
var slots []primitives.Slot
196-
attsBySlot := map[primitives.Slot]proposerAtts{}
197-
for _, att := range a {
198-
if _, ok := attsBySlot[att.GetData().Slot]; !ok {
199-
slots = append(slots, att.GetData().Slot)
200-
}
201-
attsBySlot[att.GetData().Slot] = append(attsBySlot[att.GetData().Slot], att)
202-
}
203-
204-
selectAtts := func(atts proposerAtts) (proposerAtts, error) {
205-
if len(atts) < 2 {
206-
return atts, nil
207-
}
208-
candidates := make([]*bitfield.Bitlist64, len(atts))
209-
for i := 0; i < len(atts); i++ {
210-
var err error
211-
candidates[i], err = atts[i].GetAggregationBits().ToBitlist64()
212-
if err != nil {
213-
return nil, err
214-
}
215-
}
216-
// Add selected candidates on top, those that are not selected - append at bottom.
217-
selectedKeys, _, err := aggregation.MaxCover(candidates, len(candidates), true /* allowOverlaps */)
218-
if err == nil {
219-
// Pick selected attestations first, leftover attestations will be appended at the end.
220-
// Both lists will be sorted by number of bits set.
221-
selectedAtts := make(proposerAtts, selectedKeys.Count())
222-
leftoverAtts := make(proposerAtts, selectedKeys.Not().Count())
223-
for i, key := range selectedKeys.BitIndices() {
224-
selectedAtts[i] = atts[key]
225-
}
226-
for i, key := range selectedKeys.Not().BitIndices() {
227-
leftoverAtts[i] = atts[key]
228-
}
229-
sort.Slice(selectedAtts, func(i, j int) bool {
230-
return selectedAtts[i].GetAggregationBits().Count() > selectedAtts[j].GetAggregationBits().Count()
231-
})
232-
sort.Slice(leftoverAtts, func(i, j int) bool {
233-
return leftoverAtts[i].GetAggregationBits().Count() > leftoverAtts[j].GetAggregationBits().Count()
234-
})
235-
return append(selectedAtts, leftoverAtts...), nil
236-
}
237-
return atts, nil
238-
}
239-
240-
// Select attestations. Slots are sorted from higher to lower at this point. Within slots attestations
241-
// are sorted to maximize profitability (greedily selected, with previous attestations' bits
242-
// evaluated before including any new attestation).
243-
var sortedAtts proposerAtts
244-
sort.Slice(slots, func(i, j int) bool {
245-
return slots[i] > slots[j]
246-
})
247-
for _, slot := range slots {
248-
selected, err := selectAtts(attsBySlot[slot])
249-
if err != nil {
250-
return nil, err
251-
}
252-
sortedAtts = append(sortedAtts, selected...)
253-
}
254-
255-
return sortedAtts, nil
256-
}
257-
258191
// sort attestations as follows:
259192
//
260193
// - all attestations selected by max-cover are taken, leftover attestations are discarded
@@ -266,10 +199,6 @@ func (a proposerAtts) sort() (proposerAtts, error) {
266199
if len(a) < 2 {
267200
return a, nil
268201
}
269-
270-
if features.Get().DisableCommitteeAwarePacking {
271-
return a.sortByProfitabilityUsingMaxCover()
272-
}
273202
return a.sortBySlotAndCommittee()
274203
}
275204

beacon-chain/rpc/prysm/v1alpha1/validator/proposer_attestations_test.go

-157
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers"
1515
"github.com/prysmaticlabs/prysm/v5/beacon-chain/operations/attestations"
1616
"github.com/prysmaticlabs/prysm/v5/beacon-chain/operations/attestations/mock"
17-
"github.com/prysmaticlabs/prysm/v5/config/features"
1817
"github.com/prysmaticlabs/prysm/v5/config/params"
1918
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
2019
"github.com/prysmaticlabs/prysm/v5/crypto/bls/blst"
@@ -26,162 +25,6 @@ import (
2625
"github.com/prysmaticlabs/prysm/v5/time/slots"
2726
)
2827

29-
func TestProposer_ProposerAtts_sort(t *testing.T) {
30-
feat := features.Get()
31-
feat.DisableCommitteeAwarePacking = true
32-
reset := features.InitWithReset(feat)
33-
defer reset()
34-
35-
type testData struct {
36-
slot primitives.Slot
37-
bits bitfield.Bitlist
38-
}
39-
getAtts := func(data []testData) proposerAtts {
40-
var atts proposerAtts
41-
for _, att := range data {
42-
atts = append(atts, util.HydrateAttestation(&ethpb.Attestation{
43-
Data: &ethpb.AttestationData{Slot: att.slot}, AggregationBits: att.bits}))
44-
}
45-
return atts
46-
}
47-
48-
t.Run("no atts", func(t *testing.T) {
49-
atts := getAtts([]testData{})
50-
want := getAtts([]testData{})
51-
atts, err := atts.sort()
52-
if err != nil {
53-
t.Error(err)
54-
}
55-
require.DeepEqual(t, want, atts)
56-
})
57-
58-
t.Run("single att", func(t *testing.T) {
59-
atts := getAtts([]testData{
60-
{4, bitfield.Bitlist{0b11100000, 0b1}},
61-
})
62-
want := getAtts([]testData{
63-
{4, bitfield.Bitlist{0b11100000, 0b1}},
64-
})
65-
atts, err := atts.sort()
66-
if err != nil {
67-
t.Error(err)
68-
}
69-
require.DeepEqual(t, want, atts)
70-
})
71-
72-
t.Run("single att per slot", func(t *testing.T) {
73-
atts := getAtts([]testData{
74-
{1, bitfield.Bitlist{0b11000000, 0b1}},
75-
{4, bitfield.Bitlist{0b11100000, 0b1}},
76-
})
77-
want := getAtts([]testData{
78-
{4, bitfield.Bitlist{0b11100000, 0b1}},
79-
{1, bitfield.Bitlist{0b11000000, 0b1}},
80-
})
81-
atts, err := atts.sort()
82-
if err != nil {
83-
t.Error(err)
84-
}
85-
require.DeepEqual(t, want, atts)
86-
})
87-
88-
t.Run("two atts on one of the slots", func(t *testing.T) {
89-
atts := getAtts([]testData{
90-
{1, bitfield.Bitlist{0b11000000, 0b1}},
91-
{4, bitfield.Bitlist{0b11100000, 0b1}},
92-
{4, bitfield.Bitlist{0b11110000, 0b1}},
93-
})
94-
want := getAtts([]testData{
95-
{4, bitfield.Bitlist{0b11110000, 0b1}},
96-
{4, bitfield.Bitlist{0b11100000, 0b1}},
97-
{1, bitfield.Bitlist{0b11000000, 0b1}},
98-
})
99-
atts, err := atts.sort()
100-
if err != nil {
101-
t.Error(err)
102-
}
103-
require.DeepEqual(t, want, atts)
104-
})
105-
106-
t.Run("compare to native sort", func(t *testing.T) {
107-
// The max-cover based approach will select 0b00001100 instead, despite lower bit count
108-
// (since it has two new/unknown bits).
109-
t.Run("max-cover", func(t *testing.T) {
110-
atts := getAtts([]testData{
111-
{1, bitfield.Bitlist{0b11000011, 0b1}},
112-
{1, bitfield.Bitlist{0b11001000, 0b1}},
113-
{1, bitfield.Bitlist{0b00001100, 0b1}},
114-
})
115-
want := getAtts([]testData{
116-
{1, bitfield.Bitlist{0b11000011, 0b1}},
117-
{1, bitfield.Bitlist{0b00001100, 0b1}},
118-
{1, bitfield.Bitlist{0b11001000, 0b1}},
119-
})
120-
atts, err := atts.sort()
121-
if err != nil {
122-
t.Error(err)
123-
}
124-
require.DeepEqual(t, want, atts)
125-
})
126-
})
127-
128-
t.Run("multiple slots", func(t *testing.T) {
129-
atts := getAtts([]testData{
130-
{2, bitfield.Bitlist{0b11100000, 0b1}},
131-
{4, bitfield.Bitlist{0b11100000, 0b1}},
132-
{1, bitfield.Bitlist{0b11000000, 0b1}},
133-
{4, bitfield.Bitlist{0b11110000, 0b1}},
134-
{1, bitfield.Bitlist{0b11100000, 0b1}},
135-
{3, bitfield.Bitlist{0b11000000, 0b1}},
136-
})
137-
want := getAtts([]testData{
138-
{4, bitfield.Bitlist{0b11110000, 0b1}},
139-
{4, bitfield.Bitlist{0b11100000, 0b1}},
140-
{3, bitfield.Bitlist{0b11000000, 0b1}},
141-
{2, bitfield.Bitlist{0b11100000, 0b1}},
142-
{1, bitfield.Bitlist{0b11100000, 0b1}},
143-
{1, bitfield.Bitlist{0b11000000, 0b1}},
144-
})
145-
atts, err := atts.sort()
146-
if err != nil {
147-
t.Error(err)
148-
}
149-
require.DeepEqual(t, want, atts)
150-
})
151-
152-
t.Run("follows max-cover", func(t *testing.T) {
153-
// Items at slot 4, must be first split into two lists by max-cover, with
154-
// 0b10000011 scoring higher (as it provides more info in addition to already selected
155-
// attestations) than 0b11100001 (despite naive bit count suggesting otherwise). Then,
156-
// both selected and non-selected attestations must be additionally sorted by bit count.
157-
atts := getAtts([]testData{
158-
{4, bitfield.Bitlist{0b00000001, 0b1}},
159-
{4, bitfield.Bitlist{0b11100001, 0b1}},
160-
{1, bitfield.Bitlist{0b11000000, 0b1}},
161-
{2, bitfield.Bitlist{0b11100000, 0b1}},
162-
{4, bitfield.Bitlist{0b10000011, 0b1}},
163-
{4, bitfield.Bitlist{0b11111000, 0b1}},
164-
{1, bitfield.Bitlist{0b11100000, 0b1}},
165-
{3, bitfield.Bitlist{0b11000000, 0b1}},
166-
})
167-
want := getAtts([]testData{
168-
{4, bitfield.Bitlist{0b11111000, 0b1}},
169-
{4, bitfield.Bitlist{0b10000011, 0b1}},
170-
{4, bitfield.Bitlist{0b11100001, 0b1}},
171-
{4, bitfield.Bitlist{0b00000001, 0b1}},
172-
{3, bitfield.Bitlist{0b11000000, 0b1}},
173-
{2, bitfield.Bitlist{0b11100000, 0b1}},
174-
{1, bitfield.Bitlist{0b11100000, 0b1}},
175-
{1, bitfield.Bitlist{0b11000000, 0b1}},
176-
})
177-
atts, err := atts.sort()
178-
if err != nil {
179-
t.Error(err)
180-
}
181-
require.DeepEqual(t, want, atts)
182-
})
183-
}
184-
18528
func TestProposer_ProposerAtts_committeeAwareSort(t *testing.T) {
18629
type testData struct {
18730
slot primitives.Slot
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Removed
2+
3+
- Remove `disable-committee-aware-packing` flag.

config/features/config.go

-5
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ type Flags struct {
4949
EnableDoppelGanger bool // EnableDoppelGanger enables doppelganger protection on startup for the validator.
5050
EnableHistoricalSpaceRepresentation bool // EnableHistoricalSpaceRepresentation enables the saving of registry validators in separate buckets to save space
5151
EnableBeaconRESTApi bool // EnableBeaconRESTApi enables experimental usage of the beacon REST API by the validator when querying a beacon node
52-
DisableCommitteeAwarePacking bool // DisableCommitteeAwarePacking changes the attestation packing algorithm to one that is not aware of attesting committees.
5352
EnableExperimentalAttestationPool bool // EnableExperimentalAttestationPool enables an experimental attestation pool design.
5453
// Logging related toggles.
5554
DisableGRPCConnectionLogs bool // Disables logging when a new grpc client has connected.
@@ -267,10 +266,6 @@ func ConfigureBeaconChain(ctx *cli.Context) error {
267266
logDisabled(DisableQUIC)
268267
cfg.EnableQUIC = false
269268
}
270-
if ctx.IsSet(DisableCommitteeAwarePacking.Name) {
271-
logEnabled(DisableCommitteeAwarePacking)
272-
cfg.DisableCommitteeAwarePacking = true
273-
}
274269
if ctx.IsSet(EnableDiscoveryReboot.Name) {
275270
logEnabled(EnableDiscoveryReboot)
276271
cfg.EnableDiscoveryReboot = true

config/features/flags.go

-5
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ var (
167167
Name: "disable-quic",
168168
Usage: "Disables connecting using the QUIC protocol with peers.",
169169
}
170-
DisableCommitteeAwarePacking = &cli.BoolFlag{
171-
Name: "disable-committee-aware-packing",
172-
Usage: "Changes the attestation packing algorithm to one that is not aware of attesting committees.",
173-
}
174170
EnableDiscoveryReboot = &cli.BoolFlag{
175171
Name: "enable-discovery-reboot",
176172
Usage: "Experimental: Enables the discovery listener to rebooted in the event of connectivity issues.",
@@ -246,7 +242,6 @@ var BeaconChainFlags = combinedFlags([]cli.Flag{
246242
EnableLightClient,
247243
BlobSaveFsync,
248244
DisableQUIC,
249-
DisableCommitteeAwarePacking,
250245
EnableDiscoveryReboot,
251246
enableExperimentalAttestationPool,
252247
forceHeadFlag,

0 commit comments

Comments
 (0)