archive rpc bugfix; alert touchup

This commit is contained in:
tim
2025-02-11 15:28:12 -04:00
parent 90d6440c5a
commit adba28db32
3 changed files with 9 additions and 8 deletions

View File

@@ -5,3 +5,4 @@ redis_url = ''
ohlc_dir = '/ohlc'
walker_flush_interval=25
concurrent_rpc_connections=9999
pagerduty='' # disable

View File

@@ -10,7 +10,7 @@ log = logging.getLogger(__name__)
def alert(title, message, dedup_key=NARG, log_level=logging.ERROR, do_log=True):
if dedup_key is NARG:
dedup_key = str(hash(title + '|' + message))
dedup_key = str(hash(title))
if do_log:
msg = f'{title}: {message}'
log.log(log_level, msg) # if log_level=CRITICAL for example, make sure this does not re-alert!

View File

@@ -186,6 +186,7 @@ def _make_contract(w3_eth):
# Define methods that may carry a `block_identifier` parameter,
# along with the required number of arguments to include it.
ARCHIVE_METHODS = {
# Examples:
"eth_getBalance": 2, # e.g., get_balance(address, block_identifier)
@@ -195,7 +196,7 @@ ARCHIVE_METHODS = {
}
ARCHIVE_ERRORS = {
-32000,
'state recreation l2 gas depth limit exceeded',
}
async def archive_intercept_middleware(make_request, w3):
@@ -210,22 +211,21 @@ async def archive_intercept_middleware(make_request, w3):
if is_archive_method:
block_identifier = params[-1]
if block_identifier != 'latest':
block_identifier = int(block_identifier, 16) if type(block_identifier) is str else int(params[-1])
if block_identifier <= w3.archive_fault_height:
block_height = int(block_identifier, 16) if type(block_identifier) is str else int(params[-1])
if block_height <= w3.archive_fault_height:
# this block is at least as old as another block that already failed to fetch history from this RPC
raise ArchiveException(method, block_identifier)
raise ArchiveException(method, block_height)
resp = await make_request(method, params)
if is_archive_method and 'error' in resp and resp['error']['code'] in ARCHIVE_ERRORS:
if is_archive_method and 'error' in resp and resp['error']['message'] in ARCHIVE_ERRORS:
if block_height is None:
# noinspection PyUnboundLocalVariable
raise Exception(f'Got an archive fault using a block_identifier of {block_identifier}')
raise Exception(f'Got an archive fault using a block_identifier of {block_identifier}: {w3.provider.endpoint_uri} {method} {params}\n{resp}')
# noinspection PyTypeChecker
w3.archive_fault_height = max(w3.archive_fault_height, block_height)
raise ArchiveException(method, block_height)
resp = await make_request(method, params)
return resp
return middleware