envio 3.5.0-alpha.2 → 3.5.0-rc.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 (129) hide show
  1. package/package.json +6 -6
  2. package/src/Batch.res +8 -8
  3. package/src/Batch.res.mjs +4 -3
  4. package/src/BatchProcessing.res +24 -0
  5. package/src/BatchProcessing.res.mjs +12 -0
  6. package/src/ChainFetching.res +20 -19
  7. package/src/ChainFetching.res.mjs +14 -14
  8. package/src/ChainId.res +58 -0
  9. package/src/ChainId.res.mjs +49 -0
  10. package/src/ChainId.resi +27 -0
  11. package/src/ChainMap.res +12 -26
  12. package/src/ChainMap.res.mjs +5 -41
  13. package/src/ChainMap.resi +5 -20
  14. package/src/ChainMetadata.res +1 -1
  15. package/src/ChainMetadata.res.mjs +3 -2
  16. package/src/ChainState.res +45 -24
  17. package/src/ChainState.res.mjs +40 -16
  18. package/src/ChainState.resi +3 -1
  19. package/src/Config.res +43 -26
  20. package/src/Config.res.mjs +19 -16
  21. package/src/ContractRegisterContext.res +1 -1
  22. package/src/ContractRegisterContext.res.mjs +1 -1
  23. package/src/Core.res +1 -0
  24. package/src/CrossChainState.res +90 -22
  25. package/src/CrossChainState.res.mjs +55 -16
  26. package/src/CrossChainState.resi +5 -1
  27. package/src/Env.res +0 -3
  28. package/src/Env.res.mjs +0 -3
  29. package/src/EventConfigBuilder.res +1 -1
  30. package/src/EventProcessing.res +4 -4
  31. package/src/EventProcessing.res.mjs +5 -5
  32. package/src/FetchState.res +489 -153
  33. package/src/FetchState.res.mjs +399 -129
  34. package/src/FinalizeBackfill.res +61 -0
  35. package/src/FinalizeBackfill.res.mjs +44 -0
  36. package/src/HandlerRegister.res +8 -8
  37. package/src/HandlerRegister.res.mjs +5 -4
  38. package/src/HandlerRegister.resi +1 -1
  39. package/src/InMemoryStore.res +4 -0
  40. package/src/InMemoryStore.res.mjs +1 -1
  41. package/src/InMemoryTable.res +15 -15
  42. package/src/InMemoryTable.res.mjs +14 -14
  43. package/src/IndexerLoop.res +9 -2
  44. package/src/IndexerLoop.res.mjs +8 -1
  45. package/src/IndexerState.res +52 -23
  46. package/src/IndexerState.res.mjs +52 -14
  47. package/src/IndexerState.resi +11 -6
  48. package/src/Internal.res +19 -17
  49. package/src/Internal.res.mjs +18 -9
  50. package/src/LoadLayer.res +10 -2
  51. package/src/LoadLayer.res.mjs +3 -1
  52. package/src/LogSelection.res +2 -2
  53. package/src/Main.res +7 -11
  54. package/src/Main.res.mjs +4 -6
  55. package/src/Metrics.res +6 -6
  56. package/src/Metrics.res.mjs +4 -3
  57. package/src/Persistence.res +23 -4
  58. package/src/PgStorage.res +447 -100
  59. package/src/PgStorage.res.mjs +285 -99
  60. package/src/RawEvent.res +1 -2
  61. package/src/RawEvent.res.mjs +1 -1
  62. package/src/Rollback.res +18 -20
  63. package/src/Rollback.res.mjs +9 -9
  64. package/src/RollbackCommit.res +2 -2
  65. package/src/RollbackCommit.res.mjs +3 -3
  66. package/src/SafeCheckpointTracking.res +2 -2
  67. package/src/SimulateDeadInputTracker.res +17 -21
  68. package/src/SimulateDeadInputTracker.res.mjs +9 -8
  69. package/src/SimulateItems.res +8 -10
  70. package/src/SimulateItems.res.mjs +9 -10
  71. package/src/Sink.res +2 -2
  72. package/src/Sink.res.mjs +3 -2
  73. package/src/TestIndexer.res +14 -14
  74. package/src/TestIndexer.res.mjs +16 -10
  75. package/src/UserContext.res +2 -2
  76. package/src/UserContext.res.mjs +2 -1
  77. package/src/Utils.res +0 -4
  78. package/src/Utils.res.mjs +1 -6
  79. package/src/bindings/ClickHouse.res +20 -2
  80. package/src/bindings/ClickHouse.res.mjs +25 -14
  81. package/src/db/EntityFilter.res +0 -4
  82. package/src/db/EntityFilter.res.mjs +1 -8
  83. package/src/db/EntityHistory.res +1 -1
  84. package/src/db/IndexCatalog.res +248 -0
  85. package/src/db/IndexCatalog.res.mjs +222 -0
  86. package/src/db/IndexDefinition.res +131 -0
  87. package/src/db/IndexDefinition.res.mjs +138 -0
  88. package/src/db/IndexManager.res +145 -0
  89. package/src/db/IndexManager.res.mjs +130 -0
  90. package/src/db/InternalTable.res +54 -23
  91. package/src/db/InternalTable.res.mjs +38 -23
  92. package/src/db/Table.res +24 -14
  93. package/src/db/Table.res.mjs +21 -16
  94. package/src/sources/AddressSet.res +5 -4
  95. package/src/sources/AddressStore.res +25 -14
  96. package/src/sources/AddressStore.res.mjs +10 -12
  97. package/src/sources/Evm.res +2 -2
  98. package/src/sources/Evm.res.mjs +1 -1
  99. package/src/sources/EvmChain.res +3 -3
  100. package/src/sources/EvmChain.res.mjs +3 -3
  101. package/src/sources/EvmHyperSyncSource.res +7 -7
  102. package/src/sources/EvmHyperSyncSource.res.mjs +6 -6
  103. package/src/sources/Fuel.res +2 -2
  104. package/src/sources/Fuel.res.mjs +1 -1
  105. package/src/sources/FuelHyperSyncClient.res +3 -0
  106. package/src/sources/FuelHyperSyncClient.res.mjs +1 -0
  107. package/src/sources/FuelHyperSyncSource.res +5 -7
  108. package/src/sources/FuelHyperSyncSource.res.mjs +5 -5
  109. package/src/sources/HyperSync.resi +2 -2
  110. package/src/sources/HyperSyncClient.res +5 -0
  111. package/src/sources/HyperSyncClient.res.mjs +1 -0
  112. package/src/sources/RpcSource.res +13 -14
  113. package/src/sources/RpcSource.res.mjs +13 -12
  114. package/src/sources/SimulateSource.res +42 -15
  115. package/src/sources/SimulateSource.res.mjs +27 -9
  116. package/src/sources/Source.res +1 -5
  117. package/src/sources/SourceManager.res +12 -12
  118. package/src/sources/SourceManager.res.mjs +11 -10
  119. package/src/sources/SourceManager.resi +2 -2
  120. package/src/sources/Svm.res +4 -5
  121. package/src/sources/Svm.res.mjs +5 -4
  122. package/src/sources/SvmHyperSyncClient.res +3 -0
  123. package/src/sources/SvmHyperSyncClient.res.mjs +1 -0
  124. package/src/sources/SvmHyperSyncSource.res +4 -4
  125. package/src/sources/SvmHyperSyncSource.res.mjs +3 -3
  126. package/src/tui/Tui.res +1 -1
  127. package/src/tui/Tui.res.mjs +2 -1
  128. package/src/tui/components/CustomHooks.res +5 -4
  129. package/src/tui/components/CustomHooks.res.mjs +4 -2
@@ -3,6 +3,7 @@
3
3
  import * as Rpc from "./Rpc.res.mjs";
4
4
  import * as Rest from "../vendored/Rest.res.mjs";
5
5
  import * as Utils from "../Utils.res.mjs";
6
+ import * as ChainId from "../ChainId.res.mjs";
6
7
  import * as Logging from "../Logging.res.mjs";
7
8
  import * as Internal from "../Internal.res.mjs";
8
9
  import * as BlockStore from "./BlockStore.res.mjs";
@@ -47,7 +48,7 @@ function make(logger) {
47
48
  return Logging.createChildFrom(logger, {
48
49
  program: eventItem.onEventRegistration.eventConfig.contractName,
49
50
  instruction: eventItem.onEventRegistration.eventConfig.name,
50
- chainId: eventItem.chain,
51
+ chainId: eventItem.chainId,
51
52
  slot: eventItem.blockNumber,
52
53
  programId: instruction.programId
53
54
  });
@@ -66,16 +67,16 @@ let GetFinalizedSlot = {
66
67
  route: route
67
68
  };
68
69
 
69
- function makeRPCSource(chain, rpc, sourceForOpt) {
70
+ function makeRPCSource(chainId, rpc, sourceForOpt) {
70
71
  let sourceFor = sourceForOpt !== undefined ? sourceForOpt : "Sync";
71
72
  let client = Rest.client(rpc, undefined);
72
73
  let host = Utils.Url.getHostFromUrl(rpc);
73
- let urlHost = host !== undefined ? host : Stdlib_JsError.throwWithMessage(`The RPC url for chain ` + chain.toString() + ` is in incorrect format. The RPC url needs to start with either http:// or https://`);
74
+ let urlHost = host !== undefined ? host : Stdlib_JsError.throwWithMessage(`The RPC url for chain ` + ChainId.toString(chainId) + ` is in incorrect format. The RPC url needs to start with either http:// or https://`);
74
75
  let name = `RPC (` + urlHost + `)`;
75
76
  return {
76
77
  name: name,
77
78
  sourceFor: sourceFor,
78
- chain: chain,
79
+ chainId: chainId,
79
80
  poweredByHyperSync: false,
80
81
  pollingInterval: 10000,
81
82
  getBlockHashes: (param, param$1) => Stdlib_JsError.throwWithMessage("Svm does not support getting block hashes"),
@@ -25,6 +25,8 @@ module Registration = {
25
25
  contractName: string,
26
26
  programId: string,
27
27
  isWildcard: bool,
28
+ // Earliest slot this registration accepts; `None` is unrestricted.
29
+ startBlock: option<int>,
28
30
  discriminator?: string,
29
31
  discriminatorByteLen: int,
30
32
  isInner?: bool,
@@ -52,6 +54,7 @@ module Registration = {
52
54
  contractName: eventConfig.contractName,
53
55
  programId: eventConfig.programId->SvmTypes.Pubkey.toString,
54
56
  isWildcard: reg.isWildcard,
57
+ startBlock: reg.startBlock,
55
58
  discriminator: ?eventConfig.discriminator,
56
59
  discriminatorByteLen: eventConfig.discriminatorByteLen,
57
60
  isInner: ?eventConfig.isInner,
@@ -18,6 +18,7 @@ function fromOnEventRegistrations(onEventRegistrations) {
18
18
  contractName: eventConfig.contractName,
19
19
  programId: eventConfig.programId,
20
20
  isWildcard: reg.isWildcard,
21
+ startBlock: reg.startBlock,
21
22
  discriminator: eventConfig.discriminator,
22
23
  discriminatorByteLen: eventConfig.discriminatorByteLen,
23
24
  isInner: eventConfig.isInner,
@@ -1,7 +1,7 @@
1
1
  open Source
2
2
 
3
3
  type options = {
4
- chain: ChainMap.Chain.t,
4
+ chainId: ChainId.t,
5
5
  endpointUrl: string,
6
6
  apiToken: option<string>,
7
7
  onEventRegistrations: array<Internal.svmOnEventRegistration>,
@@ -68,7 +68,7 @@ let toSvmInstruction = (
68
68
  }
69
69
 
70
70
  let make = (
71
- {chain, endpointUrl, apiToken, onEventRegistrations, clientTimeoutMillis, addressStore}: options,
71
+ {chainId, endpointUrl, apiToken, onEventRegistrations, clientTimeoutMillis, addressStore}: options,
72
72
  ): t => {
73
73
  let name = "SvmHyperSync"
74
74
 
@@ -159,7 +159,7 @@ let make = (
159
159
  )
160
160
  Internal.Event({
161
161
  onEventRegistration,
162
- chain,
162
+ chainId,
163
163
  blockNumber: item.slot,
164
164
  logIndex: synthLogIndex(
165
165
  ~transactionIndex=item.transactionIndex,
@@ -283,7 +283,7 @@ let make = (
283
283
  {
284
284
  name,
285
285
  sourceFor: Sync,
286
- chain,
286
+ chainId,
287
287
  pollingInterval: 1000,
288
288
  poweredByHyperSync: true,
289
289
  getBlockHashes,
@@ -57,7 +57,7 @@ function toSvmInstruction(item, programName, instructionName) {
57
57
 
58
58
  function make(param) {
59
59
  let onEventRegistrations = param.onEventRegistrations;
60
- let chain = param.chain;
60
+ let chainId = param.chainId;
61
61
  let client = SvmHyperSyncClient.make(param.endpointUrl, param.apiToken, param.clientTimeoutMillis, undefined, undefined, undefined, SvmHyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations), param.addressStore);
62
62
  let getItemsOrThrow = async (fromBlock, toBlock, addressSet, knownHeight, param, selection, itemsTarget, retry, param$1) => {
63
63
  let totalTimeRef = Performance.now();
@@ -113,7 +113,7 @@ function make(param) {
113
113
  return {
114
114
  kind: 0,
115
115
  onEventRegistration: onEventRegistration,
116
- chain: chain,
116
+ chainId: chainId,
117
117
  blockNumber: item.slot,
118
118
  logIndex: synthLogIndex(item.transactionIndex, item.instructionAddress),
119
119
  transactionIndex: item.transactionIndex,
@@ -243,7 +243,7 @@ function make(param) {
243
243
  return {
244
244
  name: "SvmHyperSync",
245
245
  sourceFor: "Sync",
246
- chain: chain,
246
+ chainId: chainId,
247
247
  poweredByHyperSync: true,
248
248
  pollingInterval: 1000,
249
249
  getBlockHashes: getBlockHashes,
package/src/tui/Tui.res CHANGED
@@ -204,7 +204,7 @@ module App = {
204
204
  knownHeight: data.knownHeight,
205
205
  latestFetchedBlockNumber,
206
206
  eventsProcessed: numEventsProcessed,
207
- chainId: (cs->ChainState.chainConfig).id->Int.toString,
207
+ chainId: (cs->ChainState.chainConfig).id->ChainId.toString,
208
208
  progressBlock: committedProgressBlockNumber < data.startBlock
209
209
  ? Some(data.startBlock)
210
210
  : Some(committedProgressBlockNumber),
@@ -4,6 +4,7 @@ import * as Env from "../Env.res.mjs";
4
4
  import * as Ink from "./bindings/Ink.res.mjs";
5
5
  import * as Ink$1 from "ink";
6
6
  import * as React from "react";
7
+ import * as ChainId from "../ChainId.res.mjs";
7
8
  import * as SyncETA from "./components/SyncETA.res.mjs";
8
9
  import * as TuiData from "./components/TuiData.res.mjs";
9
10
  import * as Messages from "./components/Messages.res.mjs";
@@ -255,7 +256,7 @@ function Tui$App(props) {
255
256
  break;
256
257
  }
257
258
  return {
258
- chainId: ChainState.chainConfig(cs).id.toString(),
259
+ chainId: ChainId.toString(ChainState.chainConfig(cs).id),
259
260
  eventsProcessed: numEventsProcessed,
260
261
  progressBlock: committedProgressBlockNumber < data.startBlock ? data.startBlock : committedProgressBlockNumber,
261
262
  bufferBlock: latestFetchedBlockNumber,
@@ -4,16 +4,16 @@ module InitApi = {
4
4
  envioVersion: string,
5
5
  envioApiToken: option<string>,
6
6
  ecosystem: ecosystem,
7
- hyperSyncNetworks: array<int>,
8
- rpcNetworks: array<int>,
7
+ hyperSyncNetworks: array<ChainId.t>,
8
+ rpcNetworks: array<ChainId.t>,
9
9
  }
10
10
 
11
11
  let bodySchema = S.object(s => {
12
12
  envioVersion: s.field("envioVersion", S.string),
13
13
  envioApiToken: s.field("envioApiToken", S.option(S.string)),
14
14
  ecosystem: s.field("ecosystem", S.enum([Evm, Fuel, Svm])),
15
- hyperSyncNetworks: s.field("hyperSyncNetworks", S.array(S.int)),
16
- rpcNetworks: s.field("rpcNetworks", S.array(S.int)),
15
+ hyperSyncNetworks: s.field("hyperSyncNetworks", S.array(ChainId.schema)),
16
+ rpcNetworks: s.field("rpcNetworks", S.array(ChainId.schema)),
17
17
  })
18
18
 
19
19
  let makeBody = (~envioVersion, ~envioApiToken, ~config: Config.t) => {
@@ -28,6 +28,7 @@ module InitApi = {
28
28
  | Config.EvmSourceConfig({hypersync: None}) => false
29
29
  | Config.FuelSourceConfig(_) => true // Fuel always uses HyperFuel
30
30
  | Config.SvmSourceConfig(_) => false
31
+ | Config.SimulateSourceConfig(_) => false
31
32
  | Config.CustomSources(sources) => sources->Array.some(s => s.poweredByHyperSync)
32
33
  }
33
34
  switch usesHyperSync {
@@ -4,6 +4,7 @@ import * as Env from "../../Env.res.mjs";
4
4
  import * as Rest from "../../vendored/Rest.res.mjs";
5
5
  import * as Utils from "../../Utils.res.mjs";
6
6
  import * as React from "react";
7
+ import * as ChainId from "../../ChainId.res.mjs";
7
8
  import * as Logging from "../../Logging.res.mjs";
8
9
  import * as ChainMap from "../../ChainMap.res.mjs";
9
10
  import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
@@ -17,8 +18,8 @@ let bodySchema = S$RescriptSchema.object(s => ({
17
18
  "fuel",
18
19
  "svm"
19
20
  ])),
20
- hyperSyncNetworks: s.f("hyperSyncNetworks", S$RescriptSchema.array(S$RescriptSchema.int)),
21
- rpcNetworks: s.f("rpcNetworks", S$RescriptSchema.array(S$RescriptSchema.int))
21
+ hyperSyncNetworks: s.f("hyperSyncNetworks", S$RescriptSchema.array(ChainId.schema)),
22
+ rpcNetworks: s.f("rpcNetworks", S$RescriptSchema.array(ChainId.schema))
22
23
  }));
23
24
 
24
25
  function makeBody(envioVersion, envioApiToken, config) {
@@ -35,6 +36,7 @@ function makeBody(envioVersion, envioApiToken, config) {
35
36
  usesHyperSync = true;
36
37
  break;
37
38
  case "SvmSourceConfig" :
39
+ case "SimulateSourceConfig" :
38
40
  usesHyperSync = false;
39
41
  break;
40
42
  case "CustomSources" :