Repository navigation
fix(light,statesync): format light-provider height errors and document chunk-ID integrity - #1358
Conversation
…t chunk-ID integrity - light/provider/http: validatorSet() was formatting height (*int64) with %d, printing the pointer address instead of the value; add fmtHeight() helper and use %s in all three ErrBadLightBlock messages (LOW severity) - internal/statesync: add SEC-016 accept-risk doc comment on chunkQueue.Add documenting that chunk-ID integrity is delegated to the ABCI app and the post-restore app-hash check against the trusted light block (LOW severity) Co-authored-by: Lukasz Klimek <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
✅ Review complete (commit 738706d) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Tightly scoped PR with two safe changes: a fmtHeight helper fixing %d-on-*int64 bugs in three light-provider error messages, and a documentation-only comment on chunkQueue.Add describing the SEC-016 trust model. Both changes verified against the source — fmtHeight is correct (nil→"latest", else deref), and the chunk-integrity claim matches the actual flow (post-restore app-hash comparison in syncer.verifyApp). No blockers; one in-scope test-coverage suggestion from Codex.
🟡 1 suggestion(s)
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.
In `light/provider/http/http.go`:
- [SUGGESTION] light/provider/http/http.go:360-367: Add a test that locks in the fmtHeight fix
The whole point of this PR is to stop `%d` from formatting `*int64` as a pointer address, but there is no test exercising `fmtHeight` or asserting on the resulting `ErrBadLightBlock.Reason` string. A future refactor could silently reintroduce `%d`/pointer formatting and existing tests would still pass. A small table-driven test on `fmtHeight` covering nil and a concrete height — or an assertion on one of the three affected error strings — would lock the fix in.
| // fmtHeight formats a nullable height pointer for use in error messages. | ||
| // A nil pointer means "latest" (height was not specified by the caller). | ||
| func fmtHeight(h *int64) string { | ||
| if h == nil { | ||
| return "latest" | ||
| } | ||
| return fmt.Sprintf("%d", *h) | ||
| } |
There was a problem hiding this comment.
🟡 Suggestion: Add a test that locks in the fmtHeight fix
The whole point of this PR is to stop %d from formatting *int64 as a pointer address, but there is no test exercising fmtHeight or asserting on the resulting ErrBadLightBlock.Reason string. A future refactor could silently reintroduce %d/pointer formatting and existing tests would still pass. A small table-driven test on fmtHeight covering nil and a concrete height — or an assertion on one of the three affected error strings — would lock the fix in.
source: ['codex']
There was a problem hiding this comment.
Pull request overview
This PR applies two low-severity production-facing improvements: it fixes incorrect block-height formatting in light-provider error messages (previously printing a pointer address), and it documents the intended integrity boundary for state-sync chunk handling.
Changes:
- Fix
light/provider/httperror messages to render*int64heights correctly via a smallfmtHeight(*int64) stringhelper (nil→"latest"). - Add a doc comment to
chunkQueue.Addclarifying that chunk IDs/content are not cryptographically verified at the queue layer, and where end-to-end integrity is enforced instead.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
light/provider/http/http.go |
Replaces %d formatting of a *int64 height with %s + fmtHeight(height) to avoid printing pointer addresses in ErrBadLightBlock reasons. |
internal/statesync/chunks.go |
Documents the integrity assumptions/guarantees for chunk handling at the chunkQueue.Add boundary (documentation-only). |
Summary
Two low-severity production fixes, no logic changes:
Fix 1 (LOW) —
light/provider/http:validatorSet()formattedheight(a*int64) with%d, which printed the pointer's decimal memory address (e.g.824636669952) instead of the actual block height. Added afmtHeight(*int64) stringhelper and replaced%d+heightwith%s+fmtHeight(height)in all threeErrBadLightBlockerror messages ('validator set is empty', 'total number of vals is <= 0', 'missing threshold public key or quorum hash').Fix 2 (LOW / SEC-016 accept-risk) —
internal/statesync/chunks.go: added a concise doc comment onchunkQueue.Addrecording that individual chunk IDs and content are not cryptographically verified at this layer — integrity is delegated to (a) the ABCI application that reassembles/applies the snapshot, and (b) the post-restore app-hash comparison against the trusted light block. Documentation-only; zero logic change.Test plan
go build ./light/... ./internal/statesync/...— cleangofmt -w -s— no formatting changes neededgolangci-lint runon both packages — all findings are pre-existing in untouched filesgo test ./light/provider/http/... ./internal/statesync/...fails to link in this environment due to missing native BLS library (-lmimalloc-secure); unrelated to these changes — same failure on base branch🤖 Generated with Claude Code