Skip to content

fix validate_share panic after on_set_new_prev_hash in custom-work mode - #2156

Merged
plebhash merged 1 commit into
stratum-mining:mainfrom
rx18-eng:fix/validate-share-panic-after-snph
May 20, 2026
Merged

fix validate_share panic after on_set_new_prev_hash in custom-work mode#2156
plebhash merged 1 commit into
stratum-mining:mainfrom
rx18-eng:fix/validate-share-panic-after-snph

Conversation

@rx18-eng

Copy link
Copy Markdown
Contributor

Body

Closes #2155.

  • new JobStore::deactivate_job method that moves active_job into past_jobs
  • ExtendedChannel::on_set_new_prev_hash false arm now calls deactivate_job() before mark_past_jobs_as_stale(), so the old active goes through past then stale and late shares for it return Stale instead of panicking
  • StandardChannel::on_set_new_prev_hash reordered so job_id_to_target.clear() only runs after activate_future_job(...) returns true, so the error path can't corrupt state
  • both expect("job target must exist") sites in validate_share (extended.rs:675, standard.rs:597) replaced with ok_or(ShareValidationError::InvalidJobId)?

Two new tests

  • test_set_new_prev_hash_without_future_jobs_marks_active_as_stale in extended.rs reproduces the panic from the issue and asserts Err(Stale) after the fix
  • test_set_new_prev_hash_without_future_jobs_preserves_state in standard.rs confirms state survives the error and the next share validates without panic

Both tests fail with the original panic on unpatched code; full crate suite passes (74/74) after the fix.

@rx18-eng

Copy link
Copy Markdown
Contributor Author

@plebhash would appreciate a review from you !

@plebhash
plebhash self-requested a review May 14, 2026 18:04
@rx18-eng
rx18-eng force-pushed the fix/validate-share-panic-after-snph branch from eef2244 to 7ad4da2 Compare May 14, 2026 18:14
@rx18-eng

Copy link
Copy Markdown
Contributor Author

I fixed the failing semver check !

@rx18-eng

Copy link
Copy Markdown
Contributor Author

@plebhash shall i modify anything on this pr ?

Comment thread sv2/channels-sv2/src/server/extended.rs Outdated
Comment thread sv2/channels-sv2/src/server/extended.rs
Comment thread sv2/channels-sv2/src/server/extended.rs Outdated
@rx18-eng
rx18-eng requested a review from plebhash May 20, 2026 20:24

@plebhash plebhash left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rx18-eng you re-requested my review while not only ignoring the main suggestion, but also resolving it.

all that in less than a minute after I left my comments.

honestly I would prefer that you took the time to read and understand what the suggestions mean, instead of blindly clicking buttons on Github UI

with this current workflow, you're just closing your eyes and doing whatever you can to rush your PR getting merged, despite correctness or sanity of the contribution.

that's not a good way to make FOSS contributions.

@rx18-eng

rx18-eng commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

@plebhash you're right, I rushed. The first suggestion rendered as an empty code block in my view, so I read it as a no-op and clicked through the other two. I didn't go back to your "in other words: remove L561-L562" reply until after I'd already pushed and re-requested review. That's on me, I should have read every thread end to end first. I sincerely apologize for this !

@rx18-eng

Copy link
Copy Markdown
Contributor Author

Going back through it now, the point is clear: with the top-level clear at L561-L562 still in place, the arm-internal clears from suggestions 2 and 3 don't actually defend against the early-return on TemplateIdNotFound, because
job_id_to_target is already empty before activate_future_job even runs.

@plebhash

Copy link
Copy Markdown
Member

it seems you started your branch before #2151 had been merged, so please rebase against main and fix CI

also please squash all commits into one

@rx18-eng
rx18-eng force-pushed the fix/validate-share-panic-after-snph branch from e4bb180 to 3069d98 Compare May 20, 2026 21:46
Comment thread sv2/channels-sv2/src/server/jobs/job_store.rs Outdated
@rx18-eng
rx18-eng force-pushed the fix/validate-share-panic-after-snph branch from 3069d98 to aec69e6 Compare May 20, 2026 22:12
Co-authored-by: plebhash <147345153+plebhash@users.noreply.github.com>
Signed-off-by: rx18-eng <remopanda78@gmail.com>
@rx18-eng
rx18-eng force-pushed the fix/validate-share-panic-after-snph branch from aec69e6 to cc3977e Compare May 20, 2026 22:16
@plebhash
plebhash merged commit cb033a4 into stratum-mining:main May 20, 2026
14 checks passed
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.

validate_share panics after on_set_new_prev_hash in custom-work mode

2 participants