mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Refactor Network Config Into Main Config (#13364)
* change parameters to main config * add more changes * change to accepted format * fix changes in config * gaz * fix test * fix test again
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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...)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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++ {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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"))
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user