envio 3.13.0-alpha.0 → 3.13.0
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/package.json +6 -8
- package/src/BatchProcessing.res +4 -5
- package/src/BatchProcessing.res.mjs +4 -11
- package/src/ChainFetching.res +18 -38
- package/src/ChainFetching.res.mjs +14 -20
- package/src/ChainState.res +113 -77
- package/src/ChainState.res.mjs +90 -73
- package/src/ChainState.resi +14 -5
- package/src/Config.res +14 -17
- package/src/Config.res.mjs +5 -20
- package/src/CrossChainState.res +68 -20
- package/src/CrossChainState.res.mjs +48 -5
- package/src/CrossChainState.resi +1 -0
- package/src/Env.res +2 -2
- package/src/ErrorHandling.res +15 -4
- package/src/ErrorHandling.res.mjs +16 -5
- package/src/FinalizeBackfill.res +21 -9
- package/src/FinalizeBackfill.res.mjs +17 -4
- package/src/HandlerRegister.res +0 -37
- package/src/HandlerRegister.res.mjs +0 -18
- package/src/IndexerState.res +2 -0
- package/src/IndexerState.res.mjs +5 -0
- package/src/IndexerState.resi +1 -0
- package/src/Logging.res +6 -38
- package/src/Logging.res.mjs +5 -32
- package/src/Main.res +6 -9
- package/src/Main.res.mjs +3 -5
- package/src/Metrics.res +9 -4
- package/src/Metrics.res.mjs +3 -3
- package/src/Persistence.res +6 -3
- package/src/Persistence.res.mjs +5 -3
- package/src/PgStorage.res +2 -2
- package/src/PgStorage.res.mjs +2 -2
- package/src/Rollback.res +3 -3
- package/src/Server.res +0 -3
- package/src/SimulateItems.res +1 -1
- package/src/SimulateItems.res.mjs +1 -1
- package/src/Supervisor.res +236 -109
- package/src/Supervisor.res.mjs +185 -55
- package/src/TestIndexer.res +6 -3
- package/src/TestIndexer.res.mjs +3 -3
- package/src/Worker.res +6 -0
- package/src/Worker.res.mjs +2 -1
- package/src/bindings/NodeJs.res +25 -16
- package/src/bindings/NodeJs.res.mjs +8 -1
- package/src/sources/AddressSet.res +5 -3
- package/src/sources/AddressStore.res +19 -11
- package/src/sources/AddressStore.res.mjs +2 -7
- package/src/sources/BlockStore.res +10 -9
- package/src/sources/BlockStore.res.mjs +4 -4
- package/src/sources/ChainSources.res +4 -0
- package/src/sources/ChainSources.res.mjs +2 -2
- package/src/sources/EvmChain.res +4 -0
- package/src/sources/EvmChain.res.mjs +3 -1
- package/src/sources/EvmEventItem.res +56 -0
- package/src/sources/EvmEventItem.res.mjs +32 -0
- package/src/sources/EvmHyperSyncSource.res +7 -37
- package/src/sources/EvmHyperSyncSource.res.mjs +8 -29
- package/src/sources/EvmRpcClient.res +41 -59
- package/src/sources/EvmRpcClient.res.mjs +4 -54
- package/src/sources/EvmRpcWs.res +4 -1
- package/src/sources/EvmRpcWs.res.mjs +6 -2
- package/src/sources/FuelHyperSyncSource.res +6 -4
- package/src/sources/FuelHyperSyncSource.res.mjs +7 -9
- package/src/sources/HeightFeed.res +7 -1
- package/src/sources/HeightFeed.res.mjs +9 -7
- package/src/sources/HyperSyncClient.res +1 -14
- package/src/sources/RequestStat.res +7 -0
- package/src/sources/RequestStat.res.mjs +14 -1
- package/src/sources/RpcSource.res +100 -1043
- package/src/sources/RpcSource.res.mjs +81 -1056
- package/src/sources/SimulateSource.res +2 -5
- package/src/sources/SimulateSource.res.mjs +2 -3
- package/src/sources/Source.res +34 -12
- package/src/sources/Source.res.mjs +11 -0
- package/src/sources/SourceManager.res +111 -31
- package/src/sources/SourceManager.res.mjs +65 -31
- package/src/sources/SourceManager.resi +4 -0
- package/src/sources/StartBlockResolver.res +8 -5
- package/src/sources/StartBlockResolver.res.mjs +4 -2
- package/src/sources/SvmHyperSyncSource.res +4 -2
- package/src/sources/SvmHyperSyncSource.res.mjs +4 -6
- package/src/sources/TransactionStore.res +9 -6
- package/src/sources/TransactionStore.res.mjs +2 -2
- package/src/tui/Tui.res +4 -18
- package/src/tui/Tui.res.mjs +3 -6
- package/src/LazyLoader.res +0 -135
- package/src/LazyLoader.res.mjs +0 -118
- package/src/bindings/SDSL.res +0 -12
- package/src/bindings/SDSL.res.mjs +0 -9
- package/src/bindings/Yargs.res +0 -8
- package/src/bindings/Yargs.res.mjs +0 -2
- package/src/sources/Rpc.res +0 -185
- package/src/sources/Rpc.res.mjs +0 -183
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
-
import * as Rpc from "./Rpc.res.mjs";
|
|
4
3
|
import * as Utils from "../Utils.res.mjs";
|
|
5
4
|
import * as HeightStream from "./HeightStream.res.mjs";
|
|
6
5
|
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
@@ -30,12 +29,16 @@ function refusesSubscribe(id, subscribed) {
|
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
|
32
|
+
let hexIntSchema = S$RescriptSchema.transform(S$RescriptSchema.string, param => ({
|
|
33
|
+
p: str => Number(str)
|
|
34
|
+
}));
|
|
35
|
+
|
|
33
36
|
let wsMessageSchema = S$RescriptSchema.union([
|
|
34
37
|
S$RescriptSchema.object(s => {
|
|
35
38
|
s.f("method", S$RescriptSchema.literal("eth_subscription"));
|
|
36
39
|
return {
|
|
37
40
|
TAG: "NewHead",
|
|
38
|
-
_0: s.f("params", S$RescriptSchema.object(s => s.f("result", S$RescriptSchema.object(s => s.f("number",
|
|
41
|
+
_0: s.f("params", S$RescriptSchema.object(s => s.f("result", S$RescriptSchema.object(s => s.f("number", hexIntSchema)))))
|
|
39
42
|
};
|
|
40
43
|
}),
|
|
41
44
|
S$RescriptSchema.object(s => {
|
|
@@ -111,6 +114,7 @@ export {
|
|
|
111
114
|
subscribeRequestJson,
|
|
112
115
|
responseIdSchema,
|
|
113
116
|
refusesSubscribe,
|
|
117
|
+
hexIntSchema,
|
|
114
118
|
wsMessageSchema,
|
|
115
119
|
subscribe,
|
|
116
120
|
}
|
|
@@ -47,6 +47,8 @@ let make = ({chainId, endpointUrl, apiToken, onEventRegistrations, addressStore}
|
|
|
47
47
|
|
|
48
48
|
let startFetchingBatchTimeRef = Performance.now()
|
|
49
49
|
|
|
50
|
+
let fetchStats = () => RequestStat.single(~method="getLogs", ~sentAt=startFetchingBatchTimeRef)
|
|
51
|
+
|
|
50
52
|
//fetch batch
|
|
51
53
|
let pageUnsafe = try await FuelHyperSync.GetLogs.query(
|
|
52
54
|
~client,
|
|
@@ -57,12 +59,12 @@ let make = ({chainId, endpointUrl, apiToken, onEventRegistrations, addressStore}
|
|
|
57
59
|
~clientFilteredContracts=selection.clientFilteredContracts,
|
|
58
60
|
) catch {
|
|
59
61
|
| FuelHyperSync.GetLogs.Error(WrongInstance) =>
|
|
60
|
-
throw(Source.SourceBehindHead({blockNumber: fromBlock, requestStats:
|
|
62
|
+
throw(Source.SourceBehindHead({blockNumber: fromBlock, requestStats: fetchStats()}))
|
|
61
63
|
| FuelHyperSync.GetLogs.Error(UnexpectedMissingParams({missingParams})) =>
|
|
62
64
|
throw(
|
|
63
65
|
Source.GetItemsError(
|
|
64
66
|
Source.FailedGettingItems({
|
|
65
|
-
|
|
67
|
+
requestStats: fetchStats(),
|
|
66
68
|
attemptedToBlock: toBlock->Option.getOr(knownHeight),
|
|
67
69
|
retry: ImpossibleForTheQuery({
|
|
68
70
|
message: `Source returned invalid data with missing required fields: ${missingParams->Array.joinUnsafe(
|
|
@@ -76,6 +78,7 @@ let make = ({chainId, endpointUrl, apiToken, onEventRegistrations, addressStore}
|
|
|
76
78
|
throw(
|
|
77
79
|
Source.GetItemsError(
|
|
78
80
|
Source.FailedGettingItems({
|
|
81
|
+
requestStats: fetchStats(),
|
|
79
82
|
exn,
|
|
80
83
|
attemptedToBlock: toBlock->Option.getOr(knownHeight),
|
|
81
84
|
retry: WithBackoff({
|
|
@@ -91,7 +94,7 @@ let make = ({chainId, endpointUrl, apiToken, onEventRegistrations, addressStore}
|
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
let pageFetchTime = startFetchingBatchTimeRef->Performance.secondsSince
|
|
94
|
-
let requestStats =
|
|
97
|
+
let requestStats = fetchStats()
|
|
95
98
|
|
|
96
99
|
//set height and next from block
|
|
97
100
|
let knownHeight = pageUnsafe.archiveHeight
|
|
@@ -192,7 +195,6 @@ let make = ({chainId, endpointUrl, apiToken, onEventRegistrations, addressStore}
|
|
|
192
195
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
193
196
|
stats,
|
|
194
197
|
knownHeight,
|
|
195
|
-
fromBlockQueried: fromBlock,
|
|
196
198
|
requestStats,
|
|
197
199
|
}
|
|
198
200
|
}
|
|
@@ -4,6 +4,7 @@ import * as Source from "./Source.res.mjs";
|
|
|
4
4
|
import * as Logging from "../Logging.res.mjs";
|
|
5
5
|
import * as HyperSync from "./HyperSync.res.mjs";
|
|
6
6
|
import * as Performance from "../bindings/Performance.res.mjs";
|
|
7
|
+
import * as RequestStat from "./RequestStat.res.mjs";
|
|
7
8
|
import * as ErrorHandling from "../ErrorHandling.res.mjs";
|
|
8
9
|
import * as FuelHyperSync from "./FuelHyperSync.res.mjs";
|
|
9
10
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
@@ -42,7 +43,7 @@ function make(param) {
|
|
|
42
43
|
throw {
|
|
43
44
|
RE_EXN_ID: Source.SourceBehindHead,
|
|
44
45
|
blockNumber: fromBlock,
|
|
45
|
-
requestStats:
|
|
46
|
+
requestStats: RequestStat.single("getLogs", startFetchingBatchTimeRef),
|
|
46
47
|
Error: new Error()
|
|
47
48
|
};
|
|
48
49
|
}
|
|
@@ -50,12 +51,12 @@ function make(param) {
|
|
|
50
51
|
RE_EXN_ID: Source.GetItemsError,
|
|
51
52
|
_1: {
|
|
52
53
|
TAG: "FailedGettingItems",
|
|
53
|
-
exn: null,
|
|
54
54
|
attemptedToBlock: Stdlib_Option.getOr(toBlock, knownHeight),
|
|
55
55
|
retry: {
|
|
56
56
|
TAG: "ImpossibleForTheQuery",
|
|
57
57
|
message: `Source returned invalid data with missing required fields: ` + match.missingParams.join(", ")
|
|
58
|
-
}
|
|
58
|
+
},
|
|
59
|
+
requestStats: RequestStat.single("getLogs", startFetchingBatchTimeRef)
|
|
59
60
|
},
|
|
60
61
|
Error: new Error()
|
|
61
62
|
};
|
|
@@ -70,16 +71,14 @@ function make(param) {
|
|
|
70
71
|
TAG: "WithBackoff",
|
|
71
72
|
message: `Unexpected issue while fetching events from HyperFuel client. Attempt a retry.`,
|
|
72
73
|
backoffMillis: retry !== 0 ? 1000 * retry | 0 : 500
|
|
73
|
-
}
|
|
74
|
+
},
|
|
75
|
+
requestStats: RequestStat.single("getLogs", startFetchingBatchTimeRef)
|
|
74
76
|
},
|
|
75
77
|
Error: new Error()
|
|
76
78
|
};
|
|
77
79
|
}
|
|
78
80
|
let pageFetchTime = Performance.secondsSince(startFetchingBatchTimeRef);
|
|
79
|
-
let requestStats =
|
|
80
|
-
method: "getLogs",
|
|
81
|
-
seconds: pageFetchTime
|
|
82
|
-
}];
|
|
81
|
+
let requestStats = RequestStat.single("getLogs", startFetchingBatchTimeRef);
|
|
83
82
|
let knownHeight$1 = pageUnsafe.archiveHeight;
|
|
84
83
|
let heighestBlockQueried = pageUnsafe.nextBlock - 1 | 0;
|
|
85
84
|
let parsingTimeRef = Performance.now();
|
|
@@ -164,7 +163,6 @@ function make(param) {
|
|
|
164
163
|
parsedQueueItems: parsedQueueItems,
|
|
165
164
|
transactionStore: undefined,
|
|
166
165
|
blockStore: pageUnsafe.blockStore,
|
|
167
|
-
fromBlockQueried: fromBlock,
|
|
168
166
|
latestFetchedBlockNumber: heighestBlockQueried,
|
|
169
167
|
stats: stats,
|
|
170
168
|
requestStats: requestStats
|
|
@@ -335,7 +335,13 @@ let pollOnce = async (feed: t) => {
|
|
|
335
335
|
(feed->currentInterval, Cadence)
|
|
336
336
|
| TimedOut =>
|
|
337
337
|
feed->backOff(~what=`did not answer within ${(pollTimeoutMillis / 1000)->Int.toString}s`)
|
|
338
|
-
| Failed(exn) =>
|
|
338
|
+
| Failed(exn) =>
|
|
339
|
+
// The request reached the endpoint and is billed whether or not it
|
|
340
|
+
// answered, so it counts; unwrapping also keeps the log the provider's own
|
|
341
|
+
// message rather than the envelope carrying it.
|
|
342
|
+
let failure = exn->Source.unpackNativeRequestFailure
|
|
343
|
+
feed.recordRequestStats(failure.requestStats)
|
|
344
|
+
feed->backOff(~what="failed", ~exn=failure.cause)
|
|
339
345
|
}
|
|
340
346
|
}
|
|
341
347
|
|
|
@@ -214,14 +214,16 @@ async function pollOnce(feed) {
|
|
|
214
214
|
if (typeof res !== "object") {
|
|
215
215
|
return backOff(feed, `did not answer within ` + (60).toString() + `s`, undefined);
|
|
216
216
|
}
|
|
217
|
-
if (res.TAG
|
|
218
|
-
|
|
217
|
+
if (res.TAG === "Answered") {
|
|
218
|
+
recordAnswer(feed, generation, res._0);
|
|
219
|
+
return [
|
|
220
|
+
currentInterval(feed),
|
|
221
|
+
"Cadence"
|
|
222
|
+
];
|
|
219
223
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"Cadence"
|
|
224
|
-
];
|
|
224
|
+
let failure = Source.unpackNativeRequestFailure(res._0);
|
|
225
|
+
feed.recordRequestStats(failure.requestStats);
|
|
226
|
+
return backOff(feed, "failed", failure.cause);
|
|
225
227
|
}
|
|
226
228
|
|
|
227
229
|
async function runPollLoop(feed) {
|
|
@@ -267,20 +267,7 @@ module EventItems = {
|
|
|
267
267
|
includeAllBlocks?: bool,
|
|
268
268
|
}
|
|
269
269
|
|
|
270
|
-
type item =
|
|
271
|
-
logIndex: int,
|
|
272
|
-
srcAddress: Address.t,
|
|
273
|
-
// Number of the block this log belongs to; the block itself is resolved from
|
|
274
|
-
// `response.blocks`, deduplicated across items sharing a block.
|
|
275
|
-
blockNumber: int,
|
|
276
|
-
// Key (with the block number) into the transaction store; the transaction
|
|
277
|
-
// is resolved from the store on demand.
|
|
278
|
-
transactionIndex: int,
|
|
279
|
-
// The registration this log routed to, by chain-scoped index. Logs that
|
|
280
|
-
// route to no registration never cross the boundary.
|
|
281
|
-
onEventRegistrationIndex: int,
|
|
282
|
-
params: Internal.eventParams,
|
|
283
|
-
}
|
|
270
|
+
type item = EvmEventItem.t
|
|
284
271
|
|
|
285
272
|
type response = {
|
|
286
273
|
archiveHeight: option<int>,
|
|
@@ -10,3 +10,10 @@ type t = {
|
|
|
10
10
|
// blocks, so a zero always means the request came back empty.
|
|
11
11
|
responseBlocks?: int,
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
// The one request a source method made, timed from when it was sent. Every
|
|
15
|
+
// way out of a fetch carries it: the request was made, and is billed, whether
|
|
16
|
+
// or not it answered.
|
|
17
|
+
let single = (~method, ~sentAt: Performance.timeRef) => [
|
|
18
|
+
{method, seconds: sentAt->Performance.secondsSince},
|
|
19
|
+
]
|
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import * as Performance from "../bindings/Performance.res.mjs";
|
|
4
|
+
|
|
5
|
+
function single(method, sentAt) {
|
|
6
|
+
return [{
|
|
7
|
+
method: method,
|
|
8
|
+
seconds: Performance.secondsSince(sentAt)
|
|
9
|
+
}];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
single,
|
|
14
|
+
}
|
|
15
|
+
/* No side effect */
|