Skip to content

Commit 503ac5e

Browse files
authored
make REORG_HEAD_WEIGHT_THRESHOLD and REORG_MAX_EPOCHS_SINCE_FINALIZATION configurable (#7620)
1 parent bf05a4e commit 503ac5e

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

beacon_chain/rpc/rest_config_api.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
238238
PROPOSER_SCORE_BOOST:
239239
Base10.toString(PROPOSER_SCORE_BOOST),
240240
REORG_HEAD_WEIGHT_THRESHOLD:
241-
Base10.toString(REORG_HEAD_WEIGHT_THRESHOLD),
241+
Base10.toString(cfg.REORG_HEAD_WEIGHT_THRESHOLD),
242242
REORG_PARENT_WEIGHT_THRESHOLD:
243243
Base10.toString(REORG_PARENT_WEIGHT_THRESHOLD),
244244
REORG_MAX_EPOCHS_SINCE_FINALIZATION:
245-
Base10.toString(uint64(REORG_MAX_EPOCHS_SINCE_FINALIZATION)),
245+
Base10.toString(cfg.REORG_MAX_EPOCHS_SINCE_FINALIZATION),
246246

247247
DEPOSIT_CHAIN_ID:
248248
Base10.toString(cfg.DEPOSIT_CHAIN_ID),

beacon_chain/spec/datatypes/constants.nim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
66
# at your option. This file may not be copied, modified, or distributed except according to those terms.
77

8-
{.push raises: [].}
8+
{.push raises: [], gcsafe.}
99

1010
import chronos/timer
1111

@@ -64,9 +64,7 @@ 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
6867
REORG_PARENT_WEIGHT_THRESHOLD*: uint64 = 160
69-
REORG_MAX_EPOCHS_SINCE_FINALIZATION* = Epoch(2)
7068

7169
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#configuration
7270
MAX_REQUEST_BLOCKS* = 1024'u64

beacon_chain/spec/presets.nim

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ type
109109

110110
# Fork choice
111111
# TODO PROPOSER_SCORE_BOOST*: uint64
112-
# TODO REORG_HEAD_WEIGHT_THRESHOLD*: uint64
112+
REORG_HEAD_WEIGHT_THRESHOLD*: uint64
113113
# TODO REORG_PARENT_WEIGHT_THRESHOLD*: uint64
114-
# TODO REORG_MAX_EPOCHS_SINCE_FINALIZATION*: uint64
114+
REORG_MAX_EPOCHS_SINCE_FINALIZATION*: uint64
115115

116116
# Deposit contract
117117
DEPOSIT_CHAIN_ID*: uint64
@@ -266,7 +266,6 @@ when const_preset == "mainnet":
266266
# 2**11 (= 2,048) Eth1 blocks ~8 hours
267267
ETH1_FOLLOW_DISTANCE: 2048,
268268

269-
270269
# Validator cycle
271270
# ---------------------------------------------------------------
272271
# 2**2 (= 4)
@@ -282,6 +281,11 @@ when const_preset == "mainnet":
282281
# [New in Deneb:EIP7514] 2**3 (= 8)
283282
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8,
284283

284+
# Fork choice
285+
# ---------------------------------------------------------------
286+
REORG_HEAD_WEIGHT_THRESHOLD: 20,
287+
REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2,
288+
285289
# Deposit contract
286290
# ---------------------------------------------------------------
287291
# Ethereum PoW Mainnet
@@ -449,6 +453,11 @@ elif const_preset == "gnosis":
449453
# [New in Deneb:EIP7514] 2**3 (= 8)
450454
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8,
451455

456+
# Fork choice
457+
# ---------------------------------------------------------------
458+
REORG_HEAD_WEIGHT_THRESHOLD: 20,
459+
REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2,
460+
452461
# Deposit contract
453462
# ---------------------------------------------------------------
454463
# Gnosis PoW Mainnet
@@ -597,7 +606,6 @@ elif const_preset == "minimal":
597606
# [customized] process deposits more quickly, but insecure
598607
ETH1_FOLLOW_DISTANCE: 16,
599608

600-
601609
# Validator cycle
602610
# ---------------------------------------------------------------
603611
# 2**2 (= 4)
@@ -613,6 +621,10 @@ elif const_preset == "minimal":
613621
# [New in Deneb:EIP7514] [customized]
614622
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 4,
615623

624+
# Fork choice
625+
# ---------------------------------------------------------------
626+
REORG_HEAD_WEIGHT_THRESHOLD: 20,
627+
REORG_MAX_EPOCHS_SINCE_FINALIZATION: 2,
616628

617629
# Deposit contract
618630
# ---------------------------------------------------------------
@@ -984,9 +996,7 @@ proc readRuntimeConfig*(
984996
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.0/specs/phase0/fork-choice.md#configuration
985997
# Isn't being used as a preset in the usual way: at any time, there's one correct value
986998
checkCompatibility PROPOSER_SCORE_BOOST
987-
checkCompatibility REORG_HEAD_WEIGHT_THRESHOLD
988999
checkCompatibility REORG_PARENT_WEIGHT_THRESHOLD
989-
checkCompatibility REORG_MAX_EPOCHS_SINCE_FINALIZATION
9901000

9911001
checkCompatibility SLOT_DURATION_MS
9921002
checkCompatibility ATTESTATION_DUE_BPS

0 commit comments

Comments
 (0)