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 startup check for event logs #404

Merged
merged 2 commits into from
Sep 3, 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
17 changes: 16 additions & 1 deletion src/common/startup_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from web3 import Web3

from src.common.clients import db_client
from src.common.contracts import vault_contract
from src.common.contracts import keeper_contract, vault_contract
from src.common.execution import (
check_hot_wallet_balance,
check_vault_address,
Expand Down Expand Up @@ -197,6 +197,9 @@ async def startup_checks() -> None:
logger.info('Checking connection to execution nodes...')
await wait_for_execution_node()

logger.info('Checking oracles config...')
await _check_events_logs()

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

Expand Down Expand Up @@ -257,3 +260,15 @@ async def _check_validators_manager() -> None:
raise RuntimeError(
'validators manager address must equal to deposit data registry address'
)


async def _check_events_logs() -> None:
"""Check that EL client didn't prune logs"""
events = await keeper_contract.events.ConfigUpdated.get_logs( # type: ignore
fromBlock=settings.network_config.CONFIG_UPDATE_EVENT_BLOCK,
toBlock=settings.network_config.CONFIG_UPDATE_EVENT_BLOCK,
)
if not events:
raise ValueError(
"Can't find oracle config. Please, ensure that EL client didn't prune event logs."
)
5 changes: 5 additions & 0 deletions src/config/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class NetworkConfig:
SHARED_MEV_ESCROW_CONTRACT_ADDRESS: ChecksumAddress
STAKEWISE_API_URL: str
RATED_API_URL: str
CONFIG_UPDATE_EVENT_BLOCK: BlockNumber

@property
def SHAPELLA_FORK(self) -> ConsensusFork:
Expand Down Expand Up @@ -107,6 +108,7 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
),
STAKEWISE_API_URL='https://mainnet-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(18470104),
),
HOLESKY: NetworkConfig(
CHAIN_ID=17000,
Expand Down Expand Up @@ -151,6 +153,7 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
),
STAKEWISE_API_URL='https://holesky-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(215397),
),
GNOSIS: NetworkConfig(
CHAIN_ID=100,
Expand Down Expand Up @@ -197,6 +200,7 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
),
STAKEWISE_API_URL='https://gnosis-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(34778569),
),
CHIADO: NetworkConfig(
CHAIN_ID=10200,
Expand Down Expand Up @@ -241,5 +245,6 @@ def IS_SUPPORT_V2_MIGRATION(self) -> bool:
),
STAKEWISE_API_URL='https://chiado-api.stakewise.io/graphql',
RATED_API_URL='https://api.rated.network',
CONFIG_UPDATE_EVENT_BLOCK=BlockNumber(10627606),
),
}
Loading