Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aditiharini committed Sep 12, 2024
1 parent 671ec0b commit 48015fe
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions apps/hubble/src/eth/l2EventsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,32 +680,46 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
return; //
}

this._fidRetryDedupMap.set(fid, true);

log.info({ fid }, `Attempting to retryEventsForFid ${fid}`);
statsd().increment("l2events.retriesByFid.attempts", 1, { fid: fid.toString() });

// Let's never remove. No need to retry same fid many times. If we allow retrying multiple times, we need to rate limit.
this._fidRetryDedupMap.set(fid, true);

// Let's not remove. No need to retry same fid many times. If we allow retrying multiple times, we need to rate limit. The map will get cleared periodically to prevent memory bloat.
try {
// The viem API requires an event kind if you want to provide filters by indexed arguments
// TODO(aditi): Do we want batching?
// The viem API requires an event kind if you want to provide filters by indexed arguments-- this is why we're making multiple calls to syncHistoricalEvents and prioritizing the most common event types.

// THe batch sizes are artificially large-- this batch size is internally enforced and we essentially want to eliminate batches given that we don't expct a lot of results from these queries.
await this.syncHistoricalEvents(0, this._lastBlockNumber, this._lastBlockNumber, {
eventKind: "Storage",
eventName: "Rent",
fid,
});
// TODO(aditi): Do we want to do more event types

await this.syncHistoricalEvents(0, this._lastBlockNumber, this._lastBlockNumber, {
eventKind: "IdRegistry",
eventName: "Register",
fid,
});
// TODO(aditi): Do we want to do more event types

await this.syncHistoricalEvents(0, this._lastBlockNumber, this._lastBlockNumber, {
eventKind: "IdRegistry",
eventName: "Transfer",
fid,
});

await this.syncHistoricalEvents(0, this._lastBlockNumber, this._lastBlockNumber, {
eventKind: "KeyRegistry",
eventName: "Add",
fid,
});

await this.syncHistoricalEvents(0, this._lastBlockNumber, this._lastBlockNumber, {
eventKind: "KeyRegistry",
eventName: "Remove",
fid,
});

log.info({ fid }, `Finished retryEventsForFid ${fid}`);
statsd().increment("l2events.retriesByFid.successes", 1, { fid: fid.toString() });
} catch (e) {
Expand Down Expand Up @@ -862,7 +876,7 @@ export class L2EventsProvider<chain extends Chain = Chain, transport extends Tra
private async syncHistoricalEvents(
fromBlock: number,
toBlock: number,
batchSize: number,
batchSize: number, // This batch size is enforced by us internally, not by the RPC provider
byEventKind?: EventSpecificArgs,
) {
if (!this.idRegistryV2Address || !this.keyRegistryV2Address || !this.storageRegistryAddress) {
Expand Down

0 comments on commit 48015fe

Please sign in to comment.