Description
Extended tests like feature_pruning.py create large blocks by making many large transactions with a lot of OP_RETURNS in a single tx. Under this model roughly 14 of these transactions make a full-ish block.
These transactions are already non-standard, so I have just modified the logic to instead just create 1 large output, making a single large transaction, mining a block of roughly the same size (947k). The reduction in tx creation / number of outputs seems to significantly improve performance.
Another optimization is to splice in the OP_RETURN output after transaction signing, since it reduces the copying of the large OP_RETURN portion during signing. All signatures are SIGHHASH_NONE, so splicing after is okay.
feature_pruning.py has about a 1.5x speedup on my machine (~12 minutes down to ~8 minutes), and mempool_limit, and feature_maxuploadtarget seem to benefit as well.
Refactoring
- The original OP_RETURN generating function is now just a string. If there is a better place to put this, I will move it. At the very least I just wanted to document the format because the previous function had little explanation for all the hex values.
create_lots_of_big_transactionsno longer requires providing the OP_RETURN splice, and uses the default from before, with an optionalop_return_txout=keyword args for using the giant OP_RETURN mentioned above.