Skip to content

Fix custom mining job chain-tip transitions#2164

Open
0xjc65eth wants to merge 1 commit into
stratum-mining:mainfrom
0xjc65eth:fix-custom-job-chain-tip
Open

Fix custom mining job chain-tip transitions#2164
0xjc65eth wants to merge 1 commit into
stratum-mining:mainfrom
0xjc65eth:fix-custom-job-chain-tip

Conversation

@0xjc65eth
Copy link
Copy Markdown

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.

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

1 participant