Skip to content

Commit

Permalink
Fix proposer boost test (#14701)
Browse files Browse the repository at this point in the history
  • Loading branch information
terencechain authored Dec 10, 2024
1 parent 1f2d8cf commit e925d35
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion testing/spectest/shared/common/forkchoice/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"path"
"slices"
"strings"
"testing"

Expand All @@ -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"
Expand All @@ -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()
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit e925d35

Please sign in to comment.