mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-09 21:38:05 -05:00
Move Shared/Params Into Config/Params (#9642)
* config params into pkg * gaz Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,7 @@ go_library(
|
||||
importpath = "github.com/prysmaticlabs/prysm/config/features",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//shared/params:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@com_github_urfave_cli_v2//:go_default_library",
|
||||
],
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/shared/params"
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
59
config/params/BUILD.bazel
Normal file
59
config/params/BUILD.bazel
Normal file
@@ -0,0 +1,59 @@
|
||||
load("@prysm//tools/go:def.bzl", "go_library", "go_test")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"config.go",
|
||||
"config_utils_develop.go", # keep
|
||||
"config_utils_prod.go",
|
||||
"io_config.go",
|
||||
"loader.go",
|
||||
"mainnet_config.go",
|
||||
"minimal_config.go",
|
||||
"network_config.go",
|
||||
"testnet_e2e_config.go",
|
||||
"testnet_prater_config.go",
|
||||
"testnet_pyrmont_config.go",
|
||||
"testutils.go",
|
||||
"values.go",
|
||||
],
|
||||
importpath = "github.com/prysmaticlabs/prysm/config/params",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//math:go_default_library",
|
||||
"//shared/bytesutil:go_default_library",
|
||||
"@com_github_ethereum_go_ethereum//params:go_default_library",
|
||||
"@com_github_mohae_deepcopy//:go_default_library",
|
||||
"@com_github_prysmaticlabs_eth2_types//:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@in_gopkg_yaml_v2//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
size = "small",
|
||||
srcs = [
|
||||
"checktags_test.go",
|
||||
"config_test.go",
|
||||
"loader_test.go",
|
||||
"testnet_config_test.go",
|
||||
"testnet_prater_config_test.go",
|
||||
],
|
||||
data = glob(["*.yaml"]) + [
|
||||
"@consensus_spec//:spec_data",
|
||||
"@consensus_spec_tests_mainnet//:test_data",
|
||||
"@consensus_spec_tests_minimal//:test_data",
|
||||
"@eth2_networks//:configs",
|
||||
],
|
||||
gotags = ["develop"],
|
||||
race = "on",
|
||||
deps = [
|
||||
":go_default_library",
|
||||
"//shared/testutil/assert:go_default_library",
|
||||
"//shared/testutil/require:go_default_library",
|
||||
"@com_github_sirupsen_logrus//:go_default_library",
|
||||
"@in_gopkg_yaml_v2//:go_default_library",
|
||||
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
||||
],
|
||||
)
|
||||
11
config/params/checktags_test.go
Normal file
11
config/params/checktags_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
// +build !develop
|
||||
|
||||
package params_test
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func init() {
|
||||
log.Fatal("Tests in this package require extra build tag: re-run with `-tags develop`")
|
||||
}
|
||||
185
config/params/config.go
Normal file
185
config/params/config.go
Normal file
@@ -0,0 +1,185 @@
|
||||
// Package params defines important constants that are essential to Prysm services.
|
||||
package params
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
)
|
||||
|
||||
// BeaconChainConfig contains constant configs for node to participate in beacon chain.
|
||||
type BeaconChainConfig struct {
|
||||
// Constants (non-configurable)
|
||||
GenesisSlot types.Slot `yaml:"GENESIS_SLOT"` // GenesisSlot represents the first canonical slot number of the beacon chain.
|
||||
GenesisEpoch types.Epoch `yaml:"GENESIS_EPOCH"` // GenesisEpoch represents the first canonical epoch number of the beacon chain.
|
||||
FarFutureEpoch types.Epoch `yaml:"FAR_FUTURE_EPOCH"` // FarFutureEpoch represents a epoch extremely far away in the future used as the default penalization epoch for validators.
|
||||
FarFutureSlot types.Slot `yaml:"FAR_FUTURE_SLOT"` // FarFutureSlot represents a slot extremely far away in the future.
|
||||
BaseRewardsPerEpoch uint64 `yaml:"BASE_REWARDS_PER_EPOCH"` // BaseRewardsPerEpoch is used to calculate the per epoch rewards.
|
||||
DepositContractTreeDepth uint64 `yaml:"DEPOSIT_CONTRACT_TREE_DEPTH"` // DepositContractTreeDepth depth of the Merkle trie of deposits in the validator deposit contract on the PoW chain.
|
||||
JustificationBitsLength uint64 `yaml:"JUSTIFICATION_BITS_LENGTH"` // JustificationBitsLength defines number of epochs to track when implementing k-finality in Casper FFG.
|
||||
|
||||
// Misc constants.
|
||||
PresetBase string `yaml:"PRESET_BASE" spec:"true"` // PresetBase represents the underlying spec preset this config is based on.
|
||||
ConfigName string `yaml:"CONFIG_NAME" spec:"true"` // ConfigName for allowing an easy human-readable way of knowing what chain is being used.
|
||||
TargetCommitteeSize uint64 `yaml:"TARGET_COMMITTEE_SIZE" spec:"true"` // TargetCommitteeSize is the number of validators in a committee when the chain is healthy.
|
||||
MaxValidatorsPerCommittee uint64 `yaml:"MAX_VALIDATORS_PER_COMMITTEE" spec:"true"` // MaxValidatorsPerCommittee defines the upper bound of the size of a committee.
|
||||
MaxCommitteesPerSlot uint64 `yaml:"MAX_COMMITTEES_PER_SLOT" spec:"true"` // MaxCommitteesPerSlot defines the max amount of committee in a single slot.
|
||||
MinPerEpochChurnLimit uint64 `yaml:"MIN_PER_EPOCH_CHURN_LIMIT" spec:"true"` // MinPerEpochChurnLimit is the minimum amount of churn allotted for validator rotations.
|
||||
ChurnLimitQuotient uint64 `yaml:"CHURN_LIMIT_QUOTIENT" spec:"true"` // ChurnLimitQuotient is used to determine the limit of how many validators can rotate per epoch.
|
||||
ShuffleRoundCount uint64 `yaml:"SHUFFLE_ROUND_COUNT" spec:"true"` // ShuffleRoundCount is used for retrieving the permuted index.
|
||||
MinGenesisActiveValidatorCount uint64 `yaml:"MIN_GENESIS_ACTIVE_VALIDATOR_COUNT" spec:"true"` // MinGenesisActiveValidatorCount defines how many validator deposits needed to kick off beacon chain.
|
||||
MinGenesisTime uint64 `yaml:"MIN_GENESIS_TIME" spec:"true"` // MinGenesisTime is the time that needed to pass before kicking off beacon chain.
|
||||
TargetAggregatorsPerCommittee uint64 `yaml:"TARGET_AGGREGATORS_PER_COMMITTEE" spec:"true"` // TargetAggregatorsPerCommittee defines the number of aggregators inside one committee.
|
||||
HysteresisQuotient uint64 `yaml:"HYSTERESIS_QUOTIENT" spec:"true"` // HysteresisQuotient defines the hysteresis quotient for effective balance calculations.
|
||||
HysteresisDownwardMultiplier uint64 `yaml:"HYSTERESIS_DOWNWARD_MULTIPLIER" spec:"true"` // HysteresisDownwardMultiplier defines the hysteresis downward multiplier for effective balance calculations.
|
||||
HysteresisUpwardMultiplier uint64 `yaml:"HYSTERESIS_UPWARD_MULTIPLIER" spec:"true"` // HysteresisUpwardMultiplier defines the hysteresis upward multiplier for effective balance calculations.
|
||||
|
||||
// Gwei value constants.
|
||||
MinDepositAmount uint64 `yaml:"MIN_DEPOSIT_AMOUNT" spec:"true"` // MinDepositAmount is the minimum amount of Gwei a validator can send to the deposit contract at once (lower amounts will be reverted).
|
||||
MaxEffectiveBalance uint64 `yaml:"MAX_EFFECTIVE_BALANCE" spec:"true"` // MaxEffectiveBalance is the maximal amount of Gwei that is effective for staking.
|
||||
EjectionBalance uint64 `yaml:"EJECTION_BALANCE" spec:"true"` // EjectionBalance is the minimal GWei a validator needs to have before ejected.
|
||||
EffectiveBalanceIncrement uint64 `yaml:"EFFECTIVE_BALANCE_INCREMENT" spec:"true"` // EffectiveBalanceIncrement is used for converting the high balance into the low balance for validators.
|
||||
|
||||
// Initial value constants.
|
||||
BLSWithdrawalPrefixByte byte `yaml:"BLS_WITHDRAWAL_PREFIX" spec:"true"` // BLSWithdrawalPrefixByte is used for BLS withdrawal and it's the first byte.
|
||||
ZeroHash [32]byte // ZeroHash is used to represent a zeroed out 32 byte array.
|
||||
|
||||
// Time parameters constants.
|
||||
GenesisDelay uint64 `yaml:"GENESIS_DELAY" spec:"true"` // GenesisDelay is the minimum number of seconds to delay starting the Ethereum Beacon Chain genesis. Must be at least 1 second.
|
||||
MinAttestationInclusionDelay types.Slot `yaml:"MIN_ATTESTATION_INCLUSION_DELAY" spec:"true"` // MinAttestationInclusionDelay defines how many slots validator has to wait to include attestation for beacon block.
|
||||
SecondsPerSlot uint64 `yaml:"SECONDS_PER_SLOT" spec:"true"` // SecondsPerSlot is how many seconds are in a single slot.
|
||||
SlotsPerEpoch types.Slot `yaml:"SLOTS_PER_EPOCH" spec:"true"` // SlotsPerEpoch is the number of slots in an epoch.
|
||||
SqrRootSlotsPerEpoch types.Slot // SqrRootSlotsPerEpoch is a hard coded value where we take the square root of `SlotsPerEpoch` and round down.
|
||||
MinSeedLookahead types.Epoch `yaml:"MIN_SEED_LOOKAHEAD" spec:"true"` // MinSeedLookahead is the duration of randao look ahead seed.
|
||||
MaxSeedLookahead types.Epoch `yaml:"MAX_SEED_LOOKAHEAD" spec:"true"` // MaxSeedLookahead is the duration a validator has to wait for entry and exit in epoch.
|
||||
EpochsPerEth1VotingPeriod types.Epoch `yaml:"EPOCHS_PER_ETH1_VOTING_PERIOD" spec:"true"` // EpochsPerEth1VotingPeriod defines how often the merkle root of deposit receipts get updated in beacon node on per epoch basis.
|
||||
SlotsPerHistoricalRoot types.Slot `yaml:"SLOTS_PER_HISTORICAL_ROOT" spec:"true"` // SlotsPerHistoricalRoot defines how often the historical root is saved.
|
||||
MinValidatorWithdrawabilityDelay types.Epoch `yaml:"MIN_VALIDATOR_WITHDRAWABILITY_DELAY" spec:"true"` // MinValidatorWithdrawabilityDelay is the shortest amount of time a validator has to wait to withdraw.
|
||||
ShardCommitteePeriod types.Epoch `yaml:"SHARD_COMMITTEE_PERIOD" spec:"true"` // ShardCommitteePeriod is the minimum amount of epochs a validator must participate before exiting.
|
||||
MinEpochsToInactivityPenalty types.Epoch `yaml:"MIN_EPOCHS_TO_INACTIVITY_PENALTY" spec:"true"` // MinEpochsToInactivityPenalty defines the minimum amount of epochs since finality to begin penalizing inactivity.
|
||||
Eth1FollowDistance uint64 `yaml:"ETH1_FOLLOW_DISTANCE" spec:"true"` // Eth1FollowDistance is the number of eth1.0 blocks to wait before considering a new deposit for voting. This only applies after the chain as been started.
|
||||
SafeSlotsToUpdateJustified types.Slot `yaml:"SAFE_SLOTS_TO_UPDATE_JUSTIFIED" spec:"true"` // SafeSlotsToUpdateJustified is the minimal slots needed to update justified check point.
|
||||
SecondsPerETH1Block uint64 `yaml:"SECONDS_PER_ETH1_BLOCK" spec:"true"` // SecondsPerETH1Block is the approximate time for a single eth1 block to be produced.
|
||||
|
||||
// Ethereum PoW parameters.
|
||||
DepositChainID uint64 `yaml:"DEPOSIT_CHAIN_ID" spec:"true"` // DepositChainID of the eth1 network. This used for replay protection.
|
||||
DepositNetworkID uint64 `yaml:"DEPOSIT_NETWORK_ID" spec:"true"` // DepositNetworkID of the eth1 network. This used for replay protection.
|
||||
DepositContractAddress string `yaml:"DEPOSIT_CONTRACT_ADDRESS" spec:"true"` // DepositContractAddress is the address of the deposit contract.
|
||||
|
||||
// Validator parameters.
|
||||
RandomSubnetsPerValidator uint64 `yaml:"RANDOM_SUBNETS_PER_VALIDATOR" spec:"true"` // RandomSubnetsPerValidator specifies the amount of subnets a validator has to be subscribed to at one time.
|
||||
EpochsPerRandomSubnetSubscription uint64 `yaml:"EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION" spec:"true"` // EpochsPerRandomSubnetSubscription specifies the minimum duration a validator is connected to their subnet.
|
||||
|
||||
// State list lengths
|
||||
EpochsPerHistoricalVector types.Epoch `yaml:"EPOCHS_PER_HISTORICAL_VECTOR" spec:"true"` // EpochsPerHistoricalVector defines max length in epoch to store old historical stats in beacon state.
|
||||
EpochsPerSlashingsVector types.Epoch `yaml:"EPOCHS_PER_SLASHINGS_VECTOR" spec:"true"` // EpochsPerSlashingsVector defines max length in epoch to store old stats to recompute slashing witness.
|
||||
HistoricalRootsLimit uint64 `yaml:"HISTORICAL_ROOTS_LIMIT" spec:"true"` // HistoricalRootsLimit defines max historical roots that can be saved in state before roll over.
|
||||
ValidatorRegistryLimit uint64 `yaml:"VALIDATOR_REGISTRY_LIMIT" spec:"true"` // ValidatorRegistryLimit defines the upper bound of validators can participate in eth2.
|
||||
|
||||
// Reward and penalty quotients constants.
|
||||
BaseRewardFactor uint64 `yaml:"BASE_REWARD_FACTOR" spec:"true"` // BaseRewardFactor is used to calculate validator per-slot interest rate.
|
||||
WhistleBlowerRewardQuotient uint64 `yaml:"WHISTLEBLOWER_REWARD_QUOTIENT" spec:"true"` // WhistleBlowerRewardQuotient is used to calculate whistle blower reward.
|
||||
ProposerRewardQuotient uint64 `yaml:"PROPOSER_REWARD_QUOTIENT" spec:"true"` // ProposerRewardQuotient is used to calculate the reward for proposers.
|
||||
InactivityPenaltyQuotient uint64 `yaml:"INACTIVITY_PENALTY_QUOTIENT" spec:"true"` // InactivityPenaltyQuotient is used to calculate the penalty for a validator that is offline.
|
||||
MinSlashingPenaltyQuotient uint64 `yaml:"MIN_SLASHING_PENALTY_QUOTIENT" spec:"true"` // MinSlashingPenaltyQuotient is used to calculate the minimum penalty to prevent DoS attacks.
|
||||
ProportionalSlashingMultiplier uint64 `yaml:"PROPORTIONAL_SLASHING_MULTIPLIER" spec:"true"` // ProportionalSlashingMultiplier is used as a multiplier on slashed penalties.
|
||||
|
||||
// Max operations per block constants.
|
||||
MaxProposerSlashings uint64 `yaml:"MAX_PROPOSER_SLASHINGS" spec:"true"` // MaxProposerSlashings defines the maximum number of slashings of proposers possible in a block.
|
||||
MaxAttesterSlashings uint64 `yaml:"MAX_ATTESTER_SLASHINGS" spec:"true"` // MaxAttesterSlashings defines the maximum number of casper FFG slashings possible in a block.
|
||||
MaxAttestations uint64 `yaml:"MAX_ATTESTATIONS" spec:"true"` // MaxAttestations defines the maximum allowed attestations in a beacon block.
|
||||
MaxDeposits uint64 `yaml:"MAX_DEPOSITS" spec:"true"` // MaxDeposits defines the maximum number of validator deposits in a block.
|
||||
MaxVoluntaryExits uint64 `yaml:"MAX_VOLUNTARY_EXITS" spec:"true"` // MaxVoluntaryExits defines the maximum number of validator exits in a block.
|
||||
|
||||
// BLS domain values.
|
||||
DomainBeaconProposer [4]byte `yaml:"DOMAIN_BEACON_PROPOSER" spec:"true"` // DomainBeaconProposer defines the BLS signature domain for beacon proposal verification.
|
||||
DomainRandao [4]byte `yaml:"DOMAIN_RANDAO" spec:"true"` // DomainRandao defines the BLS signature domain for randao verification.
|
||||
DomainBeaconAttester [4]byte `yaml:"DOMAIN_BEACON_ATTESTER" spec:"true"` // DomainBeaconAttester defines the BLS signature domain for attestation verification.
|
||||
DomainDeposit [4]byte `yaml:"DOMAIN_DEPOSIT" spec:"true"` // DomainDeposit defines the BLS signature domain for deposit verification.
|
||||
DomainVoluntaryExit [4]byte `yaml:"DOMAIN_VOLUNTARY_EXIT" spec:"true"` // DomainVoluntaryExit defines the BLS signature domain for exit verification.
|
||||
DomainSelectionProof [4]byte `yaml:"DOMAIN_SELECTION_PROOF" spec:"true"` // DomainSelectionProof defines the BLS signature domain for selection proof.
|
||||
DomainAggregateAndProof [4]byte `yaml:"DOMAIN_AGGREGATE_AND_PROOF" spec:"true"` // DomainAggregateAndProof defines the BLS signature domain for aggregate and proof.
|
||||
DomainSyncCommittee [4]byte `yaml:"DOMAIN_SYNC_COMMITTEE" spec:"true"` // DomainVoluntaryExit defines the BLS signature domain for sync committee.
|
||||
DomainSyncCommitteeSelectionProof [4]byte `yaml:"DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF" spec:"true"` // DomainSelectionProof defines the BLS signature domain for sync committee selection proof.
|
||||
DomainContributionAndProof [4]byte `yaml:"DOMAIN_CONTRIBUTION_AND_PROOF" spec:"true"` // DomainAggregateAndProof defines the BLS signature domain for contribution and proof.
|
||||
|
||||
// Prysm constants.
|
||||
GweiPerEth uint64 // GweiPerEth is the amount of gwei corresponding to 1 eth.
|
||||
BLSSecretKeyLength int // BLSSecretKeyLength defines the expected length of BLS secret keys in bytes.
|
||||
BLSPubkeyLength int // BLSPubkeyLength defines the expected length of BLS public keys in bytes.
|
||||
BLSSignatureLength int // BLSSignatureLength defines the expected length of BLS signatures in bytes.
|
||||
DefaultBufferSize int // DefaultBufferSize for channels across the Prysm repository.
|
||||
ValidatorPrivkeyFileName string // ValidatorPrivKeyFileName specifies the string name of a validator private key file.
|
||||
WithdrawalPrivkeyFileName string // WithdrawalPrivKeyFileName specifies the string name of a withdrawal private key file.
|
||||
RPCSyncCheck time.Duration // Number of seconds to query the sync service, to find out if the node is synced or not.
|
||||
EmptySignature [96]byte // EmptySignature is used to represent a zeroed out BLS Signature.
|
||||
DefaultPageSize int // DefaultPageSize defines the default page size for RPC server request.
|
||||
MaxPeersToSync int // MaxPeersToSync describes the limit for number of peers in round robin sync.
|
||||
SlotsPerArchivedPoint types.Slot // SlotsPerArchivedPoint defines the number of slots per one archived point.
|
||||
GenesisCountdownInterval time.Duration // How often to log the countdown until the genesis time is reached.
|
||||
BeaconStateFieldCount int // BeaconStateFieldCount defines how many fields are in beacon state.
|
||||
BeaconStateAltairFieldCount int // BeaconStateAltairFieldCount defines how many fields are in beacon state hard fork 1.
|
||||
|
||||
// Slasher constants.
|
||||
WeakSubjectivityPeriod types.Epoch // WeakSubjectivityPeriod defines the time period expressed in number of epochs were proof of stake network should validate block headers and attestations for slashable events.
|
||||
PruneSlasherStoragePeriod types.Epoch // PruneSlasherStoragePeriod defines the time period expressed in number of epochs were proof of stake network should prune attestation and block header store.
|
||||
|
||||
// Slashing protection constants.
|
||||
SlashingProtectionPruningEpochs types.Epoch // SlashingProtectionPruningEpochs defines a period after which all prior epochs are pruned in the validator database.
|
||||
|
||||
// Fork-related values.
|
||||
GenesisForkVersion []byte `yaml:"GENESIS_FORK_VERSION" spec:"true"` // GenesisForkVersion is used to track fork version between state transitions.
|
||||
AltairForkVersion []byte `yaml:"ALTAIR_FORK_VERSION" spec:"true"` // AltairForkVersion is used to represent the fork version for altair.
|
||||
AltairForkEpoch types.Epoch `yaml:"ALTAIR_FORK_EPOCH" spec:"true"` // AltairForkEpoch is used to represent the assigned fork epoch for altair.
|
||||
MergeForkVersion []byte `yaml:"MERGE_FORK_VERSION" spec:"true"` // MergeForkVersion is used to represent the fork version for the merge.
|
||||
MergeForkEpoch types.Epoch `yaml:"MERGE_FORK_EPOCH" spec:"true"` // MergeForkEpoch is used to represent the assigned fork epoch for the merge.
|
||||
ShardingForkVersion []byte `yaml:"SHARDING_FORK_VERSION" spec:"true"` // ShardingForkVersion is used to represent the fork version for sharding.
|
||||
ShardingForkEpoch types.Epoch `yaml:"SHARDING_FORK_EPOCH" spec:"true"` // ShardingForkEpoch is used to represent the assigned fork epoch for sharding.
|
||||
ForkVersionSchedule map[[4]byte]types.Epoch // Schedule of fork epochs by version.
|
||||
MinAnchorPowBlockDifficulty uint64 `yaml:"MIN_ANCHOR_POW_BLOCK_DIFFICULTY" spec:"true"` // MinAnchorPowBlockDifficulty specifies the target chain difficulty at the time of the merge.
|
||||
TransitionTotalDifficulty uint64 `yaml:"TRANSITION_TOTAL_DIFFICULTY" spec:"true"` // TransitionTotalDifficulty is part of the experimental merge spec. This value is not used (yet) and is expected to be a uint256.
|
||||
|
||||
// Weak subjectivity values.
|
||||
SafetyDecay uint64 // SafetyDecay is defined as the loss in the 1/3 consensus safety margin of the casper FFG mechanism.
|
||||
|
||||
// New values introduced in Altair hard fork 1.
|
||||
// Participation flag indices.
|
||||
TimelySourceFlagIndex uint8 `yaml:"TIMELY_SOURCE_FLAG_INDEX" spec:"true"` // TimelySourceFlagIndex is the source flag position of the participation bits.
|
||||
TimelyTargetFlagIndex uint8 `yaml:"TIMELY_TARGET_FLAG_INDEX" spec:"true"` // TimelyTargetFlagIndex is the target flag position of the participation bits.
|
||||
TimelyHeadFlagIndex uint8 `yaml:"TIMELY_HEAD_FLAG_INDEX" spec:"true"` // TimelyHeadFlagIndex is the head flag position of the participation bits.
|
||||
|
||||
// Incentivization weights.
|
||||
TimelySourceWeight uint64 `yaml:"TIMELY_SOURCE_WEIGHT" spec:"true"` // TimelySourceWeight is the factor of how much source rewards receives.
|
||||
TimelyTargetWeight uint64 `yaml:"TIMELY_TARGET_WEIGHT" spec:"true"` // TimelyTargetWeight is the factor of how much target rewards receives.
|
||||
TimelyHeadWeight uint64 `yaml:"TIMELY_HEAD_WEIGHT" spec:"true"` // TimelyHeadWeight is the factor of how much head rewards receives.
|
||||
SyncRewardWeight uint64 `yaml:"SYNC_REWARD_WEIGHT" spec:"true"` // SyncRewardWeight is the factor of how much sync committee rewards receives.
|
||||
WeightDenominator uint64 `yaml:"WEIGHT_DENOMINATOR" spec:"true"` // WeightDenominator accounts for total rewards denomination.
|
||||
ProposerWeight uint64 `yaml:"PROPOSER_WEIGHT" spec:"true"` // ProposerWeight is the factor of how much proposer rewards receives.
|
||||
|
||||
// Validator related.
|
||||
TargetAggregatorsPerSyncSubcommittee uint64 `yaml:"TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE" spec:"true"` // TargetAggregatorsPerSyncSubcommittee for aggregating in sync committee.
|
||||
SyncCommitteeSubnetCount uint64 `yaml:"SYNC_COMMITTEE_SUBNET_COUNT" spec:"true"` // SyncCommitteeSubnetCount for sync committee subnet count.
|
||||
|
||||
// Misc.
|
||||
SyncCommitteeSize uint64 `yaml:"SYNC_COMMITTEE_SIZE" spec:"true"` // SyncCommitteeSize for light client sync committee size.
|
||||
InactivityScoreBias uint64 `yaml:"INACTIVITY_SCORE_BIAS" spec:"true"` // InactivityScoreBias for calculating score bias penalties during inactivity
|
||||
InactivityScoreRecoveryRate uint64 `yaml:"INACTIVITY_SCORE_RECOVERY_RATE" spec:"true"` // InactivityScoreRecoveryRate for recovering score bias penalties during inactivity.
|
||||
EpochsPerSyncCommitteePeriod types.Epoch `yaml:"EPOCHS_PER_SYNC_COMMITTEE_PERIOD" spec:"true"` // EpochsPerSyncCommitteePeriod defines how many epochs per sync committee period.
|
||||
|
||||
// Updated penalty values. This moves penalty parameters toward their final, maximum security values.
|
||||
// Note: We do not override previous configuration values but instead creates new values and replaces usage throughout.
|
||||
InactivityPenaltyQuotientAltair uint64 `yaml:"INACTIVITY_PENALTY_QUOTIENT_ALTAIR" spec:"true"` // InactivityPenaltyQuotientAltair for penalties during inactivity post Altair hard fork.
|
||||
MinSlashingPenaltyQuotientAltair uint64 `yaml:"MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR" spec:"true"` // MinSlashingPenaltyQuotientAltair for slashing penalties post Altair hard fork.
|
||||
ProportionalSlashingMultiplierAltair uint64 `yaml:"PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR" spec:"true"` // ProportionalSlashingMultiplierAltair for slashing penalties multiplier post Alair hard fork.
|
||||
}
|
||||
|
||||
// InitializeForkSchedule initializes the schedules forks baked into the config.
|
||||
func (b *BeaconChainConfig) InitializeForkSchedule() {
|
||||
// Reset Fork Version Schedule.
|
||||
b.ForkVersionSchedule = map[[4]byte]types.Epoch{}
|
||||
// Set Genesis fork data.
|
||||
b.ForkVersionSchedule[bytesutil.ToBytes4(b.GenesisForkVersion)] = b.GenesisEpoch
|
||||
// Set Altair fork data.
|
||||
b.ForkVersionSchedule[bytesutil.ToBytes4(b.AltairForkVersion)] = b.AltairForkEpoch
|
||||
}
|
||||
46
config/params/config_test.go
Normal file
46
config/params/config_test.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package params_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
)
|
||||
|
||||
// Test cases can be executed in an arbitrary order. TestOverrideBeaconConfigTestTeardown checks
|
||||
// that there's no state mutation leak from the previous test, therefore we need a sentinel flag,
|
||||
// to make sure that previous test case has already been completed and check can be run.
|
||||
var testOverrideBeaconConfigExecuted bool
|
||||
|
||||
func TestConfig_OverrideBeaconConfig(t *testing.T) {
|
||||
// Ensure that param modifications are safe.
|
||||
params.SetupTestConfigCleanup(t)
|
||||
cfg := params.BeaconConfig()
|
||||
cfg.SlotsPerEpoch = 5
|
||||
params.OverrideBeaconConfig(cfg)
|
||||
if c := params.BeaconConfig(); c.SlotsPerEpoch != 5 {
|
||||
t.Errorf("Shardcount in BeaconConfig incorrect. Wanted %d, got %d", 5, c.SlotsPerEpoch)
|
||||
}
|
||||
testOverrideBeaconConfigExecuted = true
|
||||
}
|
||||
|
||||
func TestConfig_OverrideBeaconConfigTestTeardown(t *testing.T) {
|
||||
if !testOverrideBeaconConfigExecuted {
|
||||
t.Skip("State leak can occur only if state mutating test has already completed")
|
||||
}
|
||||
cfg := params.BeaconConfig()
|
||||
if cfg.SlotsPerEpoch == 5 {
|
||||
t.Fatal("Parameter update has been leaked out of previous test")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfig_DataRace(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
go func() {
|
||||
cfg := params.BeaconConfig()
|
||||
params.OverrideBeaconConfig(cfg)
|
||||
}()
|
||||
go func() uint64 {
|
||||
return params.BeaconConfig().MaxDeposits
|
||||
}()
|
||||
}
|
||||
}
|
||||
40
config/params/config_utils_develop.go
Normal file
40
config/params/config_utils_develop.go
Normal file
@@ -0,0 +1,40 @@
|
||||
// +build develop
|
||||
|
||||
package params
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/mohae/deepcopy"
|
||||
)
|
||||
|
||||
var beaconConfig = MainnetConfig()
|
||||
var beaconConfigLock sync.RWMutex
|
||||
|
||||
// BeaconConfig retrieves beacon chain config.
|
||||
func BeaconConfig() *BeaconChainConfig {
|
||||
beaconConfigLock.RLock()
|
||||
defer beaconConfigLock.RUnlock()
|
||||
return beaconConfig
|
||||
}
|
||||
|
||||
// OverrideBeaconConfig by replacing the config. The preferred pattern is to
|
||||
// call BeaconConfig(), change the specific parameters, and then call
|
||||
// OverrideBeaconConfig(c). Any subsequent calls to params.BeaconConfig() will
|
||||
// return this new configuration.
|
||||
func OverrideBeaconConfig(c *BeaconChainConfig) {
|
||||
beaconConfigLock.Lock()
|
||||
defer beaconConfigLock.Unlock()
|
||||
beaconConfig = c
|
||||
}
|
||||
|
||||
// Copy returns a copy of the config object.
|
||||
func (c *BeaconChainConfig) Copy() *BeaconChainConfig {
|
||||
beaconConfigLock.RLock()
|
||||
defer beaconConfigLock.RUnlock()
|
||||
config, ok := deepcopy.Copy(*c).(BeaconChainConfig)
|
||||
if !ok {
|
||||
config = *beaconConfig
|
||||
}
|
||||
return &config
|
||||
}
|
||||
31
config/params/config_utils_prod.go
Normal file
31
config/params/config_utils_prod.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// +build !develop
|
||||
|
||||
package params
|
||||
|
||||
import (
|
||||
"github.com/mohae/deepcopy"
|
||||
)
|
||||
|
||||
var beaconConfig = MainnetConfig()
|
||||
|
||||
// BeaconConfig retrieves beacon chain config.
|
||||
func BeaconConfig() *BeaconChainConfig {
|
||||
return beaconConfig
|
||||
}
|
||||
|
||||
// OverrideBeaconConfig by replacing the config. The preferred pattern is to
|
||||
// call BeaconConfig(), change the specific parameters, and then call
|
||||
// OverrideBeaconConfig(c). Any subsequent calls to params.BeaconConfig() will
|
||||
// return this new configuration.
|
||||
func OverrideBeaconConfig(c *BeaconChainConfig) {
|
||||
beaconConfig = c
|
||||
}
|
||||
|
||||
// Copy returns a copy of the config object.
|
||||
func (c *BeaconChainConfig) Copy() *BeaconChainConfig {
|
||||
config, ok := deepcopy.Copy(*c).(BeaconChainConfig)
|
||||
if !ok {
|
||||
config = *beaconConfig
|
||||
}
|
||||
return &config
|
||||
}
|
||||
35
config/params/io_config.go
Normal file
35
config/params/io_config.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"os"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
// IoConfig defines the shared io parameters.
|
||||
type IoConfig struct {
|
||||
ReadWritePermissions os.FileMode
|
||||
ReadWriteExecutePermissions os.FileMode
|
||||
BoltTimeout time.Duration
|
||||
}
|
||||
|
||||
var defaultIoConfig = &IoConfig{
|
||||
ReadWritePermissions: 0600, //-rw------- Read and Write permissions for user
|
||||
ReadWriteExecutePermissions: 0700, //-rwx------ Read Write and Execute (traverse) permissions for user
|
||||
BoltTimeout: 1 * time.Second, // 1 second for the bolt DB to timeout.
|
||||
}
|
||||
|
||||
var defaultWindowsIoConfig = &IoConfig{
|
||||
ReadWritePermissions: 0666,
|
||||
ReadWriteExecutePermissions: 0777,
|
||||
BoltTimeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
// BeaconIoConfig returns the current io config for
|
||||
// the beacon chain.
|
||||
func BeaconIoConfig() *IoConfig {
|
||||
if runtime.GOOS == "windows" {
|
||||
return defaultWindowsIoConfig
|
||||
}
|
||||
return defaultIoConfig
|
||||
}
|
||||
136
config/params/loader.go
Normal file
136
config/params/loader.go
Normal file
@@ -0,0 +1,136 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/math"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
// LoadChainConfigFile load, convert hex values into valid param yaml format,
|
||||
// unmarshal , and apply beacon chain config file.
|
||||
func LoadChainConfigFile(chainConfigFileName string) {
|
||||
yamlFile, err := ioutil.ReadFile(chainConfigFileName) // #nosec G304
|
||||
if err != nil {
|
||||
log.WithError(err).Fatal("Failed to read chain config file.")
|
||||
}
|
||||
// Default to using mainnet.
|
||||
conf := MainnetConfig().Copy()
|
||||
// Convert 0x hex inputs to fixed bytes arrays
|
||||
lines := strings.Split(string(yamlFile), "\n")
|
||||
for i, line := range lines {
|
||||
// No need to convert the deposit contract address to byte array (as config expects a string).
|
||||
if strings.HasPrefix(line, "DEPOSIT_CONTRACT_ADDRESS") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, "PRESET_BASE: 'minimal'") || strings.HasPrefix(line, "# Minimal preset") {
|
||||
conf = MinimalSpecConfig().Copy()
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(line, "#") && strings.Contains(line, "0x") {
|
||||
parts := ReplaceHexStringWithYAMLFormat(line)
|
||||
lines[i] = strings.Join(parts, "\n")
|
||||
}
|
||||
}
|
||||
yamlFile = []byte(strings.Join(lines, "\n"))
|
||||
if err := yaml.UnmarshalStrict(yamlFile, conf); err != nil {
|
||||
if _, ok := err.(*yaml.TypeError); !ok {
|
||||
log.WithError(err).Fatal("Failed to parse chain config yaml file.")
|
||||
} else {
|
||||
log.WithError(err).Error("There were some issues parsing the config from a yaml file")
|
||||
}
|
||||
}
|
||||
// recompute SqrRootSlotsPerEpoch constant to handle non-standard values of SlotsPerEpoch
|
||||
conf.SqrRootSlotsPerEpoch = types.Slot(math.IntegerSquareRoot(uint64(conf.SlotsPerEpoch)))
|
||||
log.Debugf("Config file values: %+v", conf)
|
||||
OverrideBeaconConfig(conf)
|
||||
}
|
||||
|
||||
// ReplaceHexStringWithYAMLFormat will replace hex strings that the yaml parser will understand.
|
||||
func ReplaceHexStringWithYAMLFormat(line string) []string {
|
||||
parts := strings.Split(line, "0x")
|
||||
decoded, err := hex.DecodeString(parts[1])
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to decode hex string.")
|
||||
}
|
||||
switch l := len(decoded); {
|
||||
case l == 1:
|
||||
var b byte
|
||||
b = decoded[0]
|
||||
fixedByte, err := yaml.Marshal(b)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[0] += string(fixedByte)
|
||||
parts = parts[:1]
|
||||
case l > 1 && l <= 4:
|
||||
var arr [4]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
case l > 4 && l <= 8:
|
||||
var arr [8]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
case l > 8 && l <= 16:
|
||||
var arr [16]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
case l > 16 && l <= 20:
|
||||
var arr [20]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
case l > 20 && l <= 32:
|
||||
var arr [32]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
case l > 32 && l <= 48:
|
||||
var arr [48]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
case l > 48 && l <= 64:
|
||||
var arr [64]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
case l > 64 && l <= 96:
|
||||
var arr [96]byte
|
||||
copy(arr[:], decoded)
|
||||
fixedByte, err := yaml.Marshal(arr)
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to marshal config file.")
|
||||
}
|
||||
parts[1] = string(fixedByte)
|
||||
}
|
||||
return parts
|
||||
}
|
||||
270
config/params/loader_test.go
Normal file
270
config/params/loader_test.go
Normal file
@@ -0,0 +1,270 @@
|
||||
package params_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
func TestLoadConfigFileMainnet(t *testing.T) {
|
||||
// See https://media.githubusercontent.com/media/ethereum/consensus-spec-tests/master/tests/minimal/config/phase0.yaml
|
||||
assertVals := func(name string, fields []string, c1, c2 *params.BeaconChainConfig) {
|
||||
// Misc params.
|
||||
assert.Equal(t, c1.MaxCommitteesPerSlot, c2.MaxCommitteesPerSlot, "%s: MaxCommitteesPerSlot", name)
|
||||
assert.Equal(t, c1.TargetCommitteeSize, c2.TargetCommitteeSize, "%s: TargetCommitteeSize", name)
|
||||
assert.Equal(t, c1.MaxValidatorsPerCommittee, c2.MaxValidatorsPerCommittee, "%s: MaxValidatorsPerCommittee", name)
|
||||
assert.Equal(t, c1.MinPerEpochChurnLimit, c2.MinPerEpochChurnLimit, "%s: MinPerEpochChurnLimit", name)
|
||||
assert.Equal(t, c1.ChurnLimitQuotient, c2.ChurnLimitQuotient, "%s: ChurnLimitQuotient", name)
|
||||
assert.Equal(t, c1.ShuffleRoundCount, c2.ShuffleRoundCount, "%s: ShuffleRoundCount", name)
|
||||
assert.Equal(t, c1.MinGenesisActiveValidatorCount, c2.MinGenesisActiveValidatorCount, "%s: MinGenesisActiveValidatorCount", name)
|
||||
assert.Equal(t, c1.MinGenesisTime, c2.MinGenesisTime, "%s: MinGenesisTime", name)
|
||||
assert.Equal(t, c1.HysteresisQuotient, c2.HysteresisQuotient, "%s: HysteresisQuotient", name)
|
||||
assert.Equal(t, c1.HysteresisDownwardMultiplier, c2.HysteresisDownwardMultiplier, "%s: HysteresisDownwardMultiplier", name)
|
||||
assert.Equal(t, c1.HysteresisUpwardMultiplier, c2.HysteresisUpwardMultiplier, "%s: HysteresisUpwardMultiplier", name)
|
||||
|
||||
// Fork Choice params.
|
||||
assert.Equal(t, c1.SafeSlotsToUpdateJustified, c2.SafeSlotsToUpdateJustified, "%s: SafeSlotsToUpdateJustified", name)
|
||||
|
||||
// Validator params.
|
||||
assert.Equal(t, c1.Eth1FollowDistance, c2.Eth1FollowDistance, "%s: Eth1FollowDistance", name)
|
||||
assert.Equal(t, c1.TargetAggregatorsPerCommittee, c2.TargetAggregatorsPerCommittee, "%s: TargetAggregatorsPerCommittee", name)
|
||||
assert.Equal(t, c1.RandomSubnetsPerValidator, c2.RandomSubnetsPerValidator, "%s: RandomSubnetsPerValidator", name)
|
||||
assert.Equal(t, c1.EpochsPerRandomSubnetSubscription, c2.EpochsPerRandomSubnetSubscription, "%s: EpochsPerRandomSubnetSubscription", name)
|
||||
assert.Equal(t, c1.SecondsPerETH1Block, c2.SecondsPerETH1Block, "%s: SecondsPerETH1Block", name)
|
||||
|
||||
// Deposit contract.
|
||||
assert.Equal(t, c1.DepositChainID, c2.DepositChainID, "%s: DepositChainID", name)
|
||||
assert.Equal(t, c1.DepositNetworkID, c2.DepositNetworkID, "%s: DepositNetworkID", name)
|
||||
assert.Equal(t, c1.DepositContractAddress, c2.DepositContractAddress, "%s: DepositContractAddress", name)
|
||||
|
||||
// Gwei values.
|
||||
assert.Equal(t, c1.MinDepositAmount, c2.MinDepositAmount, "%s: MinDepositAmount", name)
|
||||
assert.Equal(t, c1.MaxEffectiveBalance, c2.MaxEffectiveBalance, "%s: MaxEffectiveBalance", name)
|
||||
assert.Equal(t, c1.EjectionBalance, c2.EjectionBalance, "%s: EjectionBalance", name)
|
||||
assert.Equal(t, c1.EffectiveBalanceIncrement, c2.EffectiveBalanceIncrement, "%s: EffectiveBalanceIncrement", name)
|
||||
|
||||
// Initial values.
|
||||
assert.DeepEqual(t, c1.GenesisForkVersion, c2.GenesisForkVersion, "%s: GenesisForkVersion", name)
|
||||
assert.DeepEqual(t, c1.BLSWithdrawalPrefixByte, c2.BLSWithdrawalPrefixByte, "%s: BLSWithdrawalPrefixByte", name)
|
||||
|
||||
// Time parameters.
|
||||
assert.Equal(t, c1.GenesisDelay, c2.GenesisDelay, "%s: GenesisDelay", name)
|
||||
assert.Equal(t, c1.SecondsPerSlot, c2.SecondsPerSlot, "%s: SecondsPerSlot", name)
|
||||
assert.Equal(t, c1.MinAttestationInclusionDelay, c2.MinAttestationInclusionDelay, "%s: MinAttestationInclusionDelay", name)
|
||||
assert.Equal(t, c1.SlotsPerEpoch, c2.SlotsPerEpoch, "%s: SlotsPerEpoch", name)
|
||||
assert.Equal(t, c1.MinSeedLookahead, c2.MinSeedLookahead, "%s: MinSeedLookahead", name)
|
||||
assert.Equal(t, c1.MaxSeedLookahead, c2.MaxSeedLookahead, "%s: MaxSeedLookahead", name)
|
||||
assert.Equal(t, c1.EpochsPerEth1VotingPeriod, c2.EpochsPerEth1VotingPeriod, "%s: EpochsPerEth1VotingPeriod", name)
|
||||
assert.Equal(t, c1.SlotsPerHistoricalRoot, c2.SlotsPerHistoricalRoot, "%s: SlotsPerHistoricalRoot", name)
|
||||
assert.Equal(t, c1.MinValidatorWithdrawabilityDelay, c2.MinValidatorWithdrawabilityDelay, "%s: MinValidatorWithdrawabilityDelay", name)
|
||||
assert.Equal(t, c1.ShardCommitteePeriod, c2.ShardCommitteePeriod, "%s: ShardCommitteePeriod", name)
|
||||
assert.Equal(t, c1.MinEpochsToInactivityPenalty, c2.MinEpochsToInactivityPenalty, "%s: MinEpochsToInactivityPenalty", name)
|
||||
|
||||
// State vector lengths.
|
||||
assert.Equal(t, c1.EpochsPerHistoricalVector, c2.EpochsPerHistoricalVector, "%s: EpochsPerHistoricalVector", name)
|
||||
assert.Equal(t, c1.EpochsPerSlashingsVector, c2.EpochsPerSlashingsVector, "%s: EpochsPerSlashingsVector", name)
|
||||
assert.Equal(t, c1.HistoricalRootsLimit, c2.HistoricalRootsLimit, "%s: HistoricalRootsLimit", name)
|
||||
assert.Equal(t, c1.ValidatorRegistryLimit, c2.ValidatorRegistryLimit, "%s: ValidatorRegistryLimit", name)
|
||||
|
||||
// Reward and penalty quotients.
|
||||
assert.Equal(t, c1.BaseRewardFactor, c2.BaseRewardFactor, "%s: BaseRewardFactor", name)
|
||||
assert.Equal(t, c1.WhistleBlowerRewardQuotient, c2.WhistleBlowerRewardQuotient, "%s: WhistleBlowerRewardQuotient", name)
|
||||
assert.Equal(t, c1.ProposerRewardQuotient, c2.ProposerRewardQuotient, "%s: ProposerRewardQuotient", name)
|
||||
assert.Equal(t, c1.InactivityPenaltyQuotient, c2.InactivityPenaltyQuotient, "%s: InactivityPenaltyQuotient", name)
|
||||
assert.Equal(t, c1.InactivityPenaltyQuotientAltair, c2.InactivityPenaltyQuotientAltair, "%s: InactivityPenaltyQuotientAltair", name)
|
||||
assert.Equal(t, c1.MinSlashingPenaltyQuotient, c2.MinSlashingPenaltyQuotient, "%s: MinSlashingPenaltyQuotient", name)
|
||||
assert.Equal(t, c1.MinSlashingPenaltyQuotientAltair, c2.MinSlashingPenaltyQuotientAltair, "%s: MinSlashingPenaltyQuotientAltair", name)
|
||||
assert.Equal(t, c1.ProportionalSlashingMultiplier, c2.ProportionalSlashingMultiplier, "%s: ProportionalSlashingMultiplier", name)
|
||||
assert.Equal(t, c1.ProportionalSlashingMultiplierAltair, c2.ProportionalSlashingMultiplierAltair, "%s: ProportionalSlashingMultiplierAltair", name)
|
||||
|
||||
// Max operations per block.
|
||||
assert.Equal(t, c1.MaxProposerSlashings, c2.MaxProposerSlashings, "%s: MaxProposerSlashings", name)
|
||||
assert.Equal(t, c1.MaxAttesterSlashings, c2.MaxAttesterSlashings, "%s: MaxAttesterSlashings", name)
|
||||
assert.Equal(t, c1.MaxAttestations, c2.MaxAttestations, "%s: MaxAttestations", name)
|
||||
assert.Equal(t, c1.MaxDeposits, c2.MaxDeposits, "%s: MaxDeposits", name)
|
||||
assert.Equal(t, c1.MaxVoluntaryExits, c2.MaxVoluntaryExits, "%s: MaxVoluntaryExits", name)
|
||||
|
||||
// Signature domains.
|
||||
assert.Equal(t, c1.DomainBeaconProposer, c2.DomainBeaconProposer, "%s: DomainBeaconProposer", name)
|
||||
assert.Equal(t, c1.DomainBeaconAttester, c2.DomainBeaconAttester, "%s: DomainBeaconAttester", name)
|
||||
assert.Equal(t, c1.DomainRandao, c2.DomainRandao, "%s: DomainRandao", name)
|
||||
assert.Equal(t, c1.DomainDeposit, c2.DomainDeposit, "%s: DomainDeposit", name)
|
||||
assert.Equal(t, c1.DomainVoluntaryExit, c2.DomainVoluntaryExit, "%s: DomainVoluntaryExit", name)
|
||||
assert.Equal(t, c1.DomainSelectionProof, c2.DomainSelectionProof, "%s: DomainSelectionProof", name)
|
||||
assert.Equal(t, c1.DomainAggregateAndProof, c2.DomainAggregateAndProof, "%s: DomainAggregateAndProof", name)
|
||||
|
||||
assertYamlFieldsMatch(t, name, fields, c1, c2)
|
||||
}
|
||||
|
||||
t.Run("mainnet", func(t *testing.T) {
|
||||
mainnetConfigFile := presetsFilePath(t, "mainnet")
|
||||
params.LoadChainConfigFile(mainnetConfigFile)
|
||||
fields := fieldsFromYaml(t, mainnetConfigFile)
|
||||
assertVals("mainnet", fields, params.MainnetConfig(), params.BeaconConfig())
|
||||
})
|
||||
|
||||
t.Run("minimal", func(t *testing.T) {
|
||||
minimalConfigFile := presetsFilePath(t, "minimal")
|
||||
params.LoadChainConfigFile(minimalConfigFile)
|
||||
fields := fieldsFromYaml(t, minimalConfigFile)
|
||||
assertVals("minimal", fields, params.MinimalSpecConfig(), params.BeaconConfig())
|
||||
})
|
||||
}
|
||||
|
||||
func TestLoadConfigFile_OverwriteCorrectly(t *testing.T) {
|
||||
file, err := ioutil.TempFile("", "")
|
||||
require.NoError(t, err)
|
||||
// Set current config to minimal config
|
||||
params.OverrideBeaconConfig(params.MinimalSpecConfig())
|
||||
|
||||
// load empty config file, so that it defaults to mainnet values
|
||||
params.LoadChainConfigFile(file.Name())
|
||||
if params.BeaconConfig().MinGenesisTime != params.MainnetConfig().MinGenesisTime {
|
||||
t.Errorf("Expected MinGenesisTime to be set to mainnet value: %d found: %d",
|
||||
params.MainnetConfig().MinGenesisTime,
|
||||
params.BeaconConfig().MinGenesisTime)
|
||||
}
|
||||
if params.BeaconConfig().SlotsPerEpoch != params.MainnetConfig().SlotsPerEpoch {
|
||||
t.Errorf("Expected SlotsPerEpoch to be set to mainnet value: %d found: %d",
|
||||
params.MainnetConfig().SlotsPerEpoch,
|
||||
params.BeaconConfig().SlotsPerEpoch)
|
||||
}
|
||||
}
|
||||
|
||||
func Test_replaceHexStringWithYAMLFormat(t *testing.T) {
|
||||
|
||||
testLines := []struct {
|
||||
line string
|
||||
wanted string
|
||||
}{
|
||||
{
|
||||
line: "ONE_BYTE: 0x41",
|
||||
wanted: "ONE_BYTE: 65\n",
|
||||
},
|
||||
{
|
||||
line: "FOUR_BYTES: 0x41414141",
|
||||
wanted: "FOUR_BYTES: \n- 65\n- 65\n- 65\n- 65\n",
|
||||
},
|
||||
{
|
||||
line: "THREE_BYTES: 0x414141",
|
||||
wanted: "THREE_BYTES: \n- 65\n- 65\n- 65\n- 0\n",
|
||||
},
|
||||
{
|
||||
line: "EIGHT_BYTES: 0x4141414141414141",
|
||||
wanted: "EIGHT_BYTES: \n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n",
|
||||
},
|
||||
{
|
||||
line: "SIXTEEN_BYTES: 0x41414141414141414141414141414141",
|
||||
wanted: "SIXTEEN_BYTES: \n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n",
|
||||
},
|
||||
{
|
||||
line: "TWENTY_BYTES: 0x4141414141414141414141414141414141414141",
|
||||
wanted: "TWENTY_BYTES: \n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n",
|
||||
},
|
||||
{
|
||||
line: "THIRTY_TWO_BYTES: 0x4141414141414141414141414141414141414141414141414141414141414141",
|
||||
wanted: "THIRTY_TWO_BYTES: \n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n",
|
||||
},
|
||||
{
|
||||
line: "FORTY_EIGHT_BYTES: 0x41414141414141414141414141414141414141414141414141414141414141414141" +
|
||||
"4141414141414141414141414141",
|
||||
wanted: "FORTY_EIGHT_BYTES: \n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n",
|
||||
},
|
||||
{
|
||||
line: "NINETY_SIX_BYTES: 0x414141414141414141414141414141414141414141414141414141414141414141414141" +
|
||||
"4141414141414141414141414141414141414141414141414141414141414141414141414141414141414141414141" +
|
||||
"41414141414141414141414141",
|
||||
wanted: "NINETY_SIX_BYTES: \n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n" +
|
||||
"- 65\n- 65\n- 65\n- 65\n- 65\n- 65\n",
|
||||
},
|
||||
}
|
||||
for _, line := range testLines {
|
||||
parts := params.ReplaceHexStringWithYAMLFormat(line.line)
|
||||
res := strings.Join(parts, "\n")
|
||||
|
||||
if res != line.wanted {
|
||||
t.Errorf("expected conversion to be: %v got: %v", line.wanted, res)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// configFilePath sets the proper config and returns the relevant
|
||||
// config file path from eth2-spec-tests directory.
|
||||
func configFilePath(t *testing.T, config string) string {
|
||||
filepath, err := bazel.Runfile("external/consensus_spec")
|
||||
require.NoError(t, err)
|
||||
configFilePath := path.Join(filepath, "configs", config+".yaml")
|
||||
return configFilePath
|
||||
}
|
||||
|
||||
// presetsFilePath sets the proper preset and returns the relevant
|
||||
// preset file path from eth2-spec-tests directory.
|
||||
func presetsFilePath(t *testing.T, config string) string {
|
||||
filepath, err := bazel.Runfile("external/consensus_spec")
|
||||
require.NoError(t, err)
|
||||
configFilePath := path.Join(filepath, "presets", config, "phase0.yaml")
|
||||
return configFilePath
|
||||
}
|
||||
|
||||
func fieldsFromYaml(t *testing.T, fp string) []string {
|
||||
yamlFile, err := ioutil.ReadFile(fp)
|
||||
require.NoError(t, err)
|
||||
m := make(map[string]interface{})
|
||||
require.NoError(t, yaml.Unmarshal(yamlFile, &m))
|
||||
|
||||
var keys []string
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
}
|
||||
|
||||
if len(keys) == 0 {
|
||||
t.Errorf("No fields loaded from yaml file %s", fp)
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
func assertYamlFieldsMatch(t *testing.T, name string, fields []string, c1, c2 *params.BeaconChainConfig) {
|
||||
// Ensure all fields from the yaml file exist, were set, and correctly match the expected value.
|
||||
ft1 := reflect.TypeOf(*c1)
|
||||
for _, field := range fields {
|
||||
var found bool
|
||||
for i := 0; i < ft1.NumField(); i++ {
|
||||
v, ok := ft1.Field(i).Tag.Lookup("yaml")
|
||||
if ok && v == field {
|
||||
found = true
|
||||
v1 := reflect.ValueOf(*c1).Field(i).Interface()
|
||||
v2 := reflect.ValueOf(*c2).Field(i).Interface()
|
||||
if reflect.ValueOf(v1).Kind() == reflect.Slice {
|
||||
assert.DeepEqual(t, v1, v2, "%s: %s", name, field)
|
||||
} else {
|
||||
assert.Equal(t, v1, v2, "%s: %s", name, field)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Errorf("No struct tag found `yaml:%s`", field)
|
||||
}
|
||||
}
|
||||
}
|
||||
231
config/params/mainnet_config.go
Normal file
231
config/params/mainnet_config.go
Normal file
@@ -0,0 +1,231 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
)
|
||||
|
||||
// MainnetConfig returns the configuration to be used in the main network.
|
||||
func MainnetConfig() *BeaconChainConfig {
|
||||
return mainnetBeaconConfig
|
||||
}
|
||||
|
||||
// UseMainnetConfig for beacon chain services.
|
||||
func UseMainnetConfig() {
|
||||
beaconConfig = MainnetConfig()
|
||||
}
|
||||
|
||||
const (
|
||||
// Genesis Fork Epoch for the mainnet config.
|
||||
genesisForkEpoch = 0
|
||||
// Altair Fork Epoch for mainnet config.
|
||||
// Placeholder until fork epoch is decided.
|
||||
mainnetAltairForkEpoch = math.MaxUint64
|
||||
)
|
||||
|
||||
var mainnetNetworkConfig = &NetworkConfig{
|
||||
GossipMaxSize: 1 << 20, // 1 MiB
|
||||
MaxChunkSize: 1 << 20, // 1 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.
|
||||
BootstrapNodes: []string{
|
||||
// Teku team's bootnode
|
||||
"enr:-KG4QOtcP9X1FbIMOe17QNMKqDxCpm14jcX5tiOE4_TyMrFqbmhPZHK_ZPG2Gxb1GE2xdtodOfx9-cgvNtxnRyHEmC0ghGV0aDKQ9aX9QgAAAAD__________4JpZIJ2NIJpcIQDE8KdiXNlY3AyNTZrMaEDhpehBDbZjM_L9ek699Y7vhUJ-eAdMyQW_Fil522Y0fODdGNwgiMog3VkcIIjKA",
|
||||
"enr:-KG4QDyytgmE4f7AnvW-ZaUOIi9i79qX4JwjRAiXBZCU65wOfBu-3Nb5I7b_Rmg3KCOcZM_C3y5pg7EBU5XGrcLTduQEhGV0aDKQ9aX9QgAAAAD__________4JpZIJ2NIJpcIQ2_DUbiXNlY3AyNTZrMaEDKnz_-ps3UUOfHWVYaskI5kWYO_vtYMGYCQRAR3gHDouDdGNwgiMog3VkcIIjKA",
|
||||
// Prylab team's bootnodes
|
||||
"enr:-Ku4QImhMc1z8yCiNJ1TyUxdcfNucje3BGwEHzodEZUan8PherEo4sF7pPHPSIB1NNuSg5fZy7qFsjmUKs2ea1Whi0EBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQOVphkDqal4QzPMksc5wnpuC3gvSC8AfbFOnZY_On34wIN1ZHCCIyg",
|
||||
"enr:-Ku4QP2xDnEtUXIjzJ_DhlCRN9SN99RYQPJL92TMlSv7U5C1YnYLjwOQHgZIUXw6c-BvRg2Yc2QsZxxoS_pPRVe0yK8Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQMeFF5GrS7UZpAH2Ly84aLK-TyvH-dRo0JM1i8yygH50YN1ZHCCJxA",
|
||||
"enr:-Ku4QPp9z1W4tAO8Ber_NQierYaOStqhDqQdOPY3bB3jDgkjcbk6YrEnVYIiCBbTxuar3CzS528d2iE7TdJsrL-dEKoBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQMw5fqqkw2hHC4F5HZZDPsNmPdB1Gi8JPQK7pRc9XHh-oN1ZHCCKvg",
|
||||
// Lighthouse team's bootnodes
|
||||
"enr:-IS4QLkKqDMy_ExrpOEWa59NiClemOnor-krjp4qoeZwIw2QduPC-q7Kz4u1IOWf3DDbdxqQIgC4fejavBOuUPy-HE4BgmlkgnY0gmlwhCLzAHqJc2VjcDI1NmsxoQLQSJfEAHZApkm5edTCZ_4qps_1k_ub2CxHFxi-gr2JMIN1ZHCCIyg",
|
||||
"enr:-IS4QDAyibHCzYZmIYZCjXwU9BqpotWmv2BsFlIq1V31BwDDMJPFEbox1ijT5c2Ou3kvieOKejxuaCqIcjxBjJ_3j_cBgmlkgnY0gmlwhAMaHiCJc2VjcDI1NmsxoQJIdpj_foZ02MXz4It8xKD7yUHTBx7lVFn3oeRP21KRV4N1ZHCCIyg",
|
||||
// EF bootnodes
|
||||
"enr:-Ku4QHqVeJ8PPICcWk1vSn_XcSkjOkNiTg6Fmii5j6vUQgvzMc9L1goFnLKgXqBJspJjIsB91LTOleFmyWWrFVATGngBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhAMRHkWJc2VjcDI1NmsxoQKLVXFOhp2uX6jeT0DvvDpPcU8FWMjQdR4wMuORMhpX24N1ZHCCIyg",
|
||||
"enr:-Ku4QG-2_Md3sZIAUebGYT6g0SMskIml77l6yR-M_JXc-UdNHCmHQeOiMLbylPejyJsdAPsTHJyjJB2sYGDLe0dn8uYBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhBLY-NyJc2VjcDI1NmsxoQORcM6e19T1T9gi7jxEZjk_sjVLGFscUNqAY9obgZaxbIN1ZHCCIyg",
|
||||
"enr:-Ku4QPn5eVhcoF1opaFEvg1b6JNFD2rqVkHQ8HApOKK61OIcIXD127bKWgAtbwI7pnxx6cDyk_nI88TrZKQaGMZj0q0Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhDayLMaJc2VjcDI1NmsxoQK2sBOLGcUb4AwuYzFuAVCaNHA-dy24UuEKkeFNgCVCsIN1ZHCCIyg",
|
||||
"enr:-Ku4QEWzdnVtXc2Q0ZVigfCGggOVB2Vc1ZCPEc6j21NIFLODSJbvNaef1g4PxhPwl_3kax86YPheFUSLXPRs98vvYsoBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpC1MD8qAAAAAP__________gmlkgnY0gmlwhDZBrP2Jc2VjcDI1NmsxoQM6jr8Rb1ktLEsVcKAPa08wCsKUmvoQ8khiOl_SLozf9IN1ZHCCIyg",
|
||||
},
|
||||
}
|
||||
|
||||
var mainnetBeaconConfig = &BeaconChainConfig{
|
||||
// Constants (Non-configurable)
|
||||
FarFutureEpoch: 1<<64 - 1,
|
||||
FarFutureSlot: 1<<64 - 1,
|
||||
BaseRewardsPerEpoch: 4,
|
||||
DepositContractTreeDepth: 32,
|
||||
GenesisDelay: 604800, // 1 week.
|
||||
|
||||
// Misc constant.
|
||||
TargetCommitteeSize: 128,
|
||||
MaxValidatorsPerCommittee: 2048,
|
||||
MaxCommitteesPerSlot: 64,
|
||||
MinPerEpochChurnLimit: 4,
|
||||
ChurnLimitQuotient: 1 << 16,
|
||||
ShuffleRoundCount: 90,
|
||||
MinGenesisActiveValidatorCount: 16384,
|
||||
MinGenesisTime: 1606824000, // Dec 1, 2020, 12pm UTC.
|
||||
TargetAggregatorsPerCommittee: 16,
|
||||
HysteresisQuotient: 4,
|
||||
HysteresisDownwardMultiplier: 1,
|
||||
HysteresisUpwardMultiplier: 5,
|
||||
|
||||
// Gwei value constants.
|
||||
MinDepositAmount: 1 * 1e9,
|
||||
MaxEffectiveBalance: 32 * 1e9,
|
||||
EjectionBalance: 16 * 1e9,
|
||||
EffectiveBalanceIncrement: 1 * 1e9,
|
||||
|
||||
// Initial value constants.
|
||||
BLSWithdrawalPrefixByte: byte(0),
|
||||
ZeroHash: [32]byte{},
|
||||
|
||||
// Time parameter constants.
|
||||
MinAttestationInclusionDelay: 1,
|
||||
SecondsPerSlot: 12,
|
||||
SlotsPerEpoch: 32,
|
||||
SqrRootSlotsPerEpoch: 5,
|
||||
MinSeedLookahead: 1,
|
||||
MaxSeedLookahead: 4,
|
||||
EpochsPerEth1VotingPeriod: 64,
|
||||
SlotsPerHistoricalRoot: 8192,
|
||||
MinValidatorWithdrawabilityDelay: 256,
|
||||
ShardCommitteePeriod: 256,
|
||||
MinEpochsToInactivityPenalty: 4,
|
||||
Eth1FollowDistance: 2048,
|
||||
SafeSlotsToUpdateJustified: 8,
|
||||
|
||||
// Ethereum PoW parameters.
|
||||
DepositChainID: 1, // Chain ID of eth1 mainnet.
|
||||
DepositNetworkID: 1, // Network ID of eth1 mainnet.
|
||||
DepositContractAddress: "0x00000000219ab540356cBB839Cbe05303d7705Fa",
|
||||
|
||||
// Validator params.
|
||||
RandomSubnetsPerValidator: 1 << 0,
|
||||
EpochsPerRandomSubnetSubscription: 1 << 8,
|
||||
|
||||
// While eth1 mainnet block times are closer to 13s, we must conform with other clients in
|
||||
// order to vote on the correct eth1 blocks.
|
||||
//
|
||||
// Additional context: https://github.com/ethereum/consensus-specs/issues/2132
|
||||
// Bug prompting this change: https://github.com/prysmaticlabs/prysm/issues/7856
|
||||
// Future optimization: https://github.com/prysmaticlabs/prysm/issues/7739
|
||||
SecondsPerETH1Block: 14,
|
||||
|
||||
// State list length constants.
|
||||
EpochsPerHistoricalVector: 65536,
|
||||
EpochsPerSlashingsVector: 8192,
|
||||
HistoricalRootsLimit: 16777216,
|
||||
ValidatorRegistryLimit: 1099511627776,
|
||||
|
||||
// Reward and penalty quotients constants.
|
||||
BaseRewardFactor: 64,
|
||||
WhistleBlowerRewardQuotient: 512,
|
||||
ProposerRewardQuotient: 8,
|
||||
InactivityPenaltyQuotient: 67108864,
|
||||
MinSlashingPenaltyQuotient: 128,
|
||||
ProportionalSlashingMultiplier: 1,
|
||||
|
||||
// Max operations per block constants.
|
||||
MaxProposerSlashings: 16,
|
||||
MaxAttesterSlashings: 2,
|
||||
MaxAttestations: 128,
|
||||
MaxDeposits: 16,
|
||||
MaxVoluntaryExits: 16,
|
||||
|
||||
// BLS domain values.
|
||||
DomainBeaconProposer: bytesutil.ToBytes4(bytesutil.Bytes4(0)),
|
||||
DomainBeaconAttester: bytesutil.ToBytes4(bytesutil.Bytes4(1)),
|
||||
DomainRandao: bytesutil.ToBytes4(bytesutil.Bytes4(2)),
|
||||
DomainDeposit: bytesutil.ToBytes4(bytesutil.Bytes4(3)),
|
||||
DomainVoluntaryExit: bytesutil.ToBytes4(bytesutil.Bytes4(4)),
|
||||
DomainSelectionProof: bytesutil.ToBytes4(bytesutil.Bytes4(5)),
|
||||
DomainAggregateAndProof: bytesutil.ToBytes4(bytesutil.Bytes4(6)),
|
||||
DomainSyncCommittee: bytesutil.ToBytes4(bytesutil.Bytes4(7)),
|
||||
DomainSyncCommitteeSelectionProof: bytesutil.ToBytes4(bytesutil.Bytes4(8)),
|
||||
DomainContributionAndProof: bytesutil.ToBytes4(bytesutil.Bytes4(9)),
|
||||
|
||||
// Prysm constants.
|
||||
GweiPerEth: 1000000000,
|
||||
BLSSecretKeyLength: 32,
|
||||
BLSPubkeyLength: 48,
|
||||
BLSSignatureLength: 96,
|
||||
DefaultBufferSize: 10000,
|
||||
WithdrawalPrivkeyFileName: "/shardwithdrawalkey",
|
||||
ValidatorPrivkeyFileName: "/validatorprivatekey",
|
||||
RPCSyncCheck: 1,
|
||||
EmptySignature: [96]byte{},
|
||||
DefaultPageSize: 250,
|
||||
MaxPeersToSync: 15,
|
||||
SlotsPerArchivedPoint: 2048,
|
||||
GenesisCountdownInterval: time.Minute,
|
||||
ConfigName: ConfigNames[Mainnet],
|
||||
PresetBase: "mainnet",
|
||||
BeaconStateFieldCount: 21,
|
||||
BeaconStateAltairFieldCount: 24,
|
||||
|
||||
// Slasher related values.
|
||||
WeakSubjectivityPeriod: 54000,
|
||||
PruneSlasherStoragePeriod: 10,
|
||||
SlashingProtectionPruningEpochs: 512,
|
||||
|
||||
// Weak subjectivity values.
|
||||
SafetyDecay: 10,
|
||||
|
||||
// Fork related values.
|
||||
GenesisForkVersion: []byte{0, 0, 0, 0},
|
||||
AltairForkVersion: []byte{1, 0, 0, 0},
|
||||
AltairForkEpoch: mainnetAltairForkEpoch,
|
||||
MergeForkVersion: []byte{2, 0, 0, 0},
|
||||
MergeForkEpoch: math.MaxUint64,
|
||||
ShardingForkVersion: []byte{3, 0, 0, 0},
|
||||
ShardingForkEpoch: math.MaxUint64,
|
||||
MinAnchorPowBlockDifficulty: 4294967296,
|
||||
ForkVersionSchedule: map[[4]byte]types.Epoch{
|
||||
{0, 0, 0, 0}: genesisForkEpoch,
|
||||
{1, 0, 0, 0}: mainnetAltairForkEpoch,
|
||||
// Any further forks must be specified here by their epoch number.
|
||||
},
|
||||
|
||||
// New values introduced in Altair hard fork 1.
|
||||
// Participation flag indices.
|
||||
TimelySourceFlagIndex: 0,
|
||||
TimelyTargetFlagIndex: 1,
|
||||
TimelyHeadFlagIndex: 2,
|
||||
|
||||
// Incentivization weight values.
|
||||
TimelySourceWeight: 14,
|
||||
TimelyTargetWeight: 26,
|
||||
TimelyHeadWeight: 14,
|
||||
SyncRewardWeight: 2,
|
||||
ProposerWeight: 8,
|
||||
WeightDenominator: 64,
|
||||
|
||||
// Validator related values.
|
||||
TargetAggregatorsPerSyncSubcommittee: 16,
|
||||
SyncCommitteeSubnetCount: 4,
|
||||
|
||||
// Misc values.
|
||||
SyncCommitteeSize: 512,
|
||||
InactivityScoreBias: 4,
|
||||
InactivityScoreRecoveryRate: 16,
|
||||
EpochsPerSyncCommitteePeriod: 256,
|
||||
|
||||
// Updated penalty values.
|
||||
InactivityPenaltyQuotientAltair: 3 * 1 << 24, //50331648
|
||||
MinSlashingPenaltyQuotientAltair: 64,
|
||||
ProportionalSlashingMultiplierAltair: 2,
|
||||
}
|
||||
113
config/params/minimal_config.go
Normal file
113
config/params/minimal_config.go
Normal file
@@ -0,0 +1,113 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"math"
|
||||
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
)
|
||||
|
||||
// UseMinimalConfig for beacon chain services.
|
||||
func UseMinimalConfig() {
|
||||
beaconConfig = MinimalSpecConfig()
|
||||
}
|
||||
|
||||
// MinimalSpecConfig retrieves the minimal config used in spec tests.
|
||||
func MinimalSpecConfig() *BeaconChainConfig {
|
||||
minimalConfig := mainnetBeaconConfig.Copy()
|
||||
// Misc
|
||||
minimalConfig.MaxCommitteesPerSlot = 4
|
||||
minimalConfig.TargetCommitteeSize = 4
|
||||
minimalConfig.MaxValidatorsPerCommittee = 2048
|
||||
minimalConfig.MinPerEpochChurnLimit = 4
|
||||
minimalConfig.ChurnLimitQuotient = 32
|
||||
minimalConfig.ShuffleRoundCount = 10
|
||||
minimalConfig.MinGenesisActiveValidatorCount = 64
|
||||
minimalConfig.MinGenesisTime = 1578009600
|
||||
minimalConfig.GenesisDelay = 300 // 5 minutes
|
||||
minimalConfig.TargetAggregatorsPerCommittee = 16
|
||||
|
||||
// Gwei values
|
||||
minimalConfig.MinDepositAmount = 1e9
|
||||
minimalConfig.MaxEffectiveBalance = 32e9
|
||||
minimalConfig.EjectionBalance = 16e9
|
||||
minimalConfig.EffectiveBalanceIncrement = 1e9
|
||||
|
||||
// Initial values
|
||||
minimalConfig.BLSWithdrawalPrefixByte = byte(0)
|
||||
|
||||
// Time parameters
|
||||
minimalConfig.SecondsPerSlot = 6
|
||||
minimalConfig.MinAttestationInclusionDelay = 1
|
||||
minimalConfig.SlotsPerEpoch = 8
|
||||
minimalConfig.SqrRootSlotsPerEpoch = 2
|
||||
minimalConfig.MinSeedLookahead = 1
|
||||
minimalConfig.MaxSeedLookahead = 4
|
||||
minimalConfig.EpochsPerEth1VotingPeriod = 4
|
||||
minimalConfig.SlotsPerHistoricalRoot = 64
|
||||
minimalConfig.MinValidatorWithdrawabilityDelay = 256
|
||||
minimalConfig.ShardCommitteePeriod = 64
|
||||
minimalConfig.MinEpochsToInactivityPenalty = 4
|
||||
minimalConfig.Eth1FollowDistance = 16
|
||||
minimalConfig.SafeSlotsToUpdateJustified = 2
|
||||
minimalConfig.SecondsPerETH1Block = 14
|
||||
|
||||
// State vector lengths
|
||||
minimalConfig.EpochsPerHistoricalVector = 64
|
||||
minimalConfig.EpochsPerSlashingsVector = 64
|
||||
minimalConfig.HistoricalRootsLimit = 16777216
|
||||
minimalConfig.ValidatorRegistryLimit = 1099511627776
|
||||
|
||||
// Reward and penalty quotients
|
||||
minimalConfig.BaseRewardFactor = 64
|
||||
minimalConfig.WhistleBlowerRewardQuotient = 512
|
||||
minimalConfig.ProposerRewardQuotient = 8
|
||||
minimalConfig.InactivityPenaltyQuotient = 33554432
|
||||
minimalConfig.MinSlashingPenaltyQuotient = 64
|
||||
minimalConfig.ProportionalSlashingMultiplier = 2
|
||||
|
||||
// Max operations per block
|
||||
minimalConfig.MaxProposerSlashings = 16
|
||||
minimalConfig.MaxAttesterSlashings = 2
|
||||
minimalConfig.MaxAttestations = 128
|
||||
minimalConfig.MaxDeposits = 16
|
||||
minimalConfig.MaxVoluntaryExits = 16
|
||||
|
||||
// Signature domains
|
||||
minimalConfig.DomainBeaconProposer = bytesutil.ToBytes4(bytesutil.Bytes4(0))
|
||||
minimalConfig.DomainBeaconAttester = bytesutil.ToBytes4(bytesutil.Bytes4(1))
|
||||
minimalConfig.DomainRandao = bytesutil.ToBytes4(bytesutil.Bytes4(2))
|
||||
minimalConfig.DomainDeposit = bytesutil.ToBytes4(bytesutil.Bytes4(3))
|
||||
minimalConfig.DomainVoluntaryExit = bytesutil.ToBytes4(bytesutil.Bytes4(4))
|
||||
minimalConfig.GenesisForkVersion = []byte{0, 0, 0, 1}
|
||||
|
||||
minimalConfig.DepositContractTreeDepth = 32
|
||||
minimalConfig.FarFutureEpoch = 1<<64 - 1
|
||||
minimalConfig.FarFutureSlot = 1<<64 - 1
|
||||
|
||||
// New Altair params
|
||||
minimalConfig.AltairForkVersion = []byte{1, 0, 0, 1} // Highest byte set to 0x01 to avoid collisions with mainnet versioning
|
||||
minimalConfig.AltairForkEpoch = math.MaxUint64
|
||||
minimalConfig.MergeForkVersion = []byte{2, 0, 0, 1}
|
||||
minimalConfig.MergeForkEpoch = math.MaxUint64
|
||||
minimalConfig.ShardingForkVersion = []byte{3, 0, 0, 1}
|
||||
minimalConfig.ShardingForkEpoch = math.MaxUint64
|
||||
// Manually set fork version schedule here.
|
||||
minimalConfig.ForkVersionSchedule = map[[4]byte]types.Epoch{
|
||||
{0, 0, 0, 1}: 0,
|
||||
{1, 0, 0, 1}: math.MaxUint64,
|
||||
}
|
||||
minimalConfig.SyncCommitteeSize = 32
|
||||
minimalConfig.InactivityScoreBias = 4
|
||||
minimalConfig.EpochsPerSyncCommitteePeriod = 8
|
||||
|
||||
// Ethereum PoW parameters.
|
||||
minimalConfig.DepositChainID = 5 // Chain ID of eth1 goerli.
|
||||
minimalConfig.DepositNetworkID = 5 // Network ID of eth1 goerli.
|
||||
minimalConfig.DepositContractAddress = "0x1234567890123456789012345678901234567890"
|
||||
|
||||
minimalConfig.ConfigName = ConfigNames[Minimal]
|
||||
minimalConfig.PresetBase = "minimal"
|
||||
|
||||
return minimalConfig
|
||||
}
|
||||
55
config/params/network_config.go
Normal file
55
config/params/network_config.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/mohae/deepcopy"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
)
|
||||
|
||||
// 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.
|
||||
MaxChunkSize uint64 `yaml:"MAX_CHUNK_SIZE"` // MaxChunkSize is the the maximum allowed size of uncompressed req/resp chunked responses.
|
||||
AttestationSubnetCount uint64 `yaml:"ATTESTATION_SUBNET_COUNT"` // AttestationSubnetCount is the number of attestation subnets used in the gossipsub protocol.
|
||||
AttestationPropagationSlotRange types.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.
|
||||
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.
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// OverrideBeaconNetworkConfig will override the network
|
||||
// config with the added argument.
|
||||
func OverrideBeaconNetworkConfig(cfg *NetworkConfig) {
|
||||
networkConfig = cfg.Copy()
|
||||
}
|
||||
|
||||
// Copy returns Copy of the config object.
|
||||
func (c *NetworkConfig) Copy() *NetworkConfig {
|
||||
config, ok := deepcopy.Copy(*c).(NetworkConfig)
|
||||
if !ok {
|
||||
config = *networkConfig
|
||||
}
|
||||
return &config
|
||||
}
|
||||
16
config/params/testnet_config_test.go
Normal file
16
config/params/testnet_config_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package params_test
|
||||
|
||||
import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||||
)
|
||||
|
||||
func testnetConfigFilePath(t *testing.T, network string) string {
|
||||
filepath, err := bazel.Runfile("external/eth2_networks")
|
||||
require.NoError(t, err)
|
||||
configFilePath := path.Join(filepath, "shared", network, "config.yaml")
|
||||
return configFilePath
|
||||
}
|
||||
44
config/params/testnet_e2e_config.go
Normal file
44
config/params/testnet_e2e_config.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package params
|
||||
|
||||
const AltairE2EForkEpoch = 6
|
||||
|
||||
// UseE2EConfig for beacon chain services.
|
||||
func UseE2EConfig() {
|
||||
beaconConfig = E2ETestConfig()
|
||||
|
||||
cfg := BeaconNetworkConfig().Copy()
|
||||
OverrideBeaconNetworkConfig(cfg)
|
||||
}
|
||||
|
||||
// E2ETestConfig retrieves the configurations made specifically for E2E testing.
|
||||
// Warning: This config is only for testing, it is not meant for use outside of E2E.
|
||||
func E2ETestConfig() *BeaconChainConfig {
|
||||
e2eConfig := MinimalSpecConfig()
|
||||
|
||||
// Misc.
|
||||
e2eConfig.MinGenesisActiveValidatorCount = 256
|
||||
e2eConfig.GenesisDelay = 10 // 10 seconds so E2E has enough time to process deposits and get started.
|
||||
e2eConfig.ChurnLimitQuotient = 65536
|
||||
|
||||
// Time parameters.
|
||||
e2eConfig.SecondsPerSlot = 10
|
||||
e2eConfig.SlotsPerEpoch = 6
|
||||
e2eConfig.SqrRootSlotsPerEpoch = 2
|
||||
e2eConfig.SecondsPerETH1Block = 2
|
||||
e2eConfig.Eth1FollowDistance = 4
|
||||
e2eConfig.EpochsPerEth1VotingPeriod = 2
|
||||
e2eConfig.ShardCommitteePeriod = 4
|
||||
e2eConfig.MaxSeedLookahead = 1
|
||||
|
||||
// PoW parameters.
|
||||
e2eConfig.DepositChainID = 1337 // Chain ID of eth1 dev net.
|
||||
e2eConfig.DepositNetworkID = 1337 // Network ID of eth1 dev net.
|
||||
|
||||
// Altair Fork Parameters.
|
||||
e2eConfig.AltairForkEpoch = AltairE2EForkEpoch
|
||||
|
||||
// Prysm constants.
|
||||
e2eConfig.ConfigName = ConfigNames[EndToEnd]
|
||||
|
||||
return e2eConfig
|
||||
}
|
||||
49
config/params/testnet_prater_config.go
Normal file
49
config/params/testnet_prater_config.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package params
|
||||
|
||||
import (
|
||||
eth1Params "github.com/ethereum/go-ethereum/params"
|
||||
)
|
||||
|
||||
// UsePraterNetworkConfig uses the Prater specific
|
||||
// network config.
|
||||
func UsePraterNetworkConfig() {
|
||||
cfg := BeaconNetworkConfig().Copy()
|
||||
cfg.ContractDeploymentBlock = 4367322
|
||||
cfg.BootstrapNodes = []string{
|
||||
// Prysm's bootnode
|
||||
"enr:-Ku4QFmUkNp0g9bsLX2PfVeIyT-9WO-PZlrqZBNtEyofOOfLMScDjaTzGxIb1Ns9Wo5Pm_8nlq-SZwcQfTH2cgO-s88Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpDkvpOTAAAQIP__________gmlkgnY0gmlwhBLf22SJc2VjcDI1NmsxoQLV_jMOIxKbjHFKgrkFvwDvpexo6Nd58TK5k7ss4Vt0IoN1ZHCCG1g",
|
||||
// Lighthouse's bootnode by Afri
|
||||
"enr:-LK4QH1xnjotgXwg25IDPjrqRGFnH1ScgNHA3dv1Z8xHCp4uP3N3Jjl_aYv_WIxQRdwZvSukzbwspXZ7JjpldyeVDzMCh2F0dG5ldHOIAAAAAAAAAACEZXRoMpB53wQoAAAQIP__________gmlkgnY0gmlwhIe1te-Jc2VjcDI1NmsxoQOkcGXqbCJYbcClZ3z5f6NWhX_1YPFRYRRWQpJjwSHpVIN0Y3CCIyiDdWRwgiMo",
|
||||
// Lighthouse's bootnode by Sigp
|
||||
"enr:-LK4QLINdtobGquK7jukLDAKmsrH2ZuHM4k0TklY5jDTD4ZgfxR9weZmo5Jwu81hlKu3qPAvk24xHGBDjYs4o8f1gZ0Bh2F0dG5ldHOIAAAAAAAAAACEZXRoMpB53wQoAAAQIP__________gmlkgnY0gmlwhDRN_P6Jc2VjcDI1NmsxoQJuNujTgsJUHUgVZML3pzrtgNtYg7rQ4K1tkWERgl0DdoN0Y3CCIyiDdWRwgiMo",
|
||||
// Teku's bootnode By Afri
|
||||
"enr:-KG4QCIzJZTY_fs_2vqWEatJL9RrtnPwDCv-jRBuO5FQ2qBrfJubWOWazri6s9HsyZdu-fRUfEzkebhf1nvO42_FVzwDhGV0aDKQed8EKAAAECD__________4JpZIJ2NIJpcISHtbYziXNlY3AyNTZrMaED4m9AqVs6F32rSCGsjtYcsyfQE2K8nDiGmocUY_iq-TSDdGNwgiMog3VkcIIjKA",
|
||||
}
|
||||
OverrideBeaconNetworkConfig(cfg)
|
||||
}
|
||||
|
||||
// UsePraterConfig sets the main beacon chain
|
||||
// config for Prater.
|
||||
func UsePraterConfig() {
|
||||
beaconConfig = PraterConfig()
|
||||
}
|
||||
|
||||
// PraterConfig defines the config for the
|
||||
// Prater testnet.
|
||||
func PraterConfig() *BeaconChainConfig {
|
||||
cfg := MainnetConfig().Copy()
|
||||
cfg.MinGenesisTime = 1614588812
|
||||
cfg.GenesisDelay = 1919188
|
||||
cfg.ConfigName = ConfigNames[Prater]
|
||||
cfg.GenesisForkVersion = []byte{0x00, 0x00, 0x10, 0x20}
|
||||
cfg.SecondsPerETH1Block = 14
|
||||
cfg.DepositChainID = eth1Params.GoerliChainConfig.ChainID.Uint64()
|
||||
cfg.DepositNetworkID = eth1Params.GoerliChainConfig.ChainID.Uint64()
|
||||
cfg.AltairForkEpoch = 36660
|
||||
cfg.AltairForkVersion = []byte{0x1, 0x0, 0x10, 0x20}
|
||||
cfg.ShardingForkVersion = []byte{0x3, 0x0, 0x10, 0x20}
|
||||
cfg.MergeForkVersion = []byte{0x2, 0x0, 0x10, 0x20}
|
||||
cfg.TransitionTotalDifficulty = 4294967296
|
||||
cfg.DepositContractAddress = "0xff50ed3d0ec03aC01D4C79aAd74928BFF48a7b2b"
|
||||
return cfg
|
||||
}
|
||||
14
config/params/testnet_prater_config_test.go
Normal file
14
config/params/testnet_prater_config_test.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package params_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
)
|
||||
|
||||
func TestPraterConfigMatchesUpstreamYaml(t *testing.T) {
|
||||
configFP := testnetConfigFilePath(t, "prater")
|
||||
params.LoadChainConfigFile(configFP)
|
||||
fields := fieldsFromYaml(t, configFP)
|
||||
assertYamlFieldsMatch(t, "prater", fields, params.BeaconConfig(), params.PraterConfig())
|
||||
}
|
||||
42
config/params/testnet_pyrmont_config.go
Normal file
42
config/params/testnet_pyrmont_config.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package params
|
||||
|
||||
import "math"
|
||||
|
||||
// UsePyrmontNetworkConfig uses the Pyrmont specific
|
||||
// network config.
|
||||
func UsePyrmontNetworkConfig() {
|
||||
cfg := BeaconNetworkConfig().Copy()
|
||||
cfg.ContractDeploymentBlock = 3743587
|
||||
cfg.BootstrapNodes = []string{
|
||||
"enr:-Ku4QOA5OGWObY8ep_x35NlGBEj7IuQULTjkgxC_0G1AszqGEA0Wn2RNlyLFx9zGTNB1gdFBA6ZDYxCgIza1uJUUOj4Dh2F0dG5ldHOIAAAAAAAAAACEZXRoMpDVTPWXAAAgCf__________gmlkgnY0gmlwhDQPSjiJc2VjcDI1NmsxoQM6yTQB6XGWYJbI7NZFBjp4Yb9AYKQPBhVrfUclQUobb4N1ZHCCIyg",
|
||||
"enr:-Ku4QOksdA2tabOGrfOOr6NynThMoio6Ggka2oDPqUuFeWCqcRM2alNb8778O_5bK95p3EFt0cngTUXm2H7o1jkSJ_8Dh2F0dG5ldHOIAAAAAAAAAACEZXRoMpDVTPWXAAAgCf__________gmlkgnY0gmlwhDaa13aJc2VjcDI1NmsxoQKdNQJvnohpf0VO0ZYCAJxGjT0uwJoAHbAiBMujGjK0SoN1ZHCCIyg",
|
||||
}
|
||||
OverrideBeaconNetworkConfig(cfg)
|
||||
}
|
||||
|
||||
// UsePyrmontConfig sets the main beacon chain
|
||||
// config for Pyrmont.
|
||||
func UsePyrmontConfig() {
|
||||
beaconConfig = PyrmontConfig()
|
||||
}
|
||||
|
||||
// PyrmontConfig defines the config for the
|
||||
// Pyrmont testnet.
|
||||
func PyrmontConfig() *BeaconChainConfig {
|
||||
cfg := MainnetConfig().Copy()
|
||||
cfg.MinGenesisTime = 1605700800
|
||||
cfg.GenesisDelay = 432000
|
||||
cfg.ConfigName = ConfigNames[Pyrmont]
|
||||
cfg.GenesisForkVersion = []byte{0x00, 0x00, 0x20, 0x09}
|
||||
cfg.AltairForkVersion = []byte{0x01, 0x00, 0x20, 0x09}
|
||||
cfg.AltairForkEpoch = 61650
|
||||
cfg.MergeForkVersion = []byte{0x02, 0x00, 0x20, 0x09}
|
||||
cfg.MergeForkEpoch = math.MaxUint64
|
||||
cfg.ShardingForkVersion = []byte{0x03, 0x00, 0x20, 0x09}
|
||||
cfg.ShardingForkEpoch = math.MaxUint64
|
||||
cfg.SecondsPerETH1Block = 14
|
||||
cfg.DepositChainID = 5
|
||||
cfg.DepositNetworkID = 5
|
||||
cfg.DepositContractAddress = "0x8c5fecdC472E27Bc447696F431E425D02dd46a8c"
|
||||
return cfg
|
||||
}
|
||||
16
config/params/testutils.go
Normal file
16
config/params/testutils.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package params
|
||||
|
||||
import "testing"
|
||||
|
||||
// SetupTestConfigCleanup preserves configurations allowing to modify them within tests without any
|
||||
// restrictions, everything is restored after the test.
|
||||
func SetupTestConfigCleanup(t testing.TB) {
|
||||
prevDefaultBeaconConfig := mainnetBeaconConfig.Copy()
|
||||
prevBeaconConfig := beaconConfig.Copy()
|
||||
prevNetworkCfg := networkConfig.Copy()
|
||||
t.Cleanup(func() {
|
||||
mainnetBeaconConfig = prevDefaultBeaconConfig
|
||||
beaconConfig = prevBeaconConfig
|
||||
networkConfig = prevNetworkCfg
|
||||
})
|
||||
}
|
||||
21
config/params/values.go
Normal file
21
config/params/values.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package params
|
||||
|
||||
const (
|
||||
Mainnet ConfigName = iota
|
||||
Minimal
|
||||
EndToEnd
|
||||
Pyrmont
|
||||
Prater
|
||||
)
|
||||
|
||||
// ConfigNames provides network configuration names.
|
||||
var ConfigNames = map[ConfigName]string{
|
||||
Mainnet: "mainnet",
|
||||
Minimal: "minimal",
|
||||
EndToEnd: "end-to-end",
|
||||
Pyrmont: "pyrmont",
|
||||
Prater: "prater",
|
||||
}
|
||||
|
||||
// ConfigName enum describes the type of known network in use.
|
||||
type ConfigName = int
|
||||
Reference in New Issue
Block a user