Understanding the Zilliqa Consensus Mechanism | Part-2

Vikram
9 min readFeb 7, 2022

--

In the first part, we saw some theories of consensus and two consensus mechanisms i.e pBFT and Nakamoto Consensus. In this part, we will continue with two more mechanisms (Bitcoin-NG and DPoS) and then finally get into the details of the Zilliqa Consensus Mechanism. Let’s start with Bitcoin-NG.

4.3 Bitcoin-NG

Bitcoin-NG or Bitcoin-Next Generation is an interesting bitcoin scalability solution proposed by Ittay Eyal and Emin Gun Sirer. It is based on the existing bitcoin consensus but with some changes to its chain design. The idea is to use the time delay between the two consecutive blocks are being mined and keep on processing transactions thus increasing tx throughput.

Bitcoin-NG Chain Design

The chain has two kinds of blocks i.e key block and micro block. The mining process and consensus are similar to the bitcoin. The key block here is produced by the mining process similar to the one in the bitcoin network and the miner that successfully mines the block becomes the temporary leader who can mine micro blocks. Micro blocks are blocks that contain a set of transactions processed from the transaction pool. There can be multiple micro blocks mined between two consecutive key blocks.

Some of the interesting projects that are based on this design are Waves and Aeternity. Note that the idea behind the consensus and mining is the same as bitcoin, the only reason we are referring to this protocol is for its new design approach.

4.4 Delegated Proof Of Stake (DPoS)

DPoS short for Delegated Proof of Stake is one of the variants of the proof of stake algorithm that is energy efficient and scales to thousand transactions. PoS in general originated as an energy-efficient alternative to PoW mining where stake refers to coins owned by the network participants and is used to participate in consensus. In this section, we will go into the details of DPoS used in the EOS blockchain.

DPoS is a democratic form of PoS algorithm where the committee of top 21 delegates a.k.a supernodes participates in the consensus process. Anyone can become a delegate but only the top 21 that gathers the most vote from the coin holders are chosen to be a part of the consensus group.

In the group, the consensus on a block happens in a PBFT style algorithm which works very well due to its small fixed group size of 21 nodes. All the nodes take turns in a round-robin fashion and propose blocks. The process is very energy efficient as there is no heavy computation involved and scales very well up to a few thousand transactions as a bulk of tx can be processed into a block and is immediately finalized.

Isn’t that all great, it is energy efficient and scales very well compared to Bitcoin, Ethereum, and even Bitcoin-NG? Actually no. There are a few issues around scalability and decentralization. It scales comparatively but is not enough and if it wants to scale to a few tens of thousand transactions then things get more complicated. Also, being democratic does not always mean decentralization. We need a consensus protocol that scales well but not at the cost of decentralization. In the next section, we will finally go through the Zilliqas design and understand how it achieves scale with strong decentralization.

4.5 Zilliqa Consensus Protocol

Zilliqa is third generation highly scalable blockchain and is the first one in the world to have practically implemented blockchain sharding. Zilliqa has a very interesting and unique design, it uses PoW+pBFT and network sharding to achieve consensus and scale. Zilliqa has a unique two-chain design and makes use of an advanced signature algorithm called Schnorr Signatures. It also has a secure, safe, and lightweight smart contract model which we won’t cover here but you can refer whitepaper for more details.

In the following subsections, we see the components around Zilliqa consensus in more detail and understand the working of Zilliqa. Let’s start with sharding.

4.5.1 Sharding

The word `shard` means a small part of a whole and sharding is to divide something into parts. The idea behind sharding is to partition the whole work into smaller parts and then parallelly operate on each one; think of it as divide and parallel conquer. Sharding is an old concept in computer science that is being used in distributed databases and systems for decades and recently getting a lot of traction as a layer 1 blockchain scalability solution.

Transaction sharding in Zilliqa

In the context of blockchain, sharding can be mainly of two types i.e network sharding and state sharding. In Network sharding (a.k.a transaction sharding), each transaction is processed in a separate shard without sharding the global state while in state sharding the global state is sharded.

Zilliqa uses network sharding where each transaction is assigned to a particular shard. The shard number is identified based on the last bits of the sender’s address. It is the simplest form of sharding but handles double-spending very well as any duplicate transaction sent by the sender will get detected immediately.

4.5.2 DS Committee and Shards

Zilliqa has two kinds of nodes; DS nodes and shard nodes. DS is short for directory service, DS nodes form the DS committee. It is responsible for dividing the network into shards that constitute shard nodes. The selection of DS nodes and shard nodes is done by the PoW mechanism, more of which we will see in the next section.

DS Block #17906 on DEVEX explorer

Blocks are of two types, DS blocks and TX blocks thus having two blockchains. DS blocks form DS blockchain and a DS block is produced per DS epoch. DS blocks contain information about the miners participating in the consensus. TX blocks are of two types, final blocks and micro blocks. Micro blocks are produced by each shard after having a consensus among shard nodes. Each shard further sends micro blocks to the DS committee where the DS committee aggregates the micro blocks and forms a final tx block after having a final consensus among DS committee nodes.

The image above shows DS block #17906, it has 180 in the DS committee while 503, 496, 485 nodes respectively in each of the three shards. For more details, you can go through the DEVEX explorer.

4.5.1 PoW and pBFT Consensus

PoW and pBFT are two powerful consensus algorithms that we saw in the first part. The main advantage of PoW is that it has strong security while pBFT is good with instant consensus finality and is less energy-intensive. Zilliqa makes use of both these algorithms in a very interesting way to form the network and perform consensus. Let’s see how Zilliqa makes use of these in detail.

4.5.1.1 PoW or Proof Of Work

PoW is used in network participation to the DS committees and shards. There are two ethash based PoW namely PoW1 and PoW2 for DS committee and shard respectively. PoW help generates network identity by preventing Sybil attack. In case you don’t know what a Sybil attack is, it's an attack where a malicious actor can fake multiple identities and get some weightage in the system. A good example can a scenario where one address is considered one vote in a network, now as we know it costs nothing to generate new addresses in a blockchain network anyone can create multiple identities and manipulate the decision by voting.

Sybil attack

PoW makes sure that some tangible work is done by the node doing some provable computation to solve a difficult math puzzle. Also note, this math puzzle that we hear all the time is nothing but a simple less than operation on a difficulty threshold and hash of header where both are converted to simple math whole number 😅.

4.5.1.2 PBFT or practical Byzantine Fault Tolerance

PBFT is used for actual consensus on transactions in both the DS committee and the Shards. DS committee does PBFT to output a final block while each shard does it to output Micro blocks. PBFT in Zilliqa is modified and a very efficient version of classical PBFT consensus. The problem or the bottleneck with classical PBFT was with scaling to a few hundred or thousands of nodes and the reason behind it was communication among nodes that has O(n²) complexity.

MAC or Message Authentication Code

Classical PBFT used MAC or message authentication code for authenticating the messages sent by another respective node. Each pair of nodes has a shared secret between them for communication. For example, if we have four nodes A, B, C, and D then each unique pair i.e (A,B) (A,C) (A,D) (B,C) (B,D)(C,D) where (A,B) same as (B,A) has a shared secret between them and that is the reason we have O(n²) complexity.

Schnorr Multi-Signatures

Zilliqa's PBFT improves the complexity by eliminating the MAC authentication technique and replacing them with schnorr multi-signatures. With schnorr multip-signatures no two need to have a shared secret between them and can just use their existing key pair to perform authentication. Multisignature reduces the complexity to O(n) as each node only needs to perform its signature, broadcast the same to the entire network, and don’t have to individually communicate with all other nodes. Schnorr multi-signatures are interesting and let’s see an example to understand them more clearly.

Let’s say we have four nodes A, B, C, and D each with its secret key and respective public key Pa, Pb, Pc, and Pd. Now we have a message M to be signed by all the nodes; so what each node does here is to sign the message M with their respective secret key and broadcast it to the network. Let’s say the message signed by each node was MSa, MSb, MSc, and MSd which is now available to all the nodes in the network that can now combine then i.e perform the simple merge operation (MSa+MSb+MSc+MSd) and form a final signature MSabcd.

Aggregation of Schnorr Public keys

Each node should have the same final signature, which can be verified by a merged public key Pabcd formed by combining the public key of all the nodes. The order does not matter here but what all nodes constitute the final signature is important i.e the message signature signed by nodes A, B, and C can only be verified by the combined signature of A, B, and C. Zilliqa consensus may not need signatures from all nodes so it takes care of this by using a bitmap to maintain a list of the signer where each bit represents a node if a node bit is true that means the node has the contribution to the final signature. This improvement helps Zilliqa to scale the PBFT to a few hundred nodes and also additionally providing security as in a bigger consensus group more byzantine nodes will be needed to manipulate the network.

That was it, hope you all understood the Zilliqa consensus mechanism and other basic theories related to the topic. I tried to simplify things and also kept a few things abstract, incase if you have any feedback, suggestions, or inputs to improve this article feel free to write me on Twitter @NakamotoVikram

--

--