What The H*** Is Blockchain?

By Pedro Fiuza Linhares on ALTCOIN MAGAZINE

Pedro Fiuza Linhares
The Dark Side
Published in
6 min readAug 18, 2019

--

(Also available in Portuguese — Também disponível em português!)

Ok, so, there is this new technology everyone seems to be hyped about called Blockchain… Something that has to do with Bitcoin, right? After all, what is so glamorous about a reversed linked list?

Bitcoin uses blockchain technology (img. source: https://www.needpix.com/photo/download/1269388/bitcoin-crypto-currency-currency-money-cash-and-cash-equivalents-buy-pay-accepted-allows)

Well… maybe it is an oversimplification to call Blockchain a reversed linked list, after all, it is a decentralized reversed linked list! Heck, that is a tongue twister, huh? And that thing has persistence! Wherever that is been persisted at… Once again, oversimplifying it for the reader’s amusement.

TL;DR;

The blockchain is basically a safe, decentralized way to store immutable data or programs, called smart contracts, usually in a public fashion. Its most well-known usage is to store transaction logs for bitcoins and ether, working as a sort of public ledger although the wallet’s owner is anonymized by cryptographic strategies. That said, cryptographic methods can be used to obfuscate the data that a block in a public blockchain holds and private blockchains, with more flexible rules can also be deployed. (See Ethereum and Hyperledger Fabric).

Now for the long and somewhat detailed explanation.

For now on, to understand the article, a reasonable knowledge of computer science is assumed, but I’ll try to keep it comprehensible to the general public. However, beware that each paragraph will dive deeper into the technology up to the details believed to be important to get a general understanding of how the blockchain works and what is it for.

Linked list representation (img. source: https://www.geeksforgeeks.org/data-structures/linked-list/)

For starters, let’s clarify the comparison with linked lists. In Data Structures 101, every aspiring computer scientist learns about a particular data structure called a linked list, which is a list data structure where each element, apart from its own data, holds a reference to the next element, if one is available.

When looking at a blockchain, you can think of it as a sort of linked list, each block is like an element of that list, but instead of holding references to the next element, each block holds a reference to the previous block.

That said, instead of holding memory references to the next element, each block holds a hash of the previous block as well as a hash of itself (commonly a special one called Merkle Root), by doing so, we can verify that each block’s data is valid by looking at its own hash and the hashes of the previous blocks. That is one of the reasons that makes the blockchain a safe way to persist data that is not going to change or that is not supposed to change, in that sense, the blockchain is a sort of immutable data database. One that shines in the finance world for this very own characteristic. After all, no one wants their transactions to be tampered with, right? (Unless human mistakes are made, or you need some sort of regulation, but that’s for another discussion…)

Those hashes are part of an element of the block called its header, in the block’s header we commonly have those hashes as well as the block’s creation timestamp and a nonce value used by, for example, the Proof of Work (PoW) consensus algorithm, such as the one used by the Bitcoin. Each blockchain implementation can have its own specialized headers, to accommodate extra logic or different consensus algorithms, such as the Proof of Stake (PoS) or Delegated Byzantine Fault Tolerance (dBFT) algorithms, but those seem to be the most common values to find in a block’s header.

A block’s payload is commonly a list of transactions but can be nearly anything, such as programs, or smart contracts as those are called in the blockchain context.

Mesh network topology to illustrate a P2P network (img. source: https://www.comparitech.com/net-admin/network-topologies-advantages-disadvantages/)

Well, but what are those consensus algorithms doing there? As has been said, the blockchain is a decentralized technology, that means it is supposed to run on a peer-to-peer (P2P) network. Similarly to how BitTorrent works, but when new data is going to be added to the blockchain there has to be centralized computation of the block’s hash as there is no way to leverage a public blockchain’s shared computing power without risking the integrity or trust of the data as of my knowledge for this day.

When a node produces some new data to the blockchain, that data gets sent to a shared element called the memory pool, periodically, each node in this P2P network will fetch some data from that pool and engage into a challenge to compute this block’s hash in a way that the hash’s value matches a predefined rule (that’s what the nonce value is used for, to mutate that hash).

The first node to complete this challenge sends its response to the other nodes in the network, which validate it and then add it to its own reference of the blockchain, therefore, all the nodes have all the data from the blockchain.

As the new block is added, the data that was in the block gets removed from the memory pool, and every other node discards the data they had fetched and fetches new data arrangements from the memory pool.

Its worth noting that since the information is stored in every node of the chain, the loss of a node is pretty much negligible and that when a node is joining or rejoining the blockchain, it must download the whole chain before it can mine, that mining process was what has just been described, this whole challenge to compute the hash thing.

In most blockchain implementations, the one to “win” the mining challenge gets rewarded a fraction of the block’s transaction’s value, some bitcoin or ether, for example, that is an incentive to stay in the blockchain as a miner.

All these processes make the blockchain technology what it is. A technology to arrange a network of create and read-only database nodes (no update or delete) where all of the nodes have to enforce policies not to tamper with the data, and all the of the chain’s data is kept in pretty much every node, making it very, very unlikely for any data to be lost or altered.

Blockchain can prove to be very useful for applications that can leverage its characteristics and its usages are not limited to the financial world, although its definitely very well fit that context.

I hope this text can be helpful and useful for everyone interested in general knowledge about how a blockchain works, feel free to respond so that more clarifications and interesting discussions can be brought up. I myself am no expert in this technology although I have some study about it and would appreciate any valuable extra inputs :)

--

--

Pedro Fiuza Linhares
The Dark Side

Computer Engineer, Master’s degree student and a Software Architect