From 54cd815514283ba1a9717c2ebb309fb3c1c9c619 Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Thu, 23 Sep 2021 11:42:21 -0400 Subject: [PATCH 1/5] Update README with install helm and create kind cluster --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index dc42c17..c9d9001 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # mev-inspect-py -> illuminating the dark forest 🌲🔦 +> illuminating the dark forest 🌲💡 **mev-inspect-py** is an MEV inspector for Ethereum @@ -16,9 +16,16 @@ mev-inspect-py is built to run on kubernetes locally and in production ### Install dependencies -1. Setup a local kubernetes deployment (we use [kind](https://kind.sigs.k8s.io/docs/user/quick-start)) +First, setup a local kubernetes deployment - we use [kind](https://kind.sigs.k8s.io/docs/user/quick-start) -2. Setup [Tilt](https://docs.tilt.dev/install.html) which manages the local deployment +If using kind, create a new cluster with: +``` +kind create cluster +``` + +Next, install [helm](https://helm.sh/docs/intro/install/) - helm is a package manager for kubernetes + +Lastly, setup [Tilt](https://docs.tilt.dev/install.html) which manages running and updating kubernetes resources locally ### Start up From 3bba682c587bb2313f3491a717ad5fbbe5c9b41c Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Thu, 23 Sep 2021 11:42:34 -0400 Subject: [PATCH 2/5] Remove platform from Tiltfile --- Tiltfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Tiltfile b/Tiltfile index c90dc93..7233762 100644 --- a/Tiltfile +++ b/Tiltfile @@ -25,7 +25,6 @@ docker_build_with_restart("mev-inspect-py", ".", run("cd /app && poetry install", trigger="./pyproject.toml"), ], - platform="linux/arm64", ) k8s_yaml("k8s/app.yaml") k8s_resource(workload="mev-inspect-deployment", resource_deps=["postgresql-postgresql"]) From e56458c9084d0006278318953dcf06bfd3bd05ec Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Thu, 23 Sep 2021 11:46:33 -0400 Subject: [PATCH 3/5] Add kubectl to README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c9d9001..160e0ce 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ If using kind, create a new cluster with: kind create cluster ``` -Next, install [helm](https://helm.sh/docs/intro/install/) - helm is a package manager for kubernetes +Next, install the kubernetes CLI [`kubectl`](https://kubernetes.io/docs/tasks/tools/) + +Then, install [helm](https://helm.sh/docs/intro/install/) - helm is a package manager for kubernetes Lastly, setup [Tilt](https://docs.tilt.dev/install.html) which manages running and updating kubernetes resources locally From 58a74095689d5eca5aeb22cff89a6d0069e3163b Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Thu, 23 Sep 2021 11:47:21 -0400 Subject: [PATCH 4/5] Add Docker to README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 160e0ce..af1e40c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ mev-inspect-py is built to run on kubernetes locally and in production ### Install dependencies -First, setup a local kubernetes deployment - we use [kind](https://kind.sigs.k8s.io/docs/user/quick-start) +First, setup a local kubernetes deployment - we use [Docker](https://www.docker.com/products/docker-desktop) and [kind](https://kind.sigs.k8s.io/docs/user/quick-start) If using kind, create a new cluster with: ``` From f2ce697175a9fe5717261254b08ddf4055c58eaa Mon Sep 17 00:00:00 2001 From: Luke Van Seters Date: Thu, 23 Sep 2021 12:04:27 -0400 Subject: [PATCH 5/5] Add instructions on connecting to Postgres --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/README.md b/README.md index af1e40c..27beabc 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,38 @@ And stop the listener with kubectl exec deploy/mev-inspect-deployment -- /app/listener stop ``` +## Exploring + +All inspect output data is stored in Postgres. + +To connect to the local Postgres database for querying, launch a client container with: +``` +kubectl run -i --rm --tty postgres-client --env="PGPASSWORD=password" --image=jbergknoff/postgresql-client -- mev_inspect --host=postgresql --user=postgres +``` + +When you see the prompt +``` +mev_inspect=# +``` + +You're ready to query! + +Try finding the total number of swaps decoded with UniswapV3Pool +``` +SELECT COUNT(*) FROM swaps WHERE abi_name='UniswapV3Pool'; +``` + +or top 10 arbs by gross profit that took profit in WETH +``` +SELECT * +FROM arbitrages +WHERE profit_token_address = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' +ORDER BY profit_amount DESC +LIMIT 10; +``` + +Postgres tip: Enter `\x` to enter "Explanded display" mode which looks nicer for results with many columns + ## Contributing ### Guide @@ -150,3 +182,13 @@ docker compose down ``` Then go through the steps in the current README for kube setup + +### Error from server (AlreadyExists): pods "postgres-client" already exists +This means the postgres client container didn't shut down correctly + +Delete this one with +``` +kubectl delete pod/postgres-client +``` + +Then start it back up again