Skip to content

Commit

Permalink
Add remote_signer_public_keys_url
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Sep 4, 2024
1 parent c6f0b72 commit d33ba14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Settings(metaclass=Singleton):
keystores_password_dir: Path
keystores_password_file: Path
remote_signer_url: str | None
remote_signer_public_keys_url: str | None
dappnode: bool = False
hashi_vault_key_paths: list[str] | None
hashi_vault_url: str | None
Expand Down Expand Up @@ -163,6 +164,9 @@ def set(

# remote signer configuration
self.remote_signer_url = remote_signer_url
self.remote_signer_public_keys_url: str = decouple_config(
'REMOTE_SIGNER_PUBLIC_KEYS_URL', default=None
)
self.dappnode = dappnode

# hashi vault configuration
Expand Down
12 changes: 10 additions & 2 deletions src/validators/keystores/remote.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import dataclasses
import logging
from dataclasses import dataclass
from typing import cast
from urllib.parse import urljoin

import milagro_bls_binding as bls
from aiohttp import ClientSession, ClientTimeout
Expand Down Expand Up @@ -85,7 +87,11 @@ async def get_exit_signature(

@staticmethod
async def _get_remote_signer_public_keys() -> list[HexStr]:
signer_url = f'{settings.remote_signer_url}/api/v1/eth2/publicKeys'
signer_base_url = cast(
str, settings.remote_signer_public_keys_url or settings.remote_signer_url
)

signer_url = urljoin(signer_base_url, '/api/v1/eth2/publicKeys')
async with ClientSession(timeout=ClientTimeout(REMOTE_SIGNER_TIMEOUT)) as session:
response = await session.get(signer_url)

Expand Down Expand Up @@ -115,7 +121,9 @@ async def _sign_exit_request(
voluntary_exit=VoluntaryExitMessage(epoch=fork.epoch, validator_index=validator_index),
)

signer_url = f'{settings.remote_signer_url}/api/v1/eth2/sign/0x{public_key.hex()}'
signer_base_url = cast(str, settings.remote_signer_url)
signer_url = urljoin(signer_base_url, f'/api/v1/eth2/sign/0x{public_key.hex()}')

async with ClientSession(timeout=ClientTimeout(REMOTE_SIGNER_TIMEOUT)) as session:
response = await session.post(signer_url, json=dataclasses.asdict(data))

Expand Down

0 comments on commit d33ba14

Please sign in to comment.