envio 3.15.0-subgraph → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/README.md +40 -34
  2. package/evm.schema.json +3 -3
  3. package/fuel.schema.json +2 -2
  4. package/index.d.ts +3 -3
  5. package/licenses/README.md +1 -1
  6. package/package.json +9 -10
  7. package/src/Batch.res.mjs +5 -5
  8. package/src/BatchProcessing.res +1 -0
  9. package/src/BatchProcessing.res.mjs +1 -0
  10. package/src/Bin.res +0 -7
  11. package/src/Bin.res.mjs +0 -8
  12. package/src/ChainFetching.res +17 -456
  13. package/src/ChainFetching.res.mjs +33 -404
  14. package/src/ChainState.res +48 -83
  15. package/src/ChainState.res.mjs +83 -115
  16. package/src/ChainState.resi +0 -26
  17. package/src/Clock.res +57 -0
  18. package/src/Clock.res.mjs +72 -0
  19. package/src/Config.res +7 -16
  20. package/src/Config.res.mjs +4 -11
  21. package/src/ContractRegisterContext.res +6 -3
  22. package/src/ContractRegisterContext.res.mjs +2 -4
  23. package/src/Core.res +5 -136
  24. package/src/Core.res.mjs +1 -90
  25. package/src/CrossChainState.res +2 -8
  26. package/src/CrossChainState.res.mjs +3 -3
  27. package/src/Ecosystem.res +4 -7
  28. package/src/Ecosystem.res.mjs +8 -8
  29. package/src/EffectState.res +10 -2
  30. package/src/EffectState.res.mjs +8 -4
  31. package/src/EffectState.resi +3 -1
  32. package/src/EntityId.res +2 -7
  33. package/src/EntityId.res.mjs +1 -8
  34. package/src/EntityTables.res +4 -1
  35. package/src/EntityTables.res.mjs +1 -1
  36. package/src/Env.res +0 -16
  37. package/src/Env.res.mjs +0 -11
  38. package/src/EventProcessing.res +1 -38
  39. package/src/EventProcessing.res.mjs +1 -28
  40. package/src/FetchState.res +160 -319
  41. package/src/FetchState.res.mjs +182 -292
  42. package/src/FinalizeBackfill.res +2 -4
  43. package/src/FinalizeBackfill.res.mjs +3 -4
  44. package/src/HandlerLoader.res +15 -39
  45. package/src/HandlerLoader.res.mjs +8 -27
  46. package/src/HandlerRegister.res +0 -4
  47. package/src/HandlerRegister.res.mjs +2 -5
  48. package/src/HandlerRegister.resi +0 -2
  49. package/src/InMemoryTable.res +17 -16
  50. package/src/InMemoryTable.res.mjs +14 -15
  51. package/src/IndexerState.res +28 -4
  52. package/src/IndexerState.res.mjs +19 -6
  53. package/src/IndexerState.resi +4 -0
  54. package/src/Internal.res +0 -110
  55. package/src/Internal.res.mjs +1 -115
  56. package/src/LoadLayer.res +21 -47
  57. package/src/LoadLayer.res.mjs +47 -72
  58. package/src/LoadLayer.resi +0 -26
  59. package/src/Main.res +1 -14
  60. package/src/Main.res.mjs +3 -4
  61. package/src/Persistence.res +3 -23
  62. package/src/Persistence.res.mjs +3 -3
  63. package/src/Rollback.res +0 -1
  64. package/src/Rollback.res.mjs +1 -1
  65. package/src/RunScope.res +0 -3
  66. package/src/SafeCheckpointTracking.res +4 -4
  67. package/src/SafeCheckpointTracking.res.mjs +1 -1
  68. package/src/SimulateItems.res +26 -42
  69. package/src/SimulateItems.res.mjs +16 -40
  70. package/src/StagedRows.res +106 -0
  71. package/src/StagedRows.res.mjs +102 -0
  72. package/src/Staging.res +32 -14
  73. package/src/Staging.res.mjs +17 -20
  74. package/src/Storage.res +277 -998
  75. package/src/Storage.res.mjs +216 -731
  76. package/src/Supervisor.res +75 -56
  77. package/src/Supervisor.res.mjs +55 -26
  78. package/src/TestIndexer.res +22 -27
  79. package/src/TestIndexer.res.mjs +20 -17
  80. package/src/Throttler.res +15 -8
  81. package/src/Throttler.res.mjs +9 -6
  82. package/src/Throttler.resi +1 -1
  83. package/src/UserContext.res +46 -410
  84. package/src/UserContext.res.mjs +30 -318
  85. package/src/Utils.res +0 -23
  86. package/src/Utils.res.mjs +1 -17
  87. package/src/Writing.res +0 -1
  88. package/src/Writing.res.mjs +1 -1
  89. package/src/bindings/ClickHouse.res +0 -322
  90. package/src/bindings/ClickHouse.res.mjs +0 -338
  91. package/src/bindings/StorageClient.res +107 -175
  92. package/src/bindings/StorageClient.res.mjs +19 -8
  93. package/src/bindings/Vitest.res +0 -26
  94. package/src/bindings/Vitest.res.mjs +0 -3
  95. package/src/db/Table.res +24 -150
  96. package/src/db/Table.res.mjs +38 -272
  97. package/src/sources/AddressSet.res +0 -2
  98. package/src/sources/AddressStore.res +0 -3
  99. package/src/sources/ChainSources.res +2 -0
  100. package/src/sources/ChainSources.res.mjs +2 -2
  101. package/src/sources/EvmChain.res +4 -7
  102. package/src/sources/EvmChain.res.mjs +5 -4
  103. package/src/sources/EvmHyperSyncSource.res +2 -2
  104. package/src/sources/EvmHyperSyncSource.res.mjs +1 -1
  105. package/src/sources/EvmRpcClient.res +13 -3
  106. package/src/sources/EvmRpcClient.res.mjs +4 -3
  107. package/src/sources/EvmRpcWs.res +4 -3
  108. package/src/sources/EvmRpcWs.res.mjs +2 -2
  109. package/src/sources/HeightFeed.res +31 -10
  110. package/src/sources/HeightFeed.res.mjs +10 -6
  111. package/src/sources/HeightStream.res +32 -17
  112. package/src/sources/HeightStream.res.mjs +10 -10
  113. package/src/sources/HyperSync.res +1 -2
  114. package/src/sources/HyperSync.res.mjs +1 -2
  115. package/src/sources/HyperSyncSSE.res +4 -6
  116. package/src/sources/HyperSyncSSE.res.mjs +2 -2
  117. package/src/sources/RpcSource.res +10 -1
  118. package/src/sources/RpcSource.res.mjs +4 -3
  119. package/src/sources/Source.res +3 -0
  120. package/src/sources/SourceManager.res +85 -104
  121. package/src/sources/SourceManager.res.mjs +18 -37
  122. package/src/sources/SourceManager.resi +3 -5
  123. package/src/sources/StartBlockResolver.res +1 -0
  124. package/src/sources/StartBlockResolver.res.mjs +4 -3
  125. package/src/sources/SvmHyperSyncSource.res +2 -2
  126. package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
  127. package/svm.schema.json +3 -3
  128. package/src/EffectCacheLookup.res +0 -98
  129. package/src/EffectCacheLookup.res.mjs +0 -116
  130. package/src/PgWriting.res +0 -36
  131. package/src/PgWriting.res.mjs +0 -34
  132. package/src/PreloadLookahead.res +0 -184
  133. package/src/PreloadLookahead.res.mjs +0 -197
  134. package/src/SubgraphLog.res +0 -19
  135. package/src/SubgraphLog.res.mjs +0 -26
  136. package/src/SyncWrites.res +0 -101
  137. package/src/SyncWrites.res.mjs +0 -98
  138. package/src/db/IndexDefinition.res +0 -47
  139. package/src/db/IndexDefinition.res.mjs +0 -60
  140. package/src/sources/CallSource.res +0 -274
  141. package/src/sources/CallSource.res.mjs +0 -196
  142. package/src/subgraph/abi-types.ts +0 -84
  143. package/src/subgraph/aggregations.ts +0 -745
  144. package/src/subgraph/as-package.ts +0 -143
  145. package/src/subgraph/assemblyscript-regex.ts +0 -67
  146. package/src/subgraph/assemblyscript.ts +0 -731
  147. package/src/subgraph/blocks.ts +0 -398
  148. package/src/subgraph/calls-source.ts +0 -702
  149. package/src/subgraph/calls.ts +0 -258
  150. package/src/subgraph/conformance.ts +0 -106
  151. package/src/subgraph/errors.ts +0 -85
  152. package/src/subgraph/graft.ts +0 -73
  153. package/src/subgraph/graph-cli-worker.mjs +0 -35
  154. package/src/subgraph/graph-cli.ts +0 -900
  155. package/src/subgraph/graph-node-decimal.ts +0 -199
  156. package/src/subgraph/graph-ts-enums.ts +0 -28
  157. package/src/subgraph/graph-ts-types/VERSION +0 -2
  158. package/src/subgraph/graph-ts-types/chain/arweave.d.ts +0 -70
  159. package/src/subgraph/graph-ts-types/chain/cosmos.d.ts +0 -327
  160. package/src/subgraph/graph-ts-types/chain/ethereum.d.ts +0 -233
  161. package/src/subgraph/graph-ts-types/chain/near.d.ts +0 -253
  162. package/src/subgraph/graph-ts-types/chain/starknet.d.ts +0 -32
  163. package/src/subgraph/graph-ts-types/common/collections.d.ts +0 -136
  164. package/src/subgraph/graph-ts-types/common/conversion.d.ts +0 -11
  165. package/src/subgraph/graph-ts-types/common/datasource.d.ts +0 -30
  166. package/src/subgraph/graph-ts-types/common/eager-offset.d.ts +0 -0
  167. package/src/subgraph/graph-ts-types/common/json.d.ts +0 -17
  168. package/src/subgraph/graph-ts-types/common/numbers.d.ts +0 -120
  169. package/src/subgraph/graph-ts-types/common/value.d.ts +0 -120
  170. package/src/subgraph/graph-ts-types/common/yaml.d.ts +0 -90
  171. package/src/subgraph/graph-ts-types/global/global.d.ts +0 -194
  172. package/src/subgraph/graph-ts-types/helper-functions.d.ts +0 -22
  173. package/src/subgraph/graph-ts-types/index.d.ts +0 -102
  174. package/src/subgraph/graph-ts.ts +0 -4280
  175. package/src/subgraph/hosts.ts +0 -554
  176. package/src/subgraph/log.ts +0 -28
  177. package/src/subgraph/receipts.ts +0 -184
  178. package/src/subgraph/register-slots.ts +0 -93
  179. package/src/subgraph/rollup.ts +0 -109
  180. package/src/subgraph/rpc.ts +0 -337
  181. package/src/subgraph/runtime.ts +0 -2060
  182. package/src/subgraph/scope.ts +0 -177
  183. package/src/subgraph/stats.ts +0 -42
  184. package/src/subgraph/template-instances.ts +0 -66
  185. package/src/subgraph/toolchain.ts +0 -327
  186. package/src/subgraph/transient.ts +0 -176
@@ -1,8 +1,8 @@
1
1
  // Rows cross in arenas both ways. A write stages its rows into memory the addon
2
- // lends (`beginStage` to `commitStage`); a read lands its rows in a Rust-owned
3
- // arena that `lendResult` hands over and `releaseResult` takes back. Reading or
4
- // writing through a buffer after it has been handed back is what detaching
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
- // A ClickHouse column. The rows read back are keyed by `rowName`, the name the
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 clickHouseTable = {
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
- // A table described for every store that keeps it: an entity for each store its
83
- // schema names, the indexer's own tables for Postgres alone.
84
- type tableInput = {
54
+ type entityLayout = {
85
55
  name: string,
86
- postgres?: Core.pgTableInput,
87
- clickhouse?: clickHouseTable,
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
- type postgresRegistered = {kinds?: array<int>}
91
-
92
- type clickHouseRegistered = {
93
- names: array<string>,
94
- kinds: array<int>,
95
- nullable: array<bool>,
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 store = Postgres | ClickHouse
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<string>,
74
+ checkpointIds: array<bigint>,
113
75
  }
114
76
 
115
77
  type progress = {
@@ -146,36 +108,18 @@ 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>,
161
115
  addresses: addresses,
162
- keptEffectCaches?: array<string>,
163
116
  }
164
117
 
165
118
  type addChain = {
166
119
  chain: chainConfig,
167
- partitions: array<partition>,
168
120
  addresses: addresses,
169
121
  }
170
122
 
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
123
  type storedChain = {
180
124
  id: float,
181
125
  ecosystem: string,
@@ -204,11 +148,11 @@ type resumedChain = {
204
148
  // Unix seconds.
205
149
  progressBlockTime?: float,
206
150
  sourceBlock: int,
207
- checkpointId: string,
151
+ checkpointId: bigint,
208
152
  }
209
153
 
210
154
  type reorgCheckpoint = {
211
- id: string,
155
+ id: bigint,
212
156
  chainId: float,
213
157
  blockNumber: int,
214
158
  blockHash: string,
@@ -228,57 +172,40 @@ type progressDiff = {
228
172
 
229
173
  type rollbackData = {removed: queryResult, restored: queryResult}
230
174
 
231
- type cacheTable = {tableName: string, rows: int}
232
-
233
- // An optional field is left out rather than null, both ways: the addon refuses
234
- // a null for one, and leaves out one it has no value for.
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>>,
175
+ // `chainId` is left out for a cross-chain cache.
176
+ type storedEffectCache = {
177
+ effectName: string,
178
+ chainId?: ChainId.t,
179
+ tableName: string,
241
180
  rows: int,
242
181
  }
243
182
 
244
- type historyWrite = {
245
- backfill: array<string>,
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
- }
183
+ // An optional field is left out rather than null, both ways: the addon refuses
184
+ // a null for one, and leaves out one it has no value for.
257
185
 
258
- type entityWrite = {
259
- table: int,
186
+ // One entity's changes within one chain scope, staged.
187
+ type changes = {
188
+ entity: int,
260
189
  chainId?: ChainId.t,
261
- postgres?: postgresEntityWrite,
262
- // Every change as a history row, staged.
263
- clickhouse?: int,
190
+ keepsHistory: bool,
191
+ changes: int,
264
192
  }
265
193
 
266
194
  type diffCheckpoint = {
267
195
  chainId: ChainId.t,
268
- checkpointId: string,
196
+ checkpointId: bigint,
269
197
  blockNumber: int,
270
198
  }
271
199
 
272
200
  type rollbackWrite = {
273
201
  bounds: bounds,
274
- tables: array<int>,
275
202
  progress: array<progress>,
276
203
  removedAddresses: addresses,
277
204
  diffCheckpoints: array<diffCheckpoint>,
278
205
  }
279
206
 
280
207
  type checkpoints = {
281
- ids: array<string>,
208
+ ids: array<bigint>,
282
209
  chainIds: array<ChainId.t>,
283
210
  blockNumbers: array<int>,
284
211
  blockHashes: array<Null.t<string>>,
@@ -286,17 +213,15 @@ type checkpoints = {
286
213
  keepsHistory: array<bool>,
287
214
  }
288
215
 
289
- type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<string>}
290
-
291
- type tableWrite = {table: int, rows: rows}
216
+ type frontier = {chainIds: array<ChainId.t>, checkpointIds: array<bigint>}
292
217
 
293
- type effectCacheWrite = {table: int, create: bool, rows: rows}
218
+ type effectCacheWrite = {table: string, create: bool, rows: int}
294
219
 
295
220
  type batch = {
296
221
  rollback?: rollbackWrite,
297
222
  progress: array<progress>,
298
- rawEvents?: tableWrite,
299
- entities: array<entityWrite>,
223
+ rawEvents?: int,
224
+ changes: array<changes>,
300
225
  chainMeta: array<chainMeta>,
301
226
  addresses: addresses,
302
227
  frontier: frontier,
@@ -306,37 +231,31 @@ type batch = {
306
231
 
307
232
  type writeTiming = {store: store, seconds: float}
308
233
 
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
234
  @send
339
- external beginStage: (t, ~table: int, ~store: store, ~rows: int) => Staging.begun = "beginStage"
235
+ external classCreate: (
236
+ Core.storageCtor,
237
+ options,
238
+ Null.t<string>,
239
+ Logger.native,
240
+ array<string>,
241
+ ) => t = "create"
242
+
243
+ // The storage of the entities `configJson` declares — the config the CLI
244
+ // wrote — or of none. The addon logs through `logger` itself, with the fields
245
+ // bound to it.
246
+ let make = (options, ~configJson=?, ~logger: Logger.t) =>
247
+ Core.getAddon().storage->classCreate(
248
+ options,
249
+ configJson->Null.fromOption,
250
+ logger.output.native,
251
+ logger.boundFieldsJson,
252
+ )
253
+
254
+ @send external layouts: t => layouts = "layouts"
255
+
256
+ @send external beginChanges: (t, ~entity: int, ~rows: int) => Staging.begun = "beginChanges"
257
+
258
+ @send external beginRows: (t, ~table: stagedTable, ~rows: int) => Staging.begun = "beginRows"
340
259
 
341
260
  @send
342
261
  external growStage: (
@@ -354,8 +273,8 @@ external commitStage: (t, ~handle: int, ~buffers: array<ArrayBuffer.t>) => unit
354
273
 
355
274
  @send external discardStaged: (t, array<int>) => unit = "discardStaged"
356
275
 
357
- let arena = (client, ~store): Staging.arena => {
358
- beginStage: (~table, ~rows) => client->beginStage(~table, ~store, ~rows),
276
+ let arena = (client, begin): Staging.arena => {
277
+ beginStage: (~rows) => begin(~rows),
359
278
  growStage: (~handle, ~column, ~needed, ~stale) =>
360
279
  client->growStage(~handle, ~column, ~needed, ~stale),
361
280
  commitStage: (~handle, ~buffers) => client->commitStage(~handle, ~buffers),
@@ -392,13 +311,26 @@ let queryForTests = async (client, sql, ~params=[]) =>
392
311
  @send
393
312
  external loadWhereRaw: (t, int, array<LoadCondition.t>) => promise<queryResult> = "loadWhere"
394
313
 
395
- let loadWhere = async (client, ~table, ~conditions) =>
396
- client->read(await client->loadWhereRaw(table, conditions))
314
+ let loadWhere = async (client, ~entity, ~conditions) =>
315
+ client->read(await client->loadWhereRaw(entity, conditions))
316
+
317
+ @send
318
+ external loadEffectCacheRaw: (t, string, array<LoadCondition.t>) => promise<queryResult> =
319
+ "loadEffectCache"
320
+
321
+ let loadEffectCache = async (client, ~table, ~conditions) =>
322
+ client->read(await client->loadEffectCacheRaw(table, conditions))
323
+
324
+ @send
325
+ external clickHouseRowsForTestsRaw: (t, int) => promise<queryResult> = "clickhouseRowsForTests"
326
+
327
+ let clickHouseRowsForTests = async (client, ~entity) =>
328
+ client->read(await client->clickHouseRowsForTestsRaw(entity))
397
329
 
398
330
  @send external historyForTestsRaw: (t, int) => promise<queryResult> = "historyForTests"
399
331
 
400
- let historyForTests = async (client, ~table) =>
401
- client->read(await client->historyForTestsRaw(table))
332
+ let historyForTests = async (client, ~entity) =>
333
+ client->read(await client->historyForTestsRaw(entity))
402
334
 
403
335
  // What the storage holds before anything is initialized or resumed.
404
336
  type holding =
@@ -420,49 +352,49 @@ type holding =
420
352
 
421
353
  @send external readStoredConfig: t => promise<storedConfig> = "readStoredConfig"
422
354
 
423
- @send external resume: (t, resume) => promise<resumed> = "resume"
355
+ // Resumes the chains this run drives, the only ones ClickHouse trims.
356
+ @send external resume: (t, array<ChainId.t>) => promise<resumed> = "resume"
424
357
 
425
358
  @send external setChainMeta: (t, array<chainMeta>) => promise<unit> = "setChainMeta"
426
359
 
360
+ // Builds every index the schema promises for the chains, then stamps them
361
+ // ready at the given unix milliseconds.
427
362
  @send
428
- external finalizeBackfill: (t, array<Core.pgIndexInput>, array<ChainId.t>, float) => promise<unit> =
429
- "finalizeBackfill"
363
+ external finalizeBackfill: (t, array<ChainId.t>, float) => promise<unit> = "finalizeBackfill"
430
364
 
431
- @send
432
- external ensureSchemaIndexes: (t, array<Core.pgIndexInput>) => promise<unit> = "ensureSchemaIndexes"
365
+ @send external ensureSchemaIndexes: (t, array<ChainId.t>) => promise<unit> = "ensureSchemaIndexes"
433
366
 
434
367
  // Null when the indexes are already there, which is every call but the first,
435
- // and every call for a table no store builds query indexes for.
368
+ // and every call for an entity Postgres doesn't keep.
436
369
  @send
437
- external ensureQueryIndexes: (t, int, string, array<string>) => Null.t<promise<unit>> =
438
- "ensureQueryIndexes"
370
+ external ensureQueryIndexes: (
371
+ t,
372
+ ~entity: int,
373
+ ~chainId: Null.t<ChainId.t>,
374
+ ~columns: array<string>,
375
+ ) => Null.t<promise<unit>> = "ensureQueryIndexes"
439
376
 
440
377
  @send external pruneCheckpoints: (t, bounds) => promise<unit> = "pruneCheckpoints"
441
378
 
442
379
  @send external pruneHistory: (t, int, bounds) => promise<unit> = "pruneHistory"
443
380
 
444
381
  @send
445
- external rollbackTargetCheckpoint: (
446
- t,
447
- ChainId.t,
448
- int,
449
- CheckpointSequence.t,
450
- ) => promise<Nullable.t<string>> = "rollbackTargetCheckpoint"
382
+ external rollbackTargetCheckpoint: (t, ChainId.t, int) => promise<Nullable.t<bigint>> =
383
+ "rollbackTargetCheckpoint"
451
384
 
452
385
  @send
453
386
  external rollbackProgressDiff: (t, bounds) => promise<array<progressDiff>> = "rollbackProgressDiff"
454
387
 
455
388
  @send external rollbackData: (t, int, bounds) => promise<rollbackData> = "rollbackData"
456
389
 
457
- @send external effectCacheTables: t => promise<array<cacheTable>> = "effectCacheTables"
458
-
459
- type cacheUpload = {table: int, path: string}
460
-
461
- @send external uploadEffectCache: (t, array<cacheUpload>) => promise<unit> = "uploadEffectCache"
462
-
463
- type cacheDump = {tableName: string, path: string}
390
+ // Uploads the caches saved under the directory first when `upload` says to,
391
+ // logging how that went.
392
+ @send
393
+ external restoreEffectCache: (t, string, bool) => promise<array<storedEffectCache>> =
394
+ "restoreEffectCache"
464
395
 
465
- @send external dumpEffectCache: (t, array<cacheDump>) => promise<unit> = "dumpEffectCache"
396
+ // Never rejects: a dump that doesn't finish is logged.
397
+ @send external dumpEffectCache: (t, string) => promise<unit> = "dumpEffectCache"
466
398
 
467
399
  @send external reset: t => promise<unit> = "reset"
468
400
 
@@ -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, onIndexEvent, onWarning) {
7
- return Core.getAddon().Storage.create(options, onIndexEvent, onWarning);
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, store) {
11
+ function arena(client, begin) {
11
12
  return {
12
- beginStage: (table, rows) => client.beginStage(table, store, rows),
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, table, conditions) {
43
- return read(client, await client.loadWhere(table, conditions));
43
+ async function loadWhere(client, entity, conditions) {
44
+ return read(client, await client.loadWhere(entity, conditions));
44
45
  }
45
46
 
46
- async function historyForTests(client, table) {
47
- return read(client, await client.historyForTests(table));
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 */
@@ -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
- }
@@ -16,12 +16,9 @@ function toThrowErrorEqual(t, fn, message, expected) {
16
16
  t.expect(messageOfThrown(fn), message).toEqual(expected);
17
17
  }
18
18
 
19
- let Vi = {};
20
-
21
19
  export {
22
20
  Async,
23
21
  messageOfThrown,
24
22
  toThrowErrorEqual,
25
- Vi,
26
23
  }
27
24
  /* No side effect */