Skip to content

Commit

Permalink
Adding Scroll Block Scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoalencar committed Sep 11, 2024
1 parent 5e7a5ed commit 6b31a35
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 14 deletions.
3 changes: 1 addition & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ RUN apk add git python3 make g++
COPY package.json tsconfig.json yarn.lock ./
RUN yarn install --frozen-lockfile

COPY migrations migrations
COPY src src

#Start
RUN yarn build
CMD [ "yarn", "migrate_and_start" ]
CMD [ "yarn", "start" ]
31 changes: 31 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,33 @@ services:
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x4200000000000000000000000000000000000006'

event-pipeline-scroll:
build:
context: .
dockerfile: Dockerfile.dev
platform: linux/amd64
restart: always
environment:
SCRAPER_MODE: 'BLOCKS'
EVM_RPC_URL: '${RPC_URL_SCROLL}'
CHAIN_ID: '534352'
POSTGRES_URI: 'postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}'
SCHEMA: 'events_scroll'
FEAT_ZEROEX_EXCHANGE_PROXY: "false"
SETTLER_DEPLOYMENT_BLOCK: 7474150
MAX_BLOCKS_TO_SEARCH: 1000
MAX_BLOCKS_TO_PULL: 100
SECONDS_BETWEEN_RUNS: 1
RESCRAPE_BLOCKS: 10
FEAT_WRAP_UNWRAP_NATIVE_EVENT: "true"
WRAP_UNWRAP_NATIVE_CONTRACT_ADDRESS: '0x5300000000000000000000000000000000000004'
FEAT_TOKENS_FROM_TRANSFERS: "true"
FEAT_ERC20_TRANSFER_ALL: "true"
FEAT_SETTLER_ERC721_TRANSFER_EVENT: "true"
FEAT_SETTLER_RFQ_ORDER_EVENT: "true"
networks:
- 0x-data-migrations_default

token-scraper-ethereum:
depends_on:
- postgres
Expand All @@ -306,3 +333,7 @@ services:
MAX_BLOCKS_TO_PULL: 1000
MAX_TX_TO_PULL: 1000
SECONDS_BETWEEN_RUNS: 5

networks:
0x-data-migrations_default:
external: true
23 changes: 12 additions & 11 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const supportedChains: Map = {
42161: { name: 'Arbitrum' },
43114: { name: 'Avalanche' },
42220: { name: 'Celo' },
534352: { name: 'Scroll' },
};

interface BridgeContract {
Expand Down Expand Up @@ -138,10 +139,10 @@ export const SCRAPER_MODE: ScraperMode =
process.env.SCRAPER_MODE === undefined
? DEFAULT_SCRAPER_MODE
: process.env.SCRAPER_MODE === 'BLOCKS'
? 'BLOCKS'
: process.env.SCRAPER_MODE === 'EVENTS'
? 'EVENTS'
: throwError('Wrong SCRAPER_MODE');
? 'BLOCKS'
: process.env.SCRAPER_MODE === 'EVENTS'
? 'EVENTS'
: throwError('Wrong SCRAPER_MODE');
export const METRICS_PATH = process.env.METRICS_PATH || DEFAULT_METRICS_PATH;

export const PROMETHEUS_PORT = getIntConfig('PROMETHEUS_PORT', DEFAULT_PROMETHEUS_PORT);
Expand Down Expand Up @@ -380,13 +381,13 @@ export const FEAT_UNISWAP_V2_PAIR_CREATED_EVENT = getBoolConfig(
export const UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS = process.env
.UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS
? process.env.UNISWAP_V2_PAIR_CREATED_PROTOCOL_CONTRACT_ADDRESSES_AND_START_BLOCKS.split(',').map((contract) => {
const [name, factoryAddress, startBlock] = contract.split(':');
return {
name,
factoryAddress,
startBlock: parseInt(startBlock),
};
})
const [name, factoryAddress, startBlock] = contract.split(':');
return {
name,
factoryAddress,
startBlock: parseInt(startBlock),
};
})
: [];

if (
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/pull_and_save_block_events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export class BlockEventsScraper {

if (lastKnownBlock === undefined) {
logger.warn('First Run');
const firstStartBlock = Math.max(...eventScrperProps.map((props) => props.startBlock));
const firstStartBlock = Math.min(...eventScrperProps.filter((props) => props.enabled).map((props) => props.startBlock));
logger.warn(`Going to start from block: ${firstStartBlock}`);
const newBlocks = await web3Source.getBatchBlockInfoForRangeAsync(firstStartBlock, firstStartBlock, true);
await getParseSaveBlocksTransactionsEvents(connection, producer, newBlocks, true);
Expand Down

0 comments on commit 6b31a35

Please sign in to comment.