Author

Topic: what miners are trying to resolve? (Read 1623 times)

newbie
Activity: 12
Merit: 0
February 14, 2011, 04:36:00 PM
#8
I'm also quite puzzled after reading the wiki-page, I don't think there is enough information currently on that page to create you own miner (which I plan to do).

To mine, you really need to know the bitcoin data structures quite intimately...  ultimately that means reading the bitcoind source code.

Not that I don't want to dive into the source code to find out, but it can't really be that hard to explain how a miner works can it? Most likely it just takes some data, hashes it with one or two changing variables and tests if it fits the current target? I doubt knowing the data structures intimately is really necessary, but I get the feeling it is more adviced and/or encouraged?

Rather then having to read sources and decypher the algorithm I'd rather see it described somewhere. I know a little C/C++ so I'll probably be able to decypher the code. When/if I find the time I'll dive into the source code to find out how it works. If I do, I'll write a more elaborate description.
legendary
Activity: 1596
Merit: 1100
February 14, 2011, 01:39:36 PM
#7
Good questions, I'm trying to answer those as well. Some things I've found out:

- The nonce is what a miner itself increases after every try.
- I think you need to hash quite some fields, the nonce, timestamp, and more (merkle root?)
- The generated hash needs to be smaller then the current target (which you can retrieve)

I'm also quite puzzled after reading the wiki-page, I don't think there is enough information currently on that page to create you own miner (which I plan to do).

To mine, you really need to know the bitcoin data structures quite intimately...  ultimately that means reading the bitcoind source code.
newbie
Activity: 12
Merit: 0
February 14, 2011, 12:54:12 PM
#6
Good questions, I'm trying to answer those as well. Some things I've found out:

- The nonce is what a miner itself increases after every try.
- I think you need to hash quite some fields, the nonce, timestamp, and more (merkle root?)
- The generated hash needs to be smaller then the current target (which you can retrieve)

I'm also quite puzzled after reading the wiki-page, I don't think there is enough information currently on that page to create you own miner (which I plan to do).

Who can enlighten us? When you get a block, which steps do you need to do to generate a (possible) new block? Can somebody write it down in pseudo code?
member
Activity: 80
Merit: 11
February 14, 2011, 04:28:02 AM
#5
after some thinking, I have a few more questions...

hope it's not very annoying  Smiley


1. which part of the above code is actually "the block header"?

2. as I understand it, you need to add nonce to the block header and then calculate SHA256? Or you need to add nonce to the hash of the block header?

3. what is the nonce in the code: "nonce":329961997, is that the successful one for the previous block?

4. do I always have to start with nonce=0 and increment it, or I can start with any number?

5. when a job is sent to a miner worker, is it a certain range of nonces I need to calculate, or is it a part of the SHA256?

Thanks!
member
Activity: 80
Merit: 11
February 12, 2011, 10:49:35 PM
#4
Thanks!
LZ
legendary
Activity: 1722
Merit: 1072
P2P Cryptocurrency
February 12, 2011, 10:22:24 PM
#3
The block example (it is №107764):
Code:
{
  "hash":"00000000000271de9d8b94afff543366e290e995f3e3e337bb86a0b7bf02e8d1",
  "ver":1,
  "prev_block":"00000000000148c04e58dca8e1a2df251339c81e2dfe1ff0e9d655b7b4ca428d",
  "mrkl_root":"72febc107470c4f83e224f9683a5c7fb24c4dece8412b9d95db277c8dd75451d",
  "time":1297566305,
  "bits":453150034,
  "nonce":329961997,
  "n_tx":2,
  "size":473,
  "tx":[
    {
      "hash":"d74f0f8e979dc08d028f0fd97e06b97b81b3f42f41c80ce5e4a900003c202abe",
      "ver":1,
      "vin_sz":1,
      "vout_sz":1,
      "lock_time":0,
      "size":134,
      "in":[
        {
          "prev_out":{
            "hash":"0000000000000000000000000000000000000000000000000000000000000000",
            "n":4294967295
          },
          "coinbase":"045285021b0135"
        }
      ],
      "out":[
        {
          "value":"50.00000000",
          "scriptPubKey":"045ac21e53fc77ea47b72ae306840bd7eb16709b04488a0daf177df6a2476bbd6fabf76731e1cbfa75ec55c575454fe89e41ce58993f1cbd3dcf497b85bbebab80 OP_CHECKSIG"
        }
      ]
    },
    {
      "hash":"8ddf80cb3f3286922752da908f3b3f96c4bd8114cd67f3e00ae6a130e7d37b6e",
      "ver":1,
      "vin_sz":1,
      "vout_sz":2,
      "lock_time":0,
      "size":258,
      "in":[
        {
          "prev_out":{
            "hash":"4f41d46faa2e34b718e7edf051e27fbfe2e77055e5a4519eda67068cc060141b",
            "n":0
          },
          "scriptSig":"3045022013402505fee0e884206e6ae22b8057227ce2de970fae57ad4ab95c616fc60418022100aa52d63f3cd6c9e17c2ba4a7410d68e8f4c25e77f7f08f161c2f1af116cc065401 045216f2b5745cf08681a1409aa83e1554c788a7365600c7378665895a5377960eb49a86e3a2128d2ffe5f52e6a6e5ed453a1b87ebf08e5fdbe0b98352be2719cf"
        }
      ],
      "out":[
        {
          "value":"0.05000000",
          "scriptPubKey":"OP_DUP OP_HASH160 8707482c01949460fad582ef14558cbf1a2baf28 OP_EQUALVERIFY OP_CHECKSIG"
        },
        {
          "value":"47.98000000",
          "scriptPubKey":"OP_DUP OP_HASH160 5b83f29112290e0baf004db04a85c1e32a7f4242 OP_EQUALVERIFY OP_CHECKSIG"
        }
      ]
    }
  ],
  "mrkl_tree":[
    "d74f0f8e979dc08d028f0fd97e06b97b81b3f42f41c80ce5e4a900003c202abe",
    "8ddf80cb3f3286922752da908f3b3f96c4bd8114cd67f3e00ae6a130e7d37b6e",
    "72febc107470c4f83e224f9683a5c7fb24c4dece8412b9d95db277c8dd75451d"
  ]
}

The hash of that block header:
Code:
00000000000271de9d8b94afff543366e290e995f3e3e337bb86a0b7bf02e8d1

The current target:
Code:
0000000000028552000000000000000000000000000000000000000000000000

The cryptoproblem is that the block header SHA-256 hash should be below the current target.
administrator
Activity: 5222
Merit: 13032
February 12, 2011, 10:03:00 PM
#2
You hash the block header and try to get the hash below the current target.

https://en.bitcoin.it/wiki/Block
https://en.bitcoin.it/wiki/Block_hashing_algorithm
https://en.bitcoin.it/wiki/Target
member
Activity: 80
Merit: 11
February 12, 2011, 09:57:18 PM
#1
Can anyone please point me to the info about what exactly needs to be solved to generate coins?

I'd like to see an example of a block, what the cryptographic problem is, and what the valid answer looks like

Thanks!
Jump to: