Skip to content

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

Open
rx18-eng wants to merge 2 commits into
stratum-mining:mainfrom
rx18-eng:fix/validate-share-panic-after-snph
Open

fix validate_share panic after on_set_new_prev_hash in custom-work mode#2156
rx18-eng wants to merge 2 commits into
stratum-mining:mainfrom
rx18-eng:fix/validate-share-panic-after-snph

Conversation

@rx18-eng
Copy link
Copy Markdown

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
Author

@plebhash would appreciate a review from you !

@plebhash plebhash self-requested a review May 14, 2026 18:04
rx18-eng added 2 commits May 14, 2026 23:43
Signed-off-by: rx18-eng <remopanda78@gmail.com>
Signed-off-by: rx18-eng <remopanda78@gmail.com>
@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
Author

I fixed the failing semver check !

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

1 participant