Skip to content

Commit

Permalink
Merge pull request #100 from ethpandaops/adding-mev-relay
Browse files Browse the repository at this point in the history
Adding mev-relay, mev-flood, mev-boost
  • Loading branch information
parithosh authored Oct 17, 2023
2 parents 9f2ff01 + 4083194 commit 9fe7893
Show file tree
Hide file tree
Showing 14 changed files with 449 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ A collection of reusable ansible components used by the EthPandaOps team.
- [ethstats](roles/ethstats)
- [goomy](roles/goomy)
- [mev_boost](roles/mev_boost)
- [mev_relay](roles/mev_relay)
- [powfaucet](roles/powfaucet)
- [xatu_sentry](roles/xatu_sentry)

Expand Down
11 changes: 6 additions & 5 deletions roles/mev_boost/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
mev_boost_user: mev_boost

mev_boost_cleanup: false # when set to "true" it will remove the container(s)

mev_boost_docker_network_name: shared
mev_boost_docker_networks:
- name: "{{ mev_boost_docker_network_name }}"
################################################################################
##
## mev_boost container configuration
##
################################################################################
mev_boost_container_name: mev_boost
mev_boost_container_name: mev-boost
mev_boost_container_image: flashbots/mev-boost:1.5.0
mev_boost_container_env: {}
mev_boost_server_port: 18550
mev_boost_container_ports:
- "127.0.0.1:{{ mev_boost_server_port }}:{{ mev_boost_server_port }}"

mev_boost_container_stop_timeout: "300"
mev_boost_container_networks: []
mev_boost_container_networks: "{{ mev_boost_docker_networks }}"
mev_boost_container_volumes: []
mev_boost_container_command:
- --addr=0.0.0.0:{{ mev_boost_server_port }}
- -relay-check

mev_boost_container_command_extra_args: []
6 changes: 6 additions & 0 deletions roles/mev_boost/tasks/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
name: "{{ mev_boost_user }}"
register: mev_boost_user_meta

- name: Setup docker network
ansible.builtin.include_role:
name: ethpandaops.general.docker_network
vars:
docker_network_name: "{{ mev_boost_docker_network_name }}"

- name: Run mev_boost container
community.docker.docker_container:
name: "{{ mev_boost_container_name }}"
Expand Down
38 changes: 38 additions & 0 deletions roles/mev_flood/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ethpandaops.general.mev_flood

This role will run [mev_flood](https://github.com/flashbots/mev-flood) within a docker container.

## Requirements

You'll need docker on the target system. Make sure to install it upfront.

## Role Variables

Default variables are defined in [defaults/main.yaml](defaults/main.yaml)

## Dependencies

You'll need docker to run this role. One way of installing docker could be via ansible galaxy with the following dependencies set within `requirements.yaml`:

```yaml
roles:
- src: geerlingguy.docker
version: latest
- src: geerlingguy.pip
version: latest
```
## Example Playbook
Your playbook could look like this:
```yaml
- hosts: localhost
become: true
roles:
- role: geerlingguy.docker
- role: geerlingguy.pip
pip_install_packages:
- name: docker
- role: ethpandaops.general.mev_flood
```
51 changes: 51 additions & 0 deletions roles/mev_flood/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
mev_flood_user: mev_flood
mev_flood_cleanup: false # when set to "true" it will remove the container(s)

mev_flood_datadir: "/data/mev_flood"

mev_flood_docker_network_name: shared
mev_flood_docker_networks:
- name: "{{ mev_flood_docker_network_name }}"

################################################################################
##
## mev_flood container configuration
## Deploy smart contracts and provision liquidity on UniV2 pairs.
##
################################################################################
mev_flood_container_name: mev-flood
mev_flood_container_image: flashbots/mev-flood:latest
mev_flood_container_env: {}
mev_flood_container_ports: []
mev_flood_container_stop_timeout: "300"
mev_flood_container_networks: "{{ mev_flood_docker_networks }}"
mev_flood_container_volumes:
- "{{ mev_flood_datadir }}:/app/cli/deployments"
- /etc/passwd:/etc/passwd:ro
mev_flood_container_command:
- init
- --saveFile=local.json

mev_flood_container_command_extra_args: []
################################################################################
##
## mev_flood container configuration
## Send a constant stream of UniV2 swaps.
##
################################################################################

mev_flood_spam_container_name: mev-flood-spam
mev_flood_spam_container_image: flashbots/mev-flood:latest
mev_flood_spam_container_env: {}
mev_flood_spam_container_ports: []
mev_flood_spam_container_stop_timeout: "300"
mev_flood_spam_container_networks: "{{ mev_flood_docker_networks }}"
mev_flood_spam_container_volumes:
- "{{ mev_flood_datadir }}:/app/cli/deployments"
- /etc/passwd:/etc/passwd:ro
mev_flood_spam_container_command:
- spam
- --loadFile=local.json
- --secondsPerBundle=15

mev_flood_spam_container_command_extra_args: []
11 changes: 11 additions & 0 deletions roles/mev_flood/tasks/cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- name: Remove mev_flood container
community.docker.docker_container:
name: "{{ mev_flood_container_name }}"
state: absent
when: mev_flood_cleanup

- name: Remove mev_flood_spam container
community.docker.docker_container:
name: "{{ mev_flood_spam_container_name }}"
state: absent
when: mev_flood_cleanup
8 changes: 8 additions & 0 deletions roles/mev_flood/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# tasks file for mev_flood
- name: Setup mev_flood
ansible.builtin.import_tasks: setup.yaml
when: not mev_flood_cleanup

- name: Cleanup mev_flood
ansible.builtin.import_tasks: cleanup.yaml
52 changes: 52 additions & 0 deletions roles/mev_flood/tasks/setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
- name: Add mev_flood user
ansible.builtin.user:
name: "{{ mev_flood_user }}"
register: mev_flood_user_meta

- name: Setup docker network
ansible.builtin.include_role:
name: ethpandaops.general.docker_network
vars:
docker_network_name: "{{ mev_flood_docker_network_name }}"

- name: Create directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
mode: "0750"
owner: "{{ mev_flood_user }}"
group: "{{ mev_flood_user }}"
loop:
- "{{ mev_flood_datadir }}"

- name: Set permissions
ansible.builtin.command: "chown -R {{ mev_flood_user }}:{{ mev_flood_user }} {{ mev_flood_datadir }}" # noqa no-free-form
changed_when: false

- name: Run mev_flood container
community.docker.docker_container:
name: "{{ mev_flood_container_name }}"
image: "{{ mev_flood_container_image }}"
state: started
restart_policy: always
stop_timeout: "{{ mev_flood_container_stop_timeout }}"
volumes: "{{ mev_flood_container_volumes }}"
env: "{{ mev_flood_container_env }}"
networks: "{{ mev_flood_container_networks }}"
ports: "{{ mev_flood_container_ports }}"
command: "{{ mev_flood_container_command + mev_flood_container_command_extra_args }} "
user: "{{ mev_flood_user_meta.uid }}"

- name: Run mev_flood_spam container
community.docker.docker_container:
name: "{{ mev_flood_spam_container_name }}"
image: "{{ mev_flood_spam_container_image }}"
state: started
restart_policy: always
stop_timeout: "{{ mev_flood_spam_container_stop_timeout }}"
volumes: "{{ mev_flood_spam_container_volumes }}"
env: "{{ mev_flood_spam_container_env }}"
networks: "{{ mev_flood_spam_container_networks }}"
ports: "{{ mev_flood_spam_container_ports }}"
command: "{{ mev_flood_spam_container_command + mev_flood_spam_container_command_extra_args }} "
user: "{{ mev_flood_user_meta.uid }}"
43 changes: 43 additions & 0 deletions roles/mev_relay/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# ethpandaops.general.mev_relay

Setup [mev_relay](https://github.com/flashbots/mev-boost-relay/) and all required dependencies all in one server.

## Requirements

You'll need docker on the target system. Make sure to install it upfront.

## Role Variables

Default variables are defined in [defaults/main.yaml](defaults/main.yaml)

## Dependencies

You'll need docker and docker-compose to run this role. One way of installing docker could be via ansible galaxy with the following dependencies set within `requirements.yaml`:

```yaml
roles:
- src: geerlingguy.docker
version: 6.0.3
- src: geerlingguy.pip
version: 2.2.0
```
## Example Playbook
Your playbook could look like this:
```yaml
- hosts: mev_relay
become: true
roles:
# Docker. Required dependency
- role: geerlingguy.docker
tags: [docker]
- role: geerlingguy.pip
pip_install_packages:
- name: docker
tags: [docker]
# Blockscout explorer
- role: mev_relay
tags: [mev_relay]
```
98 changes: 98 additions & 0 deletions roles/mev_relay/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
mev_relay_cleanup_all: false

mev_relay_user: mev_relay
mev_relay_datadir: "/data/mev_relay"
mev_relay_docker_network_name: shared
mev_relay_docker_networks:
- name: "{{ mev_relay_docker_network_name }}"

# ------------------------------------------------------------------
# mev-relay ports
mev_relay_database_port: 5432
mev_relay_redis_port: 6379
mev_relay_website_listening_port: 9060
mev_relay_api_listening_port: 9062

# mev-relay-database
mev_relay_db_enabled: true
mev_relay_db_datadir: "{{ mev_relay_datadir }}/mev-relay-database"
mev_relay_db_container_name: mev-relay-database
mev_relay_db_container_image: bitnami/postgresql:15
mev_relay_db_container_env:
POSTGRESQL_USERNAME: postgres
POSTGRESQL_PASSWORD: postgres
POSTGRESQL_DATABASE: boostrelay
mev_relay_db_container_ports:
- "127.0.0.1:{{ mev_relay_database_port }}:{{ mev_relay_database_port }}"
mev_relay_db_container_volumes:
- "{{ mev_relay_datadir }}:/bitnami/postgresql"
mev_relay_db_container_stop_timeout: "300"
mev_relay_db_container_pull: false
mev_relay_db_container_networks: "{{ mev_relay_docker_networks }}"

# ------------------------------------------------------------------
# mev-relay-redis
mev_relay_redis_enabled: true
mev_relay_redis_datadir: "{{ mev_relay_datadir }}/mev-relay-redis"
mev_relay_redis_container_name: mev-relay-redis
mev_relay_redis_container_image: bitnami/redis:6.2.12
mev_relay_redis_container_env:
ALLOW_EMPTY_PASSWORD=yes
mev_relay_redis_container_ports:
- "127.0.0.1:{{ mev_relay_redis_port }}:{{ mev_relay_redis_port }}"
mev_relay_redis_container_volumes:
- "{{ mev_relay_datadir }}:/bitnami/redis/data"
mev_relay_redis_container_stop_timeout: "300"
mev_relay_redis_container_pull: false
mev_relay_redis_container_networks: "{{ mev_relay_docker_networks }}"

# ------------------------------------------------------------------
# mev-relay-housekeeper
mev_relay_housekeeper_enabled: true
mev_relay_housekeeper_datadir: "{{ mev_relay_datadir }}/mev-relay-housekeeper"
mev_relay_housekeeper_container_name: mev-relay-housekeeper
mev_relay_housekeeper_container_image: flashbots/mev-boost-relay:latest
mev_relay_housekeeper_container_env: []
mev_relay_housekeeper_container_ports: []
mev_relay_housekeeper_container_volumes: []
mev_relay_housekeeper_container_stop_timeout: "300"
mev_relay_housekeeper_container_pull: false
mev_relay_housekeeper_container_networks: "{{ mev_relay_docker_networks }}"
mev_relay_housekeeper_container_command:
- housekeeper
mev_relay_housekeeper_container_command_extra_args: []

# ------------------------------------------------------------------
# mev-relay-api
mev_relay_api_enabled: true
mev_relay_api_datadir: "{{ mev_relay_datadir }}/mev-relay-api"
mev_relay_api_container_name: mev-relay-api
mev_relay_api_container_image: flashbots/mev-boost-relay:latest
mev_relay_api_container_env: []
mev_relay_api_container_ports:
- "127.0.0.1:{{ mev_relay_api_listening_port }}:{{ mev_relay_api_listening_port }}"
mev_relay_api_container_volumes: []
mev_relay_api_container_stop_timeout: "300"
mev_relay_api_container_pull: false
mev_relay_api_container_networks: "{{ mev_relay_docker_networks }}"
mev_relay_api_container_command:
- api
mev_relay_api_container_command_extra_args: []

# ------------------------------------------------------------------
# mev-relay-website
mev_relay_website_enabled: true
mev_relay_website_datadir: "{{ mev_relay_datadir }}/mev-relay-website"
mev_relay_website_container_name: mev-relay-website
mev_relay_website_container_image: flashbots/mev-boost-relay:latest
mev_relay_website_container_env: []
mev_relay_website_container_ports:
- "127.0.0.1:{{ mev_relay_website_listening_port }}:{{ mev_relay_website_listening_port }}"
mev_relay_website_container_volumes: []
mev_relay_website_container_stop_timeout: "300"
mev_relay_website_container_pull: false
mev_relay_website_container_networks: "{{ mev_relay_docker_networks }}"
mev_relay_website_container_command:
- website
mev_relay_website_container_command_extra_args: []
10 changes: 10 additions & 0 deletions roles/mev_relay/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
galaxy_info:
author: flashbots_mev_relay
description: Deploy Flashbots MEV Relay and all required dependencies on a single machine.
license: MIT
min_ansible_version: "2.1"
galaxy_tags: ["ethereum", "mevrelay", "flashbots", "mev"]
platforms:
- name: GenericLinux
versions: ["all"]
dependencies: []
22 changes: 22 additions & 0 deletions roles/mev_relay/tasks/cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
- name: Stop mev_relay containers
community.docker.docker_container:
name: "{{ item }}"
state: absent
loop:
- "{{ mev_relay_api_container_name }}"
- "{{ mev_relay_db_container_name }}"
- "{{ mev_relay_housekeeper_container_name }}"
- "{{ mev_relay_website_container_name }}"
- "{{ mev_relay_redis_container_name }}"

- name: Delete data directories
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ mev_relay_api_datadir }}"
- "{{ mev_relay_website_datadir }}"
- "{{ mev_relay_housekeeper_datadir }}"
- "{{ mev_relay_db_datadir }}"
- "{{ mev_relay_redis_datadir }}"
- "{{ mev_relay_datadir }}"
Loading

0 comments on commit 9fe7893

Please sign in to comment.