Skip to content

Streamlined data model for block ranges#1697

Open
tk-o wants to merge 1 commit intomainfrom
feat/1682-streamlined-block-range-data-model
Open

Streamlined data model for block ranges#1697
tk-o wants to merge 1 commit intomainfrom
feat/1682-streamlined-block-range-data-model

Conversation

@tk-o
Copy link
Contributor

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

Same types and utils have been added to ENSNode SDK and Ponder SDK.

Lite PR

Tip: Review docs on the ENSNode PR process

Summary

  • Introduces buildBlockNumberRange and buildBlockRefRange functions, along with relevant data model, to ENSNode SDK and Ponder SDK.

Why

  • We have too many representations of concepts around block ranges. We need to streamline our data model for that concept.

Testing

  • Ran lint, typecheck, testing suite.
  • Tested Indexing Status API for local ENSIndexer instance.

Notes for Reviewer (Optional)

  • This PR follows the abstract design for data model shared in this Slack thread.
  • Both implementations in ENSNode SDK and Ponder SDK should be identical.
  • We duplicate the implementation to maintain independence between those two packages.

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)

@tk-o tk-o requested a review from a team as a code owner February 27, 2026 13:36
Copilot AI review requested due to automatic review settings February 27, 2026 13:36
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

🦋 Changeset detected

Latest commit: caa31bb

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

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

@vercel
Copy link
Contributor

vercel bot commented Feb 27, 2026

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

Project Deployment Actions Updated (UTC)
admin.ensnode.io Ready Ready Preview, Comment Feb 27, 2026 3:05pm
ensnode.io Ready Ready Preview, Comment Feb 27, 2026 3:05pm
ensrainbow.io Ready Ready Preview, Comment Feb 27, 2026 3:05pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb79f21 and caa31bb.

📒 Files selected for processing (7)
  • .changeset/smart-vans-stare.md
  • packages/ensnode-sdk/src/index.ts
  • packages/ensnode-sdk/src/shared/blockrange.test.ts
  • packages/ensnode-sdk/src/shared/blockrange.ts
  • packages/ponder-sdk/src/blockrange.test.ts
  • packages/ponder-sdk/src/blockrange.ts
  • packages/ponder-sdk/src/index.ts

📝 Walkthrough

Walkthrough

Adds type-safe BlockNumberRange and BlockRefRange abstractions with factory builders and runtime validation to two SDK packages, plus unit tests and a changeset; re-exports the module from ponder-sdk while ensnode-sdk's export remains commented out.

Changes

Cohort / File(s) Summary
Changeset
.changeset/smart-vans-stare.md
New changeset bumping minor versions for @ensnode/ensnode-sdk and @ensnode/ponder-sdk with a note about a streamlined datamodel for block ranges.
ensnode-sdk: new range module & tests
packages/ensnode-sdk/src/shared/blockrange.ts, packages/ensnode-sdk/src/shared/blockrange.test.ts
Adds RangeTypeIds/RangeType, BlockNumberRange and BlockRefRange variants (Unbounded/LeftBounded/RightBounded/Bounded), buildBlockNumberRange/buildBlockRefRange factories with runtime validation/invariants, and unit tests covering valid and invalid scenarios.
ensnode-sdk: index edit
packages/ensnode-sdk/src/index.ts
Commented-out re-export of ./shared/blockrange plus a TODO comment — the blockrange export is not made public.
ponder-sdk: new range module, tests & re-export
packages/ponder-sdk/src/blockrange.ts, packages/ponder-sdk/src/blockrange.test.ts, packages/ponder-sdk/src/index.ts
Adds a mirror blockrange module (types, factories, validation), unit tests, and exposes the module via export * from "./blockrange" in the package's index.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

"I nibble logic, hop and test,
Ranges bounded, left or best,
Start and end in tidy line,
I check the order, small and fine 🐇,
A cheerful hop — the code's design."

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change in the PR: introducing a streamlined data model for block ranges across both SDKs.
Description check ✅ Passed The description follows the required template structure with all main sections (Summary, Why, Testing, Notes for Reviewer, Pre-Review Checklist) properly completed.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/1682-streamlined-block-range-data-model

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.

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

Adds a new discriminated-union data model and builder utilities for “block ranges” (bounded/unbounded, left/right-bounded) to both @ensnode/ensnode-sdk and @ensnode/ponder-sdk, plus tests and a changeset, as part of consolidating block range representations.

Changes:

  • Introduces RangeTypeIds, BlockNumberRange / BlockRefRange unions, and buildBlockNumberRange / buildBlockRefRange helpers in both SDKs.
  • Exposes the new helpers/types via each package’s public src/index.ts.
  • Adds Vitest coverage for the new builders and a changeset for versioning.

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
packages/ponder-sdk/src/index.ts Re-exports new blockrange module from Ponder SDK entrypoint.
packages/ponder-sdk/src/blockrange.ts New block range data model + builders for Ponder SDK.
packages/ponder-sdk/src/blockrange.test.ts Unit tests for Ponder SDK block range builders.
packages/ensnode-sdk/src/shared/blockrange.ts New shared block range data model + builders for ENSNode SDK.
packages/ensnode-sdk/src/shared/blockrange.test.ts Unit tests for ENSNode SDK block range builders.
packages/ensnode-sdk/src/index.ts Exposes shared blockrange from ENSNode SDK entrypoint (currently causes an export-name collision).
.changeset/smart-vans-stare.md Declares minor bumps for both packages (contains a spelling error).

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

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 27, 2026

Greptile Summary

This PR introduces a streamlined and type-safe data model for block ranges in both the ENSNode SDK and Ponder SDK. The implementation uses discriminated unions with four range types (unbounded, left-bounded, right-bounded, and bounded), making it clear at compile-time and runtime which bounds are present.

Key changes:

  • Added buildBlockNumberRange and buildBlockRefRange builder functions with comprehensive TypeScript overloads for precise type inference
  • Created well-documented type interfaces for each range variant
  • Included validation logic that ensures startBlock <= endBlock for both number and ref ranges
  • Comprehensive test coverage for all range types, edge cases, and error conditions
  • Nearly identical implementations across both SDKs (intentional for independence)

Issues found:

  • Minor typo in changeset file ("Introcudes" should be "Introduces")

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is straightforward and well-tested with only a minor spelling error in the changeset. The code follows good TypeScript practices with discriminated unions and comprehensive function overloads. Tests thoroughly cover all scenarios including edge cases and error conditions.
  • No files require special attention - all implementations are clean and well-structured

Important Files Changed

Filename Overview
.changeset/smart-vans-stare.md Changeset file for minor version bump; contains typo
packages/ensnode-sdk/src/shared/blockrange.ts Well-designed discriminated union types with validation logic
packages/ponder-sdk/src/blockrange.ts Implementation matches ensnode-sdk with appropriate imports

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class BlockNumberRange {
        <<union>>
    }
    
    class BlockNumberRangeUnbounded {
        +rangeType: "unbounded"
    }
    
    class BlockNumberRangeLeftBounded {
        +rangeType: "left-bounded"
        +startBlock: BlockNumber
    }
    
    class BlockNumberRangeRightBounded {
        +rangeType: "right-bounded"
        +endBlock: BlockNumber
    }
    
    class BlockNumberRangeBounded {
        +rangeType: "bounded"
        +startBlock: BlockNumber
        +endBlock: BlockNumber
    }
    
    class BlockRefRange {
        <<union>>
    }
    
    class BlockRefRangeUnbounded {
        +rangeType: "unbounded"
    }
    
    class BlockRefRangeLeftBounded {
        +rangeType: "left-bounded"
        +startBlock: BlockRef
    }
    
    class BlockRefRangeRightBounded {
        +rangeType: "right-bounded"
        +endBlock: BlockRef
    }
    
    class BlockRefRangeBounded {
        +rangeType: "bounded"
        +startBlock: BlockRef
        +endBlock: BlockRef
    }
    
    BlockNumberRange <|-- BlockNumberRangeUnbounded
    BlockNumberRange <|-- BlockNumberRangeLeftBounded
    BlockNumberRange <|-- BlockNumberRangeRightBounded
    BlockNumberRange <|-- BlockNumberRangeBounded
    
    BlockRefRange <|-- BlockRefRangeUnbounded
    BlockRefRange <|-- BlockRefRangeLeftBounded
    BlockRefRange <|-- BlockRefRangeRightBounded
    BlockRefRange <|-- BlockRefRangeBounded
Loading

Last reviewed commit: 585cb38

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.

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@tk-o tk-o force-pushed the feat/1682-streamlined-block-range-data-model branch from 585cb38 to d5dcf65 Compare February 27, 2026 13:41
Copilot AI review requested due to automatic review settings February 27, 2026 13:41
Copy link
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: 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 @.changeset/smart-vans-stare.md:
- Line 6: The changeset description in .changeset/smart-vans-stare.md contains a
spelling mistake: replace the word "Introcudes" with the correct "Introduces" so
the release notes read "Introduces streamlined datamodel for block ranges.";
update that exact token in the file to fix the typo.

In `@packages/ensnode-sdk/src/index.ts`:
- Line 13: The package index re-exports two different BlockRefRange types via
wildcard exports (from shared/blockrange and
indexing-status/chain-indexing-status-snapshot), causing a duplicate export
error; fix by updating the exports in index.ts to avoid exporting both
conflicting symbols: either explicitly re-export only the desired BlockRefRange
from shared/blockrange and remove BlockRefRange from the indexing-status export
(use named exports like export { BlockRefRange as ... } or omit it), or rename
the type in indexing-status (e.g., BlockRefRangeIndefinite/Definite ->
ChainBlockRefRange) and update its export so that only one BlockRefRange
identifier is exported; reference the modules shared/blockrange and
indexing-status/chain-indexing-status-snapshot and the symbol BlockRefRange when
making the change.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b25c1b5 and 585cb38.

📒 Files selected for processing (7)
  • .changeset/smart-vans-stare.md
  • packages/ensnode-sdk/src/index.ts
  • packages/ensnode-sdk/src/shared/blockrange.test.ts
  • packages/ensnode-sdk/src/shared/blockrange.ts
  • packages/ponder-sdk/src/blockrange.test.ts
  • packages/ponder-sdk/src/blockrange.ts
  • packages/ponder-sdk/src/index.ts

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 7 out of 7 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.

Copy link
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: 2

♻️ Duplicate comments (1)
packages/ensnode-sdk/src/index.ts (1)

13-14: ⚠️ Potential issue | 🟠 Major

Blockrange API remains inaccessible from the SDK root entrypoint due to unresolved export conflict.

The ./shared/blockrange export (line 14) stays commented out because both blockrange.ts and chain-indexing-status-snapshot.ts export incompatible BlockRefRange types. The blockrange variant uses rangeType with Unbounded/LeftBounded/RightBounded/Bounded states, while the indexing-status variant uses blockRangeType with Indefinite/Definite states—these cannot coexist in the same namespace without aliasing or renaming.

Resolve this before release by either:

  • Renaming one BlockRefRange type (e.g., to BlockRefRangeIndexingConfig in indexing-status)
  • Using explicit re-exports with aliases in index.ts
  • Or defer the blockrange feature exposure claim from this PR
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ensnode-sdk/src/index.ts` around lines 13 - 14, The SDK root export
for BlockRefRange is commented out because two symbols named BlockRefRange
conflict: the variant in ./shared/blockrange (uses rangeType with
Unbounded/LeftBounded/RightBounded/Bounded) and the variant in
chain-indexing-status-snapshot (uses blockRangeType with Indefinite/Definite).
Fix by either renaming one exported type (e.g., change the type name in
chain-indexing-status-snapshot.ts to BlockRefRangeIndexingConfig) or add
explicit aliased re-exports in index.ts (e.g., export { BlockRefRange as
BlockRefRangeBlockrange } from "./shared/blockrange" and export { BlockRefRange
as BlockRefRangeIndexingConfig } from "./chain-indexing-status-snapshot") so
both APIs can be exposed without collision, then uncomment the export line for
./shared/blockrange.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ensnode-sdk/src/shared/blockrange.ts`:
- Around line 44-49: Convert the interfaces that document the invariants into
type aliases and move the invariant JSDoc there: replace the interface
declaration for the bounded block range (currently documenting "startBlock is
lower than or equal to endBlock") with a type alias (e.g., BlockRangeBounded)
and do the same for BlockRefRangeBounded; remove the duplicate invariant comment
from the corresponding builder functions (the builder that constructs the
bounded block range and the builder for BlockRefRangeBounded) so the invariant
is only documented once on the type alias; ensure the type alias names and
builder function signatures remain unchanged so callers are unaffected.

In `@packages/ponder-sdk/src/blockrange.ts`:
- Around line 43-48: Remove the duplicated invariant comments that repeat the
documentation already declared on the type aliases; specifically, delete the
inline comment lines that restate "`startBlock` is lower than or equal to
`endBlock`" in the implementation blocks for BlockNumberRangeBounded and
BlockRefRangeBounded so the invariant remains documented only on the
corresponding type alias declarations (BlockNumberRangeBounded,
BlockRefRangeBounded).

---

Duplicate comments:
In `@packages/ensnode-sdk/src/index.ts`:
- Around line 13-14: The SDK root export for BlockRefRange is commented out
because two symbols named BlockRefRange conflict: the variant in
./shared/blockrange (uses rangeType with
Unbounded/LeftBounded/RightBounded/Bounded) and the variant in
chain-indexing-status-snapshot (uses blockRangeType with Indefinite/Definite).
Fix by either renaming one exported type (e.g., change the type name in
chain-indexing-status-snapshot.ts to BlockRefRangeIndexingConfig) or add
explicit aliased re-exports in index.ts (e.g., export { BlockRefRange as
BlockRefRangeBlockrange } from "./shared/blockrange" and export { BlockRefRange
as BlockRefRangeIndexingConfig } from "./chain-indexing-status-snapshot") so
both APIs can be exposed without collision, then uncomment the export line for
./shared/blockrange.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 585cb38 and bb79f21.

📒 Files selected for processing (7)
  • .changeset/smart-vans-stare.md
  • packages/ensnode-sdk/src/index.ts
  • packages/ensnode-sdk/src/shared/blockrange.test.ts
  • packages/ensnode-sdk/src/shared/blockrange.ts
  • packages/ponder-sdk/src/blockrange.test.ts
  • packages/ponder-sdk/src/blockrange.ts
  • packages/ponder-sdk/src/index.ts

Same types and utils have been added to ENSNode SDK and Ponder SDK.
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