envio 3.13.0-alpha.0 → 3.13.0-rc.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 +6 -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 +98 -76
- package/src/ChainState.res.mjs +74 -60
- package/src/ChainState.resi +13 -3
- package/src/Config.res +14 -17
- package/src/Config.res.mjs +5 -20
- package/src/CrossChainState.res +59 -18
- package/src/CrossChainState.res.mjs +33 -3
- 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 +10 -4
- package/src/FinalizeBackfill.res.mjs +5 -3
- 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 +1 -1
- package/src/TestIndexer.res.mjs +1 -1
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envio",
|
|
3
|
-
"version": "3.13.0-
|
|
3
|
+
"version": "3.13.0-rc.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
|
|
6
6
|
"bin": "./bin.mjs",
|
|
@@ -49,11 +49,9 @@
|
|
|
49
49
|
"@fuel-ts/utils": "0.96.1",
|
|
50
50
|
"bignumber.js": "9.3.1",
|
|
51
51
|
"eventsource": "4.1.0",
|
|
52
|
-
"js-sdsl": "4.4.2",
|
|
53
52
|
"express": "4.19.2",
|
|
54
53
|
"pino": "10.3.1",
|
|
55
54
|
"pino-pretty": "13.1.3",
|
|
56
|
-
"yargs": "17.7.2",
|
|
57
55
|
"@rescript/runtime": "12.2.0",
|
|
58
56
|
"rescript-schema": "9.5.1",
|
|
59
57
|
"viem": "2.54.0",
|
|
@@ -68,10 +66,10 @@
|
|
|
68
66
|
"tsx": "4.21.0"
|
|
69
67
|
},
|
|
70
68
|
"optionalDependencies": {
|
|
71
|
-
"envio-linux-x64": "3.13.0-
|
|
72
|
-
"envio-linux-x64-musl": "3.13.0-
|
|
73
|
-
"envio-linux-arm64": "3.13.0-
|
|
74
|
-
"envio-darwin-x64": "3.13.0-
|
|
75
|
-
"envio-darwin-arm64": "3.13.0-
|
|
69
|
+
"envio-linux-x64": "3.13.0-rc.0",
|
|
70
|
+
"envio-linux-x64-musl": "3.13.0-rc.0",
|
|
71
|
+
"envio-linux-arm64": "3.13.0-rc.0",
|
|
72
|
+
"envio-darwin-x64": "3.13.0-rc.0",
|
|
73
|
+
"envio-darwin-arm64": "3.13.0-rc.0"
|
|
76
74
|
}
|
|
77
75
|
}
|
package/src/BatchProcessing.res
CHANGED
|
@@ -69,7 +69,8 @@ and processNextBatch = async (state: IndexerState.t, ~scheduleFetch): unit => {
|
|
|
69
69
|
let isInReorgThresholdBeforeUpdate = state->IndexerState.isInReorgThreshold
|
|
70
70
|
let isRealtimeBeforeUpdate = state->IndexerState.isRealtime
|
|
71
71
|
|
|
72
|
-
let batch =
|
|
72
|
+
let batch =
|
|
73
|
+
state->IndexerState.createBatch(~batchSizeTarget=(state->IndexerState.config).batchSize)
|
|
73
74
|
|
|
74
75
|
let progressedChainsById = batch.progressedChainsById
|
|
75
76
|
|
|
@@ -105,8 +106,8 @@ and processNextBatch = async (state: IndexerState.t, ~scheduleFetch): unit => {
|
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
// When resuming from persisted state, all events may already be processed.
|
|
109
|
+
state->IndexerState.reportFinished
|
|
108
110
|
if EventProcessing.allChainsEventsProcessedToEndblock(state->IndexerState.chainStates) {
|
|
109
|
-
Logging.info("All chains are caught up to end blocks.")
|
|
110
111
|
if !(state->IndexerState.keepProcessAlive) && !(state->IndexerState.isHoldingRealtime) {
|
|
111
112
|
await ExitOnCaughtUp.run(state)
|
|
112
113
|
}
|
|
@@ -158,6 +159,9 @@ and processNextBatch = async (state: IndexerState.t, ~scheduleFetch): unit => {
|
|
|
158
159
|
// Can safely reset rollback state, since overwrite is not possible.
|
|
159
160
|
state->IndexerState.clearRollback
|
|
160
161
|
state->IndexerState.applyBatchProgress(~batch)
|
|
162
|
+
// Before the finalize below, so a chain says where it finished ahead of
|
|
163
|
+
// the process saying what it does about that.
|
|
164
|
+
state->IndexerState.reportFinished
|
|
161
165
|
|
|
162
166
|
// Backfilling → FinalizingIndexes → Ready. Awaiting here holds the
|
|
163
167
|
// processing loop for the whole finalize, which is what pauses
|
|
@@ -178,9 +182,6 @@ and processNextBatch = async (state: IndexerState.t, ~scheduleFetch): unit => {
|
|
|
178
182
|
let allCaughtUp = EventProcessing.allChainsEventsProcessedToEndblock(
|
|
179
183
|
state->IndexerState.chainStates,
|
|
180
184
|
)
|
|
181
|
-
if allCaughtUp {
|
|
182
|
-
Logging.info("All chains are caught up to end blocks.")
|
|
183
|
-
}
|
|
184
185
|
|
|
185
186
|
if (
|
|
186
187
|
allCaughtUp &&
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Utils from "./Utils.res.mjs";
|
|
4
|
-
import * as Logging from "./Logging.res.mjs";
|
|
5
4
|
import * as ChainState from "./ChainState.res.mjs";
|
|
6
5
|
import * as IndexerState from "./IndexerState.res.mjs";
|
|
7
6
|
import * as ChainMetadata from "./ChainMetadata.res.mjs";
|
|
@@ -42,13 +41,9 @@ async function processNextBatch(state, scheduleFetch) {
|
|
|
42
41
|
IndexerState.invalidateInflight(state);
|
|
43
42
|
scheduleFetch();
|
|
44
43
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return await ExitOnCaughtUp.run(state);
|
|
49
|
-
} else {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
44
|
+
IndexerState.reportFinished(state);
|
|
45
|
+
if (EventProcessing.allChainsEventsProcessedToEndblock(IndexerState.chainStates(state)) && !IndexerState.keepProcessAlive(state) && !IndexerState.isHoldingRealtime(state)) {
|
|
46
|
+
return await ExitOnCaughtUp.run(state);
|
|
52
47
|
} else {
|
|
53
48
|
return;
|
|
54
49
|
}
|
|
@@ -70,6 +65,7 @@ async function processNextBatch(state, scheduleFetch) {
|
|
|
70
65
|
}
|
|
71
66
|
IndexerState.clearRollback(state);
|
|
72
67
|
IndexerState.applyBatchProgress(state, batch);
|
|
68
|
+
IndexerState.reportFinished(state);
|
|
73
69
|
if (IndexerState.shouldFinalizeIndexes(state)) {
|
|
74
70
|
await FinalizeBackfill.run(state);
|
|
75
71
|
}
|
|
@@ -78,9 +74,6 @@ async function processNextBatch(state, scheduleFetch) {
|
|
|
78
74
|
scheduleFetch();
|
|
79
75
|
}
|
|
80
76
|
let allCaughtUp = EventProcessing.allChainsEventsProcessedToEndblock(IndexerState.chainStates(state));
|
|
81
|
-
if (allCaughtUp) {
|
|
82
|
-
Logging.info("All chains are caught up to end blocks.");
|
|
83
|
-
}
|
|
84
77
|
if (allCaughtUp && !IndexerState.keepProcessAlive(state) && !IndexerState.isHoldingRealtime(state)) {
|
|
85
78
|
return await ExitOnCaughtUp.run(state);
|
|
86
79
|
} else if (!allCaughtUp && IndexerState.exitAfterFirstEventBlock(state) && Object.values(IndexerState.chainStates(state)).every(ChainState.isAtHeadWithoutEndBlock)) {
|
package/src/ChainFetching.res
CHANGED
|
@@ -12,16 +12,16 @@ let runContractRegistersOrThrow = async (
|
|
|
12
12
|
~itemsWithContractRegister: array<Internal.item>,
|
|
13
13
|
~config: Config.t,
|
|
14
14
|
~chainState: ChainState.t,
|
|
15
|
-
~transactionStore: option<TransactionStore.t>,
|
|
16
15
|
) => {
|
|
17
16
|
// contractRegister handlers can read event.transaction and event.block, so
|
|
18
17
|
// materialise the selected fields onto the payloads before running them. All
|
|
19
|
-
// items belong to the chain being fetched
|
|
20
|
-
//
|
|
18
|
+
// items belong to the chain being fetched, and both stores are the chain's
|
|
19
|
+
// own, which this response's pages have already been merged into.
|
|
21
20
|
await ChainState.materializePageItems(
|
|
22
21
|
~items=itemsWithContractRegister,
|
|
23
|
-
~transactionStore,
|
|
22
|
+
~transactionStore=chainState->ChainState.transactionStore,
|
|
24
23
|
~blockStore=chainState->ChainState.blockStore,
|
|
24
|
+
~shouldChecksum=chainState->ChainState.shouldChecksum,
|
|
25
25
|
)
|
|
26
26
|
|
|
27
27
|
let registrations: array<AddressStore.registration> = []
|
|
@@ -113,14 +113,13 @@ let rec onQueryResponse = async (
|
|
|
113
113
|
latestFetchedBlockNumber,
|
|
114
114
|
stats,
|
|
115
115
|
knownHeight,
|
|
116
|
-
fromBlockQueried,
|
|
117
116
|
} = response
|
|
118
117
|
|
|
119
118
|
chainState->ChainState.recordBlockRangeFetch(
|
|
120
119
|
~totalTimeElapsed=stats.totalTimeElapsed,
|
|
121
120
|
~parsingTimeElapsed=stats.parsingTimeElapsed->Option.getOr(0.),
|
|
122
121
|
~numEvents=parsedQueueItems->Array.length,
|
|
123
|
-
~blockRangeSize=latestFetchedBlockNumber -
|
|
122
|
+
~blockRangeSize=latestFetchedBlockNumber - query.fromBlock + 1,
|
|
124
123
|
)
|
|
125
124
|
|
|
126
125
|
let numContractRegisterEvents = parsedQueueItems->Array.reduce(0, (count, item) => {
|
|
@@ -132,7 +131,7 @@ let rec onQueryResponse = async (
|
|
|
132
131
|
"msg": "Finished querying",
|
|
133
132
|
"chainId": chainId,
|
|
134
133
|
"partitionId": query.partitionId,
|
|
135
|
-
"fromBlock":
|
|
134
|
+
"fromBlock": query.fromBlock,
|
|
136
135
|
"toBlock": latestFetchedBlockNumber,
|
|
137
136
|
"numEvents": parsedQueueItems->Array.length,
|
|
138
137
|
})
|
|
@@ -141,7 +140,7 @@ let rec onQueryResponse = async (
|
|
|
141
140
|
"msg": "Finished querying",
|
|
142
141
|
"chainId": chainId,
|
|
143
142
|
"partitionId": query.partitionId,
|
|
144
|
-
"fromBlock":
|
|
143
|
+
"fromBlock": query.fromBlock,
|
|
145
144
|
"toBlock": latestFetchedBlockNumber,
|
|
146
145
|
"numEvents": parsedQueueItems->Array.length,
|
|
147
146
|
"numContractRegisterEvents": numContractRegisterEvents,
|
|
@@ -200,7 +199,18 @@ let rec onQueryResponse = async (
|
|
|
200
199
|
// Advances synchronously to FindingReorgDepth, so a concurrent rollback
|
|
201
200
|
// kick (eg from the processing loop quiescing) collapses into this one.
|
|
202
201
|
scheduleRollback()
|
|
202
|
+
// No rollback: either the guard found no reorg, or it found one and this
|
|
203
|
+
// chain only reports them. Either way the guard has merged the blocks, so
|
|
204
|
+
// the transactions follow. A source that reads the chain store to decide
|
|
205
|
+
// what to fetch leaves out what the store already holds, so its page alone
|
|
206
|
+
// does not cover its own items — only the merged store does, and contract
|
|
207
|
+
// registers read it below.
|
|
203
208
|
| None =>
|
|
209
|
+
switch transactionStore {
|
|
210
|
+
| Some(page) => chainState->ChainState.transactionStore->TransactionStore.merge(page)
|
|
211
|
+
| None => ()
|
|
212
|
+
}
|
|
213
|
+
|
|
204
214
|
// Over-fetched events (a merged partition returning an address before its
|
|
205
215
|
// effectiveStartBlock, a wildcard param referencing an address registered
|
|
206
216
|
// after the log's block, or a registration whose own start block is later
|
|
@@ -228,7 +238,6 @@ let rec onQueryResponse = async (
|
|
|
228
238
|
~knownHeight,
|
|
229
239
|
~latestFetchedBlock=latestFetchedBlockNumber,
|
|
230
240
|
~query,
|
|
231
|
-
~transactionStore,
|
|
232
241
|
)
|
|
233
242
|
ChainMetadata.stage(state)
|
|
234
243
|
scheduleFetch()
|
|
@@ -242,7 +251,6 @@ let rec onQueryResponse = async (
|
|
|
242
251
|
~itemsWithContractRegister,
|
|
243
252
|
~config=state->IndexerState.config,
|
|
244
253
|
~chainState,
|
|
245
|
-
~transactionStore,
|
|
246
254
|
) {
|
|
247
255
|
| exception exn => IndexerState.errorExit(state, exn->ErrorHandling.make)
|
|
248
256
|
| newRegistrations => proceed(~newRegistrations)
|
|
@@ -259,7 +267,6 @@ and applyQueryResponse = (
|
|
|
259
267
|
~knownHeight,
|
|
260
268
|
~latestFetchedBlock,
|
|
261
269
|
~query,
|
|
262
|
-
~transactionStore,
|
|
263
270
|
) => {
|
|
264
271
|
let chainState = state->IndexerState.getChainState(~chainId)
|
|
265
272
|
|
|
@@ -269,7 +276,6 @@ and applyQueryResponse = (
|
|
|
269
276
|
~newItems,
|
|
270
277
|
~newRegistrations,
|
|
271
278
|
~knownHeight,
|
|
272
|
-
~transactionStore,
|
|
273
279
|
)
|
|
274
280
|
|
|
275
281
|
// In auto-exit mode, set endBlock to the first event's block when events arrive.
|
|
@@ -278,32 +284,6 @@ and applyQueryResponse = (
|
|
|
278
284
|
~blockNumber=newItems->Array.getUnsafe(0)->Internal.getItemBlockNumber,
|
|
279
285
|
)
|
|
280
286
|
}
|
|
281
|
-
|
|
282
|
-
// Report the milestone this response brought the fetch frontier to, once.
|
|
283
|
-
// The chain reaches it again every time the head moves and it catches up, so
|
|
284
|
-
// what keeps the line off the log is the chain having already reported it,
|
|
285
|
-
// not the transition — which re-arms on every advance.
|
|
286
|
-
switch chainState->ChainState.isFetchingAtHead
|
|
287
|
-
? chainState->ChainState.takeFetchedTo
|
|
288
|
-
: None {
|
|
289
|
-
| None => ()
|
|
290
|
-
| Some((target, block)) =>
|
|
291
|
-
// What the chain is waiting on, which is not itself. A held process is
|
|
292
|
-
// waiting on chains it doesn't drive, so it says so even when it drives
|
|
293
|
-
// only one — how the run is split is not the reader's problem.
|
|
294
|
-
let waitingOn = if (
|
|
295
|
-
state->IndexerState.isHoldingRealtime ||
|
|
296
|
-
state->IndexerState.chainStates->Dict.keysToArray->Array.length > 1
|
|
297
|
-
) {
|
|
298
|
-
" Waiting for other chains."
|
|
299
|
-
} else {
|
|
300
|
-
""
|
|
301
|
-
}
|
|
302
|
-
chainState->ChainState.logger->Logging.childInfo({
|
|
303
|
-
"msg": `Fetched to ${target}.${waitingOn}`,
|
|
304
|
-
"block": block,
|
|
305
|
-
})
|
|
306
|
-
}
|
|
307
287
|
}
|
|
308
288
|
|
|
309
289
|
let finishWaitingForNewBlock = (
|
|
@@ -13,11 +13,12 @@ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
|
13
13
|
import * as ReorgDetection from "./ReorgDetection.res.mjs";
|
|
14
14
|
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
15
15
|
import * as Stdlib_Promise from "@rescript/runtime/lib/es6/Stdlib_Promise.js";
|
|
16
|
+
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
16
17
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
17
18
|
import * as ContractRegisterContext from "./ContractRegisterContext.res.mjs";
|
|
18
19
|
|
|
19
|
-
async function runContractRegistersOrThrow(itemsWithContractRegister, config, chainState
|
|
20
|
-
await ChainState.materializePageItems(itemsWithContractRegister, transactionStore, ChainState.blockStore(chainState));
|
|
20
|
+
async function runContractRegistersOrThrow(itemsWithContractRegister, config, chainState) {
|
|
21
|
+
await ChainState.materializePageItems(itemsWithContractRegister, ChainState.transactionStore(chainState), ChainState.blockStore(chainState), ChainState.shouldChecksum(chainState));
|
|
21
22
|
let registrations = [];
|
|
22
23
|
let onRegister = (item, contractAddress, contractName) => {
|
|
23
24
|
registrations.push({
|
|
@@ -63,21 +64,12 @@ async function runContractRegistersOrThrow(itemsWithContractRegister, config, ch
|
|
|
63
64
|
return registrations;
|
|
64
65
|
}
|
|
65
66
|
|
|
66
|
-
function applyQueryResponse(state, chainId, newItems, newRegistrations, knownHeight, latestFetchedBlock, query
|
|
67
|
+
function applyQueryResponse(state, chainId, newItems, newRegistrations, knownHeight, latestFetchedBlock, query) {
|
|
67
68
|
let chainState = IndexerState.getChainState(state, chainId);
|
|
68
|
-
ChainState.handleQueryResult(chainState, query, newItems, newRegistrations, latestFetchedBlock, knownHeight
|
|
69
|
+
ChainState.handleQueryResult(chainState, query, newItems, newRegistrations, latestFetchedBlock, knownHeight);
|
|
69
70
|
if (IndexerState.exitAfterFirstEventBlock(state) && newItems.length !== 0) {
|
|
70
|
-
ChainState.setEndBlockToFirstEvent(chainState, newItems[0].blockNumber);
|
|
71
|
+
return ChainState.setEndBlockToFirstEvent(chainState, newItems[0].blockNumber);
|
|
71
72
|
}
|
|
72
|
-
let match = ChainState.isFetchingAtHead(chainState) ? ChainState.takeFetchedTo(chainState) : undefined;
|
|
73
|
-
if (match === undefined) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
let waitingOn = IndexerState.isHoldingRealtime(state) || Object.keys(IndexerState.chainStates(state)).length > 1 ? " Waiting for other chains." : "";
|
|
77
|
-
Logging.childInfo(ChainState.logger(chainState), {
|
|
78
|
-
msg: `Fetched to ` + match[0] + `.` + waitingOn,
|
|
79
|
-
block: match[1]
|
|
80
|
-
});
|
|
81
73
|
}
|
|
82
74
|
|
|
83
75
|
async function onQueryResponse(state, param, stateId, scheduleFetch, scheduleProcessing, scheduleRollback) {
|
|
@@ -90,11 +82,10 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
90
82
|
let chainState = IndexerState.getChainState(state, chainId);
|
|
91
83
|
let stats = response.stats;
|
|
92
84
|
let latestFetchedBlockNumber = response.latestFetchedBlockNumber;
|
|
93
|
-
let fromBlockQueried = response.fromBlockQueried;
|
|
94
85
|
let transactionStore = response.transactionStore;
|
|
95
86
|
let parsedQueueItems = response.parsedQueueItems;
|
|
96
87
|
let knownHeight = response.knownHeight;
|
|
97
|
-
ChainState.recordBlockRangeFetch(chainState, stats["total time elapsed (s)"], Stdlib_Option.getOr(stats["parsing time (s)"], 0), parsedQueueItems.length, (latestFetchedBlockNumber -
|
|
88
|
+
ChainState.recordBlockRangeFetch(chainState, stats["total time elapsed (s)"], Stdlib_Option.getOr(stats["parsing time (s)"], 0), parsedQueueItems.length, (latestFetchedBlockNumber - query.fromBlock | 0) + 1 | 0);
|
|
98
89
|
let numContractRegisterEvents = Stdlib_Array.reduce(parsedQueueItems, 0, (count, item) => {
|
|
99
90
|
if (item.onEventRegistration.contractRegister !== undefined) {
|
|
100
91
|
return count + 1 | 0;
|
|
@@ -107,7 +98,7 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
107
98
|
msg: "Finished querying",
|
|
108
99
|
chainId: chainId,
|
|
109
100
|
partitionId: query.partitionId,
|
|
110
|
-
fromBlock:
|
|
101
|
+
fromBlock: query.fromBlock,
|
|
111
102
|
toBlock: latestFetchedBlockNumber,
|
|
112
103
|
numEvents: parsedQueueItems.length
|
|
113
104
|
});
|
|
@@ -116,7 +107,7 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
116
107
|
msg: "Finished querying",
|
|
117
108
|
chainId: chainId,
|
|
118
109
|
partitionId: query.partitionId,
|
|
119
|
-
fromBlock:
|
|
110
|
+
fromBlock: query.fromBlock,
|
|
120
111
|
toBlock: latestFetchedBlockNumber,
|
|
121
112
|
numEvents: parsedQueueItems.length,
|
|
122
113
|
numContractRegisterEvents: numContractRegisterEvents
|
|
@@ -140,6 +131,9 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
140
131
|
IndexerState.beginReorg(state, chainId, rollbackWithReorgDetectedBlockNumber);
|
|
141
132
|
return scheduleRollback();
|
|
142
133
|
}
|
|
134
|
+
if (transactionStore !== undefined) {
|
|
135
|
+
ChainState.transactionStore(chainState).merge(Primitive_option.valFromOption(transactionStore));
|
|
136
|
+
}
|
|
143
137
|
let itemsWithContractRegister = [];
|
|
144
138
|
for (let idx = 0, idx_finish = parsedQueueItems.length; idx < idx_finish; ++idx) {
|
|
145
139
|
let item = parsedQueueItems[idx];
|
|
@@ -149,7 +143,7 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
149
143
|
}
|
|
150
144
|
let proceed = newRegistrations => {
|
|
151
145
|
if (!IndexerState.isStale(state, stateId)) {
|
|
152
|
-
applyQueryResponse(state, chainId, parsedQueueItems, newRegistrations, knownHeight, latestFetchedBlockNumber, query
|
|
146
|
+
applyQueryResponse(state, chainId, parsedQueueItems, newRegistrations, knownHeight, latestFetchedBlockNumber, query);
|
|
153
147
|
ChainMetadata.stage(state);
|
|
154
148
|
scheduleFetch();
|
|
155
149
|
return scheduleProcessing();
|
|
@@ -160,7 +154,7 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
160
154
|
}
|
|
161
155
|
let newRegistrations;
|
|
162
156
|
try {
|
|
163
|
-
newRegistrations = await runContractRegistersOrThrow(itemsWithContractRegister, IndexerState.config(state), chainState
|
|
157
|
+
newRegistrations = await runContractRegistersOrThrow(itemsWithContractRegister, IndexerState.config(state), chainState);
|
|
164
158
|
} catch (raw_exn) {
|
|
165
159
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
166
160
|
return IndexerState.errorExit(state, ErrorHandling.make(exn, undefined, undefined));
|