Skip to content

Commit 701245b

Browse files
committed
Support hoodiUZH config via intdefine
Allow loading the config #7525 which adjusts a couple config values that so far have not been overridden by any other networks (incl under dev), to support their research. Went with a simple {.intdefine.} approach, and tagged everything that is solely {.intdefine.} to support hoodiUZH as such with a comment. The extra module is used because we convert from the raw uint64 to a different internal type but use the same name so cannot be in same mod. To compile for hoodiUZH: ``` NIMFLAGS="-d:SECONDS_PER_SLOT=6 -d:REORG_MAX_EPOCHS_SINCE_FINALIZATION=8 -d:MAX_REQUEST_BLOCKS=256 -d:EPOCHS_PER_SUBNET_SUBSCRIPTION=64 -d:TTFB_TIMEOUT=10 -d:RESP_TIMEOUT=20 -d:MAXIMUM_GOSSIP_CLOCK_DISPARITY=1000 -d:SUBNETS_PER_NODE=1 -d:REORG_HEAD_WEIGHT_THRESHOLD=10" make -j nimbus_beacon_node ```
1 parent dbc7781 commit 701245b

File tree

3 files changed

+42
-14
lines changed

3 files changed

+42
-14
lines changed

beacon_chain/spec/datatypes/constants.nim

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
{.push raises: [].}
99

10-
import chronos/timer
10+
import chronos/timer, ./constants_raw
1111

1212
type
1313
Slot* = distinct uint64
@@ -24,8 +24,8 @@ const
2424
NODE_ID_BITS* = 256
2525

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

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

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

7778
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/phase0/p2p-interface.md#configuration
7879
MAX_PAYLOAD_SIZE* = 10'u64 * 1024 * 1024 # bytes
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# beacon_chain
2+
# Copyright (c) 2025 Status Research & Development GmbH
3+
# Licensed and distributed under either of
4+
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
5+
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
6+
# at your option. This file may not be copied, modified, or distributed except according to those terms.
7+
8+
{.push raises: [].}
9+
10+
const
11+
MAXIMUM_GOSSIP_CLOCK_DISPARITY* {.intdefine.}: uint64 = 500 # hoodiUZH
12+
REORG_MAX_EPOCHS_SINCE_FINALIZATION* {.intdefine.}: uint64 = 2 # hoodiUZH

beacon_chain/spec/presets.nim

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const
2929

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

@@ -722,11 +722,26 @@ else:
722722

723723
# createConstantsFromPreset const_preset
724724

725-
const IsMainnetSupported*: bool =
726-
const_preset == "mainnet" and SECONDS_PER_SLOT == 12
727-
728-
const IsGnosisSupported*: bool =
729-
const_preset == "gnosis" and SECONDS_PER_SLOT == 5
725+
const
726+
ConstantsAreDefault: bool =
727+
REORG_MAX_EPOCHS_SINCE_FINALIZATION.uint64 == 2 and
728+
MAX_REQUEST_BLOCKS == 1024 and
729+
EPOCHS_PER_SUBNET_SUBSCRIPTION == 256 and
730+
TTFB_TIMEOUT == 5 and
731+
RESP_TIMEOUT == 10 and
732+
MAXIMUM_GOSSIP_CLOCK_DISPARITY.milliseconds.uint64 == 500 and
733+
SUBNETS_PER_NODE == 2 and
734+
REORG_HEAD_WEIGHT_THRESHOLD == 20
735+
736+
IsMainnetSupported*: bool =
737+
const_preset == "mainnet" and
738+
ConstantsAreDefault and
739+
SECONDS_PER_SLOT == 12
740+
741+
IsGnosisSupported*: bool =
742+
const_preset == "gnosis" and
743+
ConstantsAreDefault and
744+
SECONDS_PER_SLOT == 5
730745

731746
const
732747
MIN_SECONDS_PER_SLOT* = 1'u64

0 commit comments

Comments
 (0)