diff --git a/beacon_chain/validators/beacon_validators.nim b/beacon_chain/validators/beacon_validators.nim index 7c99c28b7..8397b3ba7 100644 --- a/beacon_chain/validators/beacon_validators.nim +++ b/beacon_chain/validators/beacon_validators.nim @@ -1749,8 +1749,10 @@ proc registerValidatorsPerBuilder( validatorRegistrations.add @[validatorRegistration] # 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 - # resort to use the BN fallback default (--payload-builder-url value, obtained by calling getPayloadBuilderAddress) + # See issue #5599: currently VC have no way to provide BN with per-validator + # 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] if node.externalBuilderRegistrations.len > 0 and payloadBuilderAddress == node.config.getPayloadBuilderAddress.value: diff --git a/beacon_chain/validators/keystore_management.nim b/beacon_chain/validators/keystore_management.nim index 243fed9d3..86ca1253d 100644 --- a/beacon_chain/validators/keystore_management.nim +++ b/beacon_chain/validators/keystore_management.nim @@ -1481,6 +1481,7 @@ proc removeFeeRecipientFile*(host: KeymanagerHost, if fileExists(path): io2.removeFile(path).isOkOr: return err($uint(error) & " " & ioErrorMsg(error)) + host.validatorPool[].invalidateValidatorRegistration(pubkey) ok() proc removeGasLimitFile*(host: KeymanagerHost, @@ -1499,15 +1500,22 @@ proc removeGraffitiFile*(host: KeymanagerHost, return err($uint(error) & " " & ioErrorMsg(error)) 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) - ? secureCreatePath(validatorKeystoreDir).mapErr(proc(e: auto): string = "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) + if res.isOk: + host.validatorPool[].invalidateValidatorRegistration(pubkey) + + res + proc setGasLimit*(host: KeymanagerHost, pubkey: ValidatorPubKey, gasLimit: uint64): Result[void, string] = diff --git a/beacon_chain/validators/validator_pool.nim b/beacon_chain/validators/validator_pool.nim index 6d9ccab93..4e035efac 100644 --- a/beacon_chain/validators/validator_pool.nim +++ b/beacon_chain/validators/validator_pool.nim @@ -288,6 +288,15 @@ proc updateValidator*(pool: var ValidatorPool, 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) = ## Unlock and close all validator keystore's files managed by ``pool``. for validator in pool.validators.values():