prysm-pulse/config/params/network_config.go

53 lines
1.9 KiB
Go
Raw Normal View History

package params
2020-06-24 14:03:16 +00:00
import (
"github.com/mohae/deepcopy"
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
2020-06-24 14:03:16 +00:00
)
// NetworkConfig defines the spec based network parameters.
type NetworkConfig struct {
// 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.
SyncCommsSubnetKey string // SyncCommsSubnetKey is the ENR key of the sync committee subnet bitfield in the enr.
MinimumPeersInSubnetSearch uint64 // PeersInSubnetSearch is the required amount of peers that we need to be able to lookup in a subnet search.
2020-06-24 14:03:16 +00:00
// Chain Network Config
ContractDeploymentBlock uint64 // ContractDeploymentBlock is the eth1 block in which the deposit contract is deployed.
BootstrapNodes []string // BootstrapNodes are the addresses of the bootnodes.
}
var networkConfig = mainnetNetworkConfig
// BeaconNetworkConfig returns the current network config for
// the beacon chain.
func BeaconNetworkConfig() *NetworkConfig {
return networkConfig
2020-06-24 14:03:16 +00:00
}
// OverrideBeaconNetworkConfig will override the network
// config with the added argument.
func OverrideBeaconNetworkConfig(cfg *NetworkConfig) {
networkConfig = cfg.Copy()
2020-06-24 14:03:16 +00:00
}
// Copy returns Copy of the config object.
func (c *NetworkConfig) Copy() *NetworkConfig {
config, ok := deepcopy.Copy(*c).(NetworkConfig)
if !ok {
config = *networkConfig
2020-06-24 14:03:16 +00:00
}
return &config
}
// MaxRequestBlock determines the maximum number of blocks that can be requested in a single
// request for a given epoch. If the epoch is at or beyond config's `DenebForkEpoch`,
// a special limit defined for Deneb is used.
func MaxRequestBlock(e primitives.Epoch) uint64 {
if e >= BeaconConfig().DenebForkEpoch {
return BeaconConfig().MaxRequestBlocksDeneb
}
return BeaconConfig().MaxRequestBlocks
}