envio 3.15.0-subgraph → 3.16.0-subgraph
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 +40 -34
- package/evm.schema.json +3 -3
- package/fuel.schema.json +2 -2
- package/index.d.ts +3 -3
- package/licenses/README.md +1 -1
- package/package.json +8 -8
- package/src/Batch.res.mjs +5 -5
- package/src/BatchProcessing.res +1 -0
- package/src/BatchProcessing.res.mjs +1 -0
- package/src/ChainFetching.res +1 -6
- package/src/ChainFetching.res.mjs +1 -1
- package/src/ChainState.res +48 -7
- package/src/ChainState.res.mjs +21 -8
- package/src/Clock.res +57 -0
- package/src/Clock.res.mjs +72 -0
- package/src/Config.res +16 -4
- package/src/Config.res.mjs +5 -3
- package/src/Core.res +4 -40
- package/src/CrossChainState.res +10 -6
- package/src/CrossChainState.res.mjs +1 -1
- package/src/EffectState.res +10 -2
- package/src/EffectState.res.mjs +8 -4
- package/src/EffectState.resi +3 -1
- package/src/EntityId.res +2 -7
- package/src/EntityId.res.mjs +1 -8
- package/src/EntityTables.res +4 -1
- package/src/EntityTables.res.mjs +1 -1
- package/src/Env.res +4 -0
- package/src/Env.res.mjs +5 -0
- package/src/FetchState.res +157 -69
- package/src/FetchState.res.mjs +112 -47
- package/src/FinalizeBackfill.res +2 -4
- package/src/FinalizeBackfill.res.mjs +3 -4
- package/src/InMemoryTable.res +17 -16
- package/src/InMemoryTable.res.mjs +14 -15
- package/src/IndexerState.res +28 -4
- package/src/IndexerState.res.mjs +19 -6
- package/src/IndexerState.resi +4 -0
- package/src/Internal.res +0 -49
- package/src/Internal.res.mjs +1 -80
- package/src/LoadLayer.res +17 -10
- package/src/LoadLayer.res.mjs +11 -8
- package/src/Main.res.mjs +1 -1
- package/src/Persistence.res +3 -23
- package/src/Persistence.res.mjs +3 -3
- package/src/PreloadLookahead.res +42 -24
- package/src/PreloadLookahead.res.mjs +51 -30
- package/src/Rollback.res +0 -1
- package/src/Rollback.res.mjs +1 -1
- package/src/SafeCheckpointTracking.res +4 -4
- package/src/SafeCheckpointTracking.res.mjs +1 -1
- package/src/StagedRows.res +106 -0
- package/src/StagedRows.res.mjs +102 -0
- package/src/Staging.res +32 -14
- package/src/Staging.res.mjs +17 -20
- package/src/Storage.res +278 -973
- package/src/Storage.res.mjs +218 -720
- package/src/Supervisor.res +75 -56
- package/src/Supervisor.res.mjs +55 -26
- package/src/SyncWrites.res +24 -18
- package/src/SyncWrites.res.mjs +11 -11
- package/src/TestIndexer.res +22 -27
- package/src/TestIndexer.res.mjs +20 -17
- package/src/Throttler.res +15 -8
- package/src/Throttler.res.mjs +9 -6
- package/src/Throttler.resi +1 -1
- package/src/UserContext.res +13 -4
- package/src/UserContext.res.mjs +5 -5
- package/src/Utils.res +0 -6
- package/src/Utils.res.mjs +0 -5
- package/src/Writing.res +0 -1
- package/src/Writing.res.mjs +1 -1
- package/src/bindings/ClickHouse.res +0 -322
- package/src/bindings/ClickHouse.res.mjs +0 -338
- package/src/bindings/StorageClient.res +107 -174
- package/src/bindings/StorageClient.res.mjs +19 -8
- package/src/bindings/Vitest.res +0 -26
- package/src/bindings/Vitest.res.mjs +0 -3
- package/src/db/Table.res +24 -150
- package/src/db/Table.res.mjs +38 -272
- package/src/sources/ChainSources.res +2 -0
- package/src/sources/ChainSources.res.mjs +2 -2
- package/src/sources/EvmChain.res +3 -0
- package/src/sources/EvmChain.res.mjs +4 -2
- package/src/sources/EvmHyperSyncSource.res +2 -2
- package/src/sources/EvmHyperSyncSource.res.mjs +1 -1
- package/src/sources/EvmRpcClient.res +13 -3
- package/src/sources/EvmRpcClient.res.mjs +4 -3
- package/src/sources/EvmRpcWs.res +4 -3
- package/src/sources/EvmRpcWs.res.mjs +2 -2
- package/src/sources/HeightFeed.res +31 -10
- package/src/sources/HeightFeed.res.mjs +10 -6
- package/src/sources/HeightStream.res +32 -17
- package/src/sources/HeightStream.res.mjs +10 -10
- package/src/sources/HyperSyncSSE.res +4 -6
- package/src/sources/HyperSyncSSE.res.mjs +2 -2
- package/src/sources/RpcSource.res +10 -1
- package/src/sources/RpcSource.res.mjs +4 -3
- package/src/sources/Source.res +3 -0
- package/src/sources/SourceManager.res +85 -104
- package/src/sources/SourceManager.res.mjs +18 -37
- package/src/sources/SourceManager.resi +3 -5
- package/src/sources/StartBlockResolver.res +1 -0
- package/src/sources/StartBlockResolver.res.mjs +4 -3
- package/src/sources/SvmHyperSyncSource.res +2 -2
- package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
- package/src/subgraph/graph-ts.ts +87 -28
- package/src/subgraph/runtime.ts +0 -1
- package/src/subgraph/scope.ts +0 -1
- package/svm.schema.json +3 -3
- package/src/PgWriting.res +0 -36
- package/src/PgWriting.res.mjs +0 -34
- package/src/db/IndexDefinition.res +0 -47
- package/src/db/IndexDefinition.res.mjs +0 -60
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Rows cross in arenas both ways. A write stages its rows into memory the addon
|
|
2
|
-
// lends (`
|
|
3
|
-
// arena that `lendResult` hands over and `releaseResult` takes
|
|
4
|
-
// writing through a buffer after it has been handed back is
|
|
5
|
-
// prevents — the rules are the ones at the top of
|
|
2
|
+
// lends (`beginChanges`/`beginRows` to `commitStage`); a read lands its rows in
|
|
3
|
+
// a Rust-owned arena that `lendResult` hands over and `releaseResult` takes
|
|
4
|
+
// back. Reading or writing through a buffer after it has been handed back is
|
|
5
|
+
// what detaching prevents — the rules are the ones at the top of
|
|
6
6
|
// `packages/cli/src/columnar/mod.rs`.
|
|
7
7
|
|
|
8
8
|
type t
|
|
@@ -19,6 +19,9 @@ type postgresOptions = {
|
|
|
19
19
|
applicationName: string,
|
|
20
20
|
pgSchema: string,
|
|
21
21
|
isHasuraEnabled: bool,
|
|
22
|
+
// An `envio start --chain` process: builds and looks for a per-chain
|
|
23
|
+
// entity's indexes on its own chains' partitions only.
|
|
24
|
+
isolated: bool,
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
type clickHouseOptions = {
|
|
@@ -31,7 +34,6 @@ type clickHouseOptions = {
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
type options = {
|
|
34
|
-
chainIdMode: string,
|
|
35
37
|
postgres: postgresOptions,
|
|
36
38
|
clickhouse?: clickHouseOptions,
|
|
37
39
|
}
|
|
@@ -45,71 +47,31 @@ type queryResult = {
|
|
|
45
47
|
rows: int,
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
// read schemas parse every store's rows by.
|
|
50
|
-
type clickHouseColumn = {
|
|
51
|
-
name: string,
|
|
52
|
-
rowName?: string,
|
|
53
|
-
// The schema field, which `@storage(clickhouse: {...})` expressions name a
|
|
54
|
-
// column by even when a rename is configured.
|
|
55
|
-
fieldName?: string,
|
|
56
|
-
fieldType: string,
|
|
57
|
-
isNullable: bool,
|
|
58
|
-
isArray: bool,
|
|
59
|
-
precision?: int,
|
|
60
|
-
scale?: int,
|
|
61
|
-
enumVariants?: array<string>,
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
type skippingIndex = {
|
|
65
|
-
name: string,
|
|
66
|
-
expr: string,
|
|
67
|
-
indexType: string,
|
|
68
|
-
granularity?: int,
|
|
69
|
-
}
|
|
50
|
+
type store = Postgres | ClickHouse
|
|
70
51
|
|
|
71
|
-
type
|
|
72
|
-
name: string,
|
|
73
|
-
historyTable: string,
|
|
74
|
-
columns: array<clickHouseColumn>,
|
|
75
|
-
chainIdColumn?: string,
|
|
76
|
-
partitionBy?: string,
|
|
77
|
-
orderBy?: array<string>,
|
|
78
|
-
ttl?: string,
|
|
79
|
-
skippingIndexes?: array<skippingIndex>,
|
|
80
|
-
}
|
|
52
|
+
type stagedField = Staging.stagedField
|
|
81
53
|
|
|
82
|
-
|
|
83
|
-
// schema names, the indexer's own tables for Postgres alone.
|
|
84
|
-
type tableInput = {
|
|
54
|
+
type entityLayout = {
|
|
85
55
|
name: string,
|
|
86
|
-
|
|
87
|
-
|
|
56
|
+
// The store the entity is read from; none when no configured store keeps it.
|
|
57
|
+
home?: store,
|
|
58
|
+
fields: array<stagedField>,
|
|
88
59
|
}
|
|
89
60
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
type
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
61
|
+
// How every batch is laid out: an entity's change set is its fields, then each
|
|
62
|
+
// change's checkpoint and whether it deletes.
|
|
63
|
+
type layouts = {
|
|
64
|
+
// By entity index.
|
|
65
|
+
entities: array<entityLayout>,
|
|
66
|
+
rawEvents: array<stagedField>,
|
|
67
|
+
effectCache: array<stagedField>,
|
|
96
68
|
}
|
|
97
69
|
|
|
98
|
-
type
|
|
99
|
-
|
|
100
|
-
// What each store made of a table: present for the stores that keep it.
|
|
101
|
-
type registeredTable = {
|
|
102
|
-
handle: int,
|
|
103
|
-
// The store the table is read from.
|
|
104
|
-
home: store,
|
|
105
|
-
postgres?: postgresRegistered,
|
|
106
|
-
clickhouse?: clickHouseRegistered,
|
|
107
|
-
}
|
|
70
|
+
type stagedTable = RawEvents | EffectCache
|
|
108
71
|
|
|
109
72
|
type bounds = {
|
|
110
|
-
sequence: CheckpointSequence.t,
|
|
111
73
|
chainIds: array<ChainId.t>,
|
|
112
|
-
checkpointIds: array<
|
|
74
|
+
checkpointIds: array<bigint>,
|
|
113
75
|
}
|
|
114
76
|
|
|
115
77
|
type progress = {
|
|
@@ -146,15 +108,7 @@ type chainConfig = {
|
|
|
146
108
|
maxReorgDepth: int,
|
|
147
109
|
}
|
|
148
110
|
|
|
149
|
-
type partition = {table: int, chainId: ChainId.t, name: string}
|
|
150
|
-
|
|
151
|
-
type enum = {name: string, variants: array<string>}
|
|
152
|
-
|
|
153
111
|
type initialize = {
|
|
154
|
-
sequence: CheckpointSequence.t,
|
|
155
|
-
tables: array<int>,
|
|
156
|
-
partitions: array<partition>,
|
|
157
|
-
enums: array<enum>,
|
|
158
112
|
chains: array<chainConfig>,
|
|
159
113
|
envioInfo: string,
|
|
160
114
|
contractNames: array<string>,
|
|
@@ -164,18 +118,9 @@ type initialize = {
|
|
|
164
118
|
|
|
165
119
|
type addChain = {
|
|
166
120
|
chain: chainConfig,
|
|
167
|
-
partitions: array<partition>,
|
|
168
121
|
addresses: addresses,
|
|
169
122
|
}
|
|
170
123
|
|
|
171
|
-
type resume = {
|
|
172
|
-
sequence: CheckpointSequence.t,
|
|
173
|
-
// Every entity table.
|
|
174
|
-
tables: array<int>,
|
|
175
|
-
// The chains this run drives, which are the only ones trimmed.
|
|
176
|
-
chainIds: array<ChainId.t>,
|
|
177
|
-
}
|
|
178
|
-
|
|
179
124
|
type storedChain = {
|
|
180
125
|
id: float,
|
|
181
126
|
ecosystem: string,
|
|
@@ -204,11 +149,11 @@ type resumedChain = {
|
|
|
204
149
|
// Unix seconds.
|
|
205
150
|
progressBlockTime?: float,
|
|
206
151
|
sourceBlock: int,
|
|
207
|
-
checkpointId:
|
|
152
|
+
checkpointId: bigint,
|
|
208
153
|
}
|
|
209
154
|
|
|
210
155
|
type reorgCheckpoint = {
|
|
211
|
-
id:
|
|
156
|
+
id: bigint,
|
|
212
157
|
chainId: float,
|
|
213
158
|
blockNumber: int,
|
|
214
159
|
blockHash: string,
|
|
@@ -228,57 +173,40 @@ type progressDiff = {
|
|
|
228
173
|
|
|
229
174
|
type rollbackData = {removed: queryResult, restored: queryResult}
|
|
230
175
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// Rows of a batch: staged into an arena, or one rendered parameter per cell,
|
|
237
|
-
// every row's first column first.
|
|
238
|
-
type rows = {
|
|
239
|
-
staged?: int,
|
|
240
|
-
cells?: array<Null.t<string>>,
|
|
176
|
+
// `chainId` is left out for a cross-chain cache.
|
|
177
|
+
type storedEffectCache = {
|
|
178
|
+
effectName: string,
|
|
179
|
+
chainId?: ChainId.t,
|
|
180
|
+
tableName: string,
|
|
241
181
|
rows: int,
|
|
242
182
|
}
|
|
243
183
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
sets?: rows,
|
|
247
|
-
setCheckpointIds: array<string>,
|
|
248
|
-
deleteIds: array<string>,
|
|
249
|
-
deleteCheckpointIds: array<string>,
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
type postgresEntityWrite = {
|
|
253
|
-
sets?: rows,
|
|
254
|
-
deletes: array<string>,
|
|
255
|
-
history?: historyWrite,
|
|
256
|
-
}
|
|
184
|
+
// An optional field is left out rather than null, both ways: the addon refuses
|
|
185
|
+
// a null for one, and leaves out one it has no value for.
|
|
257
186
|
|
|
258
|
-
|
|
259
|
-
|
|
187
|
+
// One entity's changes within one chain scope, staged.
|
|
188
|
+
type changes = {
|
|
189
|
+
entity: int,
|
|
260
190
|
chainId?: ChainId.t,
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
clickhouse?: int,
|
|
191
|
+
keepsHistory: bool,
|
|
192
|
+
changes: int,
|
|
264
193
|
}
|
|
265
194
|
|
|
266
195
|
type diffCheckpoint = {
|
|
267
196
|
chainId: ChainId.t,
|
|
268
|
-
checkpointId:
|
|
197
|
+
checkpointId: bigint,
|
|
269
198
|
blockNumber: int,
|
|
270
199
|
}
|
|
271
200
|
|
|
272
201
|
type rollbackWrite = {
|
|
273
202
|
bounds: bounds,
|
|
274
|
-
tables: array<int>,
|
|
275
203
|
progress: array<progress>,
|
|
276
204
|
removedAddresses: addresses,
|
|
277
205
|
diffCheckpoints: array<diffCheckpoint>,
|
|
278
206
|
}
|
|
279
207
|
|
|
280
208
|
type checkpoints = {
|
|
281
|
-
ids: array<
|
|
209
|
+
ids: array<bigint>,
|
|
282
210
|
chainIds: array<ChainId.t>,
|
|
283
211
|
blockNumbers: array<int>,
|
|
284
212
|
blockHashes: array<Null.t<string>>,
|
|
@@ -286,17 +214,15 @@ type checkpoints = {
|
|
|
286
214
|
keepsHistory: array<bool>,
|
|
287
215
|
}
|
|
288
216
|
|
|
289
|
-
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<
|
|
290
|
-
|
|
291
|
-
type tableWrite = {table: int, rows: rows}
|
|
217
|
+
type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<bigint>}
|
|
292
218
|
|
|
293
|
-
type effectCacheWrite = {table:
|
|
219
|
+
type effectCacheWrite = {table: string, create: bool, rows: int}
|
|
294
220
|
|
|
295
221
|
type batch = {
|
|
296
222
|
rollback?: rollbackWrite,
|
|
297
223
|
progress: array<progress>,
|
|
298
|
-
rawEvents?:
|
|
299
|
-
|
|
224
|
+
rawEvents?: int,
|
|
225
|
+
changes: array<changes>,
|
|
300
226
|
chainMeta: array<chainMeta>,
|
|
301
227
|
addresses: addresses,
|
|
302
228
|
frontier: frontier,
|
|
@@ -306,37 +232,31 @@ type batch = {
|
|
|
306
232
|
|
|
307
233
|
type writeTiming = {store: store, seconds: float}
|
|
308
234
|
|
|
309
|
-
// What a build was for, which decides how much an existing index has to match.
|
|
310
|
-
type indexPurpose = | @as("Query") Query | @as("Schema") Schema
|
|
311
|
-
|
|
312
|
-
@tag("kind")
|
|
313
|
-
type indexEvent =
|
|
314
|
-
| Invalid({names: array<string>})
|
|
315
|
-
| Planned({declared: int, missing: array<string>, rebuilt: array<string>})
|
|
316
|
-
| Building({purpose: indexPurpose, name: string, tableName: string, isRebuild: bool})
|
|
317
|
-
| Built({purpose: indexPurpose, name: string, seconds: float})
|
|
318
|
-
| Failed({
|
|
319
|
-
purpose: indexPurpose,
|
|
320
|
-
name: string,
|
|
321
|
-
tableName: string,
|
|
322
|
-
columns: array<string>,
|
|
323
|
-
error: string,
|
|
324
|
-
code?: string,
|
|
325
|
-
})
|
|
326
|
-
| ResyncFailed({name: string, error: string, code?: string})
|
|
327
|
-
| Committed({count: int, seconds: float})
|
|
328
|
-
|
|
329
|
-
@send
|
|
330
|
-
external classCreate: (Core.storageCtor, options, indexEvent => unit, string => unit) => t =
|
|
331
|
-
"create"
|
|
332
|
-
|
|
333
|
-
let make = (options, ~onIndexEvent, ~onWarning) =>
|
|
334
|
-
Core.getAddon().storage->classCreate(options, onIndexEvent, onWarning)
|
|
335
|
-
|
|
336
|
-
@send external registerTable: (t, tableInput) => registeredTable = "registerTable"
|
|
337
|
-
|
|
338
235
|
@send
|
|
339
|
-
external
|
|
236
|
+
external classCreate: (
|
|
237
|
+
Core.storageCtor,
|
|
238
|
+
options,
|
|
239
|
+
Null.t<string>,
|
|
240
|
+
Logger.native,
|
|
241
|
+
array<string>,
|
|
242
|
+
) => t = "create"
|
|
243
|
+
|
|
244
|
+
// The storage of the entities `configJson` declares — the config the CLI
|
|
245
|
+
// wrote — or of none. The addon logs through `logger` itself, with the fields
|
|
246
|
+
// bound to it.
|
|
247
|
+
let make = (options, ~configJson=?, ~logger: Logger.t) =>
|
|
248
|
+
Core.getAddon().storage->classCreate(
|
|
249
|
+
options,
|
|
250
|
+
configJson->Null.fromOption,
|
|
251
|
+
logger.output.native,
|
|
252
|
+
logger.boundFieldsJson,
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
@send external layouts: t => layouts = "layouts"
|
|
256
|
+
|
|
257
|
+
@send external beginChanges: (t, ~entity: int, ~rows: int) => Staging.begun = "beginChanges"
|
|
258
|
+
|
|
259
|
+
@send external beginRows: (t, ~table: stagedTable, ~rows: int) => Staging.begun = "beginRows"
|
|
340
260
|
|
|
341
261
|
@send
|
|
342
262
|
external growStage: (
|
|
@@ -354,8 +274,8 @@ external commitStage: (t, ~handle: int, ~buffers: array<ArrayBuffer.t>) => unit
|
|
|
354
274
|
|
|
355
275
|
@send external discardStaged: (t, array<int>) => unit = "discardStaged"
|
|
356
276
|
|
|
357
|
-
let arena = (client,
|
|
358
|
-
beginStage: (~
|
|
277
|
+
let arena = (client, begin): Staging.arena => {
|
|
278
|
+
beginStage: (~rows) => begin(~rows),
|
|
359
279
|
growStage: (~handle, ~column, ~needed, ~stale) =>
|
|
360
280
|
client->growStage(~handle, ~column, ~needed, ~stale),
|
|
361
281
|
commitStage: (~handle, ~buffers) => client->commitStage(~handle, ~buffers),
|
|
@@ -392,13 +312,26 @@ let queryForTests = async (client, sql, ~params=[]) =>
|
|
|
392
312
|
@send
|
|
393
313
|
external loadWhereRaw: (t, int, array<LoadCondition.t>) => promise<queryResult> = "loadWhere"
|
|
394
314
|
|
|
395
|
-
let loadWhere = async (client, ~
|
|
396
|
-
client->read(await client->loadWhereRaw(
|
|
315
|
+
let loadWhere = async (client, ~entity, ~conditions) =>
|
|
316
|
+
client->read(await client->loadWhereRaw(entity, conditions))
|
|
317
|
+
|
|
318
|
+
@send
|
|
319
|
+
external loadEffectCacheRaw: (t, string, array<LoadCondition.t>) => promise<queryResult> =
|
|
320
|
+
"loadEffectCache"
|
|
321
|
+
|
|
322
|
+
let loadEffectCache = async (client, ~table, ~conditions) =>
|
|
323
|
+
client->read(await client->loadEffectCacheRaw(table, conditions))
|
|
324
|
+
|
|
325
|
+
@send
|
|
326
|
+
external clickHouseRowsForTestsRaw: (t, int) => promise<queryResult> = "clickhouseRowsForTests"
|
|
327
|
+
|
|
328
|
+
let clickHouseRowsForTests = async (client, ~entity) =>
|
|
329
|
+
client->read(await client->clickHouseRowsForTestsRaw(entity))
|
|
397
330
|
|
|
398
331
|
@send external historyForTestsRaw: (t, int) => promise<queryResult> = "historyForTests"
|
|
399
332
|
|
|
400
|
-
let historyForTests = async (client, ~
|
|
401
|
-
client->read(await client->historyForTestsRaw(
|
|
333
|
+
let historyForTests = async (client, ~entity) =>
|
|
334
|
+
client->read(await client->historyForTestsRaw(entity))
|
|
402
335
|
|
|
403
336
|
// What the storage holds before anything is initialized or resumed.
|
|
404
337
|
type holding =
|
|
@@ -420,49 +353,49 @@ type holding =
|
|
|
420
353
|
|
|
421
354
|
@send external readStoredConfig: t => promise<storedConfig> = "readStoredConfig"
|
|
422
355
|
|
|
423
|
-
|
|
356
|
+
// Resumes the chains this run drives, the only ones ClickHouse trims.
|
|
357
|
+
@send external resume: (t, array<ChainId.t>) => promise<resumed> = "resume"
|
|
424
358
|
|
|
425
359
|
@send external setChainMeta: (t, array<chainMeta>) => promise<unit> = "setChainMeta"
|
|
426
360
|
|
|
361
|
+
// Builds every index the schema promises for the chains, then stamps them
|
|
362
|
+
// ready at the given unix milliseconds.
|
|
427
363
|
@send
|
|
428
|
-
external finalizeBackfill: (t, array<
|
|
429
|
-
"finalizeBackfill"
|
|
364
|
+
external finalizeBackfill: (t, array<ChainId.t>, float) => promise<unit> = "finalizeBackfill"
|
|
430
365
|
|
|
431
|
-
@send
|
|
432
|
-
external ensureSchemaIndexes: (t, array<Core.pgIndexInput>) => promise<unit> = "ensureSchemaIndexes"
|
|
366
|
+
@send external ensureSchemaIndexes: (t, array<ChainId.t>) => promise<unit> = "ensureSchemaIndexes"
|
|
433
367
|
|
|
434
368
|
// Null when the indexes are already there, which is every call but the first,
|
|
435
|
-
// and every call for
|
|
369
|
+
// and every call for an entity Postgres doesn't keep.
|
|
436
370
|
@send
|
|
437
|
-
external ensureQueryIndexes: (
|
|
438
|
-
|
|
371
|
+
external ensureQueryIndexes: (
|
|
372
|
+
t,
|
|
373
|
+
~entity: int,
|
|
374
|
+
~chainId: Null.t<ChainId.t>,
|
|
375
|
+
~columns: array<string>,
|
|
376
|
+
) => Null.t<promise<unit>> = "ensureQueryIndexes"
|
|
439
377
|
|
|
440
378
|
@send external pruneCheckpoints: (t, bounds) => promise<unit> = "pruneCheckpoints"
|
|
441
379
|
|
|
442
380
|
@send external pruneHistory: (t, int, bounds) => promise<unit> = "pruneHistory"
|
|
443
381
|
|
|
444
382
|
@send
|
|
445
|
-
external rollbackTargetCheckpoint: (
|
|
446
|
-
|
|
447
|
-
ChainId.t,
|
|
448
|
-
int,
|
|
449
|
-
CheckpointSequence.t,
|
|
450
|
-
) => promise<Nullable.t<string>> = "rollbackTargetCheckpoint"
|
|
383
|
+
external rollbackTargetCheckpoint: (t, ChainId.t, int) => promise<Nullable.t<bigint>> =
|
|
384
|
+
"rollbackTargetCheckpoint"
|
|
451
385
|
|
|
452
386
|
@send
|
|
453
387
|
external rollbackProgressDiff: (t, bounds) => promise<array<progressDiff>> = "rollbackProgressDiff"
|
|
454
388
|
|
|
455
389
|
@send external rollbackData: (t, int, bounds) => promise<rollbackData> = "rollbackData"
|
|
456
390
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
type cacheDump = {tableName: string, path: string}
|
|
391
|
+
// Uploads the caches saved under the directory first when `upload` says to,
|
|
392
|
+
// logging how that went.
|
|
393
|
+
@send
|
|
394
|
+
external restoreEffectCache: (t, string, bool) => promise<array<storedEffectCache>> =
|
|
395
|
+
"restoreEffectCache"
|
|
464
396
|
|
|
465
|
-
|
|
397
|
+
// Never rejects: a dump that doesn't finish is logged.
|
|
398
|
+
@send external dumpEffectCache: (t, string) => promise<unit> = "dumpEffectCache"
|
|
466
399
|
|
|
467
400
|
@send external reset: t => promise<unit> = "reset"
|
|
468
401
|
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Core from "../Core.res.mjs";
|
|
4
4
|
import * as Reading from "../Reading.res.mjs";
|
|
5
|
+
import * as Stdlib_Null from "@rescript/runtime/lib/es6/Stdlib_Null.js";
|
|
5
6
|
|
|
6
|
-
function make(options,
|
|
7
|
-
return Core.getAddon().Storage.create(options,
|
|
7
|
+
function make(options, configJson, logger) {
|
|
8
|
+
return Core.getAddon().Storage.create(options, Stdlib_Null.fromOption(configJson), logger.output.native, logger.boundFieldsJson);
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
function arena(client,
|
|
11
|
+
function arena(client, begin) {
|
|
11
12
|
return {
|
|
12
|
-
beginStage:
|
|
13
|
+
beginStage: rows => begin(rows),
|
|
13
14
|
growStage: (handle, column, needed, stale) => client.growStage(handle, column, needed, stale),
|
|
14
15
|
commitStage: (handle, buffers) => {
|
|
15
16
|
client.commitStage(handle, buffers);
|
|
@@ -39,12 +40,20 @@ async function queryForTests(client, sql, paramsOpt) {
|
|
|
39
40
|
return read(client, await client.queryForTests(sql, params));
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
async function loadWhere(client,
|
|
43
|
-
return read(client, await client.loadWhere(
|
|
43
|
+
async function loadWhere(client, entity, conditions) {
|
|
44
|
+
return read(client, await client.loadWhere(entity, conditions));
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
async function
|
|
47
|
-
return read(client, await client.
|
|
47
|
+
async function loadEffectCache(client, table, conditions) {
|
|
48
|
+
return read(client, await client.loadEffectCache(table, conditions));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function clickHouseRowsForTests(client, entity) {
|
|
52
|
+
return read(client, await client.clickhouseRowsForTests(entity));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function historyForTests(client, entity) {
|
|
56
|
+
return read(client, await client.historyForTests(entity));
|
|
48
57
|
}
|
|
49
58
|
|
|
50
59
|
export {
|
|
@@ -53,6 +62,8 @@ export {
|
|
|
53
62
|
read,
|
|
54
63
|
queryForTests,
|
|
55
64
|
loadWhere,
|
|
65
|
+
loadEffectCache,
|
|
66
|
+
clickHouseRowsForTests,
|
|
56
67
|
historyForTests,
|
|
57
68
|
}
|
|
58
69
|
/* Core Not a pure module */
|
package/src/bindings/Vitest.res
CHANGED
|
@@ -169,29 +169,3 @@ let messageOfThrown: (unit => 'a) => option<string> = %raw(`function (fn) {
|
|
|
169
169
|
// happens to equal the placeholder.
|
|
170
170
|
let toThrowErrorEqual = (t: testContext, fn: unit => 'a, ~message=?, expected: string) =>
|
|
171
171
|
t.expect(fn->messageOfThrown, ~message?).toEqual(Some(expected))
|
|
172
|
-
|
|
173
|
-
// ============================================================================
|
|
174
|
-
// Fake timers
|
|
175
|
-
// ============================================================================
|
|
176
|
-
|
|
177
|
-
module Vi = {
|
|
178
|
-
@module("vitest") @scope("vi")
|
|
179
|
-
external useFakeTimers: unit => unit = "useFakeTimers"
|
|
180
|
-
|
|
181
|
-
@module("vitest") @scope("vi")
|
|
182
|
-
external useRealTimers: unit => unit = "useRealTimers"
|
|
183
|
-
|
|
184
|
-
// Runs every timer that comes due within the window, awaiting the
|
|
185
|
-
// microtasks each one queues before moving on.
|
|
186
|
-
@module("vitest") @scope("vi")
|
|
187
|
-
external advanceTimersByTimeAsync: int => promise<unit> = "advanceTimersByTimeAsync"
|
|
188
|
-
|
|
189
|
-
@module("vitest") @scope("vi")
|
|
190
|
-
external advanceTimersToNextTimerAsync: unit => promise<unit> = "advanceTimersToNextTimerAsync"
|
|
191
|
-
|
|
192
|
-
@module("vitest") @scope("vi")
|
|
193
|
-
external getTimerCount: unit => int = "getTimerCount"
|
|
194
|
-
|
|
195
|
-
@module("vitest") @scope("vi")
|
|
196
|
-
external clearAllTimers: unit => unit = "clearAllTimers"
|
|
197
|
-
}
|