As part of generating proofs, it is possible for the node to mine the next block before adding the proof to the contender cache because mining a block takes a lock on cs_main, for which addStakeContender() also requires a lock. This patch ensures the proof was added to the cache before generating the next proof and mining the block associated with that.
This should fix some flakiness with the contender voting test.