From 67e4a045a3898208f7850458245d834e7e2b4e86 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Wed, 3 Feb 2021 18:11:42 +0100 Subject: [PATCH] simplify doppelganger detection to boolean --- beacon_chain/conf.nim | 11 +++-------- beacon_chain/eth2_processor.nim | 17 ++++------------- beacon_chain/validator_duties.nim | 5 +---- scripts/launch_local_testnet.sh | 2 +- tests/simulation/run_node.sh | 2 +- 5 files changed, 10 insertions(+), 27 deletions(-) diff --git a/beacon_chain/conf.nim b/beacon_chain/conf.nim index 1fd11d48d..da4276e63 100644 --- a/beacon_chain/conf.nim +++ b/beacon_chain/conf.nim @@ -51,11 +51,6 @@ type enabled # Always enabled disabled # Always disabled - DoppelgangerDetectionMode* {.pure.} = enum - dontcheck - warn - stop - BeaconNodeConf* = object logLevel* {. defaultValue: "INFO" @@ -266,10 +261,10 @@ type name: "dump" }: bool doppelgangerDetection* {. - defaultValue: DoppelgangerDetectionMode.stop - desc: "[=stop*] What to do when another validator is detected to be running the same validator keys (default `stop`)" + defaultValue: true + desc: "Whether to detect whether another validator is be running the same validator keys (default true)" name: "doppelganger-detection" - }: DoppelgangerDetectionMode + }: bool of createTestnet: testnetDepositsFile* {. diff --git a/beacon_chain/eth2_processor.nim b/beacon_chain/eth2_processor.nim index ce77fe212..e1a7c0b9b 100644 --- a/beacon_chain/eth2_processor.nim +++ b/beacon_chain/eth2_processor.nim @@ -31,8 +31,8 @@ declareCounter beacon_proposer_slashings_received, declareCounter beacon_voluntary_exits_received, "Number of beacon chain voluntary exits received by this peer" -declareCounter beacon_duplicate_validator_protection_activated, - "Number of times duplicate validator protection was activated" +declareCounter doppelganger_detection_activated, + "Number of times doppelganger detection was activated" const delayBuckets = [2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0, Inf] @@ -307,15 +307,6 @@ proc blockValidator*( proc checkForPotentialDoppelganger( self: var Eth2Processor, attestationData: AttestationData, attesterIndices: IntSet, wallSlot: Slot) = - # Attestations remain valid for 32 slots, so avoid confusing with one's own - # reflections, for a ATTESTATION_PROPAGATION_SLOT_RANGE div SLOTS_PER_EPOCH - # period after the attestation slot. For mainnet this can be one additional - # epoch, and for minimal, four epochs. Unlike in the attestation validation - # checks, use the spec version of the constant here. - const - # https://github.com/ethereum/eth2.0-specs/blob/v1.0.0/specs/phase0/p2p-interface.md#configuration - ATTESTATION_PROPAGATION_SLOT_RANGE = 32 - let epoch = wallSlot.epoch if epoch < self.doppelgangerDetection.broadcastStartEpoch: let tgtBlck = self.chainDag.getRef(attestationData.target.root) @@ -330,8 +321,8 @@ proc checkForPotentialDoppelganger( warn "Duplicate validator detected; would be slashed", validatorIndex, validatorPubkey - beacon_duplicate_validator_protection_activated.inc() - if self.config.doppelgangerDetection == DoppelgangerDetectionMode.stop: + doppelganger_detection_activated.inc() + if self.config.doppelgangerDetection: 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." quit QuitFailure diff --git a/beacon_chain/validator_duties.nim b/beacon_chain/validator_duties.nim index e50ee0e1d..18cd7482d 100644 --- a/beacon_chain/validator_duties.nim +++ b/beacon_chain/validator_duties.nim @@ -615,14 +615,11 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} = var curSlot = lastSlot + 1 - # The dontcheck option's a deliberately undocumented escape hatch for the - # local testnets and similar development and testing use cases. - # # If broadcastStartEpoch is 0, it hasn't had time to initialize yet, which # means that it'd be okay not to continue, but it won't gossip regardless. if curSlot.epoch < node.processor[].doppelgangerDetection.broadcastStartEpoch and - node.config.doppelgangerDetection != DoppelgangerDetectionMode.dontcheck: + node.config.doppelgangerDetection: debug "Waiting to gossip out to detect potential duplicate validators", broadcastStartEpoch = node.processor[].doppelgangerDetection.broadcastStartEpoch diff --git a/scripts/launch_local_testnet.sh b/scripts/launch_local_testnet.sh index d226c8c7a..91a9f48d5 100755 --- a/scripts/launch_local_testnet.sh +++ b/scripts/launch_local_testnet.sh @@ -391,7 +391,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do --metrics \ --metrics-address="127.0.0.1" \ --metrics-port="$(( BASE_METRICS_PORT + NUM_NODE ))" \ - --doppelganger-detection=dontcheck \ + --doppelganger-detection=off \ ${EXTRA_ARGS} \ > "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 & diff --git a/tests/simulation/run_node.sh b/tests/simulation/run_node.sh index 1aeed70d6..6be60643e 100755 --- a/tests/simulation/run_node.sh +++ b/tests/simulation/run_node.sh @@ -105,6 +105,6 @@ $BEACON_NODE_BIN \ --metrics \ --metrics-address="127.0.0.1" \ --metrics-port="$(( $BASE_METRICS_PORT + $NODE_ID ))" \ - --doppelganger-detection=dontcheck \ + --doppelganger-detection=off \ ${ADDITIONAL_BEACON_NODE_ARGS} \ "$@"