-
Notifications
You must be signed in to change notification settings - Fork 32
Block Handler only indexer #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…out event handler
WalkthroughRenames Network→Chain and threads a new knownHeight through fetch/sources/metrics/state; adds Solana ecosystem and schema generation; threads Config into event handling and user-entities mapping; updates templates, generated types (whereOperations), Prometheus metric, and many tests/scripts. Changes
sequenceDiagram sequenceDiagram
autonumber
participant SM as SourceManager
participant Source as Source (Rpc/HyperSync/HyperFuel)
participant CF as ChainFetcher
participant FS as FetchState
participant GS as GlobalState
participant PM as Prometheus
SM->>Source: executeQuery(~knownHeight)
Source-->>SM: blockRangeFetchResponse{items, knownHeight, latestFetchedBlock...}
SM->>CF: submitPartitionQueryResponse(..., knownHeight)
CF->>FS: handleQueryResult(..., ~knownHeight)
FS->>FS: updateKnownHeight(~knownHeight)
FS->>PM: setKnownHeight(blockNumber, chainId)
CF->>GS: enqueue ProcessEventBatch (uses fetchState.knownHeight)
GS->>EventProcessing: processEventBatch(~config, using knownHeight)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Areas requiring extra attention:
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
scenarios/test_codegen/test/lib_tests/FetchState_test.res (1)
2182-2182: Remove debug logging.This
Js.logstatement appears to be debug output that should be removed before merging.- Js.log(updatedFetchState) -
🧹 Nitpick comments (5)
scenarios/helpers/src/ChainMocking.res (1)
248-248: Optional: fixheighstBlockspelling for readabilityTiny nit: consider renaming the local
heighstBlocktohighestBlock(or similar) for clarity and to avoid propagating the typo in future refactors.codegenerator/cli/templates/static/codegen/src/Index.res (1)
239-290: Consider extracting the inline state construction function.The
getStatecallback has grown significantly and is now a complex inline function with nested pattern matching. Extracting it into a separate named function would improve:
- Maintainability: Easier to understand and modify
- Testability: Can be unit tested independently
- Readability: Reduces nesting and clarifies intent
Consider refactoring to:
let getStateForConsole = (gsManagerRef, envioVersion, indexer) => { switch gsManagerRef.contents { | None => Initializing({}) | Some(gsManager) => { let state = gsManager->GlobalStateManager.getState let appState = state->makeAppState Active({ envioVersion, chains: appState.chains->Js.Array2.map(c => { // ... existing mapping logic }), indexerStartTime: appState.indexerStartTime, isPreRegisteringDynamicContracts: false, rollbackOnReorg: indexer.config.shouldRollbackOnReorg, isUnorderedMultichainMode: switch indexer.config.multichain { | Unordered => true | Ordered => false }, }) } } } // Then use it: startServer(~indexer, ~isDevelopmentMode, ~getState=() => getStateForConsole(gsManagerRef, envioVersion, indexer) )codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs (1)
6-19: Avoid potential duplicatemochascript keys for hybrid TS+ReScript projectsThe new scripts cleanly separate TS (
test/**/*.ts) and ReScript (test/**/*.res.mjs) runs. One caveat: if a project ever sets bothis_typescriptandis_rescriptto true, this template will emit two"mocha"entries and only the last one will take effect. If hybrid setups are in scope, consider renaming tomocha:ts/mocha:rescriptand having"test"delegate to both; otherwise this change is fine as-is.If you expect any projects to enable both flags, generate a sample package.json with both
is_typescriptandis_rescriptset and confirm the resulting scripts match your intent.codegenerator/cli/npm/envio/src/LoadLayer.res (1)
31-45: Direct use of entity.id is fine; consider centralizing ID accessKeying both
entitiesMapandInMemoryTable.Entity.initValuebyentity.idis consistent with how IDs are loaded from storage and should behave the same as any thin accessor that previously wrapped.id.If you expect
Internal.entity’s ID representation to evolve, it may be worth routing these call sites through the same helper used elsewhere (e.g.,InMemoryTable.Entity.getEntityIdUnsafe) to keep the ID logic centralized.Also applies to: 399-405
codegenerator/cli/src/config_parsing/human_config.rs (1)
61-85: Consider reusingBaseConfiginevmandfuelmodules.The
BaseConfigstruct captures shared fields (name,description,schema,output,handlers) that are duplicated inevm::HumanConfig(lines 166-246) andfuel::HumanConfig(lines 597-640). While this may be intentional for schema generation purposes, using#[serde(flatten)]as done insolana::HumanConfigcould reduce duplication.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
codegenerator/cli/npm/envio/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlscenarios/block_handler/pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlscenarios/test_codegen/pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (63)
codegenerator/cli/Makefile(1 hunks)codegenerator/cli/npm/envio/evm.schema.json(6 hunks)codegenerator/cli/npm/envio/fuel.schema.json(5 hunks)codegenerator/cli/npm/envio/package.json(1 hunks)codegenerator/cli/npm/envio/package.json.tmpl(1 hunks)codegenerator/cli/npm/envio/solana.schema.json(1 hunks)codegenerator/cli/npm/envio/src/ChainFetcher.res(6 hunks)codegenerator/cli/npm/envio/src/ChainManager.res(2 hunks)codegenerator/cli/npm/envio/src/Config.res(4 hunks)codegenerator/cli/npm/envio/src/Envio.gen.ts(1 hunks)codegenerator/cli/npm/envio/src/Envio.res(2 hunks)codegenerator/cli/npm/envio/src/EventProcessing.res(10 hunks)codegenerator/cli/npm/envio/src/FetchState.res(14 hunks)codegenerator/cli/npm/envio/src/GlobalState.res(15 hunks)codegenerator/cli/npm/envio/src/LoadLayer.res(1 hunks)codegenerator/cli/npm/envio/src/Prometheus.res(1 hunks)codegenerator/cli/npm/envio/src/ReorgDetection.res(3 hunks)codegenerator/cli/npm/envio/src/UserContext.res(6 hunks)codegenerator/cli/npm/envio/src/sources/HyperFuelSource.res(5 hunks)codegenerator/cli/npm/envio/src/sources/HyperSyncSource.res(5 hunks)codegenerator/cli/npm/envio/src/sources/RpcSource.res(3 hunks)codegenerator/cli/npm/envio/src/sources/Source.res(2 hunks)codegenerator/cli/npm/envio/src/sources/SourceManager.res(8 hunks)codegenerator/cli/npm/envio/src/sources/SourceManager.resi(1 hunks)codegenerator/cli/src/cli_args/clap_definitions.rs(1 hunks)codegenerator/cli/src/cli_args/init_config.rs(6 hunks)codegenerator/cli/src/config_parsing/graph_migration/mod.rs(7 hunks)codegenerator/cli/src/config_parsing/human_config.rs(23 hunks)codegenerator/cli/src/config_parsing/system_config.rs(17 hunks)codegenerator/cli/src/config_parsing/validation.rs(2 hunks)codegenerator/cli/src/executor/mod.rs(1 hunks)codegenerator/cli/src/hbs_templating/codegen_templates.rs(2 hunks)codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs(1 hunks)codegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs(2 hunks)codegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs(1 hunks)codegenerator/cli/templates/dynamic/codegen/src/db/Enums.res.hbs(0 hunks)codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs(1 hunks)codegenerator/cli/templates/static/codegen/src/Index.res(6 hunks)codegenerator/cli/templates/static/codegen/src/ink/components/ChainData.res(6 hunks)codegenerator/cli/templates/static/codegen/src/ink/components/SyncETA.res(1 hunks)codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json(0 hunks)codegenerator/integration_tests/tests/test_indexers/test_exits/package.json(0 hunks)codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json(0 hunks)scenarios/block_handler/.gitignore(1 hunks)scenarios/block_handler/config.yaml(1 hunks)scenarios/block_handler/package.json(1 hunks)scenarios/block_handler/schema.graphql(1 hunks)scenarios/block_handler/src/handlers/BlockHandler.ts(1 hunks)scenarios/block_handler/tsconfig.json(1 hunks)scenarios/fuel_test/package.json(0 hunks)scenarios/helpers/src/ChainMocking.res(2 hunks)scenarios/test_codegen/package.json(0 hunks)scenarios/test_codegen/test/ChainManager_test.res(1 hunks)scenarios/test_codegen/test/E2E_test.res(2 hunks)scenarios/test_codegen/test/EventOrigin_test.res(1 hunks)scenarios/test_codegen/test/ReorgDetection_test.res(12 hunks)scenarios/test_codegen/test/helpers/Mock.res(5 hunks)scenarios/test_codegen/test/lib_tests/FetchState_onBlock_test.res(1 hunks)scenarios/test_codegen/test/lib_tests/FetchState_test.res(53 hunks)scenarios/test_codegen/test/lib_tests/SourceManager_test.res(37 hunks)scenarios/test_codegen/test/rollback/Rollback_test.res(3 hunks)scenarios/test_codegen/test/schema_types/BigDecimal_test.res(1 hunks)scenarios/test_codegen/test/schema_types/Timestamp_test.res(1 hunks)
💤 Files with no reviewable changes (6)
- codegenerator/cli/templates/dynamic/codegen/src/db/Enums.res.hbs
- codegenerator/integration_tests/tests/test_indexers/test_exits/package.json
- scenarios/test_codegen/package.json
- scenarios/fuel_test/package.json
- codegenerator/integration_tests/tests/test_indexers/dynamic_contracts/package.json
- codegenerator/integration_tests/tests/test_indexers/wildcard-uni-factory/package.json
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{res,resi}
📄 CodeRabbit inference engine (.cursor/rules/rescript.mdc)
**/*.{res,resi}: Always use ReScript 11 documentation
Never suggest ReasonML syntax
Never use[| item |]to create an array. Use[ item ]instead
Must always use=for setting value to a field. Use:=only for ref values created usingreffunction
Use records when working with structured data, and objects to conveniently pass payload data between functions
Never use %raw to access object fields if you know the type
Files:
scenarios/test_codegen/test/EventOrigin_test.rescodegenerator/cli/npm/envio/src/Config.rescodegenerator/cli/templates/static/codegen/src/ink/components/SyncETA.resscenarios/test_codegen/test/ReorgDetection_test.rescodegenerator/cli/npm/envio/src/Envio.resscenarios/helpers/src/ChainMocking.rescodegenerator/cli/npm/envio/src/UserContext.rescodegenerator/cli/npm/envio/src/sources/Source.resscenarios/test_codegen/test/E2E_test.rescodegenerator/cli/npm/envio/src/sources/HyperSyncSource.rescodegenerator/cli/templates/static/codegen/src/ink/components/ChainData.resscenarios/test_codegen/test/rollback/Rollback_test.resscenarios/test_codegen/test/schema_types/Timestamp_test.resscenarios/test_codegen/test/lib_tests/SourceManager_test.rescodegenerator/cli/npm/envio/src/sources/SourceManager.rescodegenerator/cli/templates/static/codegen/src/Index.rescodegenerator/cli/npm/envio/src/Prometheus.rescodegenerator/cli/npm/envio/src/EventProcessing.rescodegenerator/cli/npm/envio/src/ChainManager.rescodegenerator/cli/npm/envio/src/ReorgDetection.rescodegenerator/cli/npm/envio/src/ChainFetcher.rescodegenerator/cli/npm/envio/src/sources/SourceManager.resicodegenerator/cli/npm/envio/src/LoadLayer.rescodegenerator/cli/npm/envio/src/GlobalState.rescodegenerator/cli/npm/envio/src/sources/RpcSource.resscenarios/test_codegen/test/schema_types/BigDecimal_test.rescodegenerator/cli/npm/envio/src/FetchState.resscenarios/test_codegen/test/ChainManager_test.resscenarios/test_codegen/test/lib_tests/FetchState_onBlock_test.resscenarios/test_codegen/test/lib_tests/FetchState_test.resscenarios/test_codegen/test/helpers/Mock.rescodegenerator/cli/npm/envio/src/sources/HyperFuelSource.res
codegenerator/cli/templates/static/**/*.res
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Static ReScript files must be placed in
codegenerator/cli/templates/static/
Files:
codegenerator/cli/templates/static/codegen/src/ink/components/SyncETA.rescodegenerator/cli/templates/static/codegen/src/ink/components/ChainData.rescodegenerator/cli/templates/static/codegen/src/Index.res
codegenerator/cli/templates/dynamic/**/*.hbs
📄 CodeRabbit inference engine (.cursor/rules/navigation.mdc)
Handlebars templates must be placed in
codegenerator/cli/templates/dynamic/
Files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbscodegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbscodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbscodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
🧠 Learnings (35)
📓 Common learnings
Learnt from: nikbhintade
Repo: enviodev/hyperindex PR: 822
File: codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts:10-18
Timestamp: 2025-11-19T05:36:33.975Z
Learning: The multichain_indexer_template in codegenerator/cli/templates/static/ is designed to demonstrate multichain indexing features. It intentionally uses minimal event parameters (e.g., only capturing the `pool` address from Uniswap V3 PoolCreated events) to keep the focus on multichain functionality rather than comprehensive event indexing.
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.graphql : Use `entity_id` fields for relationships in GraphQL schemas (e.g., `user_id: String!`) instead of direct entity references or entity arrays
Applied to files:
scenarios/block_handler/schema.graphqlcodegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbscodegenerator/cli/npm/envio/src/LoadLayer.rescodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{yaml,yml} : Use the Envio EVM schema file for YAML validation in config.yaml: `yaml-language-server: $schema=./node_modules/envio/evm.schema.json`
Applied to files:
scenarios/block_handler/config.yamlcodegenerator/cli/npm/envio/solana.schema.jsoncodegenerator/cli/Makefilecodegenerator/cli/npm/envio/evm.schema.json
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 4 - Implement contract registration for factory events using `contractRegister` above the handler to track dynamically created contracts: `Factory.EventName.contractRegister(({ event, context }) => { context.addContractName(event.params.contractAddress); });`
Applied to files:
scenarios/test_codegen/test/EventOrigin_test.resscenarios/block_handler/src/handlers/BlockHandler.tscodegenerator/cli/npm/envio/src/UserContext.resscenarios/test_codegen/test/lib_tests/FetchState_test.res
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/generated/src/Config.res : Generated config module must be named `Config.res` and convert environment variables to typed config, setting up persistence
Applied to files:
codegenerator/cli/npm/envio/src/Config.resscenarios/block_handler/.gitignorecodegenerator/cli/npm/envio/src/EventProcessing.res
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For entity creation patterns, always include all required fields in a single object literal and use `context.Entity.set(entity)` (without await). Update patterns should spread existing entity data and update only changed fields: `const updated = { ...existing, field: newValue }; context.Entity.set(updated);`
Applied to files:
codegenerator/cli/npm/envio/src/Config.rescodegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/npm/envio/src/Envio.rescodegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbscodegenerator/cli/npm/envio/src/LoadLayer.rescodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbscodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : In Envio HyperIndex, use `entity_id` fields (e.g., `token_id: string`) instead of direct object references for entity relationships
Applied to files:
codegenerator/cli/npm/envio/src/Config.rescodegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/npm/envio/src/Envio.rescodegenerator/cli/npm/envio/solana.schema.jsoncodegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbscodegenerator/cli/templates/static/codegen/src/Index.rescodegenerator/cli/npm/envio/src/LoadLayer.rescodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbscodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: After any change to TypeScript files, run `pnpm tsc --noEmit` to ensure successful compilation
Applied to files:
scenarios/block_handler/tsconfig.jsoncodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 3 - Refactor file structure to mirror the original subgraph EXACTLY using the same filenames, create separate handler files by contract (e.g., contract1.ts, contract2.ts) instead of a single EventHandlers.ts file, and move handlers from EventHandlers.ts to contract-specific files
Applied to files:
scenarios/block_handler/tsconfig.jsoncodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : When updating existing entities in HyperIndex handlers, always use the spread operator for immutability since returned objects are read-only
Applied to files:
scenarios/block_handler/tsconfig.jsoncodegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbscodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/{**/*.ts,**/schema.graphql} : Ensure database schema compatibility: verify that the types you're setting in code match the schema entity property types exactly. Compare with schema.graphql - for example, `Int!` in schema requires `number` in code, `BigInt!` requires `BigInt`, `BigDecimal!` requires `BigDecimal`
Applied to files:
scenarios/block_handler/tsconfig.jsoncodegenerator/cli/npm/envio/src/Envio.gen.ts
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Always verify entity type field names match exactly with the generated entity types. For example, use `token0_id` not `token0`, and `transaction_id` not `transaction`. Run `pnpm tsc --noEmit` to catch type mismatches
Applied to files:
scenarios/block_handler/tsconfig.jsoncodegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Use `string | undefined` for optional string fields in Envio types, not `string | null`, as generated types are strict about null vs undefined
Applied to files:
scenarios/block_handler/tsconfig.jsoncodegenerator/cli/npm/envio/src/Envio.gen.ts
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : Import and use the Effect API (`S`, `createEffect`) from 'envio' package for external calls in HyperIndex handlers
Applied to files:
scenarios/block_handler/tsconfig.json
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : `derivedFrom` arrays in Envio are VIRTUAL fields that exist only when querying the API, not in handlers. You CANNOT access them in handlers (e.g., `transaction.mints` will not work). Use `context.Entity.getWhere.fieldName.eq(value)` to query related entities instead
Applied to files:
codegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/npm/envio/src/Envio.rescodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Import entity types from `generated/src/db/Entities.gen` for type annotations (e.g., `Pair_t`, `Token_t`), NOT from `generated` which exports contract handlers. Use the correct entity type imports to prevent TypeScript errors like 'refers to a value, but is being used as a type'
Applied to files:
codegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbscodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : All TypeScript handler and utility files must have proper async/await for database operations. Use `await` for `context.Entity.get()`, `context.Entity.getWhere().field.eq()` calls. Note: `context.Entity.set()` does NOT need `await` - it's synchronous
Applied to files:
codegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/schema.graphql : For Step 2 - Migrate GraphQL schema from TheGraph format to Envio format: remove `entity` decorators, convert `Bytes!` to `String!`, convert `ID!` to `ID!` (keep as is), and ensure ALL entity arrays have `derivedFrom(field: "fieldName")` directives to prevent 'EE211: Arrays of entities is unsupported' error
Applied to files:
codegenerator/cli/npm/envio/src/Envio.gen.tscodegenerator/cli/npm/envio/src/Envio.rescodegenerator/cli/npm/envio/solana.schema.jsoncodegenerator/cli/Makefilecodegenerator/cli/npm/envio/src/LoadLayer.rescodegenerator/cli/npm/envio/evm.schema.jsoncodegenerator/cli/npm/envio/fuel.schema.jsoncodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js} : Always cast timestamps to BigInt using `BigInt(event.block.timestamp)` instead of using raw timestamps from events
Applied to files:
codegenerator/cli/templates/static/codegen/src/ink/components/SyncETA.resscenarios/block_handler/src/handlers/BlockHandler.tscodegenerator/cli/templates/dynamic/codegen/src/TestHelpers_MockDb.res.hbs
📚 Learning: 2025-05-27T17:07:12.878Z
Learnt from: JonoPrest
Repo: enviodev/hyperindex PR: 555
File: scenarios/test_codegen/test/lib_tests/EntityHistory_test.res:631-659
Timestamp: 2025-05-27T17:07:12.878Z
Learning: In isolated tests for EntityHistory rollbacks with controlled mock data setup, the ordering of getRollbackDiff results is deterministic and doesn't require sorting before comparison with deepStrictEqual.
Applied to files:
scenarios/test_codegen/test/ReorgDetection_test.res
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/schema.graphql : CRITICAL ENVIO REQUIREMENT: All entity arrays like `[Mint!]!` MUST have `derivedFrom` directives. Without this, codegen will fail with error 'EE211: Arrays of entities is unsupported'
Applied to files:
codegenerator/cli/npm/envio/solana.schema.jsoncodegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: After any change to `schema.graphql` or `config.yaml`, run `pnpm codegen`
Applied to files:
codegenerator/cli/Makefile
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner
Applied to files:
codegenerator/cli/npm/envio/package.json.tmplcodegenerator/cli/npm/envio/package.jsoncodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.graphql : NEVER use arrays of entities (e.g., `[Enter!]!` or `[User!]!`) in HyperIndex GraphQL schemas - use `entity_id` fields instead
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/Generated.res.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/config.yaml : When using multichain indexing, ensure contract names in config.yaml are unique across all networks, place contract definitions in the global contracts section (not in network sections), and only define addresses for those contracts in network sections
Applied to files:
codegenerator/cli/src/config_parsing/validation.rscodegenerator/cli/npm/envio/evm.schema.jsoncodegenerator/cli/npm/envio/fuel.schema.jsoncodegenerator/cli/src/cli_args/init_config.rscodegenerator/cli/src/config_parsing/human_config.rs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript
Applied to files:
scenarios/test_codegen/test/lib_tests/SourceManager_test.rescodegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: For multichain indexing, prefix all entity IDs with `event.chainId`: `${event.chainId}-${originalId}`, never hardcode `chainId = 1`, always use `event.chainId`, and use chain-specific Bundle IDs like `${chainId}-1` for accurate pricing per network
Applied to files:
codegenerator/cli/npm/envio/src/ChainManager.rescodegenerator/cli/npm/envio/src/ChainFetcher.res
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Config parsing pipeline follows: `human_config.rs` → `system_config.rs` → `hbs_templating/codegen_templates.rs`
Applied to files:
codegenerator/cli/src/config_parsing/graph_migration/mod.rscodegenerator/cli/src/cli_args/init_config.rscodegenerator/cli/src/config_parsing/system_config.rscodegenerator/cli/src/config_parsing/human_config.rs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : When accessing entity fields that represent relationships, use the `_id` suffix convention. For example, use `token0_id` not `token0` when storing relationships in entity types
Applied to files:
codegenerator/cli/npm/envio/src/LoadLayer.rescodegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.graphql : Do not add the entity decorator to GraphQL schema types in HyperIndex
Applied to files:
codegenerator/cli/templates/dynamic/codegen/src/db/Entities.res.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests
Applied to files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to codegenerator/cli/templates/static/**/*.res : Static ReScript files must be placed in `codegenerator/cli/templates/static/`
Applied to files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For Step 6 - Final Migration Verification: Go through each handler and helper function systematically, comparing the logic line-by-line to the original subgraph implementation. Iterate multiple times until logic is completely correct, as first pass often misses subtle differences
Applied to files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:12:49.534Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.534Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.{ts,js,yaml,yml} : Ensure case consistency when matching addresses in configuration objects, using lowercase keys to match `address.toLowerCase()` lookups
Applied to files:
codegenerator/cli/templates/dynamic/init_templates/shared/package.json.hbs
📚 Learning: 2025-12-04T12:13:23.231Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.231Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : MAINTAIN BigDecimal precision from the original subgraph. Use BigDecimal and BigInt types for financial calculations, never simplify to JavaScript number type which loses precision. Always use BigDecimal constants (ZERO_BD, ONE_BD) and BigInt constants (ZERO_BI, ONE_BI)
Applied to files:
scenarios/test_codegen/test/schema_types/BigDecimal_test.res
🧬 Code graph analysis (1)
codegenerator/cli/src/config_parsing/graph_migration/mod.rs (1)
codegenerator/cli/src/config_parsing/contract_import/converters.rs (2)
new(17-27)new(98-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
codegenerator/cli/npm/envio/src/sources/SourceManager.res (1)
3-3: Typo in enum variant: "Querieng" → "Querying".-type sourceManagerStatus = Idle | WaitingForNewBlock | Querieng +type sourceManagerStatus = Idle | WaitingForNewBlock | QueryingNote: This will require updating all references to
Queriengthroughout the codebase (e.g., lines 82, 138).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.github/workflows/build_and_test.yml(0 hunks)codegenerator/cli/npm/envio/src/GlobalState.res(14 hunks)codegenerator/cli/npm/envio/src/sources/SourceManager.res(9 hunks)scenarios/block_handler/src/handlers/BlockHandler.ts(1 hunks)scenarios/test_codegen/package.json(1 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/build_and_test.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- scenarios/block_handler/src/handlers/BlockHandler.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{res,resi}
📄 CodeRabbit inference engine (.cursor/rules/rescript.mdc)
**/*.{res,resi}: Always use ReScript 11 documentation
Never suggest ReasonML syntax
Never use[| item |]to create an array. Use[ item ]instead
Must always use=for setting value to a field. Use:=only for ref values created usingreffunction
Use records when working with structured data, and objects to conveniently pass payload data between functions
Never use %raw to access object fields if you know the type
Files:
codegenerator/cli/npm/envio/src/sources/SourceManager.rescodegenerator/cli/npm/envio/src/GlobalState.res
🧠 Learnings (10)
📓 Common learnings
Learnt from: nikbhintade
Repo: enviodev/hyperindex PR: 822
File: codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts:10-18
Timestamp: 2025-11-19T05:36:33.975Z
Learning: The multichain_indexer_template in codegenerator/cli/templates/static/ is designed to demonstrate multichain indexing features. It intentionally uses minimal event parameters (e.g., only capturing the `pool` address from Uniswap V3 PoolCreated events) to keep the focus on multichain functionality rather than comprehensive event indexing.
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: After any change to TypeScript files, run `pnpm tsc --noEmit` to ensure successful compilation
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Verify tests pass by running `pnpm rescript` compiler and `pnpm mocha` test runner
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : Always verify entity type field names match exactly with the generated entity types. For example, use `token0_id` not `token0`, and `transaction_id` not `transaction`. Run `pnpm tsc --noEmit` to catch type mismatches
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/{**/*.ts,**/schema.graphql} : Ensure database schema compatibility: verify that the types you're setting in code match the schema entity property types exactly. Compare with schema.graphql - for example, `Int!` in schema requires `number` in code, `BigInt!` requires `BigInt`, `BigDecimal!` requires `BigDecimal`
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/*.ts : For Step 6 - Final Migration Verification: Go through each handler and helper function systematically, comparing the logic line-by-line to the original subgraph implementation. Iterate multiple times until logic is completely correct, as first pass often misses subtle differences
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 3 - Refactor file structure to mirror the original subgraph EXACTLY using the same filenames, create separate handler files by contract (e.g., contract1.ts, contract2.ts) instead of a single EventHandlers.ts file, and move handlers from EventHandlers.ts to contract-specific files
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Prefer public module APIs for testing in ReScript
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-11-25T12:40:19.463Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: .cursor/rules/navigation.mdc:0-0
Timestamp: 2025-11-25T12:40:19.463Z
Learning: Applies to **/*.{test.res,spec.res} : Use `_only` to specify which tests to run in ReScript Mocha tests
Applied to files:
scenarios/test_codegen/package.json
📚 Learning: 2025-12-04T12:12:49.547Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/hyperindex.mdc:0-0
Timestamp: 2025-12-04T12:12:49.547Z
Learning: Whitelist the following commands for HyperIndex development: `pnpm codegen` and `pnpm tsc --noEmit`
Applied to files:
scenarios/test_codegen/package.json
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (11)
scenarios/test_codegen/package.json (1)
13-13: Add TypeScript type-check to test pipeline.The addition of
tsc --noEmitbefore Mocha is a good practice that aligns with the broader PR refactoring and ensures type correctness early in the test pipeline. This catches type issues before runtime, which is especially valuable given the configuration/schema changes in this PR. Thetsconfig.jsonfile exists in the directory with proper configuration, so thetsccommand will execute correctly.codegenerator/cli/npm/envio/src/sources/SourceManager.res (4)
102-124: TheknownHeightrename is applied consistently.The parameter rename from
currentBlockHeighttoknownHeightis correctly propagated throughfetchNext, including thewaitForNewBlockcall andonNewBlockcallback.
162-211: Height polling logic correctly updated to useknownHeight.The
getSourceNewHeightfunction properly usesknownHeightin the while-loop condition and comparison, maintaining the original polling semantics.
214-255:waitForNewBlockcorrectly integratesknownHeightwith source selection logic.The conditional logic for including Live sources only after initial sync (
knownHeight === 0check) is sensible and well-commented.
381-391: Query execution correctly passesknownHeighttogetItemsOrThrow.The parameter is consistently renamed in the call site.
codegenerator/cli/npm/envio/src/GlobalState.res (6)
115-120: LGTM: Action type definitions correctly updated.The action type definitions have been properly updated to use
knownHeightinstead ofcurrentBlockHeight. The field names are clear and consistent.
347-382: LGTM: Response validation correctly uses knownHeight.The validation logic properly destructures
knownHeightfrom the response and uses it for:
- Prometheus metrics updates
- Reorg guard registration
- Comparison with the chain fetcher's current known height
The logic is sound and the naming is more accurate than the previous
currentBlockHeight.
460-475: LGTM: Query result submission correctly threaded.The
knownHeightparameter is properly passed through toChainFetcher.handleQueryResult. The function signature and call site are consistent.
591-631: LGTM: State update logic correctly handles knownHeight.The
FinishWaitingForNewBlockaction handler properly:
- Updates fetch state with the new
knownHeight(lines 595-596)- Checks reorg threshold readiness using the updated fetchers (lines 612-616)
- Dispatches appropriate follow-up actions including
ProcessEventBatch(lines 628, 630)The comment at line 626 about block handlers aligns well with the PR objective of supporting "Block Handlers without events."
832-961: LGTM: InMemoryStore and entity pruning use correct data source.The entity iteration for pruning (lines 832, 838) and InMemoryStore initialization (line 961) correctly reference
state.indexer.persistence.allEntities, which aligns with the updated data flow structure.
788-808: External module functions have been properly updated to acceptknownHeight.The callbacks in GlobalState.res correctly pass
knownHeightto:
waitForNewBlock(line 792)onNewBlockvia theFinishWaitingForNewBlockaction (line 793)executeQuerywith~knownHeight=fetchState.knownHeight(line 799)Verification confirms that
SourceManager.waitForNewBlock(line 214) andSourceManager.executeQuery(line 344) have both been updated to accept the~knownHeightparameter. The code changes are correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
scenarios/test_codegen/test/lib_tests/FetchState_test.res(54 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{res,resi}
📄 CodeRabbit inference engine (.cursor/rules/rescript.mdc)
**/*.{res,resi}: Always use ReScript 11 documentation
Never suggest ReasonML syntax
Never use[| item |]to create an array. Use[ item ]instead
Must always use=for setting value to a field. Use:=only for ref values created usingreffunction
Use records when working with structured data, and objects to conveniently pass payload data between functions
Never use %raw to access object fields if you know the type
Files:
scenarios/test_codegen/test/lib_tests/FetchState_test.res
🧠 Learnings (2)
📓 Common learnings
Learnt from: nikbhintade
Repo: enviodev/hyperindex PR: 822
File: codegenerator/cli/templates/static/multichain_indexer_template/typescript/src/EventHandlers.ts:10-18
Timestamp: 2025-11-19T05:36:33.975Z
Learning: The multichain_indexer_template in codegenerator/cli/templates/static/ is designed to demonstrate multichain indexing features. It intentionally uses minimal event parameters (e.g., only capturing the `pool` address from Uniswap V3 PoolCreated events) to keep the focus on multichain functionality rather than comprehensive event indexing.
📚 Learning: 2025-12-04T12:13:23.246Z
Learnt from: CR
Repo: enviodev/hyperindex PR: 0
File: codegenerator/cli/templates/static/shared/.cursor/rules/subgraph-migration.mdc:0-0
Timestamp: 2025-12-04T12:13:23.246Z
Learning: Applies to codegenerator/cli/templates/static/shared/**/src/**/*.ts : For Step 4 - Implement contract registration for factory events using `contractRegister` above the handler to track dynamically created contracts: `Factory.EventName.contractRegister(({ event, context }) => { context.addContractName(event.params.contractAddress); });`
Applied to files:
scenarios/test_codegen/test/lib_tests/FetchState_test.res
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build_and_test
🔇 Additional comments (3)
scenarios/test_codegen/test/lib_tests/FetchState_test.res (3)
6-6: LGTM: knownHeight threading and contractName string conversion.The mechanical changes replacing
currentBlockHeightwithknownHeightthroughout the test file are consistent and align with the PR objectives. The conversion ofcontractNameto a plain string field (removing the enum) is also correct.Also applies to: 48-56, 113-114, 179-179, 195-195
199-199: LGTM: Error message updated to reflect onBlock handler support.The error message now correctly mentions that onBlock handlers are a valid alternative to events or contracts, which aligns with the PR's goal of supporting Block Handler only indexers.
2981-3082: LGTM: Test suite validates Block Handler only indexer feature.The new test suite correctly validates the core PR feature of supporting indexers with only block handlers and no events. The test logic is sound:
- Creates FetchState with no event configs but with onBlockConfig
- Verifies getNextQuery returns WaitingForNewBlock when knownHeight is 0
- Updates knownHeight and verifies buffer is populated with block items
- Validates expected block numbers and state transitions
The test provides good coverage for this new capability.
| chainFetcher.reorgDetection->ReorgDetection.getThresholdBlockNumbersBelowBlock( | ||
| ~blockNumber=reorgBlockNumber, | ||
| ~currentBlockHeight=chainFetcher.currentBlockHeight, | ||
| ~knownHeight=chainFetcher.fetchState.knownHeight, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is knownHeight essentially current height?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that known height is better since we have multiple sources and also source might have a different height than the one we know in hyperindex. This is why I decided to use the name. It's also internal only
| }; | ||
|
|
||
| chain.contracts.push(contract); | ||
| chain.contracts.get_or_insert_with(Vec::new).push(contract); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try run cargo clippy, it will likely suggest you use get_or_default().push(contract) or something like that.
| #[serde(skip_serializing_if = "Option::is_none")] | ||
| #[schemars( | ||
| description = "Optional relative path to handlers directory for auto-loading. Defaults \ | ||
| to 'src/handlers' if not specified." | ||
| )] | ||
| pub handlers: Option<String>, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A suggestion here, since we are adding new config.
I've found its simpler to have non optional fieilds with defaults like this:
https://github.com/enviodev/hypersync-client-rust/blob/eedeed4544ba44219d5a22e8f319b93e157e96c3/hypersync-client/src/config.rs#L17-L34
And then you can still have skip_serializing_if functions that check if it matches the default. Means the schema gets the actual defaults and there's less parsing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I don't want to have defaults on the rust side. The goal is to serialize the config to json at some point and parse it in ReScript side
|
|
||
| /// Base configuration fields shared across all ecosystems | ||
| #[derive(Debug, Serialize, Deserialize, PartialEq, Clone, JsonSchema)] | ||
| pub struct BaseConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth using this in Evm and fuel config?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did it in the next pr. I didn't noticed that it didn't happen here
| {{/each}} | ||
|
|
||
| let allEnums = ([ | ||
| ContractType.config->Table.fromGenericEnumConfig, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we're just using strings in postgres for this now? I'm sure it's fine 👍🏼, depending on where its used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, from 2.30 or something the enum is unused
JonoPrest
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool 👍🏼, non blocking comments only.
Just want to understand is knownHeight the source's height?
Wondering if sourceHeight is a better name.
ContractTypeenumchain_block_heighttoenvio_indexing_known_heightcontractsoptional inconfig.yamlSummary by CodeRabbit
New Features
API Changes
Dependencies
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.