Skip to content

Commit 4dee5c4

Browse files
committed
simplify duplicate validator detection UI
1 parent aa989b9 commit 4dee5c4

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed

beacon_chain/conf.nim

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,11 @@ type
250250
desc: "Write SSZ dumps of blocks, attestations and states to data dir"
251251
name: "dump" }: bool
252252

253-
dupProtectionEpochs* {.
254-
defaultValue: 0
255-
desc: "Number of epochs of gossip to which to listen before broadcasting"
256-
name: "dup-protection-epochs" }: uint64
257-
258-
dupProtectionQuit* {.
259-
defaultValue: true
260-
desc: "Whether to quit, rather than just disabling validators, if duplicate validators are detected"
261-
name: "dup-protection-quit" }: bool
253+
duplicateValidator* {.
254+
defaultValue: "warn"
255+
desc: "What to do when another validator is detected to be running the same validator keys (default `warn`, will become `stop` in the future)"
256+
name: "duplicate-validator"
257+
}: string
262258

263259
of createTestnet:
264260
testnetDepositsFile* {.

beacon_chain/eth2_processor.nim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,12 @@ proc checkForPotentialSelfSlashing(
305305

306306
GUARD_EPOCHS = ATTESTATION_PROPAGATION_SLOT_RANGE div SLOTS_PER_EPOCH
307307

308+
# If duplicateValidator not dontcheck or stop, it's the default "warn". The
309+
# dontcheck option's a deliberately undocumented escape hatch for the local
310+
# testnets and similar development and testing use cases.
308311
let epoch = wallSlot.epoch
309-
# Can skip this whole conditional by setting relevant config value to 0
310-
if epoch < self.dupProtection.broadcastStartEpoch and
311-
self.dupProtection.probeEpoch > 0 and
312+
if self.config.duplicateValidator != "dontcheck" and
313+
epoch < self.dupProtection.broadcastStartEpoch and
312314
epoch >= self.dupProtection.probeEpoch and
313315
epoch <= self.dupProtection.probeEpoch + GUARD_EPOCHS:
314316
let tgtBlck = self.chainDag.getRef(attestationData.target.root)
@@ -324,7 +326,7 @@ proc checkForPotentialSelfSlashing(
324326
validatorIndex,
325327
validatorPubkey
326328
beacon_duplicate_validator_protection_activated.inc()
327-
if self.config.dupProtectionQuit:
329+
if self.config.duplicateValidator == "stop":
328330
quit QuitFailure
329331

330332
proc attestationValidator*(

beacon_chain/nimbus_beacon_node.nim

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,10 @@ proc setupSelfSlashingProtection(node: BeaconNode, slot: Slot) =
516516
#
517517
# This approach catches both startup and network outage conditions.
518518

519+
const duplicateValidatorEpochs = 2
520+
519521
node.processor.dupProtection.broadcastStartEpoch =
520-
slot.epoch + node.config.dupProtectionEpochs
522+
slot.epoch + duplicateValidatorEpochs
521523
# randomize() already called; also, never probe on first epoch in guard
522524
# period, so that existing, running validators can be picked up. Whilst
523525
# this reduces entropy for overlapping-start cases, and increases their
@@ -526,14 +528,12 @@ proc setupSelfSlashingProtection(node: BeaconNode, slot: Slot) =
526528
# duplicate pair overlaps exactly, only the running/starting case. Even
527529
# 2 epochs is dangerous because it'll guarantee colliding probes in the
528530
# overlapping case.
529-
if node.config.dupProtectionEpochs > 1:
530-
# So dPE == 2 -> epoch + 1, always; dPE == 3 -> epoch + (1 or 2), etc.
531-
node.processor.dupProtection.probeEpoch =
532-
slot.epoch + 1 + rand(node.config.dupProtectionEpochs.int - 2).uint64
533-
doAssert node.processor.dupProtection.probeEpoch <
534-
node.processor.dupProtection.broadcastStartEpoch
535-
else:
536-
node.processor.dupProtection.probeEpoch = 0.Epoch # don't probe
531+
532+
# So dPE == 2 -> epoch + 1, always; dPE == 3 -> epoch + (1 or 2), etc.
533+
node.processor.dupProtection.probeEpoch =
534+
slot.epoch + 1 + rand(duplicateValidatorEpochs.int - 2).uint64
535+
doAssert node.processor.dupProtection.probeEpoch <
536+
node.processor.dupProtection.broadcastStartEpoch
537537

538538
debug "Setting up self-slashing protection",
539539
epoch = slot.epoch,

scripts/launch_local_testnet.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
384384
--metrics \
385385
--metrics-address="127.0.0.1" \
386386
--metrics-port="$(( BASE_METRICS_PORT + NUM_NODE ))" \
387-
--dup-protection-epochs=0 \
387+
--duplicate-validator=dontcheck \
388388
${EXTRA_ARGS} \
389389
> "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 &
390390

tests/simulation/run_node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@ $BEACON_NODE_BIN \
105105
--metrics \
106106
--metrics-address="127.0.0.1" \
107107
--metrics-port="$(( $BASE_METRICS_PORT + $NODE_ID ))" \
108-
--dup-protection-epochs=0 \
108+
--duplicate-validator=dontcheck \
109109
${ADDITIONAL_BEACON_NODE_ARGS} \
110110
"$@"

0 commit comments

Comments
 (0)