envio 3.0.0-alpha.13 → 3.0.0-alpha.15
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/README.md +1 -1
- package/evm.schema.json +11 -19
- package/fuel.schema.json +18 -0
- package/index.d.ts +39 -1
- package/package.json +25 -23
- package/src/Batch.res +2 -1
- package/src/Batch.res.mjs +1 -1
- package/src/ChainFetcher.res +6 -8
- package/src/ChainFetcher.res.mjs +4 -5
- package/src/ChainManager.res +1 -0
- package/src/ChainManager.res.mjs +2 -1
- package/src/Config.gen.ts +19 -0
- package/src/Config.res +264 -3
- package/src/Config.res.mjs +279 -7
- package/src/Ctx.res +1 -1
- package/src/Env.res +0 -1
- package/src/Env.res.mjs +0 -3
- package/src/Envio.gen.ts +0 -6
- package/src/Envio.res +13 -5
- package/src/EvmTypes.gen.ts +6 -0
- package/src/EvmTypes.res +1 -0
- package/src/FetchState.res +123 -71
- package/src/FetchState.res.mjs +151 -111
- package/src/GlobalState.res +23 -7
- package/src/GlobalState.res.mjs +43 -20
- package/src/HandlerLoader.res +2 -2
- package/src/HandlerLoader.res.mjs +3 -3
- package/src/HandlerRegister.res +319 -0
- package/src/HandlerRegister.res.mjs +299 -0
- package/src/{EventRegister.resi → HandlerRegister.resi} +9 -10
- package/src/Hasura.res +3 -3
- package/src/Hasura.res.mjs +3 -3
- package/src/InMemoryStore.res +1 -1
- package/src/InMemoryStore.res.mjs +3 -3
- package/src/Internal.gen.ts +4 -0
- package/src/Internal.res +3 -1
- package/src/Main.res +15 -2
- package/src/Main.res.mjs +18 -3
- package/src/Persistence.res +2 -2
- package/src/Persistence.res.mjs +3 -3
- package/src/Prometheus.res +13 -3
- package/src/Prometheus.res.mjs +13 -3
- package/src/TestIndexer.res +91 -4
- package/src/TestIndexer.res.mjs +78 -5
- package/src/UserContext.res +118 -61
- package/src/UserContext.res.mjs +70 -27
- package/src/Utils.res +16 -3
- package/src/Utils.res.mjs +17 -2
- package/src/bindings/EventSource.res +8 -1
- package/src/bindings/EventSource.res.mjs +8 -1
- package/src/bindings/Vitest.res +15 -7
- package/src/db/InternalTable.res +2 -65
- package/src/db/InternalTable.res.mjs +28 -79
- package/src/sources/HyperFuelSource.res +2 -2
- package/src/sources/HyperFuelSource.res.mjs +2 -2
- package/src/sources/HyperSync.res +1 -1
- package/src/sources/HyperSync.res.mjs +1 -1
- package/src/sources/HyperSyncClient.res +1 -1
- package/src/sources/HyperSyncHeightStream.res +18 -7
- package/src/sources/HyperSyncHeightStream.res.mjs +15 -11
- package/src/sources/HyperSyncSource.res +4 -12
- package/src/sources/HyperSyncSource.res.mjs +5 -12
- package/src/sources/Rpc.res +66 -67
- package/src/sources/Rpc.res.mjs +79 -54
- package/src/sources/RpcSource.res +269 -176
- package/src/sources/RpcSource.res.mjs +501 -281
- package/src/sources/RpcWebSocketHeightStream.res +23 -4
- package/src/sources/RpcWebSocketHeightStream.res.mjs +38 -11
- package/src/sources/Svm.res +2 -2
- package/src/sources/Svm.res.mjs +2 -2
- package/src/tui/Tui.res +17 -35
- package/src/tui/Tui.res.mjs +28 -32
- package/src/tui/bindings/Ink.res +0 -5
- package/src/tui/bindings/Ink.res.mjs +0 -3
- package/svm.schema.json +112 -0
- package/src/EventRegister.res +0 -241
- package/src/EventRegister.res.mjs +0 -240
- package/src/bindings/Ethers.res +0 -183
- package/src/bindings/Ethers.res.mjs +0 -92
- package/src/bindings/RescriptMocha.res +0 -123
- package/src/bindings/RescriptMocha.res.mjs +0 -18
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ HyperIndex is a fast, developer-friendly multichain indexer, optimized for both
|
|
|
12
12
|
## Key Features
|
|
13
13
|
|
|
14
14
|
- **[Indexer auto-generation](https://docs.envio.dev/docs/HyperIndex/contract-import)** – Generate Indexers directly from smart contract addresses
|
|
15
|
-
- **High performance** – Historical backfills at over
|
|
15
|
+
- **High performance** – Historical backfills at over 25,000+ events per second ([fastest in market](https://docs.envio.dev/blog/indexer-benchmarking-results))
|
|
16
16
|
- **Local development** – Full-featured local environment with Docker
|
|
17
17
|
- **[Multichain indexing](https://docs.envio.dev/docs/HyperIndex/multichain-indexing)** – Index any EVM-, SVM-, or Fuel-compatible blockchain
|
|
18
18
|
- **Real-time indexing** – Instantly track blockchain events
|
package/evm.schema.json
CHANGED
|
@@ -73,17 +73,6 @@
|
|
|
73
73
|
"$ref": "#/$defs/Chain"
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
-
"multichain": {
|
|
77
|
-
"description": "Multichain mode: 'ordered' processes events across chains in order, 'unordered' processes chain events in order, but non-deterministically relatively to other chains (default: unordered)",
|
|
78
|
-
"anyOf": [
|
|
79
|
-
{
|
|
80
|
-
"$ref": "#/$defs/Multichain"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"type": "null"
|
|
84
|
-
}
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
76
|
"rollback_on_reorg": {
|
|
88
77
|
"description": "A flag to indicate if the indexer should rollback to the last known valid block on a reorg. This currently incurs a performance hit on historical sync and is recommended to turn this off while developing (default: true)",
|
|
89
78
|
"type": [
|
|
@@ -335,7 +324,17 @@
|
|
|
335
324
|
"integer",
|
|
336
325
|
"null"
|
|
337
326
|
],
|
|
338
|
-
"format": "
|
|
327
|
+
"format": "uint32",
|
|
328
|
+
"minimum": 0
|
|
329
|
+
},
|
|
330
|
+
"block_lag": {
|
|
331
|
+
"description": "The number of blocks behind the chain head that the indexer should lag. Useful for avoiding reorg issues by indexing slightly behind the tip.",
|
|
332
|
+
"type": [
|
|
333
|
+
"integer",
|
|
334
|
+
"null"
|
|
335
|
+
],
|
|
336
|
+
"format": "uint32",
|
|
337
|
+
"minimum": 0
|
|
339
338
|
},
|
|
340
339
|
"start_block": {
|
|
341
340
|
"description": "The block at which the indexer should start ingesting data",
|
|
@@ -597,13 +596,6 @@
|
|
|
597
596
|
}
|
|
598
597
|
]
|
|
599
598
|
},
|
|
600
|
-
"Multichain": {
|
|
601
|
-
"type": "string",
|
|
602
|
-
"enum": [
|
|
603
|
-
"ordered",
|
|
604
|
-
"unordered"
|
|
605
|
-
]
|
|
606
|
-
},
|
|
607
599
|
"AddressFormat": {
|
|
608
600
|
"type": "string",
|
|
609
601
|
"enum": [
|
package/fuel.schema.json
CHANGED
|
@@ -196,6 +196,24 @@
|
|
|
196
196
|
}
|
|
197
197
|
]
|
|
198
198
|
},
|
|
199
|
+
"max_reorg_depth": {
|
|
200
|
+
"description": "The number of blocks from the head that the indexer should account for in case of reorgs.",
|
|
201
|
+
"type": [
|
|
202
|
+
"integer",
|
|
203
|
+
"null"
|
|
204
|
+
],
|
|
205
|
+
"format": "uint32",
|
|
206
|
+
"minimum": 0
|
|
207
|
+
},
|
|
208
|
+
"block_lag": {
|
|
209
|
+
"description": "The number of blocks behind the chain head that the indexer should lag. Useful for avoiding reorg issues by indexing slightly behind the tip.",
|
|
210
|
+
"type": [
|
|
211
|
+
"integer",
|
|
212
|
+
"null"
|
|
213
|
+
],
|
|
214
|
+
"format": "uint32",
|
|
215
|
+
"minimum": 0
|
|
216
|
+
},
|
|
199
217
|
"contracts": {
|
|
200
218
|
"description": "All the contracts that should be indexed on the given chain",
|
|
201
219
|
"type": [
|
package/index.d.ts
CHANGED
|
@@ -18,6 +18,36 @@ export type { EffectCaller, Address } from "./src/Types.ts";
|
|
|
18
18
|
/** Utility type to expand/flatten complex types for better IDE display. */
|
|
19
19
|
export type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Operator for filtering entity fields in getWhere queries.
|
|
23
|
+
* Only fields with `@index` in the schema can be queried at runtime.
|
|
24
|
+
*/
|
|
25
|
+
export type WhereOperator<T> = {
|
|
26
|
+
/** Matches entities where the field equals the given value. */
|
|
27
|
+
readonly _eq?: T;
|
|
28
|
+
/** Matches entities where the field is greater than the given value. */
|
|
29
|
+
readonly _gt?: T;
|
|
30
|
+
/** Matches entities where the field is less than the given value. */
|
|
31
|
+
readonly _lt?: T;
|
|
32
|
+
/** Matches entities where the field is greater than or equal to the given value. */
|
|
33
|
+
readonly _gte?: T;
|
|
34
|
+
/** Matches entities where the field is less than or equal to the given value. */
|
|
35
|
+
readonly _lte?: T;
|
|
36
|
+
/** Matches entities where the field equals any of the given values. */
|
|
37
|
+
readonly _in?: readonly T[];
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Constructs a getWhere filter type from an entity type.
|
|
42
|
+
* Each field can be filtered using {@link WhereOperator} (`_eq`, `_gt`, `_lt`, `_gte`, `_lte`, `_in`).
|
|
43
|
+
*
|
|
44
|
+
* Note: only fields with `@index` in the schema can be queried at runtime.
|
|
45
|
+
* Attempting to filter on a non-indexed field will throw a descriptive error.
|
|
46
|
+
*/
|
|
47
|
+
export type GetWhereFilter<E> = {
|
|
48
|
+
[K in keyof E]?: WhereOperator<E[K]>;
|
|
49
|
+
};
|
|
50
|
+
|
|
21
51
|
import type {
|
|
22
52
|
effect as Effect,
|
|
23
53
|
effectArgs as EffectArgs,
|
|
@@ -234,6 +264,8 @@ type EvmChainConfig<Id extends number = number> = {
|
|
|
234
264
|
readonly endBlock?: number;
|
|
235
265
|
/** Number of blocks to keep for reorg handling (default: 200). */
|
|
236
266
|
readonly maxReorgDepth?: number;
|
|
267
|
+
/** Number of blocks behind the chain head to lag (default: 0). */
|
|
268
|
+
readonly blockLag?: number;
|
|
237
269
|
};
|
|
238
270
|
|
|
239
271
|
/** EVM chain value (for runtime Indexer). */
|
|
@@ -287,6 +319,8 @@ type FuelChainConfig<Id extends number = number> = {
|
|
|
287
319
|
readonly endBlock?: number;
|
|
288
320
|
/** Number of blocks to keep for reorg handling (default: 200). */
|
|
289
321
|
readonly maxReorgDepth?: number;
|
|
322
|
+
/** Number of blocks behind the chain head to lag (default: 0). */
|
|
323
|
+
readonly blockLag?: number;
|
|
290
324
|
};
|
|
291
325
|
|
|
292
326
|
/** Fuel chain value (for runtime Indexer). */
|
|
@@ -320,6 +354,8 @@ type SvmChainConfig<Id extends number = number> = {
|
|
|
320
354
|
readonly endBlock?: number;
|
|
321
355
|
/** Number of blocks to keep for reorg handling (default: 200). */
|
|
322
356
|
readonly maxReorgDepth?: number;
|
|
357
|
+
/** Number of blocks behind the chain head to lag (default: 0). */
|
|
358
|
+
readonly blockLag?: number;
|
|
323
359
|
};
|
|
324
360
|
|
|
325
361
|
/** SVM chain value (for runtime Indexer). */
|
|
@@ -589,7 +625,9 @@ export type TestIndexerFromConfig<Config extends IndexerConfigTypes> = {
|
|
|
589
625
|
/** Changes happened during the processing. */
|
|
590
626
|
readonly changes: readonly EntityChange<Config>[];
|
|
591
627
|
}>;
|
|
592
|
-
} &
|
|
628
|
+
} & (EcosystemCount<Config> extends 1
|
|
629
|
+
? SingleEcosystemChains<Config>
|
|
630
|
+
: MultiEcosystemChains<Config>) & {
|
|
593
631
|
/** Entity operations for direct manipulation outside of handlers. */
|
|
594
632
|
readonly [K in keyof ConfigEntities<Config>]: EntityOps<
|
|
595
633
|
ConfigEntities<Config>[K]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envio",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
|
|
6
6
|
"bin": "./bin.js",
|
|
@@ -10,30 +10,35 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/enviodev/hyperindex.git"
|
|
12
12
|
},
|
|
13
|
+
"author": "envio contributors <about@envio.dev>",
|
|
14
|
+
"license": "GPL-3.0",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/enviodev/hyperindex/issues"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://envio.dev",
|
|
13
19
|
"keywords": [
|
|
14
20
|
"blockchain",
|
|
15
21
|
"indexer",
|
|
16
22
|
"ethereum",
|
|
17
23
|
"evm",
|
|
18
24
|
"fuel",
|
|
25
|
+
"solana",
|
|
19
26
|
"data",
|
|
20
27
|
"dapp"
|
|
21
28
|
],
|
|
22
|
-
"author": "envio contributors <about@envio.dev>",
|
|
23
|
-
"license": "GPL-3.0",
|
|
24
|
-
"bugs": {
|
|
25
|
-
"url": "https://github.com/enviodev/hyperindex/issues"
|
|
26
|
-
},
|
|
27
|
-
"homepage": "https://envio.dev",
|
|
28
29
|
"engines": {
|
|
29
30
|
"node": ">=22.0.0"
|
|
30
31
|
},
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
32
|
+
"files": [
|
|
33
|
+
"bin.js",
|
|
34
|
+
"evm.schema.json",
|
|
35
|
+
"fuel.schema.json",
|
|
36
|
+
"svm.schema.json",
|
|
37
|
+
"rescript.json",
|
|
38
|
+
"index.d.ts",
|
|
39
|
+
"index.js",
|
|
40
|
+
"src"
|
|
41
|
+
],
|
|
37
42
|
"dependencies": {
|
|
38
43
|
"@clickhouse/client": "1.12.1",
|
|
39
44
|
"@elastic/ecs-pino-format": "1.4.0",
|
|
@@ -59,13 +64,10 @@
|
|
|
59
64
|
"postgres": "3.4.8",
|
|
60
65
|
"tsx": "4.21.0"
|
|
61
66
|
},
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"src"
|
|
70
|
-
]
|
|
71
|
-
}
|
|
67
|
+
"optionalDependencies": {
|
|
68
|
+
"envio-linux-x64": "3.0.0-alpha.15",
|
|
69
|
+
"envio-linux-arm64": "3.0.0-alpha.15",
|
|
70
|
+
"envio-darwin-x64": "3.0.0-alpha.15",
|
|
71
|
+
"envio-darwin-arm64": "3.0.0-alpha.15"
|
|
72
|
+
}
|
|
73
|
+
}
|
package/src/Batch.res
CHANGED
|
@@ -18,6 +18,7 @@ type chainBeforeBatch = {
|
|
|
18
18
|
progressBlockNumber: int,
|
|
19
19
|
sourceBlockNumber: int,
|
|
20
20
|
totalEventsProcessed: int,
|
|
21
|
+
chainConfig: Config.chain,
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
type t = {
|
|
@@ -113,7 +114,7 @@ let getProgressedChainsById = {
|
|
|
113
114
|
totalEventsProcessed: chainBeforeBatch.totalEventsProcessed + batchSize,
|
|
114
115
|
fetchState: fetchStateAfterBatch,
|
|
115
116
|
isProgressAtHeadWhenBatchCreated: progressBlockNumberAfterBatch >=
|
|
116
|
-
chainBeforeBatch.sourceBlockNumber,
|
|
117
|
+
chainBeforeBatch.sourceBlockNumber - chainBeforeBatch.chainConfig.blockLag,
|
|
117
118
|
}: chainAfterBatch
|
|
118
119
|
),
|
|
119
120
|
)
|
package/src/Batch.res.mjs
CHANGED
|
@@ -65,7 +65,7 @@ function getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAft
|
|
|
65
65
|
sourceBlockNumber: chainBeforeBatch.sourceBlockNumber,
|
|
66
66
|
totalEventsProcessed: chainBeforeBatch.totalEventsProcessed + batchSize,
|
|
67
67
|
fetchState: fetchStateAfterBatch,
|
|
68
|
-
isProgressAtHeadWhenBatchCreated: progressBlockNumberAfterBatch >= chainBeforeBatch.sourceBlockNumber
|
|
68
|
+
isProgressAtHeadWhenBatchCreated: progressBlockNumberAfterBatch >= chainBeforeBatch.sourceBlockNumber - chainBeforeBatch.chainConfig.blockLag
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
|
package/src/ChainFetcher.res
CHANGED
|
@@ -15,7 +15,6 @@ type t = {
|
|
|
15
15
|
isProgressAtHead: bool,
|
|
16
16
|
timestampCaughtUpToHeadOrEndblock: option<Js.Date.t>,
|
|
17
17
|
committedProgressBlockNumber: int,
|
|
18
|
-
firstEventBlockNumber: option<int>,
|
|
19
18
|
numEventsProcessed: int,
|
|
20
19
|
numBatchesFetched: int,
|
|
21
20
|
reorgDetection: ReorgDetection.t,
|
|
@@ -28,10 +27,10 @@ let make = (
|
|
|
28
27
|
~dynamicContracts: array<Internal.indexingContract>,
|
|
29
28
|
~startBlock,
|
|
30
29
|
~endBlock,
|
|
31
|
-
~
|
|
30
|
+
~firstEventBlock=None,
|
|
32
31
|
~progressBlockNumber,
|
|
33
32
|
~config: Config.t,
|
|
34
|
-
~registrations:
|
|
33
|
+
~registrations: HandlerRegister.registrations,
|
|
35
34
|
~targetBufferSize,
|
|
36
35
|
~logger,
|
|
37
36
|
~timestampCaughtUpToHeadOrEndblock,
|
|
@@ -149,7 +148,7 @@ let make = (
|
|
|
149
148
|
registrations.onBlockByChainId->Utils.Dict.dangerouslyGetNonOption(chainConfig.id->Int.toString)
|
|
150
149
|
switch onBlockConfigs {
|
|
151
150
|
| Some(onBlockConfigs) =>
|
|
152
|
-
// TODO: Move it to the
|
|
151
|
+
// TODO: Move it to the HandlerRegister module
|
|
153
152
|
// so the error is thrown with better stack trace
|
|
154
153
|
onBlockConfigs->Array.forEach(onBlockConfig => {
|
|
155
154
|
if onBlockConfig.startBlock->Option.getWithDefault(startBlock) < startBlock {
|
|
@@ -183,9 +182,10 @@ let make = (
|
|
|
183
182
|
// FIXME: Shouldn't set with full history
|
|
184
183
|
~blockLag=Pervasives.max(
|
|
185
184
|
!config.shouldRollbackOnReorg || isInReorgThreshold ? 0 : chainConfig.maxReorgDepth,
|
|
186
|
-
|
|
185
|
+
chainConfig.blockLag,
|
|
187
186
|
),
|
|
188
187
|
~onBlockConfigs?,
|
|
188
|
+
~firstEventBlock,
|
|
189
189
|
)
|
|
190
190
|
|
|
191
191
|
let chainReorgCheckpoints = reorgCheckpoints->Array.keepMapU(reorgCheckpoint => {
|
|
@@ -258,7 +258,6 @@ let make = (
|
|
|
258
258
|
),
|
|
259
259
|
isProgressAtHead: false,
|
|
260
260
|
fetchState,
|
|
261
|
-
firstEventBlockNumber,
|
|
262
261
|
committedProgressBlockNumber: progressBlockNumber,
|
|
263
262
|
timestampCaughtUpToHeadOrEndblock,
|
|
264
263
|
numEventsProcessed,
|
|
@@ -283,7 +282,6 @@ let makeFromConfig = (
|
|
|
283
282
|
~endBlock=chainConfig.endBlock,
|
|
284
283
|
~reorgCheckpoints=[],
|
|
285
284
|
~maxReorgDepth=chainConfig.maxReorgDepth,
|
|
286
|
-
~firstEventBlockNumber=None,
|
|
287
285
|
~progressBlockNumber=-1,
|
|
288
286
|
~timestampCaughtUpToHeadOrEndblock=None,
|
|
289
287
|
~numEventsProcessed=0,
|
|
@@ -328,7 +326,7 @@ let makeFromDbState = async (
|
|
|
328
326
|
~registrations,
|
|
329
327
|
~reorgCheckpoints,
|
|
330
328
|
~maxReorgDepth=resumedChainState.maxReorgDepth,
|
|
331
|
-
~
|
|
329
|
+
~firstEventBlock=resumedChainState.firstEventBlockNumber,
|
|
332
330
|
~progressBlockNumber,
|
|
333
331
|
~timestampCaughtUpToHeadOrEndblock=Env.updateSyncTimeOnRestart
|
|
334
332
|
? None
|
package/src/ChainFetcher.res.mjs
CHANGED
|
@@ -23,7 +23,8 @@ import * as HyperFuelSource from "./sources/HyperFuelSource.res.mjs";
|
|
|
23
23
|
import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
|
|
24
24
|
import * as SafeCheckpointTracking from "./SafeCheckpointTracking.res.mjs";
|
|
25
25
|
|
|
26
|
-
function make(chainConfig, dynamicContracts, startBlock, endBlock,
|
|
26
|
+
function make(chainConfig, dynamicContracts, startBlock, endBlock, firstEventBlockOpt, progressBlockNumber, config, registrations, targetBufferSize, logger, timestampCaughtUpToHeadOrEndblock, numEventsProcessed, numBatchesFetched, isInReorgThreshold, reorgCheckpoints, maxReorgDepth, knownHeightOpt) {
|
|
27
|
+
var firstEventBlock = firstEventBlockOpt !== undefined ? Caml_option.valFromOption(firstEventBlockOpt) : undefined;
|
|
27
28
|
var knownHeight = knownHeightOpt !== undefined ? knownHeightOpt : 0;
|
|
28
29
|
var eventRouter = EventRouter.empty();
|
|
29
30
|
var contracts = [];
|
|
@@ -99,7 +100,7 @@ function make(chainConfig, dynamicContracts, startBlock, endBlock, firstEventBlo
|
|
|
99
100
|
|
|
100
101
|
}));
|
|
101
102
|
}
|
|
102
|
-
var fetchState = FetchState.make(startBlock, endBlock, eventConfigs, contracts, config.maxAddrInPartition, chainConfig.id, targetBufferSize, knownHeight, progressBlockNumber, onBlockConfigs, Caml.int_max(!config.shouldRollbackOnReorg || isInReorgThreshold ? 0 : chainConfig.maxReorgDepth,
|
|
103
|
+
var fetchState = FetchState.make(startBlock, endBlock, eventConfigs, contracts, config.maxAddrInPartition, chainConfig.id, targetBufferSize, knownHeight, progressBlockNumber, onBlockConfigs, Caml.int_max(!config.shouldRollbackOnReorg || isInReorgThreshold ? 0 : chainConfig.maxReorgDepth, chainConfig.blockLag), Caml_option.some(firstEventBlock));
|
|
103
104
|
var chainReorgCheckpoints = Belt_Array.keepMapU(reorgCheckpoints, (function (reorgCheckpoint) {
|
|
104
105
|
if (reorgCheckpoint.chain_id === chainConfig.id) {
|
|
105
106
|
return reorgCheckpoint;
|
|
@@ -156,7 +157,6 @@ function make(chainConfig, dynamicContracts, startBlock, endBlock, firstEventBlo
|
|
|
156
157
|
isProgressAtHead: false,
|
|
157
158
|
timestampCaughtUpToHeadOrEndblock: timestampCaughtUpToHeadOrEndblock,
|
|
158
159
|
committedProgressBlockNumber: progressBlockNumber,
|
|
159
|
-
firstEventBlockNumber: firstEventBlockNumber,
|
|
160
160
|
numEventsProcessed: numEventsProcessed,
|
|
161
161
|
numBatchesFetched: numBatchesFetched,
|
|
162
162
|
reorgDetection: ReorgDetection.make(chainReorgCheckpoints, maxReorgDepth, config.shouldRollbackOnReorg),
|
|
@@ -178,7 +178,7 @@ async function makeFromDbState(chainConfig, resumedChainState, reorgCheckpoints,
|
|
|
178
178
|
});
|
|
179
179
|
Prometheus.ProgressEventsCount.set(resumedChainState.numEventsProcessed, chainId);
|
|
180
180
|
var progressBlockNumber = resumedChainState.progressBlockNumber >= 0 ? resumedChainState.progressBlockNumber : resumedChainState.startBlock - 1 | 0;
|
|
181
|
-
return make(chainConfig, resumedChainState.dynamicContracts, resumedChainState.startBlock, resumedChainState.endBlock, resumedChainState.firstEventBlockNumber, progressBlockNumber, config, registrations, targetBufferSize, logger, Env.updateSyncTimeOnRestart ? undefined : resumedChainState.timestampCaughtUpToHeadOrEndblock, resumedChainState.numEventsProcessed, 0, isInReorgThreshold, reorgCheckpoints, resumedChainState.maxReorgDepth, resumedChainState.sourceBlockNumber);
|
|
181
|
+
return make(chainConfig, resumedChainState.dynamicContracts, resumedChainState.startBlock, resumedChainState.endBlock, Caml_option.some(resumedChainState.firstEventBlockNumber), progressBlockNumber, config, registrations, targetBufferSize, logger, Env.updateSyncTimeOnRestart ? undefined : resumedChainState.timestampCaughtUpToHeadOrEndblock, resumedChainState.numEventsProcessed, 0, isInReorgThreshold, reorgCheckpoints, resumedChainState.maxReorgDepth, resumedChainState.sourceBlockNumber);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
function getContractStartBlock(config, chain, contractName) {
|
|
@@ -263,7 +263,6 @@ function handleQueryResult(chainFetcher, query, newItems, newItemsWithDcs, lates
|
|
|
263
263
|
isProgressAtHead: chainFetcher.isProgressAtHead,
|
|
264
264
|
timestampCaughtUpToHeadOrEndblock: chainFetcher.timestampCaughtUpToHeadOrEndblock,
|
|
265
265
|
committedProgressBlockNumber: chainFetcher.committedProgressBlockNumber,
|
|
266
|
-
firstEventBlockNumber: chainFetcher.firstEventBlockNumber,
|
|
267
266
|
numEventsProcessed: chainFetcher.numEventsProcessed,
|
|
268
267
|
numBatchesFetched: chainFetcher.numBatchesFetched,
|
|
269
268
|
reorgDetection: chainFetcher.reorgDetection,
|
package/src/ChainManager.res
CHANGED
|
@@ -125,6 +125,7 @@ let createBatch = (chainManager: t, ~batchSizeTarget: int, ~isRollback: bool): B
|
|
|
125
125
|
totalEventsProcessed: cf.numEventsProcessed,
|
|
126
126
|
sourceBlockNumber: cf.fetchState.knownHeight,
|
|
127
127
|
reorgDetection: cf.reorgDetection,
|
|
128
|
+
chainConfig: cf.chainConfig,
|
|
128
129
|
}),
|
|
129
130
|
~multichain=chainManager.multichain,
|
|
130
131
|
~batchSizeTarget,
|
package/src/ChainManager.res.mjs
CHANGED
|
@@ -93,7 +93,8 @@ function createBatch(chainManager, batchSizeTarget, isRollback) {
|
|
|
93
93
|
reorgDetection: cf.reorgDetection,
|
|
94
94
|
progressBlockNumber: cf.committedProgressBlockNumber,
|
|
95
95
|
sourceBlockNumber: cf.fetchState.knownHeight,
|
|
96
|
-
totalEventsProcessed: cf.numEventsProcessed
|
|
96
|
+
totalEventsProcessed: cf.numEventsProcessed,
|
|
97
|
+
chainConfig: cf.chainConfig
|
|
97
98
|
};
|
|
98
99
|
})), chainManager.multichain, batchSizeTarget);
|
|
99
100
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* TypeScript file generated from Config.res by genType. */
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
/* tslint:disable */
|
|
5
|
+
|
|
6
|
+
import type {t as Address_t} from './Address.gen.js';
|
|
7
|
+
|
|
8
|
+
export type DynamicContractRegistry_t = {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly chain_id: number;
|
|
11
|
+
readonly registering_event_block_number: number;
|
|
12
|
+
readonly registering_event_log_index: number;
|
|
13
|
+
readonly registering_event_block_timestamp: number;
|
|
14
|
+
readonly registering_event_contract_name: string;
|
|
15
|
+
readonly registering_event_name: string;
|
|
16
|
+
readonly registering_event_src_address: Address_t;
|
|
17
|
+
readonly contract_address: Address_t;
|
|
18
|
+
readonly contract_name: string
|
|
19
|
+
};
|