I was looking at the protocol constants using:
GET /chains/<chain_id>/blocks/<block_id>/context/constants
and noticed these two fields:
"proof_of_work_nonce_size": 8,
"nonce_length": 32,
What are they used for?
You will find the explanation to both these constants in the documentation of Tezos proof of stake algorithm.
They relate to two different nonces with different purposes.
A nonce is used to prevent the chain from being spammed with blocks:
proof_of_work_nonce
: a nonce used to pass a low-difficulty proof-of-work for the block, as a spam prevention measure.
In the section on Random seeds, you can read about nonces (whose length is nonce_length
) using the on-chain random number generation used to select baking slots. In sum, in each cycle the algorithm assigns baking slots randomly using a based on random seed calculated a set of pre-commited "nonces" from bakers from previous cycles:
The random seed for cycle n is a 256-bit number generated at the very end of cycle n-1 from nonces to which delegates commit during cycle n-2. One out of every BLOCKS_PER_COMMITMENT = 32 blocks can contain a commitment. There are therefore at most BLOCKS_PER_CYCLE / BLOCKS_PER_COMMITMENT = 128 commitments. A commitment is the hash of a nonce. The commitment is generated by the baker who produces the block and is included in the block header.