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
@@ -1,8 +1,8 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Utils from "./Utils.res.mjs";
4
- import * as Hrtime from "./bindings/Hrtime.res.mjs";
5
4
  import * as PromClient from "./bindings/PromClient.res.mjs";
5
+ import * as Performance from "./bindings/Performance.res.mjs";
6
6
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
7
7
  import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
8
8
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
@@ -290,10 +290,10 @@ function startOperation(contract, event) {
290
290
  } else {
291
291
  operations[key] = {
292
292
  pendingCount: 1,
293
- timerRef: Hrtime.makeTimer()
293
+ timerRef: Performance.now()
294
294
  };
295
295
  }
296
- return Hrtime.makeTimer();
296
+ return Performance.now();
297
297
  }
298
298
 
299
299
  function endOperation(timerRef, contract, event) {
@@ -305,10 +305,10 @@ function endOperation(timerRef, contract, event) {
305
305
  let operationRef = operations[key];
306
306
  operationRef.pendingCount = operationRef.pendingCount - 1 | 0;
307
307
  if (operationRef.pendingCount === 0) {
308
- handleFloat(timeCounter$1, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(operationRef.timerRef)));
308
+ handleFloat(timeCounter$1, labels, Performance.secondsSince(operationRef.timerRef));
309
309
  Utils.Dict.deleteInPlace(operations, key);
310
310
  }
311
- handleFloat(sumTimeCounter, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef)));
311
+ handleFloat(sumTimeCounter, labels, Performance.secondsSince(timerRef));
312
312
  increment(count$1, labels);
313
313
  }
314
314
 
@@ -389,53 +389,28 @@ let ProcessStartTimeSeconds = {
389
389
  set: set$3
390
390
  };
391
391
 
392
- let gauge$4 = makeOrThrow$1("envio_indexing_addresses", "The number of addresses indexed on chain. Includes both static and dynamic addresses.", chainIdLabelsSchema);
392
+ let gauge$4 = makeOrThrow$1("envio_indexing_concurrency", "The number of executing concurrent queries to the chain data-source.", chainIdLabelsSchema);
393
393
 
394
- function set$4(addressesCount, chainId) {
395
- handleInt$1(gauge$4, chainId, addressesCount);
394
+ function set$4(concurrency, chainId) {
395
+ handleInt$1(gauge$4, chainId, concurrency);
396
396
  }
397
397
 
398
- let IndexingAddresses = {
398
+ let IndexingConcurrency = {
399
399
  gauge: gauge$4,
400
400
  set: set$4
401
401
  };
402
402
 
403
- let gauge$5 = PromClient.Gauge.makeGauge({
404
- name: "envio_indexing_max_concurrency",
405
- help: "The maximum number of concurrent data-source queries across the whole indexer."
406
- });
403
+ let gauge$5 = makeOrThrow$1("envio_indexing_partitions", "The number of partitions used to split fetching logic by addresses and block ranges.", chainIdLabelsSchema);
407
404
 
408
- function set$5(maxConcurrency) {
409
- gauge$5.set(maxConcurrency);
405
+ function set$5(partitionsCount, chainId) {
406
+ handleInt$1(gauge$5, chainId, partitionsCount);
410
407
  }
411
408
 
412
- let IndexingMaxConcurrency = {
409
+ let IndexingPartitions = {
413
410
  gauge: gauge$5,
414
411
  set: set$5
415
412
  };
416
413
 
417
- let gauge$6 = makeOrThrow$1("envio_indexing_concurrency", "The number of executing concurrent queries to the chain data-source.", chainIdLabelsSchema);
418
-
419
- function set$6(concurrency, chainId) {
420
- handleInt$1(gauge$6, chainId, concurrency);
421
- }
422
-
423
- let IndexingConcurrency = {
424
- gauge: gauge$6,
425
- set: set$6
426
- };
427
-
428
- let gauge$7 = makeOrThrow$1("envio_indexing_partitions", "The number of partitions used to split fetching logic by addresses and block ranges.", chainIdLabelsSchema);
429
-
430
- function set$7(partitionsCount, chainId) {
431
- handleInt$1(gauge$7, chainId, partitionsCount);
432
- }
433
-
434
- let IndexingPartitions = {
435
- gauge: gauge$7,
436
- set: set$7
437
- };
438
-
439
414
  let counter = makeOrThrow("envio_indexing_idle_seconds", "The time the indexer source syncing has been idle. A high value may indicate the source sync is a bottleneck.", chainIdLabelsSchema);
440
415
 
441
416
  let IndexingIdleTime = {
@@ -454,51 +429,51 @@ let IndexingQueryTime = {
454
429
  counter: counter$2
455
430
  };
456
431
 
457
- let gauge$8 = makeOrThrow$1("envio_indexing_buffer_size", "The current number of items in the indexing buffer.", chainIdLabelsSchema);
432
+ let gauge$6 = makeOrThrow$1("envio_indexing_buffer_size", "The current number of items in the indexing buffer.", chainIdLabelsSchema);
458
433
 
459
- function set$8(bufferSize, chainId) {
460
- handleInt$1(gauge$8, chainId, bufferSize);
434
+ function set$6(bufferSize, chainId) {
435
+ handleInt$1(gauge$6, chainId, bufferSize);
461
436
  }
462
437
 
463
438
  let IndexingBufferSize = {
464
- gauge: gauge$8,
465
- set: set$8
439
+ gauge: gauge$6,
440
+ set: set$6
466
441
  };
467
442
 
468
- let gauge$9 = PromClient.Gauge.makeGauge({
443
+ let gauge$7 = PromClient.Gauge.makeGauge({
469
444
  name: "envio_indexing_target_buffer_size",
470
445
  help: "The indexer-wide target buffer size shared across all chains. The actual number of items in the queue may exceed this value, but the indexer always tries to keep the buffer filled up to this target."
471
446
  });
472
447
 
473
- function set$9(targetBufferSize) {
474
- gauge$9.set(targetBufferSize);
448
+ function set$7(targetBufferSize) {
449
+ gauge$7.set(targetBufferSize);
475
450
  }
476
451
 
477
452
  let IndexingTargetBufferSize = {
478
- gauge: gauge$9,
479
- set: set$9
453
+ gauge: gauge$7,
454
+ set: set$7
480
455
  };
481
456
 
482
- let gauge$10 = makeOrThrow$1("envio_indexing_buffer_block", "The highest block number that has been fully fetched by the indexer.", chainIdLabelsSchema);
457
+ let gauge$8 = makeOrThrow$1("envio_indexing_buffer_block", "The highest block number that has been fully fetched by the indexer.", chainIdLabelsSchema);
483
458
 
484
- function set$10(blockNumber, chainId) {
485
- handleInt$1(gauge$10, chainId, blockNumber);
459
+ function set$8(blockNumber, chainId) {
460
+ handleInt$1(gauge$8, chainId, blockNumber);
486
461
  }
487
462
 
488
463
  let IndexingBufferBlockNumber = {
489
- gauge: gauge$10,
490
- set: set$10
464
+ gauge: gauge$8,
465
+ set: set$8
491
466
  };
492
467
 
493
- let gauge$11 = makeOrThrow$1("envio_indexing_end_block", "The block number to stop indexing at. (inclusive)", chainIdLabelsSchema);
468
+ let gauge$9 = makeOrThrow$1("envio_indexing_end_block", "The block number to stop indexing at. (inclusive)", chainIdLabelsSchema);
494
469
 
495
- function set$11(endBlock, chainId) {
496
- handleInt$1(gauge$11, chainId, endBlock);
470
+ function set$9(endBlock, chainId) {
471
+ handleInt$1(gauge$9, chainId, endBlock);
497
472
  }
498
473
 
499
474
  let IndexingEndBlock = {
500
- gauge: gauge$11,
501
- set: set$11
475
+ gauge: gauge$9,
476
+ set: set$9
502
477
  };
503
478
 
504
479
  let sourceLabelsSchema = S$RescriptSchema.schema(s => ({
@@ -506,101 +481,68 @@ let sourceLabelsSchema = S$RescriptSchema.schema(s => ({
506
481
  chainId: s.m(S$RescriptSchema.coerce(S$RescriptSchema.string, S$RescriptSchema.int))
507
482
  }));
508
483
 
509
- let sourceRequestLabelsSchema = S$RescriptSchema.schema(s => ({
510
- source: s.m(S$RescriptSchema.string),
511
- chainId: s.m(S$RescriptSchema.coerce(S$RescriptSchema.string, S$RescriptSchema.int)),
512
- method: s.m(S$RescriptSchema.string)
513
- }));
484
+ let gauge$10 = makeOrThrow$1("envio_source_known_height", "The latest known block number reported by the source. This value may lag behind the actual chain height, as it is updated only when queried.", sourceLabelsSchema);
514
485
 
515
- let counter$3 = makeOrThrow("envio_source_request_total", "The number of requests made to data sources.", sourceRequestLabelsSchema);
516
-
517
- let sumTimeCounter$1 = makeOrThrow("envio_source_request_seconds_total", "Cumulative time spent on data source requests.", sourceRequestLabelsSchema);
518
-
519
- function increment$4(sourceName, chainId, method) {
520
- increment(counter$3, {
521
- source: sourceName,
522
- chainId: chainId,
523
- method: method
524
- });
525
- }
526
-
527
- function addSeconds(sourceName, chainId, method, seconds) {
528
- handleFloat(sumTimeCounter$1, {
529
- source: sourceName,
530
- chainId: chainId,
531
- method: method
532
- }, seconds);
533
- }
534
-
535
- let SourceRequestCount = {
536
- counter: counter$3,
537
- sumTimeCounter: sumTimeCounter$1,
538
- increment: increment$4,
539
- addSeconds: addSeconds
540
- };
541
-
542
- let gauge$12 = makeOrThrow$1("envio_source_known_height", "The latest known block number reported by the source. This value may lag behind the actual chain height, as it is updated only when queried.", sourceLabelsSchema);
543
-
544
- function set$12(sourceName, chainId, blockNumber) {
545
- handleInt$1(gauge$12, {
486
+ function set$10(sourceName, chainId, blockNumber) {
487
+ handleInt$1(gauge$10, {
546
488
  source: sourceName,
547
489
  chainId: chainId
548
490
  }, blockNumber);
549
491
  }
550
492
 
551
493
  let SourceHeight = {
552
- gauge: gauge$12,
553
- set: set$12
494
+ gauge: gauge$10,
495
+ set: set$10
554
496
  };
555
497
 
556
- let counter$4 = makeOrThrow("envio_reorg_detected_total", "Total number of reorgs detected", chainIdLabelsSchema);
498
+ let counter$3 = makeOrThrow("envio_reorg_detected_total", "Total number of reorgs detected", chainIdLabelsSchema);
557
499
 
558
- function increment$5(chain) {
559
- increment(counter$4, chain);
500
+ function increment$4(chain) {
501
+ increment(counter$3, chain);
560
502
  }
561
503
 
562
504
  let ReorgCount = {
563
- counter: counter$4,
564
- increment: increment$5
505
+ counter: counter$3,
506
+ increment: increment$4
565
507
  };
566
508
 
567
- let gauge$13 = makeOrThrow$1("envio_reorg_detected_block", "The block number where reorg was detected the last time. This doesn't mean that the block was reorged, this is simply where we found block hash to be different.", chainIdLabelsSchema);
509
+ let gauge$11 = makeOrThrow$1("envio_reorg_detected_block", "The block number where reorg was detected the last time. This doesn't mean that the block was reorged, this is simply where we found block hash to be different.", chainIdLabelsSchema);
568
510
 
569
- function set$13(blockNumber, chain) {
570
- handleInt$1(gauge$13, chain, blockNumber);
511
+ function set$11(blockNumber, chain) {
512
+ handleInt$1(gauge$11, chain, blockNumber);
571
513
  }
572
514
 
573
515
  let ReorgDetectionBlockNumber = {
574
- gauge: gauge$13,
575
- set: set$13
516
+ gauge: gauge$11,
517
+ set: set$11
576
518
  };
577
519
 
578
- let gauge$14 = PromClient.Gauge.makeGauge({
520
+ let gauge$12 = PromClient.Gauge.makeGauge({
579
521
  name: "envio_reorg_threshold",
580
522
  help: "Whether indexing is currently within the reorg threshold"
581
523
  });
582
524
 
583
- function set$14(isInReorgThreshold) {
584
- gauge$14.set(isInReorgThreshold ? 1 : 0);
525
+ function set$12(isInReorgThreshold) {
526
+ gauge$12.set(isInReorgThreshold ? 1 : 0);
585
527
  }
586
528
 
587
529
  let ReorgThreshold = {
588
- gauge: gauge$14,
589
- set: set$14
530
+ gauge: gauge$12,
531
+ set: set$12
590
532
  };
591
533
 
592
- let gauge$15 = PromClient.Gauge.makeGauge({
534
+ let gauge$13 = PromClient.Gauge.makeGauge({
593
535
  name: "envio_rollback_enabled",
594
536
  help: "Whether rollback on reorg is enabled"
595
537
  });
596
538
 
597
- function set$15(enabled) {
598
- gauge$15.set(enabled ? 1 : 0);
539
+ function set$13(enabled) {
540
+ gauge$13.set(enabled ? 1 : 0);
599
541
  }
600
542
 
601
543
  let RollbackEnabled = {
602
- gauge: gauge$15,
603
- set: set$15
544
+ gauge: gauge$13,
545
+ set: set$13
604
546
  };
605
547
 
606
548
  let timeCounter$3 = PromClient.Counter.makeCounter({
@@ -608,7 +550,7 @@ let timeCounter$3 = PromClient.Counter.makeCounter({
608
550
  help: "Rollback on reorg total time."
609
551
  });
610
552
 
611
- let counter$5 = PromClient.Counter.makeCounter({
553
+ let counter$4 = PromClient.Counter.makeCounter({
612
554
  name: "envio_rollback_total",
613
555
  help: "Number of successful rollbacks on reorg"
614
556
  });
@@ -618,100 +560,100 @@ let eventsCounter = PromClient.Counter.makeCounter({
618
560
  help: "Number of events rollbacked on reorg"
619
561
  });
620
562
 
621
- function increment$6(timeSeconds, rollbackedProcessedEvents) {
563
+ function increment$5(timeSeconds, rollbackedProcessedEvents) {
622
564
  timeCounter$3.inc(timeSeconds);
623
- counter$5.inc();
565
+ counter$4.inc();
624
566
  eventsCounter.inc(Math.trunc(rollbackedProcessedEvents));
625
567
  }
626
568
 
627
569
  let RollbackSuccess = {
628
570
  timeCounter: timeCounter$3,
629
- counter: counter$5,
571
+ counter: counter$4,
630
572
  eventsCounter: eventsCounter,
631
- increment: increment$6
573
+ increment: increment$5
632
574
  };
633
575
 
634
576
  let entityNameLabelsSchema = S$RescriptSchema.object(s => s.f("entity", S$RescriptSchema.string));
635
577
 
636
578
  let timeCounter$4 = makeOrThrow("envio_rollback_history_prune_seconds", "The total time spent pruning entity history which is not in the reorg threshold.", entityNameLabelsSchema);
637
579
 
638
- let counter$6 = makeOrThrow("envio_rollback_history_prune_total", "Number of successful entity history prunes", entityNameLabelsSchema);
580
+ let counter$5 = makeOrThrow("envio_rollback_history_prune_total", "Number of successful entity history prunes", entityNameLabelsSchema);
639
581
 
640
- function increment$7(timeSeconds, entityName) {
582
+ function increment$6(timeSeconds, entityName) {
641
583
  handleFloat(timeCounter$4, entityName, timeSeconds);
642
- increment(counter$6, entityName);
584
+ increment(counter$5, entityName);
643
585
  }
644
586
 
645
587
  let RollbackHistoryPrune = {
646
588
  entityNameLabelsSchema: entityNameLabelsSchema,
647
589
  timeCounter: timeCounter$4,
648
- counter: counter$6,
649
- increment: increment$7
590
+ counter: counter$5,
591
+ increment: increment$6
650
592
  };
651
593
 
652
- let gauge$16 = makeOrThrow$1("envio_rollback_target_block", "The block number reorg was rollbacked to the last time.", chainIdLabelsSchema);
594
+ let gauge$14 = makeOrThrow$1("envio_rollback_target_block", "The block number reorg was rollbacked to the last time.", chainIdLabelsSchema);
653
595
 
654
- function set$16(blockNumber, chain) {
655
- handleInt$1(gauge$16, chain, blockNumber);
596
+ function set$14(blockNumber, chain) {
597
+ handleInt$1(gauge$14, chain, blockNumber);
656
598
  }
657
599
 
658
600
  let RollbackTargetBlockNumber = {
659
- gauge: gauge$16,
660
- set: set$16
601
+ gauge: gauge$14,
602
+ set: set$14
661
603
  };
662
604
 
663
- let gauge$17 = PromClient.Gauge.makeGauge({
605
+ let gauge$15 = PromClient.Gauge.makeGauge({
664
606
  name: "envio_processing_max_batch_size",
665
607
  help: "The maximum number of items to process in a single batch."
666
608
  });
667
609
 
668
- function set$17(maxBatchSize) {
669
- gauge$17.set(maxBatchSize);
610
+ function set$15(maxBatchSize) {
611
+ gauge$15.set(maxBatchSize);
670
612
  }
671
613
 
672
614
  let ProcessingMaxBatchSize = {
673
- gauge: gauge$17,
674
- set: set$17
615
+ gauge: gauge$15,
616
+ set: set$15
675
617
  };
676
618
 
677
- let gauge$18 = makeOrThrow$1("envio_progress_block", "The block number of the latest block processed and stored in the database.", chainIdLabelsSchema);
619
+ let gauge$16 = makeOrThrow$1("envio_progress_block", "The block number of the latest block processed and stored in the database.", chainIdLabelsSchema);
678
620
 
679
- function set$18(blockNumber, chainId) {
680
- handleInt$1(gauge$18, chainId, blockNumber);
621
+ function set$16(blockNumber, chainId) {
622
+ handleInt$1(gauge$16, chainId, blockNumber);
681
623
  }
682
624
 
683
625
  let ProgressBlockNumber = {
684
- gauge: gauge$18,
685
- set: set$18
626
+ gauge: gauge$16,
627
+ set: set$16
686
628
  };
687
629
 
688
- let gauge$19 = makeOrThrow$1("envio_progress_events", "The number of events processed and reflected in the database.", chainIdLabelsSchema);
630
+ let gauge$17 = makeOrThrow$1("envio_progress_events", "The number of events processed and reflected in the database.", chainIdLabelsSchema);
689
631
 
690
- function set$19(processedCount, chainId) {
691
- handleFloat$1(gauge$19, chainId, processedCount);
632
+ function set$17(processedCount, chainId) {
633
+ handleFloat$1(gauge$17, chainId, processedCount);
692
634
  }
693
635
 
694
636
  let ProgressEventsCount = {
695
- gauge: gauge$19,
696
- set: set$19
637
+ gauge: gauge$17,
638
+ set: set$17
697
639
  };
698
640
 
699
- let gauge$20 = makeOrThrow$1("envio_progress_latency", "The latency in milliseconds between the latest processed event creation and the time it was written to storage.", chainIdLabelsSchema);
641
+ let gauge$18 = makeOrThrow$1("envio_progress_latency", "The latency in milliseconds between the latest processed event creation and the time it was written to storage.", chainIdLabelsSchema);
700
642
 
701
- function set$20(latencyMs, chainId) {
702
- handleInt$1(gauge$20, chainId, latencyMs);
643
+ function set$18(latencyMs, chainId) {
644
+ handleInt$1(gauge$18, chainId, latencyMs);
703
645
  }
704
646
 
705
647
  let ProgressLatency = {
706
- gauge: gauge$20,
707
- set: set$20
648
+ gauge: gauge$18,
649
+ set: set$18
708
650
  };
709
651
 
710
652
  let effectLabelsSchema = S$RescriptSchema.object(s => s.f("effect", S$RescriptSchema.string));
711
653
 
712
654
  let timeCounter$5 = makeOrThrow("envio_effect_call_seconds", "Processing time taken to call the Effect function.", effectLabelsSchema);
713
655
 
714
- let sumTimeCounter$2 = makeOrThrow("envio_effect_call_seconds_total", "Cumulative time spent calling the Effect function during the indexing process.", effectLabelsSchema);
656
+ let sumTimeCounter$1 = makeOrThrow("envio_effect_call_seconds_total", "Cumulative time spent calling the Effect function during the indexing process.", effectLabelsSchema);
715
657
 
716
658
  let totalCallsCount = makeOrThrow("envio_effect_call_total", "Cumulative number of resolved Effect function calls during the indexing process.", effectLabelsSchema);
717
659
 
@@ -719,45 +661,45 @@ let activeCallsCount = makeOrThrow$1("envio_effect_active_calls", "The number of
719
661
 
720
662
  let EffectCalls = {
721
663
  timeCounter: timeCounter$5,
722
- sumTimeCounter: sumTimeCounter$2,
664
+ sumTimeCounter: sumTimeCounter$1,
723
665
  totalCallsCount: totalCallsCount,
724
666
  activeCallsCount: activeCallsCount
725
667
  };
726
668
 
727
- let gauge$21 = makeOrThrow$1("envio_effect_cache", "The number of items in the effect cache.", effectLabelsSchema);
669
+ let gauge$19 = makeOrThrow$1("envio_effect_cache", "The number of items in the effect cache.", effectLabelsSchema);
728
670
 
729
- function set$21(count, effectName) {
730
- handleInt$1(gauge$21, effectName, count);
671
+ function set$19(count, effectName) {
672
+ handleInt$1(gauge$19, effectName, count);
731
673
  }
732
674
 
733
675
  let EffectCacheCount = {
734
- gauge: gauge$21,
735
- set: set$21
676
+ gauge: gauge$19,
677
+ set: set$19
736
678
  };
737
679
 
738
- let counter$7 = makeOrThrow("envio_effect_cache_invalidations", "The number of effect cache invalidations.", effectLabelsSchema);
680
+ let counter$6 = makeOrThrow("envio_effect_cache_invalidations", "The number of effect cache invalidations.", effectLabelsSchema);
739
681
 
740
- function increment$8(effectName) {
741
- increment(counter$7, effectName);
682
+ function increment$7(effectName) {
683
+ increment(counter$6, effectName);
742
684
  }
743
685
 
744
686
  let EffectCacheInvalidationsCount = {
745
- counter: counter$7,
746
- increment: increment$8
687
+ counter: counter$6,
688
+ increment: increment$7
747
689
  };
748
690
 
749
- let gauge$22 = makeOrThrow$1("envio_effect_queue", "The number of effect calls waiting in the rate limit queue.", effectLabelsSchema);
691
+ let gauge$20 = makeOrThrow$1("envio_effect_queue", "The number of effect calls waiting in the rate limit queue.", effectLabelsSchema);
750
692
 
751
693
  let timeCounter$6 = makeOrThrow("envio_effect_queue_wait_seconds", "The time spent waiting in the rate limit queue.", effectLabelsSchema);
752
694
 
753
- function set$22(count, effectName) {
754
- handleInt$1(gauge$22, effectName, count);
695
+ function set$20(count, effectName) {
696
+ handleInt$1(gauge$20, effectName, count);
755
697
  }
756
698
 
757
699
  let EffectQueueCount = {
758
- gauge: gauge$22,
700
+ gauge: gauge$20,
759
701
  timeCounter: timeCounter$6,
760
- set: set$22
702
+ set: set$20
761
703
  };
762
704
 
763
705
  let loadLabelsSchema = S$RescriptSchema.schema(s => ({
@@ -767,9 +709,9 @@ let loadLabelsSchema = S$RescriptSchema.schema(s => ({
767
709
 
768
710
  let timeCounter$7 = makeOrThrow("envio_storage_load_seconds", "Processing time taken to load data from storage.", loadLabelsSchema);
769
711
 
770
- let sumTimeCounter$3 = makeOrThrow("envio_storage_load_seconds_total", "Cumulative time spent loading data from storage during the indexing process.", loadLabelsSchema);
712
+ let sumTimeCounter$2 = makeOrThrow("envio_storage_load_seconds_total", "Cumulative time spent loading data from storage during the indexing process.", loadLabelsSchema);
771
713
 
772
- let counter$8 = makeOrThrow("envio_storage_load_total", "Cumulative number of successful storage load operations during the indexing process.", loadLabelsSchema);
714
+ let counter$7 = makeOrThrow("envio_storage_load_total", "Cumulative number of successful storage load operations during the indexing process.", loadLabelsSchema);
773
715
 
774
716
  let whereSizeCounter = makeOrThrow("envio_storage_load_where_size", "Cumulative number of filter conditions ('where' items) used in storage load operations during the indexing process.", loadLabelsSchema);
775
717
 
@@ -789,10 +731,10 @@ function startOperation$1(storage, operation) {
789
731
  } else {
790
732
  operations$1[key] = {
791
733
  pendingCount: 1,
792
- timerRef: Hrtime.makeTimer()
734
+ timerRef: Performance.now()
793
735
  };
794
736
  }
795
- return Hrtime.makeTimer();
737
+ return Performance.now();
796
738
  }
797
739
 
798
740
  function endOperation$1(timerRef, storage, operation, whereSize, size) {
@@ -804,11 +746,11 @@ function endOperation$1(timerRef, storage, operation, whereSize, size) {
804
746
  let operationRef = operations$1[key];
805
747
  operationRef.pendingCount = operationRef.pendingCount - 1 | 0;
806
748
  if (operationRef.pendingCount === 0) {
807
- handleFloat(timeCounter$7, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(operationRef.timerRef)));
749
+ handleFloat(timeCounter$7, labels, Performance.secondsSince(operationRef.timerRef));
808
750
  Utils.Dict.deleteInPlace(operations$1, key);
809
751
  }
810
- handleFloat(sumTimeCounter$3, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef)));
811
- increment(counter$8, labels);
752
+ handleFloat(sumTimeCounter$2, labels, Performance.secondsSince(timerRef));
753
+ increment(counter$7, labels);
812
754
  handleInt(whereSizeCounter, labels, whereSize);
813
755
  handleInt(sizeCounter$1, labels, size);
814
756
  }
@@ -816,8 +758,8 @@ function endOperation$1(timerRef, storage, operation, whereSize, size) {
816
758
  let StorageLoad = {
817
759
  loadLabelsSchema: loadLabelsSchema,
818
760
  timeCounter: timeCounter$7,
819
- sumTimeCounter: sumTimeCounter$3,
820
- counter: counter$8,
761
+ sumTimeCounter: sumTimeCounter$2,
762
+ counter: counter$7,
821
763
  whereSizeCounter: whereSizeCounter,
822
764
  sizeCounter: sizeCounter$1,
823
765
  operations: operations$1,
@@ -830,18 +772,18 @@ let storageLabelsSchema = S$RescriptSchema.object(s => s.f("storage", S$Rescript
830
772
 
831
773
  let timeCounter$8 = makeOrThrow("envio_storage_write_seconds", "Cumulative time spent writing batch data to storage.", storageLabelsSchema);
832
774
 
833
- let counter$9 = makeOrThrow("envio_storage_write_total", "Cumulative number of successful storage write operations during the indexing process.", storageLabelsSchema);
775
+ let counter$8 = makeOrThrow("envio_storage_write_total", "Cumulative number of successful storage write operations during the indexing process.", storageLabelsSchema);
834
776
 
835
- function increment$9(storage, timeSeconds) {
777
+ function increment$8(storage, timeSeconds) {
836
778
  handleFloat(timeCounter$8, storage, timeSeconds);
837
- increment(counter$9, storage);
779
+ increment(counter$8, storage);
838
780
  }
839
781
 
840
782
  let StorageWrite = {
841
783
  storageLabelsSchema: storageLabelsSchema,
842
784
  timeCounter: timeCounter$8,
843
- counter: counter$9,
844
- increment: increment$9
785
+ counter: counter$8,
786
+ increment: increment$8
845
787
  };
846
788
 
847
789
  export {
@@ -860,8 +802,6 @@ export {
860
802
  IndexingKnownHeight,
861
803
  Info,
862
804
  ProcessStartTimeSeconds,
863
- IndexingAddresses,
864
- IndexingMaxConcurrency,
865
805
  IndexingConcurrency,
866
806
  IndexingPartitions,
867
807
  IndexingIdleTime,
@@ -872,8 +812,6 @@ export {
872
812
  IndexingBufferBlockNumber,
873
813
  IndexingEndBlock,
874
814
  sourceLabelsSchema,
875
- sourceRequestLabelsSchema,
876
- SourceRequestCount,
877
815
  SourceHeight,
878
816
  ReorgCount,
879
817
  ReorgDetectionBlockNumber,
@@ -14,7 +14,7 @@ let runPrune = async (state: IndexerState.t) => {
14
14
  await Utils.delay(1000)
15
15
  }
16
16
  let entityConfig = persistence.allEntities->Array.getUnsafe(idx)
17
- let timeRef = Hrtime.makeTimer()
17
+ let timeRef = Performance.now()
18
18
  try {
19
19
  let () = await persistence.storage.pruneStaleEntityHistory(
20
20
  ~entityName=entityConfig.name,
@@ -34,7 +34,7 @@ let runPrune = async (state: IndexerState.t) => {
34
34
  )
35
35
  }
36
36
  Prometheus.RollbackHistoryPrune.increment(
37
- ~timeSeconds=Hrtime.timeSince(timeRef)->Hrtime.toSecondsFloat,
37
+ ~timeSeconds=Performance.secondsSince(timeRef),
38
38
  ~entityName=entityConfig.name,
39
39
  )
40
40
  }
@@ -1,10 +1,10 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Utils from "./Utils.res.mjs";
4
- import * as Hrtime from "./bindings/Hrtime.res.mjs";
5
4
  import * as Logging from "./Logging.res.mjs";
6
5
  import * as Throttler from "./Throttler.res.mjs";
7
6
  import * as Prometheus from "./Prometheus.res.mjs";
7
+ import * as Performance from "./bindings/Performance.res.mjs";
8
8
  import * as IndexerState from "./IndexerState.res.mjs";
9
9
  import * as ErrorHandling from "./ErrorHandling.res.mjs";
10
10
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
@@ -21,7 +21,7 @@ async function runPrune(state) {
21
21
  await Utils.delay(1000);
22
22
  }
23
23
  let entityConfig = persistence.allEntities[idx];
24
- let timeRef = Hrtime.makeTimer();
24
+ let timeRef = Performance.now();
25
25
  try {
26
26
  await persistence.storage.pruneStaleEntityHistory(entityConfig.name, entityConfig.index, safeCheckpointId);
27
27
  } catch (raw_exn) {
@@ -31,7 +31,7 @@ async function runPrune(state) {
31
31
  safeCheckpointId: safeCheckpointId
32
32
  }), `Failed to prune stale entity history`, exn);
33
33
  }
34
- Prometheus.RollbackHistoryPrune.increment(Hrtime.toSecondsFloat(Hrtime.timeSince(timeRef)), entityConfig.name);
34
+ Prometheus.RollbackHistoryPrune.increment(Performance.secondsSince(timeRef), entityConfig.name);
35
35
  }
36
36
  }
37
37
 
package/src/RawEvent.res CHANGED
@@ -19,16 +19,21 @@ let convertFieldsToJson = (fields: option<dict<unknown>>) => {
19
19
 
20
20
  // Block and transaction are passed already extracted from the ecosystem's
21
21
  // concrete payload (EVM or Fuel) — `RawEvent` stays payload-shape-agnostic and
22
- // only needs them as opaque field bags to serialise.
22
+ // only needs them as opaque field bags to serialise. The dedicated
23
+ // `block_hash`/`block_timestamp` column values are extracted from the payload
24
+ // block by the ecosystem caller (the field names differ per ecosystem).
23
25
  let make = (
24
26
  eventItem: Internal.eventItem,
25
27
  ~block,
26
28
  ~transaction,
27
29
  ~params: Internal.eventParams,
28
30
  ~srcAddress: Address.t,
31
+ ~blockHash: string,
32
+ ~blockTimestamp: int,
29
33
  ~cleanUpRawEventFieldsInPlace: JSON.t => unit,
30
34
  ): Internal.rawEvent => {
31
- let {eventConfig, chain, blockNumber, blockHash, timestamp: blockTimestamp, logIndex} = eventItem
35
+ let {onEventRegistration, chain, blockNumber, logIndex} = eventItem
36
+ let eventConfig = onEventRegistration.eventConfig
32
37
  let chainId = chain->ChainMap.Chain.toChainId
33
38
  let eventId = EventUtils.packEventIndex(~logIndex, ~blockNumber)
34
39
  let blockFields =