Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update presets / configs / REST config for v1.1.10 #3614

Merged
merged 1 commit into from May 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon_chain/fork_choice/proto_array.nim
Expand Up @@ -105,8 +105,8 @@ func init*(T: type ProtoArray,

# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#configuration
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#get_latest_attesting_balance
const PROPOSER_SCORE_BOOST* = 70
func calculateProposerBoost(validatorBalances: openArray[Gwei]): int64 =
const PROPOSER_SCORE_BOOST = 70
var
total_balance: uint64
num_validators: int64
Expand Down
38 changes: 28 additions & 10 deletions beacon_chain/rpc/rest_config_api.nim
Expand Up @@ -9,6 +9,7 @@ import ".."/beacon_node,
".."/eth1/eth1_monitor,
".."/spec/forks,
"."/rest_utils
from ../fork_choice/proto_array import PROPOSER_SCORE_BOOST

export rest_utils

Expand All @@ -22,10 +23,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
cachedConfigSpec =
RestApiResponse.prepareJsonResponse(
(
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/configs/mainnet/phase0.yaml
CONFIG_NAME: cfg.name(),

# https://github.com/ethereum/consensus-specs/blob/v1.1.3/presets/mainnet/phase0.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/mainnet/phase0.yaml
MAX_COMMITTEES_PER_SLOT:
Base10.toString(MAX_COMMITTEES_PER_SLOT),
TARGET_COMMITTEE_SIZE:
Expand Down Expand Up @@ -93,7 +91,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
MAX_VOLUNTARY_EXITS:
Base10.toString(MAX_VOLUNTARY_EXITS),

# https://github.com/ethereum/consensus-specs/blob/v1.1.4/presets/mainnet/altair.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/mainnet/altair.yaml
INACTIVITY_PENALTY_QUOTIENT_ALTAIR:
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_ALTAIR),
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR:
Expand All @@ -106,14 +104,36 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
Base10.toString(EPOCHS_PER_SYNC_COMMITTEE_PERIOD),
MIN_SYNC_COMMITTEE_PARTICIPANTS:
Base10.toString(uint64(MIN_SYNC_COMMITTEE_PARTICIPANTS)),
UPDATE_TIMEOUT:
Base10.toString(UPDATE_TIMEOUT),

# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/mainnet/bellatrix.yaml
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX:
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_BELLATRIX),
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX:
Base10.toString(MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX),
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX:
Base10.toString(PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX),
MAX_BYTES_PER_TRANSACTION:
Base10.toString(uint64(MAX_BYTES_PER_TRANSACTION)),
MAX_TRANSACTIONS_PER_PAYLOAD:
Base10.toString(uint64(MAX_TRANSACTIONS_PER_PAYLOAD)),
BYTES_PER_LOGS_BLOOM:
Base10.toString(uint64(BYTES_PER_LOGS_BLOOM)),
MAX_EXTRA_DATA_BYTES:
Base10.toString(uint64(MAX_EXTRA_DATA_BYTES)),

# https://github.com/ethereum/consensus-specs/blob/v1.1.3/configs/mainnet.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/configs/mainnet.yaml
PRESET_BASE:
cfg.PRESET_BASE,
CONFIG_NAME:
cfg.name(),
TERMINAL_TOTAL_DIFFICULTY:
toString(cfg.TERMINAL_TOTAL_DIFFICULTY),
TERMINAL_BLOCK_HASH:
$cfg.TERMINAL_BLOCK_HASH,
TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH:
Base10.toString(uint64(TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH)),
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT:
Base10.toString(cfg.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT),
MIN_GENESIS_TIME:
Expand Down Expand Up @@ -154,6 +174,8 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
Base10.toString(cfg.MIN_PER_EPOCH_CHURN_LIMIT),
CHURN_LIMIT_QUOTIENT:
Base10.toString(cfg.CHURN_LIMIT_QUOTIENT),
PROPOSER_SCORE_BOOST:
Base10.toString(uint64(PROPOSER_SCORE_BOOST)),
DEPOSIT_CHAIN_ID:
Base10.toString(cfg.DEPOSIT_CHAIN_ID),
DEPOSIT_NETWORK_ID:
Expand Down Expand Up @@ -230,10 +252,6 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
Base10.toString(uint64(TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE)),
SYNC_COMMITTEE_SUBNET_COUNT:
Base10.toString(uint64(SYNC_COMMITTEE_SUBNET_COUNT)),

# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#transition-settings
TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH:
Base10.toString(uint64(TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH)),
)
)
cachedDepositContract =
Expand Down
4 changes: 0 additions & 4 deletions beacon_chain/spec/datatypes/altair.nim
Expand Up @@ -74,10 +74,6 @@ const
INACTIVITY_SCORE_BIAS* = 4
INACTIVITY_SCORE_RECOVERY_RATE* = 16

# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/altair/sync-protocol.md#misc
# MIN_SYNC_COMMITTEE_PARTICIPANTS defined in presets
UPDATE_TIMEOUT* = SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD

SYNC_SUBCOMMITTEE_SIZE* = SYNC_COMMITTEE_SIZE div SYNC_COMMITTEE_SUBNET_COUNT

# "Note: The sum of the weights equal WEIGHT_DENOMINATOR."
Expand Down
24 changes: 17 additions & 7 deletions beacon_chain/spec/eth2_apis/rest_types.nim
Expand Up @@ -243,10 +243,7 @@ type
of BeaconBlockFork.Bellatrix: bellatrixBody*: bellatrix.BeaconBlockBody

RestSpec* = object
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/configs/mainnet/phase0.yaml
CONFIG_NAME*: string

# https://github.com/ethereum/consensus-specs/blob/v1.1.3/presets/mainnet/phase0.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/mainnet/phase0.yaml
MAX_COMMITTEES_PER_SLOT*: uint64
TARGET_COMMITTEE_SIZE*: uint64
MAX_VALIDATORS_PER_COMMITTEE*: uint64
Expand Down Expand Up @@ -281,18 +278,30 @@ type
MAX_DEPOSITS*: uint64
MAX_VOLUNTARY_EXITS*: uint64

# https://github.com/ethereum/consensus-specs/blob/v1.1.3/presets/mainnet/altair.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/mainnet/altair.yaml
INACTIVITY_PENALTY_QUOTIENT_ALTAIR*: uint64
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR*: uint64
PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR*: uint64
SYNC_COMMITTEE_SIZE*: uint64
EPOCHS_PER_SYNC_COMMITTEE_PERIOD*: uint64
MIN_SYNC_COMMITTEE_PARTICIPANTS*: uint64

# https://github.com/ethereum/consensus-specs/blob/v1.1.3/configs/mainnet.yaml
UPDATE_TIMEOUT*: uint64

# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/mainnet/bellatrix.yaml
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64
MAX_BYTES_PER_TRANSACTION*: uint64
MAX_TRANSACTIONS_PER_PAYLOAD*: uint64
BYTES_PER_LOGS_BLOOM*: uint64
MAX_EXTRA_DATA_BYTES*: uint64

# https://github.com/ethereum/consensus-specs/blob/v1.1.10/configs/mainnet.yaml
PRESET_BASE*: string
CONFIG_NAME*: string
TERMINAL_TOTAL_DIFFICULTY*: UInt256
TERMINAL_BLOCK_HASH*: BlockHash
TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH*: uint64
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT*: uint64
MIN_GENESIS_TIME*: uint64
GENESIS_FORK_VERSION*: Version
Expand All @@ -313,6 +322,7 @@ type
EJECTION_BALANCE*: uint64
MIN_PER_EPOCH_CHURN_LIMIT*: uint64
CHURN_LIMIT_QUOTIENT*: uint64
PROPOSER_SCORE_BOOST*: uint64
DEPOSIT_CHAIN_ID*: uint64
DEPOSIT_NETWORK_ID*: uint64
DEPOSIT_CONTRACT_ADDRESS*: Eth1Address
Expand Down
72 changes: 50 additions & 22 deletions beacon_chain/spec/presets.nim
Expand Up @@ -29,48 +29,47 @@ type
Eth1Address* = ethtypes.Address

RuntimeConfig* = object
## https://github.com/ethereum/consensus-specs/tree/v1.1.3/configs

## https://github.com/ethereum/consensus-specs/tree/v1.1.10/configs
PRESET_BASE*: string

CONFIG_NAME*: string

# Transition
TERMINAL_TOTAL_DIFFICULTY*: UInt256
TERMINAL_BLOCK_HASH*: BlockHash
# TODO TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH*: Epoch

# Genesis
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT*: uint64
MIN_GENESIS_TIME*: uint64
GENESIS_FORK_VERSION*: Version
GENESIS_DELAY*: uint64

# Altair
# Forking
ALTAIR_FORK_VERSION*: Version
ALTAIR_FORK_EPOCH*: Epoch

# Merge
BELLATRIX_FORK_VERSION*: Version
BELLATRIX_FORK_EPOCH*: Epoch

# Sharding
SHARDING_FORK_VERSION*: Version
SHARDING_FORK_EPOCH*: Epoch

MIN_ANCHOR_POW_BLOCK_DIFFICULTY*: uint64

# Time parameters
# TODO SECONDS_PER_SLOT*: uint64
SECONDS_PER_ETH1_BLOCK*: uint64
MIN_VALIDATOR_WITHDRAWABILITY_DELAY*: uint64
SHARD_COMMITTEE_PERIOD*: uint64
ETH1_FOLLOW_DISTANCE*: uint64

# Validator cycle
INACTIVITY_SCORE_BIAS*: uint64
INACTIVITY_SCORE_RECOVERY_RATE*: uint64
EJECTION_BALANCE*: uint64
MIN_PER_EPOCH_CHURN_LIMIT*: uint64
CHURN_LIMIT_QUOTIENT*: uint64

# Fork choice
# TODO PROPOSER_SCORE_BOOST*: uint64

# Deposit contract
DEPOSIT_CHAIN_ID*: uint64
DEPOSIT_NETWORK_ID*: uint64
DEPOSIT_CONTRACT_ADDRESS*: Eth1Address
Expand Down Expand Up @@ -148,6 +147,7 @@ const
"DOMAIN_CONTRIBUTION_AND_PROOF",

"TRANSITION_TOTAL_DIFFICULTY", # Name that appears in some altair alphas, obsolete, remove when no more testnets
"MIN_ANCHOR_POW_BLOCK_DIFFICULTY", # Name that appears in some altair alphas, obsolete, remove when no more testnets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's marked here so it can be found and removed if desired, but in general, I don't know how relevant it is to support such Altair devnets. There's not much cost this way, so seems reasonable to include it for now.

]

when const_preset == "mainnet":
Expand All @@ -157,19 +157,32 @@ when const_preset == "mainnet":
# TODO Move this to RuntimeConfig
const SECONDS_PER_SLOT* {.intdefine.}: uint64 = 12

# https://github.com/ethereum/consensus-specs/blob/v1.1.3/configs/mainnet.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/configs/mainnet.yaml
# TODO Read these from yaml file
const defaultRuntimeConfig* = RuntimeConfig(
# Mainnet config

# Extends the mainnet preset
PRESET_BASE: "mainnet",

# Free-form short name of the network that this configuration applies to - known
# canonical network names include:
# * 'mainnet' - there can be only one
# * 'prater' - testnet
# Must match the regex: [a-z0-9\-]
CONFIG_NAME: "mainnet",

# Transition
# ---------------------------------------------------------------
# TBD, 2**256-2**10 is a placeholder
TERMINAL_TOTAL_DIFFICULTY:
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912",
# By default, don't use this param
# By default, don't use these params
TERMINAL_BLOCK_HASH: BlockHash.fromHex(
"0x0000000000000000000000000000000000000000000000000000000000000000"),
# TODO TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: Epoch(uint64.high),



# Genesis
# ---------------------------------------------------------------
Expand All @@ -192,16 +205,13 @@ when const_preset == "mainnet":
# Altair
ALTAIR_FORK_VERSION: Version [byte 0x01, 0x00, 0x00, 0x00],
ALTAIR_FORK_EPOCH: Epoch(74240), # Oct 27, 2021, 10:56:23am UTC
# Merge
# Bellatrix
BELLATRIX_FORK_VERSION: Version [byte 0x02, 0x00, 0x00, 0x00],
BELLATRIX_FORK_EPOCH: Epoch(uint64.high),
# Sharding
SHARDING_FORK_VERSION: Version [byte 0x03, 0x00, 0x00, 0x00],
SHARDING_FORK_EPOCH: Epoch(uint64.high),

# TBD, 2**32 is a placeholder. Merge transition approach is in active R&D.
MIN_ANCHOR_POW_BLOCK_DIFFICULTY: 4294967296'u64,


# Time parameters
# ---------------------------------------------------------------
Expand Down Expand Up @@ -231,6 +241,11 @@ when const_preset == "mainnet":
CHURN_LIMIT_QUOTIENT: 65536,


# Fork choice
# ---------------------------------------------------------------
# 70%
# TODO PROPOSER_SCORE_BOOST: 70,

# Deposit contract
# ---------------------------------------------------------------
# Ethereum PoW Mainnet
Expand All @@ -245,21 +260,31 @@ elif const_preset == "minimal":

const SECONDS_PER_SLOT* {.intdefine.}: uint64 = 6

# https://github.com/ethereum/consensus-specs/blob/v1.1.3/configs/minimal.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/configs/minimal.yaml
const defaultRuntimeConfig* = RuntimeConfig(
# Minimal config

# Extends the minimal preset
PRESET_BASE: "minimal",

# Free-form short name of the network that this configuration applies to - known
# canonical network names include:
# * 'mainnet' - there can be only one
# * 'prater' - testnet
# Must match the regex: [a-z0-9\-]
CONFIG_NAME: "minimal",

# Transition
# ---------------------------------------------------------------
# TBD, 2**256-2**10 is a placeholder
TERMINAL_TOTAL_DIFFICULTY:
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912",
# By default, don't use this param
# By default, don't use these params
TERMINAL_BLOCK_HASH: BlockHash.fromHex(
"0x0000000000000000000000000000000000000000000000000000000000000000"),
# TODO TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH: Epoch(uint64.high),



# Genesis
# ---------------------------------------------------------------
Expand All @@ -281,16 +306,13 @@ elif const_preset == "minimal":
# Altair
ALTAIR_FORK_VERSION: Version [byte 0x01, 0x00, 0x00, 0x01],
ALTAIR_FORK_EPOCH: Epoch(uint64.high),
# Merge
# Bellatrix
BELLATRIX_FORK_VERSION: Version [byte 0x02, 0x00, 0x00, 0x01],
BELLATRIX_FORK_EPOCH: Epoch(uint64.high),
# Sharding
SHARDING_FORK_VERSION: Version [byte 0x03, 0x00, 0x00, 0x01],
SHARDING_FORK_EPOCH: Epoch(uint64.high),

# TBD, 2**32 is a placeholder. Merge transition approach is in active R&D.
MIN_ANCHOR_POW_BLOCK_DIFFICULTY: 4294967296'u64,


# Time parameters
# ---------------------------------------------------------------
Expand Down Expand Up @@ -320,6 +342,12 @@ elif const_preset == "minimal":
CHURN_LIMIT_QUOTIENT: 32,


# Fork choice
# ---------------------------------------------------------------
# 70%
# TODO PROPOSER_SCORE_BOOST: 70,


# Deposit contract
# ---------------------------------------------------------------
# Ethereum Goerli testnet
Expand Down
4 changes: 3 additions & 1 deletion beacon_chain/spec/presets/mainnet/altair_preset.nim
@@ -1,5 +1,5 @@
# Mainnet preset - Altair
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/presets/mainnet/altair.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/mainnet/altair.yaml
const
# Updated penalty values
# ---------------------------------------------------------------
Expand All @@ -23,3 +23,5 @@ const
# ---------------------------------------------------------------
# 1
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
# SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD (= 32 * 256)
UPDATE_TIMEOUT*: uint64 = 8192
8 changes: 5 additions & 3 deletions beacon_chain/spec/presets/minimal/altair_preset.nim
@@ -1,5 +1,5 @@
# Minimal preset - Altair
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/presets/minimal/altair.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/presets/minimal/altair.yaml
const
# Updated penalty values
# ---------------------------------------------------------------
Expand All @@ -13,13 +13,15 @@ const

# Sync committee
# ---------------------------------------------------------------
# customized
# [customized]
SYNC_COMMITTEE_SIZE* = 32
# customized
# [customized]
EPOCHS_PER_SYNC_COMMITTEE_PERIOD* {.intdefine.}: uint64 = 8


# Sync protocol
# ---------------------------------------------------------------
# 1
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
# SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD (= 8 * 8)
UPDATE_TIMEOUT*: uint64 = 64