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.
- package/index.d.ts +10 -6
- package/package.json +6 -6
- package/src/BatchProcessing.res +13 -0
- package/src/BatchProcessing.res.mjs +4 -0
- package/src/ChainFetching.res +5 -5
- package/src/ChainFetching.res.mjs +3 -4
- package/src/ChainState.res +38 -21
- package/src/ChainState.res.mjs +17 -24
- package/src/ChainState.resi +1 -5
- package/src/Change.res +3 -3
- package/src/Config.res +0 -4
- package/src/Config.res.mjs +0 -10
- package/src/Core.res +3 -0
- package/src/EntityId.res +15 -0
- package/src/EntityId.res.mjs +9 -0
- package/src/EventConfigBuilder.res +1 -58
- package/src/EventConfigBuilder.res.mjs +1 -33
- package/src/FetchState.res +345 -459
- package/src/FetchState.res.mjs +269 -430
- package/src/HandlerRegister.res +45 -0
- package/src/HandlerRegister.res.mjs +43 -0
- package/src/InMemoryStore.res +11 -4
- package/src/InMemoryTable.res +12 -10
- package/src/InMemoryTable.res.mjs +6 -5
- package/src/IndexerState.res +59 -2
- package/src/IndexerState.res.mjs +48 -3
- package/src/IndexerState.resi +2 -0
- package/src/Internal.res +17 -8
- package/src/LogSelection.res +2 -1
- package/src/Metrics.res +37 -6
- package/src/Metrics.res.mjs +5 -1
- package/src/Persistence.res +1 -1
- package/src/PgStorage.res +55 -22
- package/src/PgStorage.res.mjs +25 -17
- package/src/SimulateItems.res +2 -2
- package/src/TestIndexer.res +6 -5
- package/src/TestIndexer.res.mjs +3 -2
- package/src/UserContext.res +3 -3
- package/src/Writing.res +12 -2
- package/src/Writing.res.mjs +13 -2
- package/src/bindings/ClickHouse.res +5 -3
- package/src/bindings/ClickHouse.res.mjs +2 -5
- package/src/bindings/Vitest.res +22 -1
- package/src/bindings/Vitest.res.mjs +15 -0
- package/src/db/EntityHistory.res +16 -7
- package/src/db/EntityHistory.res.mjs +7 -6
- package/src/db/Table.res +40 -9
- package/src/db/Table.res.mjs +44 -6
- package/src/sources/AddressSet.res +48 -0
- package/src/sources/AddressSet.res.mjs +11 -0
- package/src/sources/AddressStore.res +152 -0
- package/src/sources/AddressStore.res.mjs +97 -0
- package/src/sources/EvmChain.res +3 -0
- package/src/sources/EvmChain.res.mjs +4 -2
- package/src/sources/EvmHyperSyncSource.res +6 -3
- package/src/sources/EvmHyperSyncSource.res.mjs +3 -3
- package/src/sources/EvmRpcClient.res +6 -3
- package/src/sources/EvmRpcClient.res.mjs +3 -3
- package/src/sources/FuelHyperSync.res +4 -3
- package/src/sources/FuelHyperSync.res.mjs +3 -3
- package/src/sources/FuelHyperSync.resi +2 -1
- package/src/sources/FuelHyperSyncClient.res +12 -6
- package/src/sources/FuelHyperSyncClient.res.mjs +2 -2
- package/src/sources/FuelHyperSyncSource.res +7 -4
- package/src/sources/FuelHyperSyncSource.res.mjs +3 -3
- package/src/sources/HyperSync.res +6 -4
- package/src/sources/HyperSync.res.mjs +2 -3
- package/src/sources/HyperSync.resi +1 -1
- package/src/sources/HyperSyncClient.res +18 -9
- package/src/sources/HyperSyncClient.res.mjs +4 -4
- package/src/sources/RpcSource.res +15 -10
- package/src/sources/RpcSource.res.mjs +3 -4
- package/src/sources/SimulateSource.res +26 -11
- package/src/sources/SimulateSource.res.mjs +13 -5
- package/src/sources/Source.res +4 -2
- package/src/sources/SourceManager.res +2 -3
- package/src/sources/SourceManager.res.mjs +2 -3
- package/src/sources/Svm.res +1 -2
- package/src/sources/Svm.res.mjs +1 -1
- package/src/sources/SvmHyperSyncClient.res +12 -3
- package/src/sources/SvmHyperSyncClient.res.mjs +2 -2
- package/src/sources/SvmHyperSyncSource.res +10 -5
- package/src/sources/SvmHyperSyncSource.res.mjs +5 -4
- package/src/IndexingAddresses.res +0 -151
- package/src/IndexingAddresses.res.mjs +0 -130
- package/src/IndexingAddresses.resi +0 -39
package/src/FetchState.res.mjs
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
169
|
-
|
|
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:
|
|
193
|
-
selection:
|
|
194
|
-
|
|
195
|
-
mergeBlock:
|
|
196
|
-
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:
|
|
199
|
-
prevSourceRangeCapacity:
|
|
200
|
-
eventDensity:
|
|
201
|
-
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
|
-
|
|
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.
|
|
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
|
|
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
|
-
|
|
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
|
|
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 =
|
|
774
|
-
let
|
|
775
|
-
if (
|
|
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
|
-
|
|
778
|
-
}
|
|
779
|
-
if (clientFilteredNames.length === contractNames.length) {
|
|
729
|
+
} else if (Utils.$$Array.isEmpty(serverSideNames)) {
|
|
780
730
|
absorbedPartitions.push(p);
|
|
781
|
-
|
|
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
|
-
|
|
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 <
|
|
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
|
-
|
|
875
|
-
mergeBlock:
|
|
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
|
-
|
|
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
|
|
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(
|
|
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
|
|
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
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
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
|
-
|
|
872
|
+
joining = false;
|
|
943
873
|
}
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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,
|
|
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
|
|
1065
|
-
let
|
|
1066
|
-
let
|
|
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
|
|
1070
|
-
let dcs = item.dcs;
|
|
960
|
+
let dcs = items[itemIdx].dcs;
|
|
1071
961
|
if (dcs !== undefined) {
|
|
1072
|
-
let
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
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
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
let
|
|
1127
|
-
if (
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
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
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
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
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
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$
|
|
1173
|
-
let contractName =
|
|
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$
|
|
1177
|
-
let p = mutExistingPartitions[idx$
|
|
1178
|
-
let
|
|
1179
|
-
if (
|
|
1180
|
-
let allPartitionContractNames =
|
|
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
|
|
1186
|
-
|
|
1187
|
-
|
|
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
|
-
|
|
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$
|
|
1075
|
+
mutExistingPartitions[idx$3] = {
|
|
1218
1076
|
id: p.id,
|
|
1219
1077
|
latestFetchedBlock: p.latestFetchedBlock,
|
|
1220
1078
|
selection: p.selection,
|
|
1221
|
-
|
|
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 =
|
|
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
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
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,
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
1700
|
-
let addressCount =
|
|
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 =
|
|
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,
|
|
1777
|
-
|
|
1628
|
+
function rollback(fetchState, addressStore, targetBlockNumber) {
|
|
1629
|
+
addressStore.rollback(targetBlockNumber);
|
|
1778
1630
|
let keptPartitions = [];
|
|
1779
1631
|
let nextKeptIdRef = 0;
|
|
1780
|
-
let
|
|
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
|
-
|
|
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
|
|
1800
|
-
|
|
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:
|
|
1813
|
-
selection:
|
|
1814
|
-
|
|
1656
|
+
latestFetchedBlock: init.latestFetchedBlock,
|
|
1657
|
+
selection: init.selection,
|
|
1658
|
+
addresses: init.addresses,
|
|
1815
1659
|
mergeBlock: mergeBlock$1,
|
|
1816
|
-
dynamicContract:
|
|
1660
|
+
dynamicContract: init.dynamicContract,
|
|
1817
1661
|
mutPendingQueries: rollbackPendingQueries(p.mutPendingQueries, targetBlockNumber),
|
|
1818
|
-
sourceRangeCapacity:
|
|
1819
|
-
prevSourceRangeCapacity:
|
|
1820
|
-
eventDensity:
|
|
1821
|
-
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
/*
|
|
1924
|
+
/* Env Not a pure module */
|