Skip to content

fix(stratum_v1): reset the job-gap watchdog only on usable jobs - #126

Open
Jolah1 wants to merge 2 commits into
256foundation:mainfrom
Jolah1:fix-job-gap-unconvertible-jobs
Open

Jolah1 wants to merge 2 commits into
256foundation:mainfrom
Jolah1:fix-job-gap-unconvertible-jobs

Conversation

@Jolah1

@Jolah1 Jolah1 commented Oct 14, 2026 •

Copy link
Copy Markdown

Part of #113.

The job-gap watchdog resets on every mining.notify, even when the job fails conversion and never reaches the scheduler. So a pool that only sends unusable jobs keeps the connection open forever with no work.

This resets the gap only when a job converts, so that connection gets recycled after MAX_JOB_GAP, the same as a silent pool. It doesn't do the latching part of #113.

The first commit adds a regression test (marked should_panic), the second fixes it. The test works like fresh_job_defers_recycling: one job three quarters of the way to the deadline, but with version 20002000, which sets general-purpose bits and fails conversion. It then expects ClearJobs after the original deadline.

Tested with just checks on each commit, and by running the daemon against a small test pool that only sends unusable jobs: without the fix it never reconnects, with it, it reconnects every 2 min.

@rkuester rkuester left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch. The fix is right, but the test uses the wrong kind of error.

The extranonce2 size is fixed per connection by mining.subscribe. Under #113, a bad size should fail the session at subscribe, so it will never reach the job-gap watchdog. The case this PR really fixes is a bad job on an otherwise good connection. One such job already exists. A job whose version has any of bits 13--28 set fails conversion.

Please:

  1. Test with a bad version, such as 20002000, the way fresh_job_defers_recycling tests a good one: one job at three quarters of the gap, then expect ClearJobs after the original deadline. That needs no second connection and no change to the handshake helpers.
  2. Reword the description and commit messages to match.
  3. Rebase onto main.

Jolah1 and others added 2 commits November 9, 2026 13:06
…cling

Add a test that sends one job three quarters of the way through the
job gap, with a version that sets general-purpose bits, so the job
fails conversion and never reaches the scheduler. Past the original
deadline, the test expects the source to have recycled the
connection, as it would with no job at all.

The job-gap watchdog restarts on every mining.notify, including one
that fails conversion, so the connection survives. Mark the test
should_panic until the fix lands.

Part of 256foundation#113.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Restart the job gap only when a job converts and reaches the
scheduler. A job that fails conversion, such as one whose version sets
general-purpose bits, gives the scheduler nothing to work on, so it
should not keep the connection alive. A pool that sends only such
jobs now has its connection recycled after MAX_JOB_GAP, as a silent
pool does.

Part of 256foundation#113.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Jolah1
Jolah1 force-pushed the fix-job-gap-unconvertible-jobs branch from 336ac98 to a284138 Compare November 9, 2026 12:11
@Jolah1

Jolah1 commented Nov 9, 2026

Copy link
Copy Markdown
Author

Thanks, that makes sense. The test now sends one job with version 20002000 at three quarters of the gap and expects ClearJobs after the original deadline, like fresh_job_defers_recycling, and the handshake helper changes are gone. I also reworded the commits and description, and rebased onto main.

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.

2 participants