The Chain Files pt 2.

This is a continuation of The Chain Files, a series of essays about blockchain related technologies. For starters, these essays will be focusing on the technical details of Bitcoin and then move into other cryptocurrencies and assets.

Blocks & Header Chains

When transaction data is recorded, it is recorded permanently into what are called blocks. As can be expected, blocks are what make up the blockchain. Each block can be thought of as its own input into a much larger ledger. For example, when Alice sends Bob 15 bitcoin, that transaction is processed by miners and if those transactions are confirmed, they are then recorded to a block. Each block is then organized in a linear sequence over time, this chain of blocks is what makes up the blockchain. As the chain grows longer and longer over time, it becomes much more difficult to reverse any earlier transactions due to Proof-of-Work. 

The main way to identify a block in the blockchain is by using the block header. Block headers are 80 bytes long and calculated by running through the sha256 algorithm twice. The block header hash is not sent through the network but is instead calculated by each node as part of the verification process for each block. Within each block header is the contents of the previous blocks hash. Since changing any input will change the output of the hash, this means that since the header of block 2 contains the hash of block 1's header, block 1's header cannot be changed without breaking the link to block 2. 

Bitcoin requires that that every block header links to the pervious header block which links to the previous header block and so on and so forth until we reach the very first block. This block is called the Genesis block. If a link between a block header and the previous block header cannot be verified, the block is considered invalid and becomes what is known as an orphan block. Because of this, the Proof-of-Work in Bitcoin is cumulative as it builds the chain of blocks connected to the previous block. For example, the Proof-of-Work that is created by the 2nd block header adds to the Proof-of-Work created by the 1st block header. A 3rd block header that links to the 2nd block header then accumulates that Proof-of-Work. These links between blocks are called header chains and are what extend the chain further. Each Bitcoin client looks for the best header chain which is the chain of valid blocks headers that has the greatest amount of cumulative work.

Header chain forks

There are complications that can arise between miners and that is when two miners each create a new and valid header at the same time that both refer to the same header parent. This collision is known as a chain fork and since each header can only refer to one previous header, every Bitcoin miner now needs to choose which of the competing previous headers to use in the next header. When moving onto the next block, the chain that demonstrates the most Proof-of-Work becomes the main chain. It is at this point that the miner who had created the header that loses has wasted their Proof-of-Work and missed out on the bitcoin mining reward.

Short chain forks happen quite a bit in Bitcoin and are usually nothing to worry about. We can take note that much work goes into keeping them from happening to keep the maximum amount of Proof-of-Work added to the headers chain.

Blocks of transactions

Ultimately Bitcoin is a transactional system, although the are no transactions in the block headers. Miners instead collect groups of transactions that are called the block of transactions and then hash them using a specific formula. That hash of the transactions is called a merkle root. The merkle root is included as 32 of the 80 bytes in the block header and together, the block of transactions and their corresponding header are what make up a block. In the previous post, it was pointed out that hashing some input will produce a specific output. So when miners hash the same block of transactions, it will always produce the same hash as the output and proves that the miner chose those particular transactions. And since the block header is protected by Proof-of-Work, it just isn't possible to change and of the transactions that appeared in that block.

As mentioned in the previous paragrah, the hash of the transactions is called a merkle root which is the root hash of what is known as as merkle tree, which is a hash based tree data structure that is a generalization of a hash list. Within the tree structure, each leaf node is a hash of the block of data and each non-leaf node is a hash of it's children. They are primarily used in distributed and peer-to-peer data systems for verification which works out perfectly for the Bitcoin blockchain.

The Bitcoin blockchain is an interesting piece of technology that demands further study and research. From a technical perspective, by combining the power of such data structures and algorithms as the hash function, Proof-of-Work, and the merkle root, we now have a better way to define attribution to digital space. Each transaction is just that, digital space that is located on a block in the ledger. From a more philosophical perspective, we can think of each transaction that takes place as it's own unique digital moment; further proof that an event*** happened at a specific time and there is proof that it took place. Bitcoin itself is more focused on financial transactions which has been a major contributor to its overall security. This is one of the top reasons to study and understand its technical merits.There are other projects focused less on the financial and more on the digital moment. It will be interesting to see how newer projects in the space will build on the technical considerations from Bitcoin and create their own projects that are more focused on the philosophical sense.

*** In this case, we can think of an event in the abstract and it could refer to most anything. A less abstract and more definite way would be to think of an event as something tangible like a digital photo, recorded music, or a piece of art that is assigned to a transaction and can be found in the ledger, easily giving attribution to the owner via their wallet address. 

Want proof I wrote this post? Take this key and decrypt it using Keybase.