Continue proof of work encapsulation

It is built on top of #5170, replaces #4506 and continues #4377.
Nit: call it GetChallengeDifficulty? It's a well-defined number.