ponder 0.8.8 → 0.8.10
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 +61 -27
- package/dist/bin/ponder.js.map +1 -1
- package/package.json +1 -1
- package/src/database/index.ts +33 -21
- package/src/indexing-store/historical.ts +1 -0
- package/src/sync/index.ts +14 -4
- package/src/utils/pg.ts +34 -4
package/dist/bin/ponder.js
CHANGED
|
@@ -3922,13 +3922,28 @@ var ReadonlyClient = class extends pg.Client {
|
|
|
3922
3922
|
}
|
|
3923
3923
|
}
|
|
3924
3924
|
};
|
|
3925
|
-
function
|
|
3926
|
-
return
|
|
3925
|
+
function createErrorHandler(logger) {
|
|
3926
|
+
return (error) => {
|
|
3927
|
+
const client = error.client;
|
|
3928
|
+
const pid = client?.processID ?? "unknown";
|
|
3929
|
+
const applicationName = client?.connectionParameters?.application_name ?? "unknown";
|
|
3930
|
+
logger.error({
|
|
3931
|
+
service: "postgres",
|
|
3932
|
+
msg: `Pool error (application_name: ${applicationName}, pid: ${pid})`,
|
|
3933
|
+
error
|
|
3934
|
+
});
|
|
3935
|
+
};
|
|
3936
|
+
}
|
|
3937
|
+
function createPool(config, logger) {
|
|
3938
|
+
const pool = new pg.Pool({
|
|
3927
3939
|
// https://stackoverflow.com/questions/59155572/how-to-set-query-timeout-in-relation-to-statement-timeout
|
|
3928
3940
|
statement_timeout: 2 * 60 * 1e3,
|
|
3929
3941
|
// 2 minutes
|
|
3930
3942
|
...config
|
|
3931
3943
|
});
|
|
3944
|
+
const onError2 = createErrorHandler(logger);
|
|
3945
|
+
pool.on("error", onError2);
|
|
3946
|
+
return pool;
|
|
3932
3947
|
}
|
|
3933
3948
|
|
|
3934
3949
|
// src/utils/pglite.ts
|
|
@@ -4108,28 +4123,40 @@ var createDatabase = ({
|
|
|
4108
4123
|
);
|
|
4109
4124
|
const [readonlyMax, userMax, syncMax] = common.options.command === "serve" ? [preBuild.databaseConfig.poolConfig.max - internalMax, 0, 0] : [equalMax, equalMax, equalMax];
|
|
4110
4125
|
driver = {
|
|
4111
|
-
internal: createPool(
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4132
|
-
|
|
4126
|
+
internal: createPool(
|
|
4127
|
+
{
|
|
4128
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4129
|
+
application_name: `${preBuild.namespace}_internal`,
|
|
4130
|
+
max: internalMax,
|
|
4131
|
+
statement_timeout: 10 * 60 * 1e3
|
|
4132
|
+
// 10 minutes to accommodate slow sync store migrations.
|
|
4133
|
+
},
|
|
4134
|
+
common.logger
|
|
4135
|
+
),
|
|
4136
|
+
user: createPool(
|
|
4137
|
+
{
|
|
4138
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4139
|
+
application_name: `${preBuild.namespace}_user`,
|
|
4140
|
+
max: userMax
|
|
4141
|
+
},
|
|
4142
|
+
common.logger
|
|
4143
|
+
),
|
|
4144
|
+
readonly: createPool(
|
|
4145
|
+
{
|
|
4146
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4147
|
+
application_name: `${preBuild.namespace}_readonly`,
|
|
4148
|
+
max: readonlyMax
|
|
4149
|
+
},
|
|
4150
|
+
common.logger
|
|
4151
|
+
),
|
|
4152
|
+
sync: createPool(
|
|
4153
|
+
{
|
|
4154
|
+
...preBuild.databaseConfig.poolConfig,
|
|
4155
|
+
application_name: "ponder_sync",
|
|
4156
|
+
max: syncMax
|
|
4157
|
+
},
|
|
4158
|
+
common.logger
|
|
4159
|
+
)
|
|
4133
4160
|
};
|
|
4134
4161
|
qb = {
|
|
4135
4162
|
internal: new HeadlessKysely({
|
|
@@ -5402,6 +5429,7 @@ ${prettyPrint(key)}`
|
|
|
5402
5429
|
await database.createTriggers();
|
|
5403
5430
|
await indexingStore.flush();
|
|
5404
5431
|
await database.removeTriggers();
|
|
5432
|
+
isDatabaseEmpty = false;
|
|
5405
5433
|
const query2 = { sql: _sql, params, typings };
|
|
5406
5434
|
const res = await database.qb.user.wrap({ method: "sql" }, async () => {
|
|
5407
5435
|
try {
|
|
@@ -9549,7 +9577,8 @@ function shouldRetry(error) {
|
|
|
9549
9577
|
// src/sync/index.ts
|
|
9550
9578
|
import {
|
|
9551
9579
|
hexToBigInt as hexToBigInt7,
|
|
9552
|
-
hexToNumber as hexToNumber7
|
|
9580
|
+
hexToNumber as hexToNumber7,
|
|
9581
|
+
toHex as toHex2
|
|
9553
9582
|
} from "viem";
|
|
9554
9583
|
|
|
9555
9584
|
// src/utils/order.ts
|
|
@@ -10234,12 +10263,17 @@ var syncDiagnostic = async ({
|
|
|
10234
10263
|
}) => {
|
|
10235
10264
|
const start2 = Math.min(...sources.map(({ filter }) => filter.fromBlock ?? 0));
|
|
10236
10265
|
const end = sources.some(({ filter }) => filter.toBlock === void 0) ? void 0 : Math.max(...sources.map(({ filter }) => filter.toBlock));
|
|
10237
|
-
const [remoteChainId, startBlock,
|
|
10266
|
+
const [remoteChainId, startBlock, latestBlock] = await Promise.all([
|
|
10238
10267
|
requestQueue.request({ method: "eth_chainId" }),
|
|
10239
10268
|
_eth_getBlockByNumber(requestQueue, { blockNumber: start2 }),
|
|
10240
|
-
end === void 0 ? void 0 : _eth_getBlockByNumber(requestQueue, { blockNumber: end }),
|
|
10241
10269
|
_eth_getBlockByNumber(requestQueue, { blockTag: "latest" })
|
|
10242
10270
|
]);
|
|
10271
|
+
const endBlock = end === void 0 ? void 0 : end > hexToBigInt7(latestBlock.number) ? {
|
|
10272
|
+
number: toHex2(end),
|
|
10273
|
+
hash: "0x",
|
|
10274
|
+
parentHash: "0x",
|
|
10275
|
+
timestamp: toHex2(maxCheckpoint.blockTimestamp)
|
|
10276
|
+
} : await _eth_getBlockByNumber(requestQueue, { blockNumber: end });
|
|
10243
10277
|
if (hexToNumber7(remoteChainId) !== network.chainId) {
|
|
10244
10278
|
common.logger.warn({
|
|
10245
10279
|
service: "sync",
|