Used black and pylint to reformat
This commit is contained in:
parent
4b660e96a7
commit
19c80bd963
2
cli.py
2
cli.py
@ -21,7 +21,6 @@ from mev_inspect.queue.tasks import (
|
||||
)
|
||||
from mev_inspect.s3_export import export_block
|
||||
from mev_inspect.utils import RPCType
|
||||
#from mev_inspect.prices import fetch_all_supported_prices
|
||||
|
||||
RPC_URL_ENV = "RPC_URL"
|
||||
|
||||
@ -56,6 +55,7 @@ async def inspect_block_command(block_number: int, rpc: str, type: str):
|
||||
block=block_number,
|
||||
)
|
||||
|
||||
|
||||
def convert_str_to_enum(type: str) -> RPCType:
|
||||
if type == "parity":
|
||||
return RPCType.parity
|
||||
|
@ -2,7 +2,6 @@ import asyncio
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
import dramatiq
|
||||
from aiohttp_retry import ExponentialRetry, RetryClient
|
||||
@ -31,6 +30,7 @@ logger = logging.getLogger(__name__)
|
||||
# lag to make sure the blocks we see are settled
|
||||
BLOCK_NUMBER_LAG = 5
|
||||
|
||||
|
||||
def convert_str_to_enum(type: str) -> RPCType:
|
||||
if type == "parity":
|
||||
return RPCType.parity
|
||||
@ -38,6 +38,7 @@ def convert_str_to_enum(type: str) -> RPCType:
|
||||
return RPCType.geth
|
||||
raise ValueError
|
||||
|
||||
|
||||
@coro
|
||||
async def run():
|
||||
rpc = os.getenv("RPC_URL")
|
||||
@ -60,7 +61,7 @@ async def run():
|
||||
queue_name=HIGH_PRIORITY_QUEUE,
|
||||
priority=HIGH_PRIORITY,
|
||||
)
|
||||
|
||||
|
||||
type_e = convert_str_to_enum(sys.argv[1])
|
||||
inspector = MEVInspector(rpc, type_e)
|
||||
base_provider = get_base_provider(rpc)
|
||||
@ -134,4 +135,3 @@ if __name__ == "__main__":
|
||||
run()
|
||||
except Exception as e:
|
||||
logger.error(e)
|
||||
|
||||
|
@ -37,7 +37,7 @@ async def create_from_block_number(
|
||||
block_number: int,
|
||||
trace_db_session: Optional[orm.Session],
|
||||
) -> Block:
|
||||
|
||||
|
||||
if type == RPCType.geth:
|
||||
block_json = await w3.eth.get_block(block_number)
|
||||
else:
|
||||
@ -45,12 +45,20 @@ async def create_from_block_number(
|
||||
|
||||
block_timestamp, receipts, traces, base_fee_per_gas = await asyncio.gather(
|
||||
_find_or_fetch_block_timestamp(w3, block_number, trace_db_session),
|
||||
_find_or_fetch_block_receipts(w3, block_number, trace_db_session, type, block_json),
|
||||
_find_or_fetch_block_traces(w3, block_number, trace_db_session, type, block_json),
|
||||
_find_or_fetch_block_receipts(
|
||||
w3, block_number, trace_db_session, type, block_json
|
||||
),
|
||||
_find_or_fetch_block_traces(
|
||||
w3, block_number, trace_db_session, type, block_json
|
||||
),
|
||||
_find_or_fetch_base_fee_per_gas(w3, block_number, trace_db_session),
|
||||
)
|
||||
|
||||
miner_address = _get_miner_address_from_traces(traces) if type == RPCType.parity else block_json.miner
|
||||
|
||||
miner_address = (
|
||||
_get_miner_address_from_traces(traces)
|
||||
if type == RPCType.parity
|
||||
else block_json.miner
|
||||
)
|
||||
|
||||
return Block(
|
||||
block_number=block_number,
|
||||
@ -71,8 +79,8 @@ async def _find_or_fetch_block_timestamp(
|
||||
existing_block_timestamp = _find_block_timestamp(trace_db_session, block_number)
|
||||
if existing_block_timestamp is not None:
|
||||
return existing_block_timestamp
|
||||
|
||||
return await _fetch_block_timestamp(w3, block_number)
|
||||
|
||||
return await _fetch_block_timestamp(w3, block_number)
|
||||
|
||||
|
||||
async def _find_or_fetch_block_receipts(
|
||||
@ -80,7 +88,7 @@ async def _find_or_fetch_block_receipts(
|
||||
block_number: int,
|
||||
trace_db_session: Optional[orm.Session],
|
||||
type: RPCType,
|
||||
block_json: dict
|
||||
block_json: dict,
|
||||
) -> List[Receipt]:
|
||||
if trace_db_session is not None:
|
||||
existing_block_receipts = _find_block_receipts(trace_db_session, block_number)
|
||||
@ -102,13 +110,13 @@ async def _find_or_fetch_block_traces(
|
||||
block_number: int,
|
||||
trace_db_session: Optional[orm.Session],
|
||||
type: RPCType,
|
||||
block_json: dict
|
||||
block_json: dict,
|
||||
) -> List[Trace]:
|
||||
if trace_db_session is not None:
|
||||
existing_block_traces = _find_block_traces(trace_db_session, block_number)
|
||||
if existing_block_traces is not None:
|
||||
return existing_block_traces
|
||||
|
||||
|
||||
if type == RPCType.geth:
|
||||
# Translate to parity format
|
||||
traces = await geth_get_tx_traces_parity_format(w3.provider, block_json)
|
||||
@ -290,7 +298,6 @@ def unwrap_tx_trace_for_parity(
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
breakpoint()
|
||||
logger.warn(f"error while unwraping tx trace for parity {e}")
|
||||
return []
|
||||
|
||||
|
@ -110,7 +110,7 @@ async def inspect_many_blocks(
|
||||
w3=w3,
|
||||
block_number=block_number,
|
||||
trace_db_session=trace_db_session,
|
||||
type=type
|
||||
type=type,
|
||||
)
|
||||
|
||||
logger.info(f"Block: {block_number} -- Total traces: {len(block.traces)}")
|
||||
|
Loading…
x
Reference in New Issue
Block a user