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

View File

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

View File

@ -694,7 +694,7 @@ proc removeMessageHandlers(node: BeaconNode) =
for subnet in 0'u64 ..< ATTESTATION_SUBNET_COUNT: for subnet in 0'u64 ..< ATTESTATION_SUBNET_COUNT:
node.network.unsubscribe(getAttestationTopic(node.forkDigest, subnet)) 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 # When another client's already running, this is very likely to detect
# potential duplicate validators, which can trigger slashing. # 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. # the epoch delay to one's perceived risk.
const duplicateValidatorEpochs = 2 const duplicateValidatorEpochs = 2
node.processor.doppelgangerProtection.broadcastStartEpoch = node.processor.doppelgangerDetection.broadcastStartEpoch =
slot.epoch + duplicateValidatorEpochs slot.epoch + duplicateValidatorEpochs
debug "Setting up doppelganger protection", debug "Setting up doppelganger protection",
epoch = slot.epoch, epoch = slot.epoch,
broadcastStartEpoch = broadcastStartEpoch =
node.processor.doppelgangerProtection.broadcastStartEpoch node.processor.doppelgangerDetection.broadcastStartEpoch
proc updateGossipStatus(node: BeaconNode, slot: Slot) = proc updateGossipStatus(node: BeaconNode, slot: Slot) =
# Syncing tends to be ~1 block/s, and allow for an epoch of time for libp2p # 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, headSlot = node.chainDag.head.slot,
syncQueueLen syncQueueLen
node.setupSelfSlashingProtection(slot) node.setupDoppelgangerDetection(slot)
node.addMessageHandlers() node.addMessageHandlers()
doAssert node.getTopicSubscriptionEnabled() doAssert node.getTopicSubscriptionEnabled()
elif elif
@ -1063,7 +1063,7 @@ proc run*(node: BeaconNode) =
node.startSyncManager() node.startSyncManager()
if not node.beaconClock.now().toSlot().afterGenesis: if not node.beaconClock.now().toSlot().afterGenesis:
node.setupSelfSlashingProtection(curSlot) node.setupDoppelgangerDetection(curSlot)
node.addMessageHandlers() node.addMessageHandlers()
doAssert node.getTopicSubscriptionEnabled() 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 # 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. # means that it'd be okay not to continue, but it won't gossip regardless.
if curSlot.epoch < if curSlot.epoch <
node.processor[].doppelgangerProtection.broadcastStartEpoch and node.processor[].doppelgangerDetection.broadcastStartEpoch and
node.config.doppelgangerProtection != node.config.doppelgangerDetection != DoppelgangerDetectionMode.dontcheck:
DoppelgangerProtectionMode.dontcheck:
debug "Waiting to gossip out to detect potential duplicate validators", debug "Waiting to gossip out to detect potential duplicate validators",
broadcastStartEpoch = broadcastStartEpoch =
node.processor[].doppelgangerProtection.broadcastStartEpoch node.processor[].doppelgangerDetection.broadcastStartEpoch
return return
# Start by checking if there's work we should have done in the past that we # 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 \
--metrics-address="127.0.0.1" \ --metrics-address="127.0.0.1" \
--metrics-port="$(( BASE_METRICS_PORT + NUM_NODE ))" \ --metrics-port="$(( BASE_METRICS_PORT + NUM_NODE ))" \
--doppelganger-protection=dontcheck \ --doppelganger-detection=dontcheck \
${EXTRA_ARGS} \ ${EXTRA_ARGS} \
> "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 & > "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 &

View File

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