Skip to content

Commit d918b7b

Browse files
etan-statuszah
authored andcommitted
update defaultRuntimeConfig for v1.1.1 (#2958)
This synchronizes defaultRuntimeConfig with v1.1.1 of the spec. - Introduces `TERMINAL_TOTAL_DIFFICULTY` and `TERMINAL_BLOCK_HASH`. - Sets `ALTAIR_FORK_EPOCH` in `mainnet` preset.
1 parent dbbdbea commit d918b7b

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

beacon_chain/spec/presets.nim

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

1010
import
1111
std/[macros, strutils, parseutils, tables],
12-
stew/endians2,
13-
web3/[ethtypes]
12+
stew/endians2, stint, web3/[ethtypes]
1413

1514
export
1615
toBytesBE
@@ -30,10 +29,14 @@ type
3029
Eth1Address* = ethtypes.Address
3130

3231
RuntimeConfig* = object
33-
## https://github.com/ethereum/eth2.0-specs/tree/v1.1.0-alpha.8/configs
32+
## https://github.com/ethereum/consensus-specs/tree/v1.1.1/configs
3433

3534
PRESET_BASE*: string
3635

36+
# Transition
37+
TERMINAL_TOTAL_DIFFICULTY*: UInt256
38+
TERMINAL_BLOCK_HASH*: BlockHash
39+
3740
# Genesis
3841
MIN_GENESIS_ACTIVE_VALIDATOR_COUNT*: uint64
3942
MIN_GENESIS_TIME*: uint64
@@ -144,10 +147,6 @@ const
144147

145148
"CONFIG_NAME",
146149

147-
# Merge-related settings that are already part of the mainnet config:
148-
"TERMINAL_TOTAL_DIFFICULTY",
149-
"TERMINAL_BLOCK_HASH",
150-
151150
"TRANSITION_TOTAL_DIFFICULTY", # Name that appears in some altair alphas, obsolete, remove when no more testnets
152151
]
153152

@@ -158,11 +157,20 @@ when const_preset == "mainnet":
158157
# TODO Move this to RuntimeConfig
159158
const SECONDS_PER_SLOT* {.intdefine.}: uint64 = 12
160159

161-
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-alpha.8/configs/mainnet.yaml
160+
# https://github.com/ethereum/consensus-specs/blob/v1.1.1/configs/mainnet.yaml
162161
# TODO Read these from yaml file
163162
const defaultRuntimeConfig* = RuntimeConfig(
164163
PRESET_BASE: "mainnet",
165164

165+
# Transition
166+
# ---------------------------------------------------------------
167+
# TBD, 2**256-2**10 is a placeholder
168+
TERMINAL_TOTAL_DIFFICULTY:
169+
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912",
170+
# By default, don't use this param
171+
TERMINAL_BLOCK_HASH: BlockHash.fromHex(
172+
"0x0000000000000000000000000000000000000000000000000000000000000000"),
173+
166174
# Genesis
167175
# ---------------------------------------------------------------
168176
# `2**14` (= 16,384)
@@ -183,7 +191,7 @@ when const_preset == "mainnet":
183191

184192
# Altair
185193
ALTAIR_FORK_VERSION: Version [byte 0x01, 0x00, 0x00, 0x00],
186-
ALTAIR_FORK_EPOCH: FAR_FUTURE_EPOCH,
194+
ALTAIR_FORK_EPOCH: Epoch(74240), # Oct 27, 2021, 10:56:23am UTC
187195
# Merge
188196
MERGE_FORK_VERSION: Version [byte 0x02, 0x00, 0x00, 0x00],
189197
MERGE_FORK_EPOCH: Epoch(uint64.high),
@@ -237,13 +245,22 @@ elif const_preset == "minimal":
237245

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

240-
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-alpha.8/configs/minimal.yaml
248+
# https://github.com/ethereum/consensus-specs/blob/v1.1.1/configs/minimal.yaml
241249
const defaultRuntimeConfig* = RuntimeConfig(
242250
# Minimal config
243251

244252
# Extends the minimal preset
245253
PRESET_BASE: "minimal",
246254

255+
# Transition
256+
# ---------------------------------------------------------------
257+
# TBD, 2**256-2**10 is a placeholder
258+
TERMINAL_TOTAL_DIFFICULTY:
259+
u256"115792089237316195423570985008687907853269984665640564039457584007913129638912",
260+
# By default, don't use this param
261+
TERMINAL_BLOCK_HASH: BlockHash.fromHex(
262+
"0x0000000000000000000000000000000000000000000000000000000000000000"),
263+
247264
# Genesis
248265
# ---------------------------------------------------------------
249266
# [customized]
@@ -367,6 +384,12 @@ template parse(T: type string, input: string): T =
367384
template parse(T: type Eth1Address, input: string): T =
368385
Eth1Address.fromHex(input)
369386

387+
template parse(T: type BlockHash, input: string): T =
388+
BlockHash.fromHex(input)
389+
390+
template parse(T: type UInt256, input: string): T =
391+
parse(input, UInt256, 10)
392+
370393
proc readRuntimeConfig*(
371394
path: string): (RuntimeConfig, seq[string]) {.
372395
raises: [IOError, PresetFileError, PresetIncompatibleError, Defect].} =

0 commit comments

Comments
 (0)