-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proposer attestation selection using max-cover (#8571)
* Proposer attestation selection using max-cover * better alisgn struct field * more tests * cleanup * simplify expressions * add benchmarks Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
- Loading branch information
1 parent
294b031
commit f2125e5
Showing
7 changed files
with
331 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package validator | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" | ||
"github.com/prysmaticlabs/go-bitfield" | ||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state" | ||
aggtesting "github.com/prysmaticlabs/prysm/shared/aggregation/testing" | ||
"github.com/prysmaticlabs/prysm/shared/featureconfig" | ||
"github.com/prysmaticlabs/prysm/shared/params" | ||
) | ||
|
||
func BenchmarkProposerAtts_sortByProfitability(b *testing.B) { | ||
bitlistLen := params.BeaconConfig().MaxValidatorsPerCommittee | ||
|
||
tests := []struct { | ||
name string | ||
inputs []bitfield.Bitlist | ||
}{ | ||
{ | ||
name: "256 attestations with single bit set", | ||
inputs: aggtesting.BitlistsWithSingleBitSet(256, bitlistLen), | ||
}, | ||
{ | ||
name: "256 attestations with 64 random bits set", | ||
inputs: aggtesting.BitlistsWithSingleBitSet(256, bitlistLen), | ||
}, | ||
{ | ||
name: "512 attestations with single bit set", | ||
inputs: aggtesting.BitlistsWithSingleBitSet(512, bitlistLen), | ||
}, | ||
{ | ||
name: "1024 attestations with 64 random bits set", | ||
inputs: aggtesting.BitlistsWithMultipleBitSet(b, 1024, bitlistLen, 64), | ||
}, | ||
{ | ||
name: "1024 attestations with 512 random bits set", | ||
inputs: aggtesting.BitlistsWithMultipleBitSet(b, 1024, bitlistLen, 512), | ||
}, | ||
{ | ||
name: "1024 attestations with 1000 random bits set", | ||
inputs: aggtesting.BitlistsWithMultipleBitSet(b, 1024, bitlistLen, 1000), | ||
}, | ||
} | ||
|
||
runner := func(atts []*ethpb.Attestation) { | ||
attsCopy := make(proposerAtts, len(atts)) | ||
for i, att := range atts { | ||
attsCopy[i] = stateTrie.CopyAttestation(att) | ||
} | ||
attsCopy.sortByProfitability() | ||
} | ||
|
||
for _, tt := range tests { | ||
b.Run(fmt.Sprintf("naive_%s", tt.name), func(b *testing.B) { | ||
b.StopTimer() | ||
resetCfg := featureconfig.InitWithReset(&featureconfig.Flags{ | ||
ProposerAttsSelectionUsingMaxCover: false, | ||
}) | ||
defer resetCfg() | ||
atts := aggtesting.MakeAttestationsFromBitlists(tt.inputs) | ||
b.StartTimer() | ||
for i := 0; i < b.N; i++ { | ||
runner(atts) | ||
} | ||
}) | ||
b.Run(fmt.Sprintf("max-cover_%s", tt.name), func(b *testing.B) { | ||
b.StopTimer() | ||
resetCfg := featureconfig.InitWithReset(&featureconfig.Flags{ | ||
ProposerAttsSelectionUsingMaxCover: true, | ||
}) | ||
defer resetCfg() | ||
atts := aggtesting.MakeAttestationsFromBitlists(tt.inputs) | ||
b.StartTimer() | ||
for i := 0; i < b.N; i++ { | ||
runner(atts) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.