Skip to content

Commit f5f4627

Browse files
committed
Bastin's feedback
1 parent be1297a commit f5f4627

File tree

10 files changed

+26
-31
lines changed

10 files changed

+26
-31
lines changed

beacon-chain/core/peerdas/reconstruction_helpers_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import (
1616

1717
// testBlobSetup holds common test data for blob reconstruction tests.
1818
type testBlobSetup struct {
19-
blobCount int
20-
blobs []kzg.Blob
21-
roBlock blocks.ROBlock
22-
roDataColumnSidecars []blocks.RODataColumn
23-
verifiedRoDataColumnSidecars []blocks.VerifiedRODataColumn
19+
blobCount int
20+
blobs []kzg.Blob
21+
roBlock blocks.ROBlock
22+
roDataColumnSidecars []blocks.RODataColumn
23+
verifiedRoDataColumnSidecars []blocks.VerifiedRODataColumn
2424
}
2525

2626
// setupTestBlobs creates a complete test setup with blobs, cells, proofs, and data column sidecars.

beacon-chain/p2p/broadcaster.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (s *Service) BroadcastLightClientOptimisticUpdate(ctx context.Context, upda
286286
return err
287287
}
288288
timeSinceSlotStart := time.Since(slotStart)
289-
expectedDelay := slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))
289+
expectedDelay := params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)
290290
if timeSinceSlotStart < expectedDelay {
291291
waitDuration := expectedDelay - timeSinceSlotStart
292292
<-time.After(waitDuration)
@@ -320,7 +320,7 @@ func (s *Service) BroadcastLightClientFinalityUpdate(ctx context.Context, update
320320
return err
321321
}
322322
timeSinceSlotStart := time.Since(slotStart)
323-
expectedDelay := slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))
323+
expectedDelay := params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)
324324
if timeSinceSlotStart < expectedDelay {
325325
waitDuration := expectedDelay - timeSinceSlotStart
326326
<-time.After(waitDuration)

beacon-chain/p2p/broadcaster_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"github.com/OffchainLabs/prysm/v7/config/params"
2323
"github.com/OffchainLabs/prysm/v7/consensus-types/blocks"
2424
"github.com/OffchainLabs/prysm/v7/consensus-types/interfaces"
25-
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
2625
"github.com/OffchainLabs/prysm/v7/consensus-types/wrapper"
2726
"github.com/OffchainLabs/prysm/v7/encoding/bytesutil"
2827
ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
@@ -598,7 +597,7 @@ func TestService_BroadcastLightClientOptimisticUpdate(t *testing.T) {
598597

599598
slotStartTime, err := slots.StartTime(p.genesisTime, msg.SignatureSlot())
600599
require.NoError(t, err)
601-
expectedDelay := slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))
600+
expectedDelay := params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)
602601
if time.Now().Before(slotStartTime.Add(expectedDelay)) {
603602
tt.Errorf("Message received too early, now %v, expected at least %v", time.Now(), slotStartTime.Add(expectedDelay))
604603
}
@@ -674,7 +673,7 @@ func TestService_BroadcastLightClientFinalityUpdate(t *testing.T) {
674673

675674
slotStartTime, err := slots.StartTime(p.genesisTime, msg.SignatureSlot())
676675
require.NoError(t, err)
677-
expectedDelay := slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))
676+
expectedDelay := params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)
678677
if time.Now().Before(slotStartTime.Add(expectedDelay)) {
679678
tt.Errorf("Message received too early, now %v, expected at least %v", time.Now(), slotStartTime.Add(expectedDelay))
680679
}

beacon-chain/sync/subscriber_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,6 @@ func Test_wrapAndReportValidation(t *testing.T) {
443443
func TestFilterSubnetPeers(t *testing.T) {
444444
params.SetupTestConfigCleanup(t)
445445
cfg := params.MainnetConfig()
446-
cfg.SecondsPerSlot = 1
447446
cfg.SlotDurationMilliseconds = 1000
448447
params.OverrideBeaconConfig(cfg)
449448

@@ -458,8 +457,9 @@ func TestFilterSubnetPeers(t *testing.T) {
458457
currSlot := primitives.Slot(100)
459458

460459
gt := time.Now()
460+
slotDuration := params.BeaconConfig().SlotDuration()
461461
genPlus100 := func() time.Time {
462-
return gt.Add(time.Second * time.Duration(uint64(currSlot)*params.BeaconConfig().SecondsPerSlot))
462+
return gt.Add(time.Duration(uint64(currSlot)) * slotDuration)
463463
}
464464
chain := &mockChain.ChainService{
465465
Genesis: gt,

beacon-chain/sync/validate_light_client.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/OffchainLabs/prysm/v7/config/params"
88
"github.com/OffchainLabs/prysm/v7/consensus-types/interfaces"
9-
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
109
"github.com/OffchainLabs/prysm/v7/monitoring/tracing"
1110
"github.com/OffchainLabs/prysm/v7/monitoring/tracing/trace"
1211
"github.com/OffchainLabs/prysm/v7/time/slots"
@@ -60,7 +59,7 @@ func (s *Service) validateLightClientOptimisticUpdate(ctx context.Context, pid p
6059
return pubsub.ValidationReject, nil
6160
}
6261
earliestValidTime := slotStart.
63-
Add(slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))).
62+
Add(params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)).
6463
Add(-params.BeaconConfig().MaximumGossipClockDisparityDuration())
6564
if s.cfg.clock.Now().Before(earliestValidTime) {
6665
log.Debug("Newly received light client optimistic update ignored. not enough time passed for block to propagate")
@@ -130,7 +129,7 @@ func (s *Service) validateLightClientFinalityUpdate(ctx context.Context, pid pee
130129
return pubsub.ValidationReject, nil
131130
}
132131
earliestValidTime := slotStart.
133-
Add(slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))).
132+
Add(params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)).
134133
Add(-params.BeaconConfig().MaximumGossipClockDisparityDuration())
135134
if s.cfg.clock.Now().Before(earliestValidTime) {
136135
log.Debug("Newly received light client finality update ignored. not enough time passed for block to propagate")

beacon-chain/sync/validate_light_client_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import (
1616
mockSync "github.com/OffchainLabs/prysm/v7/beacon-chain/sync/initial-sync/testing"
1717
"github.com/OffchainLabs/prysm/v7/config/params"
1818
"github.com/OffchainLabs/prysm/v7/consensus-types/interfaces"
19-
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
2019
"github.com/OffchainLabs/prysm/v7/runtime/version"
2120
"github.com/OffchainLabs/prysm/v7/testing/require"
2221
"github.com/OffchainLabs/prysm/v7/testing/util"
23-
"github.com/OffchainLabs/prysm/v7/time/slots"
2422
pubsub "github.com/libp2p/go-libp2p-pubsub"
2523
pb "github.com/libp2p/go-libp2p-pubsub/pb"
2624
)
@@ -83,7 +81,7 @@ func TestValidateLightClientOptimisticUpdate(t *testing.T) {
8381
},
8482
{
8583
name: "not enough time passed",
86-
genesisDrift: -int(math.Ceil(float64(slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))) / float64(time.Second))),
84+
genesisDrift: -int(math.Ceil(float64(params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)) / float64(time.Second))),
8785
oldUpdateOptions: []util.LightClientOption{},
8886
newUpdateOptions: []util.LightClientOption{},
8987
expectedResult: pubsub.ValidationIgnore,
@@ -209,7 +207,7 @@ func TestValidateLightClientFinalityUpdate(t *testing.T) {
209207
},
210208
{
211209
name: "not enough time passed",
212-
genesisDrift: -int(math.Ceil(float64(slots.ComponentDuration(primitives.BP(params.BeaconConfig().SyncMessageDueBPS))) / float64(time.Second))),
210+
genesisDrift: -int(math.Ceil(float64(params.BeaconConfig().SlotComponentDuration(params.BeaconConfig().SyncMessageDueBPS)) / float64(time.Second))),
213211
oldUpdateOptions: []util.LightClientOption{},
214212
newUpdateOptions: []util.LightClientOption{},
215213
expectedResult: pubsub.ValidationIgnore,

config/params/loader_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ func assertEqualConfigs(t *testing.T, name string, fields []string, expected, ac
9696
assert.Equal(t, expected.HysteresisQuotient, actual.HysteresisQuotient, "%s: HysteresisQuotient", name)
9797
assert.Equal(t, expected.HysteresisDownwardMultiplier, actual.HysteresisDownwardMultiplier, "%s: HysteresisDownwardMultiplier", name)
9898
assert.Equal(t, expected.HysteresisUpwardMultiplier, actual.HysteresisUpwardMultiplier, "%s: HysteresisUpwardMultiplier", name)
99+
assert.Equal(t, expected.AttestationDueBPS, actual.AttestationDueBPS, "%s: AttestationDueBPS", name)
100+
assert.Equal(t, expected.AggregrateDueBPS, actual.AggregrateDueBPS, "%s: AggregrateDueBPS", name)
101+
assert.Equal(t, expected.ContributionDueBPS, actual.ContributionDueBPS, "%s: ContributionDueBPS", name)
102+
assert.Equal(t, expected.ProposerReorgCutoffBPS, actual.ProposerReorgCutoffBPS, "%s: ProposerReorgCutoffBPS", name)
99103
assert.Equal(t, expected.SyncMessageDueBPS, actual.SyncMessageDueBPS, "%s: SyncMessageDueBPS", name)
100104

101105
// Validator params.

config/params/mainnet_config.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ var mainnetBeaconConfig = &BeaconChainConfig{
117117
ReorgParentWeightThreshold: 160,
118118
ReorgMaxEpochsSinceFinalization: 2,
119119
IntervalsPerSlot: 3,
120-
ProposerReorgCutoffBPS: primitives.BP(1667),
121-
AttestationDueBPS: primitives.BP(3333),
122-
AggregrateDueBPS: primitives.BP(6667),
123120

124-
SyncMessageDueBPS: primitives.BP(3333),
125-
ContributionDueBPS: primitives.BP(6667),
121+
// Time-based protocol parameters.
122+
ProposerReorgCutoffBPS: primitives.BP(1667),
123+
AttestationDueBPS: primitives.BP(3333),
124+
AggregrateDueBPS: primitives.BP(6667),
125+
SyncMessageDueBPS: primitives.BP(3333),
126+
ContributionDueBPS: primitives.BP(6667),
126127

127128
// Ethereum PoW parameters.
128129
DepositChainID: 1, // Chain ID of eth1 mainnet.

time/slots/slottime.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,3 @@ func SecondsUntilNextEpochStart(genesis time.Time) (uint64, error) {
309309
}).Debugf("%d seconds until next epoch", waitTime)
310310
return waitTime, nil
311311
}
312-
313-
// ComponentDuration calculates the duration of a slot component in milliseconds.
314-
func ComponentDuration(component primitives.BP) time.Duration {
315-
ms := (component * params.SlotBP()) / params.BasisPoints
316-
return time.Duration(ms) * time.Millisecond
317-
}

validator/client/wait_helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestSlotComponentSpanName(t *testing.T) {
6666
func TestWaitUntilSlotComponent_ContextCancelReturnsImmediately(t *testing.T) {
6767
params.SetupTestConfigCleanup(t)
6868
cfg := params.BeaconConfig().Copy()
69-
cfg.SlotDurationMilliseconds = 10
69+
cfg.SlotDurationMilliseconds = 10000
7070
params.OverrideBeaconConfig(cfg)
7171

7272
v := &validator{genesisTime: time.Now()}

0 commit comments

Comments
 (0)