Continue proof of work encapsulation

It is built on top of #5170, replaces #4506 and continues #4377.
Can you explain the nit a little bit more?