Finance and capital markets
- Bitcoin: What is it?
- Bitcoin: Overview
- Bitcoin: Cryptographic hash functions
- Bitcoin: Digital signatures
- Bitcoin: Transaction records
- Bitcoin: Proof of work
- Bitcoin: Transaction block chains
- Bitcoin: The money supply
- Bitcoin: The security of transaction block chains
The mechanics of a bitcoin transaction block chain, which is a construct that is generated by bitcoin miners and functions as a global ledger for recording and validating bitcoins. Created by Zulfikar Ramzan.
Want to join the conversation?
- At10:40, when breaking a tie between 2 proofs of work, the video says that the transaction chain which wins has the "highest aggregated difficulty associated with that underlying proof-of-work protocol in each of the transaction blocks." But how do you estimate this aggregated difficulty in practice? Can we have more details on that? Thanks!(21 votes)
- That's correct. The smaller the prefix of zeros, the lower the difficulty of solving the puzzle. The way that the proof of work is described in the actual bitcoin documentation is that there is a target value and any hash output smaller than the target satisfies the criteria. It might be possible that the output will have an even larger prefix of zeros compared to the target (it would still satisfy the criteria, though).(20 votes)
- Great series! Could you please expand this part with explanation on how do individual transactions get into a block in relation to the assigned fees? As far as I know there is a relationship between a transaction fee and a place of that transaction in a queue for inclusion in the next block. Understanding this process would give answer to why there should be a fee assigned to a transaction or what are the consequences of not assigning a fee.
- Miners choose what transactions to include in a block. If there is no fee, they have no reason to put the the transaction in the block, so they will probably just throw it away.
They higher fee you give, the more a miner will want to put it in a block, so it will likely be confirmed faster.(19 votes)
- This video seems to have a major flaw. If the block chain only stored the hashes then you wouldn't have any accessible information, hashes are irreversible. The block chain needs to maintain the public ledger in a readable format. How is this done.(15 votes)
- The blocks are still readable. It doesn't only store the hashes. The block also says what transactions are incorporated and where in the tree structure each transaction is.(4 votes)
- I am having trouble wrapping my head around the proof of work. What purpose does this serve? Wouldn't the system work better if individual transactions could be added to the block chain instantly? You wouldn't have to wait ten minutes to purchase a hotdog with bit coins.(7 votes)
- The purpose of proof of work is to make imitation of block chain hard to malefactor. If proof of work was done on the instant time, it would be easy to construct the whole block chain and do the double money spending. So, the speed of new block construction is kept on the same level to make building a block chain a hard computational process.(8 votes)
- 1:15raises a question on the composition of a transaction block at node level. Say a transaction block is of size 5 and Node1 sees transactions 1,2,3,4,5 and Node2 seems transactions 1,2,3,4,6 (instead of '5'). Which block gets injected into the global transaction block chain? What about the transaction that does NOT exist in the chosen block? Also, when multiple nodes are processing this, is it a "winner takes it all" with the other blocks or partial work thrown away (waste of electricity!)?(8 votes)
- The longest chain wins and one block will be orphaned and the miner will lose the reward. The left over transactions will be remined in future blocks. During the hard fork a couple months ago 25 blocks were orphaned and all those block rewards were lost but apparently there was some deal behind the scenes so the compensation got spread around to those that lost out.(4 votes)
- This is interesting. Lets say it takes 10 minutes to find the correct hash value below the given difficulty value (the zeroes at the start of the hash) and the unconfirmed transactions are hashed via the tree structure into the block header which forms part of the end result hash. Doesn't this introduce a delay in processing new transactions ? Once a node starts searching for the correct hash whilst new transactions continue to arrive isn't there a problem with including these new transactions as they would need to be included into the current tree which will change the root hash meaning the whole result would need to be found again. How do real world miners solve this issue ? Do they select a certain number of transactions for inclusion in the block and then start looking for the hash result whilst ignoring the other new incoming transactions and leaving them for the next block or do I misunderstand something here ?(7 votes)
- From what I've read they choose a number of transactions to create a block and the new transactions will stay unprocessed until the a new block is created.(3 votes)
- So the only point of the (challenge, proof) handshake is to prevent spammers and DOS attacks?
What about the weeding out of malicious or just bad-at-math bitcoin miners? Does that depend on multiple miners working on the same transactions? I think i missed something, but not sure what/where.(4 votes)
- No. The point is to prevent any one person from controlling the rules of what transactions get accepted as valid (and in what order). If you imagine a world of malicious bitcoin miners as well as "good" miners (i.e., those that follow the commonly followed rules of including transactions), then we just need to be assured that the total CPU power of "good" miners exceeds that of the malicious miners. So the more nodes mining, the harder it is for a bad actor to reverse transactions or prevent valid transactions from being added to the block chain.(6 votes)
- Is there a protocol for a situation where two different miners manage to find a proof at the exact same time as well as expending the exact same amount of work?
Can the person who is making the transaction set how much fee he is willing to give the miner responsible for adding the transaction? Or is it preset by the network.
If the answer to the above question is yes, then can the miners choose not to incorporate a transaction if they are being given negligible/no fee?(2 votes)
- The sender sets the transaction fee, not the miner. The sender can decide whatever transaction fee he wants to use, as long as it is greater than a minimum fee of 0.0001 BTC /kB if the transaction volume is less than 0.1 BTC. (If the sender tries to make such a transaction, the nodes simply won't relay it, although it is still a valid transaction) The miners can also decide whichever transactions that they are willing to incorporate into their blocks, including rejecting any transactions that give a low fee.
If two miners find a proof at the same time, then both will broadcast the proof at the same time. Some nodes will receive block A first, while other nodes will receive the block B first. Those miners who receive block A first will start working to build the next block on top of block A. The miners who receive block B first will start working to build the next block on top of block B. If the next block is built on top of block A, block A wins. If the next block is built on top of block B, block B wins.(6 votes)
- This peer to peer aspect is a concern to me. I assume my client tracks my Bitcoins and the minors track all transactions. If there is a discrepancy, I seem to have no one to correct it. Is the transaction complete when both parties see a record of it in a minor's log records or is there some minor response to the parties? I would think there would be a vast amount of communications and latency if each transaction is sent to all nodes. It seems like a PC problem could cause a loss of money. How would I recover my correct Bitcoin balance? Thanks!(2 votes)
- If there was a discrepancy, such as a person giving themselves bitcoins out of thin air, then the other nodes would automatically detect it and throw it out. Discrepancies are not allowed.
All transactions are broadcast to everyone. Some people see this might be a problem because of lag or storage space as more and more people use Bitcoin.
A transaction is complete as soon as it is put into a block. There is no need for the receiver to respond or anything like that.(2 votes)
- Who decides, for given block, how much work has to be done as a proof (i.e. who decides the number of leading zeros)?
I am asking because I don't understand how if two miners come up with some proof at the same time, we can choose one of them based on amount of work for the entire chain. Where does the difference come from?(3 votes)
- The one that gets spread through P2P network faster is accepted, the other is wasted. As you imagine, the probability of this event is quite low.(0 votes)
The last really essential or salient piece for understanding the mechanics of how Bitcoins work is what we call the transaction block chain. So if you recall in the previous video, you had a motivating example of a user, Alice, who wanted to send some number of Bitcoins to another user, Bob, in the system. And what Alice has to do to initiate that transaction was to construct a transaction-- a record of sorts-- that contained information about the transaction and that was signed with Alice's signing key. And that actually contained Alice's public verification key and Bob's public verification key as well. And that transaction information was basically broadcast out, as we mentioned, to the entire Bitcoin ecosystem. To all the nodes on the Bitcoin peer-to-peer network. And the various nodes in the Bitcoin ecosystem are going to sit there. They're going to receive information about this transaction. But they're also going to be getting information about a lot of other transactions that are taking place around the same time. And what these notes are going to start doing is they're going to work on incorporating this transaction record into a ledger of all transactions that have ever taken place in the Bitcoin system. And so what happens is that each node basically starts off by taking all of the previously unincorporated transactions that they've ever received. So there's going to be all these transactions out there that have kind of happened within a given time window. And there's all these Bitcoin transactions kind of floating around. And these nodes-- these Bitcoin miners as they're called-- are going to receive information about all these different transactions and they're going to start working on incorporating those transactions. And their first goal is to collate these transactions into what's known as a transaction block. So if you recall our ledger analogy, a single Bitcoin transaction essentially corresponds to a proposed entry in a ledger. In that capacity, a transaction block would basically correspond to her page in a ledger where you have multiple transactions that are listed in that page of the ledger. And the goal-- the Bitcoin miner's goal-- is to really, essentially, to take that page and get it added to the global ledger book, the global comprehensive ledger book. Now to engage in this sort of work, what these nodes will basically do is they'll first take all the transactions that have been broadcast out. And let's say these four transactions have been broadcast out. And they're going to basically hash these transactions in pairs in basically a tree-like structure. They'll take these two transactions and they'll apply a [? graphic ?] hash function to those details. And we'll get a [? cars ?] flying digest, goes the same for these two, and then they'll take these two digests and hash them to get a single digest value. And this digest effectively encodes all of the transactions that were previously unincorporated and that were received by these individual nodes. And then this digest is basically going to be combined with the hash of the transaction block that was previously accepted by the network. So you can imagine if there is-- the network will have a series of transaction blocks that were previously accepted. And in fact, every transaction block as I mentioned just now incorporates the previous transaction lock. So this transaction block will incorporate the one that was used just before it, and this transaction block will incorporate the one that was used just for it. And it's going to go on literally until the beginning of Bitcoin times. So this is really where the Bitcoin-- the beginning of time for the Bitcoin system, this is just time equals zero for Bitcoin. And they're going to take this last block and they're going to, essentially now, take this last block and combine it with this most recent block. And so if you imagine that you have now, not just an individual block, because each individual block incorporates the block before it. We're not dealing anymore with an isolated or distinct block of transactions, but rather with a chain of blocks that starts literally at the beginning of the entire Bitcoin system. Now when you do all of this combination, at the end of the day, you're going to do some cryptographic hashing and you basically will end up with a sequence of numbers. And this sequence of numbers will be derived by incorporating all these blocks together. You'll get a sequence of numbers, and what we're going to basically do is take this sequence of numbers and convert that sequence of numbers into a challenge in a proof of work protocol. Now I did a separate video on proof of protocols, I would encourage you to watch that if you want to get a better sense for how they work. But the short of it is that what the Bitcoin mining node has to do at this point is he'll take that Bitcoin-- he'll take the challenge and he'll have to come up with a separate sequence of numbers-- which we typically termed the proof, or the proof of work-- and this proof of work has to have a very specific mathematical property. And what that property entails is that if you take the challenge numbers, and you take these proof numbers, and you concatenate them together, and you make them the input to a cryptographic hash function, the resulting output has to have a large prefix of zeroes And that doesn't have to be all zeroes, but a large portion of the beginning-- the prefix-- has to be all zeroes And if you think about for a moment, given that cryptographic hash functions, given that their output tends to look fairly random, it's unlikely in any given instance that you are going to see a proof. A proposed proof that provides you with a large string of zeroes at the beginning. And so what the Bitcoin miner will have to do is on average, he'll have to try out many possible choices for these proof numbers until he finally gets lucky and he stumbles upon one that has this kind of off-beat or strange statistical property. And the actual difficulty of finding these proof numbers, as you can tell, is dependent on exactly how many leading zeroes are required. The more leading zeroes you require in this proof, the longer it takes to actually solve a problem. The longer it takes to actually come up with a proof that works with respect to a given challenge. The fewer zeroes that you require, the less time it will take. Now the exact number of bits of zero bits required in the Bitcoin protocol actually does change over time. It gets calibrated. And it's designed to not, on average, the average time taken across the whole system should be about 10 minutes. So you want to take about 10 minutes for at least one node to come up with a valid proof, but keep in mind that a lot of nodes are working on this proof concurrently. All right, now once this proof of work is found, let's say that the proof of work is eventually found. The Bitcoin miner will announce the results to the overall peer-to-peer network. He's going to take this proof and really all the challenge, and so on, and he's going to announce it to all the notes. And they're now going to see that, hey, there's this proof out there, somebody found it. Let's drop the other stuff we were doing and we're going to now start to work and build on top of this new proof. Remember, this new proof of this new challenge, these all incorporate all the previous transaction blocks. Really, what they're starting to do is starting to work off of a new, updated transaction block chain. And they're going to incorporate any new unincorporated transactions into that new transaction blocking. Now there are a couple of points I want to make here. So first of all, as part of constructing these transactions blocks, and really as part of incorporating them into a transaction block chain, Bitcoin miners are actually allowed-- one little special treat-- they are allowed to include in that transaction block-- a special node for themselves. And this node will basically be a little reward if they can get-- and let me use the greenish color for that reward-- they could take the first block, the first transaction item, the first transaction record, and they can put in that transaction record-- they can assign a reward to themselves. Now the amount of that reward will change over time. But I do want to point out what this transaction is typically called is called a coin-based transaction, or a generation transaction. This is how new coins get included in the Bitcoin system. So whenever a minor succeeds in coming up with a proof as part of that he'll have been allowed to come up with his own transaction to reward himself, a special little reward, for extending the effort necessary to come up with this proof and for doing all this work associated with adding a new transaction block to the existing transaction block chain for Bitcoin. And I think that's reasonable. After all these notes are using a lot of computational power to come up with these proofs and if they're using computational power that must mean that somewhere along the line, somebody is spending money on electricity and so on. Now, I also want to point out that in addition to this coin-base award, the nodes who're doing the Bitcoin mining, the ones who succeed. Also get to collect the transaction fees that were specified in the transaction records. If you recall, a person issuing a transaction in Bitcoin can allocate or set aside a certain amount of money-- maybe it can be a Bitcoin or a fractional Bitcoin-- for the node who succeeds in coming up with the actual proof of working, and effectively the node that succeeds in being able to add that transaction to the overall bitcoin transaction block chain. And so that node that does the work succeeds, gets a reward, another transaction fee. Now this could actually become quite large because the node will not only get the transaction fee before one transaction. You'll get the transaction fee for all the transactions that appeared in the current block. It's going to give the aggregate over all these different transactions. Now the second point I want to make is that it might be possible for two nodes to solve the proof of work independently of each other. And somehow, they both end up trying to add to that existing chain in some ways. You make get some weird chain forking happening. If that happens, the peers in the Bitcoin network will basically break a tie by sticking with the longest chain. And by longest, I don't mean the one that has to be the most transactions in it. I really need the one that has the highest aggregate difficulty associated with that underlying proof of work protocol in each of the transaction blocks. And we'll basically look at the total amount of effort that was required to generate that chain with regard to that proof of work. And whichever chain has the most work associated with it is a chain that's sacrosanct, it's a chain that everybody will accept. Now you may get some word discrepancies because of network latency issues and so on. But the idea is that after maybe a couple of rounds when there are ties, they'll quickly resolve themselves as long as most of the nodes are being honest and really stick to the implementation of the protocol. Now since Bitcoin miners are generating bitcoins, I think there's an interesting question that comes up here which is, how is the Bitcoin money supply, controlled, and how is it managed? And I'm going to talk about that concept in a subsequent video.