Skip to content

feat(ensrainbow): enhance entrypoint command with eager public config and mismatch handling#2037

Merged
djstrong merged 8 commits intomainfrom
2020-allow-ensrainbow-clients-to-fetch-ensrainbowpublicconfig-as-soon-as-possible
May 4, 2026
Merged

feat(ensrainbow): enhance entrypoint command with eager public config and mismatch handling#2037
djstrong merged 8 commits intomainfrom
2020-allow-ensrainbow-clients-to-fetch-ensrainbowpublicconfig-as-soon-as-possible

Conversation

@djstrong
Copy link
Copy Markdown
Member

@djstrong djstrong commented Apr 30, 2026

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • ENSRainbow now serves GET /v1/config immediately on startup (entrypoint mode), using CLI/env label-set values.
  • After DB bootstrap completes, ENSRainbow validates the DB-stored label set matches the configured one and terminates with a helpful error on mismatch.
  • GET /ready and GET /v1/heal/:labelhash are now aligned to only succeed once bootstrap has completed and DB-backed config is published; docs + tests updated.

Why

  • Prevent ENSRainbow cold starts from cascading across dependent services by allowing clients to fetch EnsRainbowPublicConfig as soon as possible.
  • Related: Issue #2020

Testing


Notes for Reviewer (Optional)

  • entrypointCommand builds /v1/config from LABEL_SET_ID/LABEL_SET_VERSION immediately, then validates those values against DB metadata after bootstrap; on mismatch it exits (testable via an injected exit hook).

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)

… and mismatch handling

- Implemented eager building of public configuration from CLI/env arguments to serve immediately at startup.
- Added tests for handling label-set mismatches between environment and database.
- Updated API routes to reflect immediate availability of public config and adjusted readiness checks accordingly.
- Refactored public config building logic for clarity and reusability.
Copilot AI review requested due to automatic review settings April 30, 2026 17:51
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: 3aadc33

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

This PR includes changesets to release 24 packages
Name Type
ensrainbow Major
ensindexer Major
ensadmin Major
ensapi Major
fallback-ensapi Major
enssdk Major
enscli Major
enskit Major
ensskills Major
@ensnode/datasources Major
@ensnode/ensrainbow-sdk Major
@ensnode/ensdb-sdk Major
@ensnode/ensnode-react Major
@ensnode/ensnode-sdk Major
@ensnode/integration-test-env Major
@ensnode/ponder-sdk Major
@ensnode/ponder-subgraph Major
@ensnode/shared-configs Major
@docs/ensnode Major
@docs/ensrainbow Major
@namehash/ens-referrals Major
@namehash/namehash-ui Major
@ensnode/ensindexer-perf-testing Major
@ensnode/enskit-react-example Patch

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

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 30, 2026

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

Project Deployment Actions Updated (UTC)
ensnode-enskit-react-example Ready Ready Preview, Comment May 4, 2026 7:44am
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
admin.ensnode.io Skipped Skipped May 4, 2026 7:44am
ensnode.io Skipped Skipped May 4, 2026 7:44am
ensrainbow.io Skipped Skipped May 4, 2026 7:44am

Copy link
Copy Markdown
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

Enhances ENSRainbow startup behavior so /v1/config is available immediately (built from CLI/env label-set args) while the DB bootstraps in the background, and adds enforcement/tests for env/DB label-set mismatches.

Changes:

  • Make /v1/config serve an eagerly-built in-memory public config immediately at startup (no 503 during bootstrap).
  • Add post-bootstrap validation that the opened DB’s stored label set matches configured LABEL_SET_ID / LABEL_SET_VERSION, terminating on mismatch, with new tests.
  • Refactor public config construction into a reusable “from label set” helper and adjust API readiness logic/docs accordingly.

Reviewed changes

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

Show a summary per file
File Description
docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx Document /v1/config as immediately available and adjust bootstrap/503 route list.
apps/ensrainbow/src/lib/api.ts Change createApi to take a concrete public config, and adjust /ready + /v1/config behavior.
apps/ensrainbow/src/config/public.ts Add buildEnsRainbowPublicConfigFromLabelSet helper for eager + post-bootstrap paths.
apps/ensrainbow/src/commands/server-command.ts Update createApi usage to pass public config directly.
apps/ensrainbow/src/commands/server-command.test.ts Update tests to reflect eager /v1/config behavior while DB is unattached.
apps/ensrainbow/src/commands/entrypoint-command.ts Build public config eagerly; add env-vs-DB label-set mismatch validation and injectable exit hook.
apps/ensrainbow/src/commands/entrypoint-command.test.ts Add tests for early /v1/config availability and mismatch termination behavior.

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

Comment thread apps/ensrainbow/src/lib/api.ts Outdated
Comment thread docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Warning

Rate limit exceeded

@djstrong has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 46 minutes and 49 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 760ddc79-3a26-4cb7-964c-3db9b3163d4e

📥 Commits

Reviewing files that changed from the base of the PR and between 012615c and 3aadc33.

📒 Files selected for processing (5)
  • apps/ensindexer/src/lib/public-config-builder/public-config-builder.test.ts
  • apps/ensindexer/src/lib/public-config-builder/public-config-builder.ts
  • apps/ensindexer/src/lib/public-config-builder/singleton.ts
  • apps/ensrainbow/src/commands/entrypoint-command.test.ts
  • apps/ensrainbow/src/commands/entrypoint-command.ts
📝 Walkthrough

Walkthrough

ENSRainbow now builds public config eagerly from CLI/env label-set inputs at startup and injects it into the API immediately. During DB bootstrap the entrypoint validates the DB's stored serverLabelSet against the configured set; on mismatch it requests a controlled exit via a configurable exit hook and prevents readiness.

Changes

Entrypoint & tests

Layer / File(s) Summary
Data Shape / Inputs
apps/ensrainbow/src/commands/entrypoint-command.ts
Construct argsServerLabelSet from options.labelSetId/labelSetVersion and build an in-memory public config before DB bootstrap.
Core Implementation
apps/ensrainbow/src/commands/entrypoint-command.ts
runDbBootstrap now returns only DbConfig; bootstrap completion validates dbConfig.serverLabelSet vs configured label set and requests exit(1) on mismatch.
Control / Exit Hook
apps/ensrainbow/src/commands/entrypoint-command.ts
Add EntrypointCommandOptions.exit?: (code:number)=>never, implement requestExit with exitRequested guard and swallow errors from the hook.
Tests
apps/ensrainbow/src/commands/entrypoint-command.test.ts
Existing DB test now checks /v1/config serves configured label set before bootstrap; new tests seed mismatched DB state and assert exit hook invocation and non-ready /ready after bootstrap failure.

Server & API wiring

Layer / File(s) Summary
API Signature
apps/ensrainbow/src/lib/api.ts
createApi signature changed to accept eager non-null publicConfig instead of nullable supplier; removed PublicConfigSupplier type.
Gating/Readiness Logic
apps/ensrainbow/src/lib/api.ts
Readiness and DB-backed route gating now depend on DB availability (dbConfigSupplier() === null) and server.isReady(); /v1/config no longer returns 503 based on public-config supplier nullability.
Server Wiring
apps/ensrainbow/src/commands/server-command.ts
Pass eager publicConfig into createApi (was previously a thunk).
Tests
apps/ensrainbow/src/commands/server-command.test.ts
Pending-server tests now compute eager publicConfig from declared label set and assert /v1/config returns that value while DB is unattached; /v1/labels/count remains 503 until DB attach.

Public config builder

Layer / File(s) Summary
New Builder
apps/ensrainbow/src/config/public.ts
Add buildEnsRainbowPublicConfigFromLabelSet(serverLabelSet) to construct ENSRainbowPublicConfig from an explicit server label set.
Delegation
apps/ensrainbow/src/config/public.ts
buildEnsRainbowPublicConfig(dbConfig) now delegates to the new builder using dbConfig.serverLabelSet.

Docs & changeset

Layer / File(s) Summary
API Docs
docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx
Document /v1/config availability at startup, in-memory label-set construction, bootstrap validation/exit behavior, and updated /v1/config response shape (serverLabelSet, versionInfo.ensRainbow).
Release Notes
.changeset/ensrainbow-eager-public-config.md
Add changeset describing eager public-config behavior, bootstrap validation, readiness semantics, and exit-on-mismatch behavior.

Sequence Diagram

sequenceDiagram
    participant CLI as CLI/Env
    participant Entrypoint as Entrypoint
    participant API as API Server
    participant DB as Database

    rect rgba(76, 175, 80, 0.5)
    CLI->>Entrypoint: provide LABEL_SET_ID / LABEL_SET_VERSION
    Entrypoint->>Entrypoint: buildEnsRainbowPublicConfigFromLabelSet()
    Entrypoint->>API: inject publicConfig (concrete)
    API->>API: GET /v1/config returns configured publicConfig
    end

    rect rgba(33, 150, 243, 0.5)
    Entrypoint->>DB: runDbBootstrap()
    DB-->>Entrypoint: DbConfig (serverLabelSet)
    Entrypoint->>Entrypoint: compare db.serverLabelSet vs configured
    end

    rect rgba(244, 67, 54, 0.5)
    alt mismatch detected
        Entrypoint->>API: keep /ready non-200 (503)
        Entrypoint->>Entrypoint: resolve bootstrapComplete
        Entrypoint->>Entrypoint: call options.exit(1)
    else match
        Entrypoint->>API: mark ready → /ready returns 200
    end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I build the labels in memory before the earth is turned,
A config snug and ready, from the flags I've learned.
If disk disputes the story and the records don't align,
I thump and call for exit — one hop, one final sign. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately and concisely describes the main changes: adding eager public config availability at startup and handling label set mismatches during bootstrap.
Description check ✅ Passed The pull request description follows the Lite PR template and covers all required sections: Summary clearly outlines the three main changes, Why section references the related issue, Testing section is present (though marked empty), Notes for Reviewer provides helpful context, and the Pre-Review Checklist is completed with both items checked off.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2020-allow-ensrainbow-clients-to-fetch-ensrainbowpublicconfig-as-soon-as-possible

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
Review rate limit: 0/1 reviews remaining, refill in 46 minutes and 49 seconds.

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx (1)

193-217: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update /v1/config example payload to the current schema.

The “Get Public Config” sample still documents the old shape. Current API returns serverLabelSet + versionInfo, so this section is now misleading for integrators.

📘 Proposed docs fix
 Success Response:

 ```json
 {
-  "version": "0.1.0",
-  "labelSet": {
+  "serverLabelSet": {
     "labelSetId": "subgraph",
     "highestLabelSetVersion": 0
   },
-  "recordsCount": 133856894
+  "versionInfo": {
+    "ensRainbow": "0.1.0"
+  }
 }

The response contains:
-- version: The current version of ENSRainbow
-- labelSet: The label set of the loaded database

    • labelSetId: The label set ID of the loaded database
    • highestLabelSetVersion: The highest label set version available in the database
      -- recordsCount: The total count of labels that can be healed by the ENSRainbow instance
      +- serverLabelSet: The configured server label-set identity
    • labelSetId: The configured label-set ID
    • highestLabelSetVersion: The configured highest label-set version
      +- versionInfo.ensRainbow: The running ENSRainbow version
</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx around lines 193 -
217, Update the "/v1/config" "Get Public Config" example and description to
match the current API schema: replace the top-level "version" and
"labelSet"/"recordsCount" shape with "serverLabelSet" (containing "labelSetId"
and "highestLabelSetVersion") and "versionInfo" (containing "ensRainbow"), i.e.,
change the JSON example to include "serverLabelSet" and "versionInfo.ensRainbow"
and remove "recordsCount", and update the bullet list below to document
"serverLabelSet.labelSetId", "serverLabelSet.highestLabelSetVersion" and
"versionInfo.ensRainbow" instead of the old "version", "labelSet", and
"recordsCount".


</details>

</blockquote></details>

</blockquote></details>
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx`:
- Around line 193-217: Update the "/v1/config" "Get Public Config" example and
description to match the current API schema: replace the top-level "version" and
"labelSet"/"recordsCount" shape with "serverLabelSet" (containing "labelSetId"
and "highestLabelSetVersion") and "versionInfo" (containing "ensRainbow"), i.e.,
change the JSON example to include "serverLabelSet" and "versionInfo.ensRainbow"
and remove "recordsCount", and update the bullet list below to document
"serverLabelSet.labelSetId", "serverLabelSet.highestLabelSetVersion" and
"versionInfo.ensRainbow" instead of the old "version", "labelSet", and
"recordsCount".

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 00baf6e1-4e3f-4055-b72e-55ae211bc6ed

📥 Commits

Reviewing files that changed from the base of the PR and between 7e77c5c and 6b07e67.

📒 Files selected for processing (7)
  • apps/ensrainbow/src/commands/entrypoint-command.test.ts
  • apps/ensrainbow/src/commands/entrypoint-command.ts
  • apps/ensrainbow/src/commands/server-command.test.ts
  • apps/ensrainbow/src/commands/server-command.ts
  • apps/ensrainbow/src/config/public.ts
  • apps/ensrainbow/src/lib/api.ts
  • docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx

Copilot AI review requested due to automatic review settings April 30, 2026 18:18
@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io April 30, 2026 18:18 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io April 30, 2026 18:18 Inactive
Copy link
Copy Markdown
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 updates ENSRainbow’s startup behavior so /v1/config is available immediately (built from CLI/env label set args) while the DB bootstraps in the background, and adds mismatch handling to terminate if the on-disk DB label set doesn’t match the configured label set.

Changes:

  • Refactor API route wiring so /v1/config is always served from an eagerly-built in-memory public config, while /ready and DB-backed routes remain gated on DB bootstrap completion.
  • Add entrypoint/server tests to cover “config available during bootstrap” and “env/DB label-set mismatch triggers termination”.
  • Update public-config construction helpers and documentation to reflect the new response shape/availability.

Reviewed changes

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

Show a summary per file
File Description
docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx Updates API docs to reflect /v1/config being available immediately and adjusts the documented response fields.
apps/ensrainbow/src/lib/api.ts Changes createApi to accept a concrete publicConfig and gates readiness/DB routes on dbConfigSupplier().
apps/ensrainbow/src/config/public.ts Refactors public config building to allow construction directly from a label set (pre-DB).
apps/ensrainbow/src/commands/server-command.ts Updates createApi call site to new signature.
apps/ensrainbow/src/commands/server-command.test.ts Updates tests to assert /v1/config returns 200 pre-attach while other DB-backed endpoints remain 503.
apps/ensrainbow/src/commands/entrypoint-command.ts Builds public config eagerly from args; adds env-vs-DB label-set mismatch detection and an injectable exit hook.
apps/ensrainbow/src/commands/entrypoint-command.test.ts Adds tests for early /v1/config and mismatch-triggered exit/readiness behavior.
.changeset/ensrainbow-eager-public-config.md Changeset describing the behavioral change and mismatch handling.

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

Comment thread apps/ensrainbow/src/commands/entrypoint-command.ts
Comment thread apps/ensrainbow/src/commands/entrypoint-command.ts
- Changed the exit function type from `never` to `void` for better clarity.
- Introduced a `requestExit` function to manage exit requests and handle potential errors gracefully.
- Updated comments to reflect the new exit handling mechanism.
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io April 30, 2026 19:41 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensnode.io April 30, 2026 19:41 Inactive
@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io April 30, 2026 19:41 Inactive
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx`:
- Around line 214-217: Update the /v1/config docs to reflect eager startup
semantics: change the description of serverLabelSet (and its fields
serverLabelSet.labelSetId and serverLabelSet.highestLabelSetVersion) from “the
label set managed by the ENSRainbow instance / DB-loaded values” to “configured
startup label-set values (validated against DB during bootstrap)”; keep
versionInfo.ensRainbow as the service version and ensure the text makes clear
these values are CLI/env-derived at startup and then validated against the DB
during bootstrap.
🪄 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: f33bec33-f769-42ae-b361-fbdae026a49f

📥 Commits

Reviewing files that changed from the base of the PR and between 6b07e67 and cb2fdde.

📒 Files selected for processing (7)
  • .changeset/ensrainbow-eager-public-config.md
  • apps/ensrainbow/src/commands/entrypoint-command.test.ts
  • apps/ensrainbow/src/commands/entrypoint-command.ts
  • apps/ensrainbow/src/commands/server-command.test.ts
  • apps/ensrainbow/src/config/public.ts
  • apps/ensrainbow/src/lib/api.ts
  • docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx

Comment thread docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx Outdated
Copilot AI review requested due to automatic review settings April 30, 2026 19:55
@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io April 30, 2026 19:56 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io April 30, 2026 19:56 Inactive
Copy link
Copy Markdown
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 makes ENSRainbow’s public configuration (GET /v1/config) available immediately on startup (before DB bootstrap completes) by building it eagerly from CLI/env label-set arguments, while keeping /ready and DB-backed endpoints gated on DB attach + post-bootstrap validation (including env-vs-DB label-set mismatch handling).

Changes:

  • Serve /v1/config from an eagerly built in-memory config (no longer 503 during bootstrap).
  • Gate /ready and DB-backed routes on a non-null DbConfig snapshot; add explicit env-vs-DB label-set mismatch termination behavior.
  • Add/adjust tests and update docs + changeset to reflect the new readiness/config semantics.

Reviewed changes

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

Show a summary per file
File Description
docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx Documents /v1/config as available immediately and updates the response shape/semantics.
apps/ensrainbow/src/lib/api.ts Updates API wiring to accept a concrete publicConfig and gate DB-backed endpoints on DbConfig availability.
apps/ensrainbow/src/config/public.ts Refactors public config construction to support building from a label set (pre-DB) or DbConfig (post-DB).
apps/ensrainbow/src/commands/server-command.ts Adapts to the new createApi signature (pass publicConfig directly).
apps/ensrainbow/src/commands/server-command.test.ts Updates server API construction and adds pending-server assertions for eager /v1/config.
apps/ensrainbow/src/commands/entrypoint-command.ts Builds public config eagerly from CLI/env; adds mismatch validation + injectable exit hook for tests.
apps/ensrainbow/src/commands/entrypoint-command.test.ts Adds coverage for early /v1/config availability and env-vs-DB mismatch exit behavior.
.changeset/ensrainbow-eager-public-config.md Records the behavior change for release notes/versioning.

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

@djstrong djstrong marked this pull request as ready for review April 30, 2026 20:04
@djstrong djstrong requested a review from a team as a code owner April 30, 2026 20:04
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This PR makes ENSRainbow's GET /v1/config available immediately at startup by building the public config in-memory from CLI/env args (LABEL_SET_ID, LABEL_SET_VERSION) before the database is bootstrapped. After bootstrap completes, the configured label set is validated against the on-disk database's stored values; a mismatch logs a diagnostic error and terminates with exit code 1. ENSIndexer's PublicConfigBuilder has its waitForEnsRainbowReady dependency removed, since /v1/config no longer requires the DB to be ready.

Confidence Score: 5/5

Safe to merge — logic is sound and all new code paths are covered by tests.

No P0 or P1 issues found. The one P2 finding (an unreachable exitRequested guard in .catch()) is defensive dead code that does not affect correctness or safety. The mismatch detection, exit-hook contract, and 503 gating on dbConfigSupplier are all well-reasoned and well-tested.

apps/ensrainbow/src/commands/entrypoint-command.ts — minor dead-code guard, no action required to merge.

Important Files Changed

Filename Overview
apps/ensrainbow/src/commands/entrypoint-command.ts Core logic change: builds in-memory public config from CLI/env before HTTP server starts, validates against DB after bootstrap, exits on mismatch. One dead-code guard found in .catch() branch.
apps/ensrainbow/src/lib/api.ts Removed PublicConfigSupplier type; createApi now accepts static publicConfig. /v1/config always returns immediately; /v1/heal and /ready correctly gate on dbConfigSupplier() !== null.
apps/ensrainbow/src/config/public.ts Extracted buildEnsRainbowPublicConfigFromLabelSet to allow config construction without a full DbConfig; existing buildEnsRainbowPublicConfig now delegates to it.
apps/ensrainbow/src/commands/entrypoint-command.test.ts New mismatch test suite validates exit hook invocation and that /ready stays 503; early /v1/config access tested before bootstrap completes.
apps/ensrainbow/src/commands/server-command.test.ts Updated pending-server tests to use buildEnsRainbowPublicConfigFromLabelSet and verify /v1/config returns 200 before DB attaches.
apps/ensrainbow/src/commands/server-command.ts Trivial call-site update to pass static publicConfig to createApi instead of a supplier lambda.
apps/ensindexer/src/lib/public-config-builder/public-config-builder.ts Removed waitForEnsRainbowReady hook from PublicConfigBuilder since /v1/config is now always available on ENSRainbow startup.
apps/ensindexer/src/lib/public-config-builder/singleton.ts Simplified singleton construction — no longer threads waitForEnsRainbowToBeReady into PublicConfigBuilder.

Sequence Diagram

sequenceDiagram
    participant EP as entrypointCommand
    participant HTTP as HTTP Server
    participant BS as runDbBootstrap (setTimeout)
    participant DB as Database
    participant Client as ENSIndexer / Client

    EP->>EP: buildEnsRainbowPublicConfigFromLabelSet(args)
    EP->>HTTP: serve(app) — binds port
    EP->>BS: schedule via setTimeout(0)

    Client->>HTTP: GET /v1/config
    HTTP-->>Client: 200 (in-memory config)

    Client->>HTTP: GET /ready
    HTTP-->>Client: 503 (dbConfigSupplier = null)

    BS->>DB: open / download + extract
    DB-->>BS: attached

    alt label set matches
        BS->>EP: cachedDbConfig = dbConfig
        Client->>HTTP: GET /ready
        HTTP-->>Client: 200
        Client->>HTTP: GET /v1/heal/:labelhash
        HTTP-->>Client: 200 / healed label
    else label set mismatch
        BS->>EP: resolvePromise() + requestExit(1)
        EP->>EP: process.exit(1)
        Client->>HTTP: GET /ready
        HTTP-->>Client: 503 (cachedDbConfig still null)
    end
Loading

Reviews (3): Last reviewed commit: "refactor(ensrainbow): enhance exit hook ..." | Re-trigger Greptile

Comment thread apps/ensrainbow/src/commands/entrypoint-command.ts Outdated
Copy link
Copy Markdown
Member

@lightwalker-eth lightwalker-eth left a comment

Choose a reason for hiding this comment

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

@djstrong Looks good, thank you 🫡 Please take the lead to merge when ready 👍

…nfig building

- Changed the exit function type in EntrypointCommandOptions from `void` to `never` to enforce non-return behavior.
- Updated the server command tests to utilize the new `buildEnsRainbowPublicConfigFromLabelSet` function for improved clarity and functionality.
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io May 4, 2026 07:30 Inactive
@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io May 4, 2026 07:30 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensnode.io May 4, 2026 07:30 Inactive
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a 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

🤖 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/ensrainbow/src/commands/entrypoint-command.ts`:
- Around line 53-60: The optional exit hook (exit?: (code: number) => never) is
only a TypeScript guarantee; at runtime a test or misconfigured implementation
can return normally and leave the server running. Update the places that call
this.exit(...) (the exit property on the EntryPointCommand and the bootstrap
error handlers around the block referenced at lines ~186–196) to enforce the
non-returning contract: call the hook, then if it returns, immediately throw a
new Error (or call process.exit as a fallback) so the process cannot continue;
ensure the same enforcement exists in both the initial bootstrap failure and the
env-vs-DB mismatch paths. Reference the exit property on the EntryPointCommand
and the bootstrap/error handler methods when making the change.
🪄 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: b33ef739-ed71-4d28-8104-9cd99ac28770

📥 Commits

Reviewing files that changed from the base of the PR and between cb2fdde and 012615c.

📒 Files selected for processing (3)
  • apps/ensrainbow/src/commands/entrypoint-command.ts
  • apps/ensrainbow/src/commands/server-command.test.ts
  • docs/ensnode.io/src/content/docs/ensrainbow/usage/api.mdx

Comment thread apps/ensrainbow/src/commands/entrypoint-command.ts
djstrong added 2 commits May 4, 2026 09:42
…onstructor

- Eliminated the one-time async readiness hook from the PublicConfigBuilder constructor to streamline the configuration process.
- Updated related tests to reflect the removal of the readiness check, ensuring they still validate the expected behavior of the public config retrieval.
- Updated the exit function in EntrypointCommandOptions to ensure it throws an error instead of returning, enforcing the non-returning contract.
- Improved the requestExit function to handle cases where the exit hook may return, adding a fallback to process.exit to prevent the server from running in a failed state.
- Updated comments for clarity on the exit handling mechanism and its implications for testing.
Copilot AI review requested due to automatic review settings May 4, 2026 07:43
@vercel vercel Bot temporarily deployed to Preview – ensnode.io May 4, 2026 07:43 Inactive
@vercel vercel Bot temporarily deployed to Preview – ensrainbow.io May 4, 2026 07:43 Inactive
@vercel vercel Bot temporarily deployed to Preview – admin.ensnode.io May 4, 2026 07:43 Inactive
Copy link
Copy Markdown
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 11 out of 11 changed files in this pull request and generated no new comments.


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

@djstrong djstrong merged commit 1db1637 into main May 4, 2026
25 checks passed
@djstrong djstrong deleted the 2020-allow-ensrainbow-clients-to-fetch-ensrainbowpublicconfig-as-soon-as-possible branch May 4, 2026 08:17
@github-actions github-actions Bot mentioned this pull request May 3, 2026
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.

Allow ENSRainbow clients to fetch EnsRainbowPublicConfig as soon as possible.

3 participants