envio 3.3.0-alpha.8 → 3.3.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.
- package/index.d.ts +19 -0
- package/licenses/CLA.md +35 -0
- package/licenses/EULA.md +67 -0
- package/licenses/LICENSE.md +45 -0
- package/licenses/README.md +35 -0
- package/package.json +9 -8
- package/src/Batch.res.mjs +1 -1
- package/src/BatchProcessing.res +0 -7
- package/src/BatchProcessing.res.mjs +1 -8
- package/src/ChainFetching.res +30 -18
- package/src/ChainFetching.res.mjs +23 -13
- package/src/ChainState.res +205 -59
- package/src/ChainState.res.mjs +130 -27
- package/src/ChainState.resi +16 -1
- package/src/Config.res +9 -5
- package/src/Config.res.mjs +2 -2
- package/src/Core.res +20 -0
- package/src/Core.res.mjs +12 -0
- package/src/CrossChainState.res +147 -39
- package/src/CrossChainState.res.mjs +42 -10
- package/src/EffectState.res +100 -0
- package/src/EffectState.res.mjs +74 -0
- package/src/EffectState.resi +32 -0
- package/src/Envio.res +25 -7
- package/src/Envio.res.mjs +15 -19
- package/src/EnvioGlobal.res +53 -0
- package/src/EnvioGlobal.res.mjs +31 -0
- package/src/EventConfigBuilder.res +30 -56
- package/src/EventConfigBuilder.res.mjs +24 -30
- package/src/EventProcessing.res +8 -5
- package/src/EventProcessing.res.mjs +2 -1
- package/src/FetchState.res +842 -474
- package/src/FetchState.res.mjs +545 -356
- package/src/HandlerLoader.res +1 -1
- package/src/HandlerLoader.res.mjs +1 -1
- package/src/HandlerRegister.res +478 -305
- package/src/HandlerRegister.res.mjs +277 -209
- package/src/HandlerRegister.resi +11 -6
- package/src/InMemoryStore.res +14 -26
- package/src/InMemoryStore.res.mjs +6 -19
- package/src/IndexerState.res +15 -39
- package/src/IndexerState.res.mjs +18 -29
- package/src/IndexerState.resi +2 -10
- package/src/Internal.res +121 -18
- package/src/Internal.res.mjs +96 -2
- package/src/LoadLayer.res +44 -24
- package/src/LoadLayer.res.mjs +43 -20
- package/src/LoadLayer.resi +1 -0
- package/src/LogSelection.res +92 -217
- package/src/LogSelection.res.mjs +95 -184
- package/src/Main.res +29 -143
- package/src/Main.res.mjs +25 -88
- package/src/Metrics.res +1 -1
- package/src/Metrics.res.mjs +1 -1
- package/src/Persistence.res +12 -3
- package/src/PgStorage.res +155 -82
- package/src/PgStorage.res.mjs +130 -77
- package/src/Prometheus.res +20 -10
- package/src/Prometheus.res.mjs +22 -10
- package/src/PruneStaleHistory.res +146 -35
- package/src/PruneStaleHistory.res.mjs +114 -20
- package/src/RawEvent.res +2 -2
- package/src/Rollback.res +32 -13
- package/src/Rollback.res.mjs +24 -11
- package/src/RollbackCommit.res +4 -1
- package/src/RollbackCommit.res.mjs +3 -2
- package/src/SimulateDeadInputTracker.res +1 -1
- package/src/SimulateItems.res +39 -7
- package/src/SimulateItems.res.mjs +28 -9
- package/src/TestIndexer.res +2 -2
- package/src/TestIndexer.res.mjs +2 -2
- package/src/TopicFilter.res +1 -25
- package/src/TopicFilter.res.mjs +0 -74
- package/src/UserContext.res +62 -23
- package/src/UserContext.res.mjs +26 -6
- package/src/Writing.res +60 -21
- package/src/Writing.res.mjs +27 -9
- package/src/bindings/NodeJs.res +5 -0
- package/src/bindings/Viem.res +0 -5
- package/src/sources/EventRouter.res +0 -21
- package/src/sources/EventRouter.res.mjs +0 -12
- package/src/sources/Evm.res +4 -1
- package/src/sources/Evm.res.mjs +1 -1
- package/src/sources/EvmChain.res +2 -27
- package/src/sources/EvmChain.res.mjs +2 -23
- package/src/sources/EvmRpcClient.res +58 -23
- package/src/sources/EvmRpcClient.res.mjs +11 -5
- package/src/sources/Fuel.res +3 -1
- package/src/sources/Fuel.res.mjs +1 -1
- package/src/sources/HyperSync.res +9 -38
- package/src/sources/HyperSync.res.mjs +16 -28
- package/src/sources/HyperSync.resi +2 -2
- package/src/sources/HyperSyncClient.res +88 -11
- package/src/sources/HyperSyncClient.res.mjs +39 -6
- package/src/sources/HyperSyncSource.res +18 -210
- package/src/sources/HyperSyncSource.res.mjs +9 -137
- package/src/sources/Rpc.res +0 -32
- package/src/sources/Rpc.res.mjs +1 -46
- package/src/sources/RpcSource.res +129 -533
- package/src/sources/RpcSource.res.mjs +161 -379
- package/src/sources/SimulateSource.res +37 -19
- package/src/sources/SimulateSource.res.mjs +27 -10
- package/src/sources/SourceManager.res +4 -14
- package/src/sources/SourceManager.res.mjs +3 -9
- package/src/sources/SourceManager.resi +0 -2
- package/src/sources/SvmHyperSyncSource.res +13 -3
- package/src/sources/SvmHyperSyncSource.res.mjs +1 -1
package/index.d.ts
CHANGED
|
@@ -48,6 +48,13 @@ export type EffectCaller = <I, O>(
|
|
|
48
48
|
input: I extends undefined ? undefined : I
|
|
49
49
|
) => Promise<O>;
|
|
50
50
|
|
|
51
|
+
/** The chain an Effect was called on. Available only on chain-scoped effects
|
|
52
|
+
* (`crossChain: false`). */
|
|
53
|
+
export type EffectChain = {
|
|
54
|
+
/** The chain id the effect handler was called on. */
|
|
55
|
+
readonly id: number;
|
|
56
|
+
};
|
|
57
|
+
|
|
51
58
|
/** Context passed to an Effect's handler function. */
|
|
52
59
|
export type EffectContext = {
|
|
53
60
|
/** Access the logger instance with the event as context. */
|
|
@@ -57,6 +64,9 @@ export type EffectContext = {
|
|
|
57
64
|
/** Whether to cache this call's result. Defaults to the effect's `cache`
|
|
58
65
|
* option; set to `false` to skip caching for this specific invocation. */
|
|
59
66
|
cache: boolean;
|
|
67
|
+
/** The chain the effect was called on. Only available on effects created with
|
|
68
|
+
* `crossChain: false`; accessing it on a cross-chain effect throws. */
|
|
69
|
+
readonly chain: EffectChain;
|
|
60
70
|
};
|
|
61
71
|
|
|
62
72
|
/** Rate-limit window for an {@link Effect}. Strings resolve to common
|
|
@@ -82,6 +92,11 @@ export type EffectOptions<Input, Output> = {
|
|
|
82
92
|
readonly rateLimit: RateLimit;
|
|
83
93
|
/** Whether the effect should be cached. */
|
|
84
94
|
readonly cache?: boolean;
|
|
95
|
+
/** Whether the effect's cache is shared across all chains. Defaults to
|
|
96
|
+
* `true`. Set to `false` to isolate the cache and rate limiting per chain and
|
|
97
|
+
* enable `context.chain.id` inside the handler. Changing this changes the
|
|
98
|
+
* effect's cache identity. */
|
|
99
|
+
readonly crossChain?: boolean;
|
|
85
100
|
};
|
|
86
101
|
|
|
87
102
|
/** Arguments passed to the handler function of an {@link Effect}. */
|
|
@@ -209,6 +224,10 @@ export function createEffect<
|
|
|
209
224
|
readonly rateLimit: RateLimit;
|
|
210
225
|
/** Whether the effect should be cached. */
|
|
211
226
|
readonly cache?: boolean;
|
|
227
|
+
/** Whether the effect's cache is shared across all chains. Defaults to
|
|
228
|
+
* `true`. Set to `false` to isolate the cache and rate limiting per chain
|
|
229
|
+
* and enable `context.chain.id` inside the handler. */
|
|
230
|
+
readonly crossChain?: boolean;
|
|
212
231
|
},
|
|
213
232
|
handler: (args: EffectArgs<I>) => Promise<R>
|
|
214
233
|
): Effect<I, O>;
|
package/licenses/CLA.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Contributor License Agreement (CLA)
|
|
2
|
+
|
|
3
|
+
## 1. Introduction
|
|
4
|
+
|
|
5
|
+
Thank you for your interest in contributing to this project ("Project"). We value your time and effort, and we appreciate all contributions made by the community. By submitting any work (a "Contribution"), you agree to the terms below.
|
|
6
|
+
|
|
7
|
+
## 2. Automatic Acceptance
|
|
8
|
+
|
|
9
|
+
By submitting a Pull Request or making any contribution to this project, you automatically agree to and accept all terms outlined in this Contributor License Agreement. This includes all future contributions you may make to the project.
|
|
10
|
+
|
|
11
|
+
## 3. Your Contributions
|
|
12
|
+
|
|
13
|
+
3.1 A "Contribution" includes any original work you share with the Project, such as code, documentation, or other creative content.
|
|
14
|
+
|
|
15
|
+
3.2 You confirm that each Contribution is either your own original work or that you have all necessary rights and permissions to submit it under this CLA.
|
|
16
|
+
|
|
17
|
+
## 4. License Grant
|
|
18
|
+
|
|
19
|
+
4.1 By submitting a Contribution, you grant Envio (the "Maintainer") an irrevocable, worldwide, non-exclusive, royalty-free, perpetual license to use, reproduce, modify, distribute, prepare derivative works of, publicly display, perform, sublicense, and otherwise exploit your Contribution as part of the Project.
|
|
20
|
+
|
|
21
|
+
4.2 You agree that the Maintainer may license or re-license your Contribution under terms compatible with those of the Project.
|
|
22
|
+
|
|
23
|
+
## 5. Ongoing Use
|
|
24
|
+
|
|
25
|
+
5.1 Once provided, Contributions cannot be retracted; however, the Maintainer is not obligated to include or continue using your Contribution.
|
|
26
|
+
|
|
27
|
+
5.2 You understand that this CLA helps ensure your work remains compatible with the Project's licensing, now and in the future.
|
|
28
|
+
|
|
29
|
+
## 6. Disclaimer
|
|
30
|
+
|
|
31
|
+
6.1 You provide your Contributions on an "as is" basis, without warranties of any kind. This includes, but is not limited to, warranties of merchantability, fitness for a particular purpose, and non-infringement.
|
|
32
|
+
|
|
33
|
+
## 7. Governing Law
|
|
34
|
+
|
|
35
|
+
7.1 This CLA is governed by and construed in accordance with the laws of England. Any disputes will be subject to the exclusive jurisdiction of the English courts.
|
package/licenses/EULA.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
## HyperIndex End-User License Agreement (EULA)
|
|
2
|
+
|
|
3
|
+
This agreement describes the users' rights and the conditions upon which the Software and Generated Code may be used. The user should review the entire agreement, including any supplemental license terms that accompany the Software, since all of the terms are important and together create this agreement that applies to them.
|
|
4
|
+
|
|
5
|
+
### 1. Definitions
|
|
6
|
+
|
|
7
|
+
**Software:** HyperIndex, a copyrightable work created by Envio and licensed under this End User License Agreement (“EULA”).
|
|
8
|
+
|
|
9
|
+
**Generated Code:** In the context of this license agreement, the term "generated code" refers to computer programming code that is produced automatically by the Software based on input provided by the user.
|
|
10
|
+
|
|
11
|
+
**Licensed Material:** The Software and Generated Code defined here will be collectively referred to as “Licensed Material”.
|
|
12
|
+
|
|
13
|
+
### 2. Installation and User Rights
|
|
14
|
+
|
|
15
|
+
**License:** The Software is provided under this EULA. By agreeing to the EULA terms, you are granted the right to install and operate one instance of the Software on your device (referred to as the licensed device), for the use of one individual at a time, on the condition that you adhere to all terms outlined in this agreement.
|
|
16
|
+
The licensor provides you with a non-exclusive, royalty-free, worldwide license that is non-sublicensable and non-transferable. This license allows you to use the Software subject to the limitations and conditions outlined in this EULA.
|
|
17
|
+
With one license, the user can only use the Software on a single device.
|
|
18
|
+
|
|
19
|
+
**Device:** In this agreement, "device" refers to a hardware system, whether physical or virtual, equipped with an internal storage device capable of executing the Software. This includes hardware partitions, which are considered as individual devices for the purposes of this agreement. Updates may be provided to the Software, and these updates may alter the minimum hardware requirements necessary for the Software. It is the responsibility of users to comply with any changing hardware requirements.
|
|
20
|
+
|
|
21
|
+
**Updates:** The Software may be updated automatically. With each update, the EULA may be amended, and it is the users' responsibility to comply with the amendments.
|
|
22
|
+
|
|
23
|
+
**Limitations:** Envio reserves all rights, including those under intellectual property laws, not expressly granted in this agreement. For instance, this license does not confer upon you the right to, and you are prohibited from:
|
|
24
|
+
|
|
25
|
+
(i) Publishing, copying (other than the permitted backup copy), renting, leasing, or lending the Software;
|
|
26
|
+
|
|
27
|
+
(ii) Transferring the Software (except as permitted by this agreement);
|
|
28
|
+
|
|
29
|
+
(iii) Circumventing any technical restrictions or limitations in the Software;
|
|
30
|
+
|
|
31
|
+
(iv) Using the Software as server Software, for commercial hosting, making the Software available for simultaneous use by multiple users over a network, installing the Software on a server and allowing users to access it remotely, or installing the Software on a device solely for remote user use;
|
|
32
|
+
|
|
33
|
+
(v) Reverse engineering, decompiling, or disassembling the Software, or attempting to do so, except and only to the extent that the foregoing restriction is (a) permitted by applicable law; (b) permitted by licensing terms governing the use of open-source components that may be included with the Software and
|
|
34
|
+
|
|
35
|
+
(vi) When using the Software, you may not use any features in any manner that could interfere with anyone else's use of them, or attempt to gain unauthorized access to or use of any service, data, account, or network.
|
|
36
|
+
|
|
37
|
+
These limitations apply specifically to the Software and do not extend to the Generated Code. Details regarding the use of the Generated Code, including associated limitations, are provided below.
|
|
38
|
+
|
|
39
|
+
### 3. Use of the Generated Code
|
|
40
|
+
|
|
41
|
+
**Limitations:** Users can use, copy, distribute, make available, and create derivative works of the Generated Code freely, subject to the limitations and conditions specified below.
|
|
42
|
+
|
|
43
|
+
(i) The user is prohibited from offering the Generated Code or any software that includes the Generated Code to third parties as a hosted or managed service, where the service grants users access to a significant portion of the Software's features or functionality.
|
|
44
|
+
|
|
45
|
+
(ii) The user is not permitted to tamper with, alter, disable, or bypass the functionality of the license key in the Software. Additionally, the user may not eliminate or conceal any functionality within the Software that is safeguarded by the license key.
|
|
46
|
+
|
|
47
|
+
(iii) Any modification, removal, or concealment of licensing, copyright, or other notices belonging to the licensor in the Software is strictly forbidden. The use of the licensor's trademarks is subject to relevant laws.
|
|
48
|
+
|
|
49
|
+
**Credit:** If the user utilizes the Generated Code to develop and release a new software, product or service, the license agreement for said software, product or service must include proper credit to HyperIndex.
|
|
50
|
+
|
|
51
|
+
**Liability:** Envio does not provide any assurance that the Generated Code functions correctly, nor does it assume any responsibility in this regard.
|
|
52
|
+
|
|
53
|
+
Additionally, it will be the responsibility of the user to assess whether the Generated Code is suitable for the products and services provided by the user. Envio will not bear any responsibility if the Generated Code is found unsuitable for the products and services provided by the user.
|
|
54
|
+
|
|
55
|
+
### 4. Additional Terms
|
|
56
|
+
|
|
57
|
+
**Disclaimer of Warranties and Limitation of Liability:**
|
|
58
|
+
|
|
59
|
+
(i) Unless expressly undertaken by the Licensor separately, the Licensed Material is provided on an as-is, as-available basis, and the Licensor makes no representations or warranties of any kind regarding the Licensed Material, whether express, implied, statutory, or otherwise. This encompasses, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether known or discoverable. If disclaimers of warranties are not permitted in whole or in part, this disclaimer may not apply to You.
|
|
60
|
+
|
|
61
|
+
(ii) To the fullest extent permitted by law, under no circumstances shall the Licensor be liable to You under any legal theory (including, but not limited to, negligence) for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising from the use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. If limitations of liability are not permitted in whole or in part, this limitation may not apply to You.
|
|
62
|
+
|
|
63
|
+
(iii) The disclaimers of warranties and limitations of liability outlined above shall be construed in a manner that most closely approximates an absolute disclaimer and waiver of all liability, to the fullest extent permitted by law.
|
|
64
|
+
|
|
65
|
+
**Applicable Law and Competent Courts:** This EULA and shall be governed by and construed in accordance with the laws of England. The courts of England shall have exclusive jurisdiction to settle any dispute arising out of or in connection with this EULA.
|
|
66
|
+
|
|
67
|
+
**Additional Agreements:** If the user chooses to use the Software, it may be required to agree to additional terms or agreements outside of this EULA.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Standard SaaS End User License Agreement (EULA)
|
|
2
|
+
|
|
3
|
+
## End User License Agreement (EULA)
|
|
4
|
+
|
|
5
|
+
This End User License Agreement ("Agreement") is between Envio ("Company") and the user ("User") who downloads, installs, or uses the Software as a Service (SaaS) provided by the Company.
|
|
6
|
+
|
|
7
|
+
### 1. License Grant
|
|
8
|
+
|
|
9
|
+
1.1 Company grants User a non-exclusive, non-transferable, limited license to access and use the SaaS for business or personal purposes in accordance with this Agreement.
|
|
10
|
+
|
|
11
|
+
### 2. Restrictions
|
|
12
|
+
|
|
13
|
+
2.1 User shall not:
|
|
14
|
+
|
|
15
|
+
- Modify, copy, or create derivative works based on the SaaS.
|
|
16
|
+
- Reverse engineer, decompile, or disassemble the SaaS.
|
|
17
|
+
- Rent, lease, lend, sell, redistribute, or sublicense the SaaS.
|
|
18
|
+
- Use the SaaS for any unlawful purpose.
|
|
19
|
+
|
|
20
|
+
### 3. Ownership
|
|
21
|
+
|
|
22
|
+
3.1 The Company retains all rights, title, and interest in and to the SaaS, including all intellectual property rights.
|
|
23
|
+
|
|
24
|
+
### 4. Term and Termination
|
|
25
|
+
|
|
26
|
+
4.1 This Agreement is effective until terminated. User’s rights under this Agreement will terminate automatically without notice if User fails to comply with any term(s) of this Agreement.
|
|
27
|
+
4.2 Upon termination, User must cease all use of the SaaS and destroy all copies of any related documentation.
|
|
28
|
+
|
|
29
|
+
### 5. Disclaimer of Warranties
|
|
30
|
+
|
|
31
|
+
5.1 The SaaS is provided "AS IS" without warranty of any kind, either express or implied, including, but not limited to, implied warranties of merchantability and fitness for a particular purpose.
|
|
32
|
+
|
|
33
|
+
### 6. Limitation of Liability
|
|
34
|
+
|
|
35
|
+
6.1 In no event shall Company be liable for any special, incidental, indirect, or consequential damages whatsoever arising out of the use of or inability to use the SaaS.
|
|
36
|
+
|
|
37
|
+
### 7. Governing Law
|
|
38
|
+
|
|
39
|
+
7.1 This Agreement shall be governed by and construed in accordance with the laws of the United Kingdom.
|
|
40
|
+
|
|
41
|
+
### 8. Entire Agreement
|
|
42
|
+
|
|
43
|
+
8.1 This Agreement constitutes the entire agreement between the parties with respect to the use of the SaaS and supersedes all prior or contemporaneous understandings regarding such subject matter.
|
|
44
|
+
|
|
45
|
+
**By using the SaaS, the User agrees to be bound by this Agreement.**
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Licensing Information
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Envio's licensing reflects open source ethos but is not OSI recognized. Developers can use Envio's services without vendor lock-in, either by self-hosting or specifying an RPC URL. The generated code is open and public and so is this repository that generates the generated code.
|
|
6
|
+
|
|
7
|
+
Our licenses allows self-hosting but restricts third-party hosting with Envio's hosted service. Envio may consider open-sourcing in the future but prioritizes stakeholder interests and market traction. Please reach out to us on discord if you would like to explore hosting indexers as a third-party.
|
|
8
|
+
|
|
9
|
+
## TL;DR
|
|
10
|
+
|
|
11
|
+
- **Envio's licensing** mirrors open source benefits but is not OSI recognized.
|
|
12
|
+
- **Developers** can use Envio's services without vendor lock-in by:
|
|
13
|
+
- Self-hosting.
|
|
14
|
+
- Specifying an RPC URL.
|
|
15
|
+
- **Code** is open and public.
|
|
16
|
+
- **Generated license** allows self-hosting but restricts third-party competition.
|
|
17
|
+
- **Code generator license** is a commercial license.
|
|
18
|
+
- **non-comercial use** is allowed.
|
|
19
|
+
- **forking and modifying code** is not allowed. However, if you have specific needs or use cases, please contact us to discuss potential exceptions.
|
|
20
|
+
- **Future considerations** for open-sourcing are dependent on market traction and stakeholder interests.
|
|
21
|
+
- **Contributors** must agree to our Contributor License Agreement (CLA).
|
|
22
|
+
|
|
23
|
+
## Our Position
|
|
24
|
+
|
|
25
|
+
We're developers who value the open source ethos, which is why our licensing mirrors many benefits of open source licensing. However, Envio and its products do not use a recognized open source license by the OSI. We are public and open, and our licensing reflects this.
|
|
26
|
+
|
|
27
|
+
Our future business model lies in our hosted service and HyperSync requests, and we are protecting this. To ensure continuity and avoid vendor lock-in, developers can run and develop on their indexer without our hosted service. This can be achieved either by self-hosting, which our license permits, or by specifying an RPC URL in their indexer configuration, thus bypassing HyperSync.
|
|
28
|
+
|
|
29
|
+
Envio is in its formative stages. Although we may consider open-sourcing the software in the future, we are committed to ensuring the best interests of all stakeholders. Going open source is somewhat of a one-way function; it's easier to open source than to go "closed source." Once we have gained more market traction, we will review our position on going open source.
|
|
30
|
+
|
|
31
|
+
## Our Licenses
|
|
32
|
+
|
|
33
|
+
- [EULA](./EULA.md) - The license in your indexer pertaining to the generated code
|
|
34
|
+
- [LICENSE](./LICENSE.md) - The non-commercial use license pertaining to this code base which is used to template & generate the indexing code
|
|
35
|
+
- [CLA](./CLA.md) - The Contributor License Agreement for those who wish to contribute to the project
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "envio",
|
|
3
|
-
"version": "3.3.0-
|
|
3
|
+
"version": "3.3.0-rc.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A latency and sync speed optimized, developer friendly blockchain data indexer.",
|
|
6
6
|
"bin": "./bin.mjs",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"url": "git+https://github.com/enviodev/hyperindex.git"
|
|
12
12
|
},
|
|
13
13
|
"author": "envio contributors <about@envio.dev>",
|
|
14
|
-
"license": "
|
|
14
|
+
"license": "SEE LICENSE IN licenses/README.md",
|
|
15
15
|
"bugs": {
|
|
16
16
|
"url": "https://github.com/enviodev/hyperindex/issues"
|
|
17
17
|
},
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"rescript.json",
|
|
38
38
|
"index.d.ts",
|
|
39
39
|
"index.js",
|
|
40
|
-
"src"
|
|
40
|
+
"src",
|
|
41
|
+
"licenses"
|
|
41
42
|
],
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@clickhouse/client": "1.17.0",
|
|
@@ -69,10 +70,10 @@
|
|
|
69
70
|
"tsx": "4.21.0"
|
|
70
71
|
},
|
|
71
72
|
"optionalDependencies": {
|
|
72
|
-
"envio-linux-x64": "3.3.0-
|
|
73
|
-
"envio-linux-x64-musl": "3.3.0-
|
|
74
|
-
"envio-linux-arm64": "3.3.0-
|
|
75
|
-
"envio-darwin-x64": "3.3.0-
|
|
76
|
-
"envio-darwin-arm64": "3.3.0-
|
|
73
|
+
"envio-linux-x64": "3.3.0-rc.0",
|
|
74
|
+
"envio-linux-x64-musl": "3.3.0-rc.0",
|
|
75
|
+
"envio-linux-arm64": "3.3.0-rc.0",
|
|
76
|
+
"envio-darwin-x64": "3.3.0-rc.0",
|
|
77
|
+
"envio-darwin-arm64": "3.3.0-rc.0"
|
|
77
78
|
}
|
|
78
79
|
}
|
package/src/Batch.res.mjs
CHANGED
|
@@ -27,7 +27,7 @@ function getProgressedChainsById(chainsBeforeBatch, batchSizePerChain, progressB
|
|
|
27
27
|
let progressedChain;
|
|
28
28
|
if (batchSize !== undefined) {
|
|
29
29
|
let leftItems = fetchState.buffer.slice(batchSize);
|
|
30
|
-
progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, FetchState.updateInternal(fetchState, undefined, leftItems, undefined, undefined), batchSize);
|
|
30
|
+
progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, FetchState.updateInternal(fetchState, undefined, leftItems, undefined, undefined, undefined), batchSize);
|
|
31
31
|
} else {
|
|
32
32
|
progressedChain = getChainAfterBatchIfProgressed(chainBeforeBatch, progressBlockNumberAfterBatch, chainBeforeBatch.fetchState, 0);
|
|
33
33
|
}
|
package/src/BatchProcessing.res
CHANGED
|
@@ -180,13 +180,6 @@ and processNextBatch = async (state: IndexerState.t, ~scheduleFetch): unit => {
|
|
|
180
180
|
)
|
|
181
181
|
} else {
|
|
182
182
|
ChainMetadata.stage(state)
|
|
183
|
-
if (
|
|
184
|
-
state
|
|
185
|
-
->IndexerState.config
|
|
186
|
-
->Config.shouldPruneHistory(~isInReorgThreshold=state->IndexerState.isInReorgThreshold)
|
|
187
|
-
) {
|
|
188
|
-
state->PruneStaleHistory.schedule
|
|
189
|
-
}
|
|
190
183
|
}
|
|
191
184
|
}
|
|
192
185
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Utils from "./Utils.res.mjs";
|
|
4
|
-
import * as Config from "./Config.res.mjs";
|
|
5
4
|
import * as Logging from "./Logging.res.mjs";
|
|
6
5
|
import * as ChainState from "./ChainState.res.mjs";
|
|
7
6
|
import * as IndexerState from "./IndexerState.res.mjs";
|
|
@@ -11,7 +10,6 @@ import * as InMemoryStore from "./InMemoryStore.res.mjs";
|
|
|
11
10
|
import * as ExitOnCaughtUp from "./ExitOnCaughtUp.res.mjs";
|
|
12
11
|
import * as EventProcessing from "./EventProcessing.res.mjs";
|
|
13
12
|
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
|
|
14
|
-
import * as PruneStaleHistory from "./PruneStaleHistory.res.mjs";
|
|
15
13
|
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
16
14
|
import * as SimulateDeadInputTracker from "./SimulateDeadInputTracker.res.mjs";
|
|
17
15
|
|
|
@@ -79,12 +77,7 @@ async function processNextBatch(state, scheduleFetch) {
|
|
|
79
77
|
} else if (!allCaughtUp && IndexerState.exitAfterFirstEventBlock(state) && Object.values(IndexerState.chainStates(state)).every(ChainState.isAtHeadWithoutEndBlock)) {
|
|
80
78
|
return IndexerState.errorExit(state, ErrorHandling.make(new Error("No events found between startBlock and chain head. Cannot auto-detect endBlock."), undefined, undefined));
|
|
81
79
|
} else {
|
|
82
|
-
ChainMetadata.stage(state);
|
|
83
|
-
if (Config.shouldPruneHistory(IndexerState.config(state), IndexerState.isInReorgThreshold(state))) {
|
|
84
|
-
return PruneStaleHistory.schedule(state);
|
|
85
|
-
} else {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
80
|
+
return ChainMetadata.stage(state);
|
|
88
81
|
}
|
|
89
82
|
}
|
|
90
83
|
|
package/src/ChainFetching.res
CHANGED
|
@@ -49,9 +49,9 @@ let runContractRegistersOrThrow = async (
|
|
|
49
49
|
for idx in 0 to itemsWithContractRegister->Array.length - 1 {
|
|
50
50
|
let item = itemsWithContractRegister->Array.getUnsafe(idx)
|
|
51
51
|
let eventItem = item->Internal.castUnsafeEventItem
|
|
52
|
-
let contractRegister = switch eventItem {
|
|
53
|
-
| {
|
|
54
|
-
| {
|
|
52
|
+
let contractRegister = switch eventItem.onEventRegistration {
|
|
53
|
+
| {contractRegister: Some(contractRegister)} => contractRegister
|
|
54
|
+
| {contractRegister: None, eventConfig: {name: eventName}} =>
|
|
55
55
|
// Unexpected case, since we should pass only events with contract register to this function
|
|
56
56
|
JsError.throwWithMessage("Contract register is not set for event " ++ eventName)
|
|
57
57
|
}
|
|
@@ -151,15 +151,26 @@ let rec onQueryResponse = async (
|
|
|
151
151
|
let eventItem = item->Internal.castUnsafeEventItem
|
|
152
152
|
eventItem.onEventRegistration.contractRegister !== None ? count + 1 : count
|
|
153
153
|
})
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
if numContractRegisterEvents === 0 {
|
|
155
|
+
Logging.trace({
|
|
156
|
+
"msg": "Finished querying",
|
|
157
|
+
"chainId": chain->ChainMap.Chain.toChainId,
|
|
158
|
+
"partitionId": query.partitionId,
|
|
159
|
+
"fromBlock": fromBlockQueried,
|
|
160
|
+
"toBlock": latestFetchedBlockNumber,
|
|
161
|
+
"numEvents": parsedQueueItems->Array.length,
|
|
162
|
+
})
|
|
163
|
+
} else {
|
|
164
|
+
Logging.trace({
|
|
165
|
+
"msg": "Finished querying",
|
|
166
|
+
"chainId": chain->ChainMap.Chain.toChainId,
|
|
167
|
+
"partitionId": query.partitionId,
|
|
168
|
+
"fromBlock": fromBlockQueried,
|
|
169
|
+
"toBlock": latestFetchedBlockNumber,
|
|
170
|
+
"numEvents": parsedQueueItems->Array.length,
|
|
171
|
+
"numContractRegisterEvents": numContractRegisterEvents,
|
|
172
|
+
})
|
|
173
|
+
}
|
|
163
174
|
|
|
164
175
|
let reorgResult = chainState->ChainState.registerReorgGuard(~blockHashes, ~knownHeight)
|
|
165
176
|
|
|
@@ -212,17 +223,18 @@ let rec onQueryResponse = async (
|
|
|
212
223
|
// kick (eg from the processing loop quiescing) collapses into this one.
|
|
213
224
|
scheduleRollback()
|
|
214
225
|
| None =>
|
|
226
|
+
// Drop over-fetched events (a merged partition returning an address before
|
|
227
|
+
// its effectiveStartBlock, or a wildcard param referencing an address
|
|
228
|
+
// registered after the log's block) before contract registration, so they
|
|
229
|
+
// neither spawn dynamic contracts nor enter the buffer.
|
|
230
|
+
let newItems = chainState->ChainState.filterByClientAddress(parsedQueueItems)
|
|
215
231
|
let itemsWithContractRegister = []
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
let item = parsedQueueItems->Array.getUnsafe(idx)
|
|
232
|
+
for idx in 0 to newItems->Array.length - 1 {
|
|
233
|
+
let item = newItems->Array.getUnsafe(idx)
|
|
219
234
|
let eventItem = item->Internal.castUnsafeEventItem
|
|
220
235
|
if eventItem.onEventRegistration.contractRegister !== None {
|
|
221
236
|
itemsWithContractRegister->Array.push(item)
|
|
222
237
|
}
|
|
223
|
-
// TODO: Don't really need to keep it in the queue
|
|
224
|
-
// when there's no handler (besides raw_events, processed counter, and dcsToStore consuming)
|
|
225
|
-
newItems->Array.push(item)
|
|
226
238
|
}
|
|
227
239
|
|
|
228
240
|
// Re-check staleness: contract registration is async, so the chain state
|
|
@@ -111,15 +111,26 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
111
111
|
return count;
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
if (numContractRegisterEvents === 0) {
|
|
115
|
+
Logging.trace({
|
|
116
|
+
msg: "Finished querying",
|
|
117
|
+
chainId: chain,
|
|
118
|
+
partitionId: query.partitionId,
|
|
119
|
+
fromBlock: fromBlockQueried,
|
|
120
|
+
toBlock: latestFetchedBlockNumber,
|
|
121
|
+
numEvents: parsedQueueItems.length
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
Logging.trace({
|
|
125
|
+
msg: "Finished querying",
|
|
126
|
+
chainId: chain,
|
|
127
|
+
partitionId: query.partitionId,
|
|
128
|
+
fromBlock: fromBlockQueried,
|
|
129
|
+
toBlock: latestFetchedBlockNumber,
|
|
130
|
+
numEvents: parsedQueueItems.length,
|
|
131
|
+
numContractRegisterEvents: numContractRegisterEvents
|
|
132
|
+
});
|
|
133
|
+
}
|
|
123
134
|
let reorgResult = ChainState.registerReorgGuard(chainState, response.blockHashes, knownHeight);
|
|
124
135
|
let rollbackWithReorgDetectedBlockNumber;
|
|
125
136
|
if (typeof reorgResult !== "object") {
|
|
@@ -139,14 +150,13 @@ async function onQueryResponse(state, param, stateId, scheduleFetch, schedulePro
|
|
|
139
150
|
IndexerState.beginReorg(state, chain, rollbackWithReorgDetectedBlockNumber);
|
|
140
151
|
return scheduleRollback();
|
|
141
152
|
}
|
|
153
|
+
let newItems = ChainState.filterByClientAddress(chainState, parsedQueueItems);
|
|
142
154
|
let itemsWithContractRegister = [];
|
|
143
|
-
let
|
|
144
|
-
|
|
145
|
-
let item = parsedQueueItems[idx];
|
|
155
|
+
for (let idx = 0, idx_finish = newItems.length; idx < idx_finish; ++idx) {
|
|
156
|
+
let item = newItems[idx];
|
|
146
157
|
if (item.onEventRegistration.contractRegister !== undefined) {
|
|
147
158
|
itemsWithContractRegister.push(item);
|
|
148
159
|
}
|
|
149
|
-
newItems.push(item);
|
|
150
160
|
}
|
|
151
161
|
let proceed = newItemsWithDcs => {
|
|
152
162
|
if (!IndexerState.isStale(state, stateId)) {
|