contrib: support injecting custom txs to signet miner#111
contrib: support injecting custom txs to signet miner#111ajtowns wants to merge 3 commits intobitcoin-inquisition:29.xfrom
Conversation
Co-Authored-By: Anthony Towns <aj@erisian.com.au>
|
cc @theStack |
Co-Authored-By: Anthony Towns <aj@erisian.com.au>
27a4e73 to
f222707
Compare
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsNo conflicts as of last run. |
|
Concept ACK, makes sense to have a more flexible solution. Thanks for mining the block! |
| # can't easily calculate fees to collect, so just burn them | ||
| tmpl["coinbasevalue"] = int(50_0000_0000 >> (tmpl["height"] // 210000)) |
There was a problem hiding this comment.
I was about to suggest calculating the fees with repeated gettxout RPC calls with all the inputs' prevout fields passed each, but that's probably very slow for larger blocks with many inputs and wouldn't work anyways, if UTXOs are spent that are created within the same block... seems fine to burn anyways, I guess.
There was a problem hiding this comment.
Well the python code could detect the txouts that are created and spent in the same block, so that part would be fine, I think. Could maybe batch the gettxout RPC calls into a single request (or one request per X txouts) to be a little less slow?
…sult field 12c3c3f test: mining: add coverage for GBT's "coinbasevalue" result field (Sebastian Falbesoner) Pull request description: This PR adds missing coverage for the "coinbasevalue" result field of the `getblocktemplate` RPC call. Specifically, the introduced test checks that the value is set to claim the full block reward (subsidy plus fees). Can be verified with the following patch, which succeeds on master and fails on the PR branch: ```diff diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index a935810..ba9ac9dadb 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -998,7 +998,7 @@ static RPCHelpMan getblocktemplate() result.pushKV("previousblockhash", block.hashPrevBlock.GetHex()); result.pushKV("transactions", std::move(transactions)); result.pushKV("coinbaseaux", std::move(aux)); - result.pushKV("coinbasevalue", block.vtx[0]->vout[0].nValue); + result.pushKV("coinbasevalue", block.vtx[0]->vout[0].nValue - 1); result.pushKV("longpollid", tip.GetHex() + ToString(nTransactionsUpdatedLast)); result.pushKV("target", hashTarget.GetHex()); result.pushKV("mintime", GetMinimumTime(pindexPrev, consensusParams.DifficultyAdjustmentInterval())); ``` I'm not sure how relevant this field is nowadays in real-world mining scenarios (we use it for the signet miner at least), but it seems useful to have a test for it anyways. Stumbled upon this while looking at bitcoin-inquisition#111. ACKs for top commit: maflcko: lgtm ACK 12c3c3f Sjors: ACK 12c3c3f Tree-SHA512: ae10f63c99b21cf7771feefe3d0e47b2e0d511aceb344cf11efa9182d78f2960f1e079797b8a36db110a3c54acb27a3706413a710a74bf56aed29ea162a6aab2
Adds
--custom-block-dirto signet miner, which allows specifying a directory containing files12345.json(ie, block-height-dot-json). Those json files can specify a json object of{"txs": [txhex,txhex,...]}which will result in the miner attempting to build a block that only contains the given txs, and burns all their fees (only claiming the block subsidy). The block will be verified viagetblocktemplatein proposal mode before signing or applying proof of work, and falls back to attempting a regular block if that fails. In future the json file could potentially add additional fields to control coinbase values or header fields. Replaces #107. Tested on block 297073.