diff --git a/packages/daimo-api/src/contract/foreignCoinIndexer.ts b/packages/daimo-api/src/contract/foreignCoinIndexer.ts index 543625f12..8d70131b5 100644 --- a/packages/daimo-api/src/contract/foreignCoinIndexer.ts +++ b/packages/daimo-api/src/contract/foreignCoinIndexer.ts @@ -59,10 +59,6 @@ export class ForeignCoinIndexer extends Indexer { const result = await retryBackoff( `foreignCoinIndexer-logs-query-${from}-${to}`, async () => { - await Promise.all([ - pg.query(`REFRESH MATERIALIZED VIEW filtered_erc20_transfers;`), - pg.query(`REFRESH MATERIALIZED VIEW filtered_eth_transfers;`), - ]); return await pg.query( ` SELECT * FROM ( @@ -77,8 +73,11 @@ export class ForeignCoinIndexer extends Indexer { t, v, log_idx as sort_idx - FROM filtered_erc20_transfers - WHERE block_num BETWEEN $1 AND $2 + FROM erc20_transfers + WHERE ig_name='erc20_transfers' + AND src_name='base' + AND block_num BETWEEN $1 AND $2 + AND ((t in (SELECT addr FROM names)) OR (f in (SELECT addr FROM names))) UNION ALL SELECT chain_id, @@ -91,8 +90,11 @@ export class ForeignCoinIndexer extends Indexer { "to" as t, "value" as v, trace_action_idx as sort_idx - FROM filtered_eth_transfers et - WHERE block_num BETWEEN $1 AND $2 + FROM eth_transfers et + WHERE ig_name='eth_transfers' + AND src_name='baseTrace' + AND block_num BETWEEN $1 AND $2 + AND (("to" in (SELECT addr FROM names)) OR ("from" in (SELECT addr FROM names))) ) ORDER BY block_num ASC, tx_idx ASC, sort_idx ASC ;`, diff --git a/packages/daimo-api/src/shovel/watcher.ts b/packages/daimo-api/src/shovel/watcher.ts index c15cb9740..e01fcc1af 100644 --- a/packages/daimo-api/src/shovel/watcher.ts +++ b/packages/daimo-api/src/shovel/watcher.ts @@ -32,7 +32,7 @@ export class Watcher { // Start from a block before the first Daimo tx on Base and Base Sepolia. private latest = 5699999; private slowLatest = 5699999; - private batchSize = 100000; + private batchSize = 25000; private isIndexing = false; private isSlowIndexing = false; @@ -98,30 +98,6 @@ export class Watcher { CREATE INDEX IF NOT EXISTS i_eth_from ON eth_transfers("from"); CREATE INDEX IF NOT EXISTS i_eth_to ON eth_transfers("to"); `); - - console.log(`[SHOVEL] migrateDB: filtered_erc20_transfers...`); - await this.pg.query(` - CREATE MATERIALIZED VIEW IF NOT EXISTS filtered_erc20_transfers AS ( - SELECT et.* - FROM erc20_transfers et - JOIN names n ON n.addr = et.f - OR n.addr = et.t - ); - CREATE INDEX IF NOT EXISTS i_block_num - ON filtered_erc20_transfers (block_num); - `); - - console.log(`[SHOVEL] migrateDB: filtered_eth_transfers...`); - await this.pg.query(` - CREATE MATERIALIZED VIEW IF NOT EXISTS filtered_eth_transfers AS ( - SELECT et.* - FROM eth_transfers et - JOIN names n ON n.addr = et.to - OR n.addr = et.from - ); - CREATE INDEX IF NOT EXISTS i_filtered_eth_transfers_block_num - ON filtered_eth_transfers (block_num); - `); } async init() {