consensus/bor, internal/cli: full grpc implementation #2194
Claude / Claude Code Review
completed
Apr 23, 2026 in 17m 19s
Code review found 1 important issue
Found 6 candidates, confirmed 2. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 1 |
| 🟡 Nit | 1 |
| 🟣 Pre-existing | 0 |
| Severity | File:Line | Issue |
|---|---|---|
| 🔴 Important | internal/cli/server/api_service.go:178-201 |
GetBlockInfoInBatch uint64 overflow: loop wraps past MaxUint64 |
| 🟡 Nit | internal/cli/server/api_service.go:234-257 |
fetchBlockInfo: Author is nil (not zero-valued) for genesis, diverges from GetAuthor |
Annotations
Check failure on line 201 in internal/cli/server/api_service.go
claude / Claude Code Review
GetBlockInfoInBatch uint64 overflow: loop wraps past MaxUint64
`GetBlockInfoInBatch` has a uint64 overflow: the size gate `End-Start >= 256` accepts near-MaxUint64 ranges (e.g. Start=MaxUint64-3, End=MaxUint64 passes with diff=3), then the loop `for i := Start; i <= End; i++` wraps after i=MaxUint64 (i++ → 0) and begins walking the chain from genesis, calling `HeaderByNumber`+`GetTd`+`Author(ecrecover)` per block and growing `out.Blocks` unboundedly. Fix by rejecting `EndBlockNumber == math.MaxUint64` or by iterating with a bounded counter (e.g. `for n := 0
Check warning on line 257 in internal/cli/server/api_service.go
claude / Claude Code Review
fetchBlockInfo: Author is nil (not zero-valued) for genesis, diverges from GetAuthor
The comment on `fetchBlockInfo` says "Author is left zero-valued for genesis (matching bor_getAuthor behavior)", but neither half is accurate: the code leaves `info.Author` as a nil `*H160` (not a pointer to a zero-valued H160), and `GetAuthor` actually returns an *error* for genesis (Bor's `Author()` delegates to `ecrecover` on an all-zero seal, which fails). Suggest either setting `info.Author = protoutil.ConvertAddressToH160(common.Address{})` for `blockNum == 0` to make the code match the co
Loading