Skip to content

Commit

Permalink
Add vault address check (#270)
Browse files Browse the repository at this point in the history
Signed-off-by: cyc60 <[email protected]>
  • Loading branch information
cyc60 authored Jan 18, 2024
1 parent caec831 commit 69a7a47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/common/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import statistics
from typing import cast

import click
from eth_typing import BlockNumber
from web3 import Web3
from web3.exceptions import MethodUnavailable
from web3.exceptions import BadFunctionCallOutput, MethodUnavailable
from web3.types import BlockIdentifier, Wei

from src.common.clients import execution_client, ipfs_fetch_client
from src.common.contracts import keeper_contract, multicall_contract
from src.common.contracts import keeper_contract, multicall_contract, vault_contract
from src.common.metrics import metrics
from src.common.tasks import BaseTask
from src.common.typings import Oracles, OraclesCache
Expand All @@ -24,6 +25,13 @@ async def get_hot_wallet_balance() -> Wei:
return await execution_client.eth.get_balance(hot_wallet.address)


async def check_vault_address() -> None:
try:
await vault_contract.get_validators_root()
except BadFunctionCallOutput as e:
raise click.ClickException('Invalid vault contract address') from e


async def check_hot_wallet_balance() -> None:
hot_wallet_min_balance = settings.network_config.HOT_WALLET_MIN_BALANCE
symbol = settings.network_config.SYMBOL
Expand Down
9 changes: 8 additions & 1 deletion src/common/startup_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
from sw_utils import IpfsFetchClient, get_consensus_client, get_execution_client

from src.common.clients import db_client
from src.common.execution import check_hot_wallet_balance, get_oracles
from src.common.execution import (
check_hot_wallet_balance,
check_vault_address,
get_oracles,
)
from src.common.utils import format_error, warning_verbose
from src.common.wallet import hot_wallet
from src.config.settings import settings
Expand Down Expand Up @@ -183,6 +187,9 @@ async def startup_checks():
logger.info('Checking connection to execution nodes...')
await wait_for_execution_node()

logger.info('Checking vault address %s...', settings.vault)
await check_vault_address()

logger.info('Checking hot wallet balance %s...', hot_wallet.address)
await check_hot_wallet_balance()

Expand Down

0 comments on commit 69a7a47

Please sign in to comment.