ponder 0.17.9 → 0.17.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/esm/rpc/actions.js +5 -2
- package/dist/esm/rpc/actions.js.map +1 -1
- package/dist/esm/runtime/historical.js +1 -1
- package/dist/esm/runtime/historical.js.map +1 -1
- package/dist/esm/sync-historical/index.js +2 -1
- package/dist/esm/sync-historical/index.js.map +1 -1
- package/dist/esm/sync-realtime/index.js +42 -38
- package/dist/esm/sync-realtime/index.js.map +1 -1
- package/dist/esm/utils/finality.js +4 -1
- package/dist/esm/utils/finality.js.map +1 -1
- package/dist/esm/utils/sql-parse.js +1 -5
- package/dist/esm/utils/sql-parse.js.map +1 -1
- package/dist/types/rpc/actions.d.ts +2 -1
- package/dist/types/rpc/actions.d.ts.map +1 -1
- package/dist/types/runtime/historical.d.ts.map +1 -1
- package/dist/types/sync-historical/index.d.ts.map +1 -1
- package/dist/types/sync-realtime/index.d.ts.map +1 -1
- package/dist/types/utils/finality.d.ts.map +1 -1
- package/dist/types/utils/sql-parse.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/rpc/actions.ts +7 -1
- package/src/runtime/historical.ts +4 -1
- package/src/sync-historical/index.ts +2 -0
- package/src/sync-realtime/index.ts +52 -48
- package/src/utils/finality.ts +4 -1
- package/src/utils/sql-parse.ts +1 -5
|
@@ -301,13 +301,14 @@ export const createRealtimeSync = (
|
|
|
301
301
|
////////
|
|
302
302
|
|
|
303
303
|
// "eth_getLogs" calls can be skipped if no filters match `newHeadBlock.logsBloom`.
|
|
304
|
-
// Async-execution chains
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
304
|
+
// Async-execution chains cannot reliably use blooms to filter or validate logs.
|
|
305
|
+
const isAsyncExecution = isAsyncExecutionChain(args.chain.id);
|
|
306
|
+
const shouldRequestLogs = isAsyncExecution
|
|
307
|
+
? logFilters.length > 0
|
|
308
|
+
: maybeBlockHeader.logsBloom === zeroLogsBloom ||
|
|
309
|
+
logFilters.some((filter) =>
|
|
310
|
+
isFilterInBloom({ block: maybeBlockHeader, filter }),
|
|
311
|
+
);
|
|
311
312
|
|
|
312
313
|
let logs: SyncLog[] = [];
|
|
313
314
|
if (shouldRequestLogs) {
|
|
@@ -344,54 +345,57 @@ export const createRealtimeSync = (
|
|
|
344
345
|
method: "eth_getBlockByHash",
|
|
345
346
|
params: [block.hash, true],
|
|
346
347
|
},
|
|
348
|
+
isAsyncExecutionChain(args.chain.id),
|
|
347
349
|
);
|
|
348
350
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
351
|
+
if (isAsyncExecutionChain(args.chain.id) === false) {
|
|
352
|
+
// Note: Exact `logsBloom` validations were considered too strict to add to `validateLogsAndBlock`.
|
|
353
|
+
let isInvalidLogsBloom = false;
|
|
354
|
+
for (const log of logs) {
|
|
355
|
+
if (isInBloom(block.logsBloom, log.address) === false) {
|
|
356
|
+
isInvalidLogsBloom = true;
|
|
357
|
+
}
|
|
355
358
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
359
|
+
if (
|
|
360
|
+
log.topics[0] &&
|
|
361
|
+
isInBloom(block.logsBloom, log.topics[0]) === false
|
|
362
|
+
) {
|
|
363
|
+
isInvalidLogsBloom = true;
|
|
364
|
+
}
|
|
362
365
|
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
366
|
+
if (
|
|
367
|
+
log.topics[1] &&
|
|
368
|
+
isInBloom(block.logsBloom, log.topics[1]) === false
|
|
369
|
+
) {
|
|
370
|
+
isInvalidLogsBloom = true;
|
|
371
|
+
}
|
|
369
372
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
if (
|
|
374
|
+
log.topics[2] &&
|
|
375
|
+
isInBloom(block.logsBloom, log.topics[2]) === false
|
|
376
|
+
) {
|
|
377
|
+
isInvalidLogsBloom = true;
|
|
378
|
+
}
|
|
376
379
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
380
|
+
if (
|
|
381
|
+
log.topics[3] &&
|
|
382
|
+
isInBloom(block.logsBloom, log.topics[3]) === false
|
|
383
|
+
) {
|
|
384
|
+
isInvalidLogsBloom = true;
|
|
385
|
+
}
|
|
383
386
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
387
|
+
if (isInvalidLogsBloom) {
|
|
388
|
+
args.common.logger.warn({
|
|
389
|
+
msg: "Detected inconsistent RPC responses. Log not found in block.logsBloom.",
|
|
390
|
+
action: "fetch_block_data",
|
|
391
|
+
chain: args.chain.name,
|
|
392
|
+
chain_id: args.chain.id,
|
|
393
|
+
number: hexToNumber(block.number),
|
|
394
|
+
hash: block.hash,
|
|
395
|
+
logIndex: hexToNumber(log.logIndex),
|
|
396
|
+
});
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
395
399
|
}
|
|
396
400
|
}
|
|
397
401
|
|
package/src/utils/finality.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Chain } from "viem";
|
|
2
2
|
|
|
3
3
|
export const isAsyncExecutionChain = (chainId: number) =>
|
|
4
|
-
chainId === 143 ||
|
|
4
|
+
chainId === 143 ||
|
|
5
|
+
chainId === 10143 ||
|
|
6
|
+
chainId === 43114 ||
|
|
7
|
+
chainId === 43113;
|
|
5
8
|
|
|
6
9
|
/**
|
|
7
10
|
* Returns the number of blocks that must pass before a block is considered final.
|
package/src/utils/sql-parse.ts
CHANGED
|
@@ -56,11 +56,7 @@ export const parseSQLQuery = async (sql: string): Promise<Node> => {
|
|
|
56
56
|
export const validateAllowableSQLQuery = async (sql: string) => {
|
|
57
57
|
const crypto = await import(/* webpackIgnore: true */ "node:crypto");
|
|
58
58
|
|
|
59
|
-
const hash = crypto
|
|
60
|
-
.createHash("sha256")
|
|
61
|
-
.update(sql)
|
|
62
|
-
.digest("hex")
|
|
63
|
-
.slice(0, 10);
|
|
59
|
+
const hash = crypto.createHash("sha256").update(sql).digest("hex");
|
|
64
60
|
|
|
65
61
|
if (ALLOW_CACHE.has(hash)) {
|
|
66
62
|
const result = ALLOW_CACHE.get(hash)!;
|