@sentio/runtime 2.59.0-rc.4 → 2.59.0-rc.40
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/lib/{chunk-ZUTD563J.js → chunk-3SLKMZUX.js} +1020 -34
- package/lib/chunk-3SLKMZUX.js.map +1 -0
- package/lib/{chunk-QELD44EL.js → chunk-ELSE7PSY.js} +4363 -4316
- package/lib/{chunk-QELD44EL.js.map → chunk-ELSE7PSY.js.map} +1 -1
- package/lib/{chunk-BPGFX5S5.js → chunk-FDZMT76B.js} +2 -2
- package/lib/index.d.ts +631 -17
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +102 -94
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.d.ts +5 -6
- package/lib/service-worker.js +32 -43
- package/lib/service-worker.js.map +1 -1
- package/lib/test-processor.test.js.map +1 -1
- package/package.json +1 -1
- package/src/db-context.ts +2 -4
- package/src/full-service.ts +59 -13
- package/src/gen/processor/protos/processor.ts +1099 -125
- package/src/gen/service/common/protos/common.ts +304 -1
- package/src/index.ts +7 -0
- package/src/metrics.ts +8 -4
- package/src/plugin.ts +24 -0
- package/src/processor-runner.ts +10 -3
- package/src/service-manager.ts +56 -106
- package/src/service-worker.ts +33 -48
- package/src/service.ts +89 -46
- package/src/utils.ts +20 -4
- package/lib/chunk-ZUTD563J.js.map +0 -1
- /package/lib/{chunk-BPGFX5S5.js.map → chunk-FDZMT76B.js.map} +0 -0
package/lib/index.js
CHANGED
@@ -22,17 +22,18 @@ import {
|
|
22
22
|
getProvider,
|
23
23
|
makeEthCallKey,
|
24
24
|
mergeProcessResults,
|
25
|
+
mergeProcessResultsInPlace,
|
25
26
|
metricsStorage,
|
26
27
|
parseSemver,
|
27
28
|
processMetrics,
|
28
29
|
providerMetrics,
|
29
30
|
recordRuntimeInfo,
|
30
31
|
timeoutError
|
31
|
-
} from "./chunk-
|
32
|
+
} from "./chunk-ELSE7PSY.js";
|
32
33
|
import {
|
33
34
|
Plugin,
|
34
35
|
PluginManager
|
35
|
-
} from "./chunk-
|
36
|
+
} from "./chunk-3SLKMZUX.js";
|
36
37
|
|
37
38
|
// src/chain-config.ts
|
38
39
|
import("node:process").then((p) => p.stdout.write(""));
|
@@ -62,6 +63,7 @@ export {
|
|
62
63
|
getProvider,
|
63
64
|
makeEthCallKey,
|
64
65
|
mergeProcessResults,
|
66
|
+
mergeProcessResultsInPlace,
|
65
67
|
metricsStorage,
|
66
68
|
parseSemver,
|
67
69
|
processMetrics,
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/chain-config.ts","../src/index.ts"],"sourcesContent":["export interface ChainConfig {\n ChainID: string\n Https?: string[]\n ChainServer?: string\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './plugin.js'\nexport * from './state.js'\nexport * from './utils.js'\nexport * from './endpoints.js'\nexport * from './chain-config.js'\nexport * from './service.js'\nexport { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'\nexport * from './db-context.js'\nexport * from './provider.js'\nexport * from './metrics.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":"
|
1
|
+
{"version":3,"sources":["../src/chain-config.ts","../src/index.ts"],"sourcesContent":["export interface ChainConfig {\n ChainID: string\n Https?: string[]\n ChainServer?: string\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './plugin.js'\nexport * from './state.js'\nexport * from './utils.js'\nexport * from './endpoints.js'\nexport * from './chain-config.js'\nexport * from './service.js'\nexport { GLOBAL_CONFIG, type GlobalConfig } from './global-config.js'\nexport * from './db-context.js'\nexport * from './provider.js'\nexport * from './metrics.js'\nexport {\n type DataBinding,\n type Data_EthLog,\n type Data_EthBlock,\n type Data_EthTransaction,\n type Data_EthTrace\n} from './gen/processor/protos/processor.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;ACYrD,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
|
package/lib/processor-runner.js
CHANGED
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
} from "./chunk-6XHWJ2VS.js";
|
6
6
|
import {
|
7
7
|
setupLogger
|
8
|
-
} from "./chunk-
|
8
|
+
} from "./chunk-FDZMT76B.js";
|
9
9
|
import {
|
10
10
|
DiagConsoleLogger,
|
11
11
|
DiagLogLevel,
|
@@ -35,7 +35,6 @@ import {
|
|
35
35
|
isValidTraceId,
|
36
36
|
metrics,
|
37
37
|
parseSemver,
|
38
|
-
processMetrics,
|
39
38
|
propagation,
|
40
39
|
require_lib,
|
41
40
|
require_lib2,
|
@@ -44,13 +43,11 @@ import {
|
|
44
43
|
require_lodash,
|
45
44
|
require_src,
|
46
45
|
trace
|
47
|
-
} from "./chunk-
|
46
|
+
} from "./chunk-ELSE7PSY.js";
|
48
47
|
import {
|
49
48
|
ExecutionConfig,
|
50
|
-
HandlerType,
|
51
49
|
PluginManager,
|
52
50
|
ProcessConfigResponse,
|
53
|
-
ProcessResult,
|
54
51
|
ProcessorDefinition,
|
55
52
|
StartRequest,
|
56
53
|
__commonJS,
|
@@ -60,7 +57,7 @@ import {
|
|
60
57
|
__toCommonJS,
|
61
58
|
__toESM,
|
62
59
|
require_minimal2 as require_minimal
|
63
|
-
} from "./chunk-
|
60
|
+
} from "./chunk-3SLKMZUX.js";
|
64
61
|
|
65
62
|
// ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.25.1/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
|
66
63
|
// @__NO_SIDE_EFFECTS__
|
@@ -25956,6 +25953,7 @@ import { createRequire } from "module";
|
|
25956
25953
|
var import_fs_extra = __toESM(require_lib(), 1);
|
25957
25954
|
import path from "path";
|
25958
25955
|
import os from "os";
|
25956
|
+
import { createHash } from "crypto";
|
25959
25957
|
var require2 = createRequire(import.meta.url);
|
25960
25958
|
var FUEL_PROTO_UPDATE_VERSION = parseSemver("2.54.0-rc.7");
|
25961
25959
|
var FUEL_PROTO_NO_FUEL_TRANSACTION_AS_CALL_VERSION = parseSemver("2.55.0-rc.1");
|
@@ -25964,6 +25962,22 @@ var ETH_USE_RAW_VERSION = parseSemver("2.57.9-rc.12");
|
|
25964
25962
|
var PROCESSED_MOVE_EVENT_TX_HANDLER = new LRUCache({
|
25965
25963
|
max: 1e4
|
25966
25964
|
});
|
25965
|
+
var enableTxCache = process.env.ENABLE_PARSE_CACHE === "true";
|
25966
|
+
var PARSED_DATA_CACHE = new LRUCache({
|
25967
|
+
max: enableTxCache ? 5e3 : 1
|
25968
|
+
});
|
25969
|
+
function getParsedData(rawData) {
|
25970
|
+
if (!enableTxCache) {
|
25971
|
+
return JSON.parse(rawData);
|
25972
|
+
}
|
25973
|
+
const digest = createHash("md5").update(rawData).digest("hex");
|
25974
|
+
let parsedData = PARSED_DATA_CACHE.get(digest);
|
25975
|
+
if (!parsedData) {
|
25976
|
+
parsedData = JSON.parse(rawData);
|
25977
|
+
PARSED_DATA_CACHE.set(digest, parsedData);
|
25978
|
+
}
|
25979
|
+
return parsedData;
|
25980
|
+
}
|
25967
25981
|
function locatePackageJson(pkgId) {
|
25968
25982
|
const m = require2.resolve(pkgId);
|
25969
25983
|
let dir = path.dirname(m);
|
@@ -26064,17 +26078,31 @@ var FullProcessorServiceImpl = class {
|
|
26064
26078
|
const ethLog = dataBinding.data?.ethLog;
|
26065
26079
|
if (ethLog?.log == null && ethLog?.rawLog) {
|
26066
26080
|
ethLog.log = JSON.parse(ethLog.rawLog);
|
26067
|
-
|
26068
|
-
|
26069
|
-
|
26081
|
+
if (ethLog.rawTransaction) {
|
26082
|
+
ethLog.transaction = getParsedData(ethLog.rawTransaction);
|
26083
|
+
}
|
26084
|
+
if (ethLog.rawBlock) {
|
26085
|
+
ethLog.block = getParsedData(ethLog.rawBlock);
|
26086
|
+
}
|
26087
|
+
if (ethLog.rawTransactionReceipt) {
|
26088
|
+
ethLog.transactionReceipt = getParsedData(ethLog.rawTransactionReceipt);
|
26089
|
+
}
|
26070
26090
|
}
|
26071
26091
|
break;
|
26072
26092
|
case 11 /* ETH_TRANSACTION */:
|
26073
26093
|
const ethTx = dataBinding.data?.ethTransaction;
|
26074
26094
|
if (ethTx?.transaction == null && ethTx?.rawTransaction) {
|
26075
|
-
ethTx.transaction =
|
26076
|
-
|
26077
|
-
|
26095
|
+
ethTx.transaction = getParsedData(ethTx.rawTransaction);
|
26096
|
+
if (ethTx.rawBlock) {
|
26097
|
+
ethTx.block = getParsedData(ethTx.rawBlock);
|
26098
|
+
} else {
|
26099
|
+
ethTx.block = void 0;
|
26100
|
+
}
|
26101
|
+
if (ethTx.rawTransactionReceipt) {
|
26102
|
+
ethTx.transactionReceipt = getParsedData(ethTx.rawTransactionReceipt);
|
26103
|
+
} else {
|
26104
|
+
ethTx.transactionReceipt = void 0;
|
26105
|
+
}
|
26078
26106
|
}
|
26079
26107
|
break;
|
26080
26108
|
case 20 /* FUEL_TRANSACTION */:
|
@@ -26097,7 +26125,7 @@ var FullProcessorServiceImpl = class {
|
|
26097
26125
|
const aptEvent = dataBinding.data?.aptEvent;
|
26098
26126
|
if (aptEvent) {
|
26099
26127
|
if (isBeforeMoveUseRawVersion && aptEvent.rawTransaction) {
|
26100
|
-
const transaction =
|
26128
|
+
const transaction = getParsedData(aptEvent.rawTransaction);
|
26101
26129
|
const key = `${transaction.hash}-${dataBinding.handlerIds[0]}`;
|
26102
26130
|
if (PROCESSED_MOVE_EVENT_TX_HANDLER.has(key)) {
|
26103
26131
|
console.debug("skip binding", key);
|
@@ -26116,7 +26144,7 @@ var FullProcessorServiceImpl = class {
|
|
26116
26144
|
const aptCall = dataBinding.data?.aptCall;
|
26117
26145
|
if (aptCall) {
|
26118
26146
|
if (isBeforeMoveUseRawVersion && aptCall.rawTransaction) {
|
26119
|
-
aptCall.transaction =
|
26147
|
+
aptCall.transaction = getParsedData(aptCall.rawTransaction);
|
26120
26148
|
}
|
26121
26149
|
}
|
26122
26150
|
break;
|
@@ -26132,7 +26160,7 @@ var FullProcessorServiceImpl = class {
|
|
26132
26160
|
const suiEvent = dataBinding.data?.suiEvent;
|
26133
26161
|
if (suiEvent) {
|
26134
26162
|
if (isBeforeMoveUseRawVersion && suiEvent.rawTransaction) {
|
26135
|
-
const transaction =
|
26163
|
+
const transaction = getParsedData(suiEvent.rawTransaction);
|
26136
26164
|
const key = `${transaction.digest}-${dataBinding.handlerIds[0]}`;
|
26137
26165
|
if (PROCESSED_MOVE_EVENT_TX_HANDLER.has(key)) {
|
26138
26166
|
console.debug("skip binding", key);
|
@@ -26151,7 +26179,7 @@ var FullProcessorServiceImpl = class {
|
|
26151
26179
|
const suiCall = dataBinding.data?.suiCall;
|
26152
26180
|
if (suiCall) {
|
26153
26181
|
if (isBeforeMoveUseRawVersion && suiCall.rawTransaction) {
|
26154
|
-
suiCall.transaction =
|
26182
|
+
suiCall.transaction = getParsedData(suiCall.rawTransaction);
|
26155
26183
|
}
|
26156
26184
|
}
|
26157
26185
|
break;
|
@@ -26258,13 +26286,12 @@ import("node:process").then((p) => p.stdout.write(""));
|
|
26258
26286
|
// src/service-manager.ts
|
26259
26287
|
import { Piscina } from "piscina";
|
26260
26288
|
import { MessageChannel } from "node:worker_threads";
|
26261
|
-
var { process_binding_count, process_binding_time, process_binding_error } = processMetrics;
|
26262
26289
|
BigInt.prototype.toJSON = function() {
|
26263
26290
|
return this.toString();
|
26264
26291
|
};
|
26265
26292
|
var ServiceManager = class extends ProcessorServiceImpl {
|
26266
|
-
constructor(
|
26267
|
-
super(loader2, shutdownHandler);
|
26293
|
+
constructor(loader2, options2, shutdownHandler) {
|
26294
|
+
super(loader2, options2, shutdownHandler);
|
26268
26295
|
this.options = options2;
|
26269
26296
|
this.workerData.options = options2;
|
26270
26297
|
}
|
@@ -26290,58 +26317,47 @@ var ServiceManager = class extends ProcessorServiceImpl {
|
|
26290
26317
|
await this.pool?.destroy();
|
26291
26318
|
return await super.stop(request3, context2);
|
26292
26319
|
}
|
26293
|
-
|
26320
|
+
contexts = new Contexts();
|
26321
|
+
async handleRequests(requests, subject) {
|
26294
26322
|
if (!this.pool) {
|
26295
26323
|
await this.initPool();
|
26296
26324
|
}
|
26297
|
-
return this.pool.run(
|
26298
|
-
{ request: request3, workerPort: dbContext?.workerPort },
|
26299
|
-
{ transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
|
26300
|
-
);
|
26301
|
-
}
|
26302
|
-
contexts = new Contexts();
|
26303
|
-
async handleRequests(requests, subject) {
|
26304
26325
|
for await (const request3 of requests) {
|
26305
|
-
|
26306
|
-
|
26307
|
-
|
26308
|
-
|
26309
|
-
|
26310
|
-
|
26311
|
-
|
26312
|
-
|
26313
|
-
|
26314
|
-
|
26315
|
-
|
26316
|
-
const dbContext = this.contexts.new(request3.processId, subject);
|
26317
|
-
const start = Date.now();
|
26318
|
-
this.process(binding, dbContext).then(async (result) => {
|
26319
|
-
subject.next({
|
26320
|
-
result,
|
26321
|
-
processId: request3.processId
|
26322
|
-
});
|
26323
|
-
}).catch((e) => {
|
26324
|
-
dbContext.error(request3.processId, e);
|
26325
|
-
process_binding_error.add(1);
|
26326
|
-
}).finally(() => {
|
26327
|
-
const cost = Date.now() - start;
|
26328
|
-
process_binding_time.add(cost);
|
26329
|
-
this.contexts.delete(request3.processId);
|
26330
|
-
});
|
26331
|
-
}
|
26332
|
-
if (request3.dbResult) {
|
26333
|
-
const dbContext = this.contexts.get(request3.processId);
|
26334
|
-
try {
|
26335
|
-
dbContext?.result(request3.dbResult);
|
26336
|
-
} catch (e) {
|
26337
|
-
subject.error(new Error("db result error, process should stop"));
|
26338
|
-
}
|
26326
|
+
this.handleSingleRequest(request3, subject);
|
26327
|
+
}
|
26328
|
+
}
|
26329
|
+
async handleSingleRequest(request3, subject) {
|
26330
|
+
const processId = request3.processId;
|
26331
|
+
if (request3.binding) {
|
26332
|
+
const context2 = this.contexts.new(processId);
|
26333
|
+
context2.mainPort.on("message", (resp) => {
|
26334
|
+
subject.next(resp);
|
26335
|
+
if (resp.result) {
|
26336
|
+
this.contexts.delete(processId);
|
26339
26337
|
}
|
26340
|
-
}
|
26341
|
-
|
26338
|
+
});
|
26339
|
+
await this.pool.run(
|
26340
|
+
{ request: request3, workerPort: context2.workerPort, processId },
|
26341
|
+
{ transferList: [context2.workerPort] }
|
26342
|
+
);
|
26343
|
+
} else {
|
26344
|
+
const context2 = this.contexts.get(processId);
|
26345
|
+
if (!context2) {
|
26346
|
+
console.error("No context found for processId:", processId);
|
26347
|
+
throw new Error(`No context found for processId: ${processId}`);
|
26342
26348
|
}
|
26349
|
+
context2.sendRequest(request3);
|
26343
26350
|
}
|
26344
26351
|
}
|
26352
|
+
async process(processId, context2) {
|
26353
|
+
if (!this.pool) {
|
26354
|
+
await this.initPool();
|
26355
|
+
}
|
26356
|
+
return this.pool.run(
|
26357
|
+
{ workerPort: context2?.workerPort, processId },
|
26358
|
+
{ transferList: context2?.workerPort ? [context2?.workerPort] : [] }
|
26359
|
+
);
|
26360
|
+
}
|
26345
26361
|
async initPool() {
|
26346
26362
|
if (this.pool) {
|
26347
26363
|
await this.pool.close();
|
@@ -26366,8 +26382,12 @@ var Contexts = class {
|
|
26366
26382
|
get(processId) {
|
26367
26383
|
return this.contexts.get(processId);
|
26368
26384
|
}
|
26369
|
-
new(processId
|
26370
|
-
|
26385
|
+
new(processId) {
|
26386
|
+
let context2 = this.get(processId);
|
26387
|
+
if (context2) {
|
26388
|
+
return context2;
|
26389
|
+
}
|
26390
|
+
context2 = new ChannelContext(processId);
|
26371
26391
|
this.contexts.set(processId, context2);
|
26372
26392
|
return context2;
|
26373
26393
|
}
|
@@ -26376,21 +26396,17 @@ var Contexts = class {
|
|
26376
26396
|
context2?.close();
|
26377
26397
|
this.contexts.delete(processId);
|
26378
26398
|
}
|
26399
|
+
has(processId) {
|
26400
|
+
return this.contexts.has(processId);
|
26401
|
+
}
|
26379
26402
|
};
|
26380
|
-
var
|
26381
|
-
constructor(
|
26382
|
-
this.subject = subject;
|
26403
|
+
var ChannelContext = class {
|
26404
|
+
constructor(processId) {
|
26383
26405
|
this.processId = processId;
|
26384
|
-
this.mainPort.on("message", (req) => {
|
26385
|
-
subject.next({
|
26386
|
-
...req,
|
26387
|
-
processId
|
26388
|
-
});
|
26389
|
-
});
|
26390
26406
|
}
|
26391
26407
|
channel = new MessageChannel();
|
26392
|
-
sendRequest(request3
|
26393
|
-
|
26408
|
+
sendRequest(request3) {
|
26409
|
+
this.mainPort.postMessage(request3);
|
26394
26410
|
}
|
26395
26411
|
get workerPort() {
|
26396
26412
|
return this.channel.port2;
|
@@ -26398,24 +26414,9 @@ var ChannelStoreContext = class {
|
|
26398
26414
|
get mainPort() {
|
26399
26415
|
return this.channel.port1;
|
26400
26416
|
}
|
26401
|
-
result(dbResult) {
|
26402
|
-
this.mainPort.postMessage(dbResult);
|
26403
|
-
}
|
26404
26417
|
close() {
|
26405
26418
|
this.mainPort.close();
|
26406
26419
|
}
|
26407
|
-
error(processId, e) {
|
26408
|
-
console.error("process error", processId, e);
|
26409
|
-
const errorResult = ProcessResult.create({
|
26410
|
-
states: {
|
26411
|
-
error: e?.toString()
|
26412
|
-
}
|
26413
|
-
});
|
26414
|
-
this.subject.next({
|
26415
|
-
result: errorResult,
|
26416
|
-
processId
|
26417
|
-
});
|
26418
|
-
}
|
26419
26420
|
};
|
26420
26421
|
import("node:process").then((p) => p.stdout.write(""));
|
26421
26422
|
|
@@ -26445,7 +26446,14 @@ var optionDefinitions = [
|
|
26445
26446
|
{ name: "debug", type: Boolean, defaultValue: false },
|
26446
26447
|
{ name: "otlp-debug", type: Boolean, defaultValue: false },
|
26447
26448
|
{ name: "start-action-server", type: Boolean, defaultValue: false },
|
26448
|
-
{ name: "worker", type: Number, defaultValue: workerNum }
|
26449
|
+
{ name: "worker", type: Number, defaultValue: workerNum },
|
26450
|
+
{ name: "process-timeout", type: Number, defaultValue: 60 },
|
26451
|
+
{ name: "worker-timeout", type: Number, defaultValue: 60 },
|
26452
|
+
{
|
26453
|
+
name: "enable-partition",
|
26454
|
+
type: Boolean,
|
26455
|
+
defaultValue: process.env["SENTIO_ENABLE_BINDING_DATA_PARTITION"] === "true"
|
26456
|
+
}
|
26449
26457
|
];
|
26450
26458
|
var options = command_line_args_default(optionDefinitions, { partial: true });
|
26451
26459
|
var logLevel = process.env["LOG_LEVEL"]?.toLowerCase();
|
@@ -26472,9 +26480,9 @@ if (options["start-action-server"]) {
|
|
26472
26480
|
"grpc.default_compression_algorithm": import_grpc_js.compressionAlgorithms.gzip
|
26473
26481
|
}).use((0, import_nice_grpc_opentelemetry.openTelemetryServerMiddleware)()).use(import_nice_grpc_error_details.errorDetailsServerMiddleware);
|
26474
26482
|
if (options.worker > 1) {
|
26475
|
-
baseService = new ServiceManager(
|
26483
|
+
baseService = new ServiceManager(loader, options, server.shutdown);
|
26476
26484
|
} else {
|
26477
|
-
baseService = new ProcessorServiceImpl(loader, server.shutdown);
|
26485
|
+
baseService = new ProcessorServiceImpl(loader, options, server.shutdown);
|
26478
26486
|
}
|
26479
26487
|
const service = new FullProcessorServiceImpl(baseService);
|
26480
26488
|
server.add(ProcessorDefinition, service);
|