Author

Topic: A few questions about mining I couldn't find on the wiki... (Read 1604 times)

kjj
legendary
Activity: 1302
Merit: 1026
A miner gets a header and starts working on it by running through all of the possible nonce values.  This can take a few seconds to several minutes, depending on the hashing speed of the miner.  If it finds no valid hashes that way, it reports back to the node.  Or, the node can tell the miner to stop, assuming both ends support long polling, by sending out a new header before the miner is done with the first one.

If the miner asks for a new block because it exhausted all of the possible nonces, the node will update the Merkle root hash (by allowing in new transactions, or by updating the nonce in the generation transaction) and/or the timestamp and send it out again.

If the miner was interrupted by a long poll, it usually means that the node heard that someone else got a valid block, so the new work will have a different "last block hash", and the transaction list will be totally different, giving a new Merkle root hash, and the timestamp will (likely) be different.

So, no, the miner doesn't really need to know what it did before, because it will never get that unique combination of bits again.
newbie
Activity: 14
Merit: 0
This seems like a good place to ask:

I'm certain I've heard mention that a miner doesn't need to "remember" previously attempted hashes to avoid duplicate work. Why is this true? From the descriptions above it would seem that pools are doing exactly that, dividing up work towards a completed block in an orderly fashion.
newbie
Activity: 25
Merit: 0
fpgaminer has it right except for one tiny detail.

The block of transactions is built first, because the merkle hash of all the transactions is included in the header that the miners work on.  Also, the node will add newly arrived transactions to the block periodically.  Oh, and the node could give totally different blocks out to different miners if it wanted to.

There is a key detail that may not be obvious, but is crucial to understanding the mining process is that there isn't just one true next block that every node is searching for.  Every node is searching for their own unique next block that meets the validity criteria.  Their unique block includes the address that gets the mining reward.

Ok, so in theory on my dual core processor, 4gb of RAM laptop could EVENTUALLY get the 50 BTC...?

I could start hashing by hand and theoretically get a block Tongue

And ram has no effect on hashing speed, FYI.

Eh, I was just making an example. Hmm, this is kind overwhelming...
sr. member
Activity: 406
Merit: 256
fpgaminer has it right except for one tiny detail.

The block of transactions is built first, because the merkle hash of all the transactions is included in the header that the miners work on.  Also, the node will add newly arrived transactions to the block periodically.  Oh, and the node could give totally different blocks out to different miners if it wanted to.

There is a key detail that may not be obvious, but is crucial to understanding the mining process is that there isn't just one true next block that every node is searching for.  Every node is searching for their own unique next block that meets the validity criteria.  Their unique block includes the address that gets the mining reward.

Ok, so in theory on my dual core processor, 4gb of RAM laptop could EVENTUALLY get the 50 BTC...?

I could start hashing by hand and theoretically get a block Tongue

And ram has no effect on hashing speed, FYI.
member
Activity: 112
Merit: 100
"I'm not psychic; I'm just damn good"
Quote
Ok, so in theory on my dual core processor, 4gb of RAM laptop could EVENTUALLY get the 50 BTC...?
Every time a miner makes another attempt and calculates a new hash, it has the same chance as anyone else for that to be a valid hash (and thus get the tasty 50 BTC). But of course, the more hashes you do per second, the more chances you get per second.

So yeah, your laptop could get lucky. But it'd be safer to bet that it won't solve a block until the sun has exploded.
'
Haha that was awesome fpga. Anyway very detailed explanation on what it actually does although I don't get half of it lolx. How goes your open source project?
hero member
Activity: 560
Merit: 517
Quote
Ok, so in theory on my dual core processor, 4gb of RAM laptop could EVENTUALLY get the 50 BTC...?
Every time a miner makes another attempt and calculates a new hash, it has the same chance as anyone else for that to be a valid hash (and thus get the tasty 50 BTC). But of course, the more hashes you do per second, the more chances you get per second.

So yeah, your laptop could get lucky. But it'd be safer to bet that it won't solve a block until the sun has exploded.
hero member
Activity: 560
Merit: 517
Quote
The block of transactions is built first, because the merkle hash of all the transactions is included in the header that the miners work on.
Ahh, okay, so the merkle hash is included in what the miners work on. The spec on the wiki was a little vague and I haven't taken the time to rip open bitcoind to check. Thank you for clearing that up!
newbie
Activity: 25
Merit: 0
fpgaminer has it right except for one tiny detail.

The block of transactions is built first, because the merkle hash of all the transactions is included in the header that the miners work on.  Also, the node will add newly arrived transactions to the block periodically.  Oh, and the node could give totally different blocks out to different miners if it wanted to.

There is a key detail that may not be obvious, but is crucial to understanding the mining process is that there isn't just one true next block that every node is searching for.  Every node is searching for their own unique next block that meets the validity criteria.  Their unique block includes the address that gets the mining reward.

Ok, so in theory on my dual core processor, 4gb of RAM laptop could EVENTUALLY get the 50 BTC...?
kjj
legendary
Activity: 1302
Merit: 1026
fpgaminer has it right except for one tiny detail.

The block of transactions is built first, because the merkle hash of all the transactions is included in the header that the miners work on.  Also, the node will add newly arrived transactions to the block periodically.  Oh, and the node could give totally different blocks out to different miners if it wanted to.

There is a key detail that may not be obvious, but is crucial to understanding the mining process is that there isn't just one true next block that every node is searching for.  Every node is searching for their own unique next block that meets the validity criteria.  Their unique block includes the address that gets the mining reward.
hero member
Activity: 560
Merit: 517
Quote
So correct me of I'm wrong. When you're "mining" you're computer is essentially guessing a random number, encrypting it, and comparing it to the already encrypted block.
That doesn't sound quite right ... I'll try to explain it. Remember, this is only for mining:

In order to successfully get 50 BTC, or whatever the current reward is, a Bitcoin client must add a block to the current block chain, and show the new block to everyone else. So the first thing the client program does is put together a small data structure that is the block header. This block header contains a copy of the last block's hash, which is why blocks form a chain, and a bunch of other data.

Before this potential block will be considered valid by others, the SHA-256 hash of the block header (actually, only a portion of the header) must be less than or equal to a 256-bit Target. The Target is determined by the current Difficulty.

Obviously, most of the time when the client puts together the block header the hash will not be less than the Target. To "mine" a block the client, or dedicated mining program, must manipulate various fields in the block header in an attempt to find values that make the hash less than the Target. Since SHA-256 generates pseudo-random numbers, and isn't feasibly reversible or predictable, this basically just amounts to brute-forcing.

There is one field in particular, called the Nonce. It's a 32-bit value that miners increment from 0 to 2^32, running the SHA-256 hash each time to check if they've found a Nonce that makes the block header valid.

Once a block header has been found that meets the Target requirement, the bitcoin client can add confirmed transactions to the block and then share it with the rest of the world. Other bitcoin clients can run the SHA-256 on the block header to confirm that this new block is indeed valid.

There's just one more thing. The bitcoin client usually does all the work of putting together the block header and such. Dedicated mining programs can communicate over JSON-RPC with a bitcoin client to ask for "work". The bitcoin client returns only the portion of the block header that actually needs to be worked on, and the miner is only responsible for searching all 2^32 values of the 32-bit Nonce. If it finds a valid Nonce, it can report its findings back to Bitcoin which will finish up constructing the block and submit it to the world. If the miner doesn't find a valid Nonce, it can make another "getwork" request of the bitcoin client, which will change a few fields in the block header and then give new work to the miner.
member
Activity: 112
Merit: 100
"I'm not psychic; I'm just damn good"
Hi, the newbies guide has been stickied maybe some of the information that you seek can been found there.

I'm not as technically inclined as you and I'm also new but I'm pretty sure that there is a certain code that needs to be decrypted and once the key to decrypting it is found, the user's whose computer who solves it gets 50 BTC instantly. I guess you can say the computer does guess a certain key to see if it works in that sense.

Anyway as I mentioned, I'm neither technically inclined nor am I experienced enough to tell you how it works. This is just the general idea I've gotten since last week when I joined.
newbie
Activity: 25
Merit: 0
Just started with Bitcoin last night and I've been trying to figure out how mining actually works. I'm pretty technically inclined but Cryptography isn't my thing...

So correct me of I'm wrong. When you're "mining" you're computer is essentially guessing a random number, encrypting it, and comparing it to the already encrypted block. The block is encrypted multiple times (millions?) into layers. So every time you decrypt it you remove a layer (much like an onion) then share that news with the rest of the network. Then the next layer is started. I'm guessing that the bitcoins are awarded to the client with the most layers removed once the entire block is decrypted?

So if above is true (Again, I don't know for certain this is just what I assume) then having a CPU based miner makes it physically impossible to get the coins...

Again, if I'm wrong please let me know...

I also know that blocks are basically records of all transactions by the network. How do they get packed into the blocks and encrypted? Are they sent from node to node each adding another layer?

Again, sorry if these have been asked before I couldn't find anything... Thanks in advance!
Jump to: