-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: main
Are you sure you want to change the base?
Avoid dlp validator crashes eg if rpc goes down #23
Conversation
volod-vana
commented
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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}") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?