WARNING: This hasn’t been used for mainnet mining yet as far as I know.
NOTE: This includes a commit which changes the default block priority size to 0. This code has been optimized for not including transactions in a priority space. If block priority space > 0 then the code does not offer too much of a performance improvement over the existing code. (EDIT: now its fast regardless)
The mempool is explicitly assumed to be responsible for maintaining consistency of transactions with respect to not spending non-existent outputs, not double spending, script validity and coinbase maturity. Only finality of transactions is checked before assembling a block.
A final call to TestBlockValidity is still performed. If an invalid block has been constructed, then an error is thrown logged and a NULL pointer is returned. (EDIT: reverted to original behavior with more informative error)
This code produces the same blocks as the code it replaces with the following exceptions:
- The fee rate sort tie breaker is hash instead of priority
- The priority sort has a secondary tie breaker of hash
The priority block is not limited to transactons above AllowFree()(EDIT: fixed)The fee rate sorted part of the block is not limited to transactions above minRelayTxFee(EDIT: fixed)- (EDIT: The blocks are the same if you keep scanning to the end to try to fill up the last remaining space, but this code stops after trying 50 times to fill the last 1000 bytes)
Comparing this to the original code over 2000 calls to CreateNewBlock over the last 2 days. (blockprioritysize=0, maxmempool=300, dbcache=1000, maxsigcachesize=1000000) Time in ms
Time to assemble block | Additional time to perform final TestBlockValidity | |
---|---|---|
master | 2602 | 240 |
this pull | 14 | 438 |
The extra slowness in TestBlockValidity is because the cache used to be warmed up in the assembly code.