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

Avoid dlp validator crashes eg if rpc goes down #23

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

volod-vana
Copy link
Member

image

@volod-vana volod-vana self-assigned this Jul 11, 2024
@@ -252,13 +275,21 @@ def get_current_block(self) -> int:
Knowing the current block number is essential for querying real-time data and performing time-sensitive
operations on the blockchain. It serves as a reference point for network activities and data synchronization.
"""
return self.web3.eth.block_number
return self.circuit_breaker.call(self._get_current_block)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be used at a higher level, e.g. where the server is spawned?

@@ -84,6 +84,27 @@ def __init__(
if sync:
self.sync(block=None, lite=lite)

self.cache_file = f"state_cache_{network}_{dlp_uid}.json"

def save_cache(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between the cache and the state file? Seems to be saving the same data?

def check_rpc_health(self):
try:
block_number = self.get_current_block()
vana.logging.info(f"RPC is healthy. Current block number: {block_number}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this, I feel this may get too noisy in the logs.

@@ -252,13 +275,21 @@ def get_current_block(self) -> int:
Knowing the current block number is essential for querying real-time data and performing time-sensitive
operations on the blockchain. It serves as a reference point for network activities and data synchronization.
"""
return self.web3.eth.block_number
return self.circuit_breaker.call(self._get_current_block)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably misunderstanding, but does the circuit breaker give us anything additional that the @Retry doesn't?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants