fix(miner): preserve valid work across mempool updates#226
Conversation
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_bbade51b-4efd-4e11-b5d6-0b7c605daab6) |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_36664d42-594a-46e9-bd0b-a9519409e4ec) |
evan-forbes
left a comment
There was a problem hiding this comment.
personally I found the title a bit confusing, but generally agree that mempool churn shouldn't have a an impact on restarting or sleeping the template
|
@codex fix changelog |
|
To use Codex here, create an environment for this repo. |
|
@codex fix changelog |
…internal-miner-work # Conflicts: # CHANGELOG.md
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_8e05f53d-abd0-4aab-b6ea-dbedf9bf5c67) |
Motivation
The internal miner cancelled active Equihash solver work whenever a long-poll
block template produced a different header. Mempool-only template updates change
the transaction roots in the header, but the old block remains potentially valid
because newly received transactions do not have to be included.
An accepted transaction stream could therefore make the optional internal miner
repeatedly restart useful work even though
getblocktemplatereturnedsubmitold: true.Solution
Use the template's
submitolddecision when publishing work to the internalsolver. Keep mining the current template when a changed template explicitly says
old work remains valid, and replace it when the response invalidates old work or
does not provide a reuse decision.
Identical headers remain suppressed as before. External RPC miners are unchanged;
they continue to receive the full
getblocktemplateresponse.Add focused coverage for initial publication, identical headers, reusable
mempool-only updates, invalidating updates, and missing
submitoldvalues. Updatethe operator changelog.
Testing
cargo test -p zakura --features internal-miner mining_template_updates_respect_submit_oldcargo clippy -p zakura --features internal-miner --lib -- -D warningscargo fmt --all -- --checkgit diff --checkSpecifications & References
Note
Low Risk
Scoped to optional internal-miner template publishing; aligns with BIP 22 long-poll semantics and does not change RPC miners or consensus.
Overview
The internal miner no longer restarts Equihash work on every long-poll template whose header differs.
generate_block_templatesnow readssubmit_oldfrom the RPC template and only pushes a new block to solvers whenshould_replace_mining_templatesays prior work is invalid—unchanged headers are still ignored, andsubmitold: true(typical mempool-only updates) keeps the current template so solvers are not cancelled.Logging distinguishes a real template swap from keeping work (debug when work is preserved). A unit test covers initial publish, identical headers, reusable mempool updates, invalidating updates, and missing
submit_old. The unreleased changelog records the fix. External RPC miners are unchanged.Reviewed by Cursor Bugbot for commit 66a418e. Bugbot is set up for automated code reviews on this repo. Configure here.