envio 3.5.0-alpha.0 → 3.5.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +10 -6
- package/package.json +6 -6
- package/src/BatchProcessing.res +13 -0
- package/src/BatchProcessing.res.mjs +4 -0
- package/src/Bin.res +2 -2
- package/src/ChainFetching.res +5 -5
- package/src/ChainFetching.res.mjs +3 -4
- package/src/ChainState.res +44 -36
- package/src/ChainState.res.mjs +36 -31
- package/src/ChainState.resi +2 -12
- package/src/Change.res +3 -3
- package/src/Config.res +4 -4
- package/src/Config.res.mjs +1 -10
- package/src/Core.res +4 -35
- package/src/Core.res.mjs +1 -31
- package/src/CrossChainState.res +2 -20
- package/src/CrossChainState.res.mjs +2 -6
- package/src/EntityId.res +15 -0
- package/src/EntityId.res.mjs +9 -0
- package/src/Env.res +16 -0
- package/src/Env.res.mjs +6 -0
- package/src/EventConfigBuilder.res +1 -58
- package/src/EventConfigBuilder.res.mjs +1 -33
- package/src/FetchState.res +663 -484
- package/src/FetchState.res.mjs +491 -440
- package/src/HandlerRegister.res +45 -0
- package/src/HandlerRegister.res.mjs +43 -0
- package/src/InMemoryStore.res +11 -4
- package/src/InMemoryTable.res +12 -10
- package/src/InMemoryTable.res.mjs +6 -5
- package/src/IndexerState.res +59 -2
- package/src/IndexerState.res.mjs +48 -3
- package/src/IndexerState.resi +2 -0
- package/src/Internal.res +17 -8
- package/src/LogSelection.res +2 -1
- package/src/Metrics.res +37 -6
- package/src/Metrics.res.mjs +5 -1
- package/src/Persistence.res +1 -1
- package/src/PgStorage.res +55 -22
- package/src/PgStorage.res.mjs +25 -17
- package/src/SimulateItems.res +2 -2
- package/src/TestIndexer.res +6 -5
- package/src/TestIndexer.res.mjs +3 -2
- package/src/UserContext.res +3 -3
- package/src/Writing.res +12 -2
- package/src/Writing.res.mjs +13 -2
- package/src/bindings/ClickHouse.res +5 -3
- package/src/bindings/ClickHouse.res.mjs +2 -5
- package/src/bindings/Vitest.res +22 -1
- package/src/bindings/Vitest.res.mjs +15 -0
- package/src/db/EntityHistory.res +16 -7
- package/src/db/EntityHistory.res.mjs +7 -6
- package/src/db/Table.res +40 -9
- package/src/db/Table.res.mjs +44 -6
- package/src/sources/AddressSet.res +48 -0
- package/src/sources/AddressSet.res.mjs +11 -0
- package/src/sources/AddressStore.res +152 -0
- package/src/sources/AddressStore.res.mjs +97 -0
- package/src/sources/EvmChain.res +3 -0
- package/src/sources/EvmChain.res.mjs +4 -2
- package/src/sources/EvmHyperSyncSource.res +9 -9
- package/src/sources/EvmHyperSyncSource.res.mjs +3 -3
- package/src/sources/EvmRpcClient.res +10 -3
- package/src/sources/EvmRpcClient.res.mjs +3 -3
- package/src/sources/FuelHyperSync.res +4 -3
- package/src/sources/FuelHyperSync.res.mjs +3 -3
- package/src/sources/FuelHyperSync.resi +2 -1
- package/src/sources/FuelHyperSyncClient.res +12 -6
- package/src/sources/FuelHyperSyncClient.res.mjs +2 -2
- package/src/sources/FuelHyperSyncSource.res +7 -4
- package/src/sources/FuelHyperSyncSource.res.mjs +3 -3
- package/src/sources/HyperSync.res +9 -5
- package/src/sources/HyperSync.res.mjs +3 -3
- package/src/sources/HyperSync.resi +3 -2
- package/src/sources/HyperSyncClient.res +24 -10
- package/src/sources/HyperSyncClient.res.mjs +4 -4
- package/src/sources/RpcSource.res +71 -67
- package/src/sources/RpcSource.res.mjs +4 -4
- package/src/sources/SimulateSource.res +26 -11
- package/src/sources/SimulateSource.res.mjs +13 -5
- package/src/sources/Source.res +8 -4
- package/src/sources/SourceManager.res +2 -3
- package/src/sources/SourceManager.res.mjs +2 -3
- package/src/sources/Svm.res +1 -2
- package/src/sources/Svm.res.mjs +1 -1
- package/src/sources/SvmHyperSyncClient.res +14 -4
- package/src/sources/SvmHyperSyncClient.res.mjs +2 -2
- package/src/sources/SvmHyperSyncSource.res +11 -6
- package/src/sources/SvmHyperSyncSource.res.mjs +5 -4
- package/src/IndexingAddresses.res +0 -108
- package/src/IndexingAddresses.res.mjs +0 -101
- package/src/IndexingAddresses.resi +0 -34
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
open Source
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
// Surfaced by HyperSyncClient.getHeight (Rust) when HyperSync rejects the API
|
|
5
4
|
// token. The corrupted-token test feeds the real server error through this
|
|
6
5
|
// check so it can't silently drift away from what getHeightOrThrow guards on.
|
|
@@ -17,6 +16,8 @@ type options = {
|
|
|
17
16
|
serializationFormat: HyperSyncClient.serializationFormat,
|
|
18
17
|
enableQueryCaching: bool,
|
|
19
18
|
logLevel: HyperSyncClient.logLevel,
|
|
19
|
+
// The chain's address index; the client reads it while routing.
|
|
20
|
+
addressStore: AddressStore.t,
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
let make = (
|
|
@@ -30,6 +31,7 @@ let make = (
|
|
|
30
31
|
serializationFormat,
|
|
31
32
|
enableQueryCaching,
|
|
32
33
|
logLevel,
|
|
34
|
+
addressStore,
|
|
33
35
|
}: options,
|
|
34
36
|
): t => {
|
|
35
37
|
let name = "HyperSync"
|
|
@@ -46,13 +48,12 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
46
48
|
~url=endpointUrl,
|
|
47
49
|
~apiToken,
|
|
48
50
|
~httpReqTimeoutMillis=clientTimeoutMillis,
|
|
49
|
-
~eventRegistrations=HyperSyncClient.Registration.fromOnEventRegistrations(
|
|
50
|
-
onEventRegistrations,
|
|
51
|
-
),
|
|
51
|
+
~eventRegistrations=HyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations),
|
|
52
52
|
~enableChecksumAddresses=!lowercaseAddresses,
|
|
53
53
|
~serializationFormat,
|
|
54
54
|
~enableQueryCaching,
|
|
55
55
|
~logLevel,
|
|
56
|
+
~addressStore,
|
|
56
57
|
) {
|
|
57
58
|
| client => client
|
|
58
59
|
| exception exn =>
|
|
@@ -89,8 +90,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
89
90
|
let getItemsOrThrow = async (
|
|
90
91
|
~fromBlock,
|
|
91
92
|
~toBlock,
|
|
92
|
-
~
|
|
93
|
-
~contractNameByAddress as _,
|
|
93
|
+
~addressSet,
|
|
94
94
|
~knownHeight,
|
|
95
95
|
~partitionId as _,
|
|
96
96
|
~selection: FetchState.selection,
|
|
@@ -109,7 +109,8 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
109
109
|
~toBlock,
|
|
110
110
|
~maxNumLogs=itemsTarget,
|
|
111
111
|
~registrationIndexes=selection.onEventRegistrations->Array.map(reg => reg.index),
|
|
112
|
-
~
|
|
112
|
+
~addressSet,
|
|
113
|
+
~clientFilteredContracts=selection.clientFilteredContracts,
|
|
113
114
|
) catch {
|
|
114
115
|
| HyperSync.GetLogs.Error(error) =>
|
|
115
116
|
throw(
|
|
@@ -180,8 +181,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
180
181
|
let getBlock = blockNumber => blocksByNumber->Utils.Map.unsafeGet(blockNumber)
|
|
181
182
|
|
|
182
183
|
pageUnsafe.items->Array.forEach(item => {
|
|
183
|
-
let onEventRegistration =
|
|
184
|
-
onEventRegistrations->Array.getUnsafe(item.onEventRegistrationIndex)
|
|
184
|
+
let onEventRegistration = onEventRegistrations->Array.getUnsafe(item.onEventRegistrationIndex)
|
|
185
185
|
parsedQueueItems
|
|
186
186
|
->Array.push(makeEventBatchQueueItem(item, ~onEventRegistration))
|
|
187
187
|
->ignore
|
|
@@ -28,7 +28,7 @@ Set the ENVIO_API_TOKEN environment variable in your .env file.
|
|
|
28
28
|
Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
29
29
|
let client;
|
|
30
30
|
try {
|
|
31
|
-
client = HyperSyncClient.make(endpointUrl, apiToken$1, param.clientTimeoutMillis, HyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations), !param.lowercaseAddresses, param.serializationFormat, param.enableQueryCaching, undefined, undefined, undefined, param.logLevel);
|
|
31
|
+
client = HyperSyncClient.make(endpointUrl, apiToken$1, param.clientTimeoutMillis, HyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations), !param.lowercaseAddresses, param.serializationFormat, param.enableQueryCaching, undefined, undefined, undefined, param.logLevel, param.addressStore);
|
|
32
32
|
} catch (raw_exn) {
|
|
33
33
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
34
34
|
client = ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate the hypersync client, please double check your ABI", exn);
|
|
@@ -52,12 +52,12 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
|
-
let getItemsOrThrow = async (fromBlock, toBlock,
|
|
55
|
+
let getItemsOrThrow = async (fromBlock, toBlock, addressSet, knownHeight, param, selection, itemsTarget, retry, param$1) => {
|
|
56
56
|
let totalTimeRef = Performance.now();
|
|
57
57
|
let startFetchingBatchTimeRef = Performance.now();
|
|
58
58
|
let pageUnsafe;
|
|
59
59
|
try {
|
|
60
|
-
pageUnsafe = await HyperSync.GetLogs.query(client, fromBlock, toBlock, itemsTarget, selection.onEventRegistrations.map(reg => reg.index),
|
|
60
|
+
pageUnsafe = await HyperSync.GetLogs.query(client, fromBlock, toBlock, itemsTarget, selection.onEventRegistrations.map(reg => reg.index), addressSet, selection.clientFilteredContracts);
|
|
61
61
|
} catch (raw_error) {
|
|
62
62
|
let error = Primitive_exceptions.internalToException(raw_error);
|
|
63
63
|
if (error.RE_EXN_ID === HyperSync.GetLogs.$$Error) {
|
|
@@ -26,7 +26,10 @@ type nextPageParams = {
|
|
|
26
26
|
// selections and the routing index are derived on the Rust side from the
|
|
27
27
|
// registrations passed at construction.
|
|
28
28
|
registrationIndexes: array<int>,
|
|
29
|
-
|
|
29
|
+
// Contract names to fetch address-free even though their registrations
|
|
30
|
+
// depend on addresses (client-side filtering). None/empty means
|
|
31
|
+
// every address-dependent contract is filtered server-side.
|
|
32
|
+
clientFilteredContracts: option<array<string>>,
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
type nextPageResponse = {
|
|
@@ -38,7 +41,7 @@ type nextPageResponse = {
|
|
|
38
41
|
// The caller provides a range; Rust decides the actual `toBlock` and returns it.
|
|
39
42
|
type t = {
|
|
40
43
|
getHeight: unit => promise<int>,
|
|
41
|
-
getNextPage: nextPageParams => promise<nextPageResponse>,
|
|
44
|
+
getNextPage: (nextPageParams, AddressSet.t) => promise<nextPageResponse>,
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
@send
|
|
@@ -47,6 +50,7 @@ external classNew: (
|
|
|
47
50
|
cfg,
|
|
48
51
|
array<HyperSyncClient.Registration.input>,
|
|
49
52
|
~checksumAddresses: bool,
|
|
53
|
+
~addressStore: AddressStore.t,
|
|
50
54
|
) => t = "new"
|
|
51
55
|
|
|
52
56
|
// Rust encodes JSON-RPC errors as a JSON payload in the napi error's
|
|
@@ -85,6 +89,7 @@ let make = (
|
|
|
85
89
|
~httpReqTimeoutMillis=?,
|
|
86
90
|
~headers=?,
|
|
87
91
|
~eventRegistrations=[],
|
|
92
|
+
~addressStore,
|
|
88
93
|
) => {
|
|
89
94
|
let client = Core.getAddon().evmRpcClient->classNew(
|
|
90
95
|
{
|
|
@@ -100,9 +105,11 @@ let make = (
|
|
|
100
105
|
},
|
|
101
106
|
eventRegistrations,
|
|
102
107
|
~checksumAddresses,
|
|
108
|
+
~addressStore,
|
|
103
109
|
)
|
|
104
110
|
{
|
|
105
111
|
getHeight: () => client.getHeight()->Promise.catch(coerceErrorOrThrow),
|
|
106
|
-
getNextPage: params =>
|
|
112
|
+
getNextPage: (params, addressSet) =>
|
|
113
|
+
client.getNextPage(params, addressSet)->Promise.catch(coerceErrorOrThrow),
|
|
107
114
|
}
|
|
108
115
|
}
|
|
@@ -46,7 +46,7 @@ function coerceErrorOrThrow(exn) {
|
|
|
46
46
|
throw exn;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function make(url, checksumAddresses, syncConfig, httpReqTimeoutMillis, headers, eventRegistrationsOpt) {
|
|
49
|
+
function make(url, checksumAddresses, syncConfig, httpReqTimeoutMillis, headers, eventRegistrationsOpt, addressStore) {
|
|
50
50
|
let eventRegistrations = eventRegistrationsOpt !== undefined ? eventRegistrationsOpt : [];
|
|
51
51
|
let client = Core.getAddon().EvmRpcClient.new({
|
|
52
52
|
url: url,
|
|
@@ -58,10 +58,10 @@ function make(url, checksumAddresses, syncConfig, httpReqTimeoutMillis, headers,
|
|
|
58
58
|
intervalCeiling: syncConfig.intervalCeiling,
|
|
59
59
|
backoffMillis: syncConfig.backoffMillis,
|
|
60
60
|
queryTimeoutMillis: syncConfig.queryTimeoutMillis
|
|
61
|
-
}, eventRegistrations, checksumAddresses);
|
|
61
|
+
}, eventRegistrations, checksumAddresses, addressStore);
|
|
62
62
|
return {
|
|
63
63
|
getHeight: () => Stdlib_Promise.$$catch(client.getHeight(), coerceErrorOrThrow),
|
|
64
|
-
getNextPage: params => Stdlib_Promise.$$catch(client.getNextPage(params), coerceErrorOrThrow)
|
|
64
|
+
getNextPage: (params, addressSet) => Stdlib_Promise.$$catch(client.getNextPage(params, addressSet), coerceErrorOrThrow)
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -43,16 +43,17 @@ module GetLogs = {
|
|
|
43
43
|
~fromBlock,
|
|
44
44
|
~toBlock,
|
|
45
45
|
~registrationIndexes,
|
|
46
|
-
~
|
|
46
|
+
~addressSet,
|
|
47
|
+
~clientFilteredContracts,
|
|
47
48
|
): logsQueryPage => {
|
|
48
49
|
let query: FuelHyperSyncClient.EventItems.query = {
|
|
49
50
|
fromBlock,
|
|
50
51
|
toBlock,
|
|
51
52
|
registrationIndexes,
|
|
52
|
-
|
|
53
|
+
clientFilteredContracts,
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
let res = switch await client->FuelHyperSyncClient.getEventItems(query) {
|
|
56
|
+
let res = switch await client->FuelHyperSyncClient.getEventItems(query, addressSet) {
|
|
56
57
|
| res => res
|
|
57
58
|
| exception exn =>
|
|
58
59
|
switch exn->extractMissingParams {
|
|
@@ -29,16 +29,16 @@ function extractMissingParams(exn) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
async function query(client, fromBlock, toBlock, registrationIndexes,
|
|
32
|
+
async function query(client, fromBlock, toBlock, registrationIndexes, addressSet, clientFilteredContracts) {
|
|
33
33
|
let query$1 = {
|
|
34
34
|
fromBlock: fromBlock,
|
|
35
35
|
toBlock: toBlock,
|
|
36
36
|
registrationIndexes: registrationIndexes,
|
|
37
|
-
|
|
37
|
+
clientFilteredContracts: clientFilteredContracts
|
|
38
38
|
};
|
|
39
39
|
let res;
|
|
40
40
|
try {
|
|
41
|
-
res = await client.getEventItems(query$1);
|
|
41
|
+
res = await client.getEventItems(query$1, addressSet);
|
|
42
42
|
} catch (raw_exn) {
|
|
43
43
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
44
44
|
let missingParams = extractMissingParams(exn);
|
|
@@ -17,6 +17,7 @@ module GetLogs: {
|
|
|
17
17
|
~fromBlock: int,
|
|
18
18
|
~toBlock: option<int>,
|
|
19
19
|
~registrationIndexes: array<int>,
|
|
20
|
-
~
|
|
20
|
+
~addressSet: AddressSet.t,
|
|
21
|
+
~clientFilteredContracts: option<array<string>>,
|
|
21
22
|
) => promise<logsQueryPage>
|
|
22
23
|
}
|
|
@@ -52,15 +52,18 @@ module Registration = {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
module EventItems = {
|
|
55
|
-
// The whole per-query input
|
|
56
|
-
// selection (by index)
|
|
57
|
-
//
|
|
55
|
+
// The whole per-query input beside the partition's address set: block range
|
|
56
|
+
// and the registration selection (by index). Receipt selections, field
|
|
57
|
+
// selection, and routing are derived on the Rust side.
|
|
58
58
|
type query = {
|
|
59
59
|
fromBlock: int,
|
|
60
60
|
// Inclusive; None queries to the end of available data.
|
|
61
61
|
toBlock: option<int>,
|
|
62
62
|
registrationIndexes: array<int>,
|
|
63
|
-
|
|
63
|
+
// Contract names to fetch address-free even though their registrations
|
|
64
|
+
// depend on addresses (client-side filtering). None/empty means every
|
|
65
|
+
// address-dependent contract is filtered server-side.
|
|
66
|
+
clientFilteredContracts: option<array<string>>,
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
// One routed receipt with its kind-specific columns flattened: LogData
|
|
@@ -102,19 +105,22 @@ external classNew: (
|
|
|
102
105
|
cfg,
|
|
103
106
|
~userAgent: string,
|
|
104
107
|
array<Registration.input>,
|
|
108
|
+
AddressStore.t,
|
|
105
109
|
) => t = "new"
|
|
106
110
|
|
|
107
|
-
let make = (cfg: cfg, ~eventRegistrations) => {
|
|
111
|
+
let make = (cfg: cfg, ~eventRegistrations, ~addressStore) => {
|
|
108
112
|
let envioVersion = Utils.EnvioPackage.value.version
|
|
109
113
|
Core.getAddon().fuelHyperSyncClient->classNew(
|
|
110
114
|
cfg,
|
|
111
115
|
~userAgent=`hyperindex/${envioVersion}`,
|
|
112
116
|
eventRegistrations,
|
|
117
|
+
addressStore,
|
|
113
118
|
)
|
|
114
119
|
}
|
|
115
120
|
|
|
116
121
|
@send
|
|
117
|
-
external getEventItems: (t, EventItems.query) => promise<EventItems.response> =
|
|
122
|
+
external getEventItems: (t, EventItems.query, AddressSet.t) => promise<EventItems.response> =
|
|
123
|
+
"getEventItems"
|
|
118
124
|
|
|
119
125
|
@send
|
|
120
126
|
external getHeight: t => promise<int> = "getHeight"
|
|
@@ -58,9 +58,9 @@ let Registration = {
|
|
|
58
58
|
|
|
59
59
|
let EventItems = {};
|
|
60
60
|
|
|
61
|
-
function make(cfg, eventRegistrations) {
|
|
61
|
+
function make(cfg, eventRegistrations, addressStore) {
|
|
62
62
|
let envioVersion = Utils.EnvioPackage.value.version;
|
|
63
|
-
return Core.getAddon().FuelHyperSyncClient.new(cfg, `hyperindex/` + envioVersion, eventRegistrations);
|
|
63
|
+
return Core.getAddon().FuelHyperSyncClient.new(cfg, `hyperindex/` + envioVersion, eventRegistrations, addressStore);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export {
|
|
@@ -8,9 +8,11 @@ type options = {
|
|
|
8
8
|
apiToken: option<string>,
|
|
9
9
|
// The chain's registrations, indexed by their sequential `index`.
|
|
10
10
|
onEventRegistrations: array<Internal.fuelOnEventRegistration>,
|
|
11
|
+
// The chain's address index; the client reads it while routing.
|
|
12
|
+
addressStore: AddressStore.t,
|
|
11
13
|
}
|
|
12
14
|
|
|
13
|
-
let make = ({chain, endpointUrl, apiToken, onEventRegistrations}: options): t => {
|
|
15
|
+
let make = ({chain, endpointUrl, apiToken, onEventRegistrations, addressStore}: options): t => {
|
|
14
16
|
let name = "HyperFuel"
|
|
15
17
|
|
|
16
18
|
let apiToken = switch apiToken {
|
|
@@ -24,6 +26,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
24
26
|
let client = switch FuelHyperSyncClient.make(
|
|
25
27
|
{url: endpointUrl, apiToken},
|
|
26
28
|
~eventRegistrations=FuelHyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations),
|
|
29
|
+
~addressStore,
|
|
27
30
|
) {
|
|
28
31
|
| client => client
|
|
29
32
|
| exception exn =>
|
|
@@ -33,8 +36,7 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
33
36
|
let getItemsOrThrow = async (
|
|
34
37
|
~fromBlock,
|
|
35
38
|
~toBlock,
|
|
36
|
-
~
|
|
37
|
-
~contractNameByAddress as _,
|
|
39
|
+
~addressSet,
|
|
38
40
|
~knownHeight,
|
|
39
41
|
~partitionId as _,
|
|
40
42
|
~selection: FetchState.selection,
|
|
@@ -52,7 +54,8 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`)
|
|
|
52
54
|
~fromBlock,
|
|
53
55
|
~toBlock,
|
|
54
56
|
~registrationIndexes=selection.onEventRegistrations->Array.map(reg => reg.index),
|
|
55
|
-
~
|
|
57
|
+
~addressSet,
|
|
58
|
+
~clientFilteredContracts=selection.clientFilteredContracts,
|
|
56
59
|
) catch {
|
|
57
60
|
| FuelHyperSync.GetLogs.Error(error) =>
|
|
58
61
|
throw(
|
|
@@ -27,17 +27,17 @@ Learn more or get a free Envio API token at: https://envio.dev/app/api-tokens`);
|
|
|
27
27
|
client = FuelHyperSyncClient.make({
|
|
28
28
|
url: param.endpointUrl,
|
|
29
29
|
apiToken: apiToken$1
|
|
30
|
-
}, FuelHyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations));
|
|
30
|
+
}, FuelHyperSyncClient.Registration.fromOnEventRegistrations(onEventRegistrations), param.addressStore);
|
|
31
31
|
} catch (raw_exn) {
|
|
32
32
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
33
33
|
client = ErrorHandling.mkLogAndRaise(undefined, "Failed to instantiate the HyperFuel client", exn);
|
|
34
34
|
}
|
|
35
|
-
let getItemsOrThrow = async (fromBlock, toBlock,
|
|
35
|
+
let getItemsOrThrow = async (fromBlock, toBlock, addressSet, knownHeight, param, selection, param$1, retry, logger) => {
|
|
36
36
|
let totalTimeRef = Performance.now();
|
|
37
37
|
let startFetchingBatchTimeRef = Performance.now();
|
|
38
38
|
let pageUnsafe;
|
|
39
39
|
try {
|
|
40
|
-
pageUnsafe = await FuelHyperSync.GetLogs.query(client, fromBlock, toBlock, selection.onEventRegistrations.map(reg => reg.index),
|
|
40
|
+
pageUnsafe = await FuelHyperSync.GetLogs.query(client, fromBlock, toBlock, selection.onEventRegistrations.map(reg => reg.index), addressSet, selection.clientFilteredContracts);
|
|
41
41
|
} catch (raw_error) {
|
|
42
42
|
let error = Primitive_exceptions.internalToException(raw_error);
|
|
43
43
|
if (error.RE_EXN_ID === FuelHyperSync.GetLogs.$$Error) {
|
|
@@ -16,7 +16,7 @@ let reraisIfRateLimited = exn =>
|
|
|
16
16
|
|
|
17
17
|
type logsQueryPage = {
|
|
18
18
|
items: array<HyperSyncClient.EventItems.item>,
|
|
19
|
-
//
|
|
19
|
+
// Headers for every returned block, deduplicated by block number.
|
|
20
20
|
blocks: array<HyperSyncClient.EventItems.blockHeader>,
|
|
21
21
|
nextBlock: int,
|
|
22
22
|
archiveHeight: int,
|
|
@@ -92,17 +92,21 @@ module GetLogs = {
|
|
|
92
92
|
~toBlock,
|
|
93
93
|
~maxNumLogs,
|
|
94
94
|
~registrationIndexes,
|
|
95
|
-
~
|
|
95
|
+
~addressSet,
|
|
96
|
+
~clientFilteredContracts,
|
|
96
97
|
): logsQueryPage => {
|
|
97
98
|
let query: HyperSyncClient.EventItems.query = {
|
|
98
99
|
fromBlock,
|
|
99
100
|
toBlock,
|
|
100
|
-
maxNumLogs,
|
|
101
|
+
?maxNumLogs,
|
|
101
102
|
registrationIndexes,
|
|
102
|
-
|
|
103
|
+
clientFilteredContracts,
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
let (res, transactionStore, blockStore) = switch await client.getEventItems(
|
|
106
|
+
let (res, transactionStore, blockStore) = switch await client.getEventItems(
|
|
107
|
+
~query,
|
|
108
|
+
~addressSet,
|
|
109
|
+
) {
|
|
106
110
|
| res => res
|
|
107
111
|
| exception exn =>
|
|
108
112
|
reraisIfRateLimited(exn)
|
|
@@ -82,17 +82,17 @@ function extractMissingParams(exn) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
async function query(client, fromBlock, toBlock, maxNumLogs, registrationIndexes,
|
|
85
|
+
async function query(client, fromBlock, toBlock, maxNumLogs, registrationIndexes, addressSet, clientFilteredContracts) {
|
|
86
86
|
let query$1 = {
|
|
87
87
|
fromBlock: fromBlock,
|
|
88
88
|
toBlock: toBlock,
|
|
89
89
|
maxNumLogs: maxNumLogs,
|
|
90
90
|
registrationIndexes: registrationIndexes,
|
|
91
|
-
|
|
91
|
+
clientFilteredContracts: clientFilteredContracts
|
|
92
92
|
};
|
|
93
93
|
let match;
|
|
94
94
|
try {
|
|
95
|
-
match = await client.getEventItems(query$1);
|
|
95
|
+
match = await client.getEventItems(query$1, addressSet);
|
|
96
96
|
} catch (raw_exn) {
|
|
97
97
|
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
98
98
|
reraisIfRateLimited(exn);
|
|
@@ -32,9 +32,10 @@ module GetLogs: {
|
|
|
32
32
|
~client: HyperSyncClient.t,
|
|
33
33
|
~fromBlock: int,
|
|
34
34
|
~toBlock: option<int>,
|
|
35
|
-
~maxNumLogs: int
|
|
35
|
+
~maxNumLogs: option<int>,
|
|
36
36
|
~registrationIndexes: array<int>,
|
|
37
|
-
~
|
|
37
|
+
~addressSet: AddressSet.t,
|
|
38
|
+
~clientFilteredContracts: option<array<string>>,
|
|
38
39
|
) => promise<logsQueryPage>
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -302,16 +302,20 @@ module Registration = {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
module EventItems = {
|
|
305
|
-
// The whole per-query input
|
|
306
|
-
// selection (by id)
|
|
307
|
-
//
|
|
305
|
+
// The whole per-query input beside the partition's address set: block range
|
|
306
|
+
// and the registration selection (by id). Log selections, field selection,
|
|
307
|
+
// and the routing index are derived on the Rust side.
|
|
308
308
|
type query = {
|
|
309
309
|
fromBlock: int,
|
|
310
310
|
// Inclusive; None queries to the end of available data.
|
|
311
311
|
toBlock: option<int>,
|
|
312
|
-
|
|
312
|
+
// Absent means no server-side cap on the number of logs returned.
|
|
313
|
+
maxNumLogs?: int,
|
|
313
314
|
registrationIndexes: array<int>,
|
|
314
|
-
|
|
315
|
+
// Contract names to fetch address-free even though their registrations
|
|
316
|
+
// depend on addresses (client-side filtering). None/empty means
|
|
317
|
+
// every address-dependent contract is filtered server-side.
|
|
318
|
+
clientFilteredContracts: option<array<string>>,
|
|
315
319
|
}
|
|
316
320
|
|
|
317
321
|
type item = {
|
|
@@ -340,7 +344,9 @@ module EventItems = {
|
|
|
340
344
|
type response = {
|
|
341
345
|
archiveHeight: option<int>,
|
|
342
346
|
nextBlock: int,
|
|
343
|
-
// One header per block number
|
|
347
|
+
// One header per returned block number, including blocks no item
|
|
348
|
+
// references — reorg detection reads them all. The block store keeps only
|
|
349
|
+
// the ones items reference.
|
|
344
350
|
blocks: array<blockHeader>,
|
|
345
351
|
items: array<item>,
|
|
346
352
|
rollbackGuard: option<ResponseTypes.rollbackGuard>,
|
|
@@ -353,16 +359,22 @@ type t = {
|
|
|
353
359
|
// and blocks.
|
|
354
360
|
getEventItems: (
|
|
355
361
|
~query: EventItems.query,
|
|
362
|
+
~addressSet: AddressSet.t,
|
|
356
363
|
) => promise<(EventItems.response, TransactionStore.t, BlockStore.t)>,
|
|
357
364
|
getHeight: unit => promise<int>,
|
|
358
365
|
}
|
|
359
366
|
|
|
360
367
|
@send
|
|
361
|
-
external classNew: (
|
|
362
|
-
|
|
368
|
+
external classNew: (
|
|
369
|
+
Core.evmHyperSyncClientCtor,
|
|
370
|
+
cfg,
|
|
371
|
+
string,
|
|
372
|
+
array<Registration.input>,
|
|
373
|
+
AddressStore.t,
|
|
374
|
+
) => t = "new"
|
|
363
375
|
|
|
364
|
-
let makeWithAgent = (cfg, ~userAgent, ~eventRegistrations) =>
|
|
365
|
-
Core.getAddon().evmHyperSyncClient->classNew(cfg, userAgent, eventRegistrations)
|
|
376
|
+
let makeWithAgent = (cfg, ~userAgent, ~eventRegistrations, ~addressStore) =>
|
|
377
|
+
Core.getAddon().evmHyperSyncClient->classNew(cfg, userAgent, eventRegistrations, addressStore)
|
|
366
378
|
|
|
367
379
|
type logLevel = [#trace | #debug | #info | #warn | #error]
|
|
368
380
|
let logLevelSchema: S.t<logLevel> = S.enum([#trace, #debug, #info, #warn, #error])
|
|
@@ -388,6 +400,7 @@ let make = (
|
|
|
388
400
|
~retryBackoffMs=?,
|
|
389
401
|
~retryCeilingMs=?,
|
|
390
402
|
~logLevel=#info,
|
|
403
|
+
~addressStore,
|
|
391
404
|
) => {
|
|
392
405
|
let envioVersion = Utils.EnvioPackage.value.version
|
|
393
406
|
makeWithAgent(
|
|
@@ -407,5 +420,6 @@ let make = (
|
|
|
407
420
|
},
|
|
408
421
|
~userAgent=`hyperindex/${envioVersion}`,
|
|
409
422
|
~eventRegistrations,
|
|
423
|
+
~addressStore,
|
|
410
424
|
)
|
|
411
425
|
}
|
|
@@ -73,8 +73,8 @@ let Registration = {
|
|
|
73
73
|
|
|
74
74
|
let EventItems = {};
|
|
75
75
|
|
|
76
|
-
function makeWithAgent(cfg, userAgent, eventRegistrations) {
|
|
77
|
-
return Core.getAddon().EvmHyperSyncClient.new(cfg, userAgent, eventRegistrations);
|
|
76
|
+
function makeWithAgent(cfg, userAgent, eventRegistrations, addressStore) {
|
|
77
|
+
return Core.getAddon().EvmHyperSyncClient.new(cfg, userAgent, eventRegistrations, addressStore);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
let logLevelSchema = S$RescriptSchema.$$enum([
|
|
@@ -99,7 +99,7 @@ function logLevelToString(level) {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChecksumAddressesOpt, serializationFormat, enableQueryCaching, retryBaseMs, retryBackoffMs, retryCeilingMs, logLevelOpt) {
|
|
102
|
+
function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChecksumAddressesOpt, serializationFormat, enableQueryCaching, retryBaseMs, retryBackoffMs, retryCeilingMs, logLevelOpt, addressStore) {
|
|
103
103
|
let enableChecksumAddresses = enableChecksumAddressesOpt !== undefined ? enableChecksumAddressesOpt : true;
|
|
104
104
|
let logLevel = logLevelOpt !== undefined ? logLevelOpt : "info";
|
|
105
105
|
let envioVersion = Utils.EnvioPackage.value.version;
|
|
@@ -115,7 +115,7 @@ function make(url, apiToken, httpReqTimeoutMillis, eventRegistrations, enableChe
|
|
|
115
115
|
serializationFormat: serializationFormat,
|
|
116
116
|
enableQueryCaching: enableQueryCaching,
|
|
117
117
|
logLevel: logLevelToString(logLevel)
|
|
118
|
-
}, `hyperindex/` + envioVersion, eventRegistrations);
|
|
118
|
+
}, `hyperindex/` + envioVersion, eventRegistrations, addressStore);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export {
|