Skip to content

fix: read governance debug log tail in binary mode#7295

Merged
PastaPastaPasta merged 1 commit into
dashpay:developfrom
thepastaclaw:fix/governance-log-seek-mode
May 1, 2026
Merged

fix: read governance debug log tail in binary mode#7295
PastaPastaPasta merged 1 commit into
dashpay:developfrom
thepastaclaw:fix/governance-log-seek-mode

Conversation

@thepastaclaw
Copy link
Copy Markdown

Summary

  • fix feature_governance_cl.py log tail polling to seek debug.log
    in binary mode
  • decode the tailed bytes after reading so the seek offset stays valid
    for the stream mode
  • preserve the existing behavior of scanning only the last 100 KiB for
    the expected governance tip message

Context

This is a follow-up for a valid review finding from merged PR #7258:
#7258 (comment)

Upstream develop currently opens debug.log in text mode but computes
the seek position with a binary offset. The final fix here uses a fully
binary tail read and decodes afterward, which avoids both mixed-mode seek
problems and text-stream offset arithmetic.

Validation

  • python3 -m py_compile test/functional/feature_governance_cl.py
  • pre-PR code review gate verdict: ship

I did not run feature_governance_cl.py end-to-end because this worktree
does not have built dashd/test binaries available, and building Dash
Core would be disproportionate for this narrowly scoped Python
functional-test fix.

@thepastaclaw
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

✅ No Merge Conflicts Detected

This PR currently has no conflicts with other open PRs.

feature_governance_cl.py was opening debug.log in text mode but
seeking with a binary offset. The fully safe fix is to read the
tail in binary mode, seek using a binary offset, then decode the
resulting bytes afterward for the string match.

This preserves the existing 100 KiB tail scan while avoiding
invalid mixed-mode seek behavior in Python text I/O.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@thepastaclaw thepastaclaw force-pushed the fix/governance-log-seek-mode branch from 45d3b21 to 0293c6d Compare April 28, 2026 14:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8e51eb01-5841-4f07-b375-926cd6f514c5

📥 Commits

Reviewing files that changed from the base of the PR and between 45d3b21 and 0293c6d.

📒 Files selected for processing (1)
  • test/functional/feature_governance_cl.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/functional/feature_governance_cl.py

Walkthrough

The governance test's log-verification helper now opens the debug log in binary mode, seeks to the last 100 KiB, reads raw bytes, decodes them with UTF-8 using replacement for invalid sequences, and then searches the decoded string for the existing CGovernanceManager::UpdatedBlockTip -- nCachedBlockHeight: {tip_height} substring. The change adjusts how encoding/decoding errors are handled when scanning the log without altering the substring check or overall control flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: fixing the governance debug log tail reading to use binary mode instead of mixed text/binary mode.
Description check ✅ Passed The pull request description is fully related to the changeset, explaining the problem (mixed-mode seek issues), the solution (binary read with post-decode), and the context (follow-up to PR #7258).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Timed out fetching pipeline failures after 30000ms


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.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@thepastaclaw
Copy link
Copy Markdown
Author

thepastaclaw commented Apr 28, 2026

✅ Review complete (commit 0293c6d)

Copy link
Copy Markdown
Author

@thepastaclaw thepastaclaw left a comment

Choose a reason for hiding this comment

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

Code Review

I re-checked the diff directly and did not find a correctness issue to block this PR. The patch fixes the original mixed-mode seek bug by computing the tail offset and performing the seek in the same stream mode that is later read, and the helper rename to debug_log_size() makes the adjacent test-framework call sites explicit about that contract.

Reviewed commit: 0293c6d

@knst knst marked this pull request as ready for review April 30, 2026 07:48
Copy link
Copy Markdown
Collaborator

@knst knst left a comment

Choose a reason for hiding this comment

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

LGTM 0293c6d

p.s. CI succeed, I have no objections

@knst knst requested review from PastaPastaPasta and UdjinM6 April 30, 2026 07:52
@PastaPastaPasta PastaPastaPasta merged commit 4a0fd85 into dashpay:develop May 1, 2026
79 of 83 checks passed
@UdjinM6 UdjinM6 added this to the 24 milestone May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants