From fea05e16c7e597dfa327a6206abbe4ec4feba5b7 Mon Sep 17 00:00:00 2001 From: Robert Miller Date: Mon, 5 Jul 2021 20:52:28 -0400 Subject: [PATCH 1/3] Create README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec3b964 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# mev-inspect-py +MEV-inspect-py is a script which "inspects" an Ethereum block, or range of blocks, and tries to identify and analyze transactions which extract MEV. For example, it will identify and quantify arbitrage trades which capture profit from mispricing across two DEXes in a single transaction. + +MEV-inspect-py is currently a work in progress that builds on the work done in [MEV-inspect-rs](https://github.com/flashbots/mev-inspect-rs). In the coming weeks we will release a foundation from which contributors can add new inspectors. From 7f26c600dc790ac6923a458f5e64c015c1856df4 Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Wed, 28 Jul 2021 21:03:33 -0700 Subject: [PATCH 2/3] moved all scripts to ./scripts and added some arg shorthands --- README.md | 10 ++++---- pyproject.toml | 24 +++++++++---------- scripts/inspect.py | 21 ---------------- inspect_block.py => scripts/inspect_block.py | 0 scripts/{ => poetry}/dev_tools.py | 0 scripts/{ => poetry}/docker.py | 8 +++---- scripts/poetry/inspect.py | 25 ++++++++++++++++++++ 7 files changed, 46 insertions(+), 42 deletions(-) delete mode 100644 scripts/inspect.py rename inspect_block.py => scripts/inspect_block.py (100%) rename scripts/{ => poetry}/dev_tools.py (100%) rename scripts/{ => poetry}/docker.py (82%) create mode 100644 scripts/poetry/inspect.py diff --git a/README.md b/README.md index f8c7ec6..fcd3c35 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Install dependencies through poetry poetry install ``` -Start the services (optionally as background processes) +Start the services (optionally as daemon ``` -poetry run start [-b] +poetry run start [-d] ``` Apply the latest migrations against the local DB: @@ -30,7 +30,7 @@ poetry run exec alembic upgrade head Run inspect on a block ``` -poetry run inspect --block-number 11931270 --rpc 'http://111.11.11.111:8545/' +poetry run inspect -b/--block-number 11931270 -r/--rpc 'http://111.11.11.111:8545/' ``` To stop the services (if running in the background, otherwise just ctrl+c) @@ -67,12 +67,12 @@ poetry run mypy # type checking poetry run black # style guide poetry run pre-commit run --all-files # runs Black, PyLint and MyPy # docker management -poetry run start [-b] # starts all services, optionally in the background +poetry run start [-d] # starts all services, optionally as a daemon 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 --block-number 11931270 --rpc 'http://111.11.11.111:8545/' +poetry run inspect -b/--block-number 11931270 -r/--rpc 'http://111.11.11.111:8545/' ``` diff --git a/pyproject.toml b/pyproject.toml index 76a07dd..47e514f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,18 +29,18 @@ requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" [tool.poetry.scripts] -lint = 'scripts.dev_tools:lint' -test = 'scripts.dev_tools:test' -isort = 'scripts.dev_tools:isort' -mypy = 'scripts.dev_tools:mypy' -black = 'scripts.dev_tools:black' -pre_commit = 'scripts.dev_tools:pre_commit' -start = 'scripts.docker:start' -stop = 'scripts.docker:stop' -build = 'scripts.docker:build' -attach = 'scripts.docker:attach' -exec = 'scripts.docker:exec' -inspect = 'scripts.inspect:inspect' +lint = 'scripts.poetry.dev_tools:lint' +test = 'scripts.poetry.dev_tools:test' +isort = 'scripts.poetry.dev_tools:isort' +mypy = 'scripts.poetry.dev_tools:mypy' +black = 'scripts.poetry.dev_tools:black' +pre_commit = 'scripts.poetry.dev_tools:pre_commit' +start = 'scripts.poetry.docker:start' +stop = 'scripts.poetry.docker:stop' +build = 'scripts.poetry.docker:build' +attach = 'scripts.poetry.docker:attach' +exec = 'scripts.poetry.docker:exec' +inspect = 'scripts.poetry.inspect:inspect' [tool.black] exclude = ''' diff --git a/scripts/inspect.py b/scripts/inspect.py deleted file mode 100644 index fc36014..0000000 --- a/scripts/inspect.py +++ /dev/null @@ -1,21 +0,0 @@ -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, - ] - ) diff --git a/inspect_block.py b/scripts/inspect_block.py similarity index 100% rename from inspect_block.py rename to scripts/inspect_block.py diff --git a/scripts/dev_tools.py b/scripts/poetry/dev_tools.py similarity index 100% rename from scripts/dev_tools.py rename to scripts/poetry/dev_tools.py diff --git a/scripts/docker.py b/scripts/poetry/docker.py similarity index 82% rename from scripts/docker.py rename to scripts/poetry/docker.py index e034c33..fc8ba02 100644 --- a/scripts/docker.py +++ b/scripts/poetry/docker.py @@ -5,10 +5,10 @@ import click @click.command() -@click.option("-b", required=False, is_flag=True) -def start(b: str): - """if d is present background compose""" - if b: +@click.option("-d", required=False, is_flag=True) +def start(d: str): + """if d is present, run docker compose as daemon""" + if d: check_call(["docker", "compose", "up", "-d"]) click.echo("docker running in the background...") else: diff --git a/scripts/poetry/inspect.py b/scripts/poetry/inspect.py new file mode 100644 index 0000000..1128925 --- /dev/null +++ b/scripts/poetry/inspect.py @@ -0,0 +1,25 @@ +from subprocess import check_call + +import click + + +@click.command() +@click.option( + "-b", "--block-number", type=str, help="the block number you are targetting" +) +@click.option( + "-r", "--rpc", help="rpc endpoint, this needs to have parity style traces" +) +def inspect(block_number: str, rpc: str): + check_call( + [ + "docker", + "compose", + "exec", + "mev-inspect", + "python", + "./scripts/inspect_block.py", + block_number, + rpc, + ] + ) From 598c2bf313e6642d28524a99a3322f6628656cee Mon Sep 17 00:00:00 2001 From: Patrick Daly Date: Thu, 29 Jul 2021 06:09:17 -0700 Subject: [PATCH 3/3] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fcd3c35..bcad8ca 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Install dependencies through poetry poetry install ``` -Start the services (optionally as daemon +Start the services (optionally as daemon) ``` poetry run start [-d] ```