Bitcoin Forum
November 18, 2024, 02:48:02 AM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Mining Questions  (Read 427 times)
titus (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 0


View Profile
February 26, 2013, 05:54:29 PM
 #1

Hi all,
I'm trying to wrap my head around mining and I think I get it, but I have a few questions I hope someone can shine some light on.  I've read through many pages on the subject but didn't see these questions answered, or I just misunderstood what I was reading (definitely possible!).

- When a miner starts trying to hash a block of transactions, do they "choose" which transactions go in the block, or do they just throw in all transactions they've received that were not in the last block? I assume that they can, in theory, choose to ignore transactions that don't have fees, but does that really happen?

- While a miner is hashing a new block, which includes x transactions, how do they respond if a new transaction comes in? Do they include the new transactions and start hashing again, or do they ignore the new transactions?

- How does the nonce work? I'm currently under the impression that a block being hashed has x transactions which would result (always) in a given hash, so the miner changes the nonce so that they can get a new hash. Is that correct?  Could they, instead, re-order the listing of transactions in the block, and would that produce a new hash?

- How does the network resolve forks in the chain? By which I mean two miners come up with two different, valid solutions to the same block, and push their changes to the network. Some clients receive new Block A, and some get new Block B.  Those clients now start working on the NEXT block even while the new blocks are propagating, etc.  It would seem that one solution will spread out faster, but how do clients following the "bad" chain fix the error?  Do they look at a timestamp and select the earliest? Do they select the block with the most transactions? 

Thanks for any elucidation.
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
February 26, 2013, 07:19:31 PM
 #2

- When a miner starts trying to hash a block of transactions, do they "choose" which transactions go in the block, or do they just throw in all transactions they've received that were not in the last block? I assume that they can, in theory, choose to ignore transactions that don't have fees, but does that really happen?

That depends on the miner.  If you are mining in a pool, then the pool decides for you which transactions will be in the block.  All they need to send you is the block header since that is all that needs to be hashed to reach the target difficulty.

If you are solo mining, the rules of the protocol allow you to choose the transactions if you want to write a program to do that.  Most solo miners use software that selects based on the priority based rules in the reference client.

- While a miner is hashing a new block, which includes x transactions, how do they respond if a new transaction comes in? Do they include the new transactions and start hashing again, or do they ignore the new transactions?

I would expect that most miners would continue with the block header as is at least until all values in the nonce are used up.  Beyond that I don't know if any pools or mining software reselect the transactions, but my guess is that they don't.  Seems like an opportunity lost there to grab some high value transactions if any happen to come in.

I'm currently under the impression that a block being hashed has x transactions which would result (always) in a given hash, so the miner changes the nonce so that they can get a new hash. Is that correct?

Yes.

Could they, instead, re-order the listing of transactions in the block, and would that produce a new hash?

Yes but it would be slower because they'd have to re-calculate the merkle root each time they do that.

- How does the network resolve forks in the chain? By which I mean two miners come up with two different, valid solutions to the same block, and push their changes to the network. Some clients receive new Block A, and some get new Block B.  Those clients now start working on the NEXT block even while the new blocks are propagating, etc.  It would seem that one solution will spread out faster, but how do clients following the "bad" chain fix the error?  Do they look at a timestamp and select the earliest? Do they select the block with the most transactions?

They end up in a race with some of the network looking for a block that builds on Block A, and some of the network looking for a block that builds on Block B.  Which ever part of the network finds their block first broadcasts it out relaying through peers and when peers see that there is now a blockchain that is longer than the one they are working on, their block becomes orphaned and they adopt the new longer chain.
 
titus (OP)
Newbie
*
Offline Offline

Activity: 29
Merit: 0


View Profile
February 26, 2013, 07:29:35 PM
 #3

Wow, thank you, that explains a lot.

I had one more though - How does the "network" decide to award the miner the coins? Or, does the miner get to just claim the related bitcoins as input to a future transaction, and other nodes on the network can decide if that input is valid for that transaction?
DannyHamilton
Legendary
*
Offline Offline

Activity: 3486
Merit: 4851



View Profile
February 26, 2013, 07:34:00 PM
 #4

The miner (or pool) claims the reward in the block that they mine.

Every block is allowed by the protocol to have exactly one transaction that has no inputs.  That transaction is allowed to have outputs the sum of which are less than or equal to the sum of the current block subsidy and the transaction fees of all transactions included in the block.  This is generally (always?) the first transaction in the block.  It is commonly called a "coinbase" transaction.

Every node, when they receive a new block, verifies that the coinbase transaction has not claimed a reward that is too large.  If the outputs of the coinbase transaction are too large, then the nodes will simply reject the block and refuse to relay it.
pe1pip
Newbie
*
Offline Offline

Activity: 8
Merit: 0


View Profile
March 14, 2013, 01:15:58 AM
 #5

- When a miner starts trying to hash a block of transactions, do they "choose" which transactions go in the block, or do they just throw in all transactions they've received that were not in the last block? I assume that they can, in theory, choose to ignore transactions that don't have fees, but does that really happen?

That depends on the miner.  If you are mining in a pool, then the pool decides for you which transactions will be in the block.  All they need to send you is the block header since that is all that needs to be hashed to reach the target difficulty.

If you are solo mining, the rules of the protocol allow you to choose the transactions if you want to write a program to do that.  Most solo miners use software that selects based on the priority based rules in the reference client.
Is there some convention? "rules in the reference client" sounds nice, but, are those documented in plain English for those of us who are not very eager to read source code?

- While a miner is hashing a new block, which includes x transactions, how do they respond if a new transaction comes in? Do they include the new transactions and start hashing again, or do they ignore the new transactions?

I would expect that most miners would continue with the block header as is at least until all values in the nonce are used up.  Beyond that I don't know if any pools or mining software reselect the transactions, but my guess is that they don't.  Seems like an opportunity lost there to grab some high value transactions if any happen to come in.
Again, more or less the same question... Is there any documentation? I sort of get the feeling that, because there is no such thing as lost work, new transactions do get added to the current block at least once a minute or so. Is that right?

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!