Skip to content

Conversation

@Cordtus
Copy link

@Cordtus Cordtus commented Dec 5, 2025

Description

Closes: #15463

This PR implements the EarliestVersion() method on the MultiStore interface to enable querying the earliest available state height. This addresses the longstanding TODO in the Status gRPC endpoint that was returning 0 for EarliestStoreHeight.

Problem

Indexers and tooling need to know which heights a pruned node can serve queries for. Currently:

  • earliest_block_height in Tendermint's STATUS RPC returns the earliest block, not the earliest state
  • The EarliestStoreHeight field in cosmos.base.node.v1beta1.Status was hardcoded to 0

Solution

  • Add EarliestVersion() int64 to the MultiStore interface
  • Implement persistent tracking in rootmulti.Store:
    • Stores earliest version at s/earliest key
    • Defaults to 1 for unpruned chains
    • Updates after successful pruning in PruneStores()
  • Add panic implementation in cachemulti.Store (consistent with LatestVersion())
  • Update Status gRPC endpoint to return the actual earliest store height

Changes

File Change
store/types/store.go Add EarliestVersion() to MultiStore interface
store/rootmulti/store.go Implement EarliestVersion(), GetEarliestVersion(), flushEarliestVersion()
store/cachemulti/store.go Add panic implementation
client/grpc/node/service.go Use EarliestVersion() instead of hardcoded 0
store/rootmulti/store_test.go Add 3 unit tests

Testing

  • TestEarliestVersion - basic functionality, default value
  • TestEarliestVersionWithPruning - tracks updates after pruning
  • TestEarliestVersionPersistence - persists across restarts
=== RUN   TestEarliestVersion
--- PASS: TestEarliestVersion (0.00s)
=== RUN   TestEarliestVersionWithPruning
--- PASS: TestEarliestVersionWithPruning (0.00s)
=== RUN   TestEarliestVersionPersistence
--- PASS: TestEarliestVersionPersistence (0.00s)

API Changes

This is a breaking change for any code implementing the MultiStore interface - they must now implement EarliestVersion() int64.

@fmorency
Copy link
Contributor

fmorency commented Dec 5, 2025

Would love to get this backported to 0.50.x. It would enable fixing manifest-network/yaci#28

@aljo242
Copy link
Contributor

aljo242 commented Dec 8, 2025

This seems like a nice feature but will need more extensive testing such as using systemtest if we are going to include

Add EarliestVersion() method to MultiStore interface to enable querying
the earliest available state height. This is essential for indexers and
tooling that need to know which heights a pruned node can serve.

Changes:
- Add EarliestVersion() to MultiStore interface
- Implement in rootmulti.Store with persistent storage
- Track earliest version after pruning in PruneStores()
- Add panic impl in cachemulti.Store (matches LatestVersion)
- Update Status gRPC endpoint to return actual EarliestStoreHeight
- Add unit tests for EarliestVersion functionality

Closes: cosmos#15463
The gRPC query context provides a CacheMultiStore which panics on
EarliestVersion(). Fix by passing the root CommitMultiStore directly
to the node service and using it for the EarliestStoreHeight field.
Needed for EarliestVersion implementation in the store module.
Tests earliest_store_height field in the node.Status gRPC endpoint:
- Basic test verifies valid heights are returned
- Stability test confirms earliest height remains stable on unpruned chain
- Pruning test verifies earliest_store_height increases after state pruning
@Cordtus Cordtus force-pushed the fix/earliest-store-height-upstream branch from e7384c5 to eaa696a Compare December 10, 2025 20:22
@Cordtus
Copy link
Author

Cordtus commented Dec 10, 2025

Added systemtest for the node.Status gRPC endpoint:

  • Basic test confirms valid heights are returned
  • Pruning test configures aggressive state pruning and confirms earliest_store_height increases afterward

Also updated the service to use CommitMultiStore directly since query context provides a CacheMultiStore which doesn't support version queries.

Run locally:

make build && cp build/simd tests/systemtests/binaries/
cd tests/systemtests && go test -tags system_test -v -run TestNodeStatus

@Cordtus Cordtus changed the title feat(store): implement EarliestVersion for MultiStore fix(grpc): return actual earliest_store_height in node.Status endpoint Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make query to find what states a given node exposes

3 participants