I'm working with pool side mining software.
I noticed there is a race condition between obtaining bestblockhash and next block nbits. The chaintips may change.
I thought it might be useful to include bestblockhash in getmininginfo rpc response.
I'm working with pool side mining software.
I noticed there is a race condition between obtaining bestblockhash and next block nbits. The chaintips may change.
I thought it might be useful to include bestblockhash in getmininginfo rpc response.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--006a51241073e994b41acfe9ec718e94-->
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/36081.
<!--021abf342d371248e50ceaed478a90ca-->
See the guideline and AI policy for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | Sjors |
| Concept ACK | pablomartin4btc |
If your review is incorrectly listed, please copy-paste <code><!--meta-tag:bot-skip--></code> into the comment that the bot should ignore.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
Concept ACK
We use the tip hash in a few other places to deal with race conditions, e.g. waitfornewblock takes the current tip as an argument.
utACK 6522d443e8d0326552ac89550313578dbb3bd208 if CI passes
CI needs a maintainer to approve the workflow run, I believe.
minor nit (if you have to retouch): the release notes filename doesn't follow the naming convention — every other file under doc/ is release-notes-<PR#>.md (so it would be release-notes-36081.md here).
ok, good point. I renamed the file.
453 | @@ -454,6 +454,7 @@ static RPCMethod getmininginfo() 454 | RPCResult::Type::OBJ, "", "", 455 | { 456 | {RPCResult::Type::NUM, "blocks", "The current block"}, 457 | + {RPCResult::Type::STR_HEX, "bestblockhash", "The hash of the current best block"},
On src/rpc/mining.cpp:457: getblockchaininfo's bestblockhash is declared RPCResult::Type::STR, while this one is STR_HEX, which I think is more correct (matches how other hash fields in this file are typed), but worth noting the two now don't match for a field with the same name and meaning.
STR_HEX indeed seems better. It might be ok to add refactor commit to switch getblockchaininfo over.
Concept ACK, and utACK at 6522d443e8d0326552ac89550313578dbb3bd208 on the mechanism — nice fix.
Left a couple of comments (none blocker).
Mining software building a block template from getmininginfo's `next`
object (next height, nBits, target) also needs the hash of the tip that
`next` was derived from. Today that requires a second call
(getblockchaininfo or getbestblockhash), which can race with a tip
change - notably a same-height reorg at a retarget boundary, where the
two competing tips imply different next nBits.
Return the tip hash from getmininginfo itself so all values come from
the same tip under a single cs_main lock.
<!--85328a0da195eb286784d51f73fa0af9-->
🚧 At least one of the CI tasks failed.
<sub>Task Windows native, fuzz, VS: https://github.com/bitcoin/bitcoin/actions/runs/32946989507/job/98116580388</sub>
<sub>LLM reason (✨ experimental): CI failed because the fuzz target rpc crashed (exit code 3221225477, likely an access violation) during the fuzz corpus run.</sub>
<details><summary>Hints</summary>
Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
</details>
re-ACK 74e1cd38f2a381977b5e46fab6bb15ca17efd349 (just the release note file rename)