don't register exited validators with builder API (#3985)

This commit is contained in:
tersec 2022-08-18 11:59:35 +00:00 committed by GitHub
parent c0f673dc09
commit c0668367de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -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: