Add inspect command
This commit is contained in:
parent
d7f2d120dd
commit
e38f1384ef
@ -28,6 +28,11 @@ Apply the latest migrations against the local DB:
|
||||
poetry run exec alembic upgrade head
|
||||
```
|
||||
|
||||
Run inspect on a block
|
||||
```
|
||||
poetry run inspect --block-number 11931270 --rpc 'http://111.11.11.111:8545/'
|
||||
```
|
||||
|
||||
To stop the services (if running in the background, otherwise just ctrl+c)
|
||||
```
|
||||
poetry run stop
|
||||
@ -67,7 +72,7 @@ poetry run stop # shutsdown all services or just ctrl + c if foreground
|
||||
poetry run build # rebuilds containers
|
||||
poetry run attach # enters the mev-inspect container in interactive mode
|
||||
# launches inspection script
|
||||
poetry run inspect -script ... -block_number ... -rpc ...
|
||||
poetry run inspect --block-number 11931270 --rpc 'http://111.11.11.111:8545/'
|
||||
```
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import argparse
|
||||
import json
|
||||
|
||||
import click
|
||||
from web3 import Web3
|
||||
|
||||
from mev_inspect import block
|
||||
@ -10,7 +10,11 @@ from mev_inspect.classifier_specs import CLASSIFIER_SPECS
|
||||
from mev_inspect.trace_classifier import TraceClassifier
|
||||
|
||||
|
||||
def inspect_block(base_provider, block_number):
|
||||
@click.command()
|
||||
@click.argument("block_number", type=int)
|
||||
@click.argument("rpc")
|
||||
def inspect_block(block_number: int, rpc: str):
|
||||
base_provider = Web3.HTTPProvider(rpc)
|
||||
block_data = block.create_from_block_number(block_number, base_provider)
|
||||
print(f"Total traces: {len(block_data.traces)}")
|
||||
|
||||
@ -54,21 +58,4 @@ def get_stats(classified_traces) -> dict:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Inspect some blocks.")
|
||||
|
||||
parser.add_argument(
|
||||
"-block_number",
|
||||
metavar="b",
|
||||
type=int,
|
||||
nargs="+",
|
||||
help="the block number you are targetting, eventually this will need to be changed",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-rpc", metavar="r", help="rpc endpoint, this needs to have parity style traces"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
w3_base_provider = Web3.HTTPProvider(args.rpc)
|
||||
inspect_block(w3_base_provider, args.block_number[0])
|
||||
inspect_block()
|
@ -40,6 +40,7 @@ stop = 'scripts.docker:stop'
|
||||
build = 'scripts.docker:build'
|
||||
attach = 'scripts.docker:attach'
|
||||
exec = 'scripts.docker:exec'
|
||||
inspect = 'scripts.inspect:inspect'
|
||||
|
||||
[tool.black]
|
||||
exclude = '''
|
||||
|
21
scripts/inspect.py
Normal file
21
scripts/inspect.py
Normal file
@ -0,0 +1,21 @@
|
||||
from subprocess import check_call
|
||||
|
||||
import click
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--block-number", type=int, help="the block number you are targetting")
|
||||
@click.option("--rpc", help="rpc endpoint, this needs to have parity style traces")
|
||||
def inspect(block_number: int, rpc: str):
|
||||
check_call(
|
||||
[
|
||||
"docker",
|
||||
"compose",
|
||||
"exec",
|
||||
"mev-inspect",
|
||||
"python",
|
||||
"inspect_block.py",
|
||||
str(block_number),
|
||||
rpc,
|
||||
]
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user