-
Notifications
You must be signed in to change notification settings - Fork 15
refactor(ensnode-sdk): improve indexing status data model #1628
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
Replace `./types` with `./cross-chain-indexing-status-snapshot`
…zed-types.ts file
Replace `./serialized-types` with `./serialize/cross-chain-indexing-status-snapshot`
Replace `./deserialize` with `./deserialize/cross-chain-indexing-status-snapshot`
…types.ts file Rename `types.ts` to `realtime-indexing-status-projection.ts`.
…projection.ts file Merge `projection.ts` into `realtime-indexing-status-projection.ts`.
… serialized-types.ts file Rename `serialize-types.ts` to `serialize/realtime-indexing-status-projection.ts`.
… serialize.ts file Merge `serialize.ts` into `serialize/realtime-indexing-status-projection.ts`.
…c zod-schemas.ts file Rename `zod-schemas.ts` into `zod-schema/realtime-indexing-status-projection.ts`.
…c validations.ts file Merge `validations.ts` into `zod-schema/realtime-indexing-status-projection.ts`.
…ic deserialize.ts file Rename `deserialize.ts` to `deserialize/realtime-indexing-status-projection.ts`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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. 📝 WalkthroughWalkthroughThis pull request refactors the Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Refactors the ENSIndexer indexing-status module to further separate responsibilities (data model vs serialize/deserialize vs Zod schema) in preparation for an independent validation layer for CrossChainIndexingStatusSnapshot and RealtimeIndexingStatusProjection.
Changes:
- Moves Cross-chain + Realtime projection Zod schemas into the
zod-schema/layer and splits serialization/deserialization into dedicated modules. - Extracts
RealtimeIndexingStatusProjectioninto its own model file and relocatesgetLatestIndexedBlockRefintocross-chain-indexing-status-snapshot.ts. - Removes legacy aggregator modules (
deserialize.ts,serialize.ts,serialized-types.ts,zod-schemas.ts,helpers.ts,projection.ts) in favor of granular exports.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ensnode-sdk/src/internal.ts | Removes re-export of deprecated ENSIndexer indexing-status Zod schema barrel. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schemas.ts | Deleted old indexing-status Zod schema barrel (moved to zod-schema/). |
| packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/realtime-indexing-status-projection.ts | Adds dedicated Zod schema + invariants for realtime projection. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/cross-chain-indexing-status-snapshot.ts | Updates cross-chain snapshot schema placement and dependencies. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/chain-indexing-status-snapshot.test.ts | Fixes imports after refactor. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/serialized-types.ts | Deletes old shared serialized type definitions (moved into serialize modules). |
| packages/ensnode-sdk/src/ensindexer/indexing-status/serialize/realtime-indexing-status-projection.ts | Adds serialize module + serialized interfaces for realtime projection. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/serialize/cross-chain-indexing-status-snapshot.ts | Adds serialize module + serialized interfaces for cross-chain snapshot. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/serialize.ts | Deletes old serialize barrel. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/realtime-indexing-status-projection.ts | Introduces dedicated realtime projection model + constructor. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/realtime-indexing-status-projection.test.ts | Updates tests to new module paths/types. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/projection.ts | Deletes old projection module (logic moved). |
| packages/ensnode-sdk/src/ensindexer/indexing-status/index.ts | Updates public exports to new granular module structure. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/helpers.ts | Deletes old helpers module (helper moved). |
| packages/ensnode-sdk/src/ensindexer/indexing-status/deserialize/realtime-indexing-status-snapshot.ts | Adds dedicated deserialize for realtime projection (file naming mismatch noted). |
| packages/ensnode-sdk/src/ensindexer/indexing-status/deserialize/cross-chain-indexing-status-snapshot.ts | Adds dedicated deserialize for cross-chain snapshot. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/deserialize.ts | Deletes old deserialize barrel. |
| packages/ensnode-sdk/src/ensindexer/indexing-status/cross-chain-indexing-status-snapshot.ts | Removes projection type from this file; adds getLatestIndexedBlockRef. |
| packages/ensnode-sdk/src/api/indexing-status/zod-schemas.ts | Updates API schema dependency to new realtime projection schema location. |
Comments suppressed due to low confidence (1)
packages/ensnode-sdk/src/ensindexer/indexing-status/cross-chain-indexing-status-snapshot.ts:3
- The JSDoc for
CrossChainIndexingStatusSnapshotOmnichainreferences{@link ChainIndexingConfigTypeIds.Definite}, butChainIndexingConfigTypeIdsis no longer imported in this module. If Typedoc/linking is used, this will likely become an unresolved reference; consider re-adding a type-only import forChainIndexingConfigTypeIdsor adjusting the link to a resolvable target.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ensnode-sdk/src/ensindexer/indexing-status/zod-schema/realtime-indexing-status-projection.ts
Show resolved
Hide resolved
| code: "custom", | ||
| input: projection, | ||
| message: | ||
| "`worstCaseDistance` must be the exact difference between `projectedAt` and `snapshot.omnichainIndexingCursor`.", |
Copilot
AI
Feb 11, 2026
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.
The invariant error message references snapshot.omnichainIndexingCursor, but the actual field is nested (snapshot.omnichainSnapshot.omnichainIndexingCursor) or can be expressed via snapshot.slowestChainIndexingCursor. Updating the message will make validation errors actionable and consistent with the data model.
| "`worstCaseDistance` must be the exact difference between `projectedAt` and `snapshot.omnichainIndexingCursor`.", | |
| "`worstCaseDistance` must be the exact difference between `projectedAt` and `snapshot.omnichainSnapshot.omnichainIndexingCursor`.", |
| slowestChainIndexingCursor, | ||
| snapshotTime, | ||
| omnichainSnapshot, | ||
| }: CrossChainIndexingStatusSnapshot): SerializedCrossChainIndexingStatusSnapshot { |
Copilot
AI
Feb 11, 2026
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.
serializeCrossChainIndexingStatusSnapshotOmnichain is named as if it only accepts the omnichain variant, but its parameter is typed as CrossChainIndexingStatusSnapshot (the union). Typing the parameter as CrossChainIndexingStatusSnapshotOmnichain would better match the function name and avoid future issues if additional strategies are added.
| }: CrossChainIndexingStatusSnapshot): SerializedCrossChainIndexingStatusSnapshot { | |
| }: CrossChainIndexingStatusSnapshotOmnichain): SerializedCrossChainIndexingStatusSnapshot { |
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: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/cross-chain-indexing-status-snapshot.ts (1)
26-29:⚠️ Potential issue | 🟡 MinorRemove debug
console.logfrom the invariant function.This
console.logon Line 26 looks like a debug artifact left from development. Invariant validation functions should not emit console output — the validation error pushed toctx.issueson Line 30 already provides the necessary diagnostics.🧹 Proposed fix
if (slowestChainIndexingCursor !== omnichainIndexingCursor) { - console.log("invariant_slowestChainEqualsToOmnichainSnapshotTime", { - slowestChainIndexingCursor, - omnichainIndexingCursor, - }); ctx.issues.push({ code: "custom", input: ctx.value,
🤖 Fix all issues with AI agents
In `@packages/ensnode-sdk/src/ensindexer/indexing-status/index.ts`:
- Around line 11-12: There is a duplicate re-export of the same module: remove
one of the two identical export lines re-exporting
"./serialize/realtime-indexing-status-projection" so that the module is only
exported once (ensure the remaining export is left intact and no other exports
are changed).
In
`@packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/realtime-indexing-status-projection.ts`:
- Around line 41-57: The invariant function
invariant_realtimeIndexingStatusProjectionWorstCaseDistanceIsCorrect currently
computes expectedWorstCaseDistance using
omnichainSnapshot.omnichainIndexingCursor and references
snapshot.omnichainIndexingCursor in the error message; update it to use
omnichainSnapshot.slowestChainIndexingCursor for the calculation and update the
error message to mention `snapshot.slowestChainIndexingCursor` so the validation
aligns with the RealtimeIndexingStatusProjection type and its documented
invariant.
...ensnode-sdk/src/ensindexer/indexing-status/zod-schema/realtime-indexing-status-projection.ts
Show resolved
Hide resolved
...nsnode-sdk/src/ensindexer/indexing-status/deserialize/realtime-indexing-status-projection.ts
Show resolved
Hide resolved
Greptile OverviewGreptile SummaryThis PR refactors the ENSNode SDK's indexing-status data model by splitting the previously monolithic Net effect is intended to be structural only: the runtime behavior and invariants are preserved while enabling an independent validation layer that can validate Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant SDK as ensnode-sdk
participant Zod
Client->>SDK: deserializeRealtimeIndexingStatusProjection(payload)
SDK->>Zod: makeRealtimeIndexingStatusProjectionSchema().safeParse(payload)
Zod->>Zod: check projectedAt vs snapshotTime
Zod->>Zod: check worstCaseDistance vs slowestChainIndexingCursor
Zod-->>SDK: parsed projection or error
SDK-->>Client: return projection / throw Error
Client->>SDK: deserializeCrossChainIndexingStatusSnapshot(payload)
SDK->>Zod: makeCrossChainIndexingStatusSnapshotSchema().safeParse(payload)
Zod->>Zod: check slowestChainIndexingCursor invariant
Zod->>Zod: check snapshotTime highest-known-block invariant
Zod-->>SDK: parsed snapshot or error
SDK-->>Client: return snapshot / throw Error
|
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.
19 files reviewed, no comments
Import paths updates
General serialization method for `CrossChainIndexingStatusSnapshot`.
|
@greptile review |
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: 3
🤖 Fix all issues with AI agents
In `@packages/ensnode-sdk/src/ensindexer/indexing-status/index.ts`:
- Around line 9-11: The barrel is missing a re-export for the serialize module
cross-chain-indexing-status-snapshot; add an export line for
"./serialize/cross-chain-indexing-status-snapshot" alongside the existing
exports (e.g., the lines exporting "./serialize/chain-indexing-status-snapshot",
"./serialize/omnichain-indexing-status-snapshot", and
"./serialize/realtime-indexing-status-projection") so consumers can import the
cross-chain serialization utilities.
In
`@packages/ensnode-sdk/src/ensindexer/indexing-status/serialize/cross-chain-indexing-status-snapshot.ts`:
- Around line 39-45: The switch in serializeCrossChainIndexingStatusSnapshot on
snapshot.strategy covers CrossChainIndexingStrategyIds.Omnichain but lacks an
exhaustive default branch; update serializeCrossChainIndexingStatusSnapshot to
add a default case that performs an exhaustive-check (e.g., call an
assertUnreachable helper or throw a descriptive Error) referencing the
snapshot.strategy and function name, so any future CrossChainIndexingStrategyIds
variant triggers a runtime failure and makes the intent explicit.
In
`@packages/ensnode-sdk/src/ensindexer/indexing-status/zod-schema/realtime-indexing-status-projection.ts`:
- Around line 36-39: Update the JSDoc invariant so it references the correct
field name: replace `omnichainIndexingCursor` with `slowestChainIndexingCursor`
and ensure it states that `worstCaseDistance` is the difference between
`projectedAt` and `snapshot.slowestChainIndexingCursor`; this aligns the comment
with the implementation that uses `snapshot.slowestChainIndexingCursor` and the
error message in this file (realtime-indexing-status-projection.ts) and avoids
the stale `omnichainIndexingCursor` name.
...ensnode-sdk/src/ensindexer/indexing-status/serialize/cross-chain-indexing-status-snapshot.ts
Show resolved
Hide resolved
...ensnode-sdk/src/ensindexer/indexing-status/zod-schema/realtime-indexing-status-projection.ts
Outdated
Show resolved
Hide resolved
Use equivalent `slowestChainIndexingCursor` field to replace `omnichainSnapshot.omnichainIndexingCursor` in invariant logic for `RealtimeIndexingStatusProjection`.
e069a8f to
66ae12d
Compare
| const { projectedAt, snapshot, worstCaseDistance } = projection; | ||
| const { omnichainSnapshot } = snapshot; | ||
| const expectedWorstCaseDistance = projectedAt - omnichainSnapshot.omnichainIndexingCursor; | ||
| const expectedWorstCaseDistance = projectedAt - snapshot.slowestChainIndexingCursor; |
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.
snapshot.omnichainSnapshot.omnichainIndexingCursor and snapshot.slowestChainIndexingCursor are the same value, but snapshot.slowestChainIndexingCursor is more relevant in the context of RealtimeIndexingStatusProjection.
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.
Pull request overview
Copilot reviewed 19 out of 19 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.
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.
19 files reviewed, 1 comment
Additional Comments (1)
|
Lite PR
Tip: Review docs on the ENSNode PR process
Summary
CrossChainIndexingStatusSnapshotRealtimeIndexingStatusProjectionWhy
Unvalidated<CrossChainIndexingStatusSnapshot>and have it validated withvalidateCrossChainIndexingStatusSnapshot.Testing
/api/indexing-statuson local ENSIndexer instance./api/indexing-statuson local ENSApi instance connected to ENSIndexer Alpha in the Green env.Notes for Reviewer (Optional)
OmnichainIndexingStatusSnapshotdata model #1627.Pre-Review Checklist (Blocking)