From 117852541c6943d2422e473770b313afd9bc8890 Mon Sep 17 00:00:00 2001 From: Dmitry Zakharov Date: Fri, 16 May 2025 12:01:04 +0400 Subject: [PATCH] Update docs for v2.20 --- docs/HyperIndex/Guides/schema-file.md | 1 + docs/HyperIndex/Troubleshoot/logging.mdx | 127 +++++++---------------- docs/HyperIndex/benchmarks.md | 8 +- 3 files changed, 43 insertions(+), 93 deletions(-) diff --git a/docs/HyperIndex/Guides/schema-file.md b/docs/HyperIndex/Guides/schema-file.md index b26b145b..241cb334 100644 --- a/docs/HyperIndex/Guides/schema-file.md +++ b/docs/HyperIndex/Guides/schema-file.md @@ -46,6 +46,7 @@ Scalar types represent basic data types and map directly to JavaScript, TypeScri | `BigInt` | Signed integer (`int256` in Solidity) | `bigint` | `bigint` | | `BigDecimal` | Arbitrary-size floating-point | `BigDecimal` (imported) | `BigDecimal.t` | | `Timestamp` | Timestamp with timezone | `Date` | `Js.Date.t` | +| `Json` | JSON object (from envio@2.20) | `Json` | `Js.Json.t` | Learn more about GraphQL scalars [here](https://graphql.org/learn/). diff --git a/docs/HyperIndex/Troubleshoot/logging.mdx b/docs/HyperIndex/Troubleshoot/logging.mdx index 1b61cb11..356b6ebb 100644 --- a/docs/HyperIndex/Troubleshoot/logging.mdx +++ b/docs/HyperIndex/Troubleshoot/logging.mdx @@ -29,14 +29,13 @@ When implementing handlers for your indexer, use the logging functions provided - `.log.info` - For general information about application flow - `.log.warn` - For potentially problematic situations - `.log.error` - For error events that might still allow the application to continue -- `.log.errorWithExn` - Same as `error`, but takes an exception as the first argument to include stacktraces and error messages in the log ### Examples by Language - + -```javascript +```typescript // Inside your handler context.log.debug( `Processing event with block hash: ${event.blockHash} (debug)` @@ -44,14 +43,15 @@ context.log.debug( context.log.info(`Processing event with block hash: ${event.blockHash} (info)`); context.log.warn(`Potential issue with event: ${event.blockHash} (warn)`); context.log.error(`Failed to process event: ${event.blockHash} (error)`); -context.log.errorWithExn( - new Error("Error processing event"), - `Failed to process event: ${event.blockHash}` + +// With exception: +context.log.error( + `Failed to process event: ${event.blockHash}`, + new Error("Error processing event") ); -// You can also pass objects to logs for structured logging: -context.log.info({ - msg: "Processing blockchain event", +// You can also provide an object as the second argument for structured logging: +context.log.info("Processing blockchain event", { type: "info", extra: "Additional debugging context", data: { blockHash: event.blockHash }, @@ -59,9 +59,9 @@ context.log.info({ ``` - + -```typescript +```javascript // Inside your handler context.log.debug( `Processing event with block hash: ${event.blockHash} (debug)` @@ -69,43 +69,17 @@ context.log.debug( context.log.info(`Processing event with block hash: ${event.blockHash} (info)`); context.log.warn(`Potential issue with event: ${event.blockHash} (warn)`); context.log.error(`Failed to process event: ${event.blockHash} (error)`); -context.log.errorWithExn( - new Error("Error processing event"), - `Failed to process event: ${event.blockHash}` -); -``` - -{/* Note: Our TypeScript bindings currently only accept strings as arguments to logs. We have an open issue to allow the 'any' type for more flexibility */} -For structured logging with TypeScript, use the following pattern: - -```typescript -import Logs from "generated/src/Logs.bs.js"; +// With exception: +context.log.error( + `Failed to process event: ${event.blockHash}`, + new Error("Error processing event") +); -// Inside your handler -Logs.debug(context.log, { - msg: "Processing blockchain event", - type: "debug", - data: { blockHash: event.blockHash }, -}); -Logs.info(context.log, { - msg: "Processing blockchain event", +// You can also provide an object as the second argument for structured logging: +context.log.info("Processing blockchain event", { type: "info", - data: { blockHash: event.blockHash }, -}); -Logs.warn(context.log, { - msg: "Potential issue with event", - type: "warn", - data: { blockHash: event.blockHash }, -}); -Logs.error(context.log, { - msg: "Failed to process event", - type: "error", - data: { blockHash: event.blockHash }, -}); -Logs.errorWithExn(context.log, new Error("Error in processing"), { - msg: "Failed to process event", - type: "error", + extra: "Additional debugging context", data: { blockHash: event.blockHash }, }); ``` @@ -114,52 +88,27 @@ Logs.errorWithExn(context.log, new Error("Error in processing"), { ```rescript - // Inside your handler - exception ExampleException(string) // Example of an exception - - // Basic string logging - context.log.debug(`Processing event with block hash: ${event.blockHash} (debug)`) - context.log.info(`Processing event with block hash: ${event.blockHash} (info)`) - context.log.warn(`Potential issue with event: ${event.blockHash} (warn)`) - context.log.error(`Failed to process event: ${event.blockHash} (error)`) - context.log.errorWithExn( - ExampleException("Error processing event"), - `Failed to process event: ${event.blockHash}`, - ) -``` +// Inside your handler +exception ExampleException(string) // Example of an exception -For structured logging in ReScript (since records are strictly typed and not polymorphic): +// Basic string logging +context.log.debug(`Processing event with block hash: ${event.blockHash} (debug)`) +context.log.info(`Processing event with block hash: ${event.blockHash} (info)`) +context.log.warn(`Potential issue with event: ${event.blockHash} (warn)`) +context.log.error(`Failed to process event: ${event.blockHash} (error)`) -```rescript - // Structured logging with objects - context.log->Logs.debug({ - "msg": "Processing blockchain event", - "type": "debug", - "data": {"blockHash": event.blockHash}, - }) - context.log->Logs.info({ - "msg": "Processing blockchain event", - "type": "info", - "data": {"blockHash": event.blockHash}, - }) - context.log->Logs.warn({ - "msg": "Potential issue with event", - "type": "warn", - "data": {"blockHash": event.blockHash}, - }) - context.log->Logs.error({ - "msg": "Failed to process event", - "type": "error", - "data": {"blockHash": event.blockHash}, - }) - context.log->Logs.errorWithExn( - ExampleException("Error processing event"), - { - "msg": "Failed to process event", - "type": "error", - "data": {"blockHash": event.blockHash}, - }, - ) +// With exception: +context.log.errorWithExn( + `Failed to process event: ${event.blockHash}`, + ExampleException("Error processing event") +) + +// You can also provide an object as the second argument for structured logging: +context.log.info("Processing blockchain event", ~params={ + "type": "info", + "extra": "Additional debugging context", + "data": { "blockHash": event.blockHash }, +}); ``` diff --git a/docs/HyperIndex/benchmarks.md b/docs/HyperIndex/benchmarks.md index 1c068cd4..24bdfa2e 100644 --- a/docs/HyperIndex/benchmarks.md +++ b/docs/HyperIndex/benchmarks.md @@ -13,20 +13,20 @@ HyperIndex delivers industry-leading performance for blockchain data indexing. I ## Recent Independent Benchmarks -The most comprehensive and up-to-date benchmarks were conducted by Sentio in April 2025 and are available in the [sentioxyz/indexer-benchmark repository](https://github.com/sentioxyz/indexer-benchmark). These benchmarks compare Envio's HyperIndex against other popular indexers across multiple real-world scenarios: +The most comprehensive and up-to-date benchmarks were conducted by Sentio in April 2025 and are available in the [sentio-benchmark repository](https://github.com/enviodev/sentio-benchmark). These benchmarks compare Envio's HyperIndex against other popular indexers across multiple real-world scenarios: ### Key Performance Highlights | Case | Description | Envio | Nearest Competitor | TheGraph | Ponder | Advantage vs. Nearest | | ------------------------------ | ------------------------------------------- | ------ | ------------------ | -------- | ------ | --------------------- | | LBTC Token Transfers | Event handling, No RPC calls, Write-only | 2m | 8m (Sentio) | 3h9m | 1h40m | 4x faster | -| LBTC Token with RPC calls | Event handling, RPC calls, Read-after-write | 1m | 32m (Subsquid) | 18h38m | 4h38m | 32x faster | +| LBTC Token with RPC calls | Event handling, RPC calls, Read-after-write | 15s | 32m (Subsquid) | 18h38m | 4h38m | 128x faster | | Ethereum Block Processing | 100K blocks with Metadata extraction | 7.9s | 1m (Subsquid) | 10m | 33m | 7.5x faster | | Ethereum Transaction Gas Usage | Transaction handling, Gas calculations | 1m 26s | 5m (Subsquid) | N/A | 33m | 3.5x faster | | Uniswap V2 Swap Trace Analysis | Transaction trace handling, Swap decoding | 41s | 2m (Subsquid) | 8m | N/A | 3x faster | -| Uniswap V2 Factory | Event handling, Pair and swap analysis | 20s | 2m (Subsquid) | 34m | 2h24m | 6x faster | +| Uniswap V2 Factory | Event handling, Pair and swap analysis | 10s | 2m (Subsquid) | 19m | 2h24m | 12x faster | -The independent benchmark results demonstrate that HyperIndex consistently outperforms all competitors across every tested scenario. The most significant performance advantage was seen in real-world indexing scenarios with external RPC calls, where HyperIndex was up to 32x faster than the nearest competitor and over 1000x faster than TheGraph. +The independent benchmark results demonstrate that HyperIndex consistently outperforms all competitors across every tested scenario. The most significant performance advantage was seen in real-world indexing scenarios with external RPC calls, where HyperIndex was up to 128x faster than the nearest competitor and over 4000x faster than TheGraph. ## Historical Benchmarking Results