This repository contains our dataset of detected MEV across Ethereum and Layer-2 Rollups such as Arbitrum, Optimism, and zkSync. It also includes a collection of tools that we used to measure and compare MEV as well as a proof-of-concept implementation of cross-layer sandwich attacks where we demonstrate that frontrunning is possible on Layer-2 Rollups as a normal user (i.e., without being a sequencer).
Our paper can be found here.
A container with all the dependencies can be found here.
To run the container, please install docker and run:
-v ./:/root below. This is because the container will first try to import all the data into an instance of MongoDB when started. Please keep in mind that this process might take a while, so feel free to grab a cup of coffee meanwhile.
docker pull christoftorres/rolling-in-the-shadows && docker run -m 16g --memory-swap="24g" -p 8888:8888 -v ./:/root -it christoftorres/rolling-in-the-shadows:latestAfter starting the container it will import all the collected data into an instance of MongoDB running inside the container and finally launch a jupyter notebook server.
docker build -t rolling-in-the-shadows .
docker run -m 16g --memory-swap="24g" -p 8888:8888 -v ./:/root -it rolling-in-the-shadows:latestbrew tap mongodb/brew
brew install [email protected]curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc | gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg --dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-6.0.list
apt-get update
apt-get install mongodb-org=6.0.4 mongodb-org-database=6.0.4 mongodb-org-server=6.0.4 mongodb-org-mongos=6.0.4 mongodb-org-tools=6.0.4For other operating systems follow the installation instructions on mongodb.com.
python3 -m pip install -r requirements.txtMake sure MongoDB is running and that you have installed all Python dependencies.
PROVIDER in scripts/utils/settings.py accordingly.
cd scripts/mev/flashbots
python3 download_falshbots_data.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/arbitrage/ethereum
python3 arbitrage.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/arbitrage/arbitrum
python3 arbitrage.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/arbitrage/optimism
python3 arbitrage.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/arbitrage/zksync
python3 arbitrage.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/liquidation/ethereum
python3 liquidation.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/liquidation/arbitrum
python3 liquidation.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/liquidation/optimism
python3 liquidation.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/liquidation/zksync
python3 liquidation.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/sandwiching/ethereum
python3 sandwiching.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/sandwiching/arbitrum
python3 sandwiching.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/sandwiching/optimism
python3 sandwiching.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/sandwiching/zksync
python3 sandwiching.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/mev/opportunities/arbitrage/ethereum
python3 opportunity.pycd scripts/mev/opportunities/arbitrage/arbitrum
python3 opportunity.pycd scripts/mev/opportunities/arbitrage/optimism
python3 opportunity.pycd scripts/mev/opportunities/arbitrage/zksync
python3 opportunity.pycd scripts/mev/opportunities/liquidation/ethereum
python3 opportunity.pycd scripts/mev/opportunities/liquidation/arbitrum
python3 opportunity.pycd scripts/mev/opportunities/liquidation/optimism
python3 opportunity.pycd scripts/mev/opportunities/liquidation/zksync
python3 opportunity.pycd scripts/mev/code_reuse
python3 download_and_disassemble_bytecode.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/cross_layer_sandwiching/l1_analyzer
python3 L1MessageAnalyzer.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END>cd scripts/cross_layer_sandwiching/l2_analyzer
python3 L2MessageAnalyzer.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END> arbitrumcd scripts/cross_layer_sandwiching/l2_analyzer
python3 L2MessageAnalyzer.py <BLOCK_RANGE_START>:<BLOCK_RANGE_END> optimismcd scripts/cross_layer_sandwiching/l2_analyzer
python3 L2MessageAnalyzer.py zksynccd scripts/cross_layer_sandwiching/simulation
python3 arbitrum_attack_simulator.pycd scripts/cross_layer_sandwiching/simulation
python3 optimism_attack_simulator.pycd scripts/cross_layer_sandwiching/testnet
python3 attacker_script_arbitrum_all_attacks.pycd scripts/cross_layer_sandwiching/testnet
python3 attacker_script_optimism_all_attacks.pycd scripts/cross_layer_sandwiching/testnet
python3 attacker_script_zksync_all_attacks.pyRequired Solidity contracts can be found in scripts/cross_layer_sandwiching/testnet/contracts.
Make sure Juypter notebook is running and that you have installed all Python dependencies.
Then open up http://localhost:8888 on your browser and navigate to analysis.
To compare and analyze MEV volume (Section 4.1) run:
4_1_volume.ipynb
To compare and analyze MEV profits (Section 4.2) run:
4_2_profits.ipynb
To compare and analyze MEV costs (Section 4.3) run:
4_3_costs.ipynb
To compare and analyze MEV opportunities (Section 4.4) run:
4_4_opportunities.ipynb
To compare and analyze MEV competition (Section 4.5) run:
4_5_competition.ipynb
To compare and analyze MEV flash loans (Section 4.6) run:
4_6_flash_loans.ipynb
To compare and analyze MEV code reuse (Section 4.7) run:
4_7_code_reuse.ipynb
To compare and analyze cross-layer sandwiching victim inference (Section 5.3.1) run:
5_3_1_victim_inference.ipynb
To compare and analyze cross-layer sandwiching transaction inclusion delays (Section 5.3.2) run:
5_3_2_transaction_inclusion_delays.ipynb
To compare and analyze cross-layer sandwiching estimated profits (Section 5.3.3) run:
5_3_3_estimated_profits.ipynb
If using this repository for research, please cite as:
@article{rollingintheshadows,
author = {Ferreira Torres, Christof and
Mamuti, Albin and
Weintraub, Ben and
Nita{-}Rotaru, Cristina and
Shinde, Shweta},
title = {Rolling in the Shadows: Analyzing the Extraction of {MEV} Across Layer-2 Rollups},
booktitle = {Proceedings of the 2024 {ACM} {SIGSAC} Conference on Computer and
Communications Security, {CCS} 2024, Salt Lake City, UT, USA, October
14-18, 2024},
publisher = {{ACM}},
year = {2024}
}