EVM Blockchain Scraper, mainly for 0x Protocol Events and some extra useful Events.
NOTE: Due to new optimizations, starting to scrape a chain from scratch is currently not straight forward, please read the whole document before starting
Run locally:
-
Copy the
.env.exmaple
file to.env
. Add theRPC_URL
for the chain(s) you are going to run Configure the scape Mode -
Start Postgres
For local development, you will need to get the local databases running depending on which pipelines you are going to develop/test. You can setup them by following the instructions on the 0x-data-migrations repository. We manage all db setup/changes there. It will guide you on how to get the dbs up and running the initial setup that is necessary to be used here.
- Build the Scraper images
docker-compose build
- Start the scraper(s)
docker-compose up event-pipeline-ethereum # change the chain name
Blocks is the preferred and most efficient mode but is not yet compatible with all RPC providers/chains. To use it the RPC provider must support eth_getBlockReceipts
.
Set MODE="BLOCKS"
in .env
to use blocks mode, make sure to read Stateful Events and Tokens if it is the first run.
Events is the legacy mode but it is supported by all chains. Since this mode makes extra calls for each monitored event, monitoring a lot of events can be expensive/bring your node down.
Set MODE="EVENTS"
in .env
to use events mode.
Switching modes is currently not automated but it is possible following the next steps
- Make sure there are no backfills in process
- Stop the Scraper
- Delete the last
MAX_BLOCKS_REORG
blocks from theblocks
table (just to be sure we are not skipping anything) - Change the mode to
BLOCKS
- Start the scraper
- Stop the Scraper
- For all the events being scraped upsert a row to
last_block_processed
withlast_processed_block_number
to the current max block number of theblocks
table - Change the mode to
EVENTS
- Start the scraper
Scraping some events (Uni v2 & Uni v3 VIP) depends on other events being already available in the DB (pool creation events).
When in BLOCKS
mode this is not an issue as long as the scraping starts when the Uni Pool Factory was deployed, instead of when the EP was deployed. For now please copy the pool creation table from an existing source. Or use EVENTS
mode (with fetching and saving blocks disabled) to backfill this events up to the point you want to start scraping the rest of the events.
When in EVENTS
mode, do a first pass only scraping the pool creation events, up till where you want to start scraping the rest of the events.
Not backfilling the pool creation events before scraping VIP swaps will make the scrapers assume that all VIP swaps are spoofed (not from a real Pool) and ignore them.
To be able to get a complete list of tokens, the scrapers must process all blocks after the first ERC20 was deployed on the chain, this can take a lot of time and it is recommended to use the backfill feature.