@sentio/runtime 2.59.0-rc.3 → 2.59.0-rc.30

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/index.js CHANGED
@@ -28,11 +28,11 @@ import {
28
28
  providerMetrics,
29
29
  recordRuntimeInfo,
30
30
  timeoutError
31
- } from "./chunk-QELD44EL.js";
31
+ } from "./chunk-X2VTMTYL.js";
32
32
  import {
33
33
  Plugin,
34
34
  PluginManager
35
- } from "./chunk-ZUTD563J.js";
35
+ } from "./chunk-FO2V2K7T.js";
36
36
 
37
37
  // src/chain-config.ts
38
38
  import("node:process").then((p) => p.stdout.write(""));
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;ACKrD,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;","names":[]}
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":[]}
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-6XHWJ2VS.js";
6
6
  import {
7
7
  setupLogger
8
- } from "./chunk-BPGFX5S5.js";
8
+ } from "./chunk-CPLWSUD7.js";
9
9
  import {
10
10
  DiagConsoleLogger,
11
11
  DiagLogLevel,
@@ -44,7 +44,7 @@ import {
44
44
  require_lodash,
45
45
  require_src,
46
46
  trace
47
- } from "./chunk-QELD44EL.js";
47
+ } from "./chunk-X2VTMTYL.js";
48
48
  import {
49
49
  ExecutionConfig,
50
50
  HandlerType,
@@ -60,7 +60,7 @@ import {
60
60
  __toCommonJS,
61
61
  __toESM,
62
62
  require_minimal2 as require_minimal
63
- } from "./chunk-ZUTD563J.js";
63
+ } from "./chunk-FO2V2K7T.js";
64
64
 
65
65
  // ../../node_modules/.pnpm/@opentelemetry+semantic-conventions@1.25.1/node_modules/@opentelemetry/semantic-conventions/build/esm/internal/utils.js
66
66
  // @__NO_SIDE_EFFECTS__
@@ -12966,19 +12966,19 @@ var require_root = __commonJS({
12966
12966
  return Span2;
12967
12967
  }();
12968
12968
  v1.Status = function() {
12969
- function Status(properties) {
12969
+ function Status2(properties) {
12970
12970
  if (properties) {
12971
12971
  for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
12972
12972
  if (properties[keys[i]] != null)
12973
12973
  this[keys[i]] = properties[keys[i]];
12974
12974
  }
12975
12975
  }
12976
- Status.prototype.message = null;
12977
- Status.prototype.code = null;
12978
- Status.create = function create(properties) {
12979
- return new Status(properties);
12976
+ Status2.prototype.message = null;
12977
+ Status2.prototype.code = null;
12978
+ Status2.create = function create(properties) {
12979
+ return new Status2(properties);
12980
12980
  };
12981
- Status.encode = function encode(message, writer) {
12981
+ Status2.encode = function encode(message, writer) {
12982
12982
  if (!writer)
12983
12983
  writer = $Writer.create();
12984
12984
  if (message.message != null && Object.hasOwnProperty.call(message, "message"))
@@ -12993,10 +12993,10 @@ var require_root = __commonJS({
12993
12993
  ).int32(message.code);
12994
12994
  return writer;
12995
12995
  };
12996
- Status.encodeDelimited = function encodeDelimited(message, writer) {
12996
+ Status2.encodeDelimited = function encodeDelimited(message, writer) {
12997
12997
  return this.encode(message, writer).ldelim();
12998
12998
  };
12999
- Status.decode = function decode(reader, length) {
12999
+ Status2.decode = function decode(reader, length) {
13000
13000
  if (!(reader instanceof $Reader))
13001
13001
  reader = $Reader.create(reader);
13002
13002
  var end = length === void 0 ? reader.len : reader.pos + length, message = new $root.opentelemetry.proto.trace.v1.Status();
@@ -13018,12 +13018,12 @@ var require_root = __commonJS({
13018
13018
  }
13019
13019
  return message;
13020
13020
  };
13021
- Status.decodeDelimited = function decodeDelimited(reader) {
13021
+ Status2.decodeDelimited = function decodeDelimited(reader) {
13022
13022
  if (!(reader instanceof $Reader))
13023
13023
  reader = new $Reader(reader);
13024
13024
  return this.decode(reader, reader.uint32());
13025
13025
  };
13026
- Status.verify = function verify(message) {
13026
+ Status2.verify = function verify(message) {
13027
13027
  if (typeof message !== "object" || message === null)
13028
13028
  return "object expected";
13029
13029
  if (message.message != null && message.hasOwnProperty("message")) {
@@ -13041,7 +13041,7 @@ var require_root = __commonJS({
13041
13041
  }
13042
13042
  return null;
13043
13043
  };
13044
- Status.fromObject = function fromObject(object) {
13044
+ Status2.fromObject = function fromObject(object) {
13045
13045
  if (object instanceof $root.opentelemetry.proto.trace.v1.Status)
13046
13046
  return object;
13047
13047
  var message = new $root.opentelemetry.proto.trace.v1.Status();
@@ -13069,7 +13069,7 @@ var require_root = __commonJS({
13069
13069
  }
13070
13070
  return message;
13071
13071
  };
13072
- Status.toObject = function toObject(message, options2) {
13072
+ Status2.toObject = function toObject(message, options2) {
13073
13073
  if (!options2)
13074
13074
  options2 = {};
13075
13075
  var object = {};
@@ -13083,23 +13083,23 @@ var require_root = __commonJS({
13083
13083
  object.code = options2.enums === String ? $root.opentelemetry.proto.trace.v1.Status.StatusCode[message.code] === void 0 ? message.code : $root.opentelemetry.proto.trace.v1.Status.StatusCode[message.code] : message.code;
13084
13084
  return object;
13085
13085
  };
13086
- Status.prototype.toJSON = function toJSON() {
13086
+ Status2.prototype.toJSON = function toJSON() {
13087
13087
  return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
13088
13088
  };
13089
- Status.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
13089
+ Status2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
13090
13090
  if (typeUrlPrefix === void 0) {
13091
13091
  typeUrlPrefix = "type.googleapis.com";
13092
13092
  }
13093
13093
  return typeUrlPrefix + "/opentelemetry.proto.trace.v1.Status";
13094
13094
  };
13095
- Status.StatusCode = function() {
13095
+ Status2.StatusCode = function() {
13096
13096
  var valuesById = {}, values = Object.create(valuesById);
13097
13097
  values[valuesById[0] = "STATUS_CODE_UNSET"] = 0;
13098
13098
  values[valuesById[1] = "STATUS_CODE_OK"] = 1;
13099
13099
  values[valuesById[2] = "STATUS_CODE_ERROR"] = 2;
13100
13100
  return values;
13101
13101
  }();
13102
- return Status;
13102
+ return Status2;
13103
13103
  }();
13104
13104
  return v1;
13105
13105
  }();
@@ -25945,7 +25945,7 @@ function commandLineArgs(optionDefinitions2, options2) {
25945
25945
  var command_line_args_default = commandLineArgs;
25946
25946
 
25947
25947
  // src/processor-runner.ts
25948
- var import_nice_grpc = __toESM(require_lib3(), 1);
25948
+ var import_nice_grpc2 = __toESM(require_lib3(), 1);
25949
25949
  var import_nice_grpc_error_details = __toESM(require_lib4(), 1);
25950
25950
  var import_nice_grpc_opentelemetry = __toESM(require_lib5(), 1);
25951
25951
  import http2 from "http";
@@ -25956,6 +25956,7 @@ import { createRequire } from "module";
25956
25956
  var import_fs_extra = __toESM(require_lib(), 1);
25957
25957
  import path from "path";
25958
25958
  import os from "os";
25959
+ import { createHash } from "crypto";
25959
25960
  var require2 = createRequire(import.meta.url);
25960
25961
  var FUEL_PROTO_UPDATE_VERSION = parseSemver("2.54.0-rc.7");
25961
25962
  var FUEL_PROTO_NO_FUEL_TRANSACTION_AS_CALL_VERSION = parseSemver("2.55.0-rc.1");
@@ -25964,6 +25965,22 @@ var ETH_USE_RAW_VERSION = parseSemver("2.57.9-rc.12");
25964
25965
  var PROCESSED_MOVE_EVENT_TX_HANDLER = new LRUCache({
25965
25966
  max: 1e4
25966
25967
  });
25968
+ var enableTxCache = process.env.ENABLE_PARSE_CACHE === "true";
25969
+ var PARSED_DATA_CACHE = new LRUCache({
25970
+ max: enableTxCache ? 5e3 : 1
25971
+ });
25972
+ function getParsedData(rawData) {
25973
+ if (!enableTxCache) {
25974
+ return JSON.parse(rawData);
25975
+ }
25976
+ const digest = createHash("md5").update(rawData).digest("hex");
25977
+ let parsedData = PARSED_DATA_CACHE.get(digest);
25978
+ if (!parsedData) {
25979
+ parsedData = JSON.parse(rawData);
25980
+ PARSED_DATA_CACHE.set(digest, parsedData);
25981
+ }
25982
+ return parsedData;
25983
+ }
25967
25984
  function locatePackageJson(pkgId) {
25968
25985
  const m = require2.resolve(pkgId);
25969
25986
  let dir = path.dirname(m);
@@ -26064,17 +26081,31 @@ var FullProcessorServiceImpl = class {
26064
26081
  const ethLog = dataBinding.data?.ethLog;
26065
26082
  if (ethLog?.log == null && ethLog?.rawLog) {
26066
26083
  ethLog.log = JSON.parse(ethLog.rawLog);
26067
- ethLog.transaction = ethLog.rawTransaction ? JSON.parse(ethLog.rawTransaction) : void 0;
26068
- ethLog.block = ethLog.rawBlock ? JSON.parse(ethLog.rawBlock) : void 0;
26069
- ethLog.transactionReceipt = ethLog.rawTransactionReceipt ? JSON.parse(ethLog.rawTransactionReceipt) : void 0;
26084
+ if (ethLog.rawTransaction) {
26085
+ ethLog.transaction = getParsedData(ethLog.rawTransaction);
26086
+ }
26087
+ if (ethLog.rawBlock) {
26088
+ ethLog.block = getParsedData(ethLog.rawBlock);
26089
+ }
26090
+ if (ethLog.rawTransactionReceipt) {
26091
+ ethLog.transactionReceipt = getParsedData(ethLog.rawTransactionReceipt);
26092
+ }
26070
26093
  }
26071
26094
  break;
26072
26095
  case 11 /* ETH_TRANSACTION */:
26073
26096
  const ethTx = dataBinding.data?.ethTransaction;
26074
26097
  if (ethTx?.transaction == null && ethTx?.rawTransaction) {
26075
- ethTx.transaction = JSON.parse(ethTx.rawTransaction);
26076
- ethTx.block = ethTx.rawBlock ? JSON.parse(ethTx.rawBlock) : void 0;
26077
- ethTx.transactionReceipt = ethTx.rawTransactionReceipt ? JSON.parse(ethTx.rawTransactionReceipt) : void 0;
26098
+ ethTx.transaction = getParsedData(ethTx.rawTransaction);
26099
+ if (ethTx.rawBlock) {
26100
+ ethTx.block = getParsedData(ethTx.rawBlock);
26101
+ } else {
26102
+ ethTx.block = void 0;
26103
+ }
26104
+ if (ethTx.rawTransactionReceipt) {
26105
+ ethTx.transactionReceipt = getParsedData(ethTx.rawTransactionReceipt);
26106
+ } else {
26107
+ ethTx.transactionReceipt = void 0;
26108
+ }
26078
26109
  }
26079
26110
  break;
26080
26111
  case 20 /* FUEL_TRANSACTION */:
@@ -26097,7 +26128,7 @@ var FullProcessorServiceImpl = class {
26097
26128
  const aptEvent = dataBinding.data?.aptEvent;
26098
26129
  if (aptEvent) {
26099
26130
  if (isBeforeMoveUseRawVersion && aptEvent.rawTransaction) {
26100
- const transaction = JSON.parse(aptEvent.rawTransaction);
26131
+ const transaction = getParsedData(aptEvent.rawTransaction);
26101
26132
  const key = `${transaction.hash}-${dataBinding.handlerIds[0]}`;
26102
26133
  if (PROCESSED_MOVE_EVENT_TX_HANDLER.has(key)) {
26103
26134
  console.debug("skip binding", key);
@@ -26116,7 +26147,7 @@ var FullProcessorServiceImpl = class {
26116
26147
  const aptCall = dataBinding.data?.aptCall;
26117
26148
  if (aptCall) {
26118
26149
  if (isBeforeMoveUseRawVersion && aptCall.rawTransaction) {
26119
- aptCall.transaction = JSON.parse(aptCall.rawTransaction);
26150
+ aptCall.transaction = getParsedData(aptCall.rawTransaction);
26120
26151
  }
26121
26152
  }
26122
26153
  break;
@@ -26132,7 +26163,7 @@ var FullProcessorServiceImpl = class {
26132
26163
  const suiEvent = dataBinding.data?.suiEvent;
26133
26164
  if (suiEvent) {
26134
26165
  if (isBeforeMoveUseRawVersion && suiEvent.rawTransaction) {
26135
- const transaction = JSON.parse(suiEvent.rawTransaction);
26166
+ const transaction = getParsedData(suiEvent.rawTransaction);
26136
26167
  const key = `${transaction.digest}-${dataBinding.handlerIds[0]}`;
26137
26168
  if (PROCESSED_MOVE_EVENT_TX_HANDLER.has(key)) {
26138
26169
  console.debug("skip binding", key);
@@ -26151,7 +26182,7 @@ var FullProcessorServiceImpl = class {
26151
26182
  const suiCall = dataBinding.data?.suiCall;
26152
26183
  if (suiCall) {
26153
26184
  if (isBeforeMoveUseRawVersion && suiCall.rawTransaction) {
26154
- suiCall.transaction = JSON.parse(suiCall.rawTransaction);
26185
+ suiCall.transaction = getParsedData(suiCall.rawTransaction);
26155
26186
  }
26156
26187
  }
26157
26188
  break;
@@ -26256,6 +26287,7 @@ var ActionServer = class {
26256
26287
  import("node:process").then((p) => p.stdout.write(""));
26257
26288
 
26258
26289
  // src/service-manager.ts
26290
+ var import_nice_grpc = __toESM(require_lib3(), 1);
26259
26291
  import { Piscina } from "piscina";
26260
26292
  import { MessageChannel } from "node:worker_threads";
26261
26293
  var { process_binding_count, process_binding_time, process_binding_error } = processMetrics;
@@ -26290,18 +26322,10 @@ var ServiceManager = class extends ProcessorServiceImpl {
26290
26322
  await this.pool?.destroy();
26291
26323
  return await super.stop(request3, context2);
26292
26324
  }
26293
- async process(request3, dbContext) {
26294
- if (!this.pool) {
26295
- await this.initPool();
26296
- }
26297
- return this.pool.run(
26298
- { request: request3, workerPort: dbContext?.workerPort },
26299
- { transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
26300
- );
26301
- }
26302
26325
  contexts = new Contexts();
26303
26326
  async handleRequests(requests, subject) {
26304
26327
  for await (const request3 of requests) {
26328
+ let lastBinding = void 0;
26305
26329
  try {
26306
26330
  if (request3.binding) {
26307
26331
  process_binding_count.add(1);
@@ -26312,22 +26336,23 @@ var ServiceManager = class extends ProcessorServiceImpl {
26312
26336
  });
26313
26337
  continue;
26314
26338
  }
26315
- const binding = request3.binding;
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
26339
+ if (this.enablePartition) {
26340
+ PluginManager.INSTANCE.partition(request3.binding).then((partitions) => {
26341
+ subject.next({
26342
+ processId: request3.processId,
26343
+ partitions
26344
+ });
26322
26345
  });
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
- });
26346
+ lastBinding = request3.binding;
26347
+ } else {
26348
+ this.doProcess(request3.processId, request3.binding, subject);
26349
+ }
26350
+ }
26351
+ if (request3.start) {
26352
+ if (!lastBinding) {
26353
+ throw new import_nice_grpc.ServerError(import_nice_grpc.Status.INVALID_ARGUMENT, "start request received without binding");
26354
+ }
26355
+ this.doProcess(request3.processId, lastBinding, subject);
26331
26356
  }
26332
26357
  if (request3.dbResult) {
26333
26358
  const dbContext = this.contexts.get(request3.processId);
@@ -26342,6 +26367,32 @@ var ServiceManager = class extends ProcessorServiceImpl {
26342
26367
  }
26343
26368
  }
26344
26369
  }
26370
+ doProcess(processId, binding, subject) {
26371
+ const dbContext = this.contexts.new(processId, subject);
26372
+ const start = Date.now();
26373
+ this.process(binding, dbContext).then(async (result) => {
26374
+ subject.next({
26375
+ result,
26376
+ processId
26377
+ });
26378
+ }).catch((e) => {
26379
+ dbContext.error(processId, e);
26380
+ process_binding_error.add(1);
26381
+ }).finally(() => {
26382
+ const cost = Date.now() - start;
26383
+ process_binding_time.add(cost);
26384
+ this.contexts.delete(processId);
26385
+ });
26386
+ }
26387
+ async process(request3, dbContext) {
26388
+ if (!this.pool) {
26389
+ await this.initPool();
26390
+ }
26391
+ return this.pool.run(
26392
+ { request: request3, workerPort: dbContext?.workerPort },
26393
+ { transferList: dbContext?.workerPort ? [dbContext?.workerPort] : [] }
26394
+ );
26395
+ }
26345
26396
  async initPool() {
26346
26397
  if (this.pool) {
26347
26398
  await this.pool.close();
@@ -26466,7 +26517,7 @@ if (options["start-action-server"]) {
26466
26517
  server = new ActionServer(loader);
26467
26518
  server.listen(options.port);
26468
26519
  } else {
26469
- server = (0, import_nice_grpc.createServer)({
26520
+ server = (0, import_nice_grpc2.createServer)({
26470
26521
  "grpc.max_send_message_length": 768 * 1024 * 1024,
26471
26522
  "grpc.max_receive_message_length": 768 * 1024 * 1024,
26472
26523
  "grpc.default_compression_algorithm": import_grpc_js.compressionAlgorithms.gzip