If the miner with the strongest ability to solve the block wins, why doesn't the same miner win every time? Wouldn't that miner still have the strongest ability to perform the proof of work on the next block and thus win every block?
Mining is not won by the miner with the "strongest ability to solve the block". Mining is a random progress-free process. Each block candidate independently has a tiny chance to be a valid block.
Each miner is working on a separate, non-overlapping block candidate set. Block candidates assign the block reward to their author with an output in the Coinbase transactions and therefore each miner has their own transaction set differing to that of other miners. As everyone is working on a separate set of work, and every piece of work has an tiny chance of winning (independently of what else was tried!), mining is a Poisson process, rather than a linear stack of work that needs to be powered through. Therefore, the miner with the most hashing power has the greatest chance to win the block, but only probabilistically so.
Think of mining as buying a lottery ticket for each block candidate hashed. Only a fraction of the tickets in the pot are winning tickets, but somebody might draw a winner on their second try, while another has bought fifty losing tickets already. However, when you buy more tickets more quickly, your chance of winning is higher.
For a better overview what mining is, you can have a look at "What exactly is mining?".
Thanks Murch. So the stronger hash power allows you to enter into the pot more often? Feb 24, 2015 at 1:38
5Each hash is a lottery ticket. Hashes per second (hashrate) are lottery tickets per second. If you do more hashes per second then you will find blocks more often. Feb 24, 2015 at 7:23
Every miner is working a on different block. While they share some of the same data, there are several parts of a block which are completely up to the miner to decide, and those differences make the blocks different. This also means that they have different hashes so every miner is searching a different part of the SHA256d search space.
Although each of the blocks every miner is working on will share the same height and parent block, they will have different transactions, and may have different block version numbers, and timestamps.
But the most obvious thing is going to be the transactions, which are hashed into the merkle root. Just one transaction being different, or just one transaction in a different position, is going to cause the merkle root to change, which causes the block header to change, which thus makes the hash different. And every miner is going to have at least their coinbase transaction be different from everyone else's. This is because the coinbase transaction contains the output that pays the miner, so obviously every miner is going to make their coinbase transaction pay themselves, not someone else. From this simple fact, the transactions in the blocks that miners are working on are going to be different in at least the coinbase.
So because miners are all working on different blocks, every nonce that they try is going to result in a block hash that no other miner has seen yet. Thus a small miner could be lucky enough that the block they are trying has a nonce that makes the hash meet the PoW requirement before a larger miner finds such a nonce for their block.
1Does this mean that whenever a miner meets the PoW requirement and therefore his/her block is added to the blockchain, all the other miners have to throw away the work on their currently mined blocks because the parent block to append the next block to changed, therefore the hash of the next block will change? I hope this makes sense. Nov 16, 2021 at 22:27
@pkout Yes, but they aren't really throwing away work. Mining is a progressless process, so all previous work done has no bearing on whether the miner would have found the block if someone else hadn't.– Andrew Chow ♦Nov 17, 2021 at 0:07
1So say a miner A and B mine blocks. Miner A finishes PoW first, so his/her block is added to the top of the blockchain. That means that the next block to be added will have to contain the hash of the miner A's block as its parent block, right (because that's the new top of the blockchain)? But the miner A's block wasn't known when miner B started mining the last block, so he/she will have to restart the process so that he/she starts with the correct parent block hash at the header of the next block to be mined, no? I know I am missing something, just can't figure out what it is. Nov 17, 2021 at 0:52
@pkout Yes, that is what will happen. Miner B will change the header they work on to have a new previous block and to have new transactions (as the original transactions are likely to have been confirmed in A's block). However this doesn't cost B anything because mining is progress-less. All of the work that B had done previously did not make it more or less likely that the next block header B tries will be valid. Yes they "restart", but they restart after each and every nonce tried. Updating to the next block is no different than trying the a new nonce.– Andrew Chow ♦Nov 17, 2021 at 5:27
1Ah, now I get it. This was the missing piece for me: "Yes they "restart", but they restart after each and every nonce tried. Updating to the next block is no different than trying the a new nonce." I pictured that once a block is being mined, transactions in it are frozen until the correct nonce is found. That's not the case. Each nonce is tried on a "fresh" block of transactions, header of which points at the top of the current longest block chain. Thank you, Andrew! Nov 17, 2021 at 6:44