archive rpc bugfix; alert touchup
This commit is contained in:
@@ -5,3 +5,4 @@ redis_url = ''
|
|||||||
ohlc_dir = '/ohlc'
|
ohlc_dir = '/ohlc'
|
||||||
walker_flush_interval=25
|
walker_flush_interval=25
|
||||||
concurrent_rpc_connections=9999
|
concurrent_rpc_connections=9999
|
||||||
|
pagerduty='' # disable
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ log = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def alert(title, message, dedup_key=NARG, log_level=logging.ERROR, do_log=True):
|
def alert(title, message, dedup_key=NARG, log_level=logging.ERROR, do_log=True):
|
||||||
if dedup_key is NARG:
|
if dedup_key is NARG:
|
||||||
dedup_key = str(hash(title + '|' + message))
|
dedup_key = str(hash(title))
|
||||||
if do_log:
|
if do_log:
|
||||||
msg = f'{title}: {message}'
|
msg = f'{title}: {message}'
|
||||||
log.log(log_level, msg) # if log_level=CRITICAL for example, make sure this does not re-alert!
|
log.log(log_level, msg) # if log_level=CRITICAL for example, make sure this does not re-alert!
|
||||||
|
|||||||
@@ -186,6 +186,7 @@ def _make_contract(w3_eth):
|
|||||||
|
|
||||||
# Define methods that may carry a `block_identifier` parameter,
|
# Define methods that may carry a `block_identifier` parameter,
|
||||||
# along with the required number of arguments to include it.
|
# along with the required number of arguments to include it.
|
||||||
|
|
||||||
ARCHIVE_METHODS = {
|
ARCHIVE_METHODS = {
|
||||||
# Examples:
|
# Examples:
|
||||||
"eth_getBalance": 2, # e.g., get_balance(address, block_identifier)
|
"eth_getBalance": 2, # e.g., get_balance(address, block_identifier)
|
||||||
@@ -195,7 +196,7 @@ ARCHIVE_METHODS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ARCHIVE_ERRORS = {
|
ARCHIVE_ERRORS = {
|
||||||
-32000,
|
'state recreation l2 gas depth limit exceeded',
|
||||||
}
|
}
|
||||||
|
|
||||||
async def archive_intercept_middleware(make_request, w3):
|
async def archive_intercept_middleware(make_request, w3):
|
||||||
@@ -210,22 +211,21 @@ async def archive_intercept_middleware(make_request, w3):
|
|||||||
if is_archive_method:
|
if is_archive_method:
|
||||||
block_identifier = params[-1]
|
block_identifier = params[-1]
|
||||||
if block_identifier != 'latest':
|
if block_identifier != 'latest':
|
||||||
block_identifier = int(block_identifier, 16) if type(block_identifier) is str else int(params[-1])
|
block_height = int(block_identifier, 16) if type(block_identifier) is str else int(params[-1])
|
||||||
if block_identifier <= w3.archive_fault_height:
|
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
|
# 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)
|
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:
|
if block_height is None:
|
||||||
# noinspection PyUnboundLocalVariable
|
# 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
|
# noinspection PyTypeChecker
|
||||||
w3.archive_fault_height = max(w3.archive_fault_height, block_height)
|
w3.archive_fault_height = max(w3.archive_fault_height, block_height)
|
||||||
raise ArchiveException(method, block_height)
|
raise ArchiveException(method, block_height)
|
||||||
resp = await make_request(method, params)
|
resp = await make_request(method, params)
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
|
|
||||||
return middleware
|
return middleware
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user