How to Build Block Header in stratum?

When I studied the stratum on here,I found that there were little difference between the stratum and solo mining for building block header.

The stratum tell us that we needed to pad the header to uint512.


The bits is different to the algorithm of sha256’s padding.

But when I practiced the example which solved testnet3 block,I couldn’t use the information to calculate the hash until I discarded the padding.

In real-work,whether I need to pad or not?

By the way,the previous hash provided from notification is not correct,you need to find it on there.