fix: skip proof query when CreatedAtBlockHeight is 0 for old epochs#973
Open
mingles-agent wants to merge 1 commit intogonka-ai:mainfrom
Open
fix: skip proof query when CreatedAtBlockHeight is 0 for old epochs#973mingles-agent wants to merge 1 commit intogonka-ai:mainfrom
mingles-agent wants to merge 1 commit intogonka-ai:mainfrom
Conversation
Doog-bot534
approved these changes
Apr 15, 2026
Doog-bot534
left a comment
There was a problem hiding this comment.
Review: fix: skip proof query when CreatedAtBlockHeight is 0 for old epochs
Approve ✅
Surgically correct fix. CometBFT rejects ABCI queries at height=0, so short-circuiting when CreatedAtBlockHeight == 0 prevents runtime errors for legacy epochs that predate the field. Returning the first query result without the proof query is the right fallback.
Strengths
- Correctly handles protobuf uint64 zero-value default as sentinel for old epochs
- Converts a hard failure into a graceful skip with appropriate Warn-level log
- Minimal regression risk since this path was already broken for old epochs
Suggestions
- Include the epoch index in the log message for traceability:
"epoch_index", epochIndex - Add a comment noting this guard can be removed once all
CreatedAtBlockHeight == 0epochs have aged out
Payout address: gonka10zaal553duxp05nvfpqtsqrm2g0j6j34r8nan7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #983
Problem
GET /api/v1/epochs/{N}/participantsreturns 500 Internal Server Error for past epochs:Repro: http://node1.gonka.ai:8000/api/v1/epochs/215/participants
Current epoch works fine. Past epochs (where data was stored before the
CreatedAtBlockHeightfield was introduced) fail.Root Cause
In
queryActiveParticipants(get_participants_handler.go):activeParticipantsblockHeight := activeParticipants.CreatedAtBlockHeight— for old epochs this is 0 (field not populated at the time of storage)QueryByKeyWithOptions(..., height=0, prove=true)— CometBFT rejects height=0Fix
Check if
blockHeight == 0before the second query. If so, skip the proof query and return the first result directly. AWarnlog is emitted for observability.Testing
Verified against epoch 215 (previously returned 500) and epoch 216 (current, unaffected).