Conversation
🦋 Changeset detectedLatest commit: b78f2ce The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 3 Skipped Deployments
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughCentralized the ENSRainbow API client into a process-wide singleton, removed the factory, added a memoized readiness check with retries, and made onchain event handlers await ENSRainbow readiness (setup events bypass wait). Tests updated to mock and assert the new async precondition behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant Ponder as Ponder Event System
participant Precond as Event Preconditions
participant ENS as ENSRainbow Client
participant Retry as p-retry
participant Handler as Registered Event Handler
Ponder->>Precond: eventHandlerPreconditions(eventName)
alt Setup Event (ends with :setup)
Precond->>Handler: invoke handler immediately
Handler-->>Precond: result
else Onchain Event
Precond->>ENS: waitForEnsRainbowToBeReady()
ENS->>Retry: perform health() with retries (up to 12)
loop retry attempts
Retry->>ENS: client.health()
ENS-->>Retry: success / error
Retry-->>Retry: log & decide retry
end
alt Ready
Precond->>Handler: invoke handler
Handler-->>Precond: result
else Exhausted
Retry-->>Precond: reject with Error (cause)
Precond-->>Ponder: promise rejects (handler not invoked)
end
end
Precond-->>Ponder: precondition resolved/rejected
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
|
@greptile review |
There was a problem hiding this comment.
Pull request overview
Adds an ENSRainbow client singleton and introduces an indexing “precondition” layer so onchain Ponder handlers wait for ENSRainbow readiness before executing, improving resiliency when ENSRainbow is temporarily unavailable.
Changes:
- Introduced
ensRainbowClientsingleton +waitForEnsRainbowToBeReady()with shared retry/backoff. - Added event-handler preconditions in the Ponder indexing wrapper to block onchain handlers until ENSRainbow is ready (setup handlers bypass this).
- Updated ENSRainbow client call sites and expanded unit tests to cover precondition behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/ensindexer/src/lib/public-config-builder/singleton.ts | Switches to the shared ENSRainbow singleton for public config construction. |
| apps/ensindexer/src/lib/indexing-engines/ponder.ts | Adds event-type detection + precondition gating before handler execution. |
| apps/ensindexer/src/lib/indexing-engines/ponder.test.ts | Updates tests for async callback behavior and adds precondition coverage. |
| apps/ensindexer/src/lib/graphnode-helpers.ts | Migrates heal calls to the ENSRainbow singleton client. |
| apps/ensindexer/src/lib/ensrainbow/singleton.ts | New singleton module with readiness-wait helper and retry logging. |
| apps/ensindexer/src/lib/ensraibow-api-client.ts | Removes the old ENSRainbow client factory. |
| .changeset/sharp-moons-shave.md | Declares a minor version bump for the resiliency change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile SummaryThis PR introduces a precondition gate that blocks onchain event handlers from executing until the ENSRainbow service is confirmed healthy, advancing the fix for issue #1417. It consolidates ENSRainbow client construction into a new Key aspects of the implementation:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Ponder
participant addOnchainEventListener
participant eventHandlerPreconditions
participant initializeIndexingActivation
participant waitForEnsRainbowToBeReady
participant ENSRainbow
Note over Ponder: Startup — setup events fire first
Ponder->>addOnchainEventListener: Registry:setup event
addOnchainEventListener->>eventHandlerPreconditions: Setup type
eventHandlerPreconditions->>eventHandlerPreconditions: indexingSetupPromise === null → set & await (resolves immediately)
eventHandlerPreconditions-->>addOnchainEventListener: resolved
addOnchainEventListener->>addOnchainEventListener: run setup handler
Note over Ponder: First onchain event — ENSRainbow may not be ready
Ponder->>addOnchainEventListener: Resolver:AddrChanged (event A)
addOnchainEventListener->>eventHandlerPreconditions: Onchain type
eventHandlerPreconditions->>initializeIndexingActivation: indexingActivationPromise === null → initiate
initializeIndexingActivation->>waitForEnsRainbowToBeReady: first call → start pRetry loop
waitForEnsRainbowToBeReady->>ENSRainbow: health() attempt 1 — fails
waitForEnsRainbowToBeReady->>ENSRainbow: health() attempt 2 — fails
Note over waitForEnsRainbowToBeReady,ENSRainbow: … retries every 60s up to 60 times …
Note over Ponder: Concurrent onchain event arrives while waiting
Ponder->>addOnchainEventListener: Registry:Transfer (event B)
addOnchainEventListener->>eventHandlerPreconditions: Onchain type
eventHandlerPreconditions->>eventHandlerPreconditions: indexingActivationPromise !== null → await same promise (blocks)
ENSRainbow-->>waitForEnsRainbowToBeReady: health() succeeds
waitForEnsRainbowToBeReady-->>initializeIndexingActivation: resolved
initializeIndexingActivation-->>eventHandlerPreconditions: resolved (both A & B unblock)
eventHandlerPreconditions-->>addOnchainEventListener: resolved (event A)
eventHandlerPreconditions-->>addOnchainEventListener: resolved (event B)
addOnchainEventListener->>addOnchainEventListener: run handler A
addOnchainEventListener->>addOnchainEventListener: run handler B
Note over Ponder: All subsequent onchain events — indexingActivationPromise already resolved
Ponder->>addOnchainEventListener: any onchain event
addOnchainEventListener->>eventHandlerPreconditions: Onchain type
eventHandlerPreconditions->>eventHandlerPreconditions: await cached resolved promise (fast path)
eventHandlerPreconditions-->>addOnchainEventListener: resolved immediately
addOnchainEventListener->>addOnchainEventListener: run handler
Reviews (5): Last reviewed commit: "Apply AI PR feedback" | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/ensindexer/src/lib/ensrainbow/singleton.ts`:
- Around line 50-58: The health check currently treats any fulfilled
ensRainbowClient.health() response as success; change the pRetry callback used
for waitForEnsRainbowToBeReadyPromise to parse and validate the response body
and throw unless it exactly matches { status: "ok" } (so pRetry will retry on
unexpected payloads); add import { z } from "zod" near the top or perform an
explicit equality check, validate the response inside the async function that
calls ensRainbowClient.health(), and only resolve/allow the .then() readiness
log when the validation passes (use the identifiers
waitForEnsRainbowToBeReadyPromise, pRetry, ensRainbowClient.health(), and
ensRainbowUrl to locate the code).
In `@apps/ensindexer/src/lib/indexing-engines/ponder.test.ts`:
- Around line 254-256: The test currently asserts await expect(callback({
context: mockContext, event: mockEvent })).resolves.not.toThrow(); but the
callback resolves to void; change the assertion to await expect(callback({
context: mockContext, event: mockEvent })).resolves.toBeUndefined() so the test
explicitly verifies the promise resolves to undefined; update the line using
mockPonderOn.mock.calls[0] and the extracted callback to use
resolves.toBeUndefined() when invoking callback with mockContext and mockEvent
(ENSRainbow-related behavior remains unchanged).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 17de5765-4835-4c7e-b972-b4df11823062
📒 Files selected for processing (7)
.changeset/sharp-moons-shave.mdapps/ensindexer/src/lib/ensraibow-api-client.tsapps/ensindexer/src/lib/ensrainbow/singleton.tsapps/ensindexer/src/lib/graphnode-helpers.tsapps/ensindexer/src/lib/indexing-engines/ponder.test.tsapps/ensindexer/src/lib/indexing-engines/ponder.tsapps/ensindexer/src/lib/public-config-builder/singleton.ts
💤 Files with no reviewable changes (1)
- apps/ensindexer/src/lib/ensraibow-api-client.ts
This function will enbale ENSIndexer modules to wait for when the ENSRainbow instance is ready to serve traffic.
Allows to wait with indexing onchain events until ENSRainbow instance is ready.
…ndler-preconditions
9ff175e to
911035a
Compare
|
@greptile review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
lightwalker-eth
left a comment
There was a problem hiding this comment.
@tk-o Thanks for updates. Shared a few more suggestions 👍
…ndler-preconditions
|
@greptile revew |
|
@greptile review |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
ensRainbowClientsingleton for modules in the ENSIndexer app to use.apps/ensindexer/src/lib/ensrainbow/singleton.tswaitForEnsRainbowToBeReadyfunction to enable waiting with certain code execution untli the ENSRainbow instance is ready to serve traffic.apps/ensindexer/src/lib/ensrainbow/singleton.tseventHandlerPrecondtionsfunction to prevent indexing onchain events beforewaitForEnsRainbowToBeReadyresolves. Please note how processing "setup" events is unaffected.apps/ensindexer/src/lib/indexing-engines/ponder.tsWhy
Testing
ensRainbowPublicConfigobject available.Test logs from ENSIndexer
Notes for Reviewer (Optional)
Pre-Review Checklist (Blocking)