As with mining, what are the bitcoin miners really solving?They are solving hashes, but what does that really mean. Can we see what they are solving?

in #bitcoin7 years ago (edited)

They try to find a random nonce (a little random data) that goes into a block and makes the block have an (SHA256) hash that (in binary) starts with a certain amount of 0's. The more zeroes the more rare hash is. A good hash' outcome is not predictable, and so you have to try a lot of times to find a good nonce.

A number of zeroes are based on how difficult it is supposed to be to find a block. In Bitcoin it adjusts to have a new block every 10 minutes (on average, given the rate at which previous blocks are found).

Interesting: because the hashes are unpredictable it doesn't matter how the nonce changes! Most of the time it's just a number counting upwards from 0!

The data:

This is the hash of the lastest block (shortened to 30 characters):

00000000000001adf44c7d69767585
These are the hashes of a few valid transactions waiting for inclusion (shortened).

5572eca4dd4
db7d0c0b845
And this the hash of one special transaction that you just crafted, which gives 25BTC (the current reward) to yourself:

916d849af76
Building the next block:

Now, let's use a gross approximation of what a new block might look like (the real one uses binary format). It contains the hash of the previous block and the hashes of those 3 transactions:

00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--
Now let's do mining by hand! Our goal is to complete this block with a nonce (a piece of garbage) such that the hash of the new block starts with 13 zeros (considering the previous hash, it seems that 13 zeroes is the current difficulty!).

Mining (trying to finalize this block):

Let's try with nonce=1, and compute the hash of the block (I'm using the md5 hash algorithm, but Bitcoin uses double sha256):

echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--1" | md5sum
8b9b994dcf57f8f90194d82e234b72ac
No luck, the hash does not start with a 0… Let's try with nonce=2

echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--2" | md5sum
5b7ce5bcc07a2822f227fcae7792fd90
No luck…

If we pursue until nonce=16, we get our first leading zero.

echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--16" | md5sum
03b80c7a34b060b33dd8fbbece79cee3
For nonce=208, we get two leading zeroes!

echo "00000000000001adf44c7d69767585--5572eca4dd4-db7d0c0b845-916d849af76--208" | md5sum
0055e55df5758517c9bed0981b52ce4a
Continue like this… If you finally find a hash that has 13 leading zeroes… you're a winner! Other miners will now build upon your block, you've just got 25BTC.

But you'll have to be fast!

Back to step 1…

If someone manages to build a block before you do, you'll have to start again from the beginning with the new block's hash (the one of the winner).

Ref:https://bitcoin.stackexchange.com/questions/8031/what-are-bitcoin-miners-really-solving

Sort:  

WELCOME TO STEEMIT @moeez
I'm very happy to have you around and render my assistance on steemit.
DQmWdRgxxwjAp2UGa33Q8UvshFvfrxhqT5tGR7dXQpUi5gn_1680x8400.png

Very interesting

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 58906.05
ETH 2666.51
USDT 1.00
SBD 2.44