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.
Files changed (114) 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 +8 -8
  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/ChainFetching.res +1 -6
  11. package/src/ChainFetching.res.mjs +1 -1
  12. package/src/ChainState.res +48 -7
  13. package/src/ChainState.res.mjs +21 -8
  14. package/src/Clock.res +57 -0
  15. package/src/Clock.res.mjs +72 -0
  16. package/src/Config.res +16 -4
  17. package/src/Config.res.mjs +5 -3
  18. package/src/Core.res +4 -40
  19. package/src/CrossChainState.res +10 -6
  20. package/src/CrossChainState.res.mjs +1 -1
  21. package/src/EffectState.res +10 -2
  22. package/src/EffectState.res.mjs +8 -4
  23. package/src/EffectState.resi +3 -1
  24. package/src/EntityId.res +2 -7
  25. package/src/EntityId.res.mjs +1 -8
  26. package/src/EntityTables.res +4 -1
  27. package/src/EntityTables.res.mjs +1 -1
  28. package/src/Env.res +4 -0
  29. package/src/Env.res.mjs +5 -0
  30. package/src/FetchState.res +157 -69
  31. package/src/FetchState.res.mjs +112 -47
  32. package/src/FinalizeBackfill.res +2 -4
  33. package/src/FinalizeBackfill.res.mjs +3 -4
  34. package/src/InMemoryTable.res +17 -16
  35. package/src/InMemoryTable.res.mjs +14 -15
  36. package/src/IndexerState.res +28 -4
  37. package/src/IndexerState.res.mjs +19 -6
  38. package/src/IndexerState.resi +4 -0
  39. package/src/Internal.res +0 -49
  40. package/src/Internal.res.mjs +1 -80
  41. package/src/LoadLayer.res +17 -10
  42. package/src/LoadLayer.res.mjs +11 -8
  43. package/src/Main.res.mjs +1 -1
  44. package/src/Persistence.res +3 -23
  45. package/src/Persistence.res.mjs +3 -3
  46. package/src/PreloadLookahead.res +42 -24
  47. package/src/PreloadLookahead.res.mjs +51 -30
  48. package/src/Rollback.res +0 -1
  49. package/src/Rollback.res.mjs +1 -1
  50. package/src/SafeCheckpointTracking.res +4 -4
  51. package/src/SafeCheckpointTracking.res.mjs +1 -1
  52. package/src/StagedRows.res +106 -0
  53. package/src/StagedRows.res.mjs +102 -0
  54. package/src/Staging.res +32 -14
  55. package/src/Staging.res.mjs +17 -20
  56. package/src/Storage.res +278 -973
  57. package/src/Storage.res.mjs +218 -720
  58. package/src/Supervisor.res +75 -56
  59. package/src/Supervisor.res.mjs +55 -26
  60. package/src/SyncWrites.res +24 -18
  61. package/src/SyncWrites.res.mjs +11 -11
  62. package/src/TestIndexer.res +22 -27
  63. package/src/TestIndexer.res.mjs +20 -17
  64. package/src/Throttler.res +15 -8
  65. package/src/Throttler.res.mjs +9 -6
  66. package/src/Throttler.resi +1 -1
  67. package/src/UserContext.res +13 -4
  68. package/src/UserContext.res.mjs +5 -5
  69. package/src/Utils.res +0 -6
  70. package/src/Utils.res.mjs +0 -5
  71. package/src/Writing.res +0 -1
  72. package/src/Writing.res.mjs +1 -1
  73. package/src/bindings/ClickHouse.res +0 -322
  74. package/src/bindings/ClickHouse.res.mjs +0 -338
  75. package/src/bindings/StorageClient.res +107 -174
  76. package/src/bindings/StorageClient.res.mjs +19 -8
  77. package/src/bindings/Vitest.res +0 -26
  78. package/src/bindings/Vitest.res.mjs +0 -3
  79. package/src/db/Table.res +24 -150
  80. package/src/db/Table.res.mjs +38 -272
  81. package/src/sources/ChainSources.res +2 -0
  82. package/src/sources/ChainSources.res.mjs +2 -2
  83. package/src/sources/EvmChain.res +3 -0
  84. package/src/sources/EvmChain.res.mjs +4 -2
  85. package/src/sources/EvmHyperSyncSource.res +2 -2
  86. package/src/sources/EvmHyperSyncSource.res.mjs +1 -1
  87. package/src/sources/EvmRpcClient.res +13 -3
  88. package/src/sources/EvmRpcClient.res.mjs +4 -3
  89. package/src/sources/EvmRpcWs.res +4 -3
  90. package/src/sources/EvmRpcWs.res.mjs +2 -2
  91. package/src/sources/HeightFeed.res +31 -10
  92. package/src/sources/HeightFeed.res.mjs +10 -6
  93. package/src/sources/HeightStream.res +32 -17
  94. package/src/sources/HeightStream.res.mjs +10 -10
  95. package/src/sources/HyperSyncSSE.res +4 -6
  96. package/src/sources/HyperSyncSSE.res.mjs +2 -2
  97. package/src/sources/RpcSource.res +10 -1
  98. package/src/sources/RpcSource.res.mjs +4 -3
  99. package/src/sources/Source.res +3 -0
  100. package/src/sources/SourceManager.res +85 -104
  101. package/src/sources/SourceManager.res.mjs +18 -37
  102. package/src/sources/SourceManager.resi +3 -5
  103. package/src/sources/StartBlockResolver.res +1 -0
  104. package/src/sources/StartBlockResolver.res.mjs +4 -3
  105. package/src/sources/SvmHyperSyncSource.res +2 -2
  106. package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
  107. package/src/subgraph/graph-ts.ts +87 -28
  108. package/src/subgraph/runtime.ts +0 -1
  109. package/src/subgraph/scope.ts +0 -1
  110. package/svm.schema.json +3 -3
  111. package/src/PgWriting.res +0 -36
  112. package/src/PgWriting.res.mjs +0 -34
  113. package/src/db/IndexDefinition.res +0 -47
  114. package/src/db/IndexDefinition.res.mjs +0 -60
@@ -7,7 +7,6 @@ import * as Config from "./Config.res.mjs";
7
7
  import * as Logger from "./Logger.res.mjs";
8
8
  import * as ChainId from "./ChainId.res.mjs";
9
9
  import * as ChainMap from "./ChainMap.res.mjs";
10
- import * as EntityId from "./EntityId.res.mjs";
11
10
  import * as Frontier from "./db/Frontier.res.mjs";
12
11
  import * as Internal from "./Internal.res.mjs";
13
12
  import * as ChainState from "./ChainState.res.mjs";
@@ -39,11 +38,12 @@ function renderRows(rows, config) {
39
38
  return AddressRows.render(rows, config.ecosystem.name, !config.lowercaseAddresses);
40
39
  }
41
40
 
42
- function rowKey(scope, entityId) {
41
+ function rowKey(table, scope, entityId) {
42
+ let entityKey = table.entityIdToKey(entityId);
43
43
  if (scope === "crossChain") {
44
- return EntityId.toKey(entityId);
44
+ return entityKey;
45
45
  } else {
46
- return ChainId.toString(scope) + `|` + EntityId.toKey(entityId);
46
+ return ChainId.toString(scope) + `|` + entityKey;
47
47
  }
48
48
  }
49
49
 
@@ -126,12 +126,12 @@ function handleWriteBatch(state, config, updatedEntities, registeredAddresses, c
126
126
  let entity = change.entity;
127
127
  let match = Internal.chainScopeChainId(scope);
128
128
  let storedEntity = chainIdField !== undefined && match !== undefined ? Internal.stampChainId(entity, chainIdField.fieldName, Primitive_option.valFromOption(match)) : entity;
129
- entityDict[rowKey(scope, change.entityId)] = storedEntity;
129
+ entityDict[rowKey(entityConfig.table, scope, change.entityId)] = storedEntity;
130
130
  entityChangeFor(change.checkpointId).sets.push(entity);
131
131
  return;
132
132
  }
133
133
  let entityId = change.entityId;
134
- Stdlib_Dict.$$delete(entityDict, rowKey(scope, entityId));
134
+ Stdlib_Dict.$$delete(entityDict, rowKey(entityConfig.table, scope, entityId));
135
135
  entityChangeFor(change.checkpointId).deleted.push(entityId);
136
136
  };
137
137
  param.changes.forEach(processChange);
@@ -304,11 +304,14 @@ function getEntityFromState(state, entityConfig, entityId, methodName) {
304
304
  Stdlib_JsError.throwWithMessage(`Cannot call ` + entityConfig.name + `.` + methodName + `() while indexer.process() is running. ` + "Wait for process() to complete before accessing entities directly.");
305
305
  }
306
306
  let entityDict = Stdlib_Option.getOr(state.entities[entityConfig.name], {});
307
+ let match = entityConfig.table;
308
+ let entityIdToKey = match.entityIdToKey;
309
+ let key = entityIdToKey(entityId);
307
310
  let field = Table.getChainIdField(entityConfig.table);
308
311
  if (field === undefined) {
309
- return Stdlib_Option.map(entityDict[entityId], copyEntity);
312
+ return Stdlib_Option.map(entityDict[key], copyEntity);
310
313
  }
311
- let matches = Object.values(entityDict).filter(entity => entity.id === entityId);
314
+ let matches = Object.values(entityDict).filter(entity => entityIdToKey(entity.id) === key);
312
315
  let len = matches.length;
313
316
  if (len !== 1) {
314
317
  if (len === 0) {
@@ -358,7 +361,7 @@ function makeEntitySet(state, entityConfig) {
358
361
  } else {
359
362
  scope = "crossChain";
360
363
  }
361
- entityDict[rowKey(scope, entity.id)] = Utils.Dict.shallowCopy(entity);
364
+ entityDict[rowKey(entityConfig.table, scope, entity.id)] = Utils.Dict.shallowCopy(entity);
362
365
  };
363
366
  }
364
367
 
@@ -388,23 +391,23 @@ function makeInMemoryStorage(state) {
388
391
  name: "test-inmemory",
389
392
  entityStoreName: param => "test-inmemory",
390
393
  holding: async () => "Initialized",
391
- initialize: async (param, param$1, param$2, param$3, param$4) => Stdlib_JsError.throwWithMessage("TestIndexer: initialize should not be called; the initial state is derived from config."),
394
+ initialize: async (param, param$1, param$2) => Stdlib_JsError.throwWithMessage("TestIndexer: initialize should not be called; the initial state is derived from config."),
392
395
  readStoredConfig: async () => Stdlib_JsError.throwWithMessage("TestIndexer: readStoredConfig should not be called; the initial state is derived from config."),
393
- addChain: async (param, param$1, param$2) => Stdlib_JsError.throwWithMessage("TestIndexer: addChain should not be called; the initial state is derived from config."),
394
- resumeInitialState: async (param, param$1, param$2) => Stdlib_JsError.throwWithMessage("TestIndexer: resumeInitialState should not be called; the initial state is derived from config."),
396
+ addChain: async (param, param$1) => Stdlib_JsError.throwWithMessage("TestIndexer: addChain should not be called; the initial state is derived from config."),
397
+ resumeInitialState: async (param, param$1) => Stdlib_JsError.throwWithMessage("TestIndexer: resumeInitialState should not be called; the initial state is derived from config."),
395
398
  loadOrThrow: async (filter, table) => handleLoad(state, table.tableName, filter),
396
399
  ensureQueryIndexes: async (param, param$1, param$2) => {},
397
- ensureSchemaIndexes: async (param, param$1) => {},
398
- finalizeBackfill: async (param, param$1, param$2) => {},
400
+ ensureSchemaIndexes: async param => {},
401
+ finalizeBackfill: async (param, param$1) => {},
399
402
  dumpEffectCache: async () => {},
400
403
  reset: async () => {},
401
404
  setChainMeta: async param => {},
402
405
  pruneStaleCheckpoints: async param => {},
403
406
  pruneStaleEntityHistory: async (param, param$1) => {},
404
- getRollbackTargetCheckpoint: async (param, param$1, param$2) => Stdlib_JsError.throwWithMessage("TestIndexer: Rollback is not supported. The runner forces rollbackOnReorg off, so this should be unreachable."),
407
+ getRollbackTargetCheckpoint: async (param, param$1) => Stdlib_JsError.throwWithMessage("TestIndexer: Rollback is not supported. The runner forces rollbackOnReorg off, so this should be unreachable."),
405
408
  getRollbackProgressDiff: async param => Stdlib_JsError.throwWithMessage("TestIndexer: Rollback is not supported. The runner forces rollbackOnReorg off, so this should be unreachable."),
406
409
  getRollbackData: async (param, param$1) => Stdlib_JsError.throwWithMessage("TestIndexer: Rollback is not supported. The runner forces rollbackOnReorg off, so this should be unreachable."),
407
- writeBatch: async (batch, param, config, param$1, param$2, updatedEntities, registeredAddresses, param$3, param$4) => handleWriteBatch(state, config, updatedEntities, registeredAddresses, batch.checkpointIds, batch.checkpointChainIds, batch.checkpointBlockNumbers, batch.checkpointEventsProcessed),
410
+ writeBatch: async (batch, param, config, param$1, updatedEntities, registeredAddresses, param$2, param$3) => handleWriteBatch(state, config, updatedEntities, registeredAddresses, batch.checkpointIds, batch.checkpointChainIds, batch.checkpointBlockNumbers, batch.checkpointEventsProcessed),
408
411
  close: async () => {}
409
412
  };
410
413
  }
@@ -648,7 +651,7 @@ function createTestIndexer() {
648
651
  let indexerState = IndexerState.makeFromDbState(runConfig, logger$1, persistence, initialState, registrationsByChainId, undefined, undefined, exitAfterFirstEventBlock, undefined, undefined, undefined, errHandler => {
649
652
  ErrorHandling.log(errHandler);
650
653
  reject(ErrorHandling.toExn(errHandler));
651
- }, () => resolve());
654
+ }, () => resolve(), undefined);
652
655
  indexerStateRef.contents = Primitive_option.some(indexerState);
653
656
  IndexerLoop.start(indexerState);
654
657
  });
package/src/Throttler.res CHANGED
@@ -5,27 +5,30 @@ type t = {
5
5
  mutable scheduled: option<unit => promise<unit>>,
6
6
  intervalMillis: float,
7
7
  logger: Logger.t,
8
+ clock: Clock.t,
8
9
  }
9
10
 
10
- let make = (~intervalMillis: int, ~logger) => {
11
- lastRunTimeMillis: 0.,
11
+ let make = (~intervalMillis: int, ~logger, ~clock=Clock.real) => {
12
+ // A clock reads from its own origin, which the first run must not wait on.
13
+ lastRunTimeMillis: -.(intervalMillis->Int.toFloat),
12
14
  isRunning: false,
13
15
  isAwaitingInterval: false,
14
16
  scheduled: None,
15
17
  intervalMillis: intervalMillis->Int.toFloat,
16
18
  logger,
19
+ clock,
17
20
  }
18
21
 
19
22
  let rec startInternal = (throttler: t) => {
20
23
  switch throttler {
21
24
  | {scheduled: Some(fn), isRunning: false, isAwaitingInterval: false} =>
22
- let timeSinceLastRun = Date.now() -. throttler.lastRunTimeMillis
25
+ let timeSinceLastRun = throttler.clock.now() -. throttler.lastRunTimeMillis
23
26
 
24
27
  //Only execute if we are passed the interval
25
28
  if timeSinceLastRun >= throttler.intervalMillis {
26
29
  throttler.isRunning = true
27
30
  throttler.scheduled = None
28
- throttler.lastRunTimeMillis = Date.now()
31
+ throttler.lastRunTimeMillis = throttler.clock.now()
29
32
 
30
33
  // Defer off the schedule call so work queued before it (e.g. a batch) runs first.
31
34
  NodeJs.setImmediate(() => {
@@ -45,10 +48,14 @@ let rec startInternal = (throttler: t) => {
45
48
  } else {
46
49
  //Store isAwaitingInterval in state so that timers don't continuously get created
47
50
  throttler.isAwaitingInterval = true
48
- let _ = setTimeout(() => {
49
- throttler.isAwaitingInterval = false
50
- throttler->startInternal
51
- }, Int.fromFloat(throttler.intervalMillis -. timeSinceLastRun))
51
+ let _ = throttler.clock.setTimeout(
52
+ ~label="throttled write",
53
+ () => {
54
+ throttler.isAwaitingInterval = false
55
+ throttler->startInternal
56
+ },
57
+ Int.fromFloat(throttler.intervalMillis -. timeSinceLastRun),
58
+ )
52
59
  }
53
60
  | _ => ()
54
61
  }
@@ -1,16 +1,19 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Clock from "./Clock.res.mjs";
3
4
  import * as Logger from "./Logger.res.mjs";
4
5
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
5
6
 
6
- function make(intervalMillis, logger) {
7
+ function make(intervalMillis, logger, clockOpt) {
8
+ let clock = clockOpt !== undefined ? clockOpt : Clock.real;
7
9
  return {
8
- lastRunTimeMillis: 0,
10
+ lastRunTimeMillis: - intervalMillis,
9
11
  isRunning: false,
10
12
  isAwaitingInterval: false,
11
13
  scheduled: undefined,
12
14
  intervalMillis: intervalMillis,
13
- logger: logger
15
+ logger: logger,
16
+ clock: clock
14
17
  };
15
18
  }
16
19
 
@@ -27,11 +30,11 @@ function startInternal(throttler) {
27
30
  if (fn === undefined) {
28
31
  return;
29
32
  }
30
- let timeSinceLastRun = Date.now() - throttler.lastRunTimeMillis;
33
+ let timeSinceLastRun = throttler.clock.now() - throttler.lastRunTimeMillis;
31
34
  if (timeSinceLastRun >= throttler.intervalMillis) {
32
35
  throttler.isRunning = true;
33
36
  throttler.scheduled = undefined;
34
- throttler.lastRunTimeMillis = Date.now();
37
+ throttler.lastRunTimeMillis = throttler.clock.now();
35
38
  setImmediate(() => {
36
39
  (async () => {
37
40
  try {
@@ -46,7 +49,7 @@ function startInternal(throttler) {
46
49
  });
47
50
  } else {
48
51
  throttler.isAwaitingInterval = true;
49
- setTimeout(() => {
52
+ throttler.clock.setTimeout("throttled write", () => {
50
53
  throttler.isAwaitingInterval = false;
51
54
  startInternal(throttler);
52
55
  }, throttler.intervalMillis - timeSinceLastRun | 0);
@@ -15,7 +15,7 @@ Does NOT queue scheduled functions but rather overwrites them
15
15
  The logger will be used to log any errors that occur in the scheduled
16
16
  functions.
17
17
  */
18
- let make: (~intervalMillis: int, ~logger: Logger.t) => t
18
+ let make: (~intervalMillis: int, ~logger: Logger.t, ~clock: Clock.t=?) => t
19
19
 
20
20
  /**
21
21
  Schedules a function to be run on a throttler, overwriting any
@@ -390,11 +390,13 @@ let makeEntityContext = (params: params, ~entityConfig: Internal.entityConfig) =
390
390
  let run = currentRunOrThrow(~prop)
391
391
  let sync = run->syncOrThrow(~prop=`${prop}.getSync`)
392
392
  let scope = run->scopeOf
393
+ // The lookahead keys an entity as its writes do, a Bytes id by its hex.
394
+ let entityKey = entityConfig.table.entityIdToKey(entityId->EntityId.unsafeOfString)
393
395
  switch sync.writes->SyncWrites.getById(~entityConfig, ~entityId) {
394
396
  | Some(entity) => entity
395
397
  | None =>
396
398
  switch run.isPreload
397
- ? PreloadLookahead.overlayGet(~item=run.item, ~entityName, ~scope, ~entityId)
399
+ ? PreloadLookahead.overlayGet(~item=run.item, ~entityName, ~scope, ~entityId=entityKey)
398
400
  : None {
399
401
  | Some(entity) => entity
400
402
  | None =>
@@ -406,7 +408,12 @@ let makeEntityContext = (params: params, ~entityConfig: Internal.entityConfig) =
406
408
  ) {
407
409
  | Some(entity) =>
408
410
  if run.isPreload && entity->Option.isNone {
409
- PreloadLookahead.recordAbsent(~item=run.item, ~entityName, ~scope, ~entityId)
411
+ PreloadLookahead.recordAbsent(
412
+ ~item=run.item,
413
+ ~entityName,
414
+ ~scope,
415
+ ~entityId=entityKey,
416
+ )
410
417
  }
411
418
  entity
412
419
  | None =>
@@ -464,7 +471,9 @@ let makeEntityContext = (params: params, ~entityConfig: Internal.entityConfig) =
464
471
  | None =>
465
472
  let inMemTable =
466
473
  params.indexerState->InMemoryStore.getInMemTable(~entityConfig, ~scope=run->scopeOf)
467
- switch inMemTable.latestEntityChangeById->Utils.Dict.dangerouslyGetNonOption(entityId) {
474
+ switch inMemTable.latestEntityChangeById->Utils.Dict.dangerouslyGetNonOption(
475
+ inMemTable.entityIdToKey(entityId->EntityId.unsafeOfString),
476
+ ) {
468
477
  | Some(change) if change->Change.getCheckpointId == run.checkpointId =>
469
478
  change->InMemoryTable.Entity.mapChangeToEntity
470
479
  | _ => None
@@ -527,7 +536,7 @@ let rec runSyncRound = async (params: params, sync: syncRun, fn: unit => unit, ~
527
536
  ~item=run.item,
528
537
  ~entityName=entityConfig.name,
529
538
  ~scope,
530
- ~entityId=change->Change.getEntityId->EntityId.toKey,
539
+ ~entityId=entityConfig.table.entityIdToKey(change->Change.getEntityId),
531
540
  ~entity=change->InMemoryTable.Entity.mapChangeToEntity,
532
541
  )
533
542
  )
@@ -4,7 +4,6 @@ import * as Env from "./Env.res.mjs";
4
4
  import * as Utils from "./Utils.res.mjs";
5
5
  import * as Logger from "./Logger.res.mjs";
6
6
  import * as ChainId from "./ChainId.res.mjs";
7
- import * as EntityId from "./EntityId.res.mjs";
8
7
  import * as Internal from "./Internal.res.mjs";
9
8
  import * as RunScope from "./RunScope.res.mjs";
10
9
  import * as LoadLayer from "./LoadLayer.res.mjs";
@@ -275,11 +274,12 @@ function makeEntityContext(params, entityConfig) {
275
274
  let run = currentRunOrThrow(prop);
276
275
  let sync = syncOrThrow(run, prop + `.getSync`);
277
276
  let scope = scopeOf(run);
277
+ let entityKey = entityConfig.table.entityIdToKey(entityId);
278
278
  let entity = SyncWrites.getById(sync.writes, entityConfig, entityId);
279
279
  if (entity !== undefined) {
280
280
  return Primitive_option.valFromOption(entity);
281
281
  }
282
- let entity$1 = run.isPreload ? PreloadLookahead.overlayGet(run.item, entityName, scope, entityId) : undefined;
282
+ let entity$1 = run.isPreload ? PreloadLookahead.overlayGet(run.item, entityName, scope, entityKey) : undefined;
283
283
  if (entity$1 !== undefined) {
284
284
  return Primitive_option.valFromOption(entity$1);
285
285
  }
@@ -289,7 +289,7 @@ function makeEntityContext(params, entityConfig) {
289
289
  }
290
290
  let entity$3 = Primitive_option.valFromOption(entity$2);
291
291
  if (run.isPreload && Stdlib_Option.isNone(entity$3)) {
292
- PreloadLookahead.recordAbsent(run.item, entityName, scope, entityId);
292
+ PreloadLookahead.recordAbsent(run.item, entityName, scope, entityKey);
293
293
  }
294
294
  return entity$3;
295
295
  };
@@ -313,7 +313,7 @@ function makeEntityContext(params, entityConfig) {
313
313
  return Primitive_option.valFromOption(entity);
314
314
  }
315
315
  let inMemTable = InMemoryStore.getInMemTable(params.indexerState, entityConfig, scopeOf(run));
316
- let change = inMemTable.latestEntityChangeById[entityId];
316
+ let change = inMemTable.latestEntityChangeById[inMemTable.entityIdToKey(entityId)];
317
317
  if (change !== undefined && change.checkpointId === run.checkpointId) {
318
318
  return InMemoryTable.Entity.mapChangeToEntity(change);
319
319
  }
@@ -361,7 +361,7 @@ async function runSyncRound(params, sync, fn, round) {
361
361
  let match = sync.status;
362
362
  if (typeof match !== "object" && sync.speculated <= 0) {
363
363
  if (run.isPreload) {
364
- SyncWrites.forEachChange(writes, (entityConfig, scope, change) => PreloadLookahead.overlaySet(run.item, entityConfig.name, scope, EntityId.toKey(change.entityId), InMemoryTable.Entity.mapChangeToEntity(change)));
364
+ SyncWrites.forEachChange(writes, (entityConfig, scope, change) => PreloadLookahead.overlaySet(run.item, entityConfig.name, scope, entityConfig.table.entityIdToKey(change.entityId), InMemoryTable.Entity.mapChangeToEntity(change)));
365
365
  } else {
366
366
  SyncWrites.commit(writes, params.indexerState);
367
367
  }
package/src/Utils.res CHANGED
@@ -10,12 +10,6 @@ external toMethod: 'a => 'a = "%unsafe_to_method"
10
10
 
11
11
  @val external importPath: string => promise<unknown> = "import"
12
12
 
13
- // Half the delay fixed, half spread across it. Every indexer pointed at one
14
- // provider loses its stream, or gives up on a quiet chain, in the same instant
15
- // that provider blinks, and putting them all back on the same schedule is how a
16
- // blip becomes a stampede.
17
- let jitter = delay => delay / 2 + (Math.random() *. (delay / 2)->Int.toFloat)->Float.toInt
18
-
19
13
  // Clearing a pending timer and forgetting it are one action. A ref left holding
20
14
  // a spent id reads as a timer still pending, and the next clear looks like it
21
15
  // did something.
package/src/Utils.res.mjs CHANGED
@@ -14,10 +14,6 @@ import * as Primitive_string from "@rescript/runtime/lib/es6/Primitive_string.js
14
14
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
15
15
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
16
16
 
17
- function jitter(delay) {
18
- return (delay / 2 | 0) + (Math.random() * (delay / 2 | 0) | 0) | 0;
19
- }
20
-
21
17
  function clearTimeoutRef(timeoutId) {
22
18
  let id = timeoutId.contents;
23
19
  if (id !== undefined) {
@@ -824,7 +820,6 @@ function replaceLoneSurrogateEscapes(json) {
824
820
  let maxBackoffExponent = 20;
825
821
 
826
822
  export {
827
- jitter,
828
823
  clearTimeoutRef,
829
824
  maxBackoffExponent,
830
825
  expBackoff,
package/src/Writing.res CHANGED
@@ -153,7 +153,6 @@ let runOneWrite = async (state: IndexerState.t) => {
153
153
  ~batch,
154
154
  ~rollback,
155
155
  ~config,
156
- ~allEntities=persistence.allEntities,
157
156
  ~updatedEntities,
158
157
  ~registeredAddresses,
159
158
  ~updatedEffectsCache,
@@ -121,7 +121,7 @@ async function runOneWrite(state) {
121
121
  });
122
122
  let pruneTargets = PruneStaleHistory.select(state, writtenEntityNames, Stdlib_Option.isSome(rollback));
123
123
  await Promise.all([
124
- persistence.storage.writeBatch(batch, rollback, config, persistence.allEntities, updatedEffectsCache, updatedEntities, registeredAddresses, chainMetaData, (storage, timeSeconds) => IndexerState.recordStorageWrite(state, storage, timeSeconds)),
124
+ persistence.storage.writeBatch(batch, rollback, config, updatedEffectsCache, updatedEntities, registeredAddresses, chainMetaData, (storage, timeSeconds) => IndexerState.recordStorageWrite(state, storage, timeSeconds)),
125
125
  PruneStaleHistory.runConcurrent(state, pruneTargets)
126
126
  ]);
127
127
  IndexerState.markCommitted(state, writtenFrontier);