Title: Newbie Trying to understand the mining calculation process. Post by: skeeterskeeter on February 11, 2013, 06:20:37 PM Hello first timer here,
I was interested in figuring out exactly what happens when one mines bitcoins and I guess the over backbone of mining. Sorry for my lack of jargon and knowledge, I am learning! Also, I relate alot of the abstract ideas to that of Object Oriented Programing (OOP) So when I say "object" I mean all data that encompasses the type of object beign referred too. (Ex, transaction object hold all info about a transaction) So let me explain what I think I know. == Step one: Lets barter my friend. ==
== Step two: Lets notify er'one of our bartering ==
== Step three: We have a block lets get some Au from it ==
~~Overall questions~~
I figure, as i said just above, that to solve a block means we find the minimum spanning tree over all given transactions. Given that the transaction are connected as such (https://en.bitcoin.it/wiki/File:Transaction.png)
END NOTES: - First thanks for reading my wall of text and any answer you may provide. - If you think (after answering my Q's) I might have another one, try and answer that too. - If to much to try and answer all my question specifically try to give me and overview and hit on the points you think I lack most on. Title: Re: Newbie Trying to understand the mining calculation process. Post by: DannyHamilton on February 11, 2013, 06:58:00 PM Questions in step one:
The inputs contain a signature and public key. The public key is the public key associated with the bitcoin address that previously recevied the output that is being referenced as an input. The signature proves that the person using the previous output has the authority to use the previous output in an input.
This is the "jist" of it. There are some technical details that you've glossed over, but you seem to have the basics down. Question in step two:
Hopefully someone who understands the protoocol better than me will clarify if I'm mistaken on this point, but it is my understanding that the person sending the bitcoin notifies all the nodes that their client is connected to. Each of those nodes then relays the transaction to every node they are connected to. This relaying continues as the transaction works its way across the network.
Eventually mining nodes (or mining pool nodes) receive the relayed transaction. They put the transaction into the block they are currently working on if they wish to do so. Questions in step three: If you are solo mining, you hold the information about the current block that you are working on. If you are mining in a pool, then the pool operator holds all the information for the block that all the pool members are working on.
Finding a hash value smaller than the current target requires an amount of work. Providing that hash proves that you did that work. The target is adjusted on a regular basis to ensure that the amount of work needed to find the target hash requires the entire hashing power of all the miners on the network for approximately 10 minutes. The hash acts as proof that the appropriate amount of work was done for the indicated block of data. If anyone tries to modify any data in the block they will end up with a different hash. To modify the block and have nodes running the protocol accept it, you would have to repeat the same amount of work that was required to complete the original block. Since each new block contains the hash of the previous block in it's header, you can't change the data in any older block without having to repeat all the work that was necessary for every block since the block you are trying to replace. Meanwhile the honest network is continuing to create new blocks. This means that any malicious attacker would have to have more hashing power than the entire combined honest network to ever catch up with the current blockchain.
The new 25BTC comes from nowhere. Every block contains a list of transactions. The protocol requires exactly one transaction in every block that has no inputs. It requires this to be the first transaction in the block. This outputs of this transaction are not allowed to exceed the current block subsidy value (25 BTC) plus the total of all transaction fees. The transaction fees of each transaction are calculated as the difference between the total inputs and the total outputs, so yes, if you don't include your change in an output, then the change becomes a transaction fee for the miner. ~~Overall questions~~ Until a miner includes a transaction in a block it exists only in the memory pool of the various nodes on the network that are relaying it. Any miner can choose to include any valid transactions they would like from their memory pool in the next block they choose to mine.
It doesn't meet the requirements of being a valid transaction. Some of which are:
User 2 does not have the private key that is associated with any of the bitcoin addresses that User 1 owns. Therefore User 2 is unable to provide the necessary signature to include any of the outputs associated with the addresses owned by User 1 in any transaction that would use those outputs as inputs. Title: Re: Newbie Trying to understand the mining calculation process. Post by: skeeterskeeter on February 11, 2013, 08:19:35 PM Ok, after some more reading and this post some thing are clearer but I am still left with a few questions.
The validity of the BTC system rest on the idea that no one person can perform the work that we have all performed so far creating the BTC system. They would first need the computing power equal to all of us, and then the same amount of time from the transaction they wish to change to now to compute the hashes and submit the new blocks to everyone. This is semi-impossible unless someone finds a polynomial time algorithm for finding hashes, or has a crap-ola lot of money to make the computing power necessary to do such a thing. OK. So this means that the more work we all do the more secure the BTC system is. So we never want to do the same work someone else has done that would be asinine. This means that each hash someone performs is unique. This must mean that the nonce is unique to each hash. This must mean the nonce for the current block is global to all nodes. This must mean each time someone wants to try to "mine" the current block they have exclusive access to use the current nonce and if someone else wants to mine they have to take the next nonce value and work with it. This is the lottery system in it all. Each nonce value is like a scratch off for 25BTC. It cost nothing to buy the lottery ticket though! But you have to scratch a crap ton of tickets to ever get any money. OK. So in general is it a rule in hashing that it is difficult to find a small hash value? I read 1 in 2^20 hashes will have 20 leading zero's. Who/what states what the current target hash is? Who/what states how hard it is to find the current proper hash? Title: Re: Newbie Trying to understand the mining calculation process. Post by: DannyHamilton on February 11, 2013, 09:05:55 PM . . . This means that each hash someone performs is unique. This must mean that the nonce is unique to each hash. This must mean the nonce for the current block is global to all nodes. This must mean each time someone wants to try to "mine" the current block they have exclusive access to use the current nonce and if someone else wants to mine they have to take the next nonce value and work with it . . . This isn't quite true. Each miner (or pool) has a different block header that they are trying to hash, since the block includes the transaction that pays out the block subsidy and each miner (or pool) has a different payment address. This means that 2 different miners can use the same nonce on the block that each of them is working on and generate completely different hashes. When a miner happens to come upon a hash that is of low enough value, they relay the block with the target hash that they've found, and everyone else can confirm that the block contains a qualifying hash by comparing against the target and then hashing the block that they are relaying and checking to see if the hash value matches the one stored in the new block. So in general is it a rule in hashing that it is difficult to find a small hash value? I read 1 in 2^20 hashes will have 20 leading zero's. Yes, in general it is understood that the results of a hash are unpredictable and therefore essentially random. If I generate a random number between 1 and 10, there is a 90% chance that the random number will be less than 10. There is a 50% chance that the random number will be less than 6. There is a 10% chance that the number will be less than 2. In the case of block hashes, the hashing algorithm ends up with a random number between 0 and 2^256 (between 0 and 1.158 x 1077).Who/what states what the current target hash is? The protocol that every node runs has a system built in to the code that adjusts the expected target every 2,016 blocks. If a new block received does not have a hash below this target, then none of the honest nodes on the network will accept or relay it.Who/what states how hard it is to find the current proper hash? The software running on every node and every miner compares the hash to the expected difficulty that they have independently calculated based on the publicly available blocks that are currently part of the blockchain.Title: Re: Newbie Trying to understand the mining calculation process. Post by: skeeterskeeter on February 11, 2013, 10:29:42 PM Essentially this means that no two miners could perform duplicate work then, and all work added no matter how small goes into foiling dishonest nodes.
*** Dishonest nodes are ones with crap transactions, which are found in the ways previously listed. Thought: If one node were to not find a bad transaction though it existed in their block would the power of the other honest nodes create a "better" hash than them then? Meaning ALL bad transactions will ALWAYS be dropped from the block chain if indeed we all follow the hardest working hasher? *** Though duplicate work could be performed by two miners working on paying out to the same wallet, such the case in pools and multi-threading. Which good, we can do it faster then! As if each node is its own economy (Cool!) and within each node there is another almost government transposed on top of the BTC system that deduces how each miner in there gets payed out. And it all goes back to all economies following the best economy, the one with the most computing power. ----------------------------------------------------------------------------------------------------------------------------------------------- So if I have a bitcoin wallet and I make a transaction. It gets propagated throughout each node, and once...
So either there is a set size when someone can start and thus who ever makes the most transactions ( + received possible transactions) has the edge to getting to start the next block, or I haven't thought of something. ----------------------------------------------------------------------------------------------------------------------------------------------- Hopefully my last few questions... - So how exactly is the new target hash generated between the nodes, is there a technical page I could read? - And how exactly does "The software running on every node and every miner compares the hash to the expected difficulty that they have independently calculated based on the publicly available blocks that are currently part of the blockchain", again any technical pages you know? Unless of course you know well enough to explain it, but it sounds it might be a little complicated to say eloquently on a forum post. Title: Re: Newbie Trying to understand the mining calculation process. Post by: DannyHamilton on February 11, 2013, 11:11:06 PM So if I have a bitcoin wallet and I make a transaction. It gets propagated throughout each node, and once...
No, miners are ALWAYS working on the next block. They don't wait for "enough transactions". They just work with whatever transactions currently exist in the memory pool that are not yet in a block.
The race starts as soon as the previous block is received. This means that the person who computed the previous block actually has a very slight headstart on the new block, and the last person to hear about the recently completed block has lost some time that they could have been working on the new block. This acts as an incentive for miners and pools to attempt to be well connected to many fast nodes, allowing them to hear about any solved block as soon as possible. Additionally, if someone else solves and broadcasts a block before you can broadcast your own solved block, each node on the network will choose the first valid block that it hears about, adding further incentive to a miner to be well connected to propagate any block they solve as fast as possible, and eliminating the incentive to hold on to the current solved block while getting a head start on the next block.
Not sure what you are saying here. The receipt of a new valid block is the signal to immediately begin working on the next block. The time interval to find a block is random, but the target hash value is such that the long term average works out to be about 10 minutes per block. The last means we still have to send the info to the to all nodes and whoever gets it first can peek before others get it and start first so I don't think that is the case. Now that I said that number two is out because we still have to signal all nodes and set some time to start computing that is fair. (two generals paradox?http://en.wikipedia.org/wiki/Two_Generals%27_Problem (http://en.wikipedia.org/wiki/Two_Generals%27_Problem)) Receipt of a completed block is a signal to start working on the next block. If you don't receive the current completed block, then you continue to work on the wrong block. Eventually when your communications improves, you hear about the recently completed block from a peer, and give up on the one you were working on and move to the next. Every node already has all the information it needs to work on a block. It needs to know what the hash value was of the most recently completed block, and it needs a list of transactions in its memory pool that it can put into the next block that it works on. So either there is a set size when someone can start and thus who ever makes the most transactions ( + received possible transactions) has the edge to getting to start the next block, or I haven't thought of something. There is no set size. As a matter of fact, it is entirely valid to create a block that has ONLY the one transaction that pays the block subsidy to the miner and no other transactions at all. If the node happens to have some transactions in the memory pool, then this is a foolish thing to do, since you would be passing up on the opportunity to collect the transaction fees from those transactions. Hopefully my last few questions... Every node generates the new target independently. Since they are all working from the same blockchain as the input to their calculations, they all compute the same target. Is the following link enough detail to answer your question, or would you prefer a link to the actual function that runs in every node?- So how exactly is the new target hash generated between the nodes, is there a technical page I could read? https://en.bitcoin.it/wiki/Difficulty Quote The difficulty is adjusted every 2016 blocks based on the time it took to find the previous 2016 blocks. At the desired rate of one block each 10 minutes, 2016 blocks would take exactly two weeks to find. If the previous 2016 blocks took more than two weeks to find, the difficulty is reduced. If they took less than two weeks, the difficulty is increased. The change in difficulty is in proportion to the amount of time over or under two weeks the previous 2016 blocks took to find. - And how exactly does "The software running on every node and every miner compares the hash to the expected difficulty that they have independently calculated based on the publicly available blocks that are currently part of the blockchain", again any technical pages you know? The answer to this is the same as the previous question.Title: Re: Newbie Trying to understand the mining calculation process. Post by: skeeterskeeter on February 11, 2013, 11:55:55 PM Last question for the day!
So if the current pool I am in has a combined hashrate of 2000GH/s and the current difficulty is 3275464.5865656 then it will take an average of (from the bitcoin difficulty wiki) time = difficulty * 2^32 / hashrate = 3275464.5865656 * 2^32 / 2147483648000 = 6550 This is in minutes? Average of 109 hours to find a solution at this rate? I am successfully mining! Hopefully I will get my first bitcoins here soon! If anyone feels generous [1Hbz4VoBfim6CK6c3KFzV397qbp2mGTmnZ] ;) **Shoot me a address Danny and I'll see if I can send you some in the week to come!** Title: Re: Newbie Trying to understand the mining calculation process. Post by: DannyHamilton on February 12, 2013, 12:11:36 AM So if the current pool I am in has a combined hashrate of 2000GH/s and the current difficulty is 3275464.5865656 then it will take an average of I could be mistaken, but I believe that is in seconds.(from the bitcoin difficulty wiki) time = difficulty * 2^32 / hashrate = 3275464.5865656 * 2^32 / 2147483648000 = 6550 This is in minutes? Average of 109 hours to find a solution at this rate? So, 6550/60 = approximately 109 minutes, and 109/60 = approximately 1.8 hours. |