diff --git a/beacon-chain/blockchain/process_block_helpers.go b/beacon-chain/blockchain/process_block_helpers.go index 17f5859954..54e7735438 100644 --- a/beacon-chain/blockchain/process_block_helpers.go +++ b/beacon-chain/blockchain/process_block_helpers.go @@ -46,7 +46,7 @@ func (s *Service) getBlockPreState(ctx context.Context, b interfaces.ReadOnlyBea } // Verify block slot time is not from the future. - if err := slots.VerifyTime(uint64(s.genesisTime.Unix()), b.Slot(), params.BeaconNetworkConfig().MaximumGossipClockDisparity); err != nil { + if err := slots.VerifyTime(uint64(s.genesisTime.Unix()), b.Slot(), params.BeaconConfig().MaximumGossipClockDisparityDuration()); err != nil { return nil, err } diff --git a/beacon-chain/blockchain/receive_attestation.go b/beacon-chain/blockchain/receive_attestation.go index bf5ecac3d9..71e62c9637 100644 --- a/beacon-chain/blockchain/receive_attestation.go +++ b/beacon-chain/blockchain/receive_attestation.go @@ -121,7 +121,7 @@ func (s *Service) UpdateHead(ctx context.Context, proposingSlot primitives.Slot) s.cfg.ForkChoiceStore.Lock() defer s.cfg.ForkChoiceStore.Unlock() // This function is only called at 10 seconds or 0 seconds into the slot - disparity := params.BeaconNetworkConfig().MaximumGossipClockDisparity + disparity := params.BeaconConfig().MaximumGossipClockDisparityDuration() if !features.Get().DisableReorgLateBlocks { disparity += reorgLateBlockCountAttestations } diff --git a/beacon-chain/core/altair/sync_committee_test.go b/beacon-chain/core/altair/sync_committee_test.go index cbd0577da4..9194859260 100644 --- a/beacon-chain/core/altair/sync_committee_test.go +++ b/beacon-chain/core/altair/sync_committee_test.go @@ -276,7 +276,7 @@ func TestSyncSubCommitteePubkeys_CanGet(t *testing.T) { } func Test_ValidateSyncMessageTime(t *testing.T) { - if params.BeaconNetworkConfig().MaximumGossipClockDisparity < 200*time.Millisecond { + if params.BeaconConfig().MaximumGossipClockDisparityDuration() < 200*time.Millisecond { t.Fatal("This test expects the maximum clock disparity to be at least 200ms") } @@ -326,7 +326,7 @@ func Test_ValidateSyncMessageTime(t *testing.T) { name: "sync_message.slot == current_slot+CLOCK_DISPARITY", args: args{ syncMessageSlot: 100, - genesisTime: prysmTime.Now().Add(-(100*time.Duration(params.BeaconConfig().SecondsPerSlot)*time.Second - params.BeaconNetworkConfig().MaximumGossipClockDisparity)), + genesisTime: prysmTime.Now().Add(-(100*time.Duration(params.BeaconConfig().SecondsPerSlot)*time.Second - params.BeaconConfig().MaximumGossipClockDisparityDuration())), }, wantedErr: "", }, @@ -334,7 +334,7 @@ func Test_ValidateSyncMessageTime(t *testing.T) { name: "sync_message.slot == current_slot+CLOCK_DISPARITY-1000ms", args: args{ syncMessageSlot: 100, - genesisTime: prysmTime.Now().Add(-(100 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second) + params.BeaconNetworkConfig().MaximumGossipClockDisparity + 1000*time.Millisecond), + genesisTime: prysmTime.Now().Add(-(100 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second) + params.BeaconConfig().MaximumGossipClockDisparityDuration() + 1000*time.Millisecond), }, wantedErr: "(message slot 100) not within allowable range of", }, @@ -342,7 +342,7 @@ func Test_ValidateSyncMessageTime(t *testing.T) { name: "sync_message.slot == current_slot-CLOCK_DISPARITY", args: args{ syncMessageSlot: 100, - genesisTime: prysmTime.Now().Add(-(100*time.Duration(params.BeaconConfig().SecondsPerSlot)*time.Second + params.BeaconNetworkConfig().MaximumGossipClockDisparity)), + genesisTime: prysmTime.Now().Add(-(100*time.Duration(params.BeaconConfig().SecondsPerSlot)*time.Second + params.BeaconConfig().MaximumGossipClockDisparityDuration())), }, wantedErr: "", }, @@ -350,7 +350,7 @@ func Test_ValidateSyncMessageTime(t *testing.T) { name: "sync_message.slot > current_slot+CLOCK_DISPARITY", args: args{ syncMessageSlot: 101, - genesisTime: prysmTime.Now().Add(-(100*time.Duration(params.BeaconConfig().SecondsPerSlot)*time.Second + params.BeaconNetworkConfig().MaximumGossipClockDisparity)), + genesisTime: prysmTime.Now().Add(-(100*time.Duration(params.BeaconConfig().SecondsPerSlot)*time.Second + params.BeaconConfig().MaximumGossipClockDisparityDuration())), }, wantedErr: "(message slot 101) not within allowable range of", }, @@ -366,7 +366,7 @@ func Test_ValidateSyncMessageTime(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := altair.ValidateSyncMessageTime(tt.args.syncMessageSlot, tt.args.genesisTime, - params.BeaconNetworkConfig().MaximumGossipClockDisparity) + params.BeaconConfig().MaximumGossipClockDisparityDuration()) if tt.wantedErr != "" { assert.ErrorContains(t, tt.wantedErr, err) } else { diff --git a/beacon-chain/core/helpers/attestation.go b/beacon-chain/core/helpers/attestation.go index af7d57f19d..18225e801a 100644 --- a/beacon-chain/core/helpers/attestation.go +++ b/beacon-chain/core/helpers/attestation.go @@ -113,7 +113,7 @@ func ComputeSubnetFromCommitteeAndSlot(activeValCount uint64, comIdx primitives. slotSinceStart := slots.SinceEpochStarts(attSlot) comCount := SlotCommitteeCount(activeValCount) commsSinceStart := uint64(slotSinceStart.Mul(comCount)) - computedSubnet := (commsSinceStart + uint64(comIdx)) % params.BeaconNetworkConfig().AttestationSubnetCount + computedSubnet := (commsSinceStart + uint64(comIdx)) % params.BeaconConfig().AttestationSubnetCount return computedSubnet } @@ -151,8 +151,8 @@ func ValidateAttestationTime(attSlot primitives.Slot, genesisTime time.Time, clo // An attestation cannot be older than the current slot - attestation propagation slot range // with a minor tolerance for peer clock disparity. lowerBoundsSlot := primitives.Slot(0) - if currentSlot > params.BeaconNetworkConfig().AttestationPropagationSlotRange { - lowerBoundsSlot = currentSlot - params.BeaconNetworkConfig().AttestationPropagationSlotRange + if currentSlot > params.BeaconConfig().AttestationPropagationSlotRange { + lowerBoundsSlot = currentSlot - params.BeaconConfig().AttestationPropagationSlotRange } lowerTime, err := slots.ToTime(uint64(genesisTime.Unix()), lowerBoundsSlot) if err != nil { diff --git a/beacon-chain/core/helpers/attestation_test.go b/beacon-chain/core/helpers/attestation_test.go index 932dc41b33..54f8fc82b8 100644 --- a/beacon-chain/core/helpers/attestation_test.go +++ b/beacon-chain/core/helpers/attestation_test.go @@ -90,7 +90,7 @@ func Test_ValidateAttestationTime(t *testing.T) { params.OverrideBeaconConfig(cfg) params.SetupTestConfigCleanup(t) - if params.BeaconNetworkConfig().MaximumGossipClockDisparity < 200*time.Millisecond { + if params.BeaconConfig().MaximumGossipClockDisparityDuration() < 200*time.Millisecond { t.Fatal("This test expects the maximum clock disparity to be at least 200ms") } @@ -139,7 +139,7 @@ func Test_ValidateAttestationTime(t *testing.T) { { name: "attestation.slot < current_slot-ATTESTATION_PROPAGATION_SLOT_RANGE", args: args{ - attSlot: 100 - params.BeaconNetworkConfig().AttestationPropagationSlotRange - 1, + attSlot: 100 - params.BeaconConfig().AttestationPropagationSlotRange - 1, genesisTime: prysmTime.Now().Add(-100 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second), }, wantedErr: "not within attestation propagation range", @@ -147,14 +147,14 @@ func Test_ValidateAttestationTime(t *testing.T) { { name: "attestation.slot = current_slot-ATTESTATION_PROPAGATION_SLOT_RANGE", args: args{ - attSlot: 100 - params.BeaconNetworkConfig().AttestationPropagationSlotRange, + attSlot: 100 - params.BeaconConfig().AttestationPropagationSlotRange, genesisTime: prysmTime.Now().Add(-100 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second), }, }, { name: "attestation.slot = current_slot-ATTESTATION_PROPAGATION_SLOT_RANGE, received 200ms late", args: args{ - attSlot: 100 - params.BeaconNetworkConfig().AttestationPropagationSlotRange, + attSlot: 100 - params.BeaconConfig().AttestationPropagationSlotRange, genesisTime: prysmTime.Now().Add( -100 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second, ).Add(200 * time.Millisecond), @@ -163,21 +163,21 @@ func Test_ValidateAttestationTime(t *testing.T) { { name: "attestation.slot < current_slot-ATTESTATION_PROPAGATION_SLOT_RANGE in deneb", args: args{ - attSlot: 300 - params.BeaconNetworkConfig().AttestationPropagationSlotRange - 1, + attSlot: 300 - params.BeaconConfig().AttestationPropagationSlotRange - 1, genesisTime: prysmTime.Now().Add(-300 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second), }, }, { name: "attestation.slot = current_slot-ATTESTATION_PROPAGATION_SLOT_RANGE in deneb", args: args{ - attSlot: 300 - params.BeaconNetworkConfig().AttestationPropagationSlotRange, + attSlot: 300 - params.BeaconConfig().AttestationPropagationSlotRange, genesisTime: prysmTime.Now().Add(-300 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second), }, }, { name: "attestation.slot = current_slot-ATTESTATION_PROPAGATION_SLOT_RANGE, received 200ms late in deneb", args: args{ - attSlot: 300 - params.BeaconNetworkConfig().AttestationPropagationSlotRange, + attSlot: 300 - params.BeaconConfig().AttestationPropagationSlotRange, genesisTime: prysmTime.Now().Add( -300 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second, ).Add(200 * time.Millisecond), @@ -186,7 +186,7 @@ func Test_ValidateAttestationTime(t *testing.T) { { name: "attestation.slot != current epoch or previous epoch in deneb", args: args{ - attSlot: 300 - params.BeaconNetworkConfig().AttestationPropagationSlotRange, + attSlot: 300 - params.BeaconConfig().AttestationPropagationSlotRange, genesisTime: prysmTime.Now().Add( -500 * time.Duration(params.BeaconConfig().SecondsPerSlot) * time.Second, ).Add(200 * time.Millisecond), @@ -205,7 +205,7 @@ func Test_ValidateAttestationTime(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { err := helpers.ValidateAttestationTime(tt.args.attSlot, tt.args.genesisTime, - params.BeaconNetworkConfig().MaximumGossipClockDisparity) + params.BeaconConfig().MaximumGossipClockDisparityDuration()) if tt.wantedErr != "" { assert.ErrorContains(t, tt.wantedErr, err) } else { diff --git a/beacon-chain/p2p/broadcaster.go b/beacon-chain/p2p/broadcaster.go index c6490d3252..1da068b70c 100644 --- a/beacon-chain/p2p/broadcaster.go +++ b/beacon-chain/p2p/broadcaster.go @@ -191,7 +191,7 @@ func (s *Service) broadcastSyncCommittee(ctx context.Context, subnet uint64, sMs } // In the event our sync message is outdated and beyond the // acceptable threshold, we exit early and do not broadcast it. - if err := altair.ValidateSyncMessageTime(sMsg.Slot, s.genesisTime, params.BeaconNetworkConfig().MaximumGossipClockDisparity); err != nil { + if err := altair.ValidateSyncMessageTime(sMsg.Slot, s.genesisTime, params.BeaconConfig().MaximumGossipClockDisparityDuration()); err != nil { log.WithError(err).Warn("Sync Committee Message is too old to broadcast, discarding it") return } diff --git a/beacon-chain/p2p/encoder/ssz.go b/beacon-chain/p2p/encoder/ssz.go index a6acfa7f77..2ce891f9d4 100644 --- a/beacon-chain/p2p/encoder/ssz.go +++ b/beacon-chain/p2p/encoder/ssz.go @@ -16,8 +16,8 @@ import ( var _ NetworkEncoding = (*SszNetworkEncoder)(nil) // MaxGossipSize allowed for gossip messages. -var MaxGossipSize = params.BeaconNetworkConfig().GossipMaxSize // 1 Mib. -var MaxChunkSize = params.BeaconNetworkConfig().MaxChunkSize // 1 Mib. +var MaxGossipSize = params.BeaconConfig().GossipMaxSize // 10 Mib. +var MaxChunkSize = params.BeaconConfig().MaxChunkSize // 10 Mib. // This pool defines the sync pool for our buffered snappy writers, so that they // can be constantly reused. @@ -200,13 +200,3 @@ func newBufferedWriter(w io.Writer) *snappy.Writer { bufW.Reset(w) return bufW } - -// SetMaxGossipSizeForBellatrix sets the MaxGossipSize to 10Mb. -func SetMaxGossipSizeForBellatrix() { - MaxGossipSize = params.BeaconNetworkConfig().GossipMaxSizeBellatrix -} - -// SetMaxChunkSizeForBellatrix sets the MaxChunkSize to 10Mb. -func SetMaxChunkSizeForBellatrix() { - MaxChunkSize = params.BeaconNetworkConfig().MaxChunkSizeBellatrix -} diff --git a/beacon-chain/p2p/fork_watcher.go b/beacon-chain/p2p/fork_watcher.go index 87c421e3a1..c36c217984 100644 --- a/beacon-chain/p2p/fork_watcher.go +++ b/beacon-chain/p2p/fork_watcher.go @@ -1,7 +1,6 @@ package p2p import ( - "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/encoder" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/time/slots" ) @@ -29,12 +28,6 @@ func (s *Service) forkWatcher() { log.WithError(err).Error("Could not add fork entry") } } - - // from Bellatrix Epoch, the MaxGossipSize and the MaxChunkSize is changed to 10Mb. - if currEpoch == params.BeaconConfig().BellatrixForkEpoch { - encoder.SetMaxGossipSizeForBellatrix() - encoder.SetMaxChunkSizeForBellatrix() - } } case <-s.ctx.Done(): log.Debug("Context closed, exiting goroutine") diff --git a/beacon-chain/p2p/gossip_scoring_params.go b/beacon-chain/p2p/gossip_scoring_params.go index 00674a8c60..ccdb29de96 100644 --- a/beacon-chain/p2p/gossip_scoring_params.go +++ b/beacon-chain/p2p/gossip_scoring_params.go @@ -284,7 +284,7 @@ func defaultSyncContributionTopicParams() *pubsub.TopicScoreParams { } func defaultAggregateSubnetTopicParams(activeValidators uint64) *pubsub.TopicScoreParams { - subnetCount := params.BeaconNetworkConfig().AttestationSubnetCount + subnetCount := params.BeaconConfig().AttestationSubnetCount // Get weight for each specific subnet. topicWeight := attestationTotalWeight / float64(subnetCount) subnetWeight := activeValidators / subnetCount diff --git a/beacon-chain/p2p/message_id.go b/beacon-chain/p2p/message_id.go index 554df8d837..63929f206e 100644 --- a/beacon-chain/p2p/message_id.go +++ b/beacon-chain/p2p/message_id.go @@ -50,13 +50,13 @@ func MsgID(genesisValidatorsRoot []byte, pmsg *pubsubpb.Message) string { if fEpoch >= params.BeaconConfig().AltairForkEpoch { return postAltairMsgID(pmsg, fEpoch) } - decodedData, err := encoder.DecodeSnappy(pmsg.Data, params.BeaconNetworkConfig().GossipMaxSize) + decodedData, err := encoder.DecodeSnappy(pmsg.Data, params.BeaconConfig().GossipMaxSize) if err != nil { - combinedData := append(params.BeaconNetworkConfig().MessageDomainInvalidSnappy[:], pmsg.Data...) + combinedData := append(params.BeaconConfig().MessageDomainInvalidSnappy[:], pmsg.Data...) h := hash.Hash(combinedData) return string(h[:20]) } - combinedData := append(params.BeaconNetworkConfig().MessageDomainValidSnappy[:], decodedData...) + combinedData := append(params.BeaconConfig().MessageDomainValidSnappy[:], decodedData...) h := hash.Hash(combinedData) return string(h[:20]) } @@ -78,15 +78,12 @@ func postAltairMsgID(pmsg *pubsubpb.Message, fEpoch primitives.Epoch) string { topicLenBytes := bytesutil.Uint64ToBytesLittleEndian(uint64(topicLen)) // topicLen cannot be negative // beyond Bellatrix epoch, allow 10 Mib gossip data size - gossipPubSubSize := params.BeaconNetworkConfig().GossipMaxSize - if fEpoch >= params.BeaconConfig().BellatrixForkEpoch { - gossipPubSubSize = params.BeaconNetworkConfig().GossipMaxSizeBellatrix - } + gossipPubSubSize := params.BeaconConfig().GossipMaxSize decodedData, err := encoder.DecodeSnappy(pmsg.Data, gossipPubSubSize) if err != nil { totalLength, err := math.AddInt( - len(params.BeaconNetworkConfig().MessageDomainValidSnappy), + len(params.BeaconConfig().MessageDomainValidSnappy), len(topicLenBytes), topicLen, len(pmsg.Data), @@ -105,7 +102,7 @@ func postAltairMsgID(pmsg *pubsubpb.Message, fEpoch primitives.Epoch) string { return string(msg) } combinedData := make([]byte, 0, totalLength) - combinedData = append(combinedData, params.BeaconNetworkConfig().MessageDomainInvalidSnappy[:]...) + combinedData = append(combinedData, params.BeaconConfig().MessageDomainInvalidSnappy[:]...) combinedData = append(combinedData, topicLenBytes...) combinedData = append(combinedData, topic...) combinedData = append(combinedData, pmsg.Data...) @@ -113,7 +110,7 @@ func postAltairMsgID(pmsg *pubsubpb.Message, fEpoch primitives.Epoch) string { return string(h[:20]) } totalLength, err := math.AddInt( - len(params.BeaconNetworkConfig().MessageDomainValidSnappy), + len(params.BeaconConfig().MessageDomainValidSnappy), len(topicLenBytes), topicLen, len(decodedData), @@ -126,7 +123,7 @@ func postAltairMsgID(pmsg *pubsubpb.Message, fEpoch primitives.Epoch) string { return string(msg) } combinedData := make([]byte, 0, totalLength) - combinedData = append(combinedData, params.BeaconNetworkConfig().MessageDomainValidSnappy[:]...) + combinedData = append(combinedData, params.BeaconConfig().MessageDomainValidSnappy[:]...) combinedData = append(combinedData, topicLenBytes...) combinedData = append(combinedData, topic...) combinedData = append(combinedData, decodedData...) diff --git a/beacon-chain/p2p/message_id_test.go b/beacon-chain/p2p/message_id_test.go index fe7ed7e44a..f253d95038 100644 --- a/beacon-chain/p2p/message_id_test.go +++ b/beacon-chain/p2p/message_id_test.go @@ -24,14 +24,14 @@ func TestMsgID_HashesCorrectly(t *testing.T) { tpc := fmt.Sprintf(p2p.BlockSubnetTopicFormat, d) invalidSnappy := [32]byte{'J', 'U', 'N', 'K'} pMsg := &pubsubpb.Message{Data: invalidSnappy[:], Topic: &tpc} - hashedData := hash.Hash(append(params.BeaconNetworkConfig().MessageDomainInvalidSnappy[:], pMsg.Data...)) + hashedData := hash.Hash(append(params.BeaconConfig().MessageDomainInvalidSnappy[:], pMsg.Data...)) msgID := string(hashedData[:20]) assert.Equal(t, msgID, p2p.MsgID(genesisValidatorsRoot, pMsg), "Got incorrect msg id") validObj := [32]byte{'v', 'a', 'l', 'i', 'd'} enc := snappy.Encode(nil, validObj[:]) nMsg := &pubsubpb.Message{Data: enc, Topic: &tpc} - hashedData = hash.Hash(append(params.BeaconNetworkConfig().MessageDomainValidSnappy[:], validObj[:]...)) + hashedData = hash.Hash(append(params.BeaconConfig().MessageDomainValidSnappy[:], validObj[:]...)) msgID = string(hashedData[:20]) assert.Equal(t, msgID, p2p.MsgID(genesisValidatorsRoot, nMsg), "Got incorrect msg id") } @@ -47,7 +47,7 @@ func TestMessageIDFunction_HashesCorrectlyAltair(t *testing.T) { invalidSnappy := [32]byte{'J', 'U', 'N', 'K'} pMsg := &pubsubpb.Message{Data: invalidSnappy[:], Topic: &tpc} // Create object to hash - combinedObj := append(params.BeaconNetworkConfig().MessageDomainInvalidSnappy[:], topicLenBytes...) + combinedObj := append(params.BeaconConfig().MessageDomainInvalidSnappy[:], topicLenBytes...) combinedObj = append(combinedObj, tpc...) combinedObj = append(combinedObj, pMsg.Data...) hashedData := hash.Hash(combinedObj) @@ -58,7 +58,7 @@ func TestMessageIDFunction_HashesCorrectlyAltair(t *testing.T) { enc := snappy.Encode(nil, validObj[:]) nMsg := &pubsubpb.Message{Data: enc, Topic: &tpc} // Create object to hash - combinedObj = append(params.BeaconNetworkConfig().MessageDomainValidSnappy[:], topicLenBytes...) + combinedObj = append(params.BeaconConfig().MessageDomainValidSnappy[:], topicLenBytes...) combinedObj = append(combinedObj, tpc...) combinedObj = append(combinedObj, validObj[:]...) hashedData = hash.Hash(combinedObj) @@ -77,7 +77,7 @@ func TestMessageIDFunction_HashesCorrectlyBellatrix(t *testing.T) { invalidSnappy := [32]byte{'J', 'U', 'N', 'K'} pMsg := &pubsubpb.Message{Data: invalidSnappy[:], Topic: &tpc} // Create object to hash - combinedObj := append(params.BeaconNetworkConfig().MessageDomainInvalidSnappy[:], topicLenBytes...) + combinedObj := append(params.BeaconConfig().MessageDomainInvalidSnappy[:], topicLenBytes...) combinedObj = append(combinedObj, tpc...) combinedObj = append(combinedObj, pMsg.Data...) hashedData := hash.Hash(combinedObj) @@ -88,7 +88,7 @@ func TestMessageIDFunction_HashesCorrectlyBellatrix(t *testing.T) { enc := snappy.Encode(nil, validObj[:]) nMsg := &pubsubpb.Message{Data: enc, Topic: &tpc} // Create object to hash - combinedObj = append(params.BeaconNetworkConfig().MessageDomainValidSnappy[:], topicLenBytes...) + combinedObj = append(params.BeaconConfig().MessageDomainValidSnappy[:], topicLenBytes...) combinedObj = append(combinedObj, tpc...) combinedObj = append(combinedObj, validObj[:]...) hashedData = hash.Hash(combinedObj) diff --git a/beacon-chain/p2p/peers/scorers/BUILD.bazel b/beacon-chain/p2p/peers/scorers/BUILD.bazel index fd3088af33..54f076f8aa 100644 --- a/beacon-chain/p2p/peers/scorers/BUILD.bazel +++ b/beacon-chain/p2p/peers/scorers/BUILD.bazel @@ -19,7 +19,6 @@ go_library( "//consensus-types/primitives:go_default_library", "//crypto/rand:go_default_library", "//proto/prysm/v1alpha1:go_default_library", - "//time:go_default_library", "@com_github_libp2p_go_libp2p//core/peer:go_default_library", ], ) diff --git a/beacon-chain/p2p/peers/scorers/block_providers.go b/beacon-chain/p2p/peers/scorers/block_providers.go index 2c1bf71ac5..5632b518c0 100644 --- a/beacon-chain/p2p/peers/scorers/block_providers.go +++ b/beacon-chain/p2p/peers/scorers/block_providers.go @@ -11,7 +11,6 @@ import ( "github.com/prysmaticlabs/prysm/v4/cmd/beacon-chain/flags" "github.com/prysmaticlabs/prysm/v4/config/features" "github.com/prysmaticlabs/prysm/v4/crypto/rand" - prysmTime "github.com/prysmaticlabs/prysm/v4/time" ) var _ Scorer = (*BlockProviderScorer)(nil) @@ -155,7 +154,7 @@ func (s *BlockProviderScorer) touch(pid peer.ID, t ...time.Time) { if len(t) == 1 { peerData.BlockProviderUpdated = t[0] } else { - peerData.BlockProviderUpdated = prysmTime.Now() + peerData.BlockProviderUpdated = time.Now() } } diff --git a/beacon-chain/p2p/peers/scorers/peer_status.go b/beacon-chain/p2p/peers/scorers/peer_status.go index 4bac2d8d3f..591205786d 100644 --- a/beacon-chain/p2p/peers/scorers/peer_status.go +++ b/beacon-chain/p2p/peers/scorers/peer_status.go @@ -3,13 +3,13 @@ package scorers import ( "errors" "math" + "time" "github.com/libp2p/go-libp2p/core/peer" "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/peers/peerdata" p2ptypes "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" pb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" - "github.com/prysmaticlabs/prysm/v4/time" ) var _ Scorer = (*PeerStatusScorer)(nil) diff --git a/beacon-chain/p2p/pubsub.go b/beacon-chain/p2p/pubsub.go index 6ba53d8f0f..047295d2e5 100644 --- a/beacon-chain/p2p/pubsub.go +++ b/beacon-chain/p2p/pubsub.go @@ -140,7 +140,7 @@ func (s *Service) pubsubOptions() []pubsub.Option { }), pubsub.WithSubscriptionFilter(s), pubsub.WithPeerOutboundQueueSize(int(s.cfg.QueueSize)), - pubsub.WithMaxMessageSize(int(params.BeaconNetworkConfig().GossipMaxSizeBellatrix)), + pubsub.WithMaxMessageSize(int(params.BeaconConfig().GossipMaxSize)), pubsub.WithValidateQueueSize(int(s.cfg.QueueSize)), pubsub.WithPeerScore(peerScoringParams()), pubsub.WithPeerScoreInspect(s.peerInspector, time.Minute), diff --git a/beacon-chain/p2p/service.go b/beacon-chain/p2p/service.go index a3b80ca116..bd72e7d1ee 100644 --- a/beacon-chain/p2p/service.go +++ b/beacon-chain/p2p/service.go @@ -49,7 +49,7 @@ var refreshRate = slots.DivideSlotBy(2) const maxBadResponses = 5 // maxDialTimeout is the timeout for a single peer dial. -var maxDialTimeout = params.BeaconNetworkConfig().RespTimeout +var maxDialTimeout = params.BeaconConfig().RespTimeoutDuration() // Service for managing peer to peer (p2p) networking. type Service struct { @@ -134,7 +134,7 @@ func NewService(ctx context.Context, cfg *Config) (*Service, error) { // Set the pubsub global parameters that we require. setPubSubParameters() // Reinitialize them in the event we are running a custom config. - attestationSubnetCount = params.BeaconNetworkConfig().AttestationSubnetCount + attestationSubnetCount = params.BeaconConfig().AttestationSubnetCount syncCommsSubnetCount = params.BeaconConfig().SyncCommitteeSubnetCount gs, err := pubsub.NewGossipSub(s.ctx, s.host, psOpts...) @@ -217,16 +217,12 @@ func (s *Service) Start() { // current epoch. s.RefreshENR() - // if the current epoch is beyond bellatrix, increase the - // MaxGossipSize and MaxChunkSize to 10Mb. - s.increaseMaxMessageSizesForBellatrix() - // Periodic functions. - async.RunEvery(s.ctx, params.BeaconNetworkConfig().TtfbTimeout, func() { + async.RunEvery(s.ctx, params.BeaconConfig().TtfbTimeoutDuration(), func() { ensurePeerConnections(s.ctx, s.host, s.peers, relayNodes...) }) async.RunEvery(s.ctx, 30*time.Minute, s.Peers().Prune) - async.RunEvery(s.ctx, params.BeaconNetworkConfig().RespTimeout, s.updateMetrics) + async.RunEvery(s.ctx, time.Duration(params.BeaconConfig().RespTimeout)*time.Second, s.updateMetrics) async.RunEvery(s.ctx, refreshRate, s.RefreshENR) async.RunEvery(s.ctx, 1*time.Minute, func() { log.WithFields(logrus.Fields{ @@ -475,14 +471,3 @@ func (s *Service) connectToBootnodes() error { func (s *Service) isInitialized() bool { return !s.genesisTime.IsZero() && len(s.genesisValidatorsRoot) == 32 } - -// increaseMaxMessageSizesForBellatrix increases the max sizes of gossip and chunk from 1 Mb to 10Mb, -// if the current epoch is or above the configured BellatrixForkEpoch. -func (s *Service) increaseMaxMessageSizesForBellatrix() { - currentSlot := slots.Since(s.genesisTime) - currentEpoch := slots.ToEpoch(currentSlot) - if currentEpoch >= params.BeaconConfig().BellatrixForkEpoch { - encoder.SetMaxGossipSizeForBellatrix() - encoder.SetMaxChunkSizeForBellatrix() - } -} diff --git a/beacon-chain/p2p/subnets.go b/beacon-chain/p2p/subnets.go index 66b9252b95..8c8cfd3b5b 100644 --- a/beacon-chain/p2p/subnets.go +++ b/beacon-chain/p2p/subnets.go @@ -25,7 +25,7 @@ import ( pb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1" ) -var attestationSubnetCount = params.BeaconNetworkConfig().AttestationSubnetCount +var attestationSubnetCount = params.BeaconConfig().AttestationSubnetCount var syncCommsSubnetCount = params.BeaconConfig().SyncCommitteeSubnetCount var attSubnetEnrKey = params.BeaconNetworkConfig().AttSubnetKey @@ -237,7 +237,7 @@ func computeSubscribedSubnet(nodeID enode.ID, epoch primitives.Epoch, index uint if err != nil { return 0, err } - subnet := (uint64(permutatedPrefix) + index) % params.BeaconNetworkConfig().AttestationSubnetCount + subnet := (uint64(permutatedPrefix) + index) % params.BeaconConfig().AttestationSubnetCount return subnet, nil } diff --git a/beacon-chain/p2p/types/types.go b/beacon-chain/p2p/types/types.go index 3151c1d75d..8557d73642 100644 --- a/beacon-chain/p2p/types/types.go +++ b/beacon-chain/p2p/types/types.go @@ -47,8 +47,8 @@ func (r *BeaconBlockByRootsReq) MarshalSSZTo(dst []byte) ([]byte, error) { // MarshalSSZ Marshals the block by roots request type into the serialized object. func (r *BeaconBlockByRootsReq) MarshalSSZ() ([]byte, error) { - if len(*r) > int(params.BeaconNetworkConfig().MaxRequestBlocks) { - return nil, errors.Errorf("beacon block by roots request exceeds max size: %d > %d", len(*r), params.BeaconNetworkConfig().MaxRequestBlocks) + if len(*r) > int(params.BeaconConfig().MaxRequestBlocks) { + return nil, errors.Errorf("beacon block by roots request exceeds max size: %d > %d", len(*r), params.BeaconConfig().MaxRequestBlocks) } buf := make([]byte, 0, r.SizeSSZ()) for _, r := range *r { @@ -66,7 +66,7 @@ func (r *BeaconBlockByRootsReq) SizeSSZ() int { // block by roots request object. func (r *BeaconBlockByRootsReq) UnmarshalSSZ(buf []byte) error { bufLen := len(buf) - maxLength := int(params.BeaconNetworkConfig().MaxRequestBlocks * rootLength) + maxLength := int(params.BeaconConfig().MaxRequestBlocks * rootLength) if bufLen > maxLength { return errors.Errorf("expected buffer with length of up to %d but received length %d", maxLength, bufLen) } diff --git a/beacon-chain/p2p/types/types_test.go b/beacon-chain/p2p/types/types_test.go index 0d93410623..3a08a7ce9e 100644 --- a/beacon-chain/p2p/types/types_test.go +++ b/beacon-chain/p2p/types/types_test.go @@ -82,7 +82,7 @@ func TestBlobSidecarsByRootReq_MarshalSSZ(t *testing.T) { func TestBeaconBlockByRootsReq_Limit(t *testing.T) { fixedRoots := make([][32]byte, 0) - for i := uint64(0); i < params.BeaconNetworkConfig().MaxRequestBlocks+100; i++ { + for i := uint64(0); i < params.BeaconConfig().MaxRequestBlocks+100; i++ { fixedRoots = append(fixedRoots, [32]byte{byte(i)}) } req := BeaconBlockByRootsReq(fixedRoots) diff --git a/beacon-chain/rpc/core/validator.go b/beacon-chain/rpc/core/validator.go index 0ba7960728..12b39bd147 100644 --- a/beacon-chain/rpc/core/validator.go +++ b/beacon-chain/rpc/core/validator.go @@ -255,7 +255,7 @@ func (s *Service) SubmitSignedAggregateSelectionProof( // As a preventive measure, a beacon node shouldn't broadcast an attestation whose slot is out of range. if err := helpers.ValidateAttestationTime(req.SignedAggregateAndProof.Message.Aggregate.Data.Slot, - s.GenesisTimeFetcher.GenesisTime(), params.BeaconNetworkConfig().MaximumGossipClockDisparity); err != nil { + s.GenesisTimeFetcher.GenesisTime(), params.BeaconConfig().MaximumGossipClockDisparityDuration()); err != nil { return &RpcError{Err: errors.New("attestation slot is no longer valid from current time"), Reason: BadRequest} } @@ -321,7 +321,7 @@ func (s *Service) GetAttestationData( if err := helpers.ValidateAttestationTime( req.Slot, s.GenesisTimeFetcher.GenesisTime(), - params.BeaconNetworkConfig().MaximumGossipClockDisparity, + params.BeaconConfig().MaximumGossipClockDisparityDuration(), ); err != nil { return nil, &RpcError{Reason: BadRequest, Err: errors.Errorf("invalid request: %v", err)} } diff --git a/beacon-chain/rpc/eth/config/handlers_test.go b/beacon-chain/rpc/eth/config/handlers_test.go index 94cf8ee624..21c3058ffd 100644 --- a/beacon-chain/rpc/eth/config/handlers_test.go +++ b/beacon-chain/rpc/eth/config/handlers_test.go @@ -172,7 +172,7 @@ func TestGetSpec(t *testing.T) { data, ok := resp.Data.(map[string]interface{}) require.Equal(t, true, ok) - assert.Equal(t, 121, len(data)) + assert.Equal(t, 132, len(data)) for k, v := range data { switch k { case "CONFIG_NAME": @@ -430,10 +430,32 @@ func TestGetSpec(t *testing.T) { assert.Equal(t, "256", v) case "MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS": assert.Equal(t, "4096", v) - case "MAX_REQUEST_BLOCKS_DENEB": - assert.Equal(t, "128", v) case "MAX_REQUEST_BLOB_SIDECARS": assert.Equal(t, "768", v) + case "MESSAGE_DOMAIN_INVALID_SNAPPY": + assert.Equal(t, "0x00000000", v) + case "MESSAGE_DOMAIN_VALID_SNAPPY": + assert.Equal(t, "0x01000000", v) + case "ATTESTATION_PROPAGATION_SLOT_RANGE": + assert.Equal(t, "32", v) + case "RESP_TIMEOUT": + assert.Equal(t, "10", v) + case "TTFB_TIMEOUT": + assert.Equal(t, "5", v) + case "MIN_EPOCHS_FOR_BLOCK_REQUESTS": + assert.Equal(t, "33024", v) + case "GOSSIP_MAX_SIZE": + assert.Equal(t, "10485760", v) + case "MAX_CHUNK_SIZE": + assert.Equal(t, "10485760", v) + case "ATTESTATION_SUBNET_COUNT": + assert.Equal(t, "64", v) + case "MAXIMUM_GOSSIP_CLOCK_DISPARITY": + assert.Equal(t, "500", v) + case "MAX_REQUEST_BLOCKS": + assert.Equal(t, "1024", v) + case "MAX_REQUEST_BLOCKS_DENEB": + assert.Equal(t, "128", v) default: t.Errorf("Incorrect key: %s", k) } diff --git a/beacon-chain/sync/deadlines.go b/beacon-chain/sync/deadlines.go index fe8a397f58..cac4ed9083 100644 --- a/beacon-chain/sync/deadlines.go +++ b/beacon-chain/sync/deadlines.go @@ -10,7 +10,7 @@ import ( ) var defaultReadDuration = ttfbTimeout -var defaultWriteDuration = params.BeaconNetworkConfig().RespTimeout // RESP_TIMEOUT +var defaultWriteDuration = params.BeaconConfig().RespTimeoutDuration() // RESP_TIMEOUT // SetRPCStreamDeadlines sets read and write deadlines for libp2p-based connection streams. func SetRPCStreamDeadlines(stream network.Stream) { diff --git a/beacon-chain/sync/error.go b/beacon-chain/sync/error.go index 100bab890b..ea70f06099 100644 --- a/beacon-chain/sync/error.go +++ b/beacon-chain/sync/error.go @@ -28,7 +28,7 @@ func (s *Service) generateErrorResponse(code byte, reason string) ([]byte, error // ReadStatusCode response from a RPC stream. func ReadStatusCode(stream network.Stream, encoding encoder.NetworkEncoding) (uint8, string, error) { // Set ttfb deadline. - SetStreamReadDeadline(stream, params.BeaconNetworkConfig().TtfbTimeout) + SetStreamReadDeadline(stream, params.BeaconConfig().TtfbTimeoutDuration()) b := make([]byte, 1) _, err := stream.Read(b) if err != nil { @@ -37,13 +37,13 @@ func ReadStatusCode(stream network.Stream, encoding encoder.NetworkEncoding) (ui if b[0] == responseCodeSuccess { // Set response deadline on a successful response code. - SetStreamReadDeadline(stream, params.BeaconNetworkConfig().RespTimeout) + SetStreamReadDeadline(stream, params.BeaconConfig().RespTimeoutDuration()) return 0, "", nil } // Set response deadline, when reading error message. - SetStreamReadDeadline(stream, params.BeaconNetworkConfig().RespTimeout) + SetStreamReadDeadline(stream, params.BeaconConfig().RespTimeoutDuration()) msg := &types.ErrorMessage{} if err := encoding.DecodeWithMaxLength(stream, msg); err != nil { return 0, "", err diff --git a/beacon-chain/sync/metrics.go b/beacon-chain/sync/metrics.go index 26e5014082..8b23c404d6 100644 --- a/beacon-chain/sync/metrics.go +++ b/beacon-chain/sync/metrics.go @@ -180,7 +180,7 @@ func (s *Service) updateMetrics() { attTopic += s.cfg.p2p.Encoding().ProtocolSuffix() syncTopic += s.cfg.p2p.Encoding().ProtocolSuffix() if flags.Get().SubscribeToAllSubnets { - for i := uint64(0); i < params.BeaconNetworkConfig().AttestationSubnetCount; i++ { + for i := uint64(0); i < params.BeaconConfig().AttestationSubnetCount; i++ { s.collectMetricForSubnet(attTopic, digest, i) } for i := uint64(0); i < params.BeaconConfig().SyncCommitteeSubnetCount; i++ { diff --git a/beacon-chain/sync/rpc.go b/beacon-chain/sync/rpc.go index cf40853ba8..b6d1950c69 100644 --- a/beacon-chain/sync/rpc.go +++ b/beacon-chain/sync/rpc.go @@ -5,6 +5,7 @@ import ( "reflect" "runtime/debug" "strings" + "time" libp2pcore "github.com/libp2p/go-libp2p/core" "github.com/libp2p/go-libp2p/core/network" @@ -14,7 +15,6 @@ import ( p2ptypes "github.com/prysmaticlabs/prysm/v4/beacon-chain/p2p/types" "github.com/prysmaticlabs/prysm/v4/config/params" "github.com/prysmaticlabs/prysm/v4/monitoring/tracing" - "github.com/prysmaticlabs/prysm/v4/time" "github.com/prysmaticlabs/prysm/v4/time/slots" "go.opencensus.io/trace" ) @@ -22,10 +22,10 @@ import ( // Time to first byte timeout. The maximum time to wait for first byte of // request response (time-to-first-byte). The client is expected to give up if // they don't receive the first byte within 5 seconds. -var ttfbTimeout = params.BeaconNetworkConfig().TtfbTimeout +var ttfbTimeout = params.BeaconConfig().TtfbTimeoutDuration() // respTimeout is the maximum time for complete response transfer. -var respTimeout = params.BeaconNetworkConfig().RespTimeout +var respTimeout = params.BeaconConfig().RespTimeoutDuration() // rpcHandler is responsible for handling and responding to any incoming message. // This method may return an error to internal monitoring, but the error will diff --git a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go index 1234462bac..43a1b3f0d6 100644 --- a/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go +++ b/beacon-chain/sync/rpc_beacon_blocks_by_range_test.go @@ -581,7 +581,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { { name: "Over limit Count", req: ðpb.BeaconBlocksByRangeRequest{ - Count: params.BeaconNetworkConfig().MaxRequestBlocks + 1, + Count: params.BeaconConfig().MaxRequestBlocks + 1, Step: 1, }, expectedError: p2ptypes.ErrInvalidRequest, @@ -590,7 +590,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { { name: "Correct Count", req: ðpb.BeaconBlocksByRangeRequest{ - Count: params.BeaconNetworkConfig().MaxRequestBlocks - 1, + Count: params.BeaconConfig().MaxRequestBlocks - 1, Step: 1, }, errorToLog: "validation failed with correct count", @@ -633,7 +633,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { name: "Over Limit End Slot", req: ðpb.BeaconBlocksByRangeRequest{ Step: 1, - Count: params.BeaconNetworkConfig().MaxRequestBlocks + 1, + Count: params.BeaconConfig().MaxRequestBlocks + 1, }, expectedError: p2ptypes.ErrInvalidRequest, errorToLog: "validation did not fail with bad end slot", @@ -650,7 +650,7 @@ func TestRPCBeaconBlocksByRange_validateRangeRequest(t *testing.T) { name: "Valid Request", req: ðpb.BeaconBlocksByRangeRequest{ Step: 1, - Count: params.BeaconNetworkConfig().MaxRequestBlocks - 1, + Count: params.BeaconConfig().MaxRequestBlocks - 1, StartSlot: 50, }, errorToLog: "validation failed with valid params", diff --git a/beacon-chain/sync/rpc_send_request_test.go b/beacon-chain/sync/rpc_send_request_test.go index 703a249329..235f8ef628 100644 --- a/beacon-chain/sync/rpc_send_request_test.go +++ b/beacon-chain/sync/rpc_send_request_test.go @@ -167,18 +167,18 @@ func TestSendRequest_SendBeaconBlocksByRangeRequest(t *testing.T) { assert.Equal(t, 128, len(blocks)) // Cap max returned roots. - cfg := params.BeaconNetworkConfig().Copy() + cfg := params.BeaconConfig().Copy() maxRequestBlocks := cfg.MaxRequestBlocks defer func() { cfg.MaxRequestBlocks = maxRequestBlocks - params.OverrideBeaconNetworkConfig(cfg) + params.OverrideBeaconConfig(cfg) }() blocks, err = SendBeaconBlocksByRangeRequest(ctx, startup.NewClock(time.Now(), [32]byte{}), p1, p2.PeerID(), req, func(block interfaces.ReadOnlySignedBeaconBlock) error { // Since ssz checks the boundaries, and doesn't normally allow to send requests bigger than // the max request size, we are updating max request size dynamically. Even when updated dynamically, // no more than max request size of blocks is expected on return. cfg.MaxRequestBlocks = 3 - params.OverrideBeaconNetworkConfig(cfg) + params.OverrideBeaconConfig(cfg) return nil }) assert.ErrorContains(t, ErrInvalidFetchedData.Error(), err) @@ -419,18 +419,18 @@ func TestSendRequest_SendBeaconBlocksByRootRequest(t *testing.T) { assert.Equal(t, 4, len(blocks)) // Cap max returned roots. - cfg := params.BeaconNetworkConfig().Copy() + cfg := params.BeaconConfig().Copy() maxRequestBlocks := cfg.MaxRequestBlocks defer func() { cfg.MaxRequestBlocks = maxRequestBlocks - params.OverrideBeaconNetworkConfig(cfg) + params.OverrideBeaconConfig(cfg) }() blocks, err = SendBeaconBlocksByRootRequest(ctx, clock, p1, p2.PeerID(), req, func(block interfaces.ReadOnlySignedBeaconBlock) error { // Since ssz checks the boundaries, and doesn't normally allow to send requests bigger than // the max request size, we are updating max request size dynamically. Even when updated dynamically, // no more than max request size of blocks is expected on return. cfg.MaxRequestBlocks = 3 - params.OverrideBeaconNetworkConfig(cfg) + params.OverrideBeaconConfig(cfg) return nil }) assert.NoError(t, err) diff --git a/beacon-chain/sync/service.go b/beacon-chain/sync/service.go index c457cda589..8b71fbe16c 100644 --- a/beacon-chain/sync/service.go +++ b/beacon-chain/sync/service.go @@ -66,7 +66,7 @@ var ( // time to allow processing early blocks. earlyBlockProcessingTolerance = slots.MultiplySlotBy(2) // time to allow processing early attestations. - earlyAttestationProcessingTolerance = params.BeaconNetworkConfig().MaximumGossipClockDisparity + earlyAttestationProcessingTolerance = params.BeaconConfig().MaximumGossipClockDisparityDuration() errWrongMessage = errors.New("wrong pubsub message") errNilMessage = errors.New("nil pubsub message") ) diff --git a/beacon-chain/sync/subscriber.go b/beacon-chain/sync/subscriber.go index 4c061c7b99..188e1d33e0 100644 --- a/beacon-chain/sync/subscriber.go +++ b/beacon-chain/sync/subscriber.go @@ -90,7 +90,7 @@ func (s *Service) registerSubscribers(epoch primitives.Epoch, digest [4]byte) { s.validateCommitteeIndexBeaconAttestation, /* validator */ s.committeeIndexBeaconAttestationSubscriber, /* message handler */ digest, - params.BeaconNetworkConfig().AttestationSubnetCount, + params.BeaconConfig().AttestationSubnetCount, ) } else { s.subscribeDynamicWithSubnets( diff --git a/beacon-chain/sync/subscriber_test.go b/beacon-chain/sync/subscriber_test.go index 59a65637a9..911a2e76ca 100644 --- a/beacon-chain/sync/subscriber_test.go +++ b/beacon-chain/sync/subscriber_test.go @@ -335,10 +335,10 @@ func TestStaticSubnets(t *testing.T) { r.subscribeStaticWithSubnets(defaultTopic, r.noopValidator, func(_ context.Context, msg proto.Message) error { // no-op return nil - }, d, params.BeaconNetworkConfig().AttestationSubnetCount) + }, d, params.BeaconConfig().AttestationSubnetCount) topics := r.cfg.p2p.PubSub().GetTopics() - if uint64(len(topics)) != params.BeaconNetworkConfig().AttestationSubnetCount { - t.Errorf("Wanted the number of subnet topics registered to be %d but got %d", params.BeaconNetworkConfig().AttestationSubnetCount, len(topics)) + if uint64(len(topics)) != params.BeaconConfig().AttestationSubnetCount { + t.Errorf("Wanted the number of subnet topics registered to be %d but got %d", params.BeaconConfig().AttestationSubnetCount, len(topics)) } cancel() } diff --git a/beacon-chain/sync/validate_beacon_blocks.go b/beacon-chain/sync/validate_beacon_blocks.go index d3b92f46a8..107cb9dc28 100644 --- a/beacon-chain/sync/validate_beacon_blocks.go +++ b/beacon-chain/sync/validate_beacon_blocks.go @@ -428,7 +428,7 @@ func isBlockQueueable(genesisTime uint64, slot primitives.Slot, receivedTime tim return false } - currentTimeWithDisparity := receivedTime.Add(params.BeaconNetworkConfig().MaximumGossipClockDisparity) + currentTimeWithDisparity := receivedTime.Add(params.BeaconConfig().MaximumGossipClockDisparityDuration()) return currentTimeWithDisparity.Unix() < slotTime.Unix() } diff --git a/beacon-chain/sync/validate_sync_committee_message.go b/beacon-chain/sync/validate_sync_committee_message.go index a49ddb0b88..da3311f86c 100644 --- a/beacon-chain/sync/validate_sync_committee_message.go +++ b/beacon-chain/sync/validate_sync_committee_message.go @@ -73,7 +73,7 @@ func (s *Service) validateSyncCommitteeMessage( if err := altair.ValidateSyncMessageTime( m.Slot, s.cfg.clock.GenesisTime(), - params.BeaconNetworkConfig().MaximumGossipClockDisparity, + params.BeaconConfig().MaximumGossipClockDisparityDuration(), ); err != nil { tracing.AnnotateError(span, err) return pubsub.ValidationIgnore, err diff --git a/beacon-chain/sync/validate_sync_contribution_proof.go b/beacon-chain/sync/validate_sync_contribution_proof.go index 5db07c3c13..4cecac0746 100644 --- a/beacon-chain/sync/validate_sync_contribution_proof.go +++ b/beacon-chain/sync/validate_sync_contribution_proof.go @@ -59,7 +59,7 @@ func (s *Service) validateSyncContributionAndProof(ctx context.Context, pid peer } // The contribution's slot is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance). - if err := altair.ValidateSyncMessageTime(m.Message.Contribution.Slot, s.cfg.clock.GenesisTime(), params.BeaconNetworkConfig().MaximumGossipClockDisparity); err != nil { + if err := altair.ValidateSyncMessageTime(m.Message.Contribution.Slot, s.cfg.clock.GenesisTime(), params.BeaconConfig().MaximumGossipClockDisparityDuration()); err != nil { tracing.AnnotateError(span, err) return pubsub.ValidationIgnore, err } diff --git a/beacon-chain/verification/blob.go b/beacon-chain/verification/blob.go index 62f6c9a9d9..bb91edc79d 100644 --- a/beacon-chain/verification/blob.go +++ b/beacon-chain/verification/blob.go @@ -118,7 +118,7 @@ func (bv *BlobVerifier) SlotNotTooEarly() (err error) { return nil } // Subtract the max clock disparity from the start slot time. - validAfter := bv.clock.SlotStart(bv.blob.Slot()).Add(-1 * params.BeaconNetworkConfig().MaximumGossipClockDisparity) + validAfter := bv.clock.SlotStart(bv.blob.Slot()).Add(-1 * params.BeaconConfig().MaximumGossipClockDisparityDuration()) // If the difference between now and gt is greater than maximum clock disparity, the block is too far in the future. if bv.clock.Now().Before(validAfter) { return ErrSlotTooEarly diff --git a/beacon-chain/verification/blob_test.go b/beacon-chain/verification/blob_test.go index fd1c6f1f9d..1c69ec5a95 100644 --- a/beacon-chain/verification/blob_test.go +++ b/beacon-chain/verification/blob_test.go @@ -59,13 +59,13 @@ func TestSlotNotTooEarly(t *testing.T) { // Since we have an early return for slots that are directly equal, give a time that is less than max disparity // but still in the previous slot. - closeClock := startup.NewClock(genesis, [32]byte{}, startup.WithNower(func() time.Time { return now.Add(-1 * params.BeaconNetworkConfig().MaximumGossipClockDisparity / 2) })) + closeClock := startup.NewClock(genesis, [32]byte{}, startup.WithNower(func() time.Time { return now.Add(-1 * params.BeaconConfig().MaximumGossipClockDisparityDuration() / 2) })) ini = Initializer{shared: &sharedResources{clock: closeClock}} v = ini.NewBlobVerifier(b, GossipSidecarRequirements...) require.NoError(t, v.SlotNotTooEarly()) // This clock will give a current slot of 0, with now coming more than max clock disparity before slot 1 - disparate := now.Add(-2 * params.BeaconNetworkConfig().MaximumGossipClockDisparity) + disparate := now.Add(-2 * params.BeaconConfig().MaximumGossipClockDisparityDuration()) dispClock := startup.NewClock(genesis, [32]byte{}, startup.WithNower(func() time.Time { return disparate })) // Set up initializer to use the clock that will set now to a little to far before slot 1 ini = Initializer{shared: &sharedResources{clock: dispClock}} diff --git a/config/params/config.go b/config/params/config.go index 0cb636079f..16f6c57d0e 100644 --- a/config/params/config.go +++ b/config/params/config.go @@ -229,12 +229,23 @@ type BeaconChainConfig struct { MaxRequestBlobSidecars uint64 `yaml:"MAX_REQUEST_BLOB_SIDECARS" spec:"true"` // MaxRequestBlobSidecars is the maximum number of blobs to request in a single request. MaxRequestBlocksDeneb uint64 `yaml:"MAX_REQUEST_BLOCKS_DENEB" spec:"true"` // MaxRequestBlocksDeneb is the maximum number of blocks in a single request after the deneb epoch. - // Values related to the new subnet backbone - EpochsPerSubnetSubscription uint64 `yaml:"EPOCHS_PER_SUBNET_SUBSCRIPTION" spec:"true"` // EpochsPerSubnetSubscription specifies the minimum duration a validator is connected to their subnet. - AttestationSubnetExtraBits uint64 `yaml:"ATTESTATION_SUBNET_EXTRA_BITS" spec:"true"` // AttestationSubnetExtraBits is the number of extra bits of a NodeId to use when mapping to a subscribed subnet. - AttestationSubnetPrefixBits uint64 `yaml:"ATTESTATION_SUBNET_PREFIX_BITS" spec:"true"` // AttestationSubnetPrefixBits is defined as (ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS). - SubnetsPerNode uint64 `yaml:"SUBNETS_PER_NODE" spec:"true"` // SubnetsPerNode is the number of long-lived subnets a beacon node should be subscribed to. - NodeIdBits uint64 `yaml:"NODE_ID_BITS" spec:"true"` // NodeIdBits defines the bit length of a node id. + // Networking Specific Parameters + GossipMaxSize uint64 `yaml:"GOSSIP_MAX_SIZE" spec:"true"` // GossipMaxSize is the maximum allowed size of uncompressed gossip messages. + MaxChunkSize uint64 `yaml:"MAX_CHUNK_SIZE" spec:"true"` // MaxChunkSize is the maximum allowed size of uncompressed req/resp chunked responses. + AttestationSubnetCount uint64 `yaml:"ATTESTATION_SUBNET_COUNT" spec:"true"` // AttestationSubnetCount is the number of attestation subnets used in the gossipsub protocol. + AttestationPropagationSlotRange primitives.Slot `yaml:"ATTESTATION_PROPAGATION_SLOT_RANGE" spec:"true"` // AttestationPropagationSlotRange is the maximum number of slots during which an attestation can be propagated. + MaxRequestBlocks uint64 `yaml:"MAX_REQUEST_BLOCKS" spec:"true"` // MaxRequestBlocks is the maximum number of blocks in a single request. + TtfbTimeout uint64 `yaml:"TTFB_TIMEOUT" spec:"true"` // TtfbTimeout is the maximum time to wait for first byte of request response (time-to-first-byte). + RespTimeout uint64 `yaml:"RESP_TIMEOUT" spec:"true"` // RespTimeout is the maximum time for complete response transfer. + MaximumGossipClockDisparity uint64 `yaml:"MAXIMUM_GOSSIP_CLOCK_DISPARITY" spec:"true"` // MaximumGossipClockDisparity is the maximum milliseconds of clock disparity assumed between honest nodes. + MessageDomainInvalidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_INVALID_SNAPPY" spec:"true"` // MessageDomainInvalidSnappy is the 4-byte domain for gossip message-id isolation of invalid snappy messages. + MessageDomainValidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_VALID_SNAPPY" spec:"true"` // MessageDomainValidSnappy is the 4-byte domain for gossip message-id isolation of valid snappy messages. + MinEpochsForBlockRequests uint64 `yaml:"MIN_EPOCHS_FOR_BLOCK_REQUESTS" spec:"true"` // MinEpochsForBlockRequests represents the minimum number of epochs for which we can serve block requests. + EpochsPerSubnetSubscription uint64 `yaml:"EPOCHS_PER_SUBNET_SUBSCRIPTION" spec:"true"` // EpochsPerSubnetSubscription specifies the minimum duration a validator is connected to their subnet. + AttestationSubnetExtraBits uint64 `yaml:"ATTESTATION_SUBNET_EXTRA_BITS" spec:"true"` // AttestationSubnetExtraBits is the number of extra bits of a NodeId to use when mapping to a subscribed subnet. + AttestationSubnetPrefixBits uint64 `yaml:"ATTESTATION_SUBNET_PREFIX_BITS" spec:"true"` // AttestationSubnetPrefixBits is defined as (ceillog2(ATTESTATION_SUBNET_COUNT) + ATTESTATION_SUBNET_EXTRA_BITS). + SubnetsPerNode uint64 `yaml:"SUBNETS_PER_NODE" spec:"true"` // SubnetsPerNode is the number of long-lived subnets a beacon node should be subscribed to. + NodeIdBits uint64 `yaml:"NODE_ID_BITS" spec:"true"` // NodeIdBits defines the bit length of a node id. } // InitializeForkSchedule initializes the schedules forks baked into the config. @@ -295,6 +306,21 @@ func (b *BeaconChainConfig) CurrentEpochAttestationsLength() uint64 { return uint64(b.SlotsPerEpoch.Mul(b.MaxAttestations)) } +// TtfbTimeoutDuration returns the time duration of the timeout. +func (b *BeaconChainConfig) TtfbTimeoutDuration() time.Duration { + return time.Duration(b.TtfbTimeout) * time.Second +} + +// RespTimeoutDuration returns the time duration of the timeout. +func (b *BeaconChainConfig) RespTimeoutDuration() time.Duration { + return time.Duration(b.RespTimeout) * time.Second +} + +// MaximumGossipClockDisparityDuration returns the time duration of the clock disparity. +func (b *BeaconChainConfig) MaximumGossipClockDisparityDuration() time.Duration { + return time.Duration(b.MaximumGossipClockDisparity) * time.Millisecond +} + // DenebEnabled centralizes the check to determine if code paths // that are specific to deneb should be allowed to execute. This will make it easier to find call sites that do this // kind of check and remove them post-deneb. diff --git a/config/params/loader.go b/config/params/loader.go index dd4eaee19d..7f801b8187 100644 --- a/config/params/loader.go +++ b/config/params/loader.go @@ -219,28 +219,17 @@ func ConfigToYaml(cfg *BeaconChainConfig) []byte { fmt.Sprintf("ATTESTATION_SUBNET_PREFIX_BITS: %d", cfg.AttestationSubnetPrefixBits), fmt.Sprintf("SUBNETS_PER_NODE: %d", cfg.SubnetsPerNode), fmt.Sprintf("NODE_ID_BITS: %d", cfg.NodeIdBits), - } - - yamlFile := []byte(strings.Join(lines, "\n")) - return yamlFile -} - -// NetworkConfigToYaml takes a provided network config and outputs its contents -// in yaml. This allows prysm's network configs to be read by other clients. -func NetworkConfigToYaml(cfg *NetworkConfig) []byte { - lines := []string{ fmt.Sprintf("GOSSIP_MAX_SIZE: %d", cfg.GossipMaxSize), - fmt.Sprintf("GOSSIP_MAX_SIZE_BELLATRIX: %d", cfg.GossipMaxSizeBellatrix), fmt.Sprintf("MAX_CHUNK_SIZE: %d", cfg.MaxChunkSize), - fmt.Sprintf("MAX_CHUNK_SIZE_BELLATRIX: %d", cfg.MaxChunkSizeBellatrix), fmt.Sprintf("ATTESTATION_SUBNET_COUNT: %d", cfg.AttestationSubnetCount), fmt.Sprintf("ATTESTATION_PROPAGATION_SLOT_RANGE: %d", cfg.AttestationPropagationSlotRange), fmt.Sprintf("MAX_REQUEST_BLOCKS: %d", cfg.MaxRequestBlocks), - fmt.Sprintf("TTFB_TIMEOUT: %d", int(cfg.TtfbTimeout.Seconds())), - fmt.Sprintf("RESP_TIMEOUT: %d", int(cfg.RespTimeout.Seconds())), - fmt.Sprintf("MAXIMUM_GOSSIP_CLOCK_DISPARITY: %d", int(cfg.MaximumGossipClockDisparity.Seconds())), + fmt.Sprintf("TTFB_TIMEOUT: %d", int(cfg.TtfbTimeout)), + fmt.Sprintf("RESP_TIMEOUT: %d", int(cfg.RespTimeout)), + fmt.Sprintf("MAXIMUM_GOSSIP_CLOCK_DISPARITY: %d", int(cfg.MaximumGossipClockDisparity)), fmt.Sprintf("MESSAGE_DOMAIN_INVALID_SNAPPY: %#x", cfg.MessageDomainInvalidSnappy), fmt.Sprintf("MESSAGE_DOMAIN_VALID_SNAPPY: %#x", cfg.MessageDomainValidSnappy), + fmt.Sprintf("MIN_EPOCHS_FOR_BLOCK_REQUESTS: %d", int(cfg.MinEpochsForBlockRequests)), } yamlFile := []byte(strings.Join(lines, "\n")) diff --git a/config/params/loader_test.go b/config/params/loader_test.go index 32ebf81219..e5661d26f8 100644 --- a/config/params/loader_test.go +++ b/config/params/loader_test.go @@ -23,23 +23,12 @@ import ( // These are variables that we don't use in Prysm. (i.e. future hardfork, light client... etc) // IMPORTANT: Use one field per line and sort these alphabetically to reduce conflicts. var placeholderFields = []string{ - "ATTESTATION_PROPAGATION_SLOT_RANGE", - "ATTESTATION_SUBNET_COUNT", "EIP6110_FORK_EPOCH", "EIP6110_FORK_VERSION", "EIP7002_FORK_EPOCH", "EIP7002_FORK_VERSION", - "GOSSIP_MAX_SIZE", - "MAXIMUM_GOSSIP_CLOCK_DISPARITY", "MAX_BLOBS_PER_BLOCK", - "MAX_CHUNK_SIZE", - "MAX_REQUEST_BLOCKS", - "MESSAGE_DOMAIN_INVALID_SNAPPY", - "MESSAGE_DOMAIN_VALID_SNAPPY", - "MIN_EPOCHS_FOR_BLOCK_REQUESTS", "REORG_HEAD_WEIGHT_THRESHOLD", - "RESP_TIMEOUT", - "TTFB_TIMEOUT", "UPDATE_TIMEOUT", "WHISK_EPOCHS_PER_SHUFFLING_PHASE", "WHISK_FORK_EPOCH", diff --git a/config/params/mainnet_config.go b/config/params/mainnet_config.go index 6378043f20..1633d95bce 100644 --- a/config/params/mainnet_config.go +++ b/config/params/mainnet_config.go @@ -27,23 +27,11 @@ const ( ) var mainnetNetworkConfig = &NetworkConfig{ - GossipMaxSize: 1 << 20, // 1 MiB - GossipMaxSizeBellatrix: 10 * 1 << 20, // 10 MiB - MaxChunkSize: 1 << 20, // 1 MiB - MaxChunkSizeBellatrix: 10 * 1 << 20, // 10 MiB - AttestationSubnetCount: 64, - AttestationPropagationSlotRange: 32, - MaxRequestBlocks: 1 << 10, // 1024 - TtfbTimeout: 5 * time.Second, - RespTimeout: 10 * time.Second, - MaximumGossipClockDisparity: 500 * time.Millisecond, - MessageDomainInvalidSnappy: [4]byte{00, 00, 00, 00}, - MessageDomainValidSnappy: [4]byte{01, 00, 00, 00}, - ETH2Key: "eth2", - AttSubnetKey: "attnets", - SyncCommsSubnetKey: "syncnets", - MinimumPeersInSubnetSearch: 20, - ContractDeploymentBlock: 11184524, // Note: contract was deployed in block 11052984 but no transactions were sent until 11184524. + ETH2Key: "eth2", + AttSubnetKey: "attnets", + SyncCommsSubnetKey: "syncnets", + MinimumPeersInSubnetSearch: 20, + ContractDeploymentBlock: 11184524, // Note: contract was deployed in block 11052984 but no transactions were sent until 11184524. BootstrapNodes: []string{ // Teku team's bootnode "enr:-KG4QMOEswP62yzDjSwWS4YEjtTZ5PO6r65CPqYBkgTTkrpaedQ8uEUo1uMALtJIvb2w_WWEVmg5yt1UAuK1ftxUU7QDhGV0aDKQu6TalgMAAAD__________4JpZIJ2NIJpcIQEnfA2iXNlY3AyNTZrMaEDfol8oLr6XJ7FsdAYE7lpJhKMls4G_v6qQOGKJUWGb_uDdGNwgiMog3VkcIIjKA", @@ -275,12 +263,23 @@ var mainnetBeaconConfig = &BeaconChainConfig{ MaxRequestBlobSidecars: 768, MaxRequestBlocksDeneb: 128, - // Values related to the new subnet backbone - EpochsPerSubnetSubscription: 256, - AttestationSubnetExtraBits: 0, - AttestationSubnetPrefixBits: 6, - SubnetsPerNode: 2, - NodeIdBits: 256, + // Values related to networking parameters. + GossipMaxSize: 10 * 1 << 20, // 10 MiB + MaxChunkSize: 10 * 1 << 20, // 10 MiB + AttestationSubnetCount: 64, + AttestationPropagationSlotRange: 32, + MaxRequestBlocks: 1 << 10, // 1024 + TtfbTimeout: 5, + RespTimeout: 10, + MaximumGossipClockDisparity: 500, + MessageDomainInvalidSnappy: [4]byte{00, 00, 00, 00}, + MessageDomainValidSnappy: [4]byte{01, 00, 00, 00}, + MinEpochsForBlockRequests: 33024, // MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT / 2 (= 33024, ~5 months) + EpochsPerSubnetSubscription: 256, + AttestationSubnetExtraBits: 0, + AttestationSubnetPrefixBits: 6, + SubnetsPerNode: 2, + NodeIdBits: 256, } // MainnetTestConfig provides a version of the mainnet config that has a different name diff --git a/config/params/mainnet_config_test.go b/config/params/mainnet_config_test.go index d439f620ca..7f518c1ee2 100644 --- a/config/params/mainnet_config_test.go +++ b/config/params/mainnet_config_test.go @@ -14,7 +14,7 @@ func TestMaxRequestBlock(t *testing.T) { }{ { epoch: primitives.Epoch(mainnetDenebForkEpoch - 1), // Assuming the fork epoch is not 0 - expectedMaxBlock: mainnetNetworkConfig.MaxRequestBlocks, + expectedMaxBlock: mainnetBeaconConfig.MaxRequestBlocks, }, { epoch: primitives.Epoch(mainnetDenebForkEpoch), diff --git a/config/params/minimal_config.go b/config/params/minimal_config.go index 9b85d563ad..6e2039ed7e 100644 --- a/config/params/minimal_config.go +++ b/config/params/minimal_config.go @@ -94,6 +94,7 @@ func MinimalSpecConfig() *BeaconChainConfig { minimalConfig.SyncCommitteeSize = 32 minimalConfig.InactivityScoreBias = 4 minimalConfig.EpochsPerSyncCommitteePeriod = 8 + minimalConfig.MinEpochsForBlockRequests = 272 // Ethereum PoW parameters. minimalConfig.DepositChainID = 5 // Chain ID of eth1 goerli. diff --git a/config/params/network_config.go b/config/params/network_config.go index 56bc304b29..4d78fde50f 100644 --- a/config/params/network_config.go +++ b/config/params/network_config.go @@ -1,27 +1,12 @@ package params import ( - "time" - "github.com/mohae/deepcopy" "github.com/prysmaticlabs/prysm/v4/consensus-types/primitives" ) // NetworkConfig defines the spec based network parameters. type NetworkConfig struct { - GossipMaxSize uint64 `yaml:"GOSSIP_MAX_SIZE"` // GossipMaxSize is the maximum allowed size of uncompressed gossip messages. - GossipMaxSizeBellatrix uint64 `yaml:"GOSSIP_MAX_SIZE_BELLATRIX"` // GossipMaxSizeBellatrix is the maximum allowed size of uncompressed gossip messages after the bellatrix epoch. - MaxChunkSize uint64 `yaml:"MAX_CHUNK_SIZE"` // MaxChunkSize is the maximum allowed size of uncompressed req/resp chunked responses. - MaxChunkSizeBellatrix uint64 `yaml:"MAX_CHUNK_SIZE_BELLATRIX"` // MaxChunkSizeBellatrix is the maximum allowed size of uncompressed req/resp chunked responses after the bellatrix epoch. - AttestationSubnetCount uint64 `yaml:"ATTESTATION_SUBNET_COUNT"` // AttestationSubnetCount is the number of attestation subnets used in the gossipsub protocol. - AttestationPropagationSlotRange primitives.Slot `yaml:"ATTESTATION_PROPAGATION_SLOT_RANGE"` // AttestationPropagationSlotRange is the maximum number of slots during which an attestation can be propagated. - MaxRequestBlocks uint64 `yaml:"MAX_REQUEST_BLOCKS"` // MaxRequestBlocks is the maximum number of blocks in a single request. - TtfbTimeout time.Duration `yaml:"TTFB_TIMEOUT"` // TtfbTimeout is the maximum time to wait for first byte of request response (time-to-first-byte). - RespTimeout time.Duration `yaml:"RESP_TIMEOUT"` // RespTimeout is the maximum time for complete response transfer. - MaximumGossipClockDisparity time.Duration `yaml:"MAXIMUM_GOSSIP_CLOCK_DISPARITY"` // MaximumGossipClockDisparity is the maximum milliseconds of clock disparity assumed between honest nodes. - MessageDomainInvalidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_INVALID_SNAPPY"` // MessageDomainInvalidSnappy is the 4-byte domain for gossip message-id isolation of invalid snappy messages. - MessageDomainValidSnappy [4]byte `yaml:"MESSAGE_DOMAIN_VALID_SNAPPY"` // MessageDomainValidSnappy is the 4-byte domain for gossip message-id isolation of valid snappy messages. - // DiscoveryV5 Config ETH2Key string // ETH2Key is the ENR key of the Ethereum consensus object in an enr. AttSubnetKey string // AttSubnetKey is the ENR key of the subnet bitfield in the enr. @@ -63,5 +48,5 @@ func MaxRequestBlock(e primitives.Epoch) uint64 { if e >= BeaconConfig().DenebForkEpoch { return BeaconConfig().MaxRequestBlocksDeneb } - return networkConfig.MaxRequestBlocks + return BeaconConfig().MaxRequestBlocks } diff --git a/testing/endtoend/components/web3remotesigner.go b/testing/endtoend/components/web3remotesigner.go index d93576b32b..26ad2bab4b 100644 --- a/testing/endtoend/components/web3remotesigner.go +++ b/testing/endtoend/components/web3remotesigner.go @@ -260,9 +260,6 @@ func createTestnetDir() (string, error) { // Add in deposit contract in yaml depContractStr := fmt.Sprintf("\nDEPOSIT_CONTRACT_ADDRESS: %s\n", params.BeaconConfig().DepositContractAddress) rawYaml = append(rawYaml, []byte(depContractStr)...) - rawYaml = append(rawYaml, params.NetworkConfigToYaml(params.BeaconNetworkConfig())...) - - rawYaml = append(rawYaml, []byte("\nMIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024\n")...) if err := file.MkdirAll(testNetDir); err != nil { return "", err diff --git a/testing/spectest/shared/common/forkchoice/builder.go b/testing/spectest/shared/common/forkchoice/builder.go index e6162d0c29..f8243707cf 100644 --- a/testing/spectest/shared/common/forkchoice/builder.go +++ b/testing/spectest/shared/common/forkchoice/builder.go @@ -108,7 +108,7 @@ func (bb *Builder) PoWBlock(pb *ethpb.PowBlock) { // Attestation receives the attestation and updates forkchoice. func (bb *Builder) Attestation(t testing.TB, a *ethpb.Attestation) { - require.NoError(t, bb.service.OnAttestation(context.TODO(), a, params.BeaconNetworkConfig().MaximumGossipClockDisparity)) + require.NoError(t, bb.service.OnAttestation(context.TODO(), a, params.BeaconConfig().MaximumGossipClockDisparityDuration())) } // AttesterSlashing receives an attester slashing and feeds it to forkchoice.