Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions beacon_chain/networking/network_metadata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.

{.push raises: [].}
{.push raises: [], gcsafe.}

import
std/os,
Expand Down Expand Up @@ -327,11 +327,16 @@ elif const_preset == "mainnet":
for network in [
mainnetMetadata, sepoliaMetadata, holeskyMetadata, hoodiMetadata]:
checkForkConsistency(network.cfg)
doAssert network.cfg.ELECTRA_FORK_EPOCH < FAR_FUTURE_EPOCH
doAssert network.cfg.FULU_FORK_EPOCH == FAR_FUTURE_EPOCH
doAssert network.cfg.GLOAS_FORK_EPOCH == FAR_FUTURE_EPOCH
doAssert ConsensusFork.high == ConsensusFork.Gloas

doAssert mainnetMetadata.cfg.FULU_FORK_EPOCH == FAR_FUTURE_EPOCH
doAssert mainnetMetadata.cfg.BLOB_SCHEDULE.len == 0

for network in [sepoliaMetadata, holeskyMetadata, hoodiMetadata]:
doAssert network.cfg.FULU_FORK_EPOCH < FAR_FUTURE_EPOCH
doAssert network.cfg.BLOB_SCHEDULE.len == 2

proc getMetadataForNetwork*(networkName: string): Eth2NetworkMetadata =
template loadRuntimeMetadata(): auto =
if fileExists(networkName / "config.yaml"):
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/spec/peerdas_helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import

from std/algorithm import sort
from std/sequtils import toSeq
from stew/staticfor import staticfor
from stew/staticfor import staticFor

type
CellBytes = array[fulu.CELLS_PER_EXT_BLOB, Cell]
Expand Down
28 changes: 25 additions & 3 deletions beacon_chain/spec/presets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
{.push raises: [], gcsafe.}

import
std/[strutils, parseutils, tables, typetraits],
std/[parseutils, tables, typetraits],
chronos/timer,
stew/[byteutils], stint, eth/common/addresses as eth,
./datatypes/constants

from std/algorithm import sort
from std/strutils import split, splitLines, startsWith, strip, `%`

export constants

export stint, eth

const
Expand All @@ -40,6 +40,17 @@ const
MAX_SUPPORTED_BLOBS_PER_BLOCK*: uint64 = 9 # revisit getShortMap(Blobs) if >9
MAX_SUPPORTED_REQUEST_BLOB_SIDECARS*: uint64 = 1152

# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/phase0/validator.md#time-parameters
ATTESTATION_DUE_BPS: uint64 = 3333
AGGREGATE_DUE_BPS: uint64 = 6667

# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/altair/validator.md#time-parameters
SYNC_MESSAGE_DUE_BPS: uint64 = 3333
CONTRIBUTION_DUE_BPS: uint64 = 6667

# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/phase0/fork-choice.md#time-parameters
PROPOSER_REORG_CUTOFF_BPS: uint64 = 1667

type
TimeConfig* = object
SECONDS_PER_SLOT*: uint64
Expand Down Expand Up @@ -164,11 +175,13 @@ type
const
const_preset* {.strdefine.} = "mainnet"

# No-longer used values from legacy config files
# No-longer used values from legacy config files, or quirks of BPO parsing
ignoredValues = [
"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
"RANDOM_SUBNETS_PER_VALIDATOR", # Removed in consensus-specs v1.4.0
" MAX_BLOBS_PER_BLOCK", # parsed separately
" - EPOCH", # parsed separately
]

when const_preset == "mainnet":
Expand Down Expand Up @@ -719,6 +732,7 @@ else:
const
MIN_SECONDS_PER_SLOT* = 1'u64
MAX_SECONDS_PER_SLOT* = int64.high.uint64 div 1_000_000_000'u64
SLOT_DURATION_MS = SECONDS_PER_SLOT * 1000

const SLOTS_PER_SYNC_COMMITTEE_PERIOD* =
SLOTS_PER_EPOCH * EPOCHS_PER_SYNC_COMMITTEE_PERIOD
Expand Down Expand Up @@ -809,6 +823,7 @@ proc readRuntimeConfig*(
if lineParts[0] in ignoredValues: continue

values[lineParts[0]] = lineParts[1].strip

# Accumulate BLOB_SCHEDULE entries
var
blobScheduleEntries: seq[BlobParameters]
Expand Down Expand Up @@ -992,6 +1007,13 @@ proc readRuntimeConfig*(
checkCompatibility REORG_PARENT_WEIGHT_THRESHOLD
checkCompatibility REORG_MAX_EPOCHS_SINCE_FINALIZATION

checkCompatibility SLOT_DURATION_MS
checkCompatibility ATTESTATION_DUE_BPS
checkCompatibility AGGREGATE_DUE_BPS
checkCompatibility SYNC_MESSAGE_DUE_BPS
checkCompatibility CONTRIBUTION_DUE_BPS
checkCompatibility PROPOSER_REORG_CUTOFF_BPS

template assignValue(name: static string, field: untyped): untyped =
if values.hasKey(name):
when field is seq[BlobParameters]:
Expand Down
2 changes: 1 addition & 1 deletion vendor/holesky
2 changes: 1 addition & 1 deletion vendor/hoodi
2 changes: 1 addition & 1 deletion vendor/sepolia
Loading