In PoW algorithm a miner has to solve a mathematical puzzle whose difficulty depends upon load on network and total computing power. But who decides what would be that puzzle for each block?
For Example I am mining a block and I have to solve following equation A + B = C
now I have A
and I have to find B
to solve this equation but who in blockchain network provides C
(predetermined number) for each block ?
Or
How do the other miners verify that he really did find the winning hash?
2 Answers
a miner has to solve a mathematical puzzle
Let's be specific: a miner has to find a block header (which you construct with the block content, i.e. transactions) whose hash (double sha256
) is a number inferior to the target.
But who decides what would be that puzzle for each block ?
This can be rephrased as: But who decide of the value of the target for each block ?
Short and abstract answer: The network sets the target value.
Or How do the other miners verify that he really did find the winning hash?
Not only the other miners but all the participants of the network (full nodes) verify the PoW upon receiving a block, with "verifying the PoW" meaning "check that the hash (double sha256
) of the block header represents a number below the current target.
So, how all the nodes can agree on the validity of the block ? Or, how all nodes can share the same target ?
The target is hardcoded for the genesis block and is adjusted (the higher the target, the lesser the difficulty. The lesser the target, the higher the difficulty) every 2016 blocks. Since all participants share the same block chain and the same formula for adjusting the target, they share the same current target. And since they share the same current target, they accept the same blocks and hence share the same block chain :-).
-
"The network sets the target value". But the network is collection of nodes. So which node decides target for current Block ? Or if they do it collectively what is the mechanism ?– RizstienDec 24, 2019 at 9:25
-
2I began with this abstraction in my answer to then answer precisely your comment. The target is updated individually at a fixed interval by each node, since the same algorithm and the same interval is used they collectively share the same value for the target. Dec 24, 2019 at 21:29
The system generates the next puzzle. Think of it as the next A is the result of hashing current A and the next transaction just solved. Therefore the hash output, new A, is random again. So the miner who just solved the puzzle does not have any advantages. The beauty is that you can always find a B that meets the target difficulty.