envio 3.5.0-alpha.1 → 3.5.0-alpha.2

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 (86) hide show
  1. package/index.d.ts +10 -6
  2. package/package.json +6 -6
  3. package/src/BatchProcessing.res +13 -0
  4. package/src/BatchProcessing.res.mjs +4 -0
  5. package/src/ChainFetching.res +5 -5
  6. package/src/ChainFetching.res.mjs +3 -4
  7. package/src/ChainState.res +38 -21
  8. package/src/ChainState.res.mjs +17 -24
  9. package/src/ChainState.resi +1 -5
  10. package/src/Change.res +3 -3
  11. package/src/Config.res +0 -4
  12. package/src/Config.res.mjs +0 -10
  13. package/src/Core.res +3 -0
  14. package/src/EntityId.res +15 -0
  15. package/src/EntityId.res.mjs +9 -0
  16. package/src/EventConfigBuilder.res +1 -58
  17. package/src/EventConfigBuilder.res.mjs +1 -33
  18. package/src/FetchState.res +345 -459
  19. package/src/FetchState.res.mjs +269 -430
  20. package/src/HandlerRegister.res +45 -0
  21. package/src/HandlerRegister.res.mjs +43 -0
  22. package/src/InMemoryStore.res +11 -4
  23. package/src/InMemoryTable.res +12 -10
  24. package/src/InMemoryTable.res.mjs +6 -5
  25. package/src/IndexerState.res +59 -2
  26. package/src/IndexerState.res.mjs +48 -3
  27. package/src/IndexerState.resi +2 -0
  28. package/src/Internal.res +17 -8
  29. package/src/LogSelection.res +2 -1
  30. package/src/Metrics.res +37 -6
  31. package/src/Metrics.res.mjs +5 -1
  32. package/src/Persistence.res +1 -1
  33. package/src/PgStorage.res +55 -22
  34. package/src/PgStorage.res.mjs +25 -17
  35. package/src/SimulateItems.res +2 -2
  36. package/src/TestIndexer.res +6 -5
  37. package/src/TestIndexer.res.mjs +3 -2
  38. package/src/UserContext.res +3 -3
  39. package/src/Writing.res +12 -2
  40. package/src/Writing.res.mjs +13 -2
  41. package/src/bindings/ClickHouse.res +5 -3
  42. package/src/bindings/ClickHouse.res.mjs +2 -5
  43. package/src/bindings/Vitest.res +22 -1
  44. package/src/bindings/Vitest.res.mjs +15 -0
  45. package/src/db/EntityHistory.res +16 -7
  46. package/src/db/EntityHistory.res.mjs +7 -6
  47. package/src/db/Table.res +40 -9
  48. package/src/db/Table.res.mjs +44 -6
  49. package/src/sources/AddressSet.res +48 -0
  50. package/src/sources/AddressSet.res.mjs +11 -0
  51. package/src/sources/AddressStore.res +152 -0
  52. package/src/sources/AddressStore.res.mjs +97 -0
  53. package/src/sources/EvmChain.res +3 -0
  54. package/src/sources/EvmChain.res.mjs +4 -2
  55. package/src/sources/EvmHyperSyncSource.res +6 -3
  56. package/src/sources/EvmHyperSyncSource.res.mjs +3 -3
  57. package/src/sources/EvmRpcClient.res +6 -3
  58. package/src/sources/EvmRpcClient.res.mjs +3 -3
  59. package/src/sources/FuelHyperSync.res +4 -3
  60. package/src/sources/FuelHyperSync.res.mjs +3 -3
  61. package/src/sources/FuelHyperSync.resi +2 -1
  62. package/src/sources/FuelHyperSyncClient.res +12 -6
  63. package/src/sources/FuelHyperSyncClient.res.mjs +2 -2
  64. package/src/sources/FuelHyperSyncSource.res +7 -4
  65. package/src/sources/FuelHyperSyncSource.res.mjs +3 -3
  66. package/src/sources/HyperSync.res +6 -4
  67. package/src/sources/HyperSync.res.mjs +2 -3
  68. package/src/sources/HyperSync.resi +1 -1
  69. package/src/sources/HyperSyncClient.res +18 -9
  70. package/src/sources/HyperSyncClient.res.mjs +4 -4
  71. package/src/sources/RpcSource.res +15 -10
  72. package/src/sources/RpcSource.res.mjs +3 -4
  73. package/src/sources/SimulateSource.res +26 -11
  74. package/src/sources/SimulateSource.res.mjs +13 -5
  75. package/src/sources/Source.res +4 -2
  76. package/src/sources/SourceManager.res +2 -3
  77. package/src/sources/SourceManager.res.mjs +2 -3
  78. package/src/sources/Svm.res +1 -2
  79. package/src/sources/Svm.res.mjs +1 -1
  80. package/src/sources/SvmHyperSyncClient.res +12 -3
  81. package/src/sources/SvmHyperSyncClient.res.mjs +2 -2
  82. package/src/sources/SvmHyperSyncSource.res +10 -5
  83. package/src/sources/SvmHyperSyncSource.res.mjs +5 -4
  84. package/src/IndexingAddresses.res +0 -151
  85. package/src/IndexingAddresses.res.mjs +0 -130
  86. package/src/IndexingAddresses.resi +0 -39
@@ -4,24 +4,31 @@ import * as Env from "./Env.res.mjs";
4
4
  import * as Utils from "./Utils.res.mjs";
5
5
  import * as Js_math from "@rescript/runtime/lib/es6/Js_math.js";
6
6
  import * as Logging from "./Logging.res.mjs";
7
+ import * as AddressSet from "./sources/AddressSet.res.mjs";
7
8
  import * as Stdlib_Int from "@rescript/runtime/lib/es6/Stdlib_Int.js";
9
+ import * as AddressStore from "./sources/AddressStore.res.mjs";
8
10
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
9
11
  import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
10
12
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
11
13
  import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
12
14
  import * as Primitive_float from "@rescript/runtime/lib/es6/Primitive_float.js";
13
15
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
14
- import * as IndexingAddresses from "./IndexingAddresses.res.mjs";
15
16
 
16
- let deriveContractNameByAddress = Utils.$$WeakMap.memoize(addressesByContractName => {
17
- let result = {};
18
- Utils.Dict.forEachWithKey(addressesByContractName, (addresses, contractName) => {
19
- for (let i = 0, i_finish = addresses.length; i < i_finish; ++i) {
20
- result[addresses[i]] = contractName;
21
- }
22
- });
23
- return result;
24
- });
17
+ function withAddresses(p, addresses) {
18
+ return {
19
+ id: p.id,
20
+ latestFetchedBlock: p.latestFetchedBlock,
21
+ selection: p.selection,
22
+ addresses: addresses,
23
+ mergeBlock: p.mergeBlock,
24
+ dynamicContract: p.dynamicContract,
25
+ mutPendingQueries: p.mutPendingQueries,
26
+ sourceRangeCapacity: p.sourceRangeCapacity,
27
+ prevSourceRangeCapacity: p.prevSourceRangeCapacity,
28
+ eventDensity: p.eventDensity,
29
+ latestSourceRangeCapacityUpdateBlock: p.latestSourceRangeCapacityUpdateBlock
30
+ };
31
+ }
25
32
 
26
33
  function densityItemsTarget(density, fromBlock, toBlock, chainTargetBlock) {
27
34
  return Primitive_int.max(1, Math.ceil(((Stdlib_Option.getOr(toBlock, chainTargetBlock) - fromBlock | 0) + 1 | 0) * density) | 0);
@@ -69,7 +76,7 @@ function getOrThrow(optimizedPartitions, partitionId) {
69
76
  }
70
77
 
71
78
  function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAddrInPartition, nextPartitionIndexRef) {
72
- let combinedAddresses = p1.addressesByContractName[contractName].concat(p2.addressesByContractName[contractName]);
79
+ let combinedAddresses = p1.addresses.merge(p2.addresses);
73
80
  let p1Below = p1.latestFetchedBlock.blockNumber < potentialMergeBlock;
74
81
  let p2Below = p2.latestFetchedBlock.blockNumber < potentialMergeBlock;
75
82
  let completed = [];
@@ -80,7 +87,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
80
87
  id: p1.id,
81
88
  latestFetchedBlock: p1.latestFetchedBlock,
82
89
  selection: p1.selection,
83
- addressesByContractName: p1.addressesByContractName,
90
+ addresses: p1.addresses,
84
91
  mergeBlock: potentialMergeBlock,
85
92
  dynamicContract: p1.dynamicContract,
86
93
  mutPendingQueries: p1.mutPendingQueries,
@@ -93,7 +100,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
93
100
  id: p2.id,
94
101
  latestFetchedBlock: p2.latestFetchedBlock,
95
102
  selection: p2.selection,
96
- addressesByContractName: p2.addressesByContractName,
103
+ addresses: p2.addresses,
97
104
  mergeBlock: potentialMergeBlock,
98
105
  dynamicContract: p2.dynamicContract,
99
106
  mutPendingQueries: p2.mutPendingQueries,
@@ -122,7 +129,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
122
129
  blockTimestamp: 0
123
130
  },
124
131
  selection: p1.selection,
125
- addressesByContractName: {},
132
+ addresses: p1.addresses,
126
133
  mergeBlock: undefined,
127
134
  dynamicContract: contractName,
128
135
  mutPendingQueries: [],
@@ -136,7 +143,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
136
143
  id: p1.id,
137
144
  latestFetchedBlock: p1.latestFetchedBlock,
138
145
  selection: p1.selection,
139
- addressesByContractName: p1.addressesByContractName,
146
+ addresses: p1.addresses,
140
147
  mergeBlock: potentialMergeBlock,
141
148
  dynamicContract: p1.dynamicContract,
142
149
  mutPendingQueries: p1.mutPendingQueries,
@@ -152,7 +159,7 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
152
159
  id: p2.id,
153
160
  latestFetchedBlock: p2.latestFetchedBlock,
154
161
  selection: p2.selection,
155
- addressesByContractName: p2.addressesByContractName,
162
+ addresses: p2.addresses,
156
163
  mergeBlock: potentialMergeBlock,
157
164
  dynamicContract: p2.dynamicContract,
158
165
  mutPendingQueries: p2.mutPendingQueries,
@@ -165,58 +172,27 @@ function mergePartitionsAtBlock(p1, p2, potentialMergeBlock, contractName, maxAd
165
172
  } else {
166
173
  continuingBase = p1;
167
174
  }
168
- if (combinedAddresses.length > maxAddrInPartition) {
169
- let addressesFull = combinedAddresses.slice(0, maxAddrInPartition);
170
- let addressesRest = combinedAddresses.slice(maxAddrInPartition);
171
- let abcFull = {};
172
- abcFull[contractName] = addressesFull;
173
- let abcRest = {};
174
- abcRest[contractName] = addressesRest;
175
- completed.push({
176
- id: continuingBase.id,
177
- latestFetchedBlock: continuingBase.latestFetchedBlock,
178
- selection: continuingBase.selection,
179
- addressesByContractName: abcFull,
180
- mergeBlock: continuingBase.mergeBlock,
181
- dynamicContract: continuingBase.dynamicContract,
182
- mutPendingQueries: continuingBase.mutPendingQueries,
183
- sourceRangeCapacity: continuingBase.sourceRangeCapacity,
184
- prevSourceRangeCapacity: continuingBase.prevSourceRangeCapacity,
185
- eventDensity: continuingBase.eventDensity,
186
- latestSourceRangeCapacityUpdateBlock: continuingBase.latestSourceRangeCapacityUpdateBlock
187
- });
175
+ if (combinedAddresses.size() > maxAddrInPartition) {
176
+ completed.push(withAddresses(continuingBase, combinedAddresses.slice(0, maxAddrInPartition)));
188
177
  let restId = nextPartitionIndexRef.contents.toString();
189
178
  nextPartitionIndexRef.contents = nextPartitionIndexRef.contents + 1 | 0;
179
+ let init = withAddresses(continuingBase, combinedAddresses.slice(maxAddrInPartition, undefined));
190
180
  completed.push({
191
181
  id: restId,
192
- latestFetchedBlock: continuingBase.latestFetchedBlock,
193
- selection: continuingBase.selection,
194
- addressesByContractName: abcRest,
195
- mergeBlock: continuingBase.mergeBlock,
196
- dynamicContract: continuingBase.dynamicContract,
182
+ latestFetchedBlock: init.latestFetchedBlock,
183
+ selection: init.selection,
184
+ addresses: init.addresses,
185
+ mergeBlock: init.mergeBlock,
186
+ dynamicContract: init.dynamicContract,
197
187
  mutPendingQueries: [],
198
- sourceRangeCapacity: continuingBase.sourceRangeCapacity,
199
- prevSourceRangeCapacity: continuingBase.prevSourceRangeCapacity,
200
- eventDensity: continuingBase.eventDensity,
201
- latestSourceRangeCapacityUpdateBlock: continuingBase.latestSourceRangeCapacityUpdateBlock
188
+ sourceRangeCapacity: init.sourceRangeCapacity,
189
+ prevSourceRangeCapacity: init.prevSourceRangeCapacity,
190
+ eventDensity: init.eventDensity,
191
+ latestSourceRangeCapacityUpdateBlock: init.latestSourceRangeCapacityUpdateBlock
202
192
  });
203
193
  return completed;
204
194
  }
205
- let abc = {};
206
- abc[contractName] = combinedAddresses;
207
- completed.push({
208
- id: continuingBase.id,
209
- latestFetchedBlock: continuingBase.latestFetchedBlock,
210
- selection: continuingBase.selection,
211
- addressesByContractName: abc,
212
- mergeBlock: continuingBase.mergeBlock,
213
- dynamicContract: continuingBase.dynamicContract,
214
- mutPendingQueries: continuingBase.mutPendingQueries,
215
- sourceRangeCapacity: continuingBase.sourceRangeCapacity,
216
- prevSourceRangeCapacity: continuingBase.prevSourceRangeCapacity,
217
- eventDensity: continuingBase.eventDensity,
218
- latestSourceRangeCapacityUpdateBlock: continuingBase.latestSourceRangeCapacityUpdateBlock
219
- });
195
+ completed.push(withAddresses(continuingBase, combinedAddresses));
220
196
  return completed;
221
197
  }
222
198
 
@@ -235,7 +211,7 @@ function make(partitions, maxAddrInPartition, nextPartitionIndex, dynamicContrac
235
211
  let exit = 0;
236
212
  if (p.dynamicContract !== undefined && p.mergeBlock === undefined && p.selection.dependsOnAddresses) {
237
213
  let contractName = p.dynamicContract;
238
- let pAddressesCount = p.addressesByContractName[contractName].length;
214
+ let pAddressesCount = p.addresses.countFor(contractName);
239
215
  let match = Utils.$$Array.last(p.mutPendingQueries);
240
216
  let potentialMergeBlock;
241
217
  if (match !== undefined) {
@@ -418,7 +394,7 @@ function handleQueryResponseForPartition(optimizedPartitions, p, query, knownHei
418
394
  }
419
395
  let updatedMainPartition_id = p.id;
420
396
  let updatedMainPartition_selection = p.selection;
421
- let updatedMainPartition_addressesByContractName = p.addressesByContractName;
397
+ let updatedMainPartition_addresses = p.addresses;
422
398
  let updatedMainPartition_mergeBlock = p.mergeBlock;
423
399
  let updatedMainPartition_dynamicContract = p.dynamicContract;
424
400
  let updatedMainPartition_mutPendingQueries = p.mutPendingQueries;
@@ -427,7 +403,7 @@ function handleQueryResponseForPartition(optimizedPartitions, p, query, knownHei
427
403
  id: updatedMainPartition_id,
428
404
  latestFetchedBlock: updatedLatestFetchedBlock,
429
405
  selection: updatedMainPartition_selection,
430
- addressesByContractName: updatedMainPartition_addressesByContractName,
406
+ addresses: updatedMainPartition_addresses,
431
407
  mergeBlock: updatedMainPartition_mergeBlock,
432
408
  dynamicContract: updatedMainPartition_dynamicContract,
433
409
  mutPendingQueries: updatedMainPartition_mutPendingQueries,
@@ -695,7 +671,6 @@ function updateInternal(fetchState, optimizedPartitionsOpt, mutItems, mutItemsSo
695
671
  startBlock: fetchState.startBlock,
696
672
  endBlock: fetchState.endBlock,
697
673
  normalSelection: fetchState.normalSelection,
698
- contractConfigs: fetchState.contractConfigs,
699
674
  chainId: fetchState.chainId,
700
675
  latestOnBlockBlockNumber: latestOnBlockBlockNumber,
701
676
  blockLag: blockLag,
@@ -708,36 +683,6 @@ function updateInternal(fetchState, optimizedPartitionsOpt, mutItems, mutItemsSo
708
683
  };
709
684
  }
710
685
 
711
- function warnDifferentContractType(fetchState, existingContract, dc) {
712
- let logger = Logging.createChild({
713
- chainId: fetchState.chainId,
714
- contractAddress: dc.address,
715
- existingContractType: existingContract.contractName,
716
- newContractType: dc.contractName
717
- });
718
- Logging.childWarn(logger, `Skipping contract registration: Contract address is already registered for one contract and cannot be registered for another contract.`);
719
- }
720
-
721
- function addressesByContractNameCount(addressesByContractName) {
722
- let numAddresses = {
723
- contents: 0
724
- };
725
- Utils.Dict.forEach(addressesByContractName, addresses => {
726
- numAddresses.contents = numAddresses.contents + addresses.length | 0;
727
- });
728
- return numAddresses.contents;
729
- }
730
-
731
- function addressesByContractNameGetAll(addressesByContractName) {
732
- let all = [];
733
- Utils.Dict.forEach(addressesByContractName, addresses => {
734
- for (let idx = 0, idx_finish = addresses.length; idx < idx_finish; ++idx) {
735
- all.push(addresses[idx]);
736
- }
737
- });
738
- return all;
739
- }
740
-
741
686
  function addClientFilteredContract(clientFilteredContracts, contractName, chainId, addressCount, threshold) {
742
687
  clientFilteredContracts.add(contractName);
743
688
  Logging.childTrace(Logging.createChild({
@@ -748,7 +693,14 @@ function addClientFilteredContract(clientFilteredContracts, contractName, chainI
748
693
  }), "Switching contract to client-side address filtering: registered address count crossed the server-side threshold.");
749
694
  }
750
695
 
751
- function collapseClientFilteredContracts(partitions, clientFilteredContracts, normalSelection, nextPartitionIndexRef) {
696
+ function claimedFetchedBlock(p, knownHeight) {
697
+ return Stdlib_Array.reduce(p.mutPendingQueries, p.latestFetchedBlock.blockNumber, (max, q) => {
698
+ let match = q.fetchedBlock;
699
+ return Primitive_int.max(max, match !== undefined ? match.blockNumber : Stdlib_Option.getOr(q.toBlock, knownHeight));
700
+ });
701
+ }
702
+
703
+ function collapseClientFilteredContracts(partitions, clientFilteredContracts, normalSelection, nextPartitionIndexRef, addressStore, knownHeight) {
752
704
  if (clientFilteredContracts.size === 0) {
753
705
  return partitions;
754
706
  }
@@ -770,32 +722,16 @@ function collapseClientFilteredContracts(partitions, clientFilteredContracts, no
770
722
  }
771
723
  return;
772
724
  }
773
- let contractNames = Object.keys(p.addressesByContractName);
774
- let clientFilteredNames = contractNames.filter(c => clientFilteredContracts.has(c));
775
- if (Utils.$$Array.isEmpty(clientFilteredNames)) {
725
+ let contractNames = p.addresses.contractNames();
726
+ let serverSideNames = contractNames.filter(c => !clientFilteredContracts.has(c));
727
+ if (serverSideNames.length === contractNames.length) {
776
728
  kept.push(p);
777
- return;
778
- }
779
- if (clientFilteredNames.length === contractNames.length) {
729
+ } else if (Utils.$$Array.isEmpty(serverSideNames)) {
780
730
  absorbedPartitions.push(p);
781
- return;
731
+ } else {
732
+ strippedFrontiers.push(p.latestFetchedBlock);
733
+ kept.push(withAddresses(p, p.addresses.filterByContracts(serverSideNames)));
782
734
  }
783
- let stripped = Utils.Dict.shallowCopy(p.addressesByContractName);
784
- clientFilteredNames.forEach(c => Utils.Dict.deleteInPlace(stripped, c));
785
- strippedFrontiers.push(p.latestFetchedBlock);
786
- kept.push({
787
- id: p.id,
788
- latestFetchedBlock: p.latestFetchedBlock,
789
- selection: p.selection,
790
- addressesByContractName: stripped,
791
- mergeBlock: p.mergeBlock,
792
- dynamicContract: p.dynamicContract,
793
- mutPendingQueries: p.mutPendingQueries,
794
- sourceRangeCapacity: p.sourceRangeCapacity,
795
- prevSourceRangeCapacity: p.prevSourceRangeCapacity,
796
- eventDensity: p.eventDensity,
797
- latestSourceRangeCapacityUpdateBlock: p.latestSourceRangeCapacityUpdateBlock
798
- });
799
735
  });
800
736
  let standing = standingRef.contents;
801
737
  let selectionChanged = standing !== undefined ? Stdlib_Option.mapOr(standing.selection.clientFilteredContracts, 0, prim => prim.length) !== clientFilteredContracts.size : true;
@@ -850,7 +786,7 @@ function collapseClientFilteredContracts(partitions, clientFilteredContracts, no
850
786
  id: id,
851
787
  latestFetchedBlock: standing$2.latestFetchedBlock,
852
788
  selection: newSelection,
853
- addressesByContractName: standing$2.addressesByContractName,
789
+ addresses: standing$2.addresses,
854
790
  mergeBlock: standing$2.mergeBlock,
855
791
  dynamicContract: standing$2.dynamicContract,
856
792
  mutPendingQueries: [],
@@ -863,16 +799,17 @@ function collapseClientFilteredContracts(partitions, clientFilteredContracts, no
863
799
  standingOut = standing$2;
864
800
  }
865
801
  kept.push(standingOut);
802
+ let catchUpToBlock = claimedFetchedBlock(standingOut, knownHeight);
866
803
  let minFrontier = minFrontierRef.contents;
867
- if (minFrontier !== undefined && minFrontier.blockNumber < standing$2.latestFetchedBlock.blockNumber) {
804
+ if (minFrontier !== undefined && minFrontier.blockNumber < catchUpToBlock) {
868
805
  let id$1 = nextPartitionIndexRef.contents.toString();
869
806
  nextPartitionIndexRef.contents = nextPartitionIndexRef.contents + 1 | 0;
870
807
  kept.push({
871
808
  id: id$1,
872
809
  latestFetchedBlock: minFrontier,
873
810
  selection: newSelection,
874
- addressesByContractName: {},
875
- mergeBlock: standing$2.latestFetchedBlock.blockNumber,
811
+ addresses: addressStore.emptySet(),
812
+ mergeBlock: catchUpToBlock,
876
813
  dynamicContract: undefined,
877
814
  mutPendingQueries: [],
878
815
  sourceRangeCapacity: standing$2.sourceRangeCapacity,
@@ -894,7 +831,7 @@ function collapseClientFilteredContracts(partitions, clientFilteredContracts, no
894
831
  id: id$2,
895
832
  latestFetchedBlock: minFrontier$1,
896
833
  selection: newSelection,
897
- addressesByContractName: {},
834
+ addresses: addressStore.emptySet(),
898
835
  mergeBlock: undefined,
899
836
  dynamicContract: undefined,
900
837
  mutPendingQueries: [],
@@ -906,111 +843,89 @@ function collapseClientFilteredContracts(partitions, clientFilteredContracts, no
906
843
  return kept;
907
844
  }
908
845
 
909
- function createPartitionsFromIndexingAddresses(registeringContractsByContract, dynamicContracts, clientFilteredContracts, normalSelection, maxAddrInPartition, nextPartitionIndex, existingPartitions, progressBlockNumber) {
846
+ function createPartitions(registeringSetsByContract, addressStore, dynamicContracts, clientFilteredContracts, normalSelection, maxAddrInPartition, nextPartitionIndex, existingPartitions, progressBlockNumber, knownHeight) {
910
847
  let nextPartitionIndexRef = {
911
848
  contents: nextPartitionIndex
912
849
  };
913
850
  let dynamicPartitions = [];
914
851
  let nonDynamicPartitions = [];
915
- let contractNames = Object.keys(registeringContractsByContract);
852
+ let contractNames = Object.keys(registeringSetsByContract);
916
853
  for (let cIdx = 0, cIdx_finish = contractNames.length; cIdx < cIdx_finish; ++cIdx) {
917
854
  let contractName = contractNames[cIdx];
918
- let registeringContracts = registeringContractsByContract[contractName];
919
- let addresses = Object.keys(registeringContracts);
855
+ let contractSet = registeringSetsByContract[contractName];
920
856
  let isDynamic = dynamicContracts.has(contractName);
921
857
  let partitions = isDynamic ? dynamicPartitions : nonDynamicPartitions;
922
- let byStartBlock = {};
923
- for (let jdx = 0, jdx_finish = addresses.length; jdx < jdx_finish; ++jdx) {
924
- let address = addresses[jdx];
925
- let indexingContract = registeringContracts[address];
926
- Utils.Dict.push(byStartBlock, indexingContract.effectiveStartBlock.toString(), address);
927
- }
928
- let ascKeys = Object.keys(byStartBlock);
929
- let initialKey = Utils.$$Array.firstUnsafe(ascKeys);
930
- let startBlockRef = Stdlib_Int.fromString(initialKey, undefined);
931
- let addressesRef = byStartBlock[initialKey];
932
- for (let idx = 0, idx_finish = ascKeys.length; idx < idx_finish; ++idx) {
933
- let maybeNextStartBlockKey = ascKeys[idx + 1 | 0];
934
- let shouldAllocateNewPartition;
935
- if (maybeNextStartBlockKey !== undefined) {
936
- let nextStartBlock = Stdlib_Int.fromString(maybeNextStartBlockKey, undefined);
937
- let shouldJoinCurrentStartBlock = (nextStartBlock - startBlockRef | 0) < 20000;
938
- if (shouldJoinCurrentStartBlock) {
939
- addressesRef = addressesRef.concat(byStartBlock[maybeNextStartBlockKey]);
940
- shouldAllocateNewPartition = false;
858
+ let groups = contractSet.startBlockGroups();
859
+ let offsetRef = 0;
860
+ let groupIdx = 0;
861
+ while (groupIdx < groups.length) {
862
+ let startBlock = groups[groupIdx].startBlock;
863
+ let countRef = 0;
864
+ let nextIdx = groupIdx;
865
+ let joining = true;
866
+ while (joining && nextIdx < groups.length) {
867
+ let group = groups[nextIdx];
868
+ if ((group.startBlock - startBlock | 0) < 20000) {
869
+ countRef = countRef + group.count | 0;
870
+ nextIdx = nextIdx + 1 | 0;
941
871
  } else {
942
- shouldAllocateNewPartition = true;
872
+ joining = false;
943
873
  }
944
- } else {
945
- shouldAllocateNewPartition = true;
946
- }
947
- if (shouldAllocateNewPartition) {
948
- let latestFetchedBlock_blockNumber = Primitive_int.max(startBlockRef - 1 | 0, progressBlockNumber);
949
- let latestFetchedBlock = {
950
- blockNumber: latestFetchedBlock_blockNumber,
951
- blockTimestamp: 0
952
- };
953
- while (addressesRef.length !== 0) {
954
- let pAddresses = addressesRef.slice(0, maxAddrInPartition);
955
- addressesRef = addressesRef.slice(maxAddrInPartition);
956
- let addressesByContractName = {};
957
- addressesByContractName[contractName] = pAddresses;
958
- partitions.push({
959
- id: nextPartitionIndexRef.contents.toString(),
960
- latestFetchedBlock: latestFetchedBlock,
961
- selection: normalSelection,
962
- addressesByContractName: addressesByContractName,
963
- mergeBlock: undefined,
964
- dynamicContract: isDynamic ? contractName : undefined,
965
- mutPendingQueries: [],
966
- sourceRangeCapacity: 0,
967
- prevSourceRangeCapacity: 0,
968
- eventDensity: undefined,
969
- latestSourceRangeCapacityUpdateBlock: 0
970
- });
971
- nextPartitionIndexRef.contents = nextPartitionIndexRef.contents + 1 | 0;
972
- };
973
- if (maybeNextStartBlockKey !== undefined) {
974
- startBlockRef = Stdlib_Int.fromString(maybeNextStartBlockKey, undefined);
975
- addressesRef = byStartBlock[maybeNextStartBlockKey];
976
- }
977
- }
978
- }
874
+ };
875
+ let latestFetchedBlock_blockNumber = Primitive_int.max(startBlock - 1 | 0, progressBlockNumber);
876
+ let latestFetchedBlock = {
877
+ blockNumber: latestFetchedBlock_blockNumber,
878
+ blockTimestamp: 0
879
+ };
880
+ let remainingRef = countRef;
881
+ let chunkOffsetRef = offsetRef;
882
+ while (remainingRef > 0) {
883
+ let take = Primitive_int.min(remainingRef, maxAddrInPartition);
884
+ let pAddresses = contractSet.slice(chunkOffsetRef, take);
885
+ partitions.push({
886
+ id: nextPartitionIndexRef.contents.toString(),
887
+ latestFetchedBlock: latestFetchedBlock,
888
+ selection: normalSelection,
889
+ addresses: pAddresses,
890
+ mergeBlock: undefined,
891
+ dynamicContract: isDynamic ? contractName : undefined,
892
+ mutPendingQueries: [],
893
+ sourceRangeCapacity: 0,
894
+ prevSourceRangeCapacity: 0,
895
+ eventDensity: undefined,
896
+ latestSourceRangeCapacityUpdateBlock: 0
897
+ });
898
+ nextPartitionIndexRef.contents = nextPartitionIndexRef.contents + 1 | 0;
899
+ chunkOffsetRef = chunkOffsetRef + take | 0;
900
+ remainingRef = remainingRef - take | 0;
901
+ };
902
+ offsetRef = offsetRef + countRef | 0;
903
+ groupIdx = nextIdx;
904
+ };
979
905
  }
980
906
  let mergedNonDynamic = [];
981
907
  if (nonDynamicPartitions.length !== 0) {
982
908
  nonDynamicPartitions.sort(ascSortFn);
983
909
  let currentPRef = nonDynamicPartitions[0];
984
- let nextIdx = 1;
985
- while (nextIdx < nonDynamicPartitions.length) {
986
- let nextP = nonDynamicPartitions[nextIdx];
910
+ let nextIdx$1 = 1;
911
+ while (nextIdx$1 < nonDynamicPartitions.length) {
912
+ let nextP = nonDynamicPartitions[nextIdx$1];
987
913
  let currentP = currentPRef;
988
914
  let currentPBlock = currentP.latestFetchedBlock.blockNumber;
989
915
  let nextPBlock = nextP.latestFetchedBlock.blockNumber;
990
- let totalCount = addressesByContractNameCount(currentP.addressesByContractName) + addressesByContractNameCount(nextP.addressesByContractName) | 0;
916
+ let totalCount = currentP.addresses.size() + nextP.addresses.size() | 0;
991
917
  if (totalCount > maxAddrInPartition) {
992
918
  mergedNonDynamic.push(currentP);
993
919
  currentPRef = nextP;
994
920
  } else {
995
- let mergedAddresses = Utils.Dict.shallowCopy(nextP.addressesByContractName);
996
- let currentContractNames = Object.keys(currentP.addressesByContractName);
997
- for (let jdx$1 = 0, jdx_finish$1 = currentContractNames.length; jdx$1 < jdx_finish$1; ++jdx$1) {
998
- let cn = currentContractNames[jdx$1];
999
- let currentAddrs = currentP.addressesByContractName[cn];
1000
- let existingAddrs = mergedAddresses[cn];
1001
- if (existingAddrs !== undefined) {
1002
- mergedAddresses[cn] = existingAddrs.concat(currentAddrs);
1003
- } else {
1004
- mergedAddresses[cn] = currentAddrs;
1005
- }
1006
- }
921
+ let mergedAddresses = nextP.addresses.merge(currentP.addresses);
1007
922
  let isTooFar = (currentPBlock + 20000 | 0) < nextPBlock;
1008
923
  if (isTooFar) {
1009
924
  mergedNonDynamic.push({
1010
925
  id: currentP.id,
1011
926
  latestFetchedBlock: currentP.latestFetchedBlock,
1012
927
  selection: currentP.selection,
1013
- addressesByContractName: currentP.addressesByContractName,
928
+ addresses: currentP.addresses,
1014
929
  mergeBlock: currentPBlock < nextPBlock ? nextPBlock : undefined,
1015
930
  dynamicContract: currentP.dynamicContract,
1016
931
  mutPendingQueries: currentP.mutPendingQueries,
@@ -1019,191 +934,134 @@ function createPartitionsFromIndexingAddresses(registeringContractsByContract, d
1019
934
  eventDensity: currentP.eventDensity,
1020
935
  latestSourceRangeCapacityUpdateBlock: currentP.latestSourceRangeCapacityUpdateBlock
1021
936
  });
1022
- currentPRef = {
1023
- id: nextP.id,
1024
- latestFetchedBlock: nextP.latestFetchedBlock,
1025
- selection: nextP.selection,
1026
- addressesByContractName: mergedAddresses,
1027
- mergeBlock: nextP.mergeBlock,
1028
- dynamicContract: nextP.dynamicContract,
1029
- mutPendingQueries: nextP.mutPendingQueries,
1030
- sourceRangeCapacity: nextP.sourceRangeCapacity,
1031
- prevSourceRangeCapacity: nextP.prevSourceRangeCapacity,
1032
- eventDensity: nextP.eventDensity,
1033
- latestSourceRangeCapacityUpdateBlock: nextP.latestSourceRangeCapacityUpdateBlock
1034
- };
937
+ currentPRef = withAddresses(nextP, mergedAddresses);
1035
938
  } else {
1036
- currentPRef = {
1037
- id: currentP.id,
1038
- latestFetchedBlock: currentP.latestFetchedBlock,
1039
- selection: currentP.selection,
1040
- addressesByContractName: mergedAddresses,
1041
- mergeBlock: currentP.mergeBlock,
1042
- dynamicContract: currentP.dynamicContract,
1043
- mutPendingQueries: currentP.mutPendingQueries,
1044
- sourceRangeCapacity: currentP.sourceRangeCapacity,
1045
- prevSourceRangeCapacity: currentP.prevSourceRangeCapacity,
1046
- eventDensity: currentP.eventDensity,
1047
- latestSourceRangeCapacityUpdateBlock: currentP.latestSourceRangeCapacityUpdateBlock
1048
- };
939
+ currentPRef = withAddresses(currentP, mergedAddresses);
1049
940
  }
1050
941
  }
1051
- nextIdx = nextIdx + 1 | 0;
942
+ nextIdx$1 = nextIdx$1 + 1 | 0;
1052
943
  };
1053
944
  mergedNonDynamic.push(currentPRef);
1054
945
  }
1055
946
  let mergedPartitions = mergedNonDynamic.concat(dynamicPartitions);
1056
- let allPartitions = collapseClientFilteredContracts(existingPartitions.concat(mergedPartitions), clientFilteredContracts, normalSelection, nextPartitionIndexRef);
947
+ let allPartitions = collapseClientFilteredContracts(existingPartitions.concat(mergedPartitions), clientFilteredContracts, normalSelection, nextPartitionIndexRef, addressStore, knownHeight);
1057
948
  return make(allPartitions, maxAddrInPartition, nextPartitionIndexRef.contents, dynamicContracts, clientFilteredContracts);
1058
949
  }
1059
950
 
1060
- function registerDynamicContracts(fetchState, indexingAddresses, items) {
951
+ function registerDynamicContracts(fetchState, addressStore, claimCeilingOpt, items) {
952
+ let claimCeiling = claimCeilingOpt !== undefined ? claimCeilingOpt : fetchState.knownHeight;
1061
953
  if (Utils.$$Array.isEmpty(fetchState.normalSelection.onEventRegistrations)) {
1062
954
  Stdlib_JsError.throwWithMessage("Invalid configuration. No events to fetch for the dynamic contract registration.");
1063
955
  }
1064
- let registeringContractsByContract = {};
1065
- let earliestRegisteringEventBlockNumber = Infinity;
1066
- let noEventsAddresses = {};
1067
- let registeringAddresses = {};
956
+ let registrations = [];
957
+ let sourceDcs = [];
958
+ let sourceIndexes = [];
1068
959
  for (let itemIdx = 0, itemIdx_finish = items.length; itemIdx < itemIdx_finish; ++itemIdx) {
1069
- let item = items[itemIdx];
1070
- let dcs = item.dcs;
960
+ let dcs = items[itemIdx].dcs;
1071
961
  if (dcs !== undefined) {
1072
- let idx = 0;
1073
- while (idx < dcs.length) {
1074
- let dc = dcs[idx];
1075
- let shouldRemove = false;
1076
- let match = fetchState.contractConfigs[dc.contractName];
1077
- if (match !== undefined) {
1078
- let dcWithStartBlock_address = dc.address;
1079
- let dcWithStartBlock_contractName = dc.contractName;
1080
- let dcWithStartBlock_registrationBlock = dc.registrationBlock;
1081
- let dcWithStartBlock_effectiveStartBlock = IndexingAddresses.deriveEffectiveStartBlock(dc.registrationBlock, match.startBlock);
1082
- let dcWithStartBlock = {
1083
- address: dcWithStartBlock_address,
1084
- contractName: dcWithStartBlock_contractName,
1085
- registrationBlock: dcWithStartBlock_registrationBlock,
1086
- effectiveStartBlock: dcWithStartBlock_effectiveStartBlock
1087
- };
1088
- let existingContract = IndexingAddresses.get(indexingAddresses, dc.address);
1089
- if (existingContract !== undefined) {
1090
- if (existingContract.contractName !== dc.contractName) {
1091
- warnDifferentContractType(fetchState, existingContract, dcWithStartBlock);
1092
- } else if (existingContract.effectiveStartBlock > dcWithStartBlock_effectiveStartBlock) {
1093
- let logger = Logging.createChild({
1094
- chainId: fetchState.chainId,
1095
- contractAddress: dc.address,
1096
- existingBlockNumber: existingContract.effectiveStartBlock,
1097
- newBlockNumber: dcWithStartBlock_effectiveStartBlock
1098
- });
1099
- Logging.childWarn(logger, `Skipping contract registration: Contract address is already registered at a later block number. Currently registration of the same contract address is not supported by Envio. Reach out to us if it's a problem for you.`);
1100
- }
1101
- shouldRemove = true;
1102
- } else {
1103
- let registeringContract = registeringAddresses[dc.address];
1104
- let shouldUpdate = registeringContract !== undefined ? (
1105
- registeringContract.contractName !== dc.contractName ? (warnDifferentContractType(fetchState, registeringContract, dcWithStartBlock), false) : false
1106
- ) : true;
1107
- if (shouldUpdate) {
1108
- earliestRegisteringEventBlockNumber = Primitive_int.min(earliestRegisteringEventBlockNumber, dcWithStartBlock_effectiveStartBlock);
1109
- Utils.Dict.getOrInsertEmptyDict(registeringContractsByContract, dc.contractName)[dc.address] = dcWithStartBlock;
1110
- registeringAddresses[dc.address] = dcWithStartBlock;
1111
- } else {
1112
- shouldRemove = true;
1113
- }
962
+ for (let dcIdx = 0, dcIdx_finish = dcs.length; dcIdx < dcIdx_finish; ++dcIdx) {
963
+ let dc = dcs[dcIdx];
964
+ registrations.push({
965
+ address: dc.address,
966
+ contractName: dc.contractName,
967
+ registrationBlock: dc.registrationBlock
968
+ });
969
+ sourceDcs.push(dcs);
970
+ sourceIndexes.push(dcIdx);
971
+ }
972
+ }
973
+ }
974
+ let idCursor = addressStore.nextId();
975
+ let verdicts = AddressStore.registerBatch(addressStore, registrations);
976
+ let warn = (contractAddress, params, message) => Logging.childWarn(Logging.createChild({
977
+ chainId: fetchState.chainId,
978
+ contractAddress: contractAddress,
979
+ details: params
980
+ }), message);
981
+ let registeringContractNames = [];
982
+ let hasNoEventsUpdatesRef = false;
983
+ for (let idx = 0, idx_finish = verdicts.length; idx < idx_finish; ++idx) {
984
+ let registration = registrations[idx];
985
+ let contractAddress = registration.address;
986
+ let match = verdicts[idx];
987
+ let keep;
988
+ if (typeof match !== "object") {
989
+ warn(contractAddress, {
990
+ contractName: registration.contractName
991
+ }, `Skipping contract registration: Not a valid address for this chain's ecosystem.`);
992
+ keep = false;
993
+ } else {
994
+ switch (match.TAG) {
995
+ case "Added" :
996
+ if (!registeringContractNames.includes(registration.contractName)) {
997
+ registeringContractNames.push(registration.contractName);
1114
998
  }
1115
- } else {
1116
- let dcAsIndexingAddress_address = dc.address;
1117
- let dcAsIndexingAddress_contractName = dc.contractName;
1118
- let dcAsIndexingAddress_registrationBlock = dc.registrationBlock;
1119
- let dcAsIndexingAddress_effectiveStartBlock = IndexingAddresses.deriveEffectiveStartBlock(dc.registrationBlock, undefined);
1120
- let dcAsIndexingAddress = {
1121
- address: dcAsIndexingAddress_address,
1122
- contractName: dcAsIndexingAddress_contractName,
1123
- registrationBlock: dcAsIndexingAddress_registrationBlock,
1124
- effectiveStartBlock: dcAsIndexingAddress_effectiveStartBlock
1125
- };
1126
- let existingContract$1 = IndexingAddresses.get(indexingAddresses, dc.address);
1127
- if (existingContract$1 !== undefined) {
1128
- if (existingContract$1.contractName !== dc.contractName) {
1129
- warnDifferentContractType(fetchState, existingContract$1, dcAsIndexingAddress);
1130
- }
1131
- shouldRemove = true;
1132
- } else {
1133
- let existingContract$2 = registeringAddresses[dc.address];
1134
- if (existingContract$2 !== undefined) {
1135
- if (existingContract$2.contractName !== dc.contractName) {
1136
- warnDifferentContractType(fetchState, existingContract$2, dcAsIndexingAddress);
1137
- }
1138
- shouldRemove = true;
1139
- } else {
1140
- let logger$1 = Logging.createChild({
1141
- chainId: fetchState.chainId,
1142
- contractAddress: dc.address,
1143
- contractName: dc.contractName
1144
- });
1145
- Logging.childWarn(logger$1, `Persisting contract registration without fetching: Contract doesn't have any events to fetch. It'll be picked up on restart if you add events for the contract.`);
1146
- noEventsAddresses[dc.address] = dcAsIndexingAddress;
1147
- registeringAddresses[dc.address] = dcAsIndexingAddress;
1148
- }
999
+ keep = true;
1000
+ break;
1001
+ case "NoEvents" :
1002
+ hasNoEventsUpdatesRef = true;
1003
+ warn(contractAddress, {
1004
+ contractName: registration.contractName
1005
+ }, `Persisting contract registration without fetching: Contract doesn't have any events to fetch. It'll be picked up on restart if you add events for the contract.`);
1006
+ keep = true;
1007
+ break;
1008
+ case "Duplicate" :
1009
+ let existingEffectiveStartBlock = match.existingEffectiveStartBlock;
1010
+ let effectiveStartBlock = match.effectiveStartBlock;
1011
+ if (existingEffectiveStartBlock > effectiveStartBlock) {
1012
+ warn(contractAddress, {
1013
+ existingBlockNumber: existingEffectiveStartBlock,
1014
+ newBlockNumber: effectiveStartBlock
1015
+ }, `Skipping contract registration: Contract address is already registered at a later block number. Currently registration of the same contract address is not supported by Envio. Reach out to us if it's a problem for you.`);
1149
1016
  }
1150
- }
1151
- if (shouldRemove) {
1152
- dcs.splice(idx, 1);
1153
- } else {
1154
- idx = idx + 1 | 0;
1155
- }
1156
- };
1017
+ keep = false;
1018
+ break;
1019
+ case "Conflict" :
1020
+ warn(contractAddress, {
1021
+ existingContractType: match.existingContractName,
1022
+ newContractType: registration.contractName
1023
+ }, `Skipping contract registration: Contract address is already registered for one contract and cannot be registered for another contract.`);
1024
+ keep = false;
1025
+ break;
1026
+ }
1027
+ }
1028
+ if (!keep) {
1029
+ sourceIndexes[idx] = -1 - sourceIndexes[idx] | 0;
1157
1030
  }
1158
1031
  }
1159
- let dcContractNamesToStore = Object.keys(registeringContractsByContract);
1160
- let hasNoEventsUpdates = !Utils.Dict.isEmpty(noEventsAddresses);
1161
- if (dcContractNamesToStore.length === 0) {
1162
- if (hasNoEventsUpdates) {
1163
- IndexingAddresses.register(indexingAddresses, noEventsAddresses);
1164
- return fetchState;
1165
- } else {
1166
- return fetchState;
1032
+ for (let idx$1 = verdicts.length - 1 | 0; idx$1 >= 0; --idx$1) {
1033
+ let marked = sourceIndexes[idx$1];
1034
+ if (marked < 0) {
1035
+ sourceDcs[idx$1].splice(-1 - marked | 0, 1);
1167
1036
  }
1168
1037
  }
1038
+ if (registeringContractNames.length === 0) {
1039
+ return fetchState;
1040
+ }
1169
1041
  let newPartitions = [];
1170
1042
  let dynamicContractsRef = fetchState.optimizedPartitions.dynamicContracts;
1171
1043
  let mutExistingPartitions = Object.values(fetchState.optimizedPartitions.entities);
1172
- for (let idx$1 = 0, idx_finish = dcContractNamesToStore.length; idx$1 < idx_finish; ++idx$1) {
1173
- let contractName = dcContractNamesToStore[idx$1];
1044
+ for (let idx$2 = 0, idx_finish$1 = registeringContractNames.length; idx$2 < idx_finish$1; ++idx$2) {
1045
+ let contractName = registeringContractNames[idx$2];
1174
1046
  if (!dynamicContractsRef.has(contractName)) {
1175
1047
  dynamicContractsRef = Utils.$$Set.immutableAdd(dynamicContractsRef, contractName);
1176
- for (let idx$2 = 0, idx_finish$1 = mutExistingPartitions.length; idx$2 < idx_finish$1; ++idx$2) {
1177
- let p = mutExistingPartitions[idx$2];
1178
- let addresses = p.addressesByContractName[contractName];
1179
- if (addresses !== undefined && p.selection.dependsOnAddresses && p.mergeBlock === undefined) {
1180
- let allPartitionContractNames = Object.keys(p.addressesByContractName);
1048
+ for (let idx$3 = 0, idx_finish$2 = mutExistingPartitions.length; idx$3 < idx_finish$2; ++idx$3) {
1049
+ let p = mutExistingPartitions[idx$3];
1050
+ let match$1 = p.addresses.countFor(contractName);
1051
+ if (match$1 !== 0 && p.selection.dependsOnAddresses && p.mergeBlock === undefined) {
1052
+ let allPartitionContractNames = p.addresses.contractNames();
1181
1053
  if (allPartitionContractNames.length !== 1) {
1182
1054
  let isFetching = p.mutPendingQueries.length !== 0;
1183
1055
  if (!isFetching) {
1184
1056
  let newPartitionId = (fetchState.optimizedPartitions.nextPartitionIndex + newPartitions.length | 0).toString();
1185
- let restAddressesByContractName = Utils.Dict.shallowCopy(p.addressesByContractName);
1186
- Utils.Dict.deleteInPlace(restAddressesByContractName, contractName);
1187
- mutExistingPartitions[idx$2] = {
1188
- id: p.id,
1189
- latestFetchedBlock: p.latestFetchedBlock,
1190
- selection: p.selection,
1191
- addressesByContractName: restAddressesByContractName,
1192
- mergeBlock: p.mergeBlock,
1193
- dynamicContract: p.dynamicContract,
1194
- mutPendingQueries: p.mutPendingQueries,
1195
- sourceRangeCapacity: p.sourceRangeCapacity,
1196
- prevSourceRangeCapacity: p.prevSourceRangeCapacity,
1197
- eventDensity: p.eventDensity,
1198
- latestSourceRangeCapacityUpdateBlock: p.latestSourceRangeCapacityUpdateBlock
1199
- };
1200
- let addressesByContractName = {};
1201
- addressesByContractName[contractName] = addresses;
1057
+ let restNames = allPartitionContractNames.filter(name => name !== contractName);
1058
+ mutExistingPartitions[idx$3] = withAddresses(p, p.addresses.filterByContracts(restNames));
1059
+ let splitAddresses = p.addresses.filterByContracts([contractName]);
1202
1060
  newPartitions.push({
1203
1061
  id: newPartitionId,
1204
1062
  latestFetchedBlock: p.latestFetchedBlock,
1205
1063
  selection: fetchState.normalSelection,
1206
- addressesByContractName: addressesByContractName,
1064
+ addresses: splitAddresses,
1207
1065
  mergeBlock: undefined,
1208
1066
  dynamicContract: contractName,
1209
1067
  mutPendingQueries: p.mutPendingQueries,
@@ -1214,11 +1072,11 @@ function registerDynamicContracts(fetchState, indexingAddresses, items) {
1214
1072
  });
1215
1073
  }
1216
1074
  } else {
1217
- mutExistingPartitions[idx$2] = {
1075
+ mutExistingPartitions[idx$3] = {
1218
1076
  id: p.id,
1219
1077
  latestFetchedBlock: p.latestFetchedBlock,
1220
1078
  selection: p.selection,
1221
- addressesByContractName: p.addressesByContractName,
1079
+ addresses: p.addresses,
1222
1080
  mergeBlock: p.mergeBlock,
1223
1081
  dynamicContract: contractName,
1224
1082
  mutPendingQueries: p.mutPendingQueries,
@@ -1231,16 +1089,13 @@ function registerDynamicContracts(fetchState, indexingAddresses, items) {
1231
1089
  }
1232
1090
  }
1233
1091
  }
1234
- let registeringContracts = registeringContractsByContract[contractName];
1235
- IndexingAddresses.register(indexingAddresses, registeringContracts);
1236
1092
  }
1237
- IndexingAddresses.register(indexingAddresses, noEventsAddresses);
1238
1093
  let threshold = fetchState.clientFilterAddressThreshold;
1239
1094
  let clientFilteredContracts;
1240
1095
  if (threshold !== undefined) {
1241
1096
  let clientFilteredContracts$1 = new Set(Array.from(fetchState.optimizedPartitions.clientFilteredContracts));
1242
1097
  Array.from(dynamicContractsRef).forEach(contractName => {
1243
- let addressCount = IndexingAddresses.contractCount(indexingAddresses, contractName);
1098
+ let addressCount = addressStore.contractCount(contractName);
1244
1099
  if (!clientFilteredContracts$1.has(contractName) && addressCount > threshold) {
1245
1100
  return addClientFilteredContract(clientFilteredContracts$1, contractName, fetchState.chainId, addressCount, threshold);
1246
1101
  }
@@ -1249,23 +1104,14 @@ function registerDynamicContracts(fetchState, indexingAddresses, items) {
1249
1104
  } else {
1250
1105
  clientFilteredContracts = fetchState.optimizedPartitions.clientFilteredContracts;
1251
1106
  }
1252
- let optimizedPartitions = createPartitionsFromIndexingAddresses(registeringContractsByContract, dynamicContractsRef, clientFilteredContracts, fetchState.normalSelection, fetchState.optimizedPartitions.maxAddrInPartition, fetchState.optimizedPartitions.nextPartitionIndex + newPartitions.length | 0, mutExistingPartitions.concat(newPartitions), 0);
1253
- return updateInternal(fetchState, optimizedPartitions, undefined, undefined, undefined, undefined);
1254
- }
1255
-
1256
- function filterByClientAddress(items, indexingAddresses) {
1257
- return items.filter(item => {
1258
- if (item.kind !== 0) {
1259
- return true;
1260
- }
1261
- let reg = item.onEventRegistration;
1262
- let filter = reg.clientAddressFilter;
1263
- if (filter !== undefined) {
1264
- return filter(item.payload, item.blockNumber, IndexingAddresses.forContract(indexingAddresses, reg.eventConfig.contractName));
1265
- } else {
1266
- return true;
1267
- }
1107
+ let registeringSetsByContract = {};
1108
+ registeringContractNames.forEach(contractName => {
1109
+ registeringSetsByContract[contractName] = AddressStore.makeSet(addressStore, contractName, {
1110
+ minId: idCursor
1111
+ });
1268
1112
  });
1113
+ let optimizedPartitions = createPartitions(registeringSetsByContract, addressStore, dynamicContractsRef, clientFilteredContracts, fetchState.normalSelection, fetchState.optimizedPartitions.maxAddrInPartition, fetchState.optimizedPartitions.nextPartitionIndex + newPartitions.length | 0, mutExistingPartitions.concat(newPartitions), 0, Primitive_int.max(claimCeiling, fetchState.knownHeight));
1114
+ return updateInternal(fetchState, optimizedPartitions, undefined, undefined, undefined, undefined);
1269
1115
  }
1270
1116
 
1271
1117
  function handleQueryResult(fetchState, query, latestFetchedBlock, newItems) {
@@ -1302,7 +1148,7 @@ function startFetchingQueries(param, queries) {
1302
1148
  }
1303
1149
  }
1304
1150
 
1305
- function pushDensityPricedQuery(queries, partitionId, fromBlock, toBlock, isChunk, density, chainTargetBlock, selection, addressesByContractName) {
1151
+ function pushDensityPricedQuery(queries, partitionId, fromBlock, toBlock, isChunk, density, chainTargetBlock, selection, addresses) {
1306
1152
  let itemsEst = densityItemsTarget(density, fromBlock, toBlock, chainTargetBlock);
1307
1153
  queries.push({
1308
1154
  partitionId: partitionId,
@@ -1312,12 +1158,12 @@ function pushDensityPricedQuery(queries, partitionId, fromBlock, toBlock, isChun
1312
1158
  itemsTarget: toBlock !== undefined ? undefined : itemsEst,
1313
1159
  itemsEst: itemsEst,
1314
1160
  selection: selection,
1315
- addressesByContractName: addressesByContractName
1161
+ addresses: addresses
1316
1162
  });
1317
1163
  return itemsEst;
1318
1164
  }
1319
1165
 
1320
- function pushGapFillQueries(queries, partitionId, rangeFromBlock, rangeEndBlock, headBlockNumber, chainTargetBlock, maybeChunkRange, maxChunks, partition, partitionBudget, selection, addressesByContractName) {
1166
+ function pushGapFillQueries(queries, partitionId, rangeFromBlock, rangeEndBlock, headBlockNumber, chainTargetBlock, maybeChunkRange, maxChunks, partition, partitionBudget, selection, addresses) {
1321
1167
  if (!(rangeFromBlock <= Primitive_int.min(headBlockNumber, chainTargetBlock) && maxChunks > 0)) {
1322
1168
  return;
1323
1169
  }
@@ -1333,7 +1179,7 @@ function pushGapFillQueries(queries, partitionId, rangeFromBlock, rangeEndBlock,
1333
1179
  if (exit === 1) {
1334
1180
  let maxBlock = rangeEndBlock !== undefined ? rangeEndBlock : chainTargetBlock;
1335
1181
  let pushSingleQuery = (density, isChunk) => {
1336
- pushDensityPricedQuery(queries, partitionId, rangeFromBlock, rangeEndBlock, isChunk, density, chainTargetBlock, selection, addressesByContractName);
1182
+ pushDensityPricedQuery(queries, partitionId, rangeFromBlock, rangeEndBlock, isChunk, density, chainTargetBlock, selection, addresses);
1337
1183
  };
1338
1184
  let match = partition.eventDensity;
1339
1185
  let exit$1 = 0;
@@ -1348,7 +1194,7 @@ function pushGapFillQueries(queries, partitionId, rangeFromBlock, rangeEndBlock,
1348
1194
  let chunkIdx = 0;
1349
1195
  while (chunkIdx < maxChunks && ((chunkFromBlock + chunkSize | 0) - 1 | 0) <= maxBlock) {
1350
1196
  let chunkToBlock = (chunkFromBlock + chunkSize | 0) - 1 | 0;
1351
- pushDensityPricedQuery(queries, partitionId, chunkFromBlock, chunkToBlock, true, match, chainTargetBlock, selection, addressesByContractName);
1197
+ pushDensityPricedQuery(queries, partitionId, chunkFromBlock, chunkToBlock, true, match, chainTargetBlock, selection, addresses);
1352
1198
  chunkFromBlock = chunkToBlock + 1 | 0;
1353
1199
  chunkIdx = chunkIdx + 1 | 0;
1354
1200
  };
@@ -1382,7 +1228,7 @@ function walkPartitionPending(p, partitionId, inFlightCount, candidates, headBlo
1382
1228
  let pq = p.mutPendingQueries[pqIdx];
1383
1229
  if (pq.fromBlock > cursor) {
1384
1230
  let beforeLen = candidates.length;
1385
- pushGapFillQueries(candidates, partitionId, cursor, Utils.$$Math.minOptInt(pq.fromBlock - 1 | 0, queryEndBlock), headBlockNumber, chainTargetBlock, maybeChunkRange, (12 - inFlightCount | 0) - chunksUsedThisCall | 0, p, partitionBudget, p.selection, p.addressesByContractName);
1231
+ pushGapFillQueries(candidates, partitionId, cursor, Utils.$$Math.minOptInt(pq.fromBlock - 1 | 0, queryEndBlock), headBlockNumber, chainTargetBlock, maybeChunkRange, (12 - inFlightCount | 0) - chunksUsedThisCall | 0, p, partitionBudget, p.selection, p.addresses);
1386
1232
  chunksUsedThisCall = chunksUsedThisCall + (candidates.length - beforeLen | 0) | 0;
1387
1233
  }
1388
1234
  let toBlock = pq.toBlock;
@@ -1438,7 +1284,7 @@ function pushForwardCandidates(candidates, inRangeStates, inRangeCount, chainTar
1438
1284
  let generatedItems = 0;
1439
1285
  while (created < maxChunksRemaining && chunkFromBlock <= chunkStartCeiling && generatedItems <= freshBudget) {
1440
1286
  let chunkToBlock = Primitive_int.min((chunkFromBlock + chunkSize | 0) - 1 | 0, maxBlock);
1441
- let itemsEst = pushDensityPricedQuery(candidates, fs.partitionId, chunkFromBlock, chunkToBlock, true, match$1, chainTargetBlock, p.selection, p.addressesByContractName);
1287
+ let itemsEst = pushDensityPricedQuery(candidates, fs.partitionId, chunkFromBlock, chunkToBlock, true, match$1, chainTargetBlock, p.selection, p.addresses);
1442
1288
  generatedItems = generatedItems + itemsEst;
1443
1289
  chunkFromBlock = chunkToBlock + 1 | 0;
1444
1290
  created = created + 1 | 0;
@@ -1454,7 +1300,7 @@ function pushForwardCandidates(candidates, inRangeStates, inRangeCount, chainTar
1454
1300
  itemsTarget: itemsEst$1,
1455
1301
  itemsEst: itemsEst$1,
1456
1302
  selection: p.selection,
1457
- addressesByContractName: p.addressesByContractName
1303
+ addresses: p.addresses
1458
1304
  });
1459
1305
  });
1460
1306
  }
@@ -1636,7 +1482,7 @@ function getReadyItemsCount(fetchState, targetSize, fromItem) {
1636
1482
  return acc;
1637
1483
  }
1638
1484
 
1639
- function make$1(startBlock, endBlock, onEventRegistrations, contractConfigs, addresses, maxAddrInPartition, chainId, maxOnBlockBufferSize, knownHeight, progressBlockNumberOpt, onBlockRegistrationsOpt, blockLagOpt, firstEventBlockOpt, clientFilterAddressThresholdOpt) {
1485
+ function make$1(startBlock, endBlock, onEventRegistrations, addressStore, addresses, maxAddrInPartition, chainId, maxOnBlockBufferSize, knownHeight, progressBlockNumberOpt, onBlockRegistrationsOpt, blockLagOpt, firstEventBlockOpt, clientFilterAddressThresholdOpt) {
1640
1486
  let progressBlockNumber = progressBlockNumberOpt !== undefined ? progressBlockNumberOpt : startBlock - 1 | 0;
1641
1487
  let onBlockRegistrations = onBlockRegistrationsOpt !== undefined ? onBlockRegistrationsOpt : [];
1642
1488
  let blockLag = blockLagOpt !== undefined ? blockLagOpt : 0;
@@ -1666,7 +1512,7 @@ function make$1(startBlock, endBlock, onEventRegistrations, contractConfigs, add
1666
1512
  onEventRegistrations: notDependingOnAddresses,
1667
1513
  dependsOnAddresses: false
1668
1514
  },
1669
- addressesByContractName: {},
1515
+ addresses: addressStore.emptySet(),
1670
1516
  mergeBlock: undefined,
1671
1517
  dynamicContract: undefined,
1672
1518
  mutPendingQueries: [],
@@ -1680,13 +1526,20 @@ function make$1(startBlock, endBlock, onEventRegistrations, contractConfigs, add
1680
1526
  onEventRegistrations: normalRegistrations,
1681
1527
  dependsOnAddresses: true
1682
1528
  };
1683
- let registeringContractsByContract = {};
1529
+ AddressStore.registerBatch(addressStore, addresses.map(contract => ({
1530
+ address: contract.address,
1531
+ contractName: contract.contractName,
1532
+ registrationBlock: contract.registrationBlock
1533
+ })));
1684
1534
  let dynamicContracts = new Set();
1685
1535
  let clientFilteredContracts = new Set();
1536
+ let registeringSetsByContract = {};
1686
1537
  addresses.forEach(contract => {
1687
1538
  let contractName = contract.contractName;
1688
1539
  if (contractNamesWithNormalEvents.has(contractName)) {
1689
- Utils.Dict.getOrInsertEmptyDict(registeringContractsByContract, contractName)[contract.address] = IndexingAddresses.makeIndexingAddress(contract, contractConfigs);
1540
+ if (!(contractName in registeringSetsByContract)) {
1541
+ registeringSetsByContract[contractName] = AddressStore.makeSet(addressStore, contractName, undefined);
1542
+ }
1690
1543
  if (contract.registrationBlock !== -1) {
1691
1544
  dynamicContracts.add(contractName);
1692
1545
  return;
@@ -1696,14 +1549,14 @@ function make$1(startBlock, endBlock, onEventRegistrations, contractConfigs, add
1696
1549
  }
1697
1550
  });
1698
1551
  if (clientFilterAddressThreshold !== undefined) {
1699
- Utils.Dict.forEachWithKey(registeringContractsByContract, (addrs, contractName) => {
1700
- let addressCount = Utils.Dict.size(addrs);
1552
+ Utils.Dict.forEachWithKey(registeringSetsByContract, (set, contractName) => {
1553
+ let addressCount = set.size();
1701
1554
  if (addressCount > clientFilterAddressThreshold) {
1702
1555
  return addClientFilteredContract(clientFilteredContracts, contractName, chainId, addressCount, clientFilterAddressThreshold);
1703
1556
  }
1704
1557
  });
1705
1558
  }
1706
- let optimizedPartitions = createPartitionsFromIndexingAddresses(registeringContractsByContract, dynamicContracts, clientFilteredContracts, normalSelection, maxAddrInPartition, partitions.length, partitions, progressBlockNumber);
1559
+ let optimizedPartitions = createPartitions(registeringSetsByContract, addressStore, dynamicContracts, clientFilteredContracts, normalSelection, maxAddrInPartition, partitions.length, partitions, progressBlockNumber, knownHeight);
1707
1560
  if (optimizedPartitions.idsInAscOrder.length === 0 && Utils.$$Array.isEmpty(onBlockRegistrations)) {
1708
1561
  Stdlib_JsError.throwWithMessage(`Invalid configuration: Nothing to fetch on chain ` + chainId.toString() + `. ` + (`addresses=` + addresses.length.toString() + `, `) + (`onEventRegistrations=` + onEventRegistrations.length.toString() + `, `) + (`normalRegistrations=` + normalRegistrations.length.toString() + `. `) + `Make sure that you provided at least one contract address to index, or have events with Wildcard mode enabled, or have onBlock handlers.`);
1709
1562
  }
@@ -1722,7 +1575,6 @@ function make$1(startBlock, endBlock, onEventRegistrations, contractConfigs, add
1722
1575
  startBlock: startBlock,
1723
1576
  endBlock: endBlock,
1724
1577
  normalSelection: normalSelection,
1725
- contractConfigs: contractConfigs,
1726
1578
  chainId: chainId,
1727
1579
  latestOnBlockBlockNumber: latestOnBlockBlockNumber,
1728
1580
  blockLag: blockLag,
@@ -1773,52 +1625,44 @@ function rollbackPendingQueries(mutPendingQueries, targetBlockNumber) {
1773
1625
  return adjusted;
1774
1626
  }
1775
1627
 
1776
- function rollback(fetchState, indexingAddresses, targetBlockNumber) {
1777
- IndexingAddresses.rollbackInPlace(indexingAddresses, targetBlockNumber);
1628
+ function rollback(fetchState, addressStore, targetBlockNumber) {
1629
+ addressStore.rollback(targetBlockNumber);
1778
1630
  let keptPartitions = [];
1779
1631
  let nextKeptIdRef = 0;
1780
- let registeringContractsByContract = {};
1632
+ let registeringSetsByContract = {};
1633
+ let collectForRecreation = set => {
1634
+ set.contractNames().forEach(contractName => {
1635
+ let contractSet = set.filterByContracts([contractName]);
1636
+ let existing = registeringSetsByContract[contractName];
1637
+ registeringSetsByContract[contractName] = existing !== undefined ? Primitive_option.valFromOption(existing).merge(contractSet) : contractSet;
1638
+ });
1639
+ };
1781
1640
  let partitions = Object.values(fetchState.optimizedPartitions.entities);
1782
1641
  for (let idx = 0, idx_finish = partitions.length; idx < idx_finish; ++idx) {
1783
1642
  let p = partitions[idx];
1784
1643
  if (p.selection.dependsOnAddresses) {
1785
1644
  if (p.latestFetchedBlock.blockNumber > targetBlockNumber) {
1786
- Utils.Dict.forEachWithKey(p.addressesByContractName, (addresses, contractName) => {
1787
- addresses.forEach(address => {
1788
- let indexingContract = IndexingAddresses.get(indexingAddresses, address);
1789
- if (indexingContract === undefined) {
1790
- return;
1791
- }
1792
- let registeringContracts = Utils.Dict.getOrInsertEmptyDict(registeringContractsByContract, contractName);
1793
- registeringContracts[address] = indexingContract;
1794
- });
1795
- });
1645
+ collectForRecreation(p.addresses.filterByRegistrationBlock(targetBlockNumber));
1796
1646
  } else {
1797
1647
  let mergeBlock = p.mergeBlock;
1798
1648
  let mergeBlock$1 = mergeBlock !== undefined && mergeBlock > targetBlockNumber ? targetBlockNumber : mergeBlock;
1799
- let rollbackedAddressesByContractName = {};
1800
- Utils.Dict.forEachWithKey(p.addressesByContractName, (addresses, contractName) => {
1801
- let keptAddresses = addresses.filter(address => Stdlib_Option.isSome(IndexingAddresses.get(indexingAddresses, address)));
1802
- if (keptAddresses.length !== 0) {
1803
- rollbackedAddressesByContractName[contractName] = keptAddresses;
1804
- return;
1805
- }
1806
- });
1807
- if (!Utils.Dict.isEmpty(rollbackedAddressesByContractName)) {
1649
+ let rollbackedAddresses = p.addresses.filterByRegistrationBlock(targetBlockNumber);
1650
+ if (!AddressSet.isEmpty(rollbackedAddresses)) {
1808
1651
  let id = nextKeptIdRef.toString();
1809
1652
  nextKeptIdRef = nextKeptIdRef + 1 | 0;
1653
+ let init = withAddresses(p, rollbackedAddresses);
1810
1654
  keptPartitions.push({
1811
1655
  id: id,
1812
- latestFetchedBlock: p.latestFetchedBlock,
1813
- selection: p.selection,
1814
- addressesByContractName: rollbackedAddressesByContractName,
1656
+ latestFetchedBlock: init.latestFetchedBlock,
1657
+ selection: init.selection,
1658
+ addresses: init.addresses,
1815
1659
  mergeBlock: mergeBlock$1,
1816
- dynamicContract: p.dynamicContract,
1660
+ dynamicContract: init.dynamicContract,
1817
1661
  mutPendingQueries: rollbackPendingQueries(p.mutPendingQueries, targetBlockNumber),
1818
- sourceRangeCapacity: p.sourceRangeCapacity,
1819
- prevSourceRangeCapacity: p.prevSourceRangeCapacity,
1820
- eventDensity: p.eventDensity,
1821
- latestSourceRangeCapacityUpdateBlock: p.latestSourceRangeCapacityUpdateBlock
1662
+ sourceRangeCapacity: init.sourceRangeCapacity,
1663
+ prevSourceRangeCapacity: init.prevSourceRangeCapacity,
1664
+ eventDensity: init.eventDensity,
1665
+ latestSourceRangeCapacityUpdateBlock: init.latestSourceRangeCapacityUpdateBlock
1822
1666
  });
1823
1667
  }
1824
1668
  }
@@ -1832,7 +1676,7 @@ function rollback(fetchState, indexingAddresses, targetBlockNumber) {
1832
1676
  blockTimestamp: 0
1833
1677
  }) : p.latestFetchedBlock,
1834
1678
  selection: p.selection,
1835
- addressesByContractName: p.addressesByContractName,
1679
+ addresses: p.addresses,
1836
1680
  mergeBlock: p.mergeBlock,
1837
1681
  dynamicContract: p.dynamicContract,
1838
1682
  mutPendingQueries: rollbackPendingQueries(p.mutPendingQueries, targetBlockNumber),
@@ -1843,13 +1687,12 @@ function rollback(fetchState, indexingAddresses, targetBlockNumber) {
1843
1687
  });
1844
1688
  }
1845
1689
  }
1846
- let optimizedPartitions = createPartitionsFromIndexingAddresses(registeringContractsByContract, fetchState.optimizedPartitions.dynamicContracts, fetchState.optimizedPartitions.clientFilteredContracts, fetchState.normalSelection, fetchState.optimizedPartitions.maxAddrInPartition, nextKeptIdRef, keptPartitions, targetBlockNumber);
1690
+ let optimizedPartitions = createPartitions(registeringSetsByContract, addressStore, fetchState.optimizedPartitions.dynamicContracts, fetchState.optimizedPartitions.clientFilteredContracts, fetchState.normalSelection, fetchState.optimizedPartitions.maxAddrInPartition, nextKeptIdRef, keptPartitions, targetBlockNumber, fetchState.knownHeight);
1847
1691
  return updateInternal({
1848
1692
  optimizedPartitions: fetchState.optimizedPartitions,
1849
1693
  startBlock: fetchState.startBlock,
1850
1694
  endBlock: fetchState.endBlock,
1851
1695
  normalSelection: fetchState.normalSelection,
1852
- contractConfigs: fetchState.contractConfigs,
1853
1696
  chainId: fetchState.chainId,
1854
1697
  latestOnBlockBlockNumber: Primitive_int.min(fetchState.latestOnBlockBlockNumber, targetBlockNumber),
1855
1698
  blockLag: fetchState.blockLag,
@@ -1877,7 +1720,7 @@ function resetPendingQueries(fetchState) {
1877
1720
  id: partition.id,
1878
1721
  latestFetchedBlock: partition.latestFetchedBlock,
1879
1722
  selection: partition.selection,
1880
- addressesByContractName: partition.addressesByContractName,
1723
+ addresses: partition.addresses,
1881
1724
  mergeBlock: partition.mergeBlock,
1882
1725
  dynamicContract: partition.dynamicContract,
1883
1726
  mutPendingQueries: kept,
@@ -1901,7 +1744,6 @@ function resetPendingQueries(fetchState) {
1901
1744
  startBlock: fetchState.startBlock,
1902
1745
  endBlock: fetchState.endBlock,
1903
1746
  normalSelection: fetchState.normalSelection,
1904
- contractConfigs: fetchState.contractConfigs,
1905
1747
  chainId: fetchState.chainId,
1906
1748
  latestOnBlockBlockNumber: fetchState.latestOnBlockBlockNumber,
1907
1749
  blockLag: fetchState.blockLag,
@@ -2032,7 +1874,7 @@ let maxChainConcurrency = Env.maxChainConcurrency;
2032
1874
  let chunkRangeGrowthFactor = 1.8;
2033
1875
 
2034
1876
  export {
2035
- deriveContractNameByAddress,
1877
+ withAddresses,
2036
1878
  densityItemsTarget,
2037
1879
  getMinHistoryRange,
2038
1880
  getTrustedDensity,
@@ -2047,14 +1889,11 @@ export {
2047
1889
  blockItemLogIndex,
2048
1890
  appendOnBlockItems,
2049
1891
  updateInternal,
2050
- warnDifferentContractType,
2051
- addressesByContractNameCount,
2052
- addressesByContractNameGetAll,
2053
1892
  addClientFilteredContract,
1893
+ claimedFetchedBlock,
2054
1894
  collapseClientFilteredContracts,
2055
- createPartitionsFromIndexingAddresses,
1895
+ createPartitions,
2056
1896
  registerDynamicContracts,
2057
- filterByClientAddress,
2058
1897
  handleQueryResult,
2059
1898
  startFetchingQueries,
2060
1899
  maxInFlightChunksPerPartition,
@@ -2082,4 +1921,4 @@ export {
2082
1921
  getProgressBlockNumberAt,
2083
1922
  updateKnownHeight,
2084
1923
  }
2085
- /* deriveContractNameByAddress Not a pure module */
1924
+ /* Env Not a pure module */