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 chain id startup check #417

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Changes from 1 commit
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
36 changes: 35 additions & 1 deletion src/common/startup_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ async def collect_healthy_oracles() -> list:
for replicas in endpoints
for endpoint in replicas
],
return_exceptions=True
evgeny-stakewise marked this conversation as resolved.
Show resolved Hide resolved
return_exceptions=True,
)

healthy_oracles = []
Expand Down Expand Up @@ -197,6 +197,12 @@ async def startup_checks() -> None:
logger.info('Checking connection to execution nodes...')
await wait_for_execution_node()

logger.info('Checking consensus node chain id...')
await _check_consensus_chain_id()

logger.info('Checking execution node chain id...')
await _check_execution_chain_id()

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

Expand Down Expand Up @@ -249,6 +255,34 @@ async def startup_checks() -> None:
await _check_validators_manager()


async def _check_consensus_chain_id() -> None:
for consensus_endpoint in settings.consensus_endpoints:
consensus_client = get_consensus_client([consensus_endpoint])
deposit_contract_data = (await consensus_client.get_deposit_contract())['data']
consensus_chain_id = int(deposit_contract_data['chain_id'])
if settings.network_config.CHAIN_ID != consensus_chain_id:
raise ValueError(
f'Consensus node chain id is {consensus_chain_id}, '
f'does not match {settings.network_config.CHAIN_ID} '
f'({settings.network})'
)


async def _check_execution_chain_id() -> None:
for execution_endpoint in settings.execution_endpoints:
execution_client = get_execution_client(
[execution_endpoint],
jwt_secret=settings.execution_jwt_secret,
)
execution_chain_id = await execution_client.eth.chain_id
if settings.network_config.CHAIN_ID != execution_chain_id:
raise ValueError(
f'Execution node chain id is {execution_chain_id}, '
f'does not match {settings.network_config.CHAIN_ID} '
f'({settings.network})'
)


async def _aiohttp_fetch(session: ClientSession, url: str) -> str:
async with session.get(url=url) as response:
response.raise_for_status()
Expand Down
Loading