Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
Codecov Report❌ Patch coverage is ❌ Your patch check has failed because the patch coverage (61.4%) is below the target coverage (90.0%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #572 +/- ##
=========================================
+ Coverage 41.6% 41.9% +0.2%
=========================================
Files 172 172
Lines 17499 17760 +261
=========================================
+ Hits 7296 7458 +162
- Misses 9124 9181 +57
- Partials 1079 1121 +42
... and 3 files with indirect coverage changes
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces deterministic, height-pinned state sync querying for the clerk module by adding visibility-based indexing (time/height) and new query endpoints that Bor can use to derive deterministic results from the latest Heimdall state.
Changes:
- Add visibility-time/visibility-height tracking with a one-block delay (pending list processed in
PreBlocker) to make state-sync queries deterministic across halts. - Add new gRPC/REST query methods:
GetBlockHeightByTimeandGetRecordListVisibleAtHeight, plus protobuf + swagger/gateway wiring. - Add extensive keeper/query tests covering legacy/hybrid/post-upgrade behavior, pending-event exclusion, and block-time cutoff lookup.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| x/clerk/types/query.pb.gw.go | Adds grpc-gateway HTTP handlers for the two new query endpoints. |
| x/clerk/types/query.pb.go | Adds generated proto types + client/server interfaces for new queries. |
| x/clerk/types/keys.go | Introduces new KV prefixes for visibility and block-time indexes. |
| x/clerk/keeper/visibility_time_test.go | Adds comprehensive tests for visibility-time/height lifecycle and deterministic querying. |
| x/clerk/keeper/side_msg_server.go | Adds post-handler logic to enqueue events for delayed visibility assignment and sets upgrade boundary. |
| x/clerk/keeper/keeper.go | Implements pending processing, visibility indexes, block-time indexing, and cutoff height lookup. |
| x/clerk/keeper/grpc_query.go | Updates GetRecordListWithTime hybrid filtering and adds two new query RPC implementations. |
| proto/heimdallv2/clerk/query.proto | Defines new RPCs and request/response messages. |
| helper/config.go | Adds an activation-height gate for the visibility-time feature. |
| client/docs/swagger-ui/swagger.yaml | Documents the new REST endpoints and response types. |
| app/abci.go | Runs pending visibility processing + block-time indexing in PreBlocker when enabled. |
| api/heimdallv2/clerk/query_grpc.pb.go | Updates generated gRPC bindings with the new methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@claude review |
|
Claude finished @marcello33's task in 2m 27s —— View job Code Review: Deterministic State Syncs
SummaryThis PR introduces deterministic, height-pinned state sync querying for the clerk module. The core idea is sound: events get a one-block-delayed Overall the architecture is well-designed. Below are the issues I found, categorized by severity. CRITICAL / HIGH Issues1.
|
Code ReviewFound 2 issues. Checked for bugs and CLAUDE.md compliance. Issue 1: fmt.Printf with %w verb in GetBlockHeightByTime Issue 2: GetVisibilityTimeUpgradeID error conflates not-found with storage errors |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@claude addressed your comments. Here's a recap:
Not addressing the following:
Re-review the changes. |
|
Claude finished @marcello33's task in 2m 37s —— View job Re-review: Deterministic State Syncs
Verification of FixesAll six addressed items look correct:
Items not addressed (acknowledged, acceptable)
Remaining Issues1.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@claude addressed your comments. Please re-review and solve the related comments if they are addressed |
|
Claude finished @marcello33's task in 2m 0s —— View job Re-review: Deterministic State Syncs
Verification of Previously Flagged FixesAll previously flagged issues have been properly addressed:
Items Not Addressed (Acknowledged, Acceptable)
Remaining Observations1.
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 23 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review1 issue found. Checked for bugs and CLAUDE.md compliance. Issue: Personal TODO comments in production code File: helper/config.go lines 490 and 510 The comment Suggested fix: Remove the TODO comments or replace with: |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 23 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.
Code ReviewFound 4 issues. Checked for bugs and CLAUDE.md compliance. Issue 1 (compile error): Issue 2 (consensus-critical): Issue 3 (state loss): Issue 4 (DoS): See inline comments for details. |
|
@claude checked your comments here
|
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 23 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.
|



Description
Implements deterministic, height-pinned state sync querying for the clerk module.
Events get a one-block-delayed
visibility_timeandvisibility_heightassigned inPreBlocker, so that during Heimdall halts, pending events stay excluded and all validators derive identical query results. A combined gRPC/REST endpoint allows Bor/Erigon to fetch deterministic state syncs in a single call.Changes
visibility_time = blockTime(H+1)viaProcessPendingVisibilityEventsin PreBlocker. During halts, no new blocks arrive, so pending events stay invisible.-
GetBlockHeightByTime(/clerk/block-height-by-time): resolvescutoff_time→ greatest committed Heimdall height via binary search on reverse index.-
GetRecordListVisibleAtHeight(/clerk/state-syncs-at-height): fetches events visible at a specific height using immutablevisibility_heightindexes-
GetStateSyncsByTime(/clerk/state-syncs-by-time): combined endpoint used by Bor/Erigon — resolves height fromto_timeinternally and returns events in a single call. Includes a stability gate that returns empty iflatestBlockTime <= cutoff, ensuring the resolved height is frozen before returning resultslatestBlockTime > cutoff, the resolved height is frozen — no new blocks can havetime <= cutoff(monotonically increasing), and no new events can havevisibility_height <= resolved_heightVisibilityTimeByID,VisibilityHeightByID,BlockTimeReverseIndexGenesisStaterecordClerkQueryMetricvisibilityTimeHeightinhelper/config.go(0 = disabled for all networks, set per-network when HF is scheduled)Activation
visibilityTimeHeight:0(disabled) on all networksChanges
Breaking changes
HF needed.
Checklist
Cross-repository changes
Testing
Manual tests
Tested on kurtosis devnets with chaos testing (2-vs-2 network partition) and self-heal recovery. Many rounds of chaos, zero errors across all 7 nodes (4 bor vals + 3 erigon rpc).