This change lifts the declaration of the randomx VM out of an inner loop
into the main function body of RandomXMiner(), which allows us to destroy
it later on when catching exceptions. We cannot lift the allocation of it's
memory (randomx_create_vm) because it depends on things that change in every
iteration of the inner loop. Otherwise, the VM will only sometimes
be destroyed, which is what I think causes the memleak.
But this seems to create one invalid block when mining each block height :
STDOUT:
TestBlockValidity: failure C checkPOW=1
RandomXMiner: Invalid randomx block mined, try again 05f30f419133b2d862106b89c20059967639e4f2699dd5afc5d2b0832f1ac76a
debug.log:
2023-10-11 16:10:41 CreateNewBlock(): total size 1000 blocktime.1697040642 nBits.200e77d1
2023-10-11 16:10:41 Running HushRandomXMiner with 1 transactions in block (260 bytes)
2023-10-11 16:10:41 ERROR: ContextualCheckBlock: block height mismatch in coinbase
Mining does seem to continue normally when testing with -testnode=1
70fa319fd9
into dev 7 months ago70fa319fd9
.