getmininginfo's currentblockweight field is not accurate. getblock on the latest mined block shows a different weight. This corrects that behaviour by storing the actual serialized weight instead of an estimate.
mining: Fix getmininginfo currentblockweight inaccuracy #17790
pull andrewtoth wants to merge 2 commits into bitcoin:master from andrewtoth:getmininginfo-weight changing 2 files +7 −4-
andrewtoth commented at 8:29 PM on December 22, 2019: contributor
- fanquake added the label Mining on Dec 22, 2019
-
in src/miner.cpp:150 in 4f6c231d6d outdated
146 | @@ -148,12 +147,14 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc 147 | coinbaseTx.vout.resize(1); 148 | coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn; 149 | coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus()); 150 | - coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0; 151 | + coinbaseTx.vin[0].scriptSig = CScript() << nHeight << CScriptNum(1);
andrewtoth commented at 8:31 PM on December 22, 2019:The extraNonce is incremented before any block is generated, which adds 4 to the block weight. This adds an extraNonce of 1 here so that the following
GetBlockWeightcalculation is accurate and not 4 less.andrewtoth renamed this:Fix getmininginfo currentblockweight inaccuracy
mining: Fix getmininginfo currentblockweight inaccuracy
on Dec 22, 2019DrahtBot commented at 11:13 PM on December 22, 2019: contributor<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #17693 (rpc: Add generateblock to mine a custom set of transactions by andrewtoth)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
Fix getmininginfo currentblockweight inaccuracy 248908cf10Fix getmininginfo currentblockweight test 1b177fef0fandrewtoth force-pushed on Dec 27, 2019luke-jr commented at 7:23 PM on January 3, 2020: memberThe client/miner decides the generated outputs, so it can't be accurate...
andrewtoth commented at 4:54 PM on January 5, 2020: contributor@luke-jr I see, thanks. Perhaps this should be documented in the help text then, that this field is only an estimate? At least with this patch it would be accurate for blocks created with
generatetoaddress. I doubt that's worth it though, so closing.andrewtoth closed this on Jan 5, 2020bitcoin locked this on Feb 15, 2022andrewtoth deleted the branch on Aug 17, 2023ContributorsLabels
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 12:14 UTC
More mirrored repositories can be found on mirror.b10c.me