A classifier for back-runable ethereum transactions made with neural network.
I created this classifier during a competition on the recognition of ethereum transactions subject to back-running (more information on this can be found in the useful links). Also does not include code for the regression problem as no significant results were found and the model could not learn with the available data
This repository shows only the best performing model that the author has been able to obtain, and is the result of several tests and tuning steps of the model.
- Google account
- 10gb+ of gdrive space
- Colab TPU runtime
Looking at the application domain and the type of data, after several tests I realized that it would be more appropriate to use a RNN (particularly useful in time series), in particular the LSTM architecture has proved more performant.
The training dataset is first pre-processed by eliminating irrelevant columns and splitting it into validation and training files with percentages of 0.1 and 0.9 respectively, this operation can be done locally and is very important for optimizing the use of Google Colab resources, especially if you make use of the free version you risk exhausting the resources (the dataset is very heavy and takes a long time to be transformed into tensors).
The most interesting part of the dataset is represented by the column "txTrace" which contains the stack of calls made in the transaction, this recursive structure is explored through DFS in order to transform the dataset into a 3d tensor [samples x time x features] suitable for RNNs, where the time dimension is the sequence of calls and the features are the attributes of individual calls.
git clone https://github.com/AlessandroPaparella/BR-transaction-classifier.git
- Move
train.csv
andtest.py
in the repo directory - Run
preprocessing.py
- For training purpose upload
training.csv
andvalidation.csv
in your gdrive root - For testing purpose upload weights (available with release) on your gdrive root
- Run the respective google colab notebook
- Challenge: https://alphamev.ai/
- Dataset download: https://alphamev.ai/data/dataset.zip
- What is MEV: https://messari.io/article/understanding-mev
- Back-running practice: https://www.mev.wiki/attack-examples/back-running
- NN graph created with: https://netron.app/