-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Calculate size and weight of block correctly in CreateNewBlock() #8838
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Log entries that change their format are really bad for tooling. Is there any reason why it's bad to log limits that are at their maximum because they're not being applied? |
The current code is not logging
That means that if size is not being accounted, CreateNewBlock always logs that a block of size 1000 (bytes) has been created. I don't think we should just change the log to output size = 1000000 if size isn't being accounted. I propose the following change:
|
Maybe @gmaxwell's concern can be addressed by logging 'total size ?' |
Alternatively, you can always just compute the total block size using ::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION). |
00daa67
to
5f274a1
Compare
Updated to always calculate size and weight correctly (whether or not size is being accounted). I'll update the description of this PR. |
utACK |
@laanwj - this PR fixes a bug where bitcoin logs incorrect sizes for new blocks. Is there anything I can do to help this get merged? |
…wBlock() 5f274a1 log block size and weight correctly. (jnewbery)
Backported in #9264, removing tag. |
Github-Pull: bitcoin#8838 Rebased-From: 5f274a1
bitcoind writes the following log when it's created a new block:
CreateNewBlock(): total size _ txs: _ fees: _ sigops _
If this is post-segwit and the miner is counting weight and not block size, then the size field will be incorrect (it will always be set to 1000).
This PR fixes the log in the following way:
I've run all tests and manually verified that the log output is correct when using the
blockmaxsize
andblockmaxweight
command line parameters.