envio 3.3.0-alpha.1 → 3.3.0-alpha.3
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/index.d.ts +23 -21
- package/package.json +6 -6
- package/src/Batch.res +0 -6
- package/src/Batch.res.mjs +0 -11
- package/src/BatchProcessing.res +2 -12
- package/src/BatchProcessing.res.mjs +2 -7
- package/src/ChainFetching.res +42 -6
- package/src/ChainFetching.res.mjs +30 -11
- package/src/ChainMetadata.res +1 -11
- package/src/ChainMetadata.res.mjs +1 -10
- package/src/ChainState.res +150 -1
- package/src/ChainState.res.mjs +138 -9
- package/src/ChainState.resi +51 -1
- package/src/Config.res +3 -6
- package/src/Config.res.mjs +2 -3
- package/src/Core.res +7 -0
- package/src/CrossChainState.res +24 -26
- package/src/CrossChainState.res.mjs +19 -16
- package/src/Ecosystem.res +6 -3
- package/src/Envio.res +3 -2
- package/src/EventConfigBuilder.res +61 -23
- package/src/EventConfigBuilder.res.mjs +27 -13
- package/src/EventProcessing.res +63 -21
- package/src/EventProcessing.res.mjs +47 -22
- package/src/FetchState.res +53 -43
- package/src/FetchState.res.mjs +71 -54
- package/src/HandlerLoader.res +10 -1
- package/src/HandlerLoader.res.mjs +15 -8
- package/src/Internal.res +46 -7
- package/src/Internal.res.mjs +19 -1
- package/src/LoadLayer.res +5 -5
- package/src/LoadLayer.res.mjs +6 -6
- package/src/Main.res +3 -50
- package/src/Main.res.mjs +2 -23
- package/src/PgStorage.res +4 -4
- package/src/PgStorage.res.mjs +5 -5
- package/src/Prometheus.res +10 -10
- package/src/Prometheus.res.mjs +9 -9
- package/src/PruneStaleHistory.res +2 -2
- package/src/PruneStaleHistory.res.mjs +3 -3
- package/src/Rollback.res +3 -3
- package/src/Rollback.res.mjs +4 -4
- package/src/SimulateItems.res +80 -15
- package/src/SimulateItems.res.mjs +65 -21
- package/src/TestIndexer.res +48 -36
- package/src/TestIndexer.res.mjs +35 -28
- package/src/bindings/Performance.res +7 -0
- package/src/bindings/Performance.res.mjs +21 -0
- package/src/bindings/Performance.resi +7 -0
- package/src/sources/EventRouter.res +17 -21
- package/src/sources/EventRouter.res.mjs +6 -9
- package/src/sources/Evm.res +47 -67
- package/src/sources/Evm.res.mjs +42 -65
- package/src/sources/Fuel.res +3 -3
- package/src/sources/Fuel.res.mjs +1 -6
- package/src/sources/HyperFuelSource.res +15 -11
- package/src/sources/HyperFuelSource.res.mjs +13 -11
- package/src/sources/HyperSync.res +7 -1
- package/src/sources/HyperSync.res.mjs +6 -3
- package/src/sources/HyperSync.resi +2 -0
- package/src/sources/HyperSyncClient.res +14 -79
- package/src/sources/HyperSyncClient.res.mjs +1 -22
- package/src/sources/HyperSyncSource.res +44 -27
- package/src/sources/HyperSyncSource.res.mjs +32 -27
- package/src/sources/RpcSource.res +14 -10
- package/src/sources/RpcSource.res.mjs +11 -9
- package/src/sources/SimulateSource.res +4 -2
- package/src/sources/SimulateSource.res.mjs +1 -0
- package/src/sources/Source.res +5 -1
- package/src/sources/SourceManager.res +17 -16
- package/src/sources/SourceManager.res.mjs +10 -15
- package/src/sources/Svm.res +23 -6
- package/src/sources/Svm.res.mjs +24 -6
- package/src/sources/SvmHyperSyncClient.res +3 -29
- package/src/sources/SvmHyperSyncSource.res +78 -96
- package/src/sources/SvmHyperSyncSource.res.mjs +79 -91
- package/src/sources/TransactionStore.res +128 -0
- package/src/sources/TransactionStore.res.mjs +97 -0
- package/src/tui/Tui.res +13 -16
- package/src/tui/Tui.res.mjs +12 -14
- package/svm.schema.json +30 -37
- package/src/bindings/Hrtime.res +0 -58
- package/src/bindings/Hrtime.res.mjs +0 -90
- package/src/bindings/Hrtime.resi +0 -30
package/src/sources/Evm.res.mjs
CHANGED
|
@@ -3,6 +3,44 @@
|
|
|
3
3
|
import * as Logging from "../Logging.res.mjs";
|
|
4
4
|
import * as RawEvent from "../RawEvent.res.mjs";
|
|
5
5
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
6
|
+
import * as TransactionStore from "./TransactionStore.res.mjs";
|
|
7
|
+
|
|
8
|
+
let transactionFields = [
|
|
9
|
+
"transactionIndex",
|
|
10
|
+
"hash",
|
|
11
|
+
"from",
|
|
12
|
+
"to",
|
|
13
|
+
"gas",
|
|
14
|
+
"gasPrice",
|
|
15
|
+
"maxPriorityFeePerGas",
|
|
16
|
+
"maxFeePerGas",
|
|
17
|
+
"cumulativeGasUsed",
|
|
18
|
+
"effectiveGasPrice",
|
|
19
|
+
"gasUsed",
|
|
20
|
+
"input",
|
|
21
|
+
"nonce",
|
|
22
|
+
"value",
|
|
23
|
+
"v",
|
|
24
|
+
"r",
|
|
25
|
+
"s",
|
|
26
|
+
"contractAddress",
|
|
27
|
+
"logsBloom",
|
|
28
|
+
"root",
|
|
29
|
+
"status",
|
|
30
|
+
"yParity",
|
|
31
|
+
"maxFeePerBlobGas",
|
|
32
|
+
"blobVersionedHashes",
|
|
33
|
+
"type",
|
|
34
|
+
"l1Fee",
|
|
35
|
+
"l1GasPrice",
|
|
36
|
+
"l1GasUsed",
|
|
37
|
+
"l1FeeScalar",
|
|
38
|
+
"gasUsedForL1",
|
|
39
|
+
"accessList",
|
|
40
|
+
"authorizationList"
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
let transactionFieldMask = TransactionStore.makeMaskFn(transactionFields);
|
|
6
44
|
|
|
7
45
|
let cleanUpRawEventFieldsInPlace = (fields => {
|
|
8
46
|
delete fields.hash
|
|
@@ -13,70 +51,6 @@ let cleanUpRawEventFieldsInPlace = (fields => {
|
|
|
13
51
|
function make(logger) {
|
|
14
52
|
return {
|
|
15
53
|
name: "evm",
|
|
16
|
-
blockFields: [
|
|
17
|
-
"number",
|
|
18
|
-
"timestamp",
|
|
19
|
-
"hash",
|
|
20
|
-
"parentHash",
|
|
21
|
-
"nonce",
|
|
22
|
-
"sha3Uncles",
|
|
23
|
-
"logsBloom",
|
|
24
|
-
"transactionsRoot",
|
|
25
|
-
"stateRoot",
|
|
26
|
-
"receiptsRoot",
|
|
27
|
-
"miner",
|
|
28
|
-
"difficulty",
|
|
29
|
-
"totalDifficulty",
|
|
30
|
-
"extraData",
|
|
31
|
-
"size",
|
|
32
|
-
"gasLimit",
|
|
33
|
-
"gasUsed",
|
|
34
|
-
"uncles",
|
|
35
|
-
"baseFeePerGas",
|
|
36
|
-
"blobGasUsed",
|
|
37
|
-
"excessBlobGas",
|
|
38
|
-
"parentBeaconBlockRoot",
|
|
39
|
-
"withdrawalsRoot",
|
|
40
|
-
"l1BlockNumber",
|
|
41
|
-
"sendCount",
|
|
42
|
-
"sendRoot",
|
|
43
|
-
"mixHash"
|
|
44
|
-
],
|
|
45
|
-
transactionFields: [
|
|
46
|
-
"transactionIndex",
|
|
47
|
-
"hash",
|
|
48
|
-
"from",
|
|
49
|
-
"to",
|
|
50
|
-
"gas",
|
|
51
|
-
"gasPrice",
|
|
52
|
-
"maxPriorityFeePerGas",
|
|
53
|
-
"maxFeePerGas",
|
|
54
|
-
"cumulativeGasUsed",
|
|
55
|
-
"effectiveGasPrice",
|
|
56
|
-
"gasUsed",
|
|
57
|
-
"input",
|
|
58
|
-
"nonce",
|
|
59
|
-
"value",
|
|
60
|
-
"v",
|
|
61
|
-
"r",
|
|
62
|
-
"s",
|
|
63
|
-
"contractAddress",
|
|
64
|
-
"logsBloom",
|
|
65
|
-
"root",
|
|
66
|
-
"status",
|
|
67
|
-
"yParity",
|
|
68
|
-
"chainId",
|
|
69
|
-
"maxFeePerBlobGas",
|
|
70
|
-
"blobVersionedHashes",
|
|
71
|
-
"type",
|
|
72
|
-
"l1Fee",
|
|
73
|
-
"l1GasPrice",
|
|
74
|
-
"l1GasUsed",
|
|
75
|
-
"l1FeeScalar",
|
|
76
|
-
"gasUsedForL1",
|
|
77
|
-
"accessList",
|
|
78
|
-
"authorizationList"
|
|
79
|
-
],
|
|
80
54
|
blockNumberName: "number",
|
|
81
55
|
blockTimestampName: "timestamp",
|
|
82
56
|
blockHashName: "hash",
|
|
@@ -86,6 +60,7 @@ function make(logger) {
|
|
|
86
60
|
onEventBlockFilterSchema: S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.object(s2 => s2.f("number", S$RescriptSchema.unknown))))),
|
|
87
61
|
logger: logger,
|
|
88
62
|
toEvent: eventItem => eventItem.payload,
|
|
63
|
+
transactionFieldMask: transactionFieldMask,
|
|
89
64
|
toEventLogger: eventItem => Logging.createChildFrom(logger, {
|
|
90
65
|
contract: eventItem.eventConfig.contractName,
|
|
91
66
|
event: eventItem.eventConfig.name,
|
|
@@ -102,7 +77,9 @@ function make(logger) {
|
|
|
102
77
|
}
|
|
103
78
|
|
|
104
79
|
export {
|
|
80
|
+
transactionFields,
|
|
81
|
+
transactionFieldMask,
|
|
105
82
|
cleanUpRawEventFieldsInPlace,
|
|
106
83
|
make,
|
|
107
84
|
}
|
|
108
|
-
/*
|
|
85
|
+
/* transactionFieldMask Not a pure module */
|
package/src/sources/Fuel.res
CHANGED
|
@@ -21,8 +21,6 @@ let cleanUpRawEventFieldsInPlace: JSON.t => unit = %raw(`fields => {
|
|
|
21
21
|
|
|
22
22
|
let make = (~logger: Pino.t): Ecosystem.t => {
|
|
23
23
|
name: Fuel,
|
|
24
|
-
blockFields: ["id", "height", "time"],
|
|
25
|
-
transactionFields: ["id"],
|
|
26
24
|
blockNumberName: "height",
|
|
27
25
|
blockTimestampName: "time",
|
|
28
26
|
blockHashName: "id",
|
|
@@ -41,7 +39,9 @@ let make = (~logger: Pino.t): Ecosystem.t => {
|
|
|
41
39
|
s.field("block", S.option(S.object(s2 => s2.field("height", S.unknown))))
|
|
42
40
|
),
|
|
43
41
|
logger,
|
|
44
|
-
|
|
42
|
+
// Fuel carries the transaction inline on the payload.
|
|
43
|
+
transactionFieldMask: _ => 0.,
|
|
44
|
+
toEvent: eventItem => eventItem.payload->(Utils.magic: Internal.eventPayload => Internal.event),
|
|
45
45
|
toEventLogger: eventItem =>
|
|
46
46
|
Logging.createChildFrom(
|
|
47
47
|
~logger,
|
package/src/sources/Fuel.res.mjs
CHANGED
|
@@ -13,12 +13,6 @@ let cleanUpRawEventFieldsInPlace = (fields => {
|
|
|
13
13
|
function make(logger) {
|
|
14
14
|
return {
|
|
15
15
|
name: "fuel",
|
|
16
|
-
blockFields: [
|
|
17
|
-
"id",
|
|
18
|
-
"height",
|
|
19
|
-
"time"
|
|
20
|
-
],
|
|
21
|
-
transactionFields: ["id"],
|
|
22
16
|
blockNumberName: "height",
|
|
23
17
|
blockTimestampName: "time",
|
|
24
18
|
blockHashName: "id",
|
|
@@ -28,6 +22,7 @@ function make(logger) {
|
|
|
28
22
|
onEventBlockFilterSchema: S$RescriptSchema.object(s => s.f("block", S$RescriptSchema.option(S$RescriptSchema.object(s2 => s2.f("height", S$RescriptSchema.unknown))))),
|
|
29
23
|
logger: logger,
|
|
30
24
|
toEvent: eventItem => eventItem.payload,
|
|
25
|
+
transactionFieldMask: param => 0,
|
|
31
26
|
toEventLogger: eventItem => Logging.createChildFrom(logger, {
|
|
32
27
|
contract: eventItem.eventConfig.contractName,
|
|
33
28
|
event: eventItem.eventConfig.name,
|
|
@@ -235,19 +235,19 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
235
235
|
~fromBlock,
|
|
236
236
|
~toBlock,
|
|
237
237
|
~addressesByContractName,
|
|
238
|
-
~
|
|
238
|
+
~contractNameByAddress,
|
|
239
239
|
~knownHeight,
|
|
240
240
|
~partitionId as _,
|
|
241
241
|
~selection: FetchState.selection,
|
|
242
242
|
~retry,
|
|
243
243
|
~logger,
|
|
244
244
|
) => {
|
|
245
|
-
let totalTimeRef =
|
|
245
|
+
let totalTimeRef = Performance.now()
|
|
246
246
|
|
|
247
247
|
let selectionConfig = getSelectionConfig(selection)
|
|
248
248
|
let recieptsSelection = selectionConfig.getRecieptsSelection(~addressesByContractName)
|
|
249
249
|
|
|
250
|
-
let startFetchingBatchTimeRef =
|
|
250
|
+
let startFetchingBatchTimeRef = Performance.now()
|
|
251
251
|
|
|
252
252
|
//fetch batch
|
|
253
253
|
Prometheus.SourceRequestCount.increment(
|
|
@@ -305,7 +305,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
305
305
|
)
|
|
306
306
|
}
|
|
307
307
|
|
|
308
|
-
let pageFetchTime = startFetchingBatchTimeRef->
|
|
308
|
+
let pageFetchTime = startFetchingBatchTimeRef->Performance.secondsSince
|
|
309
309
|
|
|
310
310
|
//set height and next from block
|
|
311
311
|
let knownHeight = pageUnsafe.archiveHeight
|
|
@@ -315,7 +315,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
315
315
|
//In the query
|
|
316
316
|
let heighestBlockQueried = pageUnsafe.nextBlock - 1
|
|
317
317
|
|
|
318
|
-
let parsingTimeRef =
|
|
318
|
+
let parsingTimeRef = Performance.now()
|
|
319
319
|
|
|
320
320
|
let parsedQueueItems = pageUnsafe.items->Array.map(item => {
|
|
321
321
|
let {contractId: contractAddress, receipt, block, receiptIndex} = item
|
|
@@ -332,9 +332,8 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
332
332
|
|
|
333
333
|
let eventConfig = switch selectionConfig.eventRouter->EventRouter.get(
|
|
334
334
|
~tag=eventId,
|
|
335
|
-
~
|
|
335
|
+
~contractNameByAddress,
|
|
336
336
|
~contractAddress,
|
|
337
|
-
~blockNumber=block.height,
|
|
338
337
|
) {
|
|
339
338
|
| None => {
|
|
340
339
|
let logger = Logging.createChildFrom(
|
|
@@ -414,6 +413,9 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
414
413
|
blockNumber: block.height,
|
|
415
414
|
blockHash: block.id,
|
|
416
415
|
logIndex: receiptIndex,
|
|
416
|
+
// Fuel carries the transaction inline on the payload; the store key is
|
|
417
|
+
// unused (Fuel identifies transactions by hash, kept on the payload).
|
|
418
|
+
transactionIndex: 0,
|
|
417
419
|
payload: {
|
|
418
420
|
contractName: eventConfig.contractName,
|
|
419
421
|
eventName: eventConfig.name,
|
|
@@ -429,7 +431,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
429
431
|
})
|
|
430
432
|
})
|
|
431
433
|
|
|
432
|
-
let parsingTimeElapsed = parsingTimeRef->
|
|
434
|
+
let parsingTimeElapsed = parsingTimeRef->Performance.secondsSince
|
|
433
435
|
|
|
434
436
|
// Fuel never rolls back on reorg, so block hashes here are purely informational
|
|
435
437
|
// for detect-only logging via ReorgDetection.
|
|
@@ -445,7 +447,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
445
447
|
| _ => 0
|
|
446
448
|
}
|
|
447
449
|
|
|
448
|
-
let totalTimeElapsed = totalTimeRef->
|
|
450
|
+
let totalTimeElapsed = totalTimeRef->Performance.secondsSince
|
|
449
451
|
|
|
450
452
|
let stats = {
|
|
451
453
|
totalTimeElapsed,
|
|
@@ -456,6 +458,8 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
456
458
|
{
|
|
457
459
|
latestFetchedBlockTimestamp,
|
|
458
460
|
parsedQueueItems,
|
|
461
|
+
// Fuel keeps transaction on the payload; no store page.
|
|
462
|
+
transactionStore: None,
|
|
459
463
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
460
464
|
stats,
|
|
461
465
|
knownHeight,
|
|
@@ -475,7 +479,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
475
479
|
pollingInterval: 100,
|
|
476
480
|
poweredByHyperSync: true,
|
|
477
481
|
getHeightOrThrow: async () => {
|
|
478
|
-
let timerRef =
|
|
482
|
+
let timerRef = Performance.now()
|
|
479
483
|
let height = try await client->HyperFuelClient.getHeight catch {
|
|
480
484
|
| JsExn(e) =>
|
|
481
485
|
switch e->JsExn.message {
|
|
@@ -487,7 +491,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
487
491
|
| _ => throw(JsExn(e))
|
|
488
492
|
}
|
|
489
493
|
}
|
|
490
|
-
let seconds = timerRef->
|
|
494
|
+
let seconds = timerRef->Performance.secondsSince
|
|
491
495
|
Prometheus.SourceRequestCount.increment(
|
|
492
496
|
~sourceName=name,
|
|
493
497
|
~chainId=chain->ChainMap.Chain.toChainId,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Hrtime from "../bindings/Hrtime.res.mjs";
|
|
4
3
|
import * as Source from "./Source.res.mjs";
|
|
5
4
|
import * as Logging from "../Logging.res.mjs";
|
|
6
5
|
import * as HyperFuel from "./HyperFuel.res.mjs";
|
|
7
6
|
import * as Prometheus from "../Prometheus.res.mjs";
|
|
8
7
|
import * as EventRouter from "./EventRouter.res.mjs";
|
|
8
|
+
import * as Performance from "../bindings/Performance.res.mjs";
|
|
9
9
|
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
10
10
|
import * as ErrorHandling from "../ErrorHandling.res.mjs";
|
|
11
11
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
@@ -196,11 +196,11 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
196
196
|
client = ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate the HyperFuel client", exn);
|
|
197
197
|
}
|
|
198
198
|
let getSelectionConfig = memoGetSelectionConfig(chain);
|
|
199
|
-
let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName,
|
|
200
|
-
let totalTimeRef =
|
|
199
|
+
let getItemsOrThrow = async (fromBlock, toBlock, addressesByContractName, contractNameByAddress, knownHeight, param, selection, retry, logger) => {
|
|
200
|
+
let totalTimeRef = Performance.now();
|
|
201
201
|
let selectionConfig = getSelectionConfig(selection);
|
|
202
202
|
let recieptsSelection = selectionConfig.getRecieptsSelection(addressesByContractName);
|
|
203
|
-
let startFetchingBatchTimeRef =
|
|
203
|
+
let startFetchingBatchTimeRef = Performance.now();
|
|
204
204
|
Prometheus.SourceRequestCount.increment(name, chain, "getLogs");
|
|
205
205
|
let pageUnsafe;
|
|
206
206
|
try {
|
|
@@ -249,10 +249,10 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
249
249
|
Error: new Error()
|
|
250
250
|
};
|
|
251
251
|
}
|
|
252
|
-
let pageFetchTime =
|
|
252
|
+
let pageFetchTime = Performance.secondsSince(startFetchingBatchTimeRef);
|
|
253
253
|
let knownHeight$1 = pageUnsafe.archiveHeight;
|
|
254
254
|
let heighestBlockQueried = pageUnsafe.nextBlock - 1 | 0;
|
|
255
|
-
let parsingTimeRef =
|
|
255
|
+
let parsingTimeRef = Performance.now();
|
|
256
256
|
let parsedQueueItems = pageUnsafe.items.map(item => {
|
|
257
257
|
let block = item.block;
|
|
258
258
|
let receiptIndex = item.receiptIndex;
|
|
@@ -277,7 +277,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
277
277
|
eventId = burnEventTag;
|
|
278
278
|
break;
|
|
279
279
|
}
|
|
280
|
-
let eventConfig = EventRouter.get(selectionConfig.eventRouter, eventId, contractAddress,
|
|
280
|
+
let eventConfig = EventRouter.get(selectionConfig.eventRouter, eventId, contractAddress, contractNameByAddress);
|
|
281
281
|
let eventConfig$1;
|
|
282
282
|
if (eventConfig !== undefined) {
|
|
283
283
|
eventConfig$1 = eventConfig;
|
|
@@ -355,6 +355,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
355
355
|
blockNumber: block.height,
|
|
356
356
|
blockHash: block.id,
|
|
357
357
|
logIndex: receiptIndex,
|
|
358
|
+
transactionIndex: 0,
|
|
358
359
|
payload: {
|
|
359
360
|
contractName: eventConfig$1.contractName,
|
|
360
361
|
eventName: eventConfig$1.name,
|
|
@@ -369,7 +370,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
369
370
|
}
|
|
370
371
|
};
|
|
371
372
|
});
|
|
372
|
-
let parsingTimeElapsed =
|
|
373
|
+
let parsingTimeElapsed = Performance.secondsSince(parsingTimeRef);
|
|
373
374
|
let blockHashes = pageUnsafe.items.map(param => {
|
|
374
375
|
let block = param.block;
|
|
375
376
|
return {
|
|
@@ -385,7 +386,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
385
386
|
} else {
|
|
386
387
|
latestFetchedBlockTimestamp = 0;
|
|
387
388
|
}
|
|
388
|
-
let totalTimeElapsed =
|
|
389
|
+
let totalTimeElapsed = Performance.secondsSince(totalTimeRef);
|
|
389
390
|
let stats_parsing$unknowntime$unknown$lpars$rpar = parsingTimeElapsed;
|
|
390
391
|
let stats_page$unknownfetch$unknowntime$unknown$lpars$rpar = pageFetchTime;
|
|
391
392
|
let stats = {
|
|
@@ -397,6 +398,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
397
398
|
knownHeight: knownHeight$1,
|
|
398
399
|
blockHashes: blockHashes,
|
|
399
400
|
parsedQueueItems: parsedQueueItems,
|
|
401
|
+
transactionStore: undefined,
|
|
400
402
|
fromBlockQueried: fromBlock,
|
|
401
403
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
402
404
|
latestFetchedBlockTimestamp: latestFetchedBlockTimestamp,
|
|
@@ -412,7 +414,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
412
414
|
pollingInterval: 100,
|
|
413
415
|
getBlockHashes: getBlockHashes,
|
|
414
416
|
getHeightOrThrow: async () => {
|
|
415
|
-
let timerRef =
|
|
417
|
+
let timerRef = Performance.now();
|
|
416
418
|
let height;
|
|
417
419
|
try {
|
|
418
420
|
height = await client.getHeight();
|
|
@@ -444,7 +446,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
444
446
|
throw e;
|
|
445
447
|
}
|
|
446
448
|
}
|
|
447
|
-
let seconds =
|
|
449
|
+
let seconds = Performance.secondsSince(timerRef);
|
|
448
450
|
Prometheus.SourceRequestCount.increment(name, chain, "getHeight");
|
|
449
451
|
Prometheus.SourceRequestCount.addSeconds(name, chain, "getHeight", seconds);
|
|
450
452
|
return height;
|
|
@@ -16,9 +16,13 @@ let reraisIfRateLimited = exn =>
|
|
|
16
16
|
|
|
17
17
|
type logsQueryPage = {
|
|
18
18
|
items: array<HyperSyncClient.EventItems.item>,
|
|
19
|
+
// Blocks referenced by `items`, deduplicated by block number.
|
|
20
|
+
blocks: array<HyperSyncClient.ResponseTypes.block>,
|
|
19
21
|
nextBlock: int,
|
|
20
22
|
archiveHeight: int,
|
|
21
23
|
rollbackGuard: option<HyperSyncClient.ResponseTypes.rollbackGuard>,
|
|
24
|
+
// Page store owning this page's raw transactions.
|
|
25
|
+
transactionStore: TransactionStore.t,
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
type missingParams = {
|
|
@@ -121,7 +125,7 @@ module GetLogs = {
|
|
|
121
125
|
~fieldSelection,
|
|
122
126
|
)
|
|
123
127
|
|
|
124
|
-
let res = switch await client.getEventItems(~query) {
|
|
128
|
+
let (res, transactionStore) = switch await client.getEventItems(~query) {
|
|
125
129
|
| res => res
|
|
126
130
|
| exception exn =>
|
|
127
131
|
reraisIfRateLimited(exn)
|
|
@@ -137,9 +141,11 @@ module GetLogs = {
|
|
|
137
141
|
|
|
138
142
|
{
|
|
139
143
|
items: res.items,
|
|
144
|
+
blocks: res.blocks,
|
|
140
145
|
nextBlock: res.nextBlock,
|
|
141
146
|
archiveHeight: res.archiveHeight->Option.getOr(0), //Archive Height is only None if height is 0
|
|
142
147
|
rollbackGuard: res.rollbackGuard,
|
|
148
|
+
transactionStore,
|
|
143
149
|
}
|
|
144
150
|
}
|
|
145
151
|
}
|
|
@@ -101,9 +101,9 @@ async function query(client, fromBlock, toBlock, logSelections, fieldSelection)
|
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
let query$1 = makeRequestBody(fromBlock, toBlock, addressesWithTopics, fieldSelection);
|
|
104
|
-
let
|
|
104
|
+
let match;
|
|
105
105
|
try {
|
|
106
|
-
|
|
106
|
+
match = await client.getEventItems(query$1);
|
|
107
107
|
} catch (raw_exn) {
|
|
108
108
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
109
109
|
reraisIfRateLimited(exn);
|
|
@@ -120,6 +120,7 @@ async function query(client, fromBlock, toBlock, logSelections, fieldSelection)
|
|
|
120
120
|
}
|
|
121
121
|
throw exn;
|
|
122
122
|
}
|
|
123
|
+
let res = match[0];
|
|
123
124
|
if (res.nextBlock <= fromBlock) {
|
|
124
125
|
throw {
|
|
125
126
|
RE_EXN_ID: $$Error,
|
|
@@ -129,9 +130,11 @@ async function query(client, fromBlock, toBlock, logSelections, fieldSelection)
|
|
|
129
130
|
}
|
|
130
131
|
return {
|
|
131
132
|
items: res.items,
|
|
133
|
+
blocks: res.blocks,
|
|
132
134
|
nextBlock: res.nextBlock,
|
|
133
135
|
archiveHeight: Stdlib_Option.getOr(res.archiveHeight, 0),
|
|
134
|
-
rollbackGuard: res.rollbackGuard
|
|
136
|
+
rollbackGuard: res.rollbackGuard,
|
|
137
|
+
transactionStore: match[1]
|
|
135
138
|
};
|
|
136
139
|
}
|
|
137
140
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
type logsQueryPage = {
|
|
2
2
|
items: array<HyperSyncClient.EventItems.item>,
|
|
3
|
+
blocks: array<HyperSyncClient.ResponseTypes.block>,
|
|
3
4
|
nextBlock: int,
|
|
4
5
|
archiveHeight: int,
|
|
5
6
|
rollbackGuard: option<HyperSyncClient.ResponseTypes.rollbackGuard>,
|
|
7
|
+
transactionStore: TransactionStore.t,
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
type missingParams = {
|
|
@@ -208,72 +208,6 @@ module ResponseTypes = {
|
|
|
208
208
|
mixHash?: string,
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
-
type accessList = {
|
|
212
|
-
address?: Address.t,
|
|
213
|
-
storageKeys?: array<string>,
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
let accessListSchema = S.object(s => {
|
|
217
|
-
address: ?s.field("address", S.option(Address.schema)),
|
|
218
|
-
storageKeys: ?s.field("storageKeys", S.option(S.array(S.string))),
|
|
219
|
-
})
|
|
220
|
-
|
|
221
|
-
type authorizationList = {
|
|
222
|
-
chainId: bigint,
|
|
223
|
-
address: Address.t,
|
|
224
|
-
nonce: int,
|
|
225
|
-
yParity: [#0 | #1],
|
|
226
|
-
r: string,
|
|
227
|
-
s: string,
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
let authorizationListSchema = S.object(s => {
|
|
231
|
-
chainId: s.field("chainId", S.bigint),
|
|
232
|
-
address: s.field("address", Address.schema),
|
|
233
|
-
nonce: s.field("nonce", S.int),
|
|
234
|
-
yParity: s.field("yParity", S.enum([#0, #1])),
|
|
235
|
-
r: s.field("r", S.string),
|
|
236
|
-
s: s.field("s", S.string),
|
|
237
|
-
})
|
|
238
|
-
|
|
239
|
-
type transaction = {
|
|
240
|
-
blockHash?: string,
|
|
241
|
-
blockNumber?: int,
|
|
242
|
-
from?: string,
|
|
243
|
-
gas?: bigint,
|
|
244
|
-
gasPrice?: bigint,
|
|
245
|
-
hash?: string,
|
|
246
|
-
input?: string,
|
|
247
|
-
nonce?: bigint,
|
|
248
|
-
to?: string,
|
|
249
|
-
transactionIndex?: int,
|
|
250
|
-
value?: bigint,
|
|
251
|
-
v?: string,
|
|
252
|
-
r?: string,
|
|
253
|
-
s?: string,
|
|
254
|
-
yParity?: string,
|
|
255
|
-
maxPriorityFeePerGas?: bigint,
|
|
256
|
-
maxFeePerGas?: bigint,
|
|
257
|
-
chainId?: int,
|
|
258
|
-
accessList?: array<accessList>,
|
|
259
|
-
maxFeePerBlobGas?: bigint,
|
|
260
|
-
blobVersionedHashes?: array<string>,
|
|
261
|
-
cumulativeGasUsed?: bigint,
|
|
262
|
-
effectiveGasPrice?: bigint,
|
|
263
|
-
gasUsed?: bigint,
|
|
264
|
-
contractAddress?: string,
|
|
265
|
-
logsBloom?: string,
|
|
266
|
-
@as("type") type_?: int,
|
|
267
|
-
root?: string,
|
|
268
|
-
status?: int,
|
|
269
|
-
l1Fee?: bigint,
|
|
270
|
-
l1GasPrice?: bigint,
|
|
271
|
-
l1GasUsed?: bigint,
|
|
272
|
-
l1FeeScalar?: float,
|
|
273
|
-
gasUsedForL1?: bigint,
|
|
274
|
-
authorizationList?: array<authorizationList>,
|
|
275
|
-
}
|
|
276
|
-
|
|
277
211
|
type log = {
|
|
278
212
|
removed?: bool,
|
|
279
213
|
@as("logIndex") index?: int,
|
|
@@ -286,11 +220,9 @@ module ResponseTypes = {
|
|
|
286
220
|
topics?: array<Nullable.t<EvmTypes.Hex.t>>,
|
|
287
221
|
}
|
|
288
222
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
log: log,
|
|
293
|
-
}
|
|
223
|
+
// Only the log is needed for decoding; the transaction/block are served from
|
|
224
|
+
// the store (event items) or unused (block-hash query).
|
|
225
|
+
type event = {log: log}
|
|
294
226
|
|
|
295
227
|
type rollbackGuard = {
|
|
296
228
|
blockNumber: int,
|
|
@@ -303,11 +235,7 @@ module ResponseTypes = {
|
|
|
303
235
|
|
|
304
236
|
type query = QueryTypes.query
|
|
305
237
|
|
|
306
|
-
type queryResponseData = {
|
|
307
|
-
blocks: array<ResponseTypes.block>,
|
|
308
|
-
transactions: array<ResponseTypes.transaction>,
|
|
309
|
-
logs: array<ResponseTypes.log>,
|
|
310
|
-
}
|
|
238
|
+
type queryResponseData = {blocks: array<ResponseTypes.block>}
|
|
311
239
|
|
|
312
240
|
type queryResponse = {
|
|
313
241
|
archiveHeight: option<int>,
|
|
@@ -352,14 +280,20 @@ module EventItems = {
|
|
|
352
280
|
srcAddress: Address.t,
|
|
353
281
|
topic0: EvmTypes.Hex.t,
|
|
354
282
|
topicCount: int,
|
|
355
|
-
block
|
|
356
|
-
|
|
283
|
+
// Number of the block this log belongs to; the block itself is resolved from
|
|
284
|
+
// `response.blocks`, deduplicated across items sharing a block.
|
|
285
|
+
blockNumber: int,
|
|
286
|
+
// Key (with the block number) into the transaction store; the transaction
|
|
287
|
+
// is resolved from the store on demand.
|
|
288
|
+
transactionIndex: int,
|
|
357
289
|
params: Nullable.t<dict<Internal.eventParams>>,
|
|
358
290
|
}
|
|
359
291
|
|
|
360
292
|
type response = {
|
|
361
293
|
archiveHeight: option<int>,
|
|
362
294
|
nextBlock: int,
|
|
295
|
+
// One entry per block number referenced by `items`.
|
|
296
|
+
blocks: array<ResponseTypes.block>,
|
|
363
297
|
items: array<item>,
|
|
364
298
|
rollbackGuard: option<ResponseTypes.rollbackGuard>,
|
|
365
299
|
}
|
|
@@ -367,7 +301,8 @@ module EventItems = {
|
|
|
367
301
|
|
|
368
302
|
type t = {
|
|
369
303
|
get: (~query: query) => promise<queryResponse>,
|
|
370
|
-
|
|
304
|
+
// Returns the response plus a page store owning this page's raw transactions.
|
|
305
|
+
getEventItems: (~query: query) => promise<(EventItems.response, TransactionStore.t)>,
|
|
371
306
|
getHeight: unit => promise<int>,
|
|
372
307
|
}
|
|
373
308
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Core from "../Core.res.mjs";
|
|
4
4
|
import * as Utils from "../Utils.res.mjs";
|
|
5
|
-
import * as Address from "../Address.res.mjs";
|
|
6
5
|
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
7
6
|
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
|
|
8
7
|
|
|
@@ -36,27 +35,7 @@ let QueryTypes = {
|
|
|
36
35
|
makeLogSelection: makeLogSelection
|
|
37
36
|
};
|
|
38
37
|
|
|
39
|
-
let
|
|
40
|
-
address: s.f("address", S$RescriptSchema.option(Address.schema)),
|
|
41
|
-
storageKeys: s.f("storageKeys", S$RescriptSchema.option(S$RescriptSchema.array(S$RescriptSchema.string)))
|
|
42
|
-
}));
|
|
43
|
-
|
|
44
|
-
let authorizationListSchema = S$RescriptSchema.object(s => ({
|
|
45
|
-
chainId: s.f("chainId", S$RescriptSchema.bigint),
|
|
46
|
-
address: s.f("address", Address.schema),
|
|
47
|
-
nonce: s.f("nonce", S$RescriptSchema.int),
|
|
48
|
-
yParity: s.f("yParity", S$RescriptSchema.$$enum([
|
|
49
|
-
0,
|
|
50
|
-
1
|
|
51
|
-
])),
|
|
52
|
-
r: s.f("r", S$RescriptSchema.string),
|
|
53
|
-
s: s.f("s", S$RescriptSchema.string)
|
|
54
|
-
}));
|
|
55
|
-
|
|
56
|
-
let ResponseTypes = {
|
|
57
|
-
accessListSchema: accessListSchema,
|
|
58
|
-
authorizationListSchema: authorizationListSchema
|
|
59
|
-
};
|
|
38
|
+
let ResponseTypes = {};
|
|
60
39
|
|
|
61
40
|
function fromParams(eventParams, checksumAddresses) {
|
|
62
41
|
return Core.getAddon().EvmDecoder.fromParams(eventParams, checksumAddresses !== undefined ? Primitive_option.valFromOption(checksumAddresses) : undefined);
|