Hyperledger — Chapter 1 | Blockchain Foundation
This is my learning journal of Hyperledger, the framework to create, deploy and maintain blockchains for businesses. This is gonna be a 10 part series.
By the end of this post, you will understand
- Hyperledger (what & who)
- Distributed Ledger Technology
- Blockchain vs. Distributed Ledger Technology
- Blockchain (Transactions, Blocks, Merkle Tree, Cryptography)
- Smart Contracts
- Consensus Algorithms
- Public Blockchains
- Permissioned vs. Permissionless Blockchains
- Other DLTs
What is Hyperledger?
Hyperledger is the umbrella open source project that the Linux Foundation has created and hosted since 2015. It aims at advancing and promoting cross-industry blockchain technologies to ensure accountability, transparency, and trust among business partners. As a result, Hyperledger makes business network and transactions more efficient.
What is the Linux Foundation?
Linux is the world’s largest and most pervasive open source software project in history. The Linux Foundation is home to Linux creator Linus Torvalds and lead maintainer Greg Kroah-Hartman, and provides a neutral home where Linux kernel development can be protected and accelerated for years to come.
The Linux Foundation is the umbrella organization for many critical open source projects that power corporations today, spanning all industry sectors:
- Big data and analytics: ODPi, R Consortium
- Networking: OpenDaylight, OPNFV
- Embedded: Dronecode, Zephyr
- Web tools: JS Foundation, Node.js
- Cloud computing: Cloud Foundry, Cloud Native Computing Foundation, Open Container Initiative
- Automotive: Automotive Grade Linux
- Security: The Core Infrastructure Initiative
- Blockchain: Hyperledger
We are witnessing the transition from centralized computing, storage, and processing to decentralized architectures and systems. These systems aim to
“give explicit control of digital assets to end-users and remove the need to trust any third-party servers and infrastructure”. — Muneeb Ali
Distributed ledger technology is one of the key innovations making this shift possible.
Distributed Ledger Technology (DLT)
A distributed ledger is a type of data structure which resides across multiple computer devices, generally spread across locations or regions.
Distributed Ledger Technology includes blockchain technologies and smart contracts. While distributed ledgers existed prior to Bitcoin, the Bitcoin blockchain marks the convergence of a host of technologies, including time-stamping of transactions, Peer-to-Peer (P2P) networks, cryptography, and shared computational power, along with a new consensus algorithm.
In summary, distributed ledger technology generally consists of three basic components:
- A data model that captures the current state of the ledger ( a time-stamped series of transactions cryptographically secured)
- A language of transactions that changes the ledger state [Smart Contracts / Chain code]
- A protocol used to build consensus among participants around which transactions will be accepted, and in what order, by the ledger.
Blockchain is a peer-peer distributed ledger forged by consensus, combined with a system for smart contracts and other assistive technologies. — Robert Schwentker (hyperledger.org)
Smart contracts are simply computer programs that execute predefined actions when certain conditions within the system are met.
Consensus refers to a system of ensuring that parties agree to a certain state of the system as the true state.
Difference between Distributed Ledger & Blockchain
Blockchain is a specific form or subset of distributed ledger technologies, which constructs a chronological chain of blocks, hence the name ‘block-chain’.
A block refers to a set of transactions that are bundled together and added to the chain at the same time. In the Bitcoin blockchain, the miner nodes bundle unconfirmed and valid transactions into a block. Each block contains a given number of transactions. In the Bitcoin network, miners must solve a cryptographic challenge to propose the next block. This process is known as ‘proof of work’, and requires significant computing power.
Transactions The record of an event, cryptographically secured with a digital signature, that is verified, ordered, and bundled together into blocks, form the transactions in the blockchain.
Cryptography has a key role to play both in the security, as well as in the immutability of the transactions recorded on blockchains. Cryptography is the study of the techniques used to allow secure communication between different parties and to ensure the authenticity and immutability of the data being communicated. For blockchain technologies, cryptography is used to prove that a transaction was created by the right person. It is also used to link transactions into a block in a tamper-proof way, as well as create the links between blocks, to form a blockchain.
Timestamping is another key feature of blockchain technology. Each block is timestamped, with each new block referring to the previous block. Combined with cryptographic hashes, this timestamped chain of blocks provides an immutable record of all transactions in the network, from the very first (or genesis) block.
A block commonly consists of four pieces of metadata:
- The reference to the previous block
- The proof of work, also known as a nonce
- The timestamp
- The Merkle tree root for the transactions included in this block.
The Merkle tree, also known as a binary hash tree, is a data structure that is used to store hashes of the individual data in large datasets in a way to make the verification of the dataset efficient. It is an anti-tamper mechanism to ensure that the large dataset has not been changed.
Merkle trees are used to summarize all the transactions in a block, producing an overall digital fingerprint of the entire set of transactions, providing a very efficient process to verify whether a transaction is included in a block.
Blockchain also allows us to create an instantaneous single source of truth. In the past, we’ve always had problems with trying to figure out what really happened over the course of a day. Banks reconcile their books, inventory systems clear sales and deliveries…With blockchains, we’re recording things in real time, and it provides us with sort of an up-to-date accounting of the state of the world. — Dave Huseby
Importance of a single source of truth and it being shared with everyone from two people I admire the most.
Boil things down to the fundamental truth - Elon Musk
One of the biggest problems with democracy is that we don’t share a common baseline of facts — Barrack Obama to David Letterman [My Next Guest Needs no introduction]
So we have established that a common base of truth / fact that is shared across the concerned parties will solve a lot of inefficiencies for which we have relied on middle men / institutions for centuries. But, who will oversee / make sure that the facts aren’t tampered with and what goes into the commonly shared ledger and what doesn’t ? Well, your answer is consensus. So a protocol is used to build consensus among participants around which transactions will be accepted, and in what order, by the ledger
Consensus is a process whereby the computers that are part of the network synchronize the data on the blockchain. Consensus in the network refers to the process of achieving agreement among the network participants as to the correct state of data on the system. Consensus leads to all nodes sharing the exact same data. A consensus algorithm, hence, does two things: it ensures that the data on the ledger is the same for all the nodes in the network, and, in turn, prevents malicious actors from manipulating the data. The consensus algorithm varies with different blockchain implementations.
There are a number of consensus mechanisms or algorithms.
- Proof of Work
- Proof of Stake
- Proof of Elapsed Time
- Simplified Byzantine Fault Tolerance
- Practical Byzantine Fault Tolerance (PBFT)
Bitcoin uses Proof of Work, while Ethereum uses Proof of Work currently, but is moving towards Proof of Stake. The Hyperledger Sawtooth uses Proof of Elapsed Time. Zilica uses PBFT.
Different Algorithms for Consensus
Decision Metrics of Consensus Algorithms
Comparative Analysis of Consensus Algorithms
Blockchain type — Blockchain type indicates the type of blockchain platform — permissioned or permissionless, in which the consensus model can be used.
Transaction finality — Transaction finality indicates whether the transaction once added to a block in the blockchain is considered final.
Transaction rate — Transaction rate is higher with platforms that can confirm transactions immediately and reach consensus fast.
Token needed? — A cryptographic token is inherently required for PoW and PoS models as their design itself is based on existence of the token.
Cost of participation — PoW and PoS have an inherent cost associated for participation in consensus. PoW requires expending energy, which is a resource that is external to the consensus protocol, while PoS requires nodes to buy some initial cryptocurrency to generate a security deposit for declaring interest and bonding with the platform.
Scalability of peer network — Scalability of the consensus models is its ability to reach consensus when number of peering nodes are constantly increasing. All models summarized above, except BFT and variants, have high scalability.
Trust model — Trust model determines if the nodes participating in the consensus have to be known or trusted. In PoW, PoS and PoET, nodes can be untrusted as the mechanism to reach consensus is based on other means such as computational work or security deposits.
Adversary tolerance — The fraction of the network that can be compromised without the consensus being affected. Each consensus model has a certain threshold to adversary tolerance.
Now that we know that consensus algorithms are used to drive distributed consensus with out a centralized authority or human intervention. How do make sure the data isn’t tampered with ? Read along.
The Immutability of the Data
The immutability of the data which sits on the blockchain is perhaps the most powerful and convincing reason to deploy blockchain-based solutions for a variety of socio-economic processes which are currently recorded on centralized servers.
This immutability, or ‘unchanging over time’ feature makes the blockchain useful for accounting, financial transactions, identity management, and asset ownership, management and transfer, just to name a few examples.
Once a transaction is written onto the blockchain, no one can change it, or, at least, it would be extremely difficult to change it.
According to Antony Lewis, the Director of Research at R3,
“When people say that blockchains are immutable, they don’t mean that the data can’t be changed, they mean it is extremely hard to change without collusion, and if you try, it’s extremely easy to detect the attempt.”
Now that we know blockchain / distributed ledger is the way to store facts and consensus algorithms are used to drive agreements of what goes into the ledger and in what order how do we actually do it? Through smart contracts!
Back in 1996, a man named Nick Szabo coined the term ‘smart contract’. Smart contracts are simply computer programs that execute predefined actions when certain conditions within the system are met. Smart contracts provide the language of transactions that allow the ledger state to be modified. They can facilitate the exchange and transfer of anything of value (e.g. shares, money, content, property).
* The data model for a DLT (Distributed Ledger Technology) is a version of Blockchain
. Transactions make a block
. Block has the reference to the previous block, The proof of work, also known as a nonce (consensus parameter), The timestamp, The Merkle tree root for the transactions included in this block.
. A cryptographically secured chain of blocks is blockchain
* A protocol used to build consensus among participants around which transactions will be accepted, and in what order, by the ledger is called consensus. Various consensus algorithms are available and you choose what's best for your solution based on certain parameters defined above.
* Smart contracts - A language of transactions that changes the ledger state
Now, you might wonder if blockchain is just a database …read on to find the differences
Blockchain vs. Databases
A blockchain is a write-only data structure, where new entries get appended onto the end of the ledger. Every new block gets appended to the block chain by linking to the previous block’s ‘hash’. There are no administrator permissions within a blockchain that allow editing or deleting of data.
In a relational database, data can be easily modified or deleted. Typically, there are database administrators who may make changes to any part of the data and/or its structure. Additionally, blockchains were designed for decentralized applications, whereas relational databases, in general, were originally designed for centralized applications, where a single entity controls the data.
Types of Blockchain
- Permissionless Blockchain (like Bitcoin or Ethereum)
- Permissioned Blockchain (like the different Hyperledger blockchain frameworks).
A Permissionless blockchain is also known as a public blockchain, because anyone can join the network.
A permissioned blockchain, or private blockchain, requires pre-verification of the participating parties within the network, and these parties are usually known to each other.
Permissionless blockchain examples
Discover the world’s most popular Bitcoin wallet. View detailed information and charts on all Bitcoin transactions and…blockchain.info
Genesis Block of Bitcoin [50 BTC transferred on Jan 3 2009]
Bitcoin Block Explorer is a web tool that provides detailed information about Bitcoin blocks, addresses, and…blockexplorer.com
Few interesting Bitcoin Transactions:
It happened at block height 170, the very first bitcoin transaction ever. This transaction was between the late Hal Finney and Satoshi Nakamoto. Finney was a computer scientist, inventor of reusable-proof-of-work (RPOW), a bitcoin pioneer, and also the first recipient of bitcoin via this transaction.
In retrospect, this was quite a monumental transaction, and it also resulted in the most expensive pizzas ever. A user of the BitcoinTalk forum wanted to order two pizzas and was asking if anyone could order it to be delivered to him in exchange for 10,000 bitcoins. The value at the time of the transaction was around $25 USD. Today, that amount in bitcoin is worth over $6.3 million. Every year since that transaction, the bitcoin community remembers this event by celebrating Bitcoin Pizza Day on May 22nd. Images of the famous pizza here
When bitcoin exchange Mt.Gox was struggling to stay afloat prior to their infamous collapse, then CEO Mark Karpeles wanted to prove that Mt.Gox was financially sound. To do so, he performed one of the biggest and most risky bitcoin transactions ever. The transaction was from Mt.Gox to Mt.Gox, but regardless it was sent over the bitcoin network to the tune of 442,000 bitcoins. The value now is in the neighborhood of $282.2 million USD.
-Programmable Blockchain with a Turing complete language, solidity.
Genesis Block of Ethereum [5 ethers transferred on 30-July-2015]
Till now, we have talked about blocks, a chain of blocks, writing on to the blockchains, driving consensus but how does it become a network ?
Every node / computer that has the distributed ledger is considered a node and a network of such computers / nodes form a network.
Architecture [Client-Server vs. Peer — Peer]
Historically, most applications utilize a central server (or servers). For one user/client to send a message to another user/client in the network, the request has to be sent to the hub or a central server, which then directs it to the right computer.
Peer-to-peer (P2P) networks were first made popular by Napster (and later BitTorrent) and consist of computer systems which are directly connected to each other via the Internet, without a central server. Peers contribute to the computing power and storage that is required for the upkeep of the network. P2P networks are generally considered to be more secure than centralized networks, as they do not have a single point of attack.
Advantages of using a Permissioned Blockchain over a Permissionless (Public) Blockchain
If you look at permissionless blockchains, like the Bitcoin blockchain or the Ethereum blockchain, anyone can join the network, as well as write and read transactions. The actors in the system are not known, which means there could be some malicious actors within the network.
Hyperledger reduces these security risks and ensures that only the parties that want to transact are the ones that are part of the transaction and, rather than displaying the record of the transactions to the whole network, they remain visible only to the parties involved. So, Hyperledger provides all the capabilities of the blockchain architecture — data privacy, information sharing, immutability, with a full stack of security protocols — all for the enterprise.
- Chain Core, created by chain.com, has initially been designed for financial service institutions, and for things like securities, bonds, and currencies. Their company has strong ties with Visa, Citigroup, and Nasdaq. “The operation of the network is governed by a designated set of entities known as a federation”
- The Corda distributed ledger platform is designed to record, manage, and automate legal agreements between businesses. It was created by the R3 company, which is a consortium of over a hundred global financial institutions. “”Corda achieves consensus between firms at the level of individual deals, not the level of the system”
- Quorum is a permissioned implementation of Ethereum, which supports data privacy. Quorum achieves this data privacy through allowing data visibility on need-to-know basis by a voting-based consensus algorithm. Interestingly, Quorum was created and open sourced by JPMorgan. “ The platform is designed to support both transaction-level privacy and network-wide transparency”
- IOTA: “It is the first cryptocurrency that provides the whole ecosystem based on blockless blockchain” to enable machine-to-machine (M2M) transactions. IOTA, however, is more than just a cryptocurrency. Essentially, the platform entails a generalization of the blockchain protocol (the technology called Tangle) that sits at the backend of the IOTA platform. Instead of paying miners to validate the transactions, the architecture of the network involves peer-based validation. Think of a simple analogy, that of a teacher grading students’ homework: the students are the clients/users in the Bitcoin protocol, and the teacher is the miner/validator. Tangle technology asks students (users) to grade each other’s homework, making the need for a teacher (external validator) redundant, and avoiding expenses related to the teacher’s/validator’s work. This allows the platform to be completely free of cost, without facing the scaling challenges that are inherent in the first generation of blockchains. Additionally, the use of the platform with connected devices or the Internet of Things “enables companies to explore new business-to-business models by making every technological resource a potential service to be traded on an open market in real time, with no fees”.
Now that we have a basic understanding of the foundational concepts we’ll move on to Hyperledger projects in the next chapters.
This is a 10 part series so ☞ Please tap or click “♥︎” to help to recommend this article to others.
Moses Sam Paul