Skip to content

Commit a05f0c7

Browse files
committed
Use new timing configs (due BPS)
1 parent 6735c92 commit a05f0c7

30 files changed

+382
-75
lines changed

beacon-chain/db/kv/genesis_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func TestEnsureEmbeddedGenesis(t *testing.T) {
146146
params.SetupTestConfigCleanup(t)
147147
// Embedded Genesis works with Mainnet config
148148
cfg := params.MainnetConfig()
149-
cfg.SecondsPerSlot = 1
149+
cfg.SlotDurationMilliseconds = 1000
150150
undo, err := params.SetActiveWithUndo(cfg)
151151
require.NoError(t, err)
152152
defer func() {

beacon-chain/forkchoice/doubly-linked-tree/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (n *Node) setNodeAndParentValidated(ctx context.Context) error {
134134
// slot will have secs = 3 below.
135135
func (n *Node) arrivedEarly(genesis time.Time) (bool, error) {
136136
sss, err := slots.SinceSlotStart(n.slot, genesis, n.timestamp.Truncate(time.Second)) // Truncate such that 3.9999 seconds will have a value of 3.
137-
votingWindow := time.Duration(params.BeaconConfig().SecondsPerSlot/params.BeaconConfig().IntervalsPerSlot) * time.Second
137+
votingWindow := params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().AttestationDueBPS)
138138
return sss < votingWindow, err
139139
}
140140

beacon-chain/forkchoice/doubly-linked-tree/reorg_late_blocks_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ func TestForkChoice_GetProposerHead(t *testing.T) {
134134
headRoot, err := f.Head(ctx)
135135
require.NoError(t, err)
136136
require.Equal(t, blk.Root(), headRoot)
137-
orphanLateBlockFirstThreshold := params.BeaconConfig().SecondsPerSlot / params.BeaconConfig().IntervalsPerSlot
138-
f.store.headNode.timestamp.Add(-1 * time.Duration(params.BeaconConfig().SecondsPerSlot-orphanLateBlockFirstThreshold) * time.Second)
137+
orphanLateBlockFirstThreshold := params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().AttestationDueBPS)
138+
f.store.headNode.timestamp.Add(-1 * (params.BeaconConfig().SlotDuration() - orphanLateBlockFirstThreshold))
139139
t.Run("head is weak", func(t *testing.T) {
140140
require.Equal(t, parentRoot, f.GetProposerHead())
141141
})

beacon-chain/forkchoice/doubly-linked-tree/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (s *Store) insert(ctx context.Context,
137137
if err != nil {
138138
return nil, fmt.Errorf("could not determine time since current slot started: %w", err)
139139
}
140-
boostThreshold := time.Duration(params.BeaconConfig().SecondsPerSlot/params.BeaconConfig().IntervalsPerSlot) * time.Second
140+
boostThreshold := params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().AttestationDueBPS)
141141
isFirstBlock := s.proposerBoostRoot == [32]byte{}
142142
if currentSlot == slot && sss < boostThreshold && isFirstBlock {
143143
s.proposerBoostRoot = root

beacon-chain/p2p/service_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func TestService_Start_NoDiscoverFlag(t *testing.T) {
128128
beaconCfg.AltairForkEpoch = 0
129129
beaconCfg.BellatrixForkEpoch = 0
130130
beaconCfg.CapellaForkEpoch = 0
131-
beaconCfg.SecondsPerSlot = 1
131+
beaconCfg.SlotDurationMilliseconds = 1000
132132
params.OverrideBeaconConfig(beaconCfg)
133133

134134
exitRoutine := make(chan bool)

beacon-chain/rpc/eth/config/handlers_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func TestGetSpec(t *testing.T) {
8787
config.ETH1AddressWithdrawalPrefixByte = byte('c')
8888
config.GenesisDelay = 24
8989
config.SecondsPerSlot = 25
90+
config.SlotDurationMilliseconds = 120
9091
config.MinAttestationInclusionDelay = 26
9192
config.SlotsPerEpoch = 27
9293
config.MinSeedLookahead = 28
@@ -129,6 +130,10 @@ func TestGetSpec(t *testing.T) {
129130
config.ProportionalSlashingMultiplierAltair = 69
130131
config.InactivityScoreRecoveryRate = 70
131132
config.MinSyncCommitteeParticipants = 71
133+
config.ProposerReorgCutoffBPS = primitives.BP(121)
134+
config.AttestationDueBPS = primitives.BP(122)
135+
config.AggregrateDueBPS = primitives.BP(123)
136+
config.ContributionDueBPS = primitives.BP(124)
132137
config.TerminalBlockHash = common.HexToHash("TerminalBlockHash")
133138
config.TerminalBlockHashActivationEpoch = 72
134139
config.TerminalTotalDifficulty = "73"
@@ -201,7 +206,7 @@ func TestGetSpec(t *testing.T) {
201206
require.NoError(t, json.Unmarshal(writer.Body.Bytes(), &resp))
202207
data, ok := resp.Data.(map[string]interface{})
203208
require.Equal(t, true, ok)
204-
assert.Equal(t, 171, len(data))
209+
assert.Equal(t, 176, len(data))
205210
for k, v := range data {
206211
t.Run(k, func(t *testing.T) {
207212
switch k {
@@ -291,6 +296,8 @@ func TestGetSpec(t *testing.T) {
291296
assert.Equal(t, "24", v)
292297
case "SECONDS_PER_SLOT":
293298
assert.Equal(t, "25", v)
299+
case "SLOT_DURATION_MS":
300+
assert.Equal(t, "120", v)
294301
case "MIN_ATTESTATION_INCLUSION_DELAY":
295302
assert.Equal(t, "26", v)
296303
case "SLOTS_PER_EPOCH":
@@ -447,6 +454,14 @@ func TestGetSpec(t *testing.T) {
447454
assert.Equal(t, "20", v)
448455
case "REORG_PARENT_WEIGHT_THRESHOLD":
449456
assert.Equal(t, "160", v)
457+
case "PROPOSER_REORG_CUTOFF_BPS":
458+
assert.Equal(t, "121", v)
459+
case "ATTESTATION_DUE_BPS":
460+
assert.Equal(t, "122", v)
461+
case "AGGREGRATE_DUE_BPS":
462+
assert.Equal(t, "123", v)
463+
case "CONTRIBUTION_DUE_BPS":
464+
assert.Equal(t, "124", v)
450465
case "MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT":
451466
assert.Equal(t, "8", v)
452467
case "MAX_REQUEST_LIGHT_CLIENT_UPDATES":

beacon-chain/sync/rpc_goodbye_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
func TestGoodByeRPCHandler_Disconnects_With_Peer(t *testing.T) {
2424
params.SetupTestConfigCleanup(t)
2525
cfg := params.MainnetConfig()
26-
cfg.SecondsPerSlot = 1
26+
cfg.SlotDurationMilliseconds = 1000
2727
params.OverrideBeaconConfig(cfg)
2828

2929
p1 := p2ptest.NewTestP2P(t)

beacon-chain/sync/subscriber_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func TestSubscribe_UnsubscribeTopic(t *testing.T) {
130130
func TestSubscribe_ReceivesAttesterSlashing(t *testing.T) {
131131
params.SetupTestConfigCleanup(t)
132132
cfg := params.MainnetConfig()
133-
cfg.SecondsPerSlot = 1
133+
cfg.SlotDurationMilliseconds = 1000
134134
params.OverrideBeaconConfig(cfg)
135135

136136
p2pService := p2ptest.NewTestP2P(t)
@@ -444,6 +444,7 @@ func TestFilterSubnetPeers(t *testing.T) {
444444
params.SetupTestConfigCleanup(t)
445445
cfg := params.MainnetConfig()
446446
cfg.SecondsPerSlot = 1
447+
cfg.SlotDurationMilliseconds = 1000
447448
params.OverrideBeaconConfig(cfg)
448449

449450
gFlags := new(flags.GlobalFlags)
@@ -525,7 +526,7 @@ func TestFilterSubnetPeers(t *testing.T) {
525526
func TestSubscribeWithSyncSubnets_DynamicOK(t *testing.T) {
526527
params.SetupTestConfigCleanup(t)
527528
cfg := params.MainnetConfig()
528-
cfg.SecondsPerSlot = 1
529+
cfg.SlotDurationMilliseconds = 1000
529530
params.OverrideBeaconConfig(cfg)
530531

531532
p := p2ptest.NewTestP2P(t)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Changed
2+
3+
- Use explicit slot component timing configs

config/params/basis_points.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
44

55
const BasisPoints = primitives.BP(10000)
66

7-
// SlotBP returns the basis points for a given slot.
7+
// SlotBP returns the duration of a slot expressed in milliseconds, represented as basis points of a slot.
88
func SlotBP() primitives.BP {
9-
return primitives.BP(12000)
9+
return primitives.BP(BeaconConfig().SlotDurationMillis())
1010
}

0 commit comments

Comments
 (0)