From c0668367de2825b8a4e44f4ce91dfc8406d1c4e6 Mon Sep 17 00:00:00 2001 From: tersec Date: Thu, 18 Aug 2022 11:59:35 +0000 Subject: [PATCH] don't register exited validators with builder API (#3985) --- beacon_chain/validators/validator_duties.nim | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/beacon_chain/validators/validator_duties.nim b/beacon_chain/validators/validator_duties.nim index d63ade480..d0f8b595c 100644 --- a/beacon_chain/validators/validator_duties.nim +++ b/beacon_chain/validators/validator_duties.nim @@ -1212,16 +1212,29 @@ proc registerValidators(node: BeaconNode) {.async.} = let restBuilderStatus = await node.payloadBuilderRestClient.checkBuilderStatus if restBuilderStatus.status != HttpOk: - warn "registerValidators: specified builder not available", + warn "registerValidators: specified builder or relay not available", builderUrl = node.config.payloadBuilderUrl, builderStatus = restBuilderStatus return - # TODO split this across slots of epoch to support larger numbers of - # validators + # TODO cache the generated registrations and keep resending the previous ones # https://github.com/ethereum/builder-specs/blob/v0.2.0/specs/validator.md#validator-registration var validatorRegistrations: seq[SignedValidatorRegistrationV1] for validator in node.attachedValidators[].validators.values: + if validator.index.isNone: + continue + + # https://ethereum.github.io/builder-specs/#/Builder/registerValidator + # Builders should verify that `pubkey` corresponds to an active or + # pending validator + withState(node.dag.headState): + if distinctBase(validator.index.get) >= state.data.validators.lenu64: + continue + + if node.currentSlot().epoch >= + state.data.validators.item(validator.index.get).exit_epoch: + continue + let validatorRegistration = await node.getValidatorRegistration(validator) if validatorRegistration.isErr: