Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add vault address check #270

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading