A collection of tools to measure and analyze frontrunning attacks on private pools such as Flashbots. Our paper can be found here and our data is available for download here.
A container with all the dependencies can be found here.
To run the container, please install docker and run:
docker pull christoftorres/a-flashbot-in-the-pan && docker run -m 16g --memory-swap="24g" -p 8888:8888 -it christoftorres/a-flashbot-in-the-panAfterwards, start an instance of MongoDB inside the container:
mkdir -p /data/db && mongod --fork --logpath /var/log/mongod.logImport the flashbots blocks into MongoDB by running inside the container the following commands:
cd /root/data-collection/flashbots
python3 import_flashbots_data.pyTo run the MEV measurement scripts, simply run inside the container the following commands:
# Run the sandwich measurement script
cd /root/data-collection/mev/sandwiches
python3 sandwiches.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END> # For exmaple: python3 sandwiches.py 10892526:10892526
# Run the arbitrage measurement script
cd /root/data-collection/mev/arbitrage
python3 arbitrage.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END> # For exmaple: python3 arbitrage.py 11706655:11706655
# Run the liquidation measurement script
cd /root/data-collection/mev/liquidation
python3 liquidation.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END> # For exmaple: python3 liquidation.py 11181773:11181773To collect pending transactions, simply run inside the container the following commands:
cd /root/data-collection/pending-transactions
node observer.jsTo run the analysis, please launch the Jupyter notebook server inside the container using the following commands and then open up http://localhost:8888 on your browser:
cd /root/analysis
jupyter notebook --port=8888 --no-browser --ip=0.0.0.0 --allow-root --NotebookApp.token='' --NotebookApp.password=''docker build -t a-flashbot-in-the-pan .
docker run -m 16g --memory-swap="24g" -p 8888:8888 -it a-flashbot-in-the-pan:latestbrew tap mongodb/brew
brew install mongodb-community@4.4For other operating systems follow the installation instructions on mongodb.com.
python3 -m pip install -r requirements.txtbrew install nodeFor other operating systems follow the installation instructions on nodejs.org.
mongodcd data-collection/flashbots
python3 import_flashbots_data.pyPROVIDER in data-collection/mev/utils/settings.py accordingly. !!
cd data-collection/mev/sandwiches
python3 sandwiches.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>
cd data-collection/mev/arbitrage
python3 arbitrage.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>
cd data-collection/mev/liquidation
python3 liquidation.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END> web3 in data-collection/pending-transactions/observer.js accordingly. !!
cd data-collection/pending-transactions
npm install
node observer.jsYou can either run the data collection scripts or download our data from Google drive:
cd data-collection
./download_and_import_data.sh
The bulk of the analysis was done in Jupyter notebooks, which can be opened by running:
cd analysis
jupyter notebookand selecting the notebook of choice.
If using this repository for research, please cite as
@inproceedings{
aflashbotinthepan,
address={Nice, France},
title={A Flash(bot) in the Pan: Measuring Maximal Extractable Value in Private Pools},
ISBN={978-1-4503-9259-4},
DOI={10.1145/3517745.3561448},
booktitle={Proceedings of the 22nd ACM Internet Measurement Conference (IMC ’22)},
publisher={Association for Computing Machinery},
author={Weintraub, Ben and Ferreira Torres, Christof and Nita-Rotaru, Cristina and State, Radu},
year={2022}
}