Skip to content
17 changes: 9 additions & 8 deletions beacon_chain/spec/datatypes/constants.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{.push raises: [].}

import chronos/timer
import chronos/timer, ./constants_raw

type
Slot* = distinct uint64
Expand All @@ -24,8 +24,8 @@ const
NODE_ID_BITS* = 256

# https://github.com/ethereum/consensus-specs/blob/v1.6.0-alpha.0/specs/phase0/p2p-interface.md#configuration
EPOCHS_PER_SUBNET_SUBSCRIPTION* = 256'u64
SUBNETS_PER_NODE* = 2'u64
EPOCHS_PER_SUBNET_SUBSCRIPTION* {.intdefine.}: uint64 = 256'u64 # hoodiUZH
SUBNETS_PER_NODE* {.intdefine.}: uint64 = 2'u64 # hoodiUZH
ATTESTATION_SUBNET_COUNT*: uint64 = 64
ATTESTATION_SUBNET_EXTRA_BITS* = 0'u64
ATTESTATION_SUBNET_PREFIX_BITS* = 6'u64 ## \
Expand Down Expand Up @@ -64,15 +64,16 @@ const

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/fork-choice.md#configuration
PROPOSER_SCORE_BOOST*: uint64 = 40
REORG_HEAD_WEIGHT_THRESHOLD*: uint64 = 20
REORG_HEAD_WEIGHT_THRESHOLD* {.intdefine.}: uint64 = 20 # hoodiUZH
REORG_PARENT_WEIGHT_THRESHOLD*: uint64 = 160
REORG_MAX_EPOCHS_SINCE_FINALIZATION* = Epoch(2)
REORG_MAX_EPOCHS_SINCE_FINALIZATION* {.intdefine.} =
Epoch(REORG_MAX_EPOCHS_SINCE_FINALIZATION)

# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#configuration
MAX_REQUEST_BLOCKS* = 1024'u64
RESP_TIMEOUT* = 10'u64
MAX_REQUEST_BLOCKS* {.intdefine.}: uint64 = 1024'u64 # hoodiUZH
RESP_TIMEOUT* {.intdefine.}: uint64 = 10'u64 # hoodiUZH
ATTESTATION_PROPAGATION_SLOT_RANGE*: uint64 = 32
MAXIMUM_GOSSIP_CLOCK_DISPARITY* = 500.millis
MAXIMUM_GOSSIP_CLOCK_DISPARITY* = MAXIMUM_GOSSIP_CLOCK_DISPARITY.int64.millis

# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/phase0/p2p-interface.md#configuration
MAX_PAYLOAD_SIZE* = 10'u64 * 1024 * 1024 # bytes
Expand Down
12 changes: 12 additions & 0 deletions beacon_chain/spec/datatypes/constants_raw.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# beacon_chain
# Copyright (c) 2025 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * 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: [].}

const
MAXIMUM_GOSSIP_CLOCK_DISPARITY* {.intdefine.}: uint64 = 500 # hoodiUZH
REORG_MAX_EPOCHS_SINCE_FINALIZATION* {.intdefine.}: uint64 = 2 # hoodiUZH
27 changes: 21 additions & 6 deletions beacon_chain/spec/presets.nim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const

# Not used anywhere; only for network preset checking
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION: uint64 = 256
TTFB_TIMEOUT* = 5'u64
TTFB_TIMEOUT* {.intdefine.}: uint64 = 5'u64 # hoodiUZH
MESSAGE_DOMAIN_INVALID_SNAPPY*: array[4, byte] = [0x00, 0x00, 0x00, 0x00]
MESSAGE_DOMAIN_VALID_SNAPPY*: array[4, byte] = [0x01, 0x00, 0x00, 0x00]

Expand Down Expand Up @@ -722,11 +722,26 @@ else:

# createConstantsFromPreset const_preset

const IsMainnetSupported*: bool =
const_preset == "mainnet" and SECONDS_PER_SLOT == 12

const IsGnosisSupported*: bool =
const_preset == "gnosis" and SECONDS_PER_SLOT == 5
const
ConstantsAreDefault: bool =
REORG_MAX_EPOCHS_SINCE_FINALIZATION.uint64 == 2 and
MAX_REQUEST_BLOCKS == 1024 and
EPOCHS_PER_SUBNET_SUBSCRIPTION == 256 and
TTFB_TIMEOUT == 5 and
RESP_TIMEOUT == 10 and
MAXIMUM_GOSSIP_CLOCK_DISPARITY.milliseconds.uint64 == 500 and
SUBNETS_PER_NODE == 2 and
REORG_HEAD_WEIGHT_THRESHOLD == 20

IsMainnetSupported*: bool =
const_preset == "mainnet" and
ConstantsAreDefault and
SECONDS_PER_SLOT == 12

IsGnosisSupported*: bool =
const_preset == "gnosis" and
ConstantsAreDefault and
SECONDS_PER_SLOT == 5

const
MIN_SECONDS_PER_SLOT* = 1'u64
Expand Down
Loading