2020-04-16 22:21:44 +00:00
|
|
|
package params
|
|
|
|
|
2020-06-24 14:03:16 +00:00
|
|
|
import (
|
|
|
|
"github.com/mohae/deepcopy"
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
2020-06-24 14:03:16 +00:00
|
|
|
)
|
2020-04-16 22:21:44 +00:00
|
|
|
|
|
|
|
// NetworkConfig defines the spec based network parameters.
|
|
|
|
type NetworkConfig struct {
|
|
|
|
// DiscoveryV5 Config
|
2021-06-26 19:00:33 +00:00
|
|
|
ETH2Key string // ETH2Key is the ENR key of the Ethereum consensus object in an enr.
|
2020-12-12 02:40:56 +00:00
|
|
|
AttSubnetKey string // AttSubnetKey is the ENR key of the subnet bitfield in the enr.
|
2021-07-18 16:18:43 +00:00
|
|
|
SyncCommsSubnetKey string // SyncCommsSubnetKey is the ENR key of the sync committee subnet bitfield in the enr.
|
2020-12-12 02:40:56 +00:00
|
|
|
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.
|
2020-04-16 22:21:44 +00:00
|
|
|
}
|
|
|
|
|
2020-06-27 00:20:24 +00:00
|
|
|
var networkConfig = mainnetNetworkConfig
|
2020-04-16 22:21:44 +00:00
|
|
|
|
|
|
|
// BeaconNetworkConfig returns the current network config for
|
|
|
|
// the beacon chain.
|
|
|
|
func BeaconNetworkConfig() *NetworkConfig {
|
2020-06-27 00:20:24 +00:00
|
|
|
return networkConfig
|
2020-06-24 14:03:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// OverrideBeaconNetworkConfig will override the network
|
|
|
|
// config with the added argument.
|
|
|
|
func OverrideBeaconNetworkConfig(cfg *NetworkConfig) {
|
2020-06-27 00:20:24 +00:00
|
|
|
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 {
|
2020-06-27 00:20:24 +00:00
|
|
|
config = *networkConfig
|
2020-06-24 14:03:16 +00:00
|
|
|
}
|
|
|
|
return &config
|
|
|
|
}
|
2023-11-14 05:50:51 +00:00
|
|
|
|
|
|
|
// 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 {
|
2023-12-16 11:37:44 +00:00
|
|
|
return BeaconConfig().MaxRequestBlocksDeneb
|
2023-11-14 05:50:51 +00:00
|
|
|
}
|
2023-12-19 14:59:30 +00:00
|
|
|
return BeaconConfig().MaxRequestBlocks
|
2023-11-14 05:50:51 +00:00
|
|
|
}
|