rename doppelganger protection to doppelganger detection; switch default from warn to stop (#2281)

This commit is contained in:
tersec 2021-02-01 12:18:16 +01:00 committed by GitHub
parent fa99c3b417
commit 6141286547
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 21 deletions

View File

@ -51,7 +51,7 @@ type
enabled # Always enabled
disabled # Always disabled
DoppelgangerProtectionMode* {.pure.} = enum
DoppelgangerDetectionMode* {.pure.} = enum
dontcheck
warn
stop
@ -258,11 +258,11 @@ type
desc: "Write SSZ dumps of blocks, attestations and states to data dir"
name: "dump" }: bool
doppelgangerProtection* {.
defaultValue: DoppelgangerProtectionMode.warn
desc: "[=warn*|stop] What to do when another validator is detected to be running the same validator keys (default `warn`, will become `stop` in the future)"
name: "doppelganger-protection"
}: DoppelgangerProtectionMode
doppelgangerDetection* {.
defaultValue: DoppelgangerDetectionMode.stop
desc: "[=stop*] What to do when another validator is detected to be running the same validator keys (default `stop`)"
name: "doppelganger-detection"
}: DoppelgangerDetectionMode
of createTestnet:
testnetDepositsFile* {.

View File

@ -78,7 +78,7 @@ type
attestationsQueue*: AsyncQueue[AttestationEntry]
aggregatesQueue*: AsyncQueue[AggregateEntry]
doppelgangerProtection*: DoppelgangerProtection
doppelgangerDetection*: DoppelgangerProtection
proc updateHead*(self: var Eth2Processor, wallSlot: Slot) =
## Trigger fork choice and returns the new head block.
@ -316,9 +316,8 @@ proc checkForPotentialDoppelganger(
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.0/specs/phase0/p2p-interface.md#configuration
ATTESTATION_PROPAGATION_SLOT_RANGE = 32
# If doppelgangerProtection not dontcheck or stop, it's the default "warn".
let epoch = wallSlot.epoch
if epoch < self.doppelgangerProtection.broadcastStartEpoch:
if epoch < self.doppelgangerDetection.broadcastStartEpoch:
let tgtBlck = self.chainDag.getRef(attestationData.target.root)
doAssert not tgtBlck.isNil # because attestation is valid above
@ -332,7 +331,7 @@ proc checkForPotentialDoppelganger(
validatorIndex,
validatorPubkey
beacon_duplicate_validator_protection_activated.inc()
if self.config.doppelgangerProtection == DoppelgangerProtectionMode.stop:
if self.config.doppelgangerDetection == DoppelgangerDetectionMode.stop:
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

View File

@ -694,7 +694,7 @@ proc removeMessageHandlers(node: BeaconNode) =
for subnet in 0'u64 ..< ATTESTATION_SUBNET_COUNT:
node.network.unsubscribe(getAttestationTopic(node.forkDigest, subnet))
proc setupSelfSlashingProtection(node: BeaconNode, slot: Slot) =
proc setupDoppelgangerDetection(node: BeaconNode, slot: Slot) =
# When another client's already running, this is very likely to detect
# potential duplicate validators, which can trigger slashing.
#
@ -704,12 +704,12 @@ proc setupSelfSlashingProtection(node: BeaconNode, slot: Slot) =
# the epoch delay to one's perceived risk.
const duplicateValidatorEpochs = 2
node.processor.doppelgangerProtection.broadcastStartEpoch =
node.processor.doppelgangerDetection.broadcastStartEpoch =
slot.epoch + duplicateValidatorEpochs
debug "Setting up doppelganger protection",
epoch = slot.epoch,
broadcastStartEpoch =
node.processor.doppelgangerProtection.broadcastStartEpoch
node.processor.doppelgangerDetection.broadcastStartEpoch
proc updateGossipStatus(node: BeaconNode, slot: Slot) =
# Syncing tends to be ~1 block/s, and allow for an epoch of time for libp2p
@ -744,7 +744,7 @@ proc updateGossipStatus(node: BeaconNode, slot: Slot) =
headSlot = node.chainDag.head.slot,
syncQueueLen
node.setupSelfSlashingProtection(slot)
node.setupDoppelgangerDetection(slot)
node.addMessageHandlers()
doAssert node.getTopicSubscriptionEnabled()
elif
@ -1063,7 +1063,7 @@ proc run*(node: BeaconNode) =
node.startSyncManager()
if not node.beaconClock.now().toSlot().afterGenesis:
node.setupSelfSlashingProtection(curSlot)
node.setupDoppelgangerDetection(curSlot)
node.addMessageHandlers()
doAssert node.getTopicSubscriptionEnabled()

View File

@ -621,12 +621,11 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
# 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[].doppelgangerProtection.broadcastStartEpoch and
node.config.doppelgangerProtection !=
DoppelgangerProtectionMode.dontcheck:
node.processor[].doppelgangerDetection.broadcastStartEpoch and
node.config.doppelgangerDetection != DoppelgangerDetectionMode.dontcheck:
debug "Waiting to gossip out to detect potential duplicate validators",
broadcastStartEpoch =
node.processor[].doppelgangerProtection.broadcastStartEpoch
node.processor[].doppelgangerDetection.broadcastStartEpoch
return
# Start by checking if there's work we should have done in the past that we

View File

@ -385,7 +385,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-protection=dontcheck \
--doppelganger-detection=dontcheck \
${EXTRA_ARGS} \
> "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 &

View File

@ -105,6 +105,6 @@ $BEACON_NODE_BIN \
--metrics \
--metrics-address="127.0.0.1" \
--metrics-port="$(( $BASE_METRICS_PORT + $NODE_ID ))" \
--doppelganger-protection=dontcheck \
--doppelganger-detection=dontcheck \
${ADDITIONAL_BEACON_NODE_ARGS} \
"$@"