Skip to content

feat(grpc): add earliest/latest block height to GetSyncing response#25648

Merged
aljo242 merged 19 commits intocosmos:mainfrom
Cordtus:feat/earliest-block-height-grpc
Jan 26, 2026
Merged

feat(grpc): add earliest/latest block height to GetSyncing response#25648
aljo242 merged 19 commits intocosmos:mainfrom
Cordtus:feat/earliest-block-height-grpc

Conversation

@Cordtus
Copy link
Copy Markdown
Contributor

@Cordtus Cordtus commented Dec 5, 2025

Description

Ref: #15463

This PR extends the GetSyncingResponse in cosmos.base.tendermint.v1beta1.Service to include block height information that is essential for indexers and tooling.

Problem

Indexers need to know which blocks are available on a node before attempting to fetch them. Currently, this information is only available via CometBFT's /status RPC endpoint (sync_info.earliest_block_height), requiring clients to query two different endpoints.

When an indexer tries to fetch a pruned block, it gets an error like:

height 60 is not available, lowest height is 28566001

Discovering available block heights proactively via gRPC would be more efficient.

Solution

Add two new fields to GetSyncingResponse:

  • earliest_block_height - The earliest block height available on this node
  • latest_block_height - The latest block height available on this node

These fields expose the same information as CometBFT's SyncInfo struct, making it available via the existing gRPC endpoint without requiring a separate RPC call.

Changes

File Change
proto/cosmos/base/tendermint/v1beta1/query.proto Add new fields to GetSyncingResponse
client/grpc/cmtservice/query.pb.go Generated code with new fields
client/grpc/cmtservice/service.go Populate new fields from SyncInfo
tests/systemtests/cometbft_service_test.go Add systemtest with pruning verification

API

message GetSyncingResponse {
  bool syncing = 1;
  int64 earliest_block_height = 2;  // NEW
  int64 latest_block_height = 3;    // NEW
}

Testing

Systemtest added (TestCometBFTGetSyncingGRPC and TestCometBFTGetSyncingWithBlockRetention) that:

  1. Verifies gRPC endpoint returns valid block heights
  2. Confirms latest_block_height increases over time
  3. Confirms earliest_block_height is stable on unpruned chains
  4. Verifies pruning behavior: Configures min-retain-blocks=5 and max_age_num_blocks=5 (in genesis), then confirms earliest_block_height increases as blocks are pruned

The pruning test required modifying both app.toml (via EditToml) and genesis params (via ModifyGenesisJSON) because CometBFT's block retention is the minimum of min-retain-blocks and max_age_num_blocks. Default max_age_num_blocks=100000 would prevent pruning in tests.

=== RUN   TestCometBFTGetSyncingWithBlockRetention
    Initial state: earliest=1, latest=5
    Waiting for 15 blocks to trigger block pruning (minRetainBlocks=5)...
    After 15 blocks: earliest=15, latest=20
    Block range: 5 (latest 20 - earliest 15)
--- PASS: TestCometBFTGetSyncingWithBlockRetention (56.35s)

Backward Compatibility

This is a non-breaking change - it only adds new optional fields to an existing response message. Existing clients will continue to work unchanged.

Use Case

// Before: Need to query CometBFT RPC separately
status, _ := rpcClient.Status(ctx)
earliest := status.SyncInfo.EarliestBlockHeight

// After: Available via gRPC
resp, _ := cmtClient.GetSyncing(ctx, &GetSyncingRequest{})
earliest := resp.EarliestBlockHeight

@github-actions github-actions Bot added the C:CLI label Dec 5, 2025
@Cordtus Cordtus marked this pull request as draft December 5, 2025 18:45
@Cordtus Cordtus force-pushed the feat/earliest-block-height-grpc branch from c24cdcc to b6db48e Compare December 5, 2025 18:45
Extend the GetSyncingResponse in cosmos.base.tendermint.v1beta1.Service
to include earliest_block_height and latest_block_height fields.

This enables gRPC clients (like indexers) to discover block availability
without needing to query the CometBFT RPC separately. The fields expose
the same information as the /status RPC endpoint's sync_info.

Changes:
- Add earliest_block_height field to GetSyncingResponse proto
- Add latest_block_height field to GetSyncingResponse proto
- Update service implementation to populate new fields from SyncInfo
@Cordtus Cordtus force-pushed the feat/earliest-block-height-grpc branch from b6db48e to dc48552 Compare December 6, 2025 00:11
@Cordtus Cordtus marked this pull request as ready for review December 6, 2025 00:12
@fmorency
Copy link
Copy Markdown
Contributor

fmorency commented Dec 8, 2025

This would be useful for manifest-network/yaci#28

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.20%. Comparing base (1bb329d) to head (551eec6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #25648      +/-   ##
==========================================
+ Coverage   66.50%   68.20%   +1.69%     
==========================================
  Files         929      894      -35     
  Lines       60231    58146    -2085     
==========================================
- Hits        40058    39658     -400     
+ Misses      20173    18488    -1685     
Files with missing lines Coverage Δ
client/grpc/cmtservice/service.go 84.05% <100.00%> (+0.23%) ⬆️

... and 38 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

aljo242 and others added 5 commits December 8, 2025 15:06
Signed-off-by: Evan Etton <evanettoneva@gmail.com>
…5659)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: aljo242 <alex@cosmoslabs.io>
Add systemtest coverage for the GetSyncing gRPC endpoint to verify
earliest_block_height and latest_block_height fields work correctly.

Tests include:
- Basic gRPC connectivity and field validation
- latest_block_height increases over time
- earliest_block_height stable on unpruned chain
- Block pruning scenario: configures min-retain-blocks=5 and
  max_age_num_blocks=5 in genesis to trigger actual pruning,
  verifying earliest_block_height increases as blocks are pruned
@Cordtus
Copy link
Copy Markdown
Contributor Author

Cordtus commented Dec 10, 2025

Added a systemtest. Run with:

cd tests/systemtests && go test -tags='system_test' -v --run 'TestCometBFT' --wait-time=120s --nodes-count=1

The pruning test configures min-retain-blocks=5 in app.toml and max_age_num_blocks=5 in genesis (Comet block retention uses the minimum of both), waits 15 blocks, then confirms earliest_block_height increases from 1 to 15 as blocks get pruned.

@fmorency
Copy link
Copy Markdown
Contributor

@aljo242 is there anything blocking this PR?

@Cordtus
Copy link
Copy Markdown
Contributor Author

Cordtus commented Jan 7, 2026

Bump. Would like to be sure there is nothing else needed from my end here.

@aljo242 aljo242 requested a review from technicallyty January 23, 2026 17:56
@aljo242
Copy link
Copy Markdown
Contributor

aljo242 commented Jan 23, 2026

@technicallyty to review this

Copy link
Copy Markdown
Member

@technicallyty technicallyty left a comment

Choose a reason for hiding this comment

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

LGTM

@technicallyty
Copy link
Copy Markdown
Member

technicallyty commented Jan 23, 2026

needs go mod tidy and changelog

@aljo242 aljo242 enabled auto-merge January 26, 2026 15:01
@aljo242
Copy link
Copy Markdown
Contributor

aljo242 commented Jan 26, 2026

@Cordtus looks like you need to run make mocks

@aljo242 aljo242 added this pull request to the merge queue Jan 26, 2026
Merged via the queue into cosmos:main with commit 174b2e9 Jan 26, 2026
42 of 44 checks passed
Cordtus added a commit to Cordtus/cosmos-sdk that referenced this pull request Feb 3, 2026
…osmos#25648)

Signed-off-by: Evan Etton <evanettoneva@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Alex | Cosmos Labs <alex@cosmoslabs.io>
Co-authored-by: Evan Etton <evanettoneva@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
@Cordtus
Copy link
Copy Markdown
Contributor Author

Cordtus commented Feb 11, 2026

@aljo242 @technicallyty -- could the backport/v0.53.x label be added here as well? This was merged to main but didn't make it into v0.53.6. Would be great to have in the next patch release. Thanks!

@technicallyty
Copy link
Copy Markdown
Member

@mergify backport release/v0.53.x

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Feb 11, 2026

backport release/v0.53.x

✅ Backports have been created

Details

Cherry-pick of 174b2e9 has failed:

On branch mergify/bp/release/v0.53.x/pr-25648
Your branch is up to date with 'origin/release/v0.53.x'.

You are currently cherry-picking commit 174b2e936.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   client/grpc/cmtservice/query.pb.go
	modified:   client/grpc/cmtservice/service.go
	new file:   client/grpc/cmtservice/service_test.go
	modified:   proto/cosmos/base/tendermint/v1beta1/query.proto
	new file:   tests/systemtests/cometbft_service_test.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   CHANGELOG.md
	both modified:   go.mod
	both modified:   go.sum
	both modified:   tests/systemtests/go.mod

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

mergify Bot pushed a commit that referenced this pull request Feb 11, 2026
…25648)

Signed-off-by: Evan Etton <evanettoneva@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Alex | Cosmos Labs <alex@cosmoslabs.io>
Co-authored-by: Evan Etton <evanettoneva@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Tyler <48813565+technicallyty@users.noreply.github.com>
(cherry picked from commit 174b2e9)

# Conflicts:
#	CHANGELOG.md
#	go.mod
#	go.sum
#	tests/systemtests/go.mod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants