From e925d35d55a369f200413569a7e37640eb635e90 Mon Sep 17 00:00:00 2001 From: terence Date: Tue, 10 Dec 2024 10:00:24 -0800 Subject: [PATCH] Fix proposer boost test (#14701) --- CHANGELOG.md | 2 +- .../shared/common/forkchoice/runner.go | 22 ++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6143188a7fa1..1737d811c24f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,10 +114,10 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - P2P: Avoid infinite loop when looking for peers in small networks. - Fixed another rollback bug due to a context deadline. - Fix checkpoint sync bug on holesky. [pr](https://github.com/prysmaticlabs/prysm/pull/14689) +- Fix proposer boost spec tests being flakey by adjusting start time from 3 to 2s into slot. - Fix segmentation fault in E2E when light-client feature flag is enabled. [PR](https://github.com/prysmaticlabs/prysm/pull/14699) - Fix `searchForPeers` infinite loop in small networks. - ### Security ## [v5.1.2](https://github.com/prysmaticlabs/prysm/compare/v5.1.1...v5.1.2) - 2024-10-16 diff --git a/testing/spectest/shared/common/forkchoice/runner.go b/testing/spectest/shared/common/forkchoice/runner.go index 0808727ddd97..c4d7a2d79ca6 100644 --- a/testing/spectest/shared/common/forkchoice/runner.go +++ b/testing/spectest/shared/common/forkchoice/runner.go @@ -6,6 +6,7 @@ import ( "fmt" "os" "path" + "slices" "strings" "testing" @@ -16,6 +17,7 @@ import ( state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" "github.com/prysmaticlabs/prysm/v5/beacon-chain/verification" fieldparams "github.com/prysmaticlabs/prysm/v5/config/fieldparams" + "github.com/prysmaticlabs/prysm/v5/config/params" "github.com/prysmaticlabs/prysm/v5/consensus-types/blocks" "github.com/prysmaticlabs/prysm/v5/consensus-types/interfaces" ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" @@ -25,6 +27,13 @@ import ( "github.com/prysmaticlabs/prysm/v5/testing/util" ) +// These are proposer boost spec tests that assume the clock starts 3 seconds into the slot. +// Example: Tick is 51, which corresponds to 3 seconds into slot 4. +var proposerBoostTests3s = []string{ + "proposer_boost_is_first_block", + "proposer_boost", +} + func init() { transition.SkipSlotCache.Disable() } @@ -97,7 +106,18 @@ func runTest(t *testing.T, config string, fork int, basePath string) { // nolint for _, step := range steps { if step.Tick != nil { - builder.Tick(t, int64(*step.Tick)) + tick := int64(*step.Tick) + // If the test is for proposer boost starting 3 seconds into the slot and the tick aligns with this, + // we provide an additional second buffer. Instead of starting 3 seconds into the slot, we start 2 seconds in to avoid missing the proposer boost. + // A 1-second buffer has proven insufficient during parallel spec test runs, as the likelihood of missing the proposer boost increases significantly, + // often extending to 4 seconds. Starting 2 seconds into the slot ensures close to a 100% pass rate. + if slices.Contains(proposerBoostTests3s, folder.Name()) { + deadline := params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot + if uint64(tick)%params.BeaconConfig().SecondsPerSlot == deadline-1 { + tick-- + } + } + builder.Tick(t, tick) } var beaconBlock interfaces.ReadOnlySignedBeaconBlock if step.Block != nil {