From 4aa110bf2d90b77cb58db67de0089f0a511aad67 Mon Sep 17 00:00:00 2001 From: cheatfate Date: Fri, 17 Mar 2023 00:25:00 +0200 Subject: [PATCH] Fix doppelganger detection should not start at pre-genesis time. Fix fallback service sync status spam. Fix false `sync committee subnets subscription error`. --- .../validator_client/doppelganger_service.nim | 15 +++++++++++++++ beacon_chain/validator_client/duties_service.nim | 14 +++++++------- .../validator_client/fallback_service.nim | 11 ++++++++++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/beacon_chain/validator_client/doppelganger_service.nim b/beacon_chain/validator_client/doppelganger_service.nim index ed165ebdd7..9cef4488b4 100644 --- a/beacon_chain/validator_client/doppelganger_service.nim +++ b/beacon_chain/validator_client/doppelganger_service.nim @@ -58,6 +58,21 @@ proc mainLoop(service: DoppelgangerServiceRef) {.async.} = debug "Service disabled because of configuration settings" return + debug "Doppelganger detection loop is waiting for initialization" + try: + await allFutures( + vc.preGenesisEvent.wait(), + vc.genesisEvent.wait(), + vc.indicesAvailable.wait() + ) + except CancelledError: + debug "Service interrupted" + return + except CatchableError as exc: + warn "Service crashed with unexpected error", err_name = exc.name, + err_msg = exc.msg + return + # On (re)start, we skip the remainder of the epoch before we start monitoring # for doppelgangers so we don't trigger on the attestations we produced before # the epoch - there's no activity in the genesis slot, so if we start at or diff --git a/beacon_chain/validator_client/duties_service.nim b/beacon_chain/validator_client/duties_service.nim index cc4d03669c..6ef11ab678 100644 --- a/beacon_chain/validator_client/duties_service.nim +++ b/beacon_chain/validator_client/duties_service.nim @@ -399,9 +399,9 @@ proc pollForAttesterDuties*(service: DutiesServiceRef) {.async.} = if len(subscriptions) > 0: let res = await vc.prepareBeaconCommitteeSubnet(subscriptions) if res == 0: - error "Failed to subscribe validators to beacon committee subnets", - slot = currentSlot, epoch = currentEpoch, - subscriptions_count = len(subscriptions) + warn "Failed to subscribe validators to beacon committee subnets", + slot = currentSlot, epoch = currentEpoch, + subscriptions_count = len(subscriptions) service.pruneAttesterDuties(currentEpoch) @@ -468,10 +468,10 @@ proc pollForSyncCommitteeDuties*(service: DutiesServiceRef) {.async.} = if len(subscriptions) > 0: let res = await vc.prepareSyncCommitteeSubnets(subscriptions) - if res != 0: - error "Failed to subscribe validators to sync committee subnets", - slot = currentSlot, epoch = currentEpoch, - subscriptions_count = len(subscriptions) + if res == 0: + warn "Failed to subscribe validators to sync committee subnets", + slot = currentSlot, epoch = currentEpoch, + subscriptions_count = len(subscriptions) service.pruneSyncCommitteeDuties(currentSlot) diff --git a/beacon_chain/validator_client/fallback_service.nim b/beacon_chain/validator_client/fallback_service.nim index a347248d25..b64de0ab59 100644 --- a/beacon_chain/validator_client/fallback_service.nim +++ b/beacon_chain/validator_client/fallback_service.nim @@ -34,6 +34,10 @@ proc otherNodes*(vc: ValidatorClientRef): seq[BeaconNodeServerRef] = proc otherNodesCount*(vc: ValidatorClientRef): int = vc.beaconNodes.countIt(it.status != RestBeaconNodeStatus.Synced) +proc preGenesisNodes*(vc: ValidatorClientRef): seq[BeaconNodeServerRef] = + vc.beaconNodes.filterIt(it.status notin {RestBeaconNodeStatus.Synced, + RestBeaconNodeStatus.OptSynced}) + proc waitNodes*(vc: ValidatorClientRef, timeoutFut: Future[void], statuses: set[RestBeaconNodeStatus], roles: set[BeaconNodeRole], waitChanges: bool) {.async.} = @@ -230,7 +234,12 @@ proc checkNode(vc: ValidatorClientRef, proc checkNodes*(service: FallbackServiceRef): Future[bool] {.async.} = let - nodesToCheck = service.client.otherNodes() + vc = service.client + nodesToCheck = + if vc.genesisEvent.isSet(): + service.client.otherNodes() + else: + service.client.preGenesisNodes() pendingChecks = nodesToCheck.mapIt(service.client.checkNode(it)) var res = false try: