envio 3.3.0-alpha.0 → 3.3.0-alpha.1

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.
@@ -400,42 +400,28 @@ let IndexingAddresses = {
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_concurrency", "The number of executing concurrent queries to the chain data-source.", chainIdLabelsSchema);
407
404
 
408
- function set$5(maxConcurrency) {
409
- gauge$5.set(maxConcurrency);
405
+ function set$5(concurrency, chainId) {
406
+ handleInt$1(gauge$5, chainId, concurrency);
410
407
  }
411
408
 
412
- let IndexingMaxConcurrency = {
409
+ let IndexingConcurrency = {
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);
414
+ let gauge$6 = makeOrThrow$1("envio_indexing_partitions", "The number of partitions used to split fetching logic by addresses and block ranges.", chainIdLabelsSchema);
418
415
 
419
- function set$6(concurrency, chainId) {
420
- handleInt$1(gauge$6, chainId, concurrency);
416
+ function set$6(partitionsCount, chainId) {
417
+ handleInt$1(gauge$6, chainId, partitionsCount);
421
418
  }
422
419
 
423
- let IndexingConcurrency = {
420
+ let IndexingPartitions = {
424
421
  gauge: gauge$6,
425
422
  set: set$6
426
423
  };
427
424
 
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
425
  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
426
 
441
427
  let IndexingIdleTime = {
@@ -454,51 +440,51 @@ let IndexingQueryTime = {
454
440
  counter: counter$2
455
441
  };
456
442
 
457
- let gauge$8 = makeOrThrow$1("envio_indexing_buffer_size", "The current number of items in the indexing buffer.", chainIdLabelsSchema);
443
+ let gauge$7 = makeOrThrow$1("envio_indexing_buffer_size", "The current number of items in the indexing buffer.", chainIdLabelsSchema);
458
444
 
459
- function set$8(bufferSize, chainId) {
460
- handleInt$1(gauge$8, chainId, bufferSize);
445
+ function set$7(bufferSize, chainId) {
446
+ handleInt$1(gauge$7, chainId, bufferSize);
461
447
  }
462
448
 
463
449
  let IndexingBufferSize = {
464
- gauge: gauge$8,
465
- set: set$8
450
+ gauge: gauge$7,
451
+ set: set$7
466
452
  };
467
453
 
468
- let gauge$9 = PromClient.Gauge.makeGauge({
454
+ let gauge$8 = PromClient.Gauge.makeGauge({
469
455
  name: "envio_indexing_target_buffer_size",
470
456
  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
457
  });
472
458
 
473
- function set$9(targetBufferSize) {
474
- gauge$9.set(targetBufferSize);
459
+ function set$8(targetBufferSize) {
460
+ gauge$8.set(targetBufferSize);
475
461
  }
476
462
 
477
463
  let IndexingTargetBufferSize = {
478
- gauge: gauge$9,
479
- set: set$9
464
+ gauge: gauge$8,
465
+ set: set$8
480
466
  };
481
467
 
482
- let gauge$10 = makeOrThrow$1("envio_indexing_buffer_block", "The highest block number that has been fully fetched by the indexer.", chainIdLabelsSchema);
468
+ let gauge$9 = makeOrThrow$1("envio_indexing_buffer_block", "The highest block number that has been fully fetched by the indexer.", chainIdLabelsSchema);
483
469
 
484
- function set$10(blockNumber, chainId) {
485
- handleInt$1(gauge$10, chainId, blockNumber);
470
+ function set$9(blockNumber, chainId) {
471
+ handleInt$1(gauge$9, chainId, blockNumber);
486
472
  }
487
473
 
488
474
  let IndexingBufferBlockNumber = {
489
- gauge: gauge$10,
490
- set: set$10
475
+ gauge: gauge$9,
476
+ set: set$9
491
477
  };
492
478
 
493
- let gauge$11 = makeOrThrow$1("envio_indexing_end_block", "The block number to stop indexing at. (inclusive)", chainIdLabelsSchema);
479
+ let gauge$10 = makeOrThrow$1("envio_indexing_end_block", "The block number to stop indexing at. (inclusive)", chainIdLabelsSchema);
494
480
 
495
- function set$11(endBlock, chainId) {
496
- handleInt$1(gauge$11, chainId, endBlock);
481
+ function set$10(endBlock, chainId) {
482
+ handleInt$1(gauge$10, chainId, endBlock);
497
483
  }
498
484
 
499
485
  let IndexingEndBlock = {
500
- gauge: gauge$11,
501
- set: set$11
486
+ gauge: gauge$10,
487
+ set: set$10
502
488
  };
503
489
 
504
490
  let sourceLabelsSchema = S$RescriptSchema.schema(s => ({
@@ -539,18 +525,18 @@ let SourceRequestCount = {
539
525
  addSeconds: addSeconds
540
526
  };
541
527
 
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);
528
+ let gauge$11 = 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
529
 
544
- function set$12(sourceName, chainId, blockNumber) {
545
- handleInt$1(gauge$12, {
530
+ function set$11(sourceName, chainId, blockNumber) {
531
+ handleInt$1(gauge$11, {
546
532
  source: sourceName,
547
533
  chainId: chainId
548
534
  }, blockNumber);
549
535
  }
550
536
 
551
537
  let SourceHeight = {
552
- gauge: gauge$12,
553
- set: set$12
538
+ gauge: gauge$11,
539
+ set: set$11
554
540
  };
555
541
 
556
542
  let counter$4 = makeOrThrow("envio_reorg_detected_total", "Total number of reorgs detected", chainIdLabelsSchema);
@@ -564,43 +550,43 @@ let ReorgCount = {
564
550
  increment: increment$5
565
551
  };
566
552
 
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);
553
+ let gauge$12 = 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
554
 
569
- function set$13(blockNumber, chain) {
570
- handleInt$1(gauge$13, chain, blockNumber);
555
+ function set$12(blockNumber, chain) {
556
+ handleInt$1(gauge$12, chain, blockNumber);
571
557
  }
572
558
 
573
559
  let ReorgDetectionBlockNumber = {
574
- gauge: gauge$13,
575
- set: set$13
560
+ gauge: gauge$12,
561
+ set: set$12
576
562
  };
577
563
 
578
- let gauge$14 = PromClient.Gauge.makeGauge({
564
+ let gauge$13 = PromClient.Gauge.makeGauge({
579
565
  name: "envio_reorg_threshold",
580
566
  help: "Whether indexing is currently within the reorg threshold"
581
567
  });
582
568
 
583
- function set$14(isInReorgThreshold) {
584
- gauge$14.set(isInReorgThreshold ? 1 : 0);
569
+ function set$13(isInReorgThreshold) {
570
+ gauge$13.set(isInReorgThreshold ? 1 : 0);
585
571
  }
586
572
 
587
573
  let ReorgThreshold = {
588
- gauge: gauge$14,
589
- set: set$14
574
+ gauge: gauge$13,
575
+ set: set$13
590
576
  };
591
577
 
592
- let gauge$15 = PromClient.Gauge.makeGauge({
578
+ let gauge$14 = PromClient.Gauge.makeGauge({
593
579
  name: "envio_rollback_enabled",
594
580
  help: "Whether rollback on reorg is enabled"
595
581
  });
596
582
 
597
- function set$15(enabled) {
598
- gauge$15.set(enabled ? 1 : 0);
583
+ function set$14(enabled) {
584
+ gauge$14.set(enabled ? 1 : 0);
599
585
  }
600
586
 
601
587
  let RollbackEnabled = {
602
- gauge: gauge$15,
603
- set: set$15
588
+ gauge: gauge$14,
589
+ set: set$14
604
590
  };
605
591
 
606
592
  let timeCounter$3 = PromClient.Counter.makeCounter({
@@ -649,62 +635,62 @@ let RollbackHistoryPrune = {
649
635
  increment: increment$7
650
636
  };
651
637
 
652
- let gauge$16 = makeOrThrow$1("envio_rollback_target_block", "The block number reorg was rollbacked to the last time.", chainIdLabelsSchema);
638
+ let gauge$15 = makeOrThrow$1("envio_rollback_target_block", "The block number reorg was rollbacked to the last time.", chainIdLabelsSchema);
653
639
 
654
- function set$16(blockNumber, chain) {
655
- handleInt$1(gauge$16, chain, blockNumber);
640
+ function set$15(blockNumber, chain) {
641
+ handleInt$1(gauge$15, chain, blockNumber);
656
642
  }
657
643
 
658
644
  let RollbackTargetBlockNumber = {
659
- gauge: gauge$16,
660
- set: set$16
645
+ gauge: gauge$15,
646
+ set: set$15
661
647
  };
662
648
 
663
- let gauge$17 = PromClient.Gauge.makeGauge({
649
+ let gauge$16 = PromClient.Gauge.makeGauge({
664
650
  name: "envio_processing_max_batch_size",
665
651
  help: "The maximum number of items to process in a single batch."
666
652
  });
667
653
 
668
- function set$17(maxBatchSize) {
669
- gauge$17.set(maxBatchSize);
654
+ function set$16(maxBatchSize) {
655
+ gauge$16.set(maxBatchSize);
670
656
  }
671
657
 
672
658
  let ProcessingMaxBatchSize = {
673
- gauge: gauge$17,
674
- set: set$17
659
+ gauge: gauge$16,
660
+ set: set$16
675
661
  };
676
662
 
677
- let gauge$18 = makeOrThrow$1("envio_progress_block", "The block number of the latest block processed and stored in the database.", chainIdLabelsSchema);
663
+ let gauge$17 = makeOrThrow$1("envio_progress_block", "The block number of the latest block processed and stored in the database.", chainIdLabelsSchema);
678
664
 
679
- function set$18(blockNumber, chainId) {
680
- handleInt$1(gauge$18, chainId, blockNumber);
665
+ function set$17(blockNumber, chainId) {
666
+ handleInt$1(gauge$17, chainId, blockNumber);
681
667
  }
682
668
 
683
669
  let ProgressBlockNumber = {
684
- gauge: gauge$18,
685
- set: set$18
670
+ gauge: gauge$17,
671
+ set: set$17
686
672
  };
687
673
 
688
- let gauge$19 = makeOrThrow$1("envio_progress_events", "The number of events processed and reflected in the database.", chainIdLabelsSchema);
674
+ let gauge$18 = makeOrThrow$1("envio_progress_events", "The number of events processed and reflected in the database.", chainIdLabelsSchema);
689
675
 
690
- function set$19(processedCount, chainId) {
691
- handleFloat$1(gauge$19, chainId, processedCount);
676
+ function set$18(processedCount, chainId) {
677
+ handleFloat$1(gauge$18, chainId, processedCount);
692
678
  }
693
679
 
694
680
  let ProgressEventsCount = {
695
- gauge: gauge$19,
696
- set: set$19
681
+ gauge: gauge$18,
682
+ set: set$18
697
683
  };
698
684
 
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);
685
+ let gauge$19 = 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
686
 
701
- function set$20(latencyMs, chainId) {
702
- handleInt$1(gauge$20, chainId, latencyMs);
687
+ function set$19(latencyMs, chainId) {
688
+ handleInt$1(gauge$19, chainId, latencyMs);
703
689
  }
704
690
 
705
691
  let ProgressLatency = {
706
- gauge: gauge$20,
707
- set: set$20
692
+ gauge: gauge$19,
693
+ set: set$19
708
694
  };
709
695
 
710
696
  let effectLabelsSchema = S$RescriptSchema.object(s => s.f("effect", S$RescriptSchema.string));
@@ -724,15 +710,15 @@ let EffectCalls = {
724
710
  activeCallsCount: activeCallsCount
725
711
  };
726
712
 
727
- let gauge$21 = makeOrThrow$1("envio_effect_cache", "The number of items in the effect cache.", effectLabelsSchema);
713
+ let gauge$20 = makeOrThrow$1("envio_effect_cache", "The number of items in the effect cache.", effectLabelsSchema);
728
714
 
729
- function set$21(count, effectName) {
730
- handleInt$1(gauge$21, effectName, count);
715
+ function set$20(count, effectName) {
716
+ handleInt$1(gauge$20, effectName, count);
731
717
  }
732
718
 
733
719
  let EffectCacheCount = {
734
- gauge: gauge$21,
735
- set: set$21
720
+ gauge: gauge$20,
721
+ set: set$20
736
722
  };
737
723
 
738
724
  let counter$7 = makeOrThrow("envio_effect_cache_invalidations", "The number of effect cache invalidations.", effectLabelsSchema);
@@ -746,18 +732,18 @@ let EffectCacheInvalidationsCount = {
746
732
  increment: increment$8
747
733
  };
748
734
 
749
- let gauge$22 = makeOrThrow$1("envio_effect_queue", "The number of effect calls waiting in the rate limit queue.", effectLabelsSchema);
735
+ let gauge$21 = makeOrThrow$1("envio_effect_queue", "The number of effect calls waiting in the rate limit queue.", effectLabelsSchema);
750
736
 
751
737
  let timeCounter$6 = makeOrThrow("envio_effect_queue_wait_seconds", "The time spent waiting in the rate limit queue.", effectLabelsSchema);
752
738
 
753
- function set$22(count, effectName) {
754
- handleInt$1(gauge$22, effectName, count);
739
+ function set$21(count, effectName) {
740
+ handleInt$1(gauge$21, effectName, count);
755
741
  }
756
742
 
757
743
  let EffectQueueCount = {
758
- gauge: gauge$22,
744
+ gauge: gauge$21,
759
745
  timeCounter: timeCounter$6,
760
- set: set$22
746
+ set: set$21
761
747
  };
762
748
 
763
749
  let loadLabelsSchema = S$RescriptSchema.schema(s => ({
@@ -861,7 +847,6 @@ export {
861
847
  Info,
862
848
  ProcessStartTimeSeconds,
863
849
  IndexingAddresses,
864
- IndexingMaxConcurrency,
865
850
  IndexingConcurrency,
866
851
  IndexingPartitions,
867
852
  IndexingIdleTime,
@@ -217,20 +217,20 @@ let trackNewStatus = (sourceManager: t, ~newStatus) => {
217
217
  sourceManager.status = newStatus
218
218
  }
219
219
 
220
- let fetchNext = async (
220
+ // Carry out the fetch decision made by CrossChainState.checkAndFetch: either
221
+ // dispatch the admitted queries or start waiting for a new block. Selection
222
+ // (getNextQuery + cross-chain admission) happens upstream so the budget is split
223
+ // per query across all chains.
224
+ let dispatch = async (
221
225
  sourceManager: t,
222
226
  ~fetchState: FetchState.t,
223
227
  ~executeQuery,
224
228
  ~waitForNewBlock,
225
229
  ~onNewBlock,
226
- ~concurrencyLimit,
227
- ~bufferLimit,
230
+ ~action: FetchState.nextQuery,
228
231
  ~stateId,
229
232
  ) => {
230
- let nextQuery = fetchState->FetchState.getNextQuery(~concurrencyLimit, ~bufferLimit)
231
-
232
- switch nextQuery {
233
- | ReachedMaxConcurrency
233
+ switch action {
234
234
  | NothingToQuery => ()
235
235
  | WaitingForNewBlock =>
236
236
  switch sourceManager.waitingForNewBlockStateId {
@@ -251,7 +251,8 @@ let fetchNext = async (
251
251
  }
252
252
  }
253
253
  | Ready(queries) => {
254
- fetchState->FetchState.startFetchingQueries(~queries)
254
+ // Queries are already marked in flight by ChainState.startFetchingQueries
255
+ // when they were admitted; here we just execute them.
255
256
  sourceManager.fetchingPartitionsCount =
256
257
  sourceManager.fetchingPartitionsCount + queries->Array.length
257
258
  Prometheus.IndexingConcurrency.set(
@@ -177,33 +177,28 @@ function trackNewStatus(sourceManager, newStatus) {
177
177
  sourceManager.status = newStatus;
178
178
  }
179
179
 
180
- async function fetchNext(sourceManager, fetchState, executeQuery, waitForNewBlock, onNewBlock, concurrencyLimit, bufferLimit, stateId) {
181
- let nextQuery = FetchState.getNextQuery(fetchState, concurrencyLimit, bufferLimit);
182
- if (typeof nextQuery !== "object") {
183
- switch (nextQuery) {
184
- case "WaitingForNewBlock" :
185
- let waitingStateId = sourceManager.waitingForNewBlockStateId;
186
- if (waitingStateId !== undefined && waitingStateId >= stateId) {
187
- return;
188
- }
189
- trackNewStatus(sourceManager, "WaitingForNewBlock");
190
- sourceManager.waitingForNewBlockStateId = stateId;
191
- let knownHeight = await waitForNewBlock(fetchState.knownHeight);
192
- let waitingStateId$1 = sourceManager.waitingForNewBlockStateId;
193
- if (waitingStateId$1 !== undefined && waitingStateId$1 === stateId) {
194
- trackNewStatus(sourceManager, "Idle");
195
- sourceManager.waitingForNewBlockStateId = undefined;
196
- return onNewBlock(knownHeight);
197
- } else {
198
- return;
199
- }
200
- case "ReachedMaxConcurrency" :
201
- case "NothingToQuery" :
202
- return;
180
+ async function dispatch(sourceManager, fetchState, executeQuery, waitForNewBlock, onNewBlock, action, stateId) {
181
+ if (typeof action !== "object") {
182
+ if (action !== "WaitingForNewBlock") {
183
+ return;
184
+ }
185
+ let waitingStateId = sourceManager.waitingForNewBlockStateId;
186
+ if (waitingStateId !== undefined && waitingStateId >= stateId) {
187
+ return;
188
+ }
189
+ trackNewStatus(sourceManager, "WaitingForNewBlock");
190
+ sourceManager.waitingForNewBlockStateId = stateId;
191
+ let knownHeight = await waitForNewBlock(fetchState.knownHeight);
192
+ let waitingStateId$1 = sourceManager.waitingForNewBlockStateId;
193
+ if (waitingStateId$1 !== undefined && waitingStateId$1 === stateId) {
194
+ trackNewStatus(sourceManager, "Idle");
195
+ sourceManager.waitingForNewBlockStateId = undefined;
196
+ return onNewBlock(knownHeight);
197
+ } else {
198
+ return;
203
199
  }
204
200
  } else {
205
- let queries = nextQuery._0;
206
- FetchState.startFetchingQueries(fetchState, queries);
201
+ let queries = action._0;
207
202
  sourceManager.fetchingPartitionsCount = sourceManager.fetchingPartitionsCount + queries.length | 0;
208
203
  Prometheus.IndexingConcurrency.set(sourceManager.fetchingPartitionsCount, sourceManager.activeSource.chain);
209
204
  trackNewStatus(sourceManager, "Querieng");
@@ -684,7 +679,7 @@ export {
684
679
  getActiveSource,
685
680
  inFlightCount,
686
681
  onReorg,
687
- fetchNext,
682
+ dispatch,
688
683
  waitForNewBlock,
689
684
  executeQuery,
690
685
  makeGetHeightRetryInterval,
@@ -25,14 +25,13 @@ let inFlightCount: t => int
25
25
 
26
26
  let onReorg: (t, ~rollbackTargetBlock: int) => unit
27
27
 
28
- let fetchNext: (
28
+ let dispatch: (
29
29
  t,
30
30
  ~fetchState: FetchState.t,
31
31
  ~executeQuery: FetchState.query => promise<unit>,
32
32
  ~waitForNewBlock: (~knownHeight: int) => promise<int>,
33
33
  ~onNewBlock: (~knownHeight: int) => unit,
34
- ~concurrencyLimit: int,
35
- ~bufferLimit: int,
34
+ ~action: FetchState.nextQuery,
36
35
  ~stateId: int,
37
36
  ) => promise<unit>
38
37