update builder API registrations after keymanager API fee recipient change (#6412)

This commit is contained in:
tersec 2024-07-04 12:08:07 +00:00 committed by GitHub
parent 85c2850971
commit 9f654690b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 5 deletions

View File

@ -1749,8 +1749,10 @@ proc registerValidatorsPerBuilder(
validatorRegistrations.add @[validatorRegistration] validatorRegistrations.add @[validatorRegistration]
# First, check for VC-added keys; cheaper because provided pre-signed # First, check for VC-added keys; cheaper because provided pre-signed
# See issue #5599: currently VC have no way to provide BN with per-validator builders per the specs, so we have to # See issue #5599: currently VC have no way to provide BN with per-validator
# resort to use the BN fallback default (--payload-builder-url value, obtained by calling getPayloadBuilderAddress) # builders per the specs, so we have to resort to use the BN fallback
# default (--payload-builder-url value, obtained by calling
# getPayloadBuilderAddress)
var nonExitedVcPubkeys: HashSet[ValidatorPubKey] var nonExitedVcPubkeys: HashSet[ValidatorPubKey]
if node.externalBuilderRegistrations.len > 0 and if node.externalBuilderRegistrations.len > 0 and
payloadBuilderAddress == node.config.getPayloadBuilderAddress.value: payloadBuilderAddress == node.config.getPayloadBuilderAddress.value:

View File

@ -1481,6 +1481,7 @@ proc removeFeeRecipientFile*(host: KeymanagerHost,
if fileExists(path): if fileExists(path):
io2.removeFile(path).isOkOr: io2.removeFile(path).isOkOr:
return err($uint(error) & " " & ioErrorMsg(error)) return err($uint(error) & " " & ioErrorMsg(error))
host.validatorPool[].invalidateValidatorRegistration(pubkey)
ok() ok()
proc removeGasLimitFile*(host: KeymanagerHost, proc removeGasLimitFile*(host: KeymanagerHost,
@ -1499,15 +1500,22 @@ proc removeGraffitiFile*(host: KeymanagerHost,
return err($uint(error) & " " & ioErrorMsg(error)) return err($uint(error) & " " & ioErrorMsg(error))
ok() ok()
proc setFeeRecipient*(host: KeymanagerHost, pubkey: ValidatorPubKey, feeRecipient: Eth1Address): Result[void, string] = proc setFeeRecipient*(
host: KeymanagerHost, pubkey: ValidatorPubKey, feeRecipient: Eth1Address):
Result[void, string] =
let validatorKeystoreDir = host.validatorKeystoreDir(pubkey) let validatorKeystoreDir = host.validatorKeystoreDir(pubkey)
? secureCreatePath(validatorKeystoreDir).mapErr(proc(e: auto): string = ? secureCreatePath(validatorKeystoreDir).mapErr(proc(e: auto): string =
"Could not create wallet directory [" & validatorKeystoreDir & "]: " & $e) "Could not create wallet directory [" & validatorKeystoreDir & "]: " & $e)
io2.writeFile(validatorKeystoreDir / FeeRecipientFilename, $feeRecipient) let res = io2.writeFile(
validatorKeystoreDir / FeeRecipientFilename, $feeRecipient)
.mapErr(proc(e: auto): string = "Failed to write fee recipient file: " & $e) .mapErr(proc(e: auto): string = "Failed to write fee recipient file: " & $e)
if res.isOk:
host.validatorPool[].invalidateValidatorRegistration(pubkey)
res
proc setGasLimit*(host: KeymanagerHost, proc setGasLimit*(host: KeymanagerHost,
pubkey: ValidatorPubKey, pubkey: ValidatorPubKey,
gasLimit: uint64): Result[void, string] = gasLimit: uint64): Result[void, string] =

View File

@ -288,6 +288,15 @@ proc updateValidator*(pool: var ValidatorPool,
validator.activationEpoch = activationEpoch validator.activationEpoch = activationEpoch
func invalidateValidatorRegistration*(
pool: var ValidatorPool, pubkey: ValidatorPubKey) =
# When the per-validator fee recipient changes via keymanager, the builder
# API validator registration needs to be recomputed. This will happen when
# next the registrations are sent, but ensure here that will happen rather
# than relying on a now-outdated, cached, validator registration.
pool.getValidator(pubkey).isErrOr:
value.externalBuilderRegistration.reset()
proc close*(pool: var ValidatorPool) = proc close*(pool: var ValidatorPool) =
## Unlock and close all validator keystore's files managed by ``pool``. ## Unlock and close all validator keystore's files managed by ``pool``.
for validator in pool.validators.values(): for validator in pool.validators.values():