Blockchain is not only a chain of blocks.
The simplest explication for blockchain is perhaps to imagine pieces of information get bundled into blocks, then these blocks are chained together in a particular way to form a blockchain. However such a simplistic definition of the technology underneath had led to many misconceptions. On the contrary, thoroughly unraveling the anatomy of blockchain might squander too many details and leave people even more confused. That is why this article aims to give you thorough understanding of blockchain’s fundamentals in the simplest language possible, without going depth into technical details. It explains what blockchain is and what it is not. It also uncovers building blocks of the technology with only enough hints of technical concepts.
Blockchain is an integral system
In order to keep a balance sheet you need at least pencils, papers and a calculator. Then you must keep a log of transactions that happened in the year, and you must be informed of log keeping rules. At the end, you must know how to figure out the balance of incomes and expenditures from information you have in hands. The whole mechanism contains not only the balance sheet, or the accounting ledger, but also norms, conventions, contracts, operations, interactions between tiers.
Blockchain, much like above, is the whole infrastructure which supports record keeping, transaction proceeding, operation processing and guarantees the impartial state of the whole system.
Saying blockchain is a record-keeping technology or a public ledger is much like assuming business is the balance sheet, or math is the calculator.
Blockchain has a state
Blockchain’ state is a snapshot of the whole system at a moment in time. It contains values of information stored in blockchain such as balance of an account, true or false answer, birth date, wedding day etc. These values cannot be modified, instead they can be transitioned from one state to the other. All of the state transitions are recorded and form a log of history of blockchain.
Blockchain history consists of chained blocks
Blockchain history is the log of the system’s states. It is simply a chain of blocks.
Each block can be seen as a Rubik’s cube, where each of its cubies contains a complete piece of information related to certain operation that has just happened and that will affect the whole state of our blockchain. The operation might as well be called a transaction.
If we look closely into a miniature cube (cubie), we can see details of the transaction it contains such as what happened, who participated, when, where and how it happened. The way these small cubies are packed into a Rubik’s cube is particular to each blockchain structure. For example Bitcoin blockchain limits weight (size) of its rubik (total weight of all cubies) to 1MB, or Ethereum limits cost of its rubik (total cost of all cubies) to 800000 gas.
A Rubik’s cube is unique by the way its cubies are bundled together. Each of the small cubies contains a signature which is a string of characters also known as hash. Hashes of upper levels are created from those of lower levels underneath. And hash of the top most level becomes the transaction root of the entire rubik, which is what makes it tamper-proof.
This structure is built upon strong cryptographic algorithms. The most commonly known are Merkle tree and its variations which are used in Bitcoin blockchain, Ethereum and several other blockchain structures.
Once transactions are packed up together within the limit of a block, the rubik will then be formed and digitally signed. The unique signature of a block is called block hash. It is created by combining the block’s transaction root, its previous block’s hash, a timestamp, and a random number called nonce. The process of creating a hash is also known as hashing. Hashing method can vary from one blockchain to another, which defines the level of security that a blockchain offers. The average time to compute a hash is known as hash rate, and it depends on conditions for a hash to be legitimate, such as its length or specific characters it must contain.
It’s worth noting that many people assimilate hashing process to mining process. That is not totally true.
Mining happens when people compete to calculate unique hash of a block, the first person to come up with a legitimate hash will be rewarded with an incentive paid in cryptocurrencies. But mining does not happen on every blockchain. Each blockchain network has a different protocol upon which people agree to delegate next person to produce a new block with a valid hash. It is the consensus of a blockchain. Mining only happens on blockchains of which consensus is Proof of Work (PoW), where hashing is hard because conditions are complex. There exists other system of consensus such as Proof of Stake (proof of ownership, PoS) in Ethereum Casper, or Proof of the Elapsed Time (PoET) in Hyperledger Sawtooth where they do not require mining to get block hashed. Again, the security of blockchain is owed to the consensus used in it.
After being hashed, a block is ready to be strung to existing chain by the person who comes up with the hash. By appending the latest block to the chain, this person modifies the state of his copy of log on his computer or whatever device he uses to produce the hash. He will then have to send the modified copy to everybody in the network. Everybody will have to vote if the block is legitimate in a process called validation. A block with majority of favorable votes will be appended to the chain and the modified state will be broadcasted to everybody for them to apply accordingly. The blockchain is hence transitioned to a new state without losing tracks of its history.
The whole process forms a chain of blocks, which is the log of history of blockchain system. The log is persisted in a file, also called a file-based ledger.
Blockchain is where transactions get executed
A transaction is an operation that modifies the state of blockchain. It might be money transfer as well as any operations to change values in the log.
In order to execute transactions, we need a small little worker called virtual machine. The device where we store our a copy of blockchain’s log and install the virtual machine is called a node. Together all nodes form what we know as peer to peer network. A peer to peer network is a system where a node is connected to several nearest nodes. When there is a change, a peer broadcasts information to its nearest peers, and its peers then continue to propagate changes to the rest of the network.
So the virtual machine works like a tiny little clerk on a node. When it receives a transaction from a peer node, it will execute the transaction locally to verify its legitimacy against current blockchain state. It is similar to running a simulation on your device so that you can tell if the transaction correctly modifies values of the current log. Once the simulation terminates, depending on the result, the virtual machine will label a transaction as valid or rejected. If a transaction is valid, the virtual machine will modify values in its copy of the log accordingly, otherwise it will revert all execution and do not modify the state of blockchain. Invalid transactions therefore do not have any impact on the state of blockchain.
Both valid and rejected transactions will then be included in a block and the virtual machine will start hashing process to sign the block.
Depending on the consensus of the network, a delegated node or a set of nodes or all nodes will carry on the process above to produce a new block.
It is worth noting that it is very inefficient for every one in the network to compete each other to produce the next block in mining process. We don’t know who is working on which transactions and what might be included in the next block, many people will carry on the same hard work just to be rejected by the end. This is why people come up with other consensus algorithm (Proof of Stake, Proof of Elapsed Time etc.) where a set of pending transactions are chosen first hand, then the next person to work on them is selected randomly.
Once a block is stuck to the log chain, all transactions included in it will be marked processed and cannot be replayed. Let’s say, the same transaction X is included in two different blocks being hashed by two different people. The first people comes up with the hash first and get his block strung to the chain. The transaction X is therefore marked as processed in the latest block. If the second person attempt to include it in a new block it will be rejected. This is what we knew as “double spending attack” or “replay attack”.
Blockchain can accommodate smart contracts
Smart contract is what defines how a transaction gets executed, such as how cryptocurrencies are transferred from accounts to accounts, how birth date is registered, how I pay my contractors in order to get my services, how people deliver license plates so on a so forth.
Smart contracts reside inside virtual machine and will be executed upon transaction requests. A smart contract defines how a transaction would modify values stored on the contract itself or elsewhere.
Most of blockchain platforms accommodate smart contracts in its execution environment, but not all. Ethereum and all Hyperledger blockchain projects provides this features since their initiation whereas Bitcoin blockchain only starts to do so.
Block chain may have built-in cryptocurrency
Or it may not.
This is where people get confused the most. Is Bitcoin a blockchain ?
From the title of the white paper written by Satoshi Nakamoto the inventor of Bitcoin:
“Bitcoin: A Peer-to-Peer Electronic Cash System”
So yes, Bitcoin is a blockchain. Bitcoin has a built-in cryptocurrency named after the system itself.
Ethereum also has a built-in cryptocurrency which is Ether. However not all blockchains support built-in cryptocurrencies. This is due to the difference in objective and mission each platform is designed to accomplish.
Bitcoin and Ethereum are built towards a goal of digitizing financial assets and decentralizing financial system. Ethereum has evolved to enable other business operations with it smart contract feature but the vast majority of transactions on Ethereum still revolve around cryptocurrencies.
Hyperledger projects such as Fabric, Sawtooth and Iroha blockchains are designed to enable manifold day to day business operations and activities which often do not require any payment facility.
Blockchain is decentralized
Each peer in the network constitutes a blockchain node, and each keeps a copy of transaction chained logs. When a new record (block) is appended to the log, changes will be broadcasted from peer to peer. Data is synced over the network. Nobody has control over the network and in order to make change, anyone must get their operation approved by the majority of nodes. That is what make blockchain decentralized and incorruptible.
Blockchain is secured
As explained above, transactions are bundled together to form a block in a structure built upon strong cryptographic algorithms. This structure is tamper-proof because a slightest change to one transaction will result in the change of digital signature (hash) of the block. A block’s hash is included in the signature of the next block. If a block’s signature is changed, it will no longer matches the signature of its immediate successor, and so the whole structure would become invalid when passing to execution environment.
Blockchain is infrastructure to decentralized applications
Decentralized applications are built on top of blockchain. They are tied to one or several smart contracts under the hood to provide services to users.
There are more than one blockchain platforms
More than often, people are likely to relate blockchain to either Bitcoin or Ethereum. But there are a handful of other blockchain platforms which have been under active development for years. Some of the most well known open source projects are:
- Hyperledger Fabric
- Hyperledger Iroha
- Hyperledger SawTooth
- Hyperledger Corda
To sum up, blockchain is an integral system supported by 4 pillars :
- a peer to peer network
- a chain or chains of transaction logs
- an execution environment or a virtual machine
- a consensus system or a mechanism upon which peers agree to cooperate.
Blockchain provides secure and reliable mediums and infrastructure for people to cooperate, collaborate, exchange safely.
Information registered on blockchain cannot be changed, instead they are transitioned from state to state.
Blockchain is secured because operations are approved by a pool of million people in the network and its log is tamper-proof.
This article’s goal is to help you understand the most fundamentals of blockchain without technical details of the system. There are many aspects the article does not cover such as security and resilience, privacy and transparency (aka public vs private), impact of consensus mechanism, efficiency and scalability, usability and practicality etc… These topics will soon be covered in dedicated articles.