Skip to content

Comments

feat(ensindexer): leverage SWR caches to achieve goals related to LocalPonderClient#1652

Open
tk-o wants to merge 15 commits intofeat/indexing-status-builder-3from
feat/indexing-status-builder-3-with-cache
Open

feat(ensindexer): leverage SWR caches to achieve goals related to LocalPonderClient#1652
tk-o wants to merge 15 commits intofeat/indexing-status-builder-3from
feat/indexing-status-builder-3-with-cache

Conversation

@tk-o
Copy link
Contributor

@tk-o tk-o commented Feb 19, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • Creates SWR cache for fetching data from PonderClient
  • Updates LocalPonderClient to read data from aforementioned SWR cache to simplify how possible data loading failures are handled. Also, LocalPonderClient maintains in-memory cache for ChainsIndexingMetadataImmutable object which includes relevant block refs for each indexed chain.
  • Simplifies the getLocalPonderClient() function that returns a LocalPonderClient singleton instance. Now, there's no need to await anything.

Why

  • Fetching data may fail, and we need to manage the complexity that stems from these possible failures in a simple way. SWRCache is a great abstraction for that goal, and LocalPonderClient should leverage it.

Testing

  • I ran static code analysis (lint, typecheck) and testing suite
  • I ran ENSIndexer service locally and tested it /api/indexing-status endpoint, including test logs

Notes for Reviewer (Optional)

  • Reviewing commit-by-commit is highly encouraged.
  • This is a follow-up PR to PR Integration of Indexing Status Builder into ENSIndexer API #1614 and simplifies LocalPonderClient idea in a meaningful way. LocalPonderClient "knows" about Ponder APIs and configs, and allows caching data that can be later used to handle Indexing Status API requests.

Pre-Review Checklist (Blocking)

  • This PR does not introduce significant changes and is low-risk to review quickly.
  • Relevant changesets are included (or are not required)

Copilot AI review requested due to automatic review settings February 19, 2026 16:23
@vercel
Copy link
Contributor

vercel bot commented Feb 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
admin.ensnode.io Skipped Skipped Feb 20, 2026 8:30pm
ensnode.io Skipped Skipped Feb 20, 2026 8:30pm
ensrainbow.io Skipped Skipped Feb 20, 2026 8:30pm

@changeset-bot
Copy link

changeset-bot bot commented Feb 19, 2026

🦋 Changeset detected

Latest commit: f3ab127

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 19 packages
Name Type
ensindexer Major
ensadmin Major
ensrainbow Major
ensapi Major
fallback-ensapi Major
@ensnode/datasources Major
@ensnode/ensrainbow-sdk Major
@ensnode/ponder-metadata Major
@ensnode/ensnode-schema Major
@ensnode/ensnode-react Major
@ensnode/ensnode-sdk Major
@ensnode/ponder-sdk Major
@ensnode/ponder-subgraph Major
@ensnode/shared-configs Major
@docs/ensnode Major
@docs/ensrainbow Major
@docs/mintlify Major
@namehash/ens-referrals Major
@namehash/namehash-ui Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors ENSIndexer’s LocalPonderClient initialization to rely on SWR caches (with proactive revalidation) and extends the shared SWRCache utility to support a context object for cache loaders.

Changes:

  • Extend SWRCache to accept an optional context parameter in fn() and add a setContext() API.
  • Refactor LocalPonderClient to use new SWR-backed caches for Ponder indexing metrics/status (dynamic) and derived immutable chain metadata.
  • Update the Ponder API handler to use a singleton LocalPonderClient instance (no per-request initialization).

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
packages/ensnode-sdk/src/shared/cache/swr-cache.ts Adds context support and proactive revalidation stop API to the shared SWR cache implementation.
packages/ensnode-sdk/src/shared/cache/swr-cache.test.ts Updates tests for the new (cachedResult, context) callback signature and adds context coverage.
apps/ensindexer/src/lib/ponder-api-client.ts Switches singleton getter to synchronous construction and injects SWR caches into LocalPonderClient.
apps/ensindexer/ponder/src/api/lib/local-ponder-client.ts Reworks LocalPonderClient to extend PonderClient and source metadata via SWR caches.
apps/ensindexer/ponder/src/api/lib/chains-indexing-metadata-immutable.ts Introduces builder for immutable chain indexing metadata.
apps/ensindexer/ponder/src/api/lib/chains-indexing-metadata-dynamic.ts Introduces builder for dynamic chain indexing metadata from metrics/status.
apps/ensindexer/ponder/src/api/lib/cache/ponder-client.cache.ts Adds SWR cache for Ponder metrics/status with proactive revalidation.
apps/ensindexer/ponder/src/api/lib/cache/chains-indexing-metadata-immutable.cache.ts Adds SWR cache for immutable chain metadata and stops revalidation after success.
apps/ensindexer/ponder/src/api/handlers/ensnode-api.ts Uses a module-level singleton LocalPonderClient for request handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor Author

@tk-o tk-o left a comment

Choose a reason for hiding this comment

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

Self-review completed.

@coderabbitai
Copy link

coderabbitai bot commented Feb 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/indexing-status-builder-3-with-cache

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tk-o tk-o force-pushed the feat/indexing-status-builder-3 branch from 34db972 to b8b2f19 Compare February 20, 2026 10:39
Copilot AI review requested due to automatic review settings February 20, 2026 12:08
@tk-o tk-o force-pushed the feat/indexing-status-builder-3-with-cache branch from 0999394 to d314b5d Compare February 20, 2026 12:08
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io February 20, 2026 12:08 Inactive
@vercel vercel bot temporarily deployed to Preview – ensnode.io February 20, 2026 12:08 Inactive
@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io February 20, 2026 12:12 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io February 20, 2026 12:12 Inactive
@vercel vercel bot temporarily deployed to Preview – ensnode.io February 20, 2026 12:12 Inactive
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

tk-o added 2 commits February 20, 2026 13:22
Move logic from `LocalPonderClient` into a separate file.
Move logic from `LocalPonderClient` into a separate file.
@tk-o tk-o force-pushed the feat/indexing-status-builder-3-with-cache branch from 9f9ca10 to dc578eb Compare February 20, 2026 12:42
@vercel vercel bot temporarily deployed to Preview – ensnode.io February 20, 2026 12:42 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io February 20, 2026 12:42 Inactive
Copilot AI review requested due to automatic review settings February 20, 2026 12:54
@tk-o tk-o marked this pull request as ready for review February 20, 2026 12:54
tk-o added 8 commits February 20, 2026 17:37
Replace `buildChainsIndexingMetadataImmutable` calls with `ChainsIndexingMetadataImmutableCache` reads while fetching `ChainsIndexingMetadataImmutable` data.
`LocalPonderClient` extends `PonderClient` now. This change allows setting up proper cache context for `this.#chainsIndexingMetadataImmutableCache`. Also, `LocalPonderClient` does not require any async initialization. The reremote data required by `LocalPonderClient` is now managed by two SWR cache instances: 1) `PonderClientCache`, and 2) `ChainsIndexingMetadataImmutableCache`. Ponder configuration and APIs are made avaialble via `LocalPonderClient` fields: `chainsConfigBlockrange`, `indexedChainIds`, `publicClients`; and methods: `getPublicClient`, `chainsIndexingMetadata`, plus all methods provided by `PonderClient` implementation.
Now, that async data fetching has been delegated to SWR caches, creating a singleton instnace for `LocalPonderClient` is way simpler, _and synchronous_!
Declares a top-level `localPonderClient` var that references the singleton `LocalPonderClient` instance. It is important to initialize singleton this way, as it also initializes SWR caches to perform data fetching in the background.
…into feat/indexing-status-builder-3-with-cache
1) `SWRCache` implementation has been reset to the current `main` branch version.
2) Caching `ChainsIndexingMetadataImmutable` value, which includes relevant block refs, has been moved from SWRCache implementation into the `chainsIndexingMetadataImmutable` field on `LocalPonderClient` class. The SWRCache for `ChainsIndexingMetadataImmutable` has been removed.
3) The `chainsIndexingMetadata()` method was replaced by more straightforward `getOmnichainIndexingStatusSnapshot` method, which can be called with no arguments from a caller's side.
4) SWRCache for `PonderClient`, called `PonderClientCache`, creates `PonderClient` instance directly now, so no cache context object is needed.
5) `PonderClientCache` is now initiated lazily. Its revalidation interval is set to 10 seconds. This gives time for Ponder app to load data needed for Ponder Client.
6) `LocalPonderClient` imports `PonderClientCache` directly, so there is no need to inject it with constructor params.
7) The Indexing Status API endpoint can now just call `omnichainSnapshot = await localPonderClient.getOmnichainIndexingStatusSnapshot();` to get the complete, fresh value for current omnichain indexing status snapshot.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vercel vercel bot temporarily deployed to Preview – ensnode.io February 20, 2026 19:29 Inactive
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io February 20, 2026 19:29 Inactive
@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io February 20, 2026 19:29 Inactive
@tk-o
Copy link
Contributor Author

tk-o commented Feb 20, 2026

@greptile review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copilot AI review requested due to automatic review settings February 20, 2026 20:30
@vercel vercel bot temporarily deployed to Preview – ensrainbow.io February 20, 2026 20:30 Inactive
@vercel vercel bot temporarily deployed to Preview – admin.ensnode.io February 20, 2026 20:30 Inactive
@vercel vercel bot temporarily deployed to Preview – ensnode.io February 20, 2026 20:30 Inactive
@tk-o
Copy link
Contributor Author

tk-o commented Feb 20, 2026

@greptile review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +97 to +99
throw new Error(
`Ponder Indexing Metrics must be available in cache to build chains indexing metadata immutable: ${ponderClientCacheResult.message}`,
);
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

The error message mentions only "Ponder Indexing Metrics" but the cache result actually contains both indexing metrics and indexing status. Consider updating the message to be more accurate, for example: "Ponder Client data (metrics and status) must be available in cache..."

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

8 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

1 participant