A guide to Dfinity consensus!

Sahana karki
6 min readMar 11, 2021

Dfinity: Consensus System

We are living in a generation where decentralized mechanisms are ruling the world. A lot of work and research is happening today to make multiple processes decentralized. In our day-to-day life, we come across various hot topics regarding decentralization and its significance like Bitcoin, Ethreum, etc. So I thought of exploring one of them which caught my attention. Dfinity !!

Dfinity provides a decentralized, secure, and tamper-proof cloud-based Internet computer on top of which we can build and operate the software. The major goal of Dfinity is to reduce the time for computation finalization by reducing the block time and by reducing the number of confirmations, improve scalability and keep the time between confirmations constant.

Dfinity’s consensus mechanism has 4 layers:

1. Identity Layer

2. Random Beacon Layer

3.Blockchain Layer

4.Notary Layer

1.Dfinity Consensus Layer

Identity Layer: This layer is responsible for registering the participants with the network and have an identity associated with them. The participants here are called clients. Clients can register themselves with the network using a protocol by providing a stake deposit with a time lock period. Since all the clients have registered themselves, any misconduct by them can lead to loss of the deposit.

Random Beacon Layer:

Before heading towards an understanding of the layer, let us first understand what a beacon is.

A beacon is a function that produces random output r at each interval t.

r ← Beacon(t)

It makes use of an extractor function y = Ext(D) which takes samples from a source of randomness Dₜ and returns an output “ y” which has high entropy.

i.e.

r ← Beacon(t) = Ext(D)

In the above equation “r” is our random output. The beacon’s unpredictable nature of producing unpredictable values at regular intervals that cannot be manipulated by anyone is what makes it indispensable.

NIST hosts a service for providing a beacon that produces random numbers but the use of a trusted third party would be the last thing to do in a decentralized environment. Some protocols use the “commit and reveal” approach to produce random numbers where each party involved will commit a value before revealing the commits and these values are merged together to form the random number. One such protocol is “RANDAO” with a verifiable delay function that has been implemented using Ethereum.

Now that we have a good understanding of what a beacon is, we will go back to our Random beacon layer.

This layer has an underlying verifiable random function(VRF) which produces random unpredictable output. This uses a ‘t’ of ’n’ threshold signature scheme for creating this uniqueness and non-interactivity where n is the set of public keys and ‘t’ out of ’n’ signatures are required for making a group signature and validation. It uses the BLS signature scheme for doing this. Having the threshold mechanism solves the last actor problem where the last actor in a decentralized mechanism with random outputs can guess the next random output and stop the protocol.

Blockchain Layer: This layer has a Probabilistic Slot Protocol(PSP) which allocates ranks to the clients based on the VRF for each height of the chain. The ranks of the clients who propose the block become the weight of the block. Forks can also be resolved using the weight of the block i.e. the heaviest chain in terms of block weight is considered.

The block here is a genesis block or a tuple.

Block B =(p,r,z,d,o)

where

p- hash of the previous block.

r -round number

z- Notarization of the previous block

d-transactions and state

o-owner

Notary Layer: The entire network that is all the nodes should come to a unanimous decision that a transaction has been irreversibly executed. This is called the Finality of a transaction. Notarization is used to fasten the process of finality. Notarization is a threshold signature by all the clients of the network under a block. All the clients only notarize the highest-ranked block and only the notarized block gets included in the chain. There is a major probability of only one block getting notarized in one round. But more than one block can get notarized in one round due to adverse timing which is less likely to happen. That is why notarization doesn’t provide full consensus and finality time and the block time is less compared to other protocols. Notarization doesn’t provide validation but it provides timestamp and proof of publication. This is made to ensure that only blocks created in that particular round get included in the chain.

In case more than one block gets notarized, the clients will build on the heaviest chain in the next round. In the image below since Chain C1 has the highest weight i.e 3.25 than chain C2 with weight 3, the clients will build on the chain C1 since it has the highest weight.

2.Image credits -dfinity whitepaper

Block proposal and notarization should happen within the specified time frame (Block time). After block time if any block is proposed, then it is not considered for notarization. The notarized block becomes final in some time T after which notarization is not done for any block. After that, the notarized block gets accepted by the network.

Threshold Relay:

A subset of clients is picked from the set of registered clients. This subset is known as a committee. The committee will execute the protocol on behalf of all the clients. This committee changes regularly and the next subset of predefined clients becomes the committee and the same process goes on. This process is known as threshold relay.

Consistency and availability:

3.Network Split

Network splits is handled very well in dfinity consensus. If a network splits into two halves of approximately the same size then the random beacon pauses within a few blocks and both the partitions cannot continue. The random beacon resumes when the network reconnects.

4. Network Split

If one partition of the network is larger than the other, the protocol continues in largest part and stops execution in the smaller parts.

And if one or part of the clients disagrees with the network due to a bug or something, then the execution will continue in the network and will only pause in that particular client.

Dfinity consensus mechanism in a nutshell:

Dfiity clients are connected through a peer-to-peer broadcast network where every node can communicate with every other node. So there are 3 roles for the clients participating in the network.

1. Participate in Random beacon.

2. Propose blocks.

3. Participate in the notarization

5.Image credits -dfinity whitepaper

The committee for the next round is chosen in the current round by the random beacon using the threshold relay method.

The random beacon assigns a random rank to every client and the weight of the block depends on the rank of the client. The block proposed by the highest-ranked client has the highest probability of getting notarized and the next set of blocks will be built on top of the notarized block.

6.Image credits -dfinity whitepaper

Here $r is the random output of the round r

Suppose in round r, the random beacon assigns unpredictable ranks to all the clients then the clients collect all the visible transactions, include them in the block and broadcast block to all the notaries for notarization. The notary based on the random beacon picks the highest-ranked block, signs it and broadcasts it again. When a notarized block is visible it is the end of round r. Now the committee signs the random output of round r and the random beacon starts producing ranks for the round r+1 by ending round r.

Thus Dfinity is achieving fast finality with constant block time and also has registered clients and the underlying random beacon which makes it reliable. Hope you liked the blog.

Thanks for reading.

Reference:

https://dfinity.org/pdf-viewer/pdfs/viewer?file=../library/dfinity-consensus.pdf

https://eprint.iacr.org/2015/1015.pdf

http://www.jbonneau.com/doc/BGB17-IEEESB-proof_of_delay_ethereum.pdf

http://www.jbonneau.com/doc/BGB17-IEEESB-proof_of_delay_ethereum.pdf

--

--

Sahana karki
0 Followers

Senior software engineer at Robert Bosch. Passionate about new technologies. Working experience in Blockchain, Full stack development and Quantum computing.