diff --git a/beacon_chain/rpc/rest_key_management_api.nim b/beacon_chain/rpc/rest_key_management_api.nim index b21c52287..466286428 100644 --- a/beacon_chain/rpc/rest_key_management_api.nim +++ b/beacon_chain/rpc/rest_key_management_api.nim @@ -10,7 +10,7 @@ import chronos, chronicles, confutils, import ".."/spec/[keystore, crypto] import ".."/spec/eth2_apis/rest_keymanager_types import ".."/validators/[slashing_protection, keystore_management, - validator_pool, validator_duties] + validator_pool] import ".."/rpc/rest_utils export rest_utils, results diff --git a/beacon_chain/validators/validator_duties.nim b/beacon_chain/validators/validator_duties.nim index 5e9ec5f28..83c8af5fa 100644 --- a/beacon_chain/validators/validator_duties.nim +++ b/beacon_chain/validators/validator_duties.nim @@ -101,29 +101,6 @@ proc findValidator*(validators: auto, pubkey: ValidatorPubKey): Opt[ValidatorInd else: Opt.some idx.ValidatorIndex -# TODO: This should probably be moved to the validator_pool module -proc addRemoteValidator*(pool: var ValidatorPool, - keystore: KeystoreData, - index: Opt[ValidatorIndex], - feeRecipient: Eth1Address, - slot: Slot) = - var clients: seq[(RestClientRef, RemoteSignerInfo)] - let httpFlags = - block: - var res: set[HttpClientFlag] - if RemoteKeystoreFlag.IgnoreSSLVerification in keystore.flags: - res.incl({HttpClientFlag.NoVerifyHost, - HttpClientFlag.NoVerifyServerName}) - res - let prestoFlags = {RestClientFlag.CommaSeparatedArray} - for remote in keystore.remotes: - let client = RestClientRef.new($remote.url, prestoFlags, httpFlags) - if client.isErr(): - warn "Unable to resolve distributed signer address", - remote_url = $remote.url, validator = $remote.pubkey - clients.add((client.get(), remote)) - pool.addRemoteValidator(keystore, clients, index, feeRecipient, slot) - proc addValidators*(node: BeaconNode) = debug "Loading validators", validatorsDir = node.config.validatorsDir() let slot = node.currentSlot() diff --git a/beacon_chain/validators/validator_pool.nim b/beacon_chain/validators/validator_pool.nim index 2744015dc..2daf1c9b4 100644 --- a/beacon_chain/validators/validator_pool.nim +++ b/beacon_chain/validators/validator_pool.nim @@ -177,6 +177,28 @@ proc close*(pool: var ValidatorPool) = notice "Could not unlock validator's keystore file", pubkey = validator.pubkey, validator = shortLog(validator) +proc addRemoteValidator*(pool: var ValidatorPool, + keystore: KeystoreData, + index: Opt[ValidatorIndex], + feeRecipient: Eth1Address, + slot: Slot) = + var clients: seq[(RestClientRef, RemoteSignerInfo)] + let httpFlags = + block: + var res: set[HttpClientFlag] + if RemoteKeystoreFlag.IgnoreSSLVerification in keystore.flags: + res.incl({HttpClientFlag.NoVerifyHost, + HttpClientFlag.NoVerifyServerName}) + res + let prestoFlags = {RestClientFlag.CommaSeparatedArray} + for remote in keystore.remotes: + let client = RestClientRef.new($remote.url, prestoFlags, httpFlags) + if client.isErr(): + warn "Unable to resolve distributed signer address", + remote_url = $remote.url, validator = $remote.pubkey + clients.add((client.get(), remote)) + pool.addRemoteValidator(keystore, clients, index, feeRecipient, slot) + iterator publicKeys*(pool: ValidatorPool): ValidatorPubKey = for item in pool.validators.keys(): yield item @@ -438,3 +460,4 @@ proc getBuilderSignature*(v: AttachedValidator, fork: Fork, let request = Web3SignerRequest.init( fork, ZERO_HASH, validatorRegistration) await v.signData(request) +