Skip to content

Commit

Permalink
Fix doppelganger detection should not start at pre-genesis time.
Browse files Browse the repository at this point in the history
Fix fallback service sync status spam.
Fix false `sync committee subnets subscription error`.
  • Loading branch information
cheatfate committed Mar 23, 2023
1 parent a7bd004 commit 4aa110b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
15 changes: 15 additions & 0 deletions beacon_chain/validator_client/doppelganger_service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions beacon_chain/validator_client/duties_service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down
11 changes: 10 additions & 1 deletion beacon_chain/validator_client/fallback_service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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.} =
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4aa110b

Please sign in to comment.