Skip to content

Commit

Permalink
Review fixes, fix timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Feb 6, 2024
1 parent 833fd75 commit 2230a76
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
19 changes: 12 additions & 7 deletions src/commands/remote_signer_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from src.common.utils import chunkify, log_verbose
from src.common.validators import validate_eth_address
from src.common.vault_config import VaultConfig
from src.config.settings import REMOTE_SIGNER_TIMEOUT, settings
from src.config.settings import (
REMOTE_SIGNER_TIMEOUT,
REMOTE_SIGNER_UPLOAD_CHUNK_SIZE,
settings,
)
from src.validators.keystores.local import LocalKeystore

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -141,7 +145,8 @@ async def main() -> None:
keystores_json.append(f.read())

# Import keystores to remote signer
chunk_size = 10
chunk_size = REMOTE_SIGNER_UPLOAD_CHUNK_SIZE

async with aiohttp.ClientSession(timeout=ClientTimeout(REMOTE_SIGNER_TIMEOUT)) as session:
for keystores_json_chunk, keystore_files_chunk in zip(
chunkify(keystores_json, chunk_size), chunkify(keystore_files, chunk_size)
Expand All @@ -163,12 +168,12 @@ async def main() -> None:
f'Successfully imported {len(keystore_files)} keys into remote signer.',
)

# Remove local keystores - keys are loaded in remote signer and are not
# needed locally anymore
for keystore_file in keystore_files:
os.remove(settings.keystores_dir / keystore_file.name)
# Keys are loaded in remote signer and are not needed locally anymore
if click.confirm('Remove local keystores?'):
for keystore_file in keystore_files:
os.remove(settings.keystores_dir / keystore_file.name)

click.echo('Removed keystores from local filesystem.')
click.echo('Removed keystores from local filesystem.')

click.echo(
f'Done.'
Expand Down
7 changes: 5 additions & 2 deletions src/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,11 @@ def is_genesis_vault(self) -> bool:
# Backoff retries
DEFAULT_RETRY_TIME = 60

# Remote signer timeout
REMOTE_SIGNER_TIMEOUT = 10
# Remote signer
REMOTE_SIGNER_UPLOAD_CHUNK_SIZE = decouple_config(
'REMOTE_SIGNER_UPLOAD_CHUNK_SIZE', cast=int, default=5
)
REMOTE_SIGNER_TIMEOUT = decouple_config('REMOTE_SIGNER_TIMEOUT', cast=int, default=10)

# Hashi vault timeout
HASHI_VAULT_TIMEOUT = 10
Expand Down
5 changes: 1 addition & 4 deletions src/validators/signing/key_shares.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
)
from py_ecc.bls.hash_to_curve import hash_to_G2
from py_ecc.optimized_bls12_381.optimized_curve import (
G1 as P1, # don't mess group name (G1) and primitive element name (P1)
G1 as P1, # don't confuse group name (G1) with primitive element name (P1)
)
from py_ecc.optimized_bls12_381.optimized_curve import (
Z1,
Expand Down Expand Up @@ -110,9 +110,6 @@ def bls_signature_and_public_key_to_shares(
The function splits `signature` and `public_key` to shares so that
each signature share can be verified with corresponding public key share.
The most straight forward way to do this is to use private key shares.
But this function does not require private key.
"""
message_g2 = hash_to_G2(message, G2ProofOfPossession.DST, G2ProofOfPossession.xmd_hash_function)

Expand Down

0 comments on commit 2230a76

Please sign in to comment.