envio 3.0.0-alpha.21 → 3.0.0-alpha.23
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/README.md +3 -3
- package/bin.mjs +2 -48
- package/evm.schema.json +67 -0
- package/fuel.schema.json +67 -0
- package/index.d.ts +822 -38
- package/index.js +5 -3
- package/package.json +10 -8
- package/rescript.json +5 -9
- package/src/Address.res +4 -5
- package/src/Address.res.mjs +9 -12
- package/src/Api.res +15 -0
- package/src/Api.res.mjs +20 -0
- package/src/Batch.res +32 -34
- package/src/Batch.res.mjs +172 -187
- package/src/Bin.res +89 -0
- package/src/Bin.res.mjs +97 -0
- package/src/ChainFetcher.res +33 -57
- package/src/ChainFetcher.res.mjs +197 -227
- package/src/ChainManager.res +6 -14
- package/src/ChainManager.res.mjs +74 -85
- package/src/ChainMap.res +14 -16
- package/src/ChainMap.res.mjs +38 -38
- package/src/Config.res +193 -135
- package/src/Config.res.mjs +566 -592
- package/src/Core.res +182 -0
- package/src/Core.res.mjs +207 -0
- package/src/Ecosystem.res +25 -4
- package/src/Ecosystem.res.mjs +12 -13
- package/src/Env.res +20 -13
- package/src/Env.res.mjs +124 -113
- package/src/EnvSafe.res +269 -0
- package/src/EnvSafe.res.mjs +296 -0
- package/src/EnvSafe.resi +18 -0
- package/src/Envio.res +37 -26
- package/src/Envio.res.mjs +59 -60
- package/src/ErrorHandling.res +2 -2
- package/src/ErrorHandling.res.mjs +15 -15
- package/src/EventConfigBuilder.res +219 -81
- package/src/EventConfigBuilder.res.mjs +259 -202
- package/src/EventProcessing.res +27 -38
- package/src/EventProcessing.res.mjs +165 -183
- package/src/EventUtils.res +11 -11
- package/src/EventUtils.res.mjs +21 -22
- package/src/EvmTypes.res +0 -1
- package/src/EvmTypes.res.mjs +5 -5
- package/src/FetchState.res +360 -256
- package/src/FetchState.res.mjs +958 -914
- package/src/GlobalState.res +365 -351
- package/src/GlobalState.res.mjs +958 -992
- package/src/GlobalStateManager.res +1 -2
- package/src/GlobalStateManager.res.mjs +36 -44
- package/src/HandlerLoader.res +107 -23
- package/src/HandlerLoader.res.mjs +128 -38
- package/src/HandlerRegister.res +127 -103
- package/src/HandlerRegister.res.mjs +164 -164
- package/src/HandlerRegister.resi +12 -4
- package/src/Hasura.res +35 -22
- package/src/Hasura.res.mjs +158 -167
- package/src/InMemoryStore.res +20 -27
- package/src/InMemoryStore.res.mjs +64 -80
- package/src/InMemoryTable.res +34 -39
- package/src/InMemoryTable.res.mjs +165 -170
- package/src/Internal.res +52 -33
- package/src/Internal.res.mjs +84 -81
- package/src/LazyLoader.res.mjs +55 -61
- package/src/LoadLayer.res +77 -78
- package/src/LoadLayer.res.mjs +160 -189
- package/src/LoadManager.res +16 -21
- package/src/LoadManager.res.mjs +79 -84
- package/src/LogSelection.res +236 -68
- package/src/LogSelection.res.mjs +211 -141
- package/src/Logging.res +13 -9
- package/src/Logging.res.mjs +130 -143
- package/src/Main.res +430 -51
- package/src/Main.res.mjs +530 -271
- package/src/Persistence.res +80 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +294 -167
- package/src/PgStorage.res.mjs +799 -817
- package/src/Prometheus.res +50 -58
- package/src/Prometheus.res.mjs +345 -373
- package/src/ReorgDetection.res +22 -24
- package/src/ReorgDetection.res.mjs +100 -106
- package/src/SafeCheckpointTracking.res +7 -7
- package/src/SafeCheckpointTracking.res.mjs +40 -43
- package/src/SimulateItems.res +41 -49
- package/src/SimulateItems.res.mjs +257 -272
- package/src/Sink.res +2 -2
- package/src/Sink.res.mjs +22 -26
- package/src/TableIndices.res +1 -2
- package/src/TableIndices.res.mjs +42 -48
- package/src/TestIndexer.res +196 -189
- package/src/TestIndexer.res.mjs +536 -536
- package/src/TestIndexerProxyStorage.res +16 -16
- package/src/TestIndexerProxyStorage.res.mjs +99 -122
- package/src/TestIndexerWorker.res +4 -0
- package/src/TestIndexerWorker.res.mjs +7 -0
- package/src/Throttler.res +3 -3
- package/src/Throttler.res.mjs +23 -24
- package/src/Time.res +1 -1
- package/src/Time.res.mjs +18 -21
- package/src/TopicFilter.res +3 -3
- package/src/TopicFilter.res.mjs +29 -30
- package/src/UserContext.res +93 -54
- package/src/UserContext.res.mjs +197 -182
- package/src/Utils.res +141 -86
- package/src/Utils.res.mjs +334 -295
- package/src/bindings/BigDecimal.res +0 -2
- package/src/bindings/BigDecimal.res.mjs +19 -23
- package/src/bindings/ClickHouse.res +28 -27
- package/src/bindings/ClickHouse.res.mjs +243 -240
- package/src/bindings/DateFns.res +11 -11
- package/src/bindings/DateFns.res.mjs +7 -7
- package/src/bindings/EventSource.res.mjs +2 -2
- package/src/bindings/Express.res +2 -5
- package/src/bindings/Hrtime.res +2 -2
- package/src/bindings/Hrtime.res.mjs +30 -32
- package/src/bindings/Lodash.res.mjs +1 -1
- package/src/bindings/NodeJs.res +14 -9
- package/src/bindings/NodeJs.res.mjs +20 -20
- package/src/bindings/Pino.res +8 -10
- package/src/bindings/Pino.res.mjs +40 -43
- package/src/bindings/Postgres.res +7 -5
- package/src/bindings/Postgres.res.mjs +9 -9
- package/src/bindings/PromClient.res +17 -2
- package/src/bindings/PromClient.res.mjs +30 -7
- package/src/bindings/SDSL.res.mjs +2 -2
- package/src/bindings/Viem.res +4 -4
- package/src/bindings/Viem.res.mjs +20 -22
- package/src/bindings/Vitest.res +1 -1
- package/src/bindings/Vitest.res.mjs +2 -2
- package/src/bindings/WebSocket.res +1 -1
- package/src/db/EntityHistory.res +9 -3
- package/src/db/EntityHistory.res.mjs +84 -59
- package/src/db/InternalTable.res +62 -60
- package/src/db/InternalTable.res.mjs +271 -203
- package/src/db/Schema.res +1 -2
- package/src/db/Schema.res.mjs +28 -32
- package/src/db/Table.res +28 -27
- package/src/db/Table.res.mjs +276 -292
- package/src/sources/EventRouter.res +21 -16
- package/src/sources/EventRouter.res.mjs +55 -57
- package/src/sources/Evm.res +17 -1
- package/src/sources/Evm.res.mjs +16 -8
- package/src/sources/EvmChain.res +15 -17
- package/src/sources/EvmChain.res.mjs +40 -42
- package/src/sources/Fuel.res +14 -1
- package/src/sources/Fuel.res.mjs +16 -8
- package/src/sources/FuelSDK.res +1 -1
- package/src/sources/FuelSDK.res.mjs +6 -8
- package/src/sources/HyperFuel.res +8 -10
- package/src/sources/HyperFuel.res.mjs +113 -123
- package/src/sources/HyperFuelClient.res.mjs +6 -7
- package/src/sources/HyperFuelSource.res +19 -20
- package/src/sources/HyperFuelSource.res.mjs +339 -356
- package/src/sources/HyperSync.res +11 -13
- package/src/sources/HyperSync.res.mjs +206 -220
- package/src/sources/HyperSyncClient.res +5 -7
- package/src/sources/HyperSyncClient.res.mjs +70 -75
- package/src/sources/HyperSyncHeightStream.res +8 -9
- package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
- package/src/sources/HyperSyncJsonApi.res +18 -15
- package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
- package/src/sources/HyperSyncSource.res +17 -21
- package/src/sources/HyperSyncSource.res.mjs +268 -290
- package/src/sources/Rpc.res +5 -5
- package/src/sources/Rpc.res.mjs +168 -192
- package/src/sources/RpcSource.res +166 -167
- package/src/sources/RpcSource.res.mjs +972 -1046
- package/src/sources/RpcWebSocketHeightStream.res +10 -11
- package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
- package/src/sources/SimulateSource.res +1 -1
- package/src/sources/SimulateSource.res.mjs +35 -38
- package/src/sources/Source.res +1 -1
- package/src/sources/Source.res.mjs +3 -3
- package/src/sources/SourceManager.res +39 -20
- package/src/sources/SourceManager.res.mjs +340 -371
- package/src/sources/SourceManager.resi +2 -1
- package/src/sources/Svm.res +12 -5
- package/src/sources/Svm.res.mjs +44 -41
- package/src/tui/Tui.res +23 -12
- package/src/tui/Tui.res.mjs +292 -290
- package/src/tui/bindings/Ink.res +2 -4
- package/src/tui/bindings/Ink.res.mjs +35 -41
- package/src/tui/components/BufferedProgressBar.res +7 -7
- package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
- package/src/tui/components/CustomHooks.res +1 -2
- package/src/tui/components/CustomHooks.res.mjs +102 -122
- package/src/tui/components/Messages.res +1 -2
- package/src/tui/components/Messages.res.mjs +38 -42
- package/src/tui/components/SyncETA.res +10 -11
- package/src/tui/components/SyncETA.res.mjs +178 -196
- package/src/tui/components/TuiData.res +1 -1
- package/src/tui/components/TuiData.res.mjs +7 -6
- package/src/vendored/Rest.res +52 -66
- package/src/vendored/Rest.res.mjs +324 -364
- package/svm.schema.json +67 -0
- package/src/Address.gen.ts +0 -8
- package/src/Config.gen.ts +0 -19
- package/src/Envio.gen.ts +0 -55
- package/src/EvmTypes.gen.ts +0 -6
- package/src/InMemoryStore.gen.ts +0 -6
- package/src/Internal.gen.ts +0 -64
- package/src/PgStorage.gen.ts +0 -10
- package/src/PgStorage.res.d.mts +0 -5
- package/src/Types.ts +0 -56
- package/src/bindings/BigDecimal.gen.ts +0 -14
- package/src/bindings/BigDecimal.res.d.mts +0 -5
- package/src/bindings/BigInt.gen.ts +0 -10
- package/src/bindings/BigInt.res +0 -70
- package/src/bindings/BigInt.res.d.mts +0 -5
- package/src/bindings/BigInt.res.mjs +0 -154
- package/src/bindings/Ethers.res.d.mts +0 -5
- package/src/bindings/Pino.gen.ts +0 -17
- package/src/bindings/Postgres.gen.ts +0 -8
- package/src/bindings/Postgres.res.d.mts +0 -5
- package/src/bindings/Promise.res +0 -67
- package/src/bindings/Promise.res.mjs +0 -26
- package/src/db/InternalTable.gen.ts +0 -36
- package/src/sources/HyperSyncClient.gen.ts +0 -19
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
|
-
|
|
3
1
|
type sourceManagerStatus = Idle | WaitingForNewBlock | Querieng
|
|
4
2
|
|
|
5
3
|
type sourceState = {
|
|
@@ -26,6 +24,7 @@ type t = {
|
|
|
26
24
|
newBlockStallTimeout: int,
|
|
27
25
|
newBlockStallTimeoutLive: int,
|
|
28
26
|
stalledPollingInterval: int,
|
|
27
|
+
reducedPollingInterval: int,
|
|
29
28
|
getHeightRetryInterval: (~retry: int) => int,
|
|
30
29
|
mutable activeSource: Source.t,
|
|
31
30
|
mutable waitingForNewBlockStateId: option<int>,
|
|
@@ -75,6 +74,7 @@ let make = (
|
|
|
75
74
|
~newBlockStallTimeout=60_000,
|
|
76
75
|
~newBlockStallTimeoutLive=20_000,
|
|
77
76
|
~stalledPollingInterval=5_000,
|
|
77
|
+
~reducedPollingInterval=60_000,
|
|
78
78
|
~recoveryTimeout=60_000.0,
|
|
79
79
|
~getHeightRetryInterval=makeGetHeightRetryInterval(
|
|
80
80
|
~initialRetryInterval=1000,
|
|
@@ -82,12 +82,13 @@ let make = (
|
|
|
82
82
|
~maxRetryInterval=60_000,
|
|
83
83
|
),
|
|
84
84
|
) => {
|
|
85
|
-
let hasLive = sources->
|
|
86
|
-
let initialActiveSource = switch sources->
|
|
85
|
+
let hasLive = sources->Array.some(s => s.sourceFor === Live)
|
|
86
|
+
let initialActiveSource = switch sources->Array.find(source =>
|
|
87
87
|
getSourceRole(~sourceFor=source.sourceFor, ~isLive, ~hasLive) === Some(Primary)
|
|
88
88
|
) {
|
|
89
89
|
| Some(source) => source
|
|
90
|
-
| None =>
|
|
90
|
+
| None =>
|
|
91
|
+
JsError.throwWithMessage("Invalid configuration, no data-source for historical sync provided")
|
|
91
92
|
}
|
|
92
93
|
Prometheus.IndexingMaxConcurrency.set(
|
|
93
94
|
~maxConcurrency=maxPartitionConcurrency,
|
|
@@ -113,6 +114,7 @@ let make = (
|
|
|
113
114
|
newBlockStallTimeout,
|
|
114
115
|
newBlockStallTimeoutLive,
|
|
115
116
|
stalledPollingInterval,
|
|
117
|
+
reducedPollingInterval,
|
|
116
118
|
getHeightRetryInterval,
|
|
117
119
|
recoveryTimeout,
|
|
118
120
|
statusStart: Hrtime.makeTimer(),
|
|
@@ -214,7 +216,7 @@ let disableSource = (sourceManager: t, sourceState: sourceState) => {
|
|
|
214
216
|
if sourceState.source.sourceFor === Live {
|
|
215
217
|
// Only clear hasLive if no other non-disabled Live sources remain
|
|
216
218
|
let hasOtherLive =
|
|
217
|
-
sourceManager.sourcesState->
|
|
219
|
+
sourceManager.sourcesState->Array.some(s =>
|
|
218
220
|
s !== sourceState && !s.disabled && s.source.sourceFor === Live
|
|
219
221
|
)
|
|
220
222
|
sourceManager.hasLive = hasOtherLive
|
|
@@ -233,6 +235,7 @@ let getSourceNewHeight = async (
|
|
|
233
235
|
~isLive,
|
|
234
236
|
~status: ref<status>,
|
|
235
237
|
~logger,
|
|
238
|
+
~reducedPolling,
|
|
236
239
|
) => {
|
|
237
240
|
let source = sourceState.source
|
|
238
241
|
let initialHeight = sourceState.knownHeight
|
|
@@ -295,7 +298,9 @@ let getSourceNewHeight = async (
|
|
|
295
298
|
sourceState.unsubscribe = Some(unsubscribe)
|
|
296
299
|
| _ =>
|
|
297
300
|
// Slowdown polling when the chain isn't progressing
|
|
298
|
-
let pollingInterval = if
|
|
301
|
+
let pollingInterval = if reducedPolling {
|
|
302
|
+
sourceManager.reducedPollingInterval
|
|
303
|
+
} else if status.contents === Stalled {
|
|
299
304
|
sourceManager.stalledPollingInterval
|
|
300
305
|
} else {
|
|
301
306
|
source.pollingInterval
|
|
@@ -331,15 +336,15 @@ let getSourceNewHeight = async (
|
|
|
331
336
|
|
|
332
337
|
let compareByOldestFailure = (a: sourceState, b: sourceState) =>
|
|
333
338
|
switch (a.lastFailedAt, b.lastFailedAt) {
|
|
334
|
-
| (None, Some(_)) =>
|
|
335
|
-
| (Some(_), None) =>
|
|
336
|
-
| (Some(a), Some(b)) => a < b ?
|
|
337
|
-
| (None, None) =>
|
|
339
|
+
| (None, Some(_)) => Ordering.less
|
|
340
|
+
| (Some(_), None) => Ordering.greater
|
|
341
|
+
| (Some(a), Some(b)) => a < b ? Ordering.less : a > b ? Ordering.greater : Ordering.equal
|
|
342
|
+
| (None, None) => Ordering.equal
|
|
338
343
|
}
|
|
339
344
|
|
|
340
345
|
// Priority: working primaries > working secondaries > all primaries.
|
|
341
346
|
let getNextSources = (sourceManager, ~isLive, ~excludedSources=?) => {
|
|
342
|
-
let now =
|
|
347
|
+
let now = Date.now()
|
|
343
348
|
let workingPrimarySources = []
|
|
344
349
|
let allPrimarySources = []
|
|
345
350
|
let workingSecondarySources = []
|
|
@@ -377,7 +382,8 @@ let getNextSources = (sourceManager, ~isLive, ~excludedSources=?) => {
|
|
|
377
382
|
workingSecondarySources
|
|
378
383
|
} else {
|
|
379
384
|
// All primaries in recovery — sort by oldest lastFailedAt (closest to recovery first)
|
|
380
|
-
allPrimarySources->
|
|
385
|
+
allPrimarySources->Array.sort(compareByOldestFailure)
|
|
386
|
+
allPrimarySources
|
|
381
387
|
}
|
|
382
388
|
}
|
|
383
389
|
|
|
@@ -389,7 +395,7 @@ let getNextSource = (sourceManager, ~isLive, ~excludedSources=?) => {
|
|
|
389
395
|
| None => None
|
|
390
396
|
| Some(first) if first.source === sourceManager.activeSource => Some(first)
|
|
391
397
|
| _ =>
|
|
392
|
-
switch sources->
|
|
398
|
+
switch sources->Array.find(s => s.source === sourceManager.activeSource) {
|
|
393
399
|
| Some(_) as result => result
|
|
394
400
|
| None => sources->Array.get(0)
|
|
395
401
|
}
|
|
@@ -397,7 +403,7 @@ let getNextSource = (sourceManager, ~isLive, ~excludedSources=?) => {
|
|
|
397
403
|
}
|
|
398
404
|
|
|
399
405
|
// Polls for a block height greater than the given block number to ensure a new block is available for indexing.
|
|
400
|
-
let waitForNewBlock = async (sourceManager: t, ~knownHeight, ~isLive) => {
|
|
406
|
+
let waitForNewBlock = async (sourceManager: t, ~knownHeight, ~isLive, ~reducedPolling) => {
|
|
401
407
|
let {sourcesState} = sourceManager
|
|
402
408
|
|
|
403
409
|
let logger = Logging.createChild(
|
|
@@ -406,13 +412,24 @@ let waitForNewBlock = async (sourceManager: t, ~knownHeight, ~isLive) => {
|
|
|
406
412
|
"knownHeight": knownHeight,
|
|
407
413
|
},
|
|
408
414
|
)
|
|
409
|
-
|
|
415
|
+
if reducedPolling {
|
|
416
|
+
logger->Logging.childTrace(
|
|
417
|
+
`Waiting for new blocks with reduced polling (${(sourceManager.reducedPollingInterval / 1000)
|
|
418
|
+
->Int.toString}s). Chain is caught up, waiting for other chains to backfill.`,
|
|
419
|
+
)
|
|
420
|
+
} else {
|
|
421
|
+
logger->Logging.childTrace("Initiating check for new blocks.")
|
|
422
|
+
}
|
|
410
423
|
|
|
411
424
|
let mainSources = sourceManager->getNextSources(~isLive)
|
|
412
425
|
|
|
413
426
|
let status = ref(Active)
|
|
414
427
|
|
|
415
|
-
|
|
428
|
+
// Use a much longer stall timeout when reduced polling is active
|
|
429
|
+
// to avoid spurious stall warnings while waiting for other chains to backfill
|
|
430
|
+
let stallTimeout = if reducedPolling {
|
|
431
|
+
sourceManager.reducedPollingInterval * 2
|
|
432
|
+
} else if isLive {
|
|
416
433
|
sourceManager.newBlockStallTimeoutLive
|
|
417
434
|
} else {
|
|
418
435
|
sourceManager.newBlockStallTimeout
|
|
@@ -430,6 +447,7 @@ let waitForNewBlock = async (sourceManager: t, ~knownHeight, ~isLive) => {
|
|
|
430
447
|
~isLive,
|
|
431
448
|
~status,
|
|
432
449
|
~logger,
|
|
450
|
+
~reducedPolling,
|
|
433
451
|
),
|
|
434
452
|
)
|
|
435
453
|
})
|
|
@@ -439,7 +457,7 @@ let waitForNewBlock = async (sourceManager: t, ~knownHeight, ~isLive) => {
|
|
|
439
457
|
let fallbackSources = []
|
|
440
458
|
sourcesState->Array.forEach(sourceState => {
|
|
441
459
|
if (
|
|
442
|
-
!(mainSources->
|
|
460
|
+
!(mainSources->Array.includes(sourceState)) &&
|
|
443
461
|
getSourceRole(
|
|
444
462
|
~sourceFor=sourceState.source.sourceFor,
|
|
445
463
|
~isLive,
|
|
@@ -479,6 +497,7 @@ let waitForNewBlock = async (sourceManager: t, ~knownHeight, ~isLive) => {
|
|
|
479
497
|
~isLive,
|
|
480
498
|
~status,
|
|
481
499
|
~logger,
|
|
500
|
+
~reducedPolling,
|
|
482
501
|
),
|
|
483
502
|
)
|
|
484
503
|
}),
|
|
@@ -560,7 +579,7 @@ let executeQuery = async (sourceManager: t, ~query: FetchState.query, ~knownHeig
|
|
|
560
579
|
~fromBlock=query.fromBlock,
|
|
561
580
|
~toBlock,
|
|
562
581
|
~addressesByContractName=query.addressesByContractName,
|
|
563
|
-
~
|
|
582
|
+
~indexingAddresses=query.indexingAddresses,
|
|
564
583
|
~partitionId=query.partitionId,
|
|
565
584
|
~knownHeight,
|
|
566
585
|
~selection=query.selection,
|
|
@@ -647,7 +666,7 @@ let executeQuery = async (sourceManager: t, ~query: FetchState.query, ~knownHeig
|
|
|
647
666
|
}
|
|
648
667
|
|
|
649
668
|
if shouldSwitch {
|
|
650
|
-
let now =
|
|
669
|
+
let now = Date.now()
|
|
651
670
|
sourceState.lastFailedAt = Some(now)
|
|
652
671
|
// Check if there's a working (recovered) source to switch to immediately
|
|
653
672
|
let nextSource =
|