Skip to content

Commit 67e4a04

Browse files
terseczah
authored andcommitted
simplify doppelganger detection to boolean
1 parent c4c0419 commit 67e4a04

File tree

5 files changed

+10
-27
lines changed

5 files changed

+10
-27
lines changed

beacon_chain/conf.nim

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,6 @@ type
5151
enabled # Always enabled
5252
disabled # Always disabled
5353

54-
DoppelgangerDetectionMode* {.pure.} = enum
55-
dontcheck
56-
warn
57-
stop
58-
5954
BeaconNodeConf* = object
6055
logLevel* {.
6156
defaultValue: "INFO"
@@ -266,10 +261,10 @@ type
266261
name: "dump" }: bool
267262

268263
doppelgangerDetection* {.
269-
defaultValue: DoppelgangerDetectionMode.stop
270-
desc: "[=stop*] What to do when another validator is detected to be running the same validator keys (default `stop`)"
264+
defaultValue: true
265+
desc: "Whether to detect whether another validator is be running the same validator keys (default true)"
271266
name: "doppelganger-detection"
272-
}: DoppelgangerDetectionMode
267+
}: bool
273268

274269
of createTestnet:
275270
testnetDepositsFile* {.

beacon_chain/eth2_processor.nim

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ declareCounter beacon_proposer_slashings_received,
3131
declareCounter beacon_voluntary_exits_received,
3232
"Number of beacon chain voluntary exits received by this peer"
3333

34-
declareCounter beacon_duplicate_validator_protection_activated,
35-
"Number of times duplicate validator protection was activated"
34+
declareCounter doppelganger_detection_activated,
35+
"Number of times doppelganger detection was activated"
3636

3737
const delayBuckets = [2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, Inf]
3838

@@ -307,15 +307,6 @@ proc blockValidator*(
307307
proc checkForPotentialDoppelganger(
308308
self: var Eth2Processor, attestationData: AttestationData,
309309
attesterIndices: IntSet, wallSlot: Slot) =
310-
# Attestations remain valid for 32 slots, so avoid confusing with one's own
311-
# reflections, for a ATTESTATION_PROPAGATION_SLOT_RANGE div SLOTS_PER_EPOCH
312-
# period after the attestation slot. For mainnet this can be one additional
313-
# epoch, and for minimal, four epochs. Unlike in the attestation validation
314-
# checks, use the spec version of the constant here.
315-
const
316-
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.0/specs/phase0/p2p-interface.md#configuration
317-
ATTESTATION_PROPAGATION_SLOT_RANGE = 32
318-
319310
let epoch = wallSlot.epoch
320311
if epoch < self.doppelgangerDetection.broadcastStartEpoch:
321312
let tgtBlck = self.chainDag.getRef(attestationData.target.root)
@@ -330,8 +321,8 @@ proc checkForPotentialDoppelganger(
330321
warn "Duplicate validator detected; would be slashed",
331322
validatorIndex,
332323
validatorPubkey
333-
beacon_duplicate_validator_protection_activated.inc()
334-
if self.config.doppelgangerDetection == DoppelgangerDetectionMode.stop:
324+
doppelganger_detection_activated.inc()
325+
if self.config.doppelgangerDetection:
335326
warn "We believe you are currently running another instance of the same validator. We've disconnected you from the network as this presents a significant slashing risk. Possible next steps are (a) making sure you've disconnected your validator from your old machine before restarting the client; and (b) running the client again with the gossip-slashing-protection option disabled, only if you are absolutely sure this is the only instance of your validator running, and reporting the issue at https://github.com/status-im/nimbus-eth2/issues."
336327
quit QuitFailure
337328

beacon_chain/validator_duties.nim

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,11 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
615615

616616
var curSlot = lastSlot + 1
617617

618-
# The dontcheck option's a deliberately undocumented escape hatch for the
619-
# local testnets and similar development and testing use cases.
620-
#
621618
# If broadcastStartEpoch is 0, it hasn't had time to initialize yet, which
622619
# means that it'd be okay not to continue, but it won't gossip regardless.
623620
if curSlot.epoch <
624621
node.processor[].doppelgangerDetection.broadcastStartEpoch and
625-
node.config.doppelgangerDetection != DoppelgangerDetectionMode.dontcheck:
622+
node.config.doppelgangerDetection:
626623
debug "Waiting to gossip out to detect potential duplicate validators",
627624
broadcastStartEpoch =
628625
node.processor[].doppelgangerDetection.broadcastStartEpoch

scripts/launch_local_testnet.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
391391
--metrics \
392392
--metrics-address="127.0.0.1" \
393393
--metrics-port="$(( BASE_METRICS_PORT + NUM_NODE ))" \
394-
--doppelganger-detection=dontcheck \
394+
--doppelganger-detection=off \
395395
${EXTRA_ARGS} \
396396
> "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 &
397397

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-
--doppelganger-detection=dontcheck \
108+
--doppelganger-detection=off \
109109
${ADDITIONAL_BEACON_NODE_ARGS} \
110110
"$@"

0 commit comments

Comments
 (0)