Table of Contents
Command-line application to track and detect chain reorganization in the Ethereum blockchain. In case a chain re-org is detected, the discarded blocks from the ephemeral forks is printed out.
It works by querying the Eth-client for the last 9 blocks and storing the blocks in an array(currentArray), then a pause of 16 seconds is taken and then the last 9 blocks are retrieved again and stored in an array, nextArray. These two arrays are then compared to detect any chain reorgs. And then, the currentArray is overwritten with nexArray and the process continues until the program is terminated by the user, by hitting Cntrl+C.
Check out reorgtracker/reorgtracker.go
to learn more about the algorithm.
Download and install Golang 1.19 (or higher).
- Navigate to
ethereum-reorg-tracker/
:cd /path/to/folder/ethereum-reorg-tracker/
- Open
.env
file and fill in theCLIENT_LINK
field. This is useful to connect to the Ethereum Node. - Get dependencies:
go mod tidy
- Run the app:
go run main.go # use "--verbose" flag to get additional logs go run main.go --verbose
- CD into
reorgtracker/
to run tests:cd reorgtracker/ go test
Thank you!