envio 3.3.0-alpha.0 → 3.3.0-alpha.10

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.
Files changed (140) hide show
  1. package/evm.schema.json +10 -0
  2. package/index.d.ts +45 -25
  3. package/package.json +7 -7
  4. package/src/Address.res +5 -2
  5. package/src/Address.res.mjs +3 -1
  6. package/src/Api.res +1 -1
  7. package/src/Api.res.mjs +1 -1
  8. package/src/Batch.res +0 -6
  9. package/src/Batch.res.mjs +1 -12
  10. package/src/BatchProcessing.res +7 -12
  11. package/src/BatchProcessing.res.mjs +8 -7
  12. package/src/Bin.res +3 -0
  13. package/src/Bin.res.mjs +4 -0
  14. package/src/ChainFetching.res +48 -16
  15. package/src/ChainFetching.res.mjs +36 -17
  16. package/src/ChainMetadata.res +1 -11
  17. package/src/ChainMetadata.res.mjs +1 -10
  18. package/src/ChainState.res +628 -149
  19. package/src/ChainState.res.mjs +440 -102
  20. package/src/ChainState.resi +74 -4
  21. package/src/Config.res +61 -33
  22. package/src/Config.res.mjs +50 -10
  23. package/src/ContractRegisterContext.res +2 -12
  24. package/src/ContractRegisterContext.res.mjs +3 -5
  25. package/src/Core.res +14 -3
  26. package/src/CrossChainState.res +142 -93
  27. package/src/CrossChainState.res.mjs +88 -60
  28. package/src/CrossChainState.resi +2 -10
  29. package/src/Ecosystem.res +5 -6
  30. package/src/Ecosystem.res.mjs +3 -3
  31. package/src/Env.res +0 -7
  32. package/src/Env.res.mjs +0 -6
  33. package/src/Envio.res +17 -11
  34. package/src/EnvioGlobal.res +53 -0
  35. package/src/EnvioGlobal.res.mjs +31 -0
  36. package/src/EventConfigBuilder.res +177 -88
  37. package/src/EventConfigBuilder.res.mjs +99 -42
  38. package/src/EventProcessing.res +74 -28
  39. package/src/EventProcessing.res.mjs +55 -29
  40. package/src/ExitOnCaughtUp.res +10 -2
  41. package/src/ExitOnCaughtUp.res.mjs +10 -1
  42. package/src/FetchState.res +558 -300
  43. package/src/FetchState.res.mjs +437 -423
  44. package/src/HandlerLoader.res +8 -104
  45. package/src/HandlerLoader.res.mjs +2 -81
  46. package/src/HandlerRegister.res +518 -144
  47. package/src/HandlerRegister.res.mjs +285 -133
  48. package/src/HandlerRegister.resi +24 -8
  49. package/src/IndexerLoop.res +2 -3
  50. package/src/IndexerLoop.res.mjs +1 -1
  51. package/src/IndexerState.res +10 -11
  52. package/src/IndexerState.res.mjs +14 -11
  53. package/src/IndexerState.resi +2 -5
  54. package/src/IndexingAddresses.res +108 -0
  55. package/src/IndexingAddresses.res.mjs +101 -0
  56. package/src/IndexingAddresses.resi +34 -0
  57. package/src/Internal.res +155 -46
  58. package/src/Internal.res.mjs +30 -2
  59. package/src/LoadLayer.res +5 -5
  60. package/src/LoadLayer.res.mjs +6 -6
  61. package/src/LogSelection.res +102 -165
  62. package/src/LogSelection.res.mjs +101 -116
  63. package/src/Main.res +71 -236
  64. package/src/Main.res.mjs +60 -145
  65. package/src/Metrics.res +74 -0
  66. package/src/Metrics.res.mjs +75 -0
  67. package/src/PgStorage.res +4 -4
  68. package/src/PgStorage.res.mjs +5 -5
  69. package/src/Prometheus.res +10 -74
  70. package/src/Prometheus.res.mjs +124 -186
  71. package/src/PruneStaleHistory.res +2 -2
  72. package/src/PruneStaleHistory.res.mjs +3 -3
  73. package/src/RawEvent.res +7 -2
  74. package/src/RawEvent.res.mjs +4 -4
  75. package/src/Rollback.res +3 -3
  76. package/src/Rollback.res.mjs +4 -4
  77. package/src/RollbackCommit.res +4 -1
  78. package/src/RollbackCommit.res.mjs +3 -2
  79. package/src/SimulateDeadInputTracker.res +85 -0
  80. package/src/SimulateDeadInputTracker.res.mjs +73 -0
  81. package/src/SimulateDeadInputTracker.resi +12 -0
  82. package/src/SimulateItems.res +91 -23
  83. package/src/SimulateItems.res.mjs +55 -32
  84. package/src/TestIndexer.res +54 -40
  85. package/src/TestIndexer.res.mjs +37 -30
  86. package/src/bindings/Performance.res +7 -0
  87. package/src/bindings/Performance.res.mjs +21 -0
  88. package/src/bindings/Performance.resi +7 -0
  89. package/src/bindings/Viem.res +0 -41
  90. package/src/bindings/Viem.res.mjs +1 -43
  91. package/src/sources/BlockStore.res +46 -0
  92. package/src/sources/BlockStore.res.mjs +24 -0
  93. package/src/sources/EventRouter.res +36 -33
  94. package/src/sources/EventRouter.res.mjs +13 -14
  95. package/src/sources/Evm.res +83 -72
  96. package/src/sources/Evm.res.mjs +53 -69
  97. package/src/sources/EvmChain.res +18 -20
  98. package/src/sources/EvmChain.res.mjs +15 -15
  99. package/src/sources/EvmRpcClient.res +74 -5
  100. package/src/sources/EvmRpcClient.res.mjs +13 -4
  101. package/src/sources/FieldMask.res +39 -0
  102. package/src/sources/FieldMask.res.mjs +42 -0
  103. package/src/sources/Fuel.res +9 -6
  104. package/src/sources/Fuel.res.mjs +5 -10
  105. package/src/sources/HyperFuelSource.res +46 -50
  106. package/src/sources/HyperFuelSource.res.mjs +64 -54
  107. package/src/sources/HyperSync.res +39 -7
  108. package/src/sources/HyperSync.res.mjs +57 -37
  109. package/src/sources/HyperSync.resi +12 -2
  110. package/src/sources/HyperSyncClient.res +22 -111
  111. package/src/sources/HyperSyncClient.res.mjs +2 -30
  112. package/src/sources/HyperSyncHeightStream.res +1 -8
  113. package/src/sources/HyperSyncHeightStream.res.mjs +0 -2
  114. package/src/sources/HyperSyncSource.res +94 -107
  115. package/src/sources/HyperSyncSource.res.mjs +82 -86
  116. package/src/sources/Rpc.res +15 -47
  117. package/src/sources/Rpc.res.mjs +25 -56
  118. package/src/sources/RpcSource.res +320 -467
  119. package/src/sources/RpcSource.res.mjs +268 -385
  120. package/src/sources/RpcWebSocketHeightStream.res +0 -5
  121. package/src/sources/RpcWebSocketHeightStream.res.mjs +0 -2
  122. package/src/sources/SimulateSource.res +10 -4
  123. package/src/sources/SimulateSource.res.mjs +16 -6
  124. package/src/sources/Source.res +34 -6
  125. package/src/sources/SourceManager.res +86 -27
  126. package/src/sources/SourceManager.res.mjs +84 -47
  127. package/src/sources/SourceManager.resi +12 -3
  128. package/src/sources/Svm.res +31 -16
  129. package/src/sources/Svm.res.mjs +36 -13
  130. package/src/sources/SvmHyperSyncClient.res +5 -32
  131. package/src/sources/SvmHyperSyncSource.res +159 -134
  132. package/src/sources/SvmHyperSyncSource.res.mjs +164 -129
  133. package/src/sources/TransactionStore.res +49 -0
  134. package/src/sources/TransactionStore.res.mjs +30 -0
  135. package/src/tui/Tui.res +13 -16
  136. package/src/tui/Tui.res.mjs +12 -14
  137. package/svm.schema.json +49 -37
  138. package/src/bindings/Hrtime.res +0 -58
  139. package/src/bindings/Hrtime.res.mjs +0 -90
  140. package/src/bindings/Hrtime.resi +0 -30
@@ -212,7 +212,7 @@ module PreloadHandler = {
212
212
 
213
213
  type operationRef = {
214
214
  mutable pendingCount: int,
215
- timerRef: Hrtime.timeRef,
215
+ timerRef: Performance.timeRef,
216
216
  }
217
217
  let operations: dict<operationRef> = Dict.make()
218
218
 
@@ -227,11 +227,11 @@ module PreloadHandler = {
227
227
  key,
228
228
  {
229
229
  pendingCount: 1,
230
- timerRef: Hrtime.makeTimer(),
230
+ timerRef: Performance.now(),
231
231
  },
232
232
  )
233
233
  }
234
- Hrtime.makeTimer()
234
+ Performance.now()
235
235
  }
236
236
 
237
237
  let endOperation = (timerRef, ~contract, ~event) => {
@@ -242,14 +242,11 @@ module PreloadHandler = {
242
242
  if operationRef.pendingCount === 0 {
243
243
  timeCounter->SafeCounter.handleFloat(
244
244
  ~labels,
245
- ~value=operationRef.timerRef->Hrtime.timeSince->Hrtime.toSecondsFloat,
245
+ ~value=operationRef.timerRef->Performance.secondsSince,
246
246
  )
247
247
  operations->Utils.Dict.deleteInPlace(key)
248
248
  }
249
- sumTimeCounter->SafeCounter.handleFloat(
250
- ~labels,
251
- ~value=timerRef->Hrtime.timeSince->Hrtime.toSecondsFloat,
252
- )
249
+ sumTimeCounter->SafeCounter.handleFloat(~labels, ~value=timerRef->Performance.secondsSince)
253
250
  count->SafeCounter.increment(~labels)
254
251
  }
255
252
  }
@@ -339,29 +336,6 @@ module ProcessStartTimeSeconds = {
339
336
  }
340
337
  }
341
338
 
342
- module IndexingAddresses = {
343
- let gauge = SafeGauge.makeOrThrow(
344
- ~name="envio_indexing_addresses",
345
- ~help="The number of addresses indexed on chain. Includes both static and dynamic addresses.",
346
- ~labelSchema=chainIdLabelsSchema,
347
- )
348
-
349
- let set = (~addressesCount, ~chainId) => {
350
- gauge->SafeGauge.handleInt(~labels=chainId, ~value=addressesCount)
351
- }
352
- }
353
-
354
- module IndexingMaxConcurrency = {
355
- let gauge = PromClient.Gauge.makeGauge({
356
- "name": "envio_indexing_max_concurrency",
357
- "help": "The maximum number of concurrent data-source queries across the whole indexer.",
358
- })
359
-
360
- let set = (~maxConcurrency) => {
361
- gauge->PromClient.Gauge.set(maxConcurrency)
362
- }
363
- }
364
-
365
339
  module IndexingConcurrency = {
366
340
  let gauge = SafeGauge.makeOrThrow(
367
341
  ~name="envio_indexing_concurrency",
@@ -464,41 +438,6 @@ let sourceLabelsSchema = S.schema(s =>
464
438
  }
465
439
  )
466
440
 
467
- let sourceRequestLabelsSchema = S.schema(s =>
468
- {
469
- "source": s.matches(S.string),
470
- "chainId": s.matches(S.string->S.coerce(S.int)),
471
- "method": s.matches(S.string),
472
- }
473
- )
474
-
475
- module SourceRequestCount = {
476
- let counter = SafeCounter.makeOrThrow(
477
- ~name="envio_source_request_total",
478
- ~help="The number of requests made to data sources.",
479
- ~labelSchema=sourceRequestLabelsSchema,
480
- )
481
-
482
- let sumTimeCounter = SafeCounter.makeOrThrow(
483
- ~name="envio_source_request_seconds_total",
484
- ~help="Cumulative time spent on data source requests.",
485
- ~labelSchema=sourceRequestLabelsSchema,
486
- )
487
-
488
- let increment = (~sourceName, ~chainId, ~method) => {
489
- counter->SafeCounter.increment(
490
- ~labels={"source": sourceName, "chainId": chainId, "method": method},
491
- )
492
- }
493
-
494
- let addSeconds = (~sourceName, ~chainId, ~method, ~seconds) => {
495
- sumTimeCounter->SafeCounter.handleFloat(
496
- ~labels={"source": sourceName, "chainId": chainId, "method": method},
497
- ~value=seconds,
498
- )
499
- }
500
- }
501
-
502
441
  module SourceHeight = {
503
442
  let gauge = SafeGauge.makeOrThrow(
504
443
  ~name="envio_source_known_height",
@@ -775,7 +714,7 @@ module StorageLoad = {
775
714
 
776
715
  type operationRef = {
777
716
  mutable pendingCount: int,
778
- timerRef: Hrtime.timeRef,
717
+ timerRef: Performance.timeRef,
779
718
  }
780
719
  let operations = Dict.make()
781
720
 
@@ -791,12 +730,12 @@ module StorageLoad = {
791
730
  (
792
731
  {
793
732
  pendingCount: 1,
794
- timerRef: Hrtime.makeTimer(),
733
+ timerRef: Performance.now(),
795
734
  }: operationRef
796
735
  ),
797
736
  )
798
737
  }
799
- Hrtime.makeTimer()
738
+ Performance.now()
800
739
  }
801
740
 
802
741
  let endOperation = (timerRef, ~storage, ~operation, ~whereSize, ~size) => {
@@ -807,14 +746,11 @@ module StorageLoad = {
807
746
  if operationRef.pendingCount === 0 {
808
747
  timeCounter->SafeCounter.handleFloat(
809
748
  ~labels,
810
- ~value=operationRef.timerRef->Hrtime.timeSince->Hrtime.toSecondsFloat,
749
+ ~value=operationRef.timerRef->Performance.secondsSince,
811
750
  )
812
751
  operations->Utils.Dict.deleteInPlace(key)
813
752
  }
814
- sumTimeCounter->SafeCounter.handleFloat(
815
- ~labels,
816
- ~value=timerRef->Hrtime.timeSince->Hrtime.toSecondsFloat,
817
- )
753
+ sumTimeCounter->SafeCounter.handleFloat(~labels, ~value=timerRef->Performance.secondsSince)
818
754
  counter->SafeCounter.increment(~labels)
819
755
  whereSizeCounter->SafeCounter.handleInt(~labels, ~value=whereSize)
820
756
  sizeCounter->SafeCounter.handleInt(~labels, ~value=size)