mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-18 07:48:46 +00:00
14b3181e67
* more spanner additions * implement iface * begin implement * wrapped up spanner functions * rem interface * added in necessary comments * comments on enums * begin adding tests * plug in surround vote detection * saved indexed db implementation * finally plugin slashing for historical data * Small fixes * add in all gazelle * save incoming new functions * resolve todo * fix broken test channel item * tests passing when fixing certain arguments and setups * Add comment and change unimplemented * find surround * added in gazelle * gazz * feedback from shay * fixed up naming * Update * Add tests for detectSurroundVotes * Remove logs * Fix slasher test * formatting * Remove unneeded condition * Test indices better * fixing broken build * pass tests * skip tests * imports * Update slasher/detection/attestations/attestations_test.go * Update slasher/beaconclient/historical_data_retrieval_test.go * Address comments * Rename function * Add comment for future optimization * Fix comment Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com>
90 lines
2.2 KiB
Go
90 lines
2.2 KiB
Go
package attestations
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"testing"
|
|
|
|
testDB "github.com/prysmaticlabs/prysm/slasher/db/testing"
|
|
)
|
|
|
|
func BenchmarkMinSpan(b *testing.B) {
|
|
diffs := []uint64{2, 10, 100, 1000, 10000, 53999}
|
|
db := testDB.SetupSlasherDB(b, true)
|
|
defer testDB.TeardownSlasherDB(b, db)
|
|
ctx := context.Background()
|
|
|
|
for _, diff := range diffs {
|
|
b.Run(fmt.Sprintf("MinSpan_diff_%d", diff), func(ib *testing.B) {
|
|
for i := uint64(0); i < uint64(ib.N); i++ {
|
|
spanMap, err := db.ValidatorSpansMap(ctx, i%10)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
_, _, err = detectAndUpdateMinEpochSpan(ctx, spanMap, i, i+diff)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func BenchmarkMaxSpan(b *testing.B) {
|
|
diffs := []uint64{2, 10, 100, 1000, 10000, 53999}
|
|
db := testDB.SetupSlasherDB(b, true)
|
|
defer testDB.TeardownSlasherDB(b, db)
|
|
ctx := context.Background()
|
|
|
|
for _, diff := range diffs {
|
|
b.Run(fmt.Sprintf("MaxSpan_diff_%d", diff), func(ib *testing.B) {
|
|
for i := uint64(0); i < uint64(ib.N); i++ {
|
|
spanMap, err := db.ValidatorSpansMap(ctx, i%10)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
_, _, err = detectAndUpdateMaxEpochSpan(ctx, spanMap, diff, diff+i)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func BenchmarkDetectSpan(b *testing.B) {
|
|
diffs := []uint64{2, 10, 100, 1000, 10000, 53999}
|
|
db := testDB.SetupSlasherDB(b, true)
|
|
defer testDB.TeardownSlasherDB(b, db)
|
|
ctx := context.Background()
|
|
|
|
for _, diff := range diffs {
|
|
b.Run(fmt.Sprintf("Detect_MaxSpan_diff_%d", diff), func(ib *testing.B) {
|
|
for i := uint64(0); i < uint64(ib.N); i++ {
|
|
spanMap, err := db.ValidatorSpansMap(ctx, i%10)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
_, _, _, err = detectSlashingByEpochSpan(ctx, spanMap, i, i+diff, detectMax)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
for _, diff := range diffs {
|
|
b.Run(fmt.Sprintf("Detect_MinSpan_diff_%d", diff), func(ib *testing.B) {
|
|
for i := uint64(0); i < uint64(ib.N); i++ {
|
|
spanMap, err := db.ValidatorSpansMap(ctx, i%10)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
_, _, _, err = detectSlashingByEpochSpan(ctx, spanMap, i, i+diff, detectMin)
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|