Skip to content

hashlog cli#3676

Open
cody-littley wants to merge 2 commits into
mainfrom
cjl/hashlog-cli
Open

hashlog cli#3676
cody-littley wants to merge 2 commits into
mainfrom
cjl/hashlog-cli

Conversation

@cody-littley

Copy link
Copy Markdown
Contributor

Describe your changes and provide context

CLI tooling for reading hashlog archives.

Testing performed to validate your change

Unit tests, hand tests

@cursor

cursor Bot commented Jun 30, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Read-only CLI and formatting around existing sc/hashlog readers; no changes to chain state or hash recording.

Overview
Adds a seidb hashlog command group so operators can inspect on-disk hashlogger archives without custom Go code.

get-block loads a block’s hash records via hashlog.ReadHashForBlock and prints them as text or --json, including multiple records when a block was re-executed after rollback and <none> for missing hash types.

compare diffs two archives with CompareHashes or --low/--high (both required), optional --max-diffs with a truncation warning, default compact output (only differing hash columns), and --full when record counts differ. JSON output follows the same compact/full rules.

Unit tests cover renderers and an end-to-end path through the public hashlogger writer and reader APIs.

Reviewed by Cursor Bugbot for commit ed399c8. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJun 30, 2026, 8:28 PM

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ed399c8. Configure here.

}
if len(result.diffs) == 0 {
ew.printf("Archives are identical over the compared range.\n")
return ew.err

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False identical message max-diffs zero

Medium Severity

When compare runs with --max-diffs=0, CompareHashes can return no pairs even if the archives differ, because the reader stops before recording the first difference. Text output still prints that the archives are identical over the compared range, which can hide a real mismatch.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ed399c8. Configure here.

@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.11628% with 75 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.01%. Comparing base (3e420fa) to head (ed399c8).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
sei-db/tools/cmd/seidb/operations/hashlog.go 65.72% 71 Missing and 2 partials ⚠️
sei-db/tools/cmd/seidb/main.go 0.00% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3676      +/-   ##
==========================================
- Coverage   58.97%   58.01%   -0.96%     
==========================================
  Files        2266     2180      -86     
  Lines      187181   177628    -9553     
==========================================
- Hits       110390   103057    -7333     
+ Misses      66852    65433    -1419     
+ Partials     9939     9138     -801     
Flag Coverage Δ
sei-chain-pr 28.52% <65.11%> (?)
sei-db 70.41% <ø> (ø)
sei-db-state-db ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sei-db/tools/cmd/seidb/main.go 0.00% <0.00%> (ø)
sei-db/tools/cmd/seidb/operations/hashlog.go 65.72% <65.72%> (ø)

... and 87 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@seidroid seidroid Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A well-tested, read-only CLI for inspecting hashlog archives. One edge-case correctness issue: --max-diffs=0 causes divergent archives to be falsely reported as identical. Cursor's review produced no output.

Findings: 0 blocking | 3 non-blocking | 1 posted inline

Blockers

  • None at the file/PR level.

Non-blocking

  • Cursor's second-opinion review file (cursor-review.md) was empty — that pass produced no output.
  • Negative --max-diffs values other than -1 (e.g. -5) are silently treated as "all diffs" and never trigger the truncation warning. Consider validating the flag to accept only -1 or non-negative values.
  • 1 suggestion(s)/nit(s) flagged inline on specific lines.

}
cmd.PersistentFlags().Uint64("low", 0, "Lowest block to compare (inclusive); requires --high")
cmd.PersistentFlags().Uint64("high", 0, "Highest block to compare (inclusive); requires --low")
cmd.PersistentFlags().Int("max-diffs", -1, "Maximum number of differing blocks to report, or -1 for all")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[suggestion] --max-diffs=0 produces misleading output for divergent archives. In compareBlockRange the cap is checked as len(diffs) >= maxDiffCount (hash_log_reader.go:338) before appending, so with maxDiffCount=0 the loop breaks at the first differing block and returns an empty slice. renderCompare then sees len(diffs) == 0 and prints "Archives are identical over the compared range." — a false negative for a tool whose entire purpose is detecting divergence. Reject 0 (and other invalid negatives) here, or distinguish "no diffs found" from "capped at 0" in renderCompare so an empty result is never reported as proof of identity.

@cody-littley cody-littley requested a review from yzang2019 July 1, 2026 18:02
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.

1 participant