Skip to content

Commit

Permalink
Add startup check for event logs (#404)
Browse files Browse the repository at this point in the history
* Add startup check for event logs

Signed-off-by: cyc60 <avsysoev60@gmail.com>

* Use fixed block numbers

Signed-off-by: cyc60 <avsysoev60@gmail.com>

---------

Signed-off-by: cyc60 <avsysoev60@gmail.com>
  • Loading branch information
cyc60 authored Sep 3, 2024
1 parent dcdf95a commit c6f0b72
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
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),
),
}

0 comments on commit c6f0b72

Please sign in to comment.