8000 Fix custom mining job chain-tip transitions by 0xjc65eth · Pull Request #2164 · stratum-mining/stratum · GitHub
[go: up one dir, main page]

Skip to content

Fix custom mining job chain-tip transitions - #2164

Merged
plebhash merged 1 commit into
stratum-mining:mainfrom
0xjc65eth:fix-custom-job-chain-tip
Jun 1, 2026
Merged

plebhash merged 1 commit into
stratum-mining:mainfrom
0xjc65eth:fix-custom-job-chain-tip

Conversation

@0xjc65eth
Copy link
Copy Markdown
Contributor

Summary

Fixes ExtendedChannel::on_set_custom_mining_job so a custom mining job that moves the channel to a new chain tip transitions the previous active job into the stale set, flushes seen shares, and clears obsolete job-target mappings before registering the new active job.

The change is intentionally scoped to actual chain-tip transitions. If a custom job arrives for the same tip, the previous behavior of keeping the old job as a past job is preserved.

Closes #2157.

Why

on_set_new_prev_hash already performs this cleanup when the tip changes, but custom-work/JD flows can move the tip through SetCustomMiningJob instead. Without the cleanup, late shares for the previous block can be evaluated against the new chain tip and reported with the wrong validation error, while old job state continues to accumulate.

Testing

  • cargo fmt --check
  • git diff --check
  • cargo test -p channels_sv2 --lib test_set_custom_mining_job_chain_tip_change_marks_past_job_stale
  • cargo test -p channels_sv2 --lib

Seek the stale path; leave no ghost jobs behind.

@plebhash
plebhash force-pushed the fix-custom-job-chain-tip branch from b9efcc6 to 2b21472 Compare June 1, 2026 19:51
@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.

LGTM

force-pushing with:

  • extra test_set_custom_mining_job_same_chain_tip_keeps_past_job unit test, which is a variation of test_set_custom_mining_job_chain_tip_change_marks_past_job_stale but for the case where chain tip didn't change (amended into the original commit)
  • rebase against main

@plebhash
plebhash merged commit a208ffb into stratum-mining:main Jun 1, 2026
14 checks passed
@0xjc65eth
Copy link
Copy Markdown
Contributor Author

Thanks for the review, extra regression coverage, and merge @plebhash. Glad to get this path cleaned up.

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.

ExtendedChannel::on_set_custom_mining_job does not transition past-job state on chain tip change

2 participants

0