@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/{chunk-BPGFX5S5.js → chunk-CPLWSUD7.js} +2 -2
- package/lib/{chunk-ZUTD563J.js → chunk-FO2V2K7T.js} +1020 -34
- package/lib/chunk-FO2V2K7T.js.map +1 -0
- package/lib/{chunk-QELD44EL.js → chunk-X2VTMTYL.js} +52 -24
- package/lib/{chunk-QELD44EL.js.map → chunk-X2VTMTYL.js.map} +1 -1
- package/lib/index.d.ts +627 -16
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/processor-runner.js +106 -55
- package/lib/processor-runner.js.map +1 -1
- package/lib/service-worker.js +3 -3
- package/package.json +1 -1
- 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/service-manager.ts +51 -30
- package/src/service.ts +53 -21
- package/src/utils.ts +1 -0
- package/lib/chunk-ZUTD563J.js.map +0 -1
- /package/lib/{chunk-BPGFX5S5.js.map → chunk-CPLWSUD7.js.map} +0 -0
package/lib/service-worker.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createRequire as createRequireShim } from 'module'; const require = createRequireShim(import.meta.url);
|
2
2
|
import {
|
3
3
|
setupLogger
|
4
|
-
} from "./chunk-
|
4
|
+
} from "./chunk-CPLWSUD7.js";
|
5
5
|
import {
|
6
6
|
AbstractStoreContext,
|
7
7
|
configureEndpoints,
|
@@ -10,12 +10,12 @@ import {
|
|
10
10
|
recordRuntimeInfo,
|
11
11
|
require_lib3 as require_lib,
|
12
12
|
require_lib4 as require_lib2
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-X2VTMTYL.js";
|
14
14
|
import {
|
15
15
|
PluginManager,
|
16
16
|
ProcessConfigResponse,
|
17
17
|
__toESM
|
18
|
-
} from "./chunk-
|
18
|
+
} from "./chunk-FO2V2K7T.js";
|
19
19
|
|
20
20
|
// src/service-worker.ts
|
21
21
|
var import_nice_grpc = __toESM(require_lib(), 1);
|
package/package.json
CHANGED
package/src/full-service.ts
CHANGED
@@ -21,6 +21,7 @@ import os from 'os'
|
|
21
21
|
import { GLOBAL_CONFIG } from './global-config.js'
|
22
22
|
import { compareSemver, parseSemver, Semver } from './utils.js'
|
23
23
|
import { LRUCache } from 'lru-cache'
|
24
|
+
import { createHash } from 'crypto'
|
24
25
|
|
25
26
|
const require = createRequire(import.meta.url)
|
26
27
|
|
@@ -35,6 +36,37 @@ const PROCESSED_MOVE_EVENT_TX_HANDLER = new LRUCache<string, boolean>({
|
|
35
36
|
max: 10000
|
36
37
|
})
|
37
38
|
|
39
|
+
const enableTxCache = process.env.ENABLE_PARSE_CACHE === 'true'
|
40
|
+
|
41
|
+
// Cache for parsed JSON data
|
42
|
+
const PARSED_DATA_CACHE = new LRUCache<string, any>({
|
43
|
+
max: enableTxCache ? 5000 : 1
|
44
|
+
})
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Gets parsed JSON data from a string, using a cache to avoid repeated parsing
|
48
|
+
* @param rawData The raw string data to parse
|
49
|
+
* @returns The parsed JSON object
|
50
|
+
*/
|
51
|
+
function getParsedData(rawData: string): any {
|
52
|
+
if (!enableTxCache) {
|
53
|
+
return JSON.parse(rawData)
|
54
|
+
}
|
55
|
+
|
56
|
+
// Create a digest of the raw data for cache key
|
57
|
+
const digest = createHash('md5').update(rawData).digest('hex')
|
58
|
+
|
59
|
+
// Check if we already have this data parsed
|
60
|
+
let parsedData = PARSED_DATA_CACHE.get(digest)
|
61
|
+
if (!parsedData) {
|
62
|
+
// Parse and cache the data
|
63
|
+
parsedData = JSON.parse(rawData)
|
64
|
+
PARSED_DATA_CACHE.set(digest, parsedData)
|
65
|
+
}
|
66
|
+
|
67
|
+
return parsedData
|
68
|
+
}
|
69
|
+
|
38
70
|
function locatePackageJson(pkgId: string) {
|
39
71
|
const m = require.resolve(pkgId)
|
40
72
|
|
@@ -173,19 +205,32 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
173
205
|
const ethLog = dataBinding.data?.ethLog
|
174
206
|
if (ethLog?.log == null && ethLog?.rawLog) {
|
175
207
|
ethLog.log = JSON.parse(ethLog.rawLog)
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
208
|
+
|
209
|
+
if (ethLog.rawTransaction) {
|
210
|
+
ethLog.transaction = getParsedData(ethLog.rawTransaction)
|
211
|
+
}
|
212
|
+
if (ethLog.rawBlock) {
|
213
|
+
ethLog.block = getParsedData(ethLog.rawBlock)
|
214
|
+
}
|
215
|
+
if (ethLog.rawTransactionReceipt) {
|
216
|
+
ethLog.transactionReceipt = getParsedData(ethLog.rawTransactionReceipt)
|
217
|
+
}
|
181
218
|
}
|
182
219
|
break
|
183
220
|
case HandlerType.ETH_TRANSACTION:
|
184
221
|
const ethTx = dataBinding.data?.ethTransaction
|
185
222
|
if (ethTx?.transaction == null && ethTx?.rawTransaction) {
|
186
|
-
ethTx.transaction =
|
187
|
-
|
188
|
-
|
223
|
+
ethTx.transaction = getParsedData(ethTx.rawTransaction)
|
224
|
+
if (ethTx.rawBlock) {
|
225
|
+
ethTx.block = getParsedData(ethTx.rawBlock)
|
226
|
+
} else {
|
227
|
+
ethTx.block = undefined
|
228
|
+
}
|
229
|
+
if (ethTx.rawTransactionReceipt) {
|
230
|
+
ethTx.transactionReceipt = getParsedData(ethTx.rawTransactionReceipt)
|
231
|
+
} else {
|
232
|
+
ethTx.transactionReceipt = undefined
|
233
|
+
}
|
189
234
|
}
|
190
235
|
break
|
191
236
|
case HandlerType.FUEL_TRANSACTION:
|
@@ -209,7 +254,8 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
209
254
|
const aptEvent = dataBinding.data?.aptEvent
|
210
255
|
if (aptEvent) {
|
211
256
|
if (isBeforeMoveUseRawVersion && aptEvent.rawTransaction) {
|
212
|
-
const transaction =
|
257
|
+
const transaction = getParsedData(aptEvent.rawTransaction)
|
258
|
+
|
213
259
|
const key = `${transaction.hash}-${dataBinding.handlerIds[0]}`
|
214
260
|
if (PROCESSED_MOVE_EVENT_TX_HANDLER.has(key)) {
|
215
261
|
console.debug('skip binding', key)
|
@@ -230,7 +276,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
230
276
|
const aptCall = dataBinding.data?.aptCall
|
231
277
|
if (aptCall) {
|
232
278
|
if (isBeforeMoveUseRawVersion && aptCall.rawTransaction) {
|
233
|
-
aptCall.transaction =
|
279
|
+
aptCall.transaction = getParsedData(aptCall.rawTransaction)
|
234
280
|
}
|
235
281
|
}
|
236
282
|
break
|
@@ -246,7 +292,8 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
246
292
|
const suiEvent = dataBinding.data?.suiEvent
|
247
293
|
if (suiEvent) {
|
248
294
|
if (isBeforeMoveUseRawVersion && suiEvent.rawTransaction) {
|
249
|
-
const transaction =
|
295
|
+
const transaction = getParsedData(suiEvent.rawTransaction)
|
296
|
+
|
250
297
|
const key = `${transaction.digest}-${dataBinding.handlerIds[0]}`
|
251
298
|
if (PROCESSED_MOVE_EVENT_TX_HANDLER.has(key)) {
|
252
299
|
console.debug('skip binding', key)
|
@@ -267,7 +314,7 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
267
314
|
const suiCall = dataBinding.data?.suiCall
|
268
315
|
if (suiCall) {
|
269
316
|
if (isBeforeMoveUseRawVersion && suiCall.rawTransaction) {
|
270
|
-
suiCall.transaction =
|
317
|
+
suiCall.transaction = getParsedData(suiCall.rawTransaction)
|
271
318
|
}
|
272
319
|
}
|
273
320
|
break
|
@@ -336,4 +383,3 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
336
383
|
// d.data?.ethTrace?.trace?.transactionPosition
|
337
384
|
// )
|
338
385
|
// }
|
339
|
-
//
|