Skip to content

Improve retry logging using error handler#2

Merged
JonoPrest merged 1 commit into
mainfrom
jp/improve-retry-logging
Jun 4, 2024
Merged

Improve retry logging using error handler#2
JonoPrest merged 1 commit into
mainfrom
jp/improve-retry-logging

Conversation

@JasoonS

@JasoonS JasoonS commented May 24, 2024

Copy link
Copy Markdown
Contributor

Migrated PR from Float-Capital/indexer#1549

@JasoonS JasoonS closed this May 24, 2024
@JasoonS JasoonS deleted the jp/improve-retry-logging branch May 24, 2024 09:50
@JasoonS JasoonS restored the jp/improve-retry-logging branch May 24, 2024 10:26
@JasoonS JasoonS reopened this May 24, 2024

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally made this PR. @JasoonS are you happy if I merge?

@JasoonS

JasoonS commented Jun 4, 2024

Copy link
Copy Markdown
Contributor Author

Cool, go for it

@JonoPrest JonoPrest merged commit ba4fc96 into main Jun 4, 2024
DZakh pushed a commit that referenced this pull request Mar 25, 2026
Only the global `type chainId = [#1 | #2]` is kept. Per-contract
narrowing (e.g., `[#1]` inside Contract1) was unused and didn't
provide meaningful type safety. Event types now resolve chainId
to the global type.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4
DZakh added a commit that referenced this pull request Mar 31, 2026
* Add simulate field to test indexer process() API

Allows test indexer to process user-specified events without fetching from
real sources. When `simulate` is provided in a chain's process config,
a SimulateSource replaces real chain sources and returns only the specified items.

- SimulateSource: Source.t implementation that returns pre-built items
- SimulateItems: Parses simulate config into Internal.item using event schemas
- Main.start: Accepts optional processConfig to override chain sources
- TestIndexer: Passes processConfig to worker with BigInt-safe serialization
- TS types: SimulateItem, SimulateEventItem, SimulateBlockItem in index.d.ts

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Add lock file updates and plan notes

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Update plan for typesafe ecosystem-scoped simulate API

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Update plan: scope simulate by ecosystem, no SVM, Fuel event kinds

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Add typesafe simulate API scoped by ecosystem contracts and events

Codegen now emits contract event names into EvmContracts/FuelContracts types
(e.g. `"Gravatar": { events: "NewGravatar" | "UpdatedGravatar" }`), enabling
TypeScript to validate simulate items' contract+event pairs at compile time.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Move simulate source patching out of Main.res into SimulateItems helper

- Extract simulate config patching logic into SimulateItems.patchConfig
- Main.start takes optional ~patchConfig callback instead of ~processConfig
- TestIndexer constructs patchConfig closure using SimulateItems.patchConfig
- Split SimulateItemForConfig into per-ecosystem types (EvmSimulateItem,
  FuelSimulateItem, SvmSimulateItem) with ecosystem-specific chain configs

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Delete old MockDb/TestHelpers in favor of createTestIndexer + simulate API

- Remove TestHelpers_MockDb.res.hbs template entirely
- Simplify TestHelpers.res.hbs to only export Addresses
- Update index.d.ts.hbs to remove MockDb exports
- Convert all MockDb tests to use createTestIndexer + simulate
- Update template test files (greeter, erc20, fuel, contract import)
- Fix SimulateItems.parse to use undefined for events with no params

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Fix contract import templates and export Addresses directly

- ReScript template: Indexer.createTestIndexer() (not Generated), remove Some() wrapper
- TS template: extract event variable, restore expected entity comparison with toEqual
- Export Addresses directly from generated package (index.js.hbs, index.d.ts.hbs)
- Update erc20/greeter/greeteronfuel templates to import Addresses directly

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Move MockAddresses to envio package and add simulate to ReScript template

- Move TestHelpers_MockAddresses.res from static codegen to envio/src
- Export Addresses directly from envio package (index.js, index.d.ts)
- Update generated index.d.ts.hbs to import Addresses from "envio"
- Remove @Gentype from TestHelpers.res.hbs (no longer needs .gen.ts)
- Add simulate field to TestIndexer.chainConfig type
- Update ReScript contract_import template to use simulate

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Fix float type error in SimulateSource totalTimeElapsed

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Move TestHelpers module from generated template to Envio.res

- Add TestHelpers.Addresses module to Envio.res
- Delete TestHelpers.res.hbs codegen template
- Export TestHelpers from envio package (index.js, index.d.ts)
- Update generated index.js.hbs and index.d.ts.hbs to import from envio

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Remove standalone Addresses export, keep only TestHelpers.Addresses

- Generated index.js.hbs/index.d.ts.hbs now only re-export TestHelpers from envio
- Remove standalone Addresses export from envio index.js/index.d.ts
- Update static test templates to destructure Addresses from TestHelpers

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Stop re-exporting TestHelpers from generated, import from envio directly

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Move test codegen to Rust, inline TestHelpers, fix simulate types

- Move Indexer_test.res.hbs and indexer.test.ts.hbs codegen to Rust
  with snapshot tests for EVM and Fuel
- Delete TestHelpers_MockAddresses module, inline into Envio.res
- Remove TestHelpers re-export from index.js (exported via Envio.res.mjs)
- Throw user-friendly error on invalid block range in SimulateSource
  instead of silently filtering
- Prefix SimulateItems types with ecosystem (evmSimulateEventItem,
  fuelSimulateEventItem, etc.)
- Split SimulateEventItemBase into EVM/Fuel variants with correct block
  fields (number vs height) in index.d.ts
- Restore deleted comments in erc20 template

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Add typed ReScript test codegen with makeSimulateItem, paramsConstructor, entity ops, and GADT simulate types

- Add paramsConstructor type and makeSimulateItem function per event in Indexer.res
- Add testIndexerEntityOps type and entity access fields on testIndexer
- Generate GADT event identifier types (per-contract + top-level simulateContractEvent)
- Add simulateBlock helper function
- Update ReScript test file generation to use makeSimulateItem with typed params
- Add default_value_rescript field to Param struct for test codegen
- Update all assertion tests and snapshots

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Rename EthereumEventParam to EvmEventParam

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Use quoted field syntax for chain IDs and entity fields in codegen

Replace @as("X") camelX: pattern with quoted key "X": pattern for chain
numeric ID fields and entity fields in handlerContext/testIndexer types,
matching the existing contract field codegen style.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Rename types, fix simulate GADTs, and update scenario field access

- Rename entityHandlerContext -> handlerEntityOperations
- Rename testIndexerEntityOps -> testIndexerEntityOperations
- Fix simulate event GADT types to use lowercase names (ReScript requirement)
- Fix simulateBlock optional parameter type
- Use quoted keys for testIndexerProcessConfigChains fields
- Use quoted key in contract_import test template
- Update all scenario files for quoted field access syntax

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Move contract+event module codegen from handlebars to indexer_code

- Generate contract modules (with event sub-modules) in Rust codegen
  as part of project_template.indexer_code instead of handlebars template
- Inline MakeRegister functor code (handler + contractRegister bindings)
  directly into each event module
- Remove MakeRegister functor, module type Event, and contract/event
  loop from Indexer.res.hbs template
- Update snapshot tests for new indexer_code structure

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Remove inline abi and eventSignatures from EVM contract codegen

These values are already present in internal.config.json and parsed by
Config.fromPublic() at runtime. The inline copies in the generated
contract modules were redundant. Fuel contracts keep their abi since
event modules reference it for decoding.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Remove per-contract chainId type from contract modules

Only the global `type chainId = [#1 | #2]` is kept. Per-contract
narrowing (e.g., `[#1]` inside Contract1) was unused and didn't
provide meaningful type safety. Event types now resolve chainId
to the global type.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Refactor simulate API: GADT-based makeSimulateItem with eventIdentity

Replace per-event makeSimulateItem labeled-args functions with a unified
GADT-based approach with eventIdentity and simulateItemConstructor.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Add open Indexer to blank ReScript test template

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Remove __X__ wrapper modules from simulate types

Reference existing contract event types directly in the GADT
constructors (e.g. Contract1.NewGravatar.event) instead of
generating intermediate type alias modules.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Move eventIdentity GADT inside contract modules

Instead of top-level contract1_eventIdentity, the type is now
Contract1.eventIdentity with relative references to sibling
event modules (NewGravatar.event, etc.).

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Inline simulate types into indexer_code, remove dead processConfig and simulateBlock

Move eventIdentity/simulateItemConstructor/makeSimulateItem from
generated_top_level_bindings into indexer_code so they appear in
snapshot tests. Remove unused processConfig type and simulateBlock.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Add getOrThrow to test indexer, restore entity assertions, remove Indexer. prefix

- Add getOrThrow to TestIndexer.res entityOps for cleaner test code
- Add getOrThrow to codegen testIndexerEntityOperations type
- Remove redundant Indexer. prefix in generated tests (open Indexer covers it)
- Replace weak Assert.isTrue(result.changes) with entity-level assertions
  using getOrThrow and Assert.deepEqual (matching old HBS template pattern)
- Delete unused blank_template/rescript/src/Indexer_test.res

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Fix test codegen: use expect().toEqual() and entity_key for field names

- Replace Assert.deepEqual (non-existent) with expect().toEqual() from Vitest
- Use entity_key.uncapitalized for entity field names (handles id → event_id rename)

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Fix test codegen: chain ID from config, default values, entity naming, TS params

- Use first chain ID from config instead of hardcoded "1"
- Remove TODO comment, set endBlock to 0
- Fix address default: TestHelpers_MockAddresses → Envio.TestHelpers.Addresses
- Improve default strings: "foo" → "default string value"
- Fix RS entity accessor to use escaped quotes: indexer.\"Entity_Name"
- Fix RS entity type: Entities.Entity_Name.t
- Generate actual TS params with default values instead of commented-out hints
- Add Addresses import from "envio" when address params exist
- Use getOrThrow and static entity ID in TS tests

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Fix TS test codegen: import TestHelpers instead of Addresses from envio

The envio package exports TestHelpers at the top level, not Addresses.
Fixed import and default value to use TestHelpers.Addresses.defaultAddress.

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Refactor test indexer: per-ecosystem types, cleanup, getOrThrow

SimulateItems.res:
- Use ? optional fields instead of option<> for event item types
- Remove block handler simulate item support
- Remove number/height override fields (use block constructor instead)
- Remove registrations param from parse (no longer needed)

TestIndexer.res:
- Add per-ecosystem chain config types (evmChainConfig, fuelChainConfig)
- Extract shared getEntityFromState helper for get/getOrThrow
- Rename entityOps -> entityOperations

index.d.ts:
- Add getOrThrow to EntityOps type
- Change mockAddresses from array to tuple of 20 addresses
- Remove block simulate item types (EvmSimulateBlockItem, FuelSimulateBlockItem)
- Remove number/height from simulate event items
- Remove SVM simulate support
- Per-ecosystem chain config types (EvmTestIndexerChainConfig, FuelTestIndexerChainConfig)
- Remove TestIndexerChainIds union type

Template tests:
- Use getOrThrow instead of get where entity is expected to exist

TS codegen:
- Omit params field for parameterless events

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Remove Fuel simulate support, keep simulate for EVM only

- Remove fuelSimulateEventItem type from SimulateItems.res
- Remove fuelChainConfig from TestIndexer.res
- Remove FuelSimulateEventItem, FuelSimulateItem from index.d.ts
- FuelTestIndexerChainConfig now has no simulate field
- Fuel/SVM codegen uses plain TestIndexer.chainConfig

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Add getEntityOperations codegen, fix TestHelpers references, cleanup stale files

- Generate getEntityOperations helper using @get_index external + GADT entity name
- Fix evmChainConfig to use simulateItem (not evmSimulateEventItem)
- Move TestHelpers.Addresses → Envio.TestHelpers.Addresses in all scenario tests
- Update LoadLinkedEntities.res to use generated getEntityOperations
- Fix EventHandlers.ts to import TestHelpers from "envio"

https://claude.ai/code/session_012sjgbBChpXi5yVFE8byZN4

* Fix test codegen: add getAll, simulate schemas, restore test coverage

- Add getAll to TestIndexer entity operations for full backward compat
- Add EVM simulate block/transaction schemas with proper S.null handling
- Fix codegen indentation for params in contract import test templates
- Rename getEntityOperations → getTestIndexerEntityOperations with GADT
- Remove dead code from MockConfig.res and Integration_ts_helpers.res
- Fix context.simpleEntity → context."SimpleEntity" in E2E_test.res
- Fix simulate block nesting: number:2 → block:{number:2}
- Restore CustomSelection type assertion tests (ReScript + TypeScript)
- Restore EventHandler.test.ts coverage: contract register assertions,
  unawaited macrotask test, checksums test, compose handler tests
- Replace .get(id) with .getAll() where old tests used bulk verification

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix generated ReScript test: use t.expect instead of bare expect

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix simulate: entity casing, params parsing, block number management

- Fix ReScript contract import template to use quoted PascalCase for
  entity context access (e.g. context."FiatTokenProxy_AdminChanged")
- Use S.reverseConvertOrThrow for simulate params validation (fixes
  BigInt parsing failure for simulate events)
- Respect user-provided block numbers in simulate items instead of
  always using auto-incremented values
- Use block timestamp from parsed block instead of hardcoding 0
- Move evmSimulateEventItem type to Envio.res, remove duplicate
  simulateItem type, prefix parse functions with Evm
- Add SimulateTestEvent entity and tests for block/logIndex management

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix ReScript handler escaped quotes and add getAll to EntityOps type

- Use \\\" in Rust format string to produce \" in generated ReScript
  (context.\"Entity_Event\".set)
- Add getAll method to EntityOps TypeScript type for test indexer

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Rename EntityOps to TestIndexerEntityOperations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix ReScript handler: only escape opening quote for field access

context.\"FiatTokenProxy_AdminChanged".set(entity)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Remove orphaned Integration_ts_helpers.gen.ts

The source .res file was deleted but the generated .gen.ts was left behind,
causing TS2307 module not found error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Update fuel_test to use createTestIndexer + simulate API

Replace old MockDb/processEvent pattern with the new createTestIndexer
and simulate API, matching the updated fuel greeter template.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add Fuel simulate support with required params

- Add fuelSimulateEventItem type (params required vs EVM optional)
- Add fuelChainConfig with simulate field to TestIndexer
- Add Fuel block/transaction schemas (height/time/id fields)
- Update SimulateItems.parse to handle Fuel ecosystem
- Update codegen to use fuelChainConfig for Fuel chains
- Update TypeScript types: FuelTestIndexerChainConfig with simulate

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix SimulateSource duplicate event processing

The source manager may call getItemsOrThrow multiple times with
different partition IDs. Return all items on the first call and
empty on subsequent calls to prevent duplicate event processing.

Also apply startBlock from processConfig to chainConfig in patchConfig.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix template tests: chain IDs, block ranges, params parsing

- Greeter template test: use hardcoded chain ID 137 matching config
- Contract import codegen: use startBlock/endBlock 1 instead of 0
- Update entity_id format to match new block numbering (chainId_1_0)
- Use S.convertOrThrow for simulate params (handles both BigInt and
  Address conversion correctly)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Fix endBlock:0 hang, revert contract import to startBlock/endBlock 0

The engine treats knownHeight=0 as "no blocks available" (FetchState
getQueryPlan returns WaitingForNewBlock when headBlockNumber<=0).
SimulateSource now reports height as max(endBlock, 1) to work around
this. Also set endBlock on chainConfig in patchConfig so the engine
knows when to exit.

Greeter template test updated with correct chain ID 137 and matching
startBlock from config.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Remove unused @Gentype from entity and enum modules in Indexer.res (#1066)

These @Gentype attributes were only needed by the old testing framework
which has been removed. Also removes dead Enum.gen re-export from
index.d.ts.hbs (no Enum.res file exists).

https://claude.ai/code/session_015zCdS7e7RYRnS4jwnpamkh

Co-authored-by: Claude <noreply@anthropic.com>

* Upgrade GitHub Actions to latest versions (#1065)

* Update GitHub Actions to Node.js 24-compatible versions

actions/checkout v4→v6, actions/setup-node v4→v6,
actions/upload-artifact v4→v7, actions/download-artifact v4→v8,
pnpm/action-setup v4→v5.

https://claude.ai/code/session_01TV3JWeXCsyNysFz9phMeKG

* Set FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 in all workflows

Forces remaining third-party actions (rust-toolchain, rust-cache, etc.)
to also run on Node.js 24.

https://claude.ai/code/session_01TV3JWeXCsyNysFz9phMeKG

* Replace Swatinem/rust-cache and cache-apt-pkgs with actions/cache@v5

Swatinem/rust-cache@v2 internally uses actions/cache/restore@v4 (node20),
and awalsh128/cache-apt-pkgs-action@v1 uses actions/cache/save@v4.
Replace both with actions/cache@v5 (node24) and direct apt-get install.

https://claude.ai/code/session_01TV3JWeXCsyNysFz9phMeKG

* Extract cargo-cache composite action to deduplicate cache config

https://claude.ai/code/session_01TV3JWeXCsyNysFz9phMeKG

---------

Co-authored-by: Claude <noreply@anthropic.com>

* Prefer .envio-artifacts/envio over packages/envio in get_envio_version()

In CI, template tests install the envio package via the file: path returned
by get_envio_version(). packages/envio is source-only (compiled .res.mjs
files are gitignored), so pnpm copies source to its store without them,
causing "BigInt.res.mjs not found" at runtime.

When .envio-artifacts/envio exists (pre-built in CI), prefer it — it
includes the compiled files needed to run the indexer.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix: only prefer .envio-artifacts/envio when binary is inside .envio-artifacts/

The previous fix unconditionally preferred .envio-artifacts/envio over
packages/envio when walking up from the binary. This broke scenarios-test:
the dev binary (target/debug/envio) picked .envio-artifacts/envio while
test_codegen/package.json hardcodes packages/envio, creating two different
envio module instances that both register the same Prometheus metrics.

Now we only prefer the artifact when the binary itself lives inside
.envio-artifacts/ (i.e. the pre-built CI artifact used by template-tests).
Dev binaries in target/ continue to use packages/envio, avoiding duplication.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Improve test assertions: assert whole addresses object, use t.expect, restore comment

- Assert `result.changes[0]?.addresses` (whole object) instead of drilling
  into `?.addresses?.sets` — catches unexpected extra fields per CLAUDE.md
  "single assert on whole value" principle
- Use vitest t.expect for the unawaited macrotask test (binds to test context)
- Restore the commented-out log assertion with explanation that there's
  currently no good way to test it — preserves useful context for future

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants