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
@@ -11,6 +11,8 @@ type effectRateLimitState = {
11
11
  mutable availableCalls: int,
12
12
  mutable windowStartTime: float,
13
13
  mutable nextWindowPromise: option<promise<unit>>,
14
+ // The run's clock: a test on virtual time opens the next window by advancing.
15
+ clock: Clock.t,
14
16
  }
15
17
 
16
18
  // Per-(effect, scope) counters rendered into the envio_effect_* metrics. Live
@@ -80,9 +82,14 @@ type t = {
80
82
  // rollback; stats and the rate-limit window survive because the table does.
81
83
  tables: dict<effectCacheInMemTable>,
82
84
  unregisteredCacheCounts: dict<unregisteredCacheCount>,
85
+ clock: Clock.t,
83
86
  }
84
87
 
85
- let make = (): t => {tables: Dict.make(), unregisteredCacheCounts: Dict.make()}
88
+ let make = (~clock=Clock.real, ()): t => {
89
+ tables: Dict.make(),
90
+ unregisteredCacheCounts: Dict.make(),
91
+ clock,
92
+ }
86
93
 
87
94
  let setUnregisteredCacheCount = (self: t, ~effectName, ~scope, ~count) => {
88
95
  let tableName = Internal.EffectCache.toTableName(~effectName, ~scope)
@@ -214,8 +221,9 @@ let getTable = (self: t, ~effect: Internal.effect, ~scope: Internal.chainScope)
214
221
  callsPerDuration,
215
222
  durationMs,
216
223
  availableCalls: callsPerDuration,
217
- windowStartTime: Date.now(),
224
+ windowStartTime: self.clock.now(),
218
225
  nextWindowPromise: None,
226
+ clock: self.clock,
219
227
  })
220
228
  }
221
229
  let inMemTable: effectCacheInMemTable = {
@@ -1,13 +1,16 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Clock from "./Clock.res.mjs";
3
4
  import * as Utils from "./Utils.res.mjs";
4
5
  import * as Internal from "./Internal.res.mjs";
5
6
  import * as Performance from "./bindings/Performance.res.mjs";
6
7
 
7
- function make() {
8
+ function make(clockOpt, param) {
9
+ let clock = clockOpt !== undefined ? clockOpt : Clock.real;
8
10
  return {
9
11
  tables: {},
10
- unregisteredCacheCounts: {}
12
+ unregisteredCacheCounts: {},
13
+ clock: clock
11
14
  };
12
15
  }
13
16
 
@@ -130,8 +133,9 @@ function getTable(self, effect, scope) {
130
133
  callsPerDuration: callsPerDuration,
131
134
  durationMs: match$1.durationMs,
132
135
  availableCalls: callsPerDuration,
133
- windowStartTime: Date.now(),
134
- nextWindowPromise: undefined
136
+ windowStartTime: self.clock.now(),
137
+ nextWindowPromise: undefined,
138
+ clock: self.clock
135
139
  };
136
140
  } else {
137
141
  rateLimitState = undefined;
@@ -4,6 +4,8 @@ type effectRateLimitState = {
4
4
  mutable availableCalls: int,
5
5
  mutable windowStartTime: float,
6
6
  mutable nextWindowPromise: option<promise<unit>>,
7
+ // The run's clock: a test on virtual time opens the next window by advancing.
8
+ clock: Clock.t,
7
9
  }
8
10
 
9
11
  // Per-(effect, scope) metric counters. Survive rollback so they stay monotonic.
@@ -32,7 +34,7 @@ type effectCacheInMemTable = {
32
34
  // Opaque store of all per-(effect, scope) runtime state.
33
35
  type t
34
36
 
35
- let make: unit => t
37
+ let make: (~clock: Clock.t=?, unit) => t
36
38
  // Get, or lazily create, the in-mem table for an (effect, scope). Reuses the
37
39
  // surviving rate-limit window when the table is recreated after a rollback.
38
40
  let getTable: (t, ~effect: Internal.effect, ~scope: Internal.chainScope) => effectCacheInMemTable
package/src/EntityId.res CHANGED
@@ -1,15 +1,10 @@
1
1
  // Opaque representation of an entity id. The generated per-entity types expose
2
- // the real scalar (string / int / bigint); the generic storage and in-memory
2
+ // the real scalar (string / int / bigint / Uint8Array); the generic storage and in-memory
3
3
  // layers work with any entity's id through this type without knowing which
4
4
  // scalar backs it. The runtime value is always the real id, never a stringified
5
- // form — `toKey` derives the string only where a JS object/dict key is needed.
5
+ // form — a table's `entityIdToKey` derives the string only where a dict or Set key is needed.
6
6
  type t
7
7
 
8
8
  external unsafeOfAny: 'a => t = "%identity"
9
9
  external unsafeToAny: t => 'a = "%identity"
10
10
  external unsafeOfString: string => t = "%identity"
11
-
12
- // Stringified id used as a JS object/dict key. `String` matches how JS coerces
13
- // a value used as an object key, so an id indexes the same whether the raw
14
- // value or its key form is used for lookup, across string/int/bigint.
15
- let toKey: t => string = %raw(`String`)
@@ -1,9 +1,2 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
-
4
- let toKey = String;
5
-
6
- export {
7
- toKey,
8
- }
9
- /* toKey Not a pure module */
2
+ /* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
@@ -6,7 +6,10 @@ type t = dict<InMemoryTable.Entity.t>
6
6
  let make = (entities: array<Internal.entityConfig>): t => {
7
7
  let init = Dict.make()
8
8
  entities->Array.forEach(entityConfig => {
9
- init->Dict.set((entityConfig.name :> string), InMemoryTable.Entity.make())
9
+ init->Dict.set(
10
+ (entityConfig.name :> string),
11
+ InMemoryTable.Entity.make(~entityIdToKey=entityConfig.table.entityIdToKey),
12
+ )
10
13
  })
11
14
  init
12
15
  }
@@ -6,7 +6,7 @@ import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
6
6
  function make(entities) {
7
7
  let init = {};
8
8
  entities.forEach(entityConfig => {
9
- init[entityConfig.name] = InMemoryTable.Entity.make();
9
+ init[entityConfig.name] = InMemoryTable.Entity.make(entityConfig.table.entityIdToKey);
10
10
  });
11
11
  return init;
12
12
  }
package/src/Env.res CHANGED
@@ -4,22 +4,6 @@
4
4
  %%private(let envSafe = EnvSafe.make())
5
5
 
6
6
  let targetBufferSize = envSafe->EnvSafe.get("ENVIO_INDEXING_MAX_BUFFER_SIZE", S.option(S.int))
7
-
8
- // Set once a subgraph-mode config is loaded. A subgraph's mappings run per
9
- // event, and every fetched event that can create a data source also holds a
10
- // live register pass and its contract calls until the response is merged, so
11
- // the pool of events ready to process is sized for that (CrossChainState).
12
- let subgraphMode = ref(false)
13
-
14
- // Most events with a register pass one subgraph response may hold before it is
15
- // cut after a block and the rest fetched again. 0 turns the cut off; unset, it
16
- // follows what the register passes cost (ChainFetching).
17
- let subgraphRegisterChunk = envSafe->EnvSafe.get("ENVIO_SUBGRAPH_REGISTER_CHUNK", S.option(S.int))
18
-
19
- // How many items ahead of the one executing a subgraph handler is preloaded
20
- // again once an entity it read as absent is created (PreloadLookahead). 0 = off.
21
- let subgraphPreloadLookahead =
22
- envSafe->EnvSafe.get("ENVIO_SUBGRAPH_PRELOAD_LOOKAHEAD", S.int, ~fallback=256)
23
7
  let maxAddrInPartition = envSafe->EnvSafe.get("MAX_PARTITION_SIZE", S.int, ~fallback=5_000)
24
8
 
25
9
  // Most parallel in-flight queries a single chain may have at once, across all
package/src/Env.res.mjs CHANGED
@@ -13,14 +13,6 @@ let envSafe = EnvSafe.make(undefined);
13
13
 
14
14
  let targetBufferSize = EnvSafe.get(envSafe, "ENVIO_INDEXING_MAX_BUFFER_SIZE", S$RescriptSchema.option(S$RescriptSchema.int), undefined, undefined, undefined, undefined);
15
15
 
16
- let subgraphMode = {
17
- contents: false
18
- };
19
-
20
- let subgraphRegisterChunk = EnvSafe.get(envSafe, "ENVIO_SUBGRAPH_REGISTER_CHUNK", S$RescriptSchema.option(S$RescriptSchema.int), undefined, undefined, undefined, undefined);
21
-
22
- let subgraphPreloadLookahead = EnvSafe.get(envSafe, "ENVIO_SUBGRAPH_PRELOAD_LOOKAHEAD", S$RescriptSchema.int, undefined, 256, undefined, undefined);
23
-
24
16
  let maxAddrInPartition = EnvSafe.get(envSafe, "MAX_PARTITION_SIZE", S$RescriptSchema.int, undefined, 5000, undefined, undefined);
25
17
 
26
18
  let clientFilterAddressThreshold = EnvSafe.get(envSafe, "ENVIO_CLIENT_FILTER_ADDRESS_THRESHOLD", S$RescriptSchema.int, undefined, (maxAddrInPartition * 100 | 0) / 5 | 0, undefined, undefined);
@@ -224,9 +216,6 @@ let maxChainConcurrency = 100;
224
216
 
225
217
  export {
226
218
  targetBufferSize,
227
- subgraphMode,
228
- subgraphRegisterChunk,
229
- subgraphPreloadLookahead,
230
219
  maxAddrInPartition,
231
220
  maxChainConcurrency,
232
221
  clientFilterAddressThreshold,
@@ -125,52 +125,17 @@ let preloadBatchOrThrow = async (batch: Batch.t, ~runtime) => {
125
125
 
126
126
  let runBatchHandlersOrThrow = async (batch: Batch.t, ~runtime) => {
127
127
  let itemIdx = ref(0)
128
- let lookahead = PreloadLookahead.active.contents
129
- // Settled before the batch ends: one finishing after a rollback would put a
130
- // value read before it back into memory.
131
- let lookaheadPreloads = []
132
- // Only read by the lookahead, which preloads items out of checkpoint order.
133
- let checkpointIdOf = switch lookahead {
134
- | Some(_) =>
135
- let ids = []
136
- batch.checkpointIds->Array.forEachWithIndex((checkpointId, checkpointIdx) => {
137
- for _ in 1 to batch.checkpointItemsCount->Array.getUnsafe(checkpointIdx) {
138
- ids->Array.push(checkpointId)
139
- }
140
- })
141
- ids
142
- | None => []
143
- }
144
128
 
145
129
  for checkpointIdx in 0 to batch.checkpointIds->Array.length - 1 {
146
130
  let checkpointId = batch.checkpointIds->Array.getUnsafe(checkpointIdx)
147
131
  let checkpointItemsCount = batch.checkpointItemsCount->Array.getUnsafe(checkpointIdx)
148
132
 
149
133
  for idx in 0 to checkpointItemsCount - 1 {
150
- let index = itemIdx.contents + idx
151
- let item = batch.items->Array.getUnsafe(index)
134
+ let item = batch.items->Array.getUnsafe(itemIdx.contents + idx)
152
135
  await runHandlerOrThrow(item, ~checkpointId, ~runtime)
153
-
154
- switch lookahead {
155
- | Some(lookahead) =>
156
- lookahead->PreloadLookahead.afterItem(~index, ~preload=(ahead, aheadIdx) =>
157
- if ahead->hasHandler {
158
- lookaheadPreloads
159
- ->Array.push(
160
- runtime->preload(
161
- ~item=ahead,
162
- ~checkpointId=checkpointIdOf->Array.getUnsafe(aheadIdx),
163
- ),
164
- )
165
- ->ignore
166
- }
167
- )
168
- | None => ()
169
- }
170
136
  }
171
137
  itemIdx := itemIdx.contents + checkpointItemsCount
172
138
  }
173
- let _ = await Promise.all(lookaheadPreloads)
174
139
  }
175
140
 
176
141
  let registerProcessEventBatchMetrics = (
@@ -254,7 +219,6 @@ let processEventBatch = async (~batch: Batch.t, ~runtime: HandlerRuntime.t) => {
254
219
  // Materialise store-backed transactions onto payloads before any handler
255
220
  // (preload or execute) reads them.
256
221
  await materializeBatchEvents(batch, ~chainStates)
257
- PreloadLookahead.start(~items=batch.items)
258
222
  await batch->preloadBatchOrThrow(~runtime)
259
223
  }
260
224
 
@@ -263,7 +227,6 @@ let processEventBatch = async (~batch: Batch.t, ~runtime: HandlerRuntime.t) => {
263
227
  if batch.items->Utils.Array.notEmpty {
264
228
  await batch->runBatchHandlersOrThrow(~runtime)
265
229
  }
266
- PreloadLookahead.stop()
267
230
 
268
231
  let elapsedTimeAfterProcessing = timeRef->Performance.secondsSince
269
232
 
@@ -14,7 +14,6 @@ import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
14
14
  import * as IndexerState from "./IndexerState.res.mjs";
15
15
  import * as ErrorHandling from "./ErrorHandling.res.mjs";
16
16
  import * as HandlerRuntime from "./HandlerRuntime.res.mjs";
17
- import * as PreloadLookahead from "./PreloadLookahead.res.mjs";
18
17
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
19
18
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
20
19
 
@@ -139,39 +138,15 @@ async function preloadBatchOrThrow(batch, runtime) {
139
138
 
140
139
  async function runBatchHandlersOrThrow(batch, runtime) {
141
140
  let itemIdx = 0;
142
- let lookahead = PreloadLookahead.active.contents;
143
- let lookaheadPreloads = [];
144
- let checkpointIdOf;
145
- if (lookahead !== undefined) {
146
- let ids = [];
147
- batch.checkpointIds.forEach((checkpointId, checkpointIdx) => {
148
- for (let _for = 1, _for_finish = batch.checkpointItemsCount[checkpointIdx]; _for <= _for_finish; ++_for) {
149
- ids.push(checkpointId);
150
- }
151
- });
152
- checkpointIdOf = ids;
153
- } else {
154
- checkpointIdOf = [];
155
- }
156
141
  for (let checkpointIdx = 0, checkpointIdx_finish = batch.checkpointIds.length; checkpointIdx < checkpointIdx_finish; ++checkpointIdx) {
157
142
  let checkpointId = batch.checkpointIds[checkpointIdx];
158
143
  let checkpointItemsCount = batch.checkpointItemsCount[checkpointIdx];
159
144
  for (let idx = 0; idx < checkpointItemsCount; ++idx) {
160
- let index = itemIdx + idx | 0;
161
- let item = batch.items[index];
145
+ let item = batch.items[itemIdx + idx | 0];
162
146
  await runHandlerOrThrow(item, checkpointId, runtime);
163
- if (lookahead !== undefined) {
164
- PreloadLookahead.afterItem(lookahead, index, (ahead, aheadIdx) => {
165
- if (hasHandler(ahead)) {
166
- lookaheadPreloads.push(preload(runtime, ahead, checkpointIdOf[aheadIdx]));
167
- return;
168
- }
169
- });
170
- }
171
147
  }
172
148
  itemIdx = itemIdx + checkpointItemsCount | 0;
173
149
  }
174
- await Promise.all(lookaheadPreloads);
175
150
  }
176
151
 
177
152
  function registerProcessEventBatchMetrics(logger, batch, indexerState, loadDuration, handlerDuration) {
@@ -220,14 +195,12 @@ async function processEventBatch(batch, runtime) {
220
195
  let timeRef = Performance.now();
221
196
  if (Utils.$$Array.notEmpty(batch.items)) {
222
197
  await materializeBatchEvents(batch, chainStates);
223
- PreloadLookahead.start(batch.items);
224
198
  await preloadBatchOrThrow(batch, runtime);
225
199
  }
226
200
  let elapsedTimeAfterLoaders = Performance.secondsSince(timeRef);
227
201
  if (Utils.$$Array.notEmpty(batch.items)) {
228
202
  await runBatchHandlersOrThrow(batch, runtime);
229
203
  }
230
- PreloadLookahead.stop();
231
204
  let elapsedTimeAfterProcessing = Performance.secondsSince(timeRef);
232
205
  Writing.commitBatch(indexerState, batch);
233
206
  let handlerDuration = elapsedTimeAfterProcessing - elapsedTimeAfterLoaders;