From a9fde1eeb55267be342e5d18582b304bf1d4f46a Mon Sep 17 00:00:00 2001 From: Evgeny Gusarov Date: Mon, 30 Oct 2023 21:22:07 +0300 Subject: [PATCH] Less get_oracles calls --- src/commands/start.py | 10 ++++++---- src/exits/tasks.py | 5 +---- src/validators/tasks.py | 5 ++--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/commands/start.py b/src/commands/start.py index 1aebc5cb..81e95371 100644 --- a/src/commands/start.py +++ b/src/commands/start.py @@ -11,7 +11,7 @@ import src from src.common.clients import consensus_client, execution_client -from src.common.execution import check_hot_wallet_balance +from src.common.execution import check_hot_wallet_balance, get_oracles from src.common.metrics import metrics, metrics_server from src.common.startup_check import startup_checks from src.common.utils import get_build_version, log_verbose @@ -245,7 +245,7 @@ def start( log_verbose(e) -async def main() -> None: +async def main() -> None: # pylint: disable=too-many-statements setup_logging() setup_sentry() log_start() @@ -315,10 +315,13 @@ async def main() -> None: remote_signer_config=remote_signer_config, deposit_data=deposit_data, ) + oracles = await get_oracles() + await register_validators( keystores=keystores, remote_signer_config=remote_signer_config, deposit_data=deposit_data, + oracles=oracles, ) # submit harvest vault transaction @@ -327,8 +330,7 @@ async def main() -> None: # process outdated exit signatures await update_exit_signatures_periodically( - keystores=keystores, - remote_signer_config=remote_signer_config, + keystores=keystores, remote_signer_config=remote_signer_config, oracles=oracles ) # check balance await check_hot_wallet_balance() diff --git a/src/exits/tasks.py b/src/exits/tasks.py index 51c12f5c..0a476e1a 100644 --- a/src/exits/tasks.py +++ b/src/exits/tasks.py @@ -6,7 +6,6 @@ from web3.types import HexStr from src.common.contracts import keeper_contract -from src.common.execution import get_oracles from src.common.metrics import metrics from src.common.typings import Oracles from src.common.utils import get_current_timestamp, is_block_finalized, log_verbose @@ -29,10 +28,8 @@ async def update_exit_signatures_periodically( - keystores: Keystores, - remote_signer_config: RemoteSignerConfiguration | None, + keystores: Keystores, remote_signer_config: RemoteSignerConfiguration | None, oracles: Oracles ) -> None: - oracles = await get_oracles() update_block = await _fetch_last_update_block() if update_block and not await is_block_finalized(update_block): logger.info('Signatures update block %d has not finalized yet', update_block) diff --git a/src/validators/tasks.py b/src/validators/tasks.py index 4ab709d6..7a733eed 100644 --- a/src/validators/tasks.py +++ b/src/validators/tasks.py @@ -9,7 +9,7 @@ from src.common.clients import ipfs_fetch_client from src.common.contracts import validators_registry_contract from src.common.exceptions import NotEnoughOracleApprovalsError -from src.common.execution import check_gas_price, get_oracles +from src.common.execution import check_gas_price from src.common.metrics import metrics from src.common.typings import Oracles from src.common.utils import MGNO_RATE, WAD, get_current_timestamp @@ -46,6 +46,7 @@ async def register_validators( keystores: Keystores, remote_signer_config: RemoteSignerConfiguration | None, deposit_data: DepositData, + oracles: Oracles, ) -> None: """Registers vault validators.""" vault_balance, update_state_call = await get_withdrawable_assets() @@ -55,8 +56,6 @@ async def register_validators( metrics.stakeable_assets.set(int(vault_balance)) - # get latest oracles - oracles = await get_oracles() logger.debug('Fetched latest oracles: %s', oracles) approval_max_validators = oracles.validators_approval_batch_limit