Skip to content

Commit

Permalink
Less get_oracles calls
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeny-stakewise committed Oct 30, 2023
1 parent 6125b11 commit a9fde1e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/commands/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions src/exits/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions src/validators/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit a9fde1e

Please sign in to comment.