ponder 0.8.9 → 0.8.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/dist/bin/ponder.js +35 -9
- package/dist/bin/ponder.js.map +1 -1
- package/package.json +1 -1
- package/src/sync/index.ts +14 -4
- package/src/sync-historical/index.ts +13 -0
- package/src/utils/requestQueue.ts +14 -6
package/dist/bin/ponder.js
CHANGED
|
@@ -8394,6 +8394,18 @@ var createHistoricalSync = async (args) => {
|
|
|
8394
8394
|
)
|
|
8395
8395
|
)
|
|
8396
8396
|
).then((logs2) => logs2.flat());
|
|
8397
|
+
const logIds = /* @__PURE__ */ new Set();
|
|
8398
|
+
for (const log of logs) {
|
|
8399
|
+
const id = `${log.blockHash}-${log.logIndex}`;
|
|
8400
|
+
if (logIds.has(id)) {
|
|
8401
|
+
args.common.logger.warn({
|
|
8402
|
+
service: "sync",
|
|
8403
|
+
msg: `Detected invalid eth_getLogs response. Duplicate log for block ${log.blockHash} with index ${log.logIndex}.`
|
|
8404
|
+
});
|
|
8405
|
+
} else {
|
|
8406
|
+
logIds.add(id);
|
|
8407
|
+
}
|
|
8408
|
+
}
|
|
8397
8409
|
if (getLogsRequestMetadata.has(filter) && getLogsRequestMetadata.get(filter).confirmedRange === void 0) {
|
|
8398
8410
|
getLogsRequestMetadata.get(filter).estimatedRange = Math.round(
|
|
8399
8411
|
getLogsRequestMetadata.get(filter).estimatedRange * 1.05
|
|
@@ -9476,7 +9488,15 @@ var createRequestQueue = ({
|
|
|
9476
9488
|
for (let i = 0; i <= RETRY_COUNT2; i++) {
|
|
9477
9489
|
try {
|
|
9478
9490
|
const stopClock = startClock();
|
|
9491
|
+
common.logger.trace({
|
|
9492
|
+
service: "rpc",
|
|
9493
|
+
msg: `Sent ${request.method} request (params=${JSON.stringify(request.params)})`
|
|
9494
|
+
});
|
|
9479
9495
|
const response = await network.transport.request(request);
|
|
9496
|
+
common.logger.trace({
|
|
9497
|
+
service: "rpc",
|
|
9498
|
+
msg: `Received ${request.method} response (duration=${stopClock()}, params=${JSON.stringify(request.params)})`
|
|
9499
|
+
});
|
|
9480
9500
|
common.metrics.ponder_rpc_request_duration.observe(
|
|
9481
9501
|
{ method: request.method, network: network.name },
|
|
9482
9502
|
stopClock()
|
|
@@ -9494,23 +9514,23 @@ var createRequestQueue = ({
|
|
|
9494
9514
|
}
|
|
9495
9515
|
if (shouldRetry(error) === false) {
|
|
9496
9516
|
common.logger.warn({
|
|
9497
|
-
service: "
|
|
9498
|
-
msg: `Failed
|
|
9517
|
+
service: "rpc",
|
|
9518
|
+
msg: `Failed ${request.method} request`
|
|
9499
9519
|
});
|
|
9500
9520
|
throw error;
|
|
9501
9521
|
}
|
|
9502
9522
|
if (i === RETRY_COUNT2) {
|
|
9503
9523
|
common.logger.warn({
|
|
9504
|
-
service: "
|
|
9505
|
-
msg: `Failed
|
|
9524
|
+
service: "rpc",
|
|
9525
|
+
msg: `Failed ${request.method} request after ${i + 1} attempts`,
|
|
9506
9526
|
error
|
|
9507
9527
|
});
|
|
9508
9528
|
throw error;
|
|
9509
9529
|
}
|
|
9510
9530
|
const duration = BASE_DURATION2 * 2 ** i;
|
|
9511
9531
|
common.logger.debug({
|
|
9512
|
-
service: "
|
|
9513
|
-
msg: `Failed
|
|
9532
|
+
service: "rpc",
|
|
9533
|
+
msg: `Failed ${request.method} request, retrying after ${duration} milliseconds`,
|
|
9514
9534
|
error
|
|
9515
9535
|
});
|
|
9516
9536
|
await wait(duration);
|
|
@@ -9577,7 +9597,8 @@ function shouldRetry(error) {
|
|
|
9577
9597
|
// src/sync/index.ts
|
|
9578
9598
|
import {
|
|
9579
9599
|
hexToBigInt as hexToBigInt7,
|
|
9580
|
-
hexToNumber as hexToNumber7
|
|
9600
|
+
hexToNumber as hexToNumber7,
|
|
9601
|
+
toHex as toHex2
|
|
9581
9602
|
} from "viem";
|
|
9582
9603
|
|
|
9583
9604
|
// src/utils/order.ts
|
|
@@ -10262,12 +10283,17 @@ var syncDiagnostic = async ({
|
|
|
10262
10283
|
}) => {
|
|
10263
10284
|
const start2 = Math.min(...sources.map(({ filter }) => filter.fromBlock ?? 0));
|
|
10264
10285
|
const end = sources.some(({ filter }) => filter.toBlock === void 0) ? void 0 : Math.max(...sources.map(({ filter }) => filter.toBlock));
|
|
10265
|
-
const [remoteChainId, startBlock,
|
|
10286
|
+
const [remoteChainId, startBlock, latestBlock] = await Promise.all([
|
|
10266
10287
|
requestQueue.request({ method: "eth_chainId" }),
|
|
10267
10288
|
_eth_getBlockByNumber(requestQueue, { blockNumber: start2 }),
|
|
10268
|
-
end === void 0 ? void 0 : _eth_getBlockByNumber(requestQueue, { blockNumber: end }),
|
|
10269
10289
|
_eth_getBlockByNumber(requestQueue, { blockTag: "latest" })
|
|
10270
10290
|
]);
|
|
10291
|
+
const endBlock = end === void 0 ? void 0 : end > hexToBigInt7(latestBlock.number) ? {
|
|
10292
|
+
number: toHex2(end),
|
|
10293
|
+
hash: "0x",
|
|
10294
|
+
parentHash: "0x",
|
|
10295
|
+
timestamp: toHex2(maxCheckpoint.blockTimestamp)
|
|
10296
|
+
} : await _eth_getBlockByNumber(requestQueue, { blockNumber: end });
|
|
10271
10297
|
if (hexToNumber7(remoteChainId) !== network.chainId) {
|
|
10272
10298
|
common.logger.warn({
|
|
10273
10299
|
service: "sync",
|