github.com/prysmaticlabs/prysm@v1.4.4/shared/params/network_config.go (about)

     1  package params
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/mohae/deepcopy"
     7  	types "github.com/prysmaticlabs/eth2-types"
     8  )
     9  
    10  // NetworkConfig defines the spec based network parameters.
    11  type NetworkConfig struct {
    12  	GossipMaxSize                   uint64        `yaml:"GOSSIP_MAX_SIZE"`                    // GossipMaxSize is the maximum allowed size of uncompressed gossip messages.
    13  	MaxChunkSize                    uint64        `yaml:"MAX_CHUNK_SIZE"`                     // MaxChunkSize is the the maximum allowed size of uncompressed req/resp chunked responses.
    14  	AttestationSubnetCount          uint64        `yaml:"ATTESTATION_SUBNET_COUNT"`           // AttestationSubnetCount is the number of attestation subnets used in the gossipsub protocol.
    15  	AttestationPropagationSlotRange types.Slot    `yaml:"ATTESTATION_PROPAGATION_SLOT_RANGE"` // AttestationPropagationSlotRange is the maximum number of slots during which an attestation can be propagated.
    16  	MaxRequestBlocks                uint64        `yaml:"MAX_REQUEST_BLOCKS"`                 // MaxRequestBlocks is the maximum number of blocks in a single request.
    17  	TtfbTimeout                     time.Duration `yaml:"TTFB_TIMEOUT"`                       // TtfbTimeout is the maximum time to wait for first byte of request response (time-to-first-byte).
    18  	RespTimeout                     time.Duration `yaml:"RESP_TIMEOUT"`                       // RespTimeout is the maximum time for complete response transfer.
    19  	MaximumGossipClockDisparity     time.Duration `yaml:"MAXIMUM_GOSSIP_CLOCK_DISPARITY"`     // MaximumGossipClockDisparity is the maximum milliseconds of clock disparity assumed between honest nodes.
    20  	MessageDomainInvalidSnappy      [4]byte       `yaml:"MESSAGE_DOMAIN_INVALID_SNAPPY"`      // MessageDomainInvalidSnappy is the 4-byte domain for gossip message-id isolation of invalid snappy messages.
    21  	MessageDomainValidSnappy        [4]byte       `yaml:"MESSAGE_DOMAIN_VALID_SNAPPY"`        // MessageDomainValidSnappy is the 4-byte domain for gossip message-id isolation of valid snappy messages.
    22  
    23  	// DiscoveryV5 Config
    24  	ETH2Key                    string // ETH2Key is the ENR key of the Ethereum consensus object in an enr.
    25  	AttSubnetKey               string // AttSubnetKey is the ENR key of the subnet bitfield in the enr.
    26  	MinimumPeersInSubnet       uint64 // MinimumPeersInSubnet is the required amount of peers that a node is to have its in subnet.
    27  	MinimumPeersInSubnetSearch uint64 // PeersInSubnetSearch is the required amount of peers that we need to be able to lookup in a subnet search.
    28  
    29  	// Chain Network Config
    30  	ContractDeploymentBlock uint64   // ContractDeploymentBlock is the eth1 block in which the deposit contract is deployed.
    31  	BootstrapNodes          []string // BootstrapNodes are the addresses of the bootnodes.
    32  }
    33  
    34  var networkConfig = mainnetNetworkConfig
    35  
    36  // BeaconNetworkConfig returns the current network config for
    37  // the beacon chain.
    38  func BeaconNetworkConfig() *NetworkConfig {
    39  	return networkConfig
    40  }
    41  
    42  // OverrideBeaconNetworkConfig will override the network
    43  // config with the added argument.
    44  func OverrideBeaconNetworkConfig(cfg *NetworkConfig) {
    45  	networkConfig = cfg.Copy()
    46  }
    47  
    48  // Copy returns Copy of the config object.
    49  func (c *NetworkConfig) Copy() *NetworkConfig {
    50  	config, ok := deepcopy.Copy(*c).(NetworkConfig)
    51  	if !ok {
    52  		config = *networkConfig
    53  	}
    54  	return &config
    55  }