Skip to content

Latest commit

 

History

History
998 lines (511 loc) · 132 KB

first draft.md

File metadata and controls

998 lines (511 loc) · 132 KB

Polkadot For Beginners

Book Outline

This is not a technical book. It's a presentation of Polkadot from a layman's perspective, with the goal of giving the community an easy-to-understand book on polkadot that they can read and also share with friends, families, and strangers who are interested in the DotSama ecosystem.

Chapter 0 - The philosophy of decentralization

  1. Lessons from our ancestors--the necessity of centralization

  2. Depressions, censorship, and protests--the dark side of centralization

  3. The only solution?

Chapter 0.5 - The how of decentralization

  1. What is a blockchain?

  2. What is a protocol?

  3. So, how do blockchains actually work?

  4. But what is a block?

  5. So where does the chain come in?

  6. Blockchain participants

  7. The evolution of blockchains

  8. First came Bitcoin

  9. Then along came Ethereum

  10. Rise of the cross-chains

  11. Blockchains and web3, disrupting the web2 landscape

Chapter 1 - Into the Dot

  1. Shared security

  2. Interoperability

  3. Scalability

  4. Forkless upgradability

Chapter 2 - The Network

  1. The relay chain--one chain to secure them all

  2. A BABE and a GRANDPA

Chapter 3 - Securing the Network

  1. The philosophy of staking

  2. Validators

  3. Nominators

  4. Collators

Chapter 4 - Governing the Network

  1. When a Classic left with Cash

  2. Polkadot Governance in 6 Questions and Answers

  3. What is governance used for?

  4. What is the governance structure?

  5. How are decisions made?

  6. What is the life cycle of a proposal?

  7. How are votes calculated?

  8. What happens after a referendum?

  9. Criticisms of Polkadot's governance

  10. It will lead to centralization

  11. It gives bad actors an opportunity to harm the network

  12. It is too complex

  13. "Decentralization means no governance"

  14. Too much reliance of tokens (DOT and KSM)

  15. Something will go wrong

Chapter 0 - The Philosophy of Decentralization

My purpose in this chapter is to explain why decentralization is necessary. Why go through this first? Because there tends to be a misunderstanding amongst some people who are called to the decentralized world. Many come because of profits, believing that this is all the industry is about. To be sure, there are many builders in the space who are focused only on growing their stock in life, and this isn't bad. I mean, everyone is free to do what they want. But. Bitcoin, sitting at a hefty $1+ trillion market capitalization, was created as a reaction against the tyranny and callousness of the financial elite. Vitalik Buterin, the creator of Ethereum, was driven to create Ethereum because of the tyranny of conglomerates. In the famous anecdote, he cried himself to sleep when a game company took all his in-game possessions (the validity of which is somewhat questionable). In both instances, it was about freedom for the individual. Is there money? Sure. But is that the point. No. The point is to lead humanity to a better place---greater individual freedom. If decentralization ever loses sight of this then it will become something else, something closer to an unkillable hydra monster.

Lessons from our ancestors---the necessity of centralization

The terms centralization and decentralization refer to different ways of organizing power, ownership, and authority. Power, ownership, and authority are directly related to security because

  1. He who owns is responsible for the security of what he owns.

  2. He who owns has power and authority over what he owns.

In a centralized system, all three attributes (power, ownership, and authority) flow to and are issued from a center---king, Council, Government, CEO, Management, etc. In this way, the government is a central agent in organizing national affairs while the company is a central agent in organizing business affairs. The centralized mode of organization has served us well for centuries because it was the most effective mode we had for coming together to build civilization. That said, it was not always so. Centralization as we have come to know it began with the invention of farming.

Before farming, our hunter-gatherer ancestors didn't stay in one place nor own many things, and so they naturally didn't need to bother about security the way we currently do. As such, their mode of governance was more decentralized, such that the tribe collectively decided what to do and where to go. But upon finding the benefits of farming, our hunter-gatherer ancestors abandoned their wandering lifestyle for a sedentary one. Now people had farmlands and houses, and naturally, villages with clear borders drawn. With a more stable food supply came a population explosion which brought new problems to light. For one thing, our ancestors had a lot of decisions to make. How were they to share the land? Who would resolve disputes? Who would lead in times of war---in self-defense and in conquest? Imagine a band of soldiers from a rival kingdom coming to conquer a kingdom of 5,000 inhabitants. If the invaded kingdom relied on their old decentralized mode of organization, then they would need to talk for a long time before coming to a conclusion. This would have been incredibly inefficient, leading the kingdom to its capture by their invaders.

Thus, a new mode of organization was needed to match our newfound prosperity and lifestyle. Then began the ascent of centralization as our de facto organizing principle. Centralization was largely possible thanks to specialization---wherein all members of the tribe didn't need to become farmers anymore. Thanks to stable food supply, people could specialize according to their talents and the available tasks. Our ancestors figured out that if some people were charged with leading---arguing about the right way forward and making decisions---the community would be more efficient in the use of its resources. Also, there would be someone to go to when issues arose amongst the tribe. Understand what was really happening here. The community decided to cede their power, ownership, and authority to a center (King, Council, etc.) for the benefit of greater efficiency. This mode of organization served us well for centuries, helping bootstrap civilization and building it to its current height.

Depressions, censorship, and protests---the dark side of centralization

The collapse of the US housing market in 2007, which no regulators had predicted, was caused by widespread illusions of safety in abstract investments, which hardly anyone understood. The system remains as complex now as it was then and a similar crisis could happen again. Maybe tomorrow.

--- Hans Rosling, Factfulness

As we all know, everything has a dark side. In the case of centralization, we have been exposed to its darkest sides, each time questioning if it can get darker, and always getting a "yes" from reality.

In 2008, the world economy was dragged into a Great Depression by the actions of a few bankers in America. Think about that for a second. The whole world experienced pain and heartache because of a few humans who, in the end, got paid large salaries for their greed and incompetence. [link to source]

A more personal experience for me was during the EndSARS protest in Nigeria. The Nigerian government, using its great central power, forced the banks to block the accounts of people who were helping facilitate the peaceful protests (I know it was peaceful because I was there, I followed it all). The government did this, totally disregarding the part of the constitution that grants free speech. It took Bitcoin and Ethereum to sustain the protest for an extra week before the government killed the protest in the most depressing ways imaginable. It sent the army to the Lekki Tollgate. While there, the army shot live rounds at the protestors, injuring and killing its own citizens who only wanted a better life from their government. Till today, typing this brings tears to my eyes and makes my heart palpitate. That a government can unleash the army on innocent citizens is the highest abuse of centralized power. The great irony here is that the protests were aimed at ending police brutality being dished out to young Nigerians by the rogue police unit called SARS. [link to source]

Or take the case of Facebook, Google, and other web products and services we use. The current web is structured in a way that fosters greater levels of centralization over time because of the data silos generated as a result. Google is so valuable to advertisers not because of anything intrinsic to Google, but rather because of the data Google has access to, data that Google doesn't actually own. Same goes for Instagram and other social media sites we use. Without user data they would be worth far less than they are. These companies take our data and grow billion dollar empires from them without ever paying a dime to the true owners of the data. Further, they can (and do) censor us whenever they want. But worse yet is the xx power their possession of the world's data gives them. This is the reality we live in and we accept it because we've not had alternatives...well, not until Bitcoin came along. But we will get to Bitcoin in a moment. [link to source]

To further understand the dark side of centralization, we need to explore the trifecta---ownership, power, and authority.

Ownership refers to who owns an item. In the case of a country, the land belongs to the government, except in cases where citizens have acquired these lands. But even in those cases, governments can still confiscate the land. Power refers to the ability to take action. Again, in a country, power is distributed across the society, with the larger share belonging to the government (split into hierarchies). Thus, the president has more power than the Vice President because he has the ability to do more than the Vice President. The citizens have power because they can vote and complain (protest).

Authority refers to the ability to control. Naturally, one who has ownership and power also has authority by default. In the current social media space, you don't own anything, not even your account. This is why you can be blocked or suspended. You also don't have power over anything other than to leave if you don't like how things are going. And finally, you have no authority to tell the company what to do, except in a case where a large number of the community is also with you (because companies like to bend to the will of the majority). This is the present state of affairs even with your bank account. The bank can freeze your account for any reason, like losing all your money while gambling in a housing bubble. The government can also force the bank to freeze your account, perhaps due to some tax issues or your undesirable participation in a protest against government ineptitude.

This isn't to say that it's bad for the government or banks to have these powers because the truth is that sometimes this power is put to good use. But most often than not, power is abused. It is just the nature of power that if it is too great, it corrupts. This is one major problem with centralization. It encourages the accumulation of a great deal of power in the hands of only a few people. Naturally, this creates god complexes in some people, turning them into tyrants (where 'tyrant' isn't reserved for only rogue heads of state).

Thus, the imperative to abandon centralization is manyfold:

  1. History has proven to some degree that too much power corrupts [link to source]

  2. Centralization creates simple points of failure, making it easy to take over a system. A perfect illustration of this is the story of Atahuallpa.

Atahuallpa was absolute monarch of the largest and most advanced state in the New World, while Pizarro represented the Holy Roman Emperor Charles V (also known as King Charles I of Spain), monarch of the most powerful state in Europe. Pizarro, leading a ragtag group of 168 Spanish soldiers, was in unfamiliar terrain, ignorant of the local inhabitants, completely out of touch with the nearest Spaniards (1,000 miles to the north in Panama) and far beyond the reach of timely reinforcements. Atahuallpa was in the middle of his own empire of millions of subjects and immediately surrounded by his army of 80,000 soldiers, recently victorious in a war with other Indians. Nevertheless, Pizarro captured Atahuallpa within a few minutes after the two leaders first set eyes on each other. Pizarro proceeded to hold his prisoner for eight months, while extracting history's largest ransom in return for a promise to free him. After the ransom---enough gold to fill a room 22 feet long long by 17 feet wide to a height of over 8 feet---was delivered, Pizarro reneged on his promise and executed Atahuallpa.

Atahuallpa's capture was decisive for the European conquest of the Inca Empire. Although the Spaniards' superior weapons would have assured an ultimate Spanish victory in any case, the capture made the conquest quicker and infinitely easier. Atahuallpa was revered by the Incas as a sungod and exercised absolute authority over his subjects, who obeyed even the orders he issued from captivity. The months until his death gave Pizarro time to dispatch exploring parties unmolested to other parts of the Inca Empire, and to send for reinforcements from Panama. When fighting between Spaniards and Incas finally did commence after Atahuallpa's execution, the Spanish forces were more formidable.

--- Jared Diamond; Guns, Germs, and Steel

  1. Centralization encourages people to abdicate their power and responsibility, inevitably leading to decision-making that marginalizes many in the community.

  2. Centralization creates asymmetries in ownership, power, and authority, putting the fates of the many in the hands of the few.

The only solution?

The only solution to the dark side of centralization is decentralization. Perhaps it's not the only solution, but it's the best option we have currently. Decentralization, at its core, is concerned with the redistribution of power and authority from a few in the center to the community at large. In such a system, no one person or group is lord over the system. This is all that the decentralization movement is all about. This way, the risks, responsibilities, and rewards are shared by everyone. Thus, decentralization's greatest appeal is fairness. It is far better to know that we went down because of our collective action rather than the actions of a few. It is better to know that no one can be silenced for speaking out against injustice, cruelty, corruption, bigotry, etc.  It is better that everyone is financially free to transact with whoever, wherever, and whenever they want.

The philosophy of decentralization is freedom. What kind of freedom is dependent on which decentralized system we are talking about. Bitcoin was created with the goal of financial freedom, to give people the option to untether themselves from an economic machine they were deeply unsatisfied with. Ethereum wanted to offer freedom to developers who wanted to build apps that could change the world---going on to spur the rise of decentralized finance (which has given many people the freedom to do what bankers do) and NFTs (which has given creators a path to artistic freedom unlike anything the art industry has seen in decades). These are just the first two big hitters. It is fully expected that within the next ten years, more decentralized products will make it to market, offering alternatives to the current system.

In summary, the advantages of decentralization are thus:

  1. Greater security because the system cannot be hijacked from the center. For example, if someone hacks Google, they will have access to all the information Google has. Taking it a bit darker. If the president's mind has been hijacked by dark agents (or aliens), the nation won't fall to his newfound foolishness because the system has many heads.

  2. Greater fairness because everyone is involved in decision making and so any catastrophe will have the seal of approval of more than a few.

  3. Better distribution of ownership. A few people should not own everything. It runs counter to the design of life. The lion doesn't own the jungle even though it could kill almost everything in it. If ownership isn't shared, then growth and progress only benefit a few and that is a sad state of affairs that fosters greater inequality.

In the next chapter, we will explore how we get to decentralization.

Chapter 0.5 - The How of Decentralization

We lose thousands of nerve cells every hour, but it has virtually no effect because of the highly distributed nature of all of our mental processes. None of our individual brain cells is all that important---there is no Chief Executive Officer neuron.

--- Ray Kurzweil; The Age of Spiritual Machines

Having understood the necessity, purpose, and advantages of decentralization, we will now explore how we achieve decentralization.

In the past, it was relatively impossible to get many human beings to work together towards a greater goal in a decentralized manner. As already explained, each attempt at organization towards a great goal was facilitated by centralization because it was the only option. But why?

Well, the biggest problem we face when trying to get many people to work together is the question of trust. This is why centralization has been such a big hit for the past few centuries. Centralization circumvented the issue of trust by giving everyone a central party to trust. This is why banks work, their primary purpose being to help us keep track of who has what and who can send what. This is partly also why governments exist, to help us determine who can and should do what. We trust the bank to keep our money safe, the government to keep us safe and facilitate prosperity, the social media company to provide us a service, etc. Thus, when it comes to decentralization, the question becomes, how can you get many people to trust each other?

The short answer is that you can't. The problem of trust is concerned with keeping track of information in a secure way such that no one questions its validity. The centralized solution is to delegate trust to one entity, either via of power, authority, or ownership. But this poses a few risks:

  1. Centralization creates an asymmetry of information that some centralized controllers use to their advantage at the expense of the many. For example, a businessman who learns of a government decision before everyone else because he is friends with a few senators. This positions him to take advantage. Bankers and businesses collude all the time. Government and banks collude. In short, every weak individual in a position of power is incentivized to collude. Where an individual is considered weak if he puts his interests ahead of the collective good.

  2. Centralized information gathering and verification presents a single point of failure. This unfolds in different ways. On the one hand, the centralized servers (computers where the information is stored---bank records, government records, user data, etc.) can be hacked. Because the hacker only has to worry about one point of attack, he is incentivized to break in and steal data. The effort-and-risk to reward ratio is too high. On the other hand, if anything were to ever happen to this one source of information, then it would be lost forever.

So how do we overcome our trust issues and achieve decentralization? Enter the blockchain.

What is a blockchain?

A blockchain is a network of nodes (computers, servers, etc.) that work together in a decentralized (meaning there is no central authority) manner to record and verify information. This information can be anything---transactions, account balances, e.t.c. This information is stored on a global ledger that every member of the network has free access to.

But how do you get many people (nodes) to trust each other? Well, you take trust out of the equation. Or phrased another way, you automate trust, such that each network participant doesn't need to trust other participants, but rather, the protocol. Now things are about to get slightly technical but don't worry, it won't be overwhelming.

What is a protocol?

A protocol is simply a set of instructions that a computer software operates with. It sets the rules of engagement for all participants in a network, such that each participant freely chooses to be a part of the network. Further, and this is the real magic, the protocol (rules of engagement) cannot be altered by any single participant or group of participants. Rather, any update/changes to the protocol can only be carried out when a majority of the network participants agree to this change. Notice that this is distinctly different from a country or company. In each of those scenarios, changes are made in a top-down manner.

Thus, blockchains give every network participant the freedom of choice to join or leave the network, and also the responsibility to steer the network. Collective ownership and leadership is the name of the game. However, note that not all blockchains follow this ethos.

It is possible to trust a protocol because its rules are clear from the beginning. In the case of Bitcoin for example, the protocol states that a block (more on this in a bit) will only be produced when a cryptographic puzzle has been solved and verified by a majority of nodes on the network. As in, no new transactions will be added to the global ledger unless a majority of nodes agree that the transactions are valid. At the creation of this new block, new BTC will be created (minted) as a reward. In summary, that is all the Bitcoin protocol is.

So, how do blockchains actually work?

Blockchains are constantly referred to as a global ledger, and this is true. But saying the blockchain is a ledger can be sometimes misleading in an imaginative sense because there is no ledger-like table for anyone to look at. The term ledger is used only to draw a similarity between a computer process and a human process. Thus, the blockchain is a ledger because it stores information, not because it's an actual ledger like a bank ledger. However, it's helpful to keep this view of a blockchain because it perfectly describes what it does. All I'll do now is try to create a better visual of how this ledger is constructed.

Well, to understand this, let's break the name blockchain into its constituent parts.

Blockchain = blocks on a chain

OR

Blockchain = blocks + chain.

But what is a block?

A block is simply a packet of verified information to be added to the global ledger. Note, a block is rarely ever just a single transaction, but rather many transactions bundled up together. To create a block, valid transactions that have taken place on the network (sending tokens, changing names on a decentralized social media site, swapping tokens, posting a comment, etc.) are compiled and locked together using cryptography. Cryptography is a discipline (just like biology, chemistry, physics, etc.) that is focused on creating strong security by using difficult-to-crack puzzles. The purpose of sealing blocks using cryptography is to avoid future tampering by anyone.

You can imagine a block as a bucket. Every block starts out as an empty bucket. Then end-users make use of the network, filling the bucket with their transactions. When the bucket is full, it is sealed and kept away for future reference. Now it's important to realize that the sealing of the block is only possible when many people (nodes---computers, etc.) agree that the transactions in the block are valid. As in, when it is confirmed that no one has tried to send tokens they don't have or other false actions. Once sealed, a block can't be opened to change any transaction, but it can be referenced to verify data.

So, where does the chain come in?

Well, there are bound to be multiple blocks, right? Seeing as each block can only contain a finite number of transactions. Thus, chaining the blocks becomes necessary so that we can tell the true sequence of the blocks---ie. which blocks come first. The process of chaining isn't so different from block creation itself. I only split it so that you could better understand the process. Each new block grows the chain and makes it more secure. Thus, the only chain that links blocks is cryptography.

Now, on a deeper level, how does a blockchain achieve this level of decentralized security? Well, different blockchains go about it differently, but despite their differences, there are really two main issues to consider in analyzing blockchains.

For a blockchain to do what it does, it needs many computers talking to each other constantly. This is called networking, or if you prefer the more human term, gossiping. This is how data (transactions, verifications, etc.) are transmitted across the network. In short, data is copied from one computer to another until all the computers on the network have this data. Without gossiping, there would be no blockchains as we know it.

The second main component of a blockchain is its consensus mechanism---aka, how the different network participants (nodes---computers, servers, etc.) come to a conclusion on which data is valid and which is false. Naturally, every blockchain has its unique consensus mechanism (unless in situations where a new blockchain was created using the code [protocol] of another blockchain). However, all the different consensus systems can be classified into three main categories.

  1. Proof-of-Work

This is the consensus mechanism of Bitcoin. It involves the computers coming to consensus only when work has been done, where the work is solving a cryptographic puzzle. Whoever solves the cryptographic puzzle first becomes the producer of the block. This method of consensus has come under fire lately for its energy-intensive demands. In such a network, the security of a system is somewhat tied to how difficult the cryptographic puzzle is.

  1. Proof-of-Stake

This method of consensus was invented to overcome the energy shortcomings of POW. It trades computer work and cryptographic puzzles for economic security, such that the security of a system is tied to how much is at stake. This is where the whole idea of staking (more on this later) came from. The logic is simply that if enough economic power backs a system, then it will be near impossible to hijack the system because anyone looking to hijack it will need to spend a lot of money. For example, a POS blockchain that has only $2million in stake is far easier to hijack than a network with $1billion in stake.

  1. Hybrid consensus

Most modern blockchains use a hybrid consensus that combines proof-of-work with proof-of-stake, taking the best of both worlds to create a more secure and energy-efficient network.

Blockchain participants

Security personnel --- These are the people responsible for the security of the network. They are called nodes. Depending on the blockchain, they could be called different things---miners (Bitcoin and Ethereum), validators (Polkadot, Cosmos), nominators, delegators, etc. Regardless of what they are called, their purpose is the same---to secure the network. They do this by recording and verifying transactions in a decentralized manner.

Builders (dApps and blockchains) --- The builders are similar to the founders in the current web2 world. They are mostly programmers who create decentralized applications or newer blockchains to work with.

End users (people who use the services) --- Many people in this category will never need to know about how blockchains work to use them. In fact, the goal of current blockchain innovation is to get the end-user to interact with blockchains without ever realizing it. These are people who use the dapps and services created by the builders.

If the concept of blockchains still seems like a concept, then worry not. We will now explore the history of blockchains, and hopefully you will get more context, and thus, more understanding.

The evolution of blockchains

First came Bitcoin 

Bitcoin changed the game in unbelievable ways. In the old system, if you needed to send money to a friend, you had to go the bank (physically or digitally) and ask them to send your money. In some cases, if you live in some weird societies like mine, you would beg them to do so. Now, this meant a few things. You didn't have full control of your money, and the bank was free to loan your money out to someone and earn interest on it without paying anything to you. Further, they could lose this money through recklessness and be bailed out by the government. Crazy right? It's been happening forever. With Bitcoin, however, for the first time people could transfer digital value (in the form of Bitcoins) to someone else anywhere in the world with no middleman telling them whether they had all the documents required to make the transfer, or the high fees it would cost to send. With Bitcoin, all you had to pay was a little transaction fee and the protocol, not a human being, would make your transfer. If the transfer failed, you would receive your money back. There was no longer any need for middlemen.

There are two ways to think of Bitcoin:

  1. As a digital value transfer system/protocol. 

  2. As a global company owned by all those who have BTC. Unlike traditional companies, anyone can join in the ownership by buying BTC.

Then along came Ethereum 

Ethereum looked at Bitcoin and thought, I could make this bigger.

Taking the base blockchain idea, Ethereum built a platform that allowed for more flexibility of use. Think of it like an open internet that allows any kind of website to be created. In comparison, Bitcoin is an open-internet with only one website/function. 

Ethereum made it possible that many smart contracts (websites, projects, protocols---whatever helps you better understand) could run on the base blockchain. Due to this, any project/website/protocol could be deployed on the blockchain and issue its own native token to users. From this sprung a new subsection of the blockchain ecosystem, dApps (decentralized applications).

Bitcoin = single-purpose blockchain

Ethereum = multi-purpose blockchain

Rise of the cross-chains

Following the smashing success of Ethereum, where success means adoption by more people, many more layer-1 blockchains were created. But what does it mean to be a layer-1? Until now, it wasn't important to make this distinction clear, but seeing as we're close to talking about Polkadot, it's important to understand what the layers mean.

A layer-1 blockchain is similar to a country with sealed borders. Inside this country, information can flow between all participants without the need for trust. Why? Because the country is already running on a trustless constitution, one that's not open to interpretation but is instantly executed. With Ethereum's invention of smart contracts, a layer 1 (country) could have as many sub-protocols (states) running on it, each talking to each other seamlessly. But then, because of the sealed borders, it meant that the layer-1 was in an existence onto itself, with no connection to the outside world.

Now, there is a misconception amongst some early blockchain adopters that a single layer-1 blockchain will be all that's needed for the blockchain industry to fulfill its mission. Most times, this view of the industry is perpetuated by those who have a maximalist approach to life/blockchains. As such, you would find some telling you that anything that isn't Bitcoin is a scam, or that it's not truly decentralized. Others will sing the praises of Ethereum, claiming its far better than Bitcoin, and that because it exists, Bitcoin and every other blockchain after them is unnecessary. Most of these people are either misinformed or are solely concerned with making money on whichever tokens they are holding. The truth of the situation is that the blockchain industry is poised for a multi-chain future, such that each new blockchain brings something new (ideally) to the table that can be leveraged by all the other blockchains. Thus, if there's a blockchain focused on decentralizing finance, and another focused on decentralizing identity, they would be better together than a blockchain who wishes to be all-purpose. Why? Because of scalability. To explain the details of this will require diving into some technical explanations and so I'll skip that for now. The point is, there's no such thing as one blockchain to rule them all. It's like asking which internet company rules the internet. It's a ridiculous suggestion by any stretch of the imagination.

If the reality is multi-chain (many chains working together), and layer-1s are sealed-off countries, how then do you connect these sealed off countries? There are various possible solutions to this problem. The first, pursued by the project Cosmos, is to give every layer-1 the same networking constitution, such that when information needs to move from one chain to another, it's easy because both chains, possessing the same networking constitution, can easily talk to each other via a specialized bridge. Where bridge means literally what it says, a gateway into the other world. This method definitely solves the problem of connecting chains, but it's not the best idea because it breaks a feature that made decentralized finance such a big hit on Ethereum. On Ethereum, smart contracts can make two kinds of interactions with each other:

  1. Send and receive tokens---In this way, two smart contracts can exchange tokens trustlessly, meaning no formal verification is needed.

  2. Initiate actions---a smart contract can do more than send tokens. It can also call another smart contract to carry out a function (or transaction). This is the real magic of composability. It means that different smart contracts can be utilized in a single transaction or application, such that two smart contracts can have multiple conversations without an extra human interaction.

With Cosmos-level inter-chain communication, the only information that can be transferred are tokens. None of the blockchains can tell another blockchain what to do. They can only send tokens to that blockchain and receive tokens back. As such, you can think of this level of communication as somewhat primitive (low-level composability). To get a higher level of composability (similar to that smart contracts enjoy), a lower layer is required. Enter Polkadot.

Polkadot is a Layer-0 protocol that seeks to connect multiple layer-1 blockchains without breaking high-level composability. Thus, each blockchain is able to connect with another blockchain on both the low and high level of composability, sending tokens and also change state (initiate actions). To change the state of a protocol means to initiate a transaction that changes the protocol's state to a new state. For example, a layer-1 blockchain focused on decentralizing finance can change the state of another layer-1 focused on decentralizing identity by requesting for the user information stored on the identity chain. The state is changed because the identity chain needs to carry out a new transaction to fulfill this request. Do you see now that no tokens were exchanged but great value has been provided? Because with this information from the identity chain, the finance chain can make payments to the user if they meet certain criteria. This is just one example, but I assure you, there are a limitless number. This is so because at the core of the blockchain idea is disruption.

Blockchains and web3, disrupting the web2 landscape

The philosophy of blockchains is similar to that of all the technology that has come before it, and that's disruption of the status quo. Unlike with earlier technologies that went about their disruption in a covet manner (almost unknowingly), with blockchains this disruption is so intentional as to be the sole purpose for its existence. This is because the true technological advancement in blockchains is automating trust. Now ask yourself, which human industry doesn't require trust? Everywhere there is a middleman, there is an issue of trust. Thus, blockchains are ripe for the disruption of so many fields. This is also why it's ridiculous to suggest or even imagine that the world needs only one blockchain. Below are some of the industries that are currently under attack.

  • Decentralizing finance

  • Decentralizing digital ownership

  • Decentralizing identity

  • Decentralizing data

  • Decentralizing supply chain

At the core of this disruption is a difference in ethos between the current digital world and the new digital world, where the current world is called web2 and th7e new world is called web3.

First, there was web1, the phase of the internet where we (end users) could only read. This was dominated by emails, newsletters, etc.

Then came web2, the phase where we could read and write. This was dominated by all the social media sites that thrive on user-generated content. In web2, a lot of unintentional exploitation was allowed to run rampant until it grew into a monster that's threatening more inequality and end-user abuse. It is marked by data leaks, user censorship, and user data exploitation to name a few.

From the shortcomings of web2 came web3, the phase where we could read, write, and own. With true digital ownership comes a whole new paradigm that will take a few decades to fully unpack and experience. But, interestingly, the experience of web2 and web3 are very similar for the end-user. It's the builders and security personnel who have a lot more learning to do. For the end-user, the real issue is understanding the ideas underpinning the revolution, as well as how to use wallets. But more important is the familiarity with the advantages and disadvantages of self-custody. More on this later.

What's important to note is the scale of disruption that's available for the taking. Any web2 company you can think of can be organized in a web3 way. Recall that the main difference between web2 and 3 are true ownership and freedom. The question to ask yourself is: which industry can't be reorganized for more fairness and inclusion? It'll be near impossible to find one that works perfectly as is. And this is why blockchain disruption will keep speeding up. But there's a limit to this disruption if every blockchain is an island unto itself.

Thankfully, Polkadot offers a path to maximum disruption and the rest of this book is dedicated to explaining what it is and how it achieves this.

Chapter 1 - Into the Dot

When I first stumbled on Polkadot, I thought I understood it. Like many, I thought it was just another attempt to create a more scalable blockchain and get as many users as possible. But then I took some time and read the whitepaper, watched videos of Gavin Wood explain, read the wiki, and played around within the ecosystem. It soon dawned on me, with each new discovery, that Polkadot was more than just another blockchain.

Many things make Polkadot special but they are impossible to see from the outside. Hell, even some DOT token holders don't know half of what Polkadot is nor aims to do.

Every blockchain network needs to be secure, it's the first goal of all blockchain technology. But to gain security for a new blockchain is not an easy task at all. Security refers both to network security and economic security, which means that:

  • The blokchain is heavily decentralized with few or no high-value attack vectors (like central computers that store sensitive information). This translates to having many miners or validators to verify transactions on the network. If there are too few, they may collude with each other and create false transactions.

  • The blockchain has a large market capitalization to make attacking the network economically difficult. For example, if Uniswap were at a market capitalization (the price per token multiplied by the total number of tokens in circulation) of $15mil. Anyone who can afford to lose $15mil would take control of the network. Also, if one person owns too many tokens, they could crash the price by selling all their tokens at a go and then buying them back when they are cheap, thus manipulating the network.

In summary, it's not easy being a new blockchain. With each new blockchain created, resources are pulled from other blockchain projects. Thus, the expansion of the industry also becomes an undoing in itself. How can we have many blockchains and have the same level of security for all of them? That's the first problem that Polkadot solves.

The second problem concerns interoperability. As I explained in chapter 0.5, DeFi (decentralized finance) grew to such great heights ($50 billion in total value locked in under 15 months), because Ethereum enabled seamless interactions between smart contracts, leading to fascinating new use-cases and a bull cycle (for the investment-minded folks). Think of it this way, each smart contract is a house that can be accessed by all the servants of other houses in the country (blockchain). Thus, if butter were needed by a baker, his servant could run into the cook's house and get the butter without seeking permission. This would naturally be called theft, but because the house is smart, it knows that the butter is being taken by the baker's servant and that it will be returned. This is an overly simplistic illustration of what happens, but it does the job I hope.

Things work better together, and blockchains are no exception to this rule. If you think of each blockchain as an internet service, then it becomes easier to envision. One deals with identity, another with content, the other banking, another gaming, privacy, interoperability, etc. The possibilities become endless, like the current internet. It is irresponsible (given the potential of blockchains) to not take advantage of the possibility of creating richer interactions between different specialized blockchains, and this is where Polkadot comes in.

So, what is Polkadot?

At its core, Polkadot is a proof-of-stake layer-0 blockchain that connects other distributed systems (layer1 blockchains, bridges, private blockchains, etc.) That's all there is to it. Polkadot exists with the goal maximizing scalability, interoperability, and security for all its connected networks. We will consider each feature in turn to see what the problem is and how Polkadot solves it via its system design.

Shared security

To avoid the problem of many chains and splintered security, Polkadot provides a framework where many chains have shared security. What this means is that rather than rely on each layer 1 blockchain to provide its set of validators (to secure the network) and a token with a large enough market capitalization, they can all leverage the security of Polkadot. Meaning that if Polkadot is sitting at a $10billion market cap, then a new layer 1 chain that deploys on polkadot is economically secured by this $10bil. But asides the economic security, the chain will also gain network security from Polkadot's large set of validators.

Interoperability

It is my belief that this is Polkadot's special attribute. We've seen what dApps can do when they can communicate with each other freely. Now imagine what different blockchains can do together. It may be hard to picture it now, but I'm sure it'll get easier once we get to chapter 5 on Parachains. For now, it is just important to know that a large determinant of Polkadot's design is ensuring interoperability between sovereign layer 1 blockchains.

Scalability

Blockchains will never disrupt the old world into greater fairness and inclusion if it doesn't solve the scalability problem. Polkadot's solution is by using sharding, wherein the network runs different transactions in parallel. For example, Ethereum is a single-shard network, meaning that transactions happen one after the other. A user wants to swap tokens, another wants to buy an NFT, and the other wants to run a private computation on health data stored on the blockchain. In a single shard network, all transactions, although very different in type, will be carried out in the same shard. In a multi-sharded network, each transaction will be executed in parallel at their respective shards. In this case, each shard corresponds to a different blockchain, such that DeFi transactions are carried out on the DeFi shard, while NFT transactions are carried out on the NFT shard. Again, this is an overly simplistic description  of what happens, but it should help.

On Polkadot, each layer 1 chain is able to optimize their network design for their use case, thus tackling the problem of scalability with efficient parallel computation (wherein the network is processing different kinds of transactions on different nodes). In this way, a layer 1 chain focused on decentralizing identity will not need the same system design as one which is focused on decentralizing finance. Thus, the network is made more scalable by:

  1. Ensuring that each network is optimized for its use case

  2. Running different transactions in parallel.

You have 1,000 nodes (computers) offering you security by verifying the validity of transactions. In a single shard model, all 1,000 nodes will be running the same transactions. In a 4-shard model, the nodes will be split into four groups of 250 each. Each group of nodes would then process a different type of transaction. For example, group A would process transactions from the identity chain, while group B will process transactions from the finance chain, group C from the governance chain, and group D for the data chain. In this way, we still have 1,000 computers, but we're doing a lot more because of how we've chosen to arrange them.

Forkless upgrades

I lied. Chain Interoperability is a special feature of polkadot, but it's not the only one. This is another. Recall the problem with Ethereum Classic and Bitcoin Cash? They happened because the chain needed a fork to upgrade. A fork, as the name implies, offers a different path for some network participants. It may seem like a desirable feature of a network, but consider for a moment a country that split every time its citizens had a big argument and some people didn't like the outcome of the vote. Each time, the country will get smaller as more people leave, cutting a part of the country away. Of course, given that blockchains are akin to digital nation states, the analogy isn't perfect, but it should help with visualizing the problem. For the long term prosperity of the network, it's imperative that the community have a way to resolve disputes and upgrade the chain without the risk of splintering economic or network security. Thus, polkadot allows for forkless updates. How this is done will be explained in chapter 4. For now, it's enough to know that these are some of the key factors that make Polkadot special. In the next chapter, we will go over the technical design of Polkadot. 

Chapter 2 - The Network

Polkadot is often accused of being complicated, and most times, that's true. That said, all its complexity is built upon a simple technical architecture which consists of only two main parts---relay chain and parachains. The relay chain is the primary network to which the parachains connect to.

This chapter will focus solely on the relay chain. Parachains will be covered in chapter 5.

Relay Chain---one chain to secure them all

To visualize the purpose of the relay chain, imagine a circular pipe to which many other pipes connect to. These connecting pipes could be of any shape and serve any function, so long as they are written in the same code.

The first function of the relay chain is to provide shared security for all the parachains connected to it, as well as interoperability. But to do these impressive things, the relay chain first needs to be as secure as can be. I mean, how can you share security when your security can't be trusted? To understand how the relay chain gets its security guarantees, we need to consider two key aspects of blockchain networks.

Recall that a public blockchain is desired because no one controls the flow of information (whether verification or retrieval). This means that a majority of nodes on the network must agree on the validity of a new block before it is created and connected to the chain of blocks. But how do the nodes come to an agreement on which transactions (data) are valid? Via a process called consensus.

The full details of the relay chain's consensus mechanism will be too technical for this book and so what I offer here is an overly simplified explanation. The current implementation of the polkadot relay chain uses a hybrid consensus mechanism, meaning that it combines proof-of-stake with proof-of-work to get the best of both worlds.

There are two processes to blockchain consensus, namely block production and finality. Block production refers to the process of creating new blocks, while finality refers to the process of verifying and sealing blocks. The polkadot relay chain, like all decentralized blockchain networks, has a few problems it tries to solve using consensus:

  • It needs robustness in the face of collusion by bad actors, such that all it takes is a few good actors to preserve the integrity of the chain.

  • It needs speed of transaction inclusion and verification for scalability

  • It needs network resilience such that it doesn't go down frequently or at all.

  • It needs a high degree of decentralization, such that no group of network participants have control over the network.

To ensure success across the board on these issues, the relay chain uses a BABE and a GRANDPA.

A BABE and a GRANDPA

(Kindly note that, owing to Polkadot's forkless upgradability feature, this consensus mechanism is subject to change in future).

Before I talk about BABE and GRANDPA, I need to explain something about computer protocols.

First, always remember that a blockchain is a protocol. But what is a protocol? A protocol is a set of instructions that a computer software operates with. It is possible to trust a protocol because its rules are clear from the beginning. You can think of a protocol as a set of automated actions that a computer takes.

Now, the vital thing you need to know about protocols is that a protocol can have many protocols and sub-protocols inside it. Such that when we say a blockchain is a protocol, we really mean that a blockchain is a protocol of sub-protocols, with each subprotocol equipped with the ability to have other sub sub protocols inside it. Each subprotocol and sub sub protocol is responsible for a specific task.

Thus, in the case of the polkadot relay chain (which is a protocol), there are various sub protocols and sub sub protocols (and so on). This is how and why we have both BABE and GRANDPA as sub protocols of the relay chain protocol. This understood, we can now get introduced to BABE (some say she's pretty sexy, but that's only from nerds that know how to read code. For us noobs, she's just a BABE, although a powerful one.)

BABE - Blind Assignment for Block Extension

BABE is a sub protocol in the relay chain that coordinates block production. To do this in a secure and decentralized manner, she uses a few cool tricks.

Blind Assignment aka random selection

The first trick up her sleeve is the process of blind assignment. There are two ways to determine which node gets to create the next block---randomly or deterministically. If a node knows ahead of time that it will provide x block, this node has enough time to create fake transactions for inclusion into this block. This would be bad. Thus, BABE chooses the path of randomness. This way, the nodes do not know beforehand which blocks they will produce. The specific mechanism is too technical to elucidate in this book. The important thing to know here is that our BABE selects nodes at random to produce blocks. A reason why I don't want to go into more detail in this book is that rumor has it that she is on her way out. Would be quite unfortunate to spend time simplifying her complexity only to edit it out less than a year later.

Multiple assignments aka creating backups

To assure a greater level of decentralization and truth-seeking, BABE gives different nodes the same block to produce. The purpose of this is that the block will be produced by more than one node, such that if there is conflict between different nodes on the validity of a block, the network of nodes vote for which block is most likely to be valid  (according to already laid-down parameters---remember, it's a protocol). In this way, further decentralized robustness is added to the system. Another good advantage of multiple assignments is that sometimes a node that was chosen to create a block may go offline or have other issues that stop it from creating a block. When this happens, thanks to multiple assignments there is always a secondary block to fall back on. Thus, for every block created, there is the primary block producer as determined by BABE and several secondary block producers.

There are other sub protocols in BABE, but these are the most noteworthy. Anything further will dive into deeply technical territory. For that, I recommend reading the research paper on BABE.

GRANDPA - the finality gadget

Like BABE, GRANDPA is another sub protocol, but unlike the girl, he is focused on finality---verifying that blocks are valid and can't be reverted. In short, where BABE helps the network create blocks in a decentralized manner, GRANDPA helps to finalize blocks in a decentralized manner. It does this by running elections for all the various fork choices.

Because BABE selects different nodes to produce the same block, there is always a question of which block sequence is true. This is because BABE creates a few blocks before GRANDPA comes in. When he does come in, there are different forks of the chain due to the BABE dance. GRANDPA's job is to decide which fork of the chain is the most valid. Wait! So polkadot also has forks? Well, yeah, though the right term for them in this context would be faux-forks. False forks because they are yet to be finalized. Once any fork is finalized, all the others collapse and every node on the network accepts GRANDPA's decision. But how does GRANDPA make his decision and how can we trust him? Well, for one thing, he's a protocol and so he only does what he's been told to do. And what has he been told to do? I'll explain it while avoiding as much technical details as I can.

Upon encountering various forks of the chain, GRANDPA's decision as to which fork will become the chain is guided by:

  1. Connection to the last finalized block---any of the fork options coming from the last finalized block (by GRANDPA) is considered valid enough to remain an option.

  2. Highest number of primary blocks---any of the fork options with the most number of primary blocks is given a higher weight. A primary block is that which is created by the node that was considered the primary node for producing particular block as determined by BABE. Remember that BABE chooses different nodes to create the same block and one node is always primary while the others are dubbed secondary.

Armed with these considerations, GRANDPA chooses whichever block most matches this criteria.

To not get lost in the sea of technical details, remember that the main purpose of BABE and GRANDPA is to offer the relay chain a decentralized mode of achieving consensus and finality, which is just another way of saying security. More decentralization is always favored because, well, decentralization is the name of the game/industry. It ensures that the network is operating on truth and not centralized falsehood. Further, if at all bad actors were to try and manipulate the data on the chain, they will have a near impossible time with it. In this chapter we've spoken about technological security, such that the design of the relay chain protocol fosters greater security. But given that Polkadot is a proof-of-stake system, this is only one side of the equation. There is the question of economic security which we will cover in the next chapter.

Something else about the relay chain that needs to be known is it's minimalism. The relay chain has no smart contract functionality. This is because it is a layer 0. It chooses not to make many assumptions so as to give the projects building on it the ultimate freedom to be whatever they want to be. Further, by staying minimal, it becomes easier to upgrade. If it were more complex then upgrading it in a forkless manner will be difficult. 

Chapter 3 - Securing the Network

Having understood the technical design that facilitates technological security, we turn now to the second consideration for security. How does Polkadot guarantee it economic security? To answer this question, we will dive into staking and the roles available on the network.

The philosophy of staking

Decentralized networks achieve collaboration between many individuals by using the concept of game theory to design a system where there are roles, responsibilities, and incentives which align the actions of all network participants. This is one of the primary reasons why tokens are necessary for many decentralized systems---economic rewards are the ultimate incentive mechanism. For Bitcoin, it is BTC, and for Ethereum, it is ETH. Thus, the strength of a blockchain's security isn't solely determined by the quality of its code but also by the quality of its game theory---the rules that define the participation parameters of the network. For example, all miners on Bitcoin create and verify blocks for a reward of BTC. In a proof-of-work system like Bitcoin, the network roles are few, limited solely to miners. This is because the network only needs nodes, Bitcoins, and users.

In a proof-of-stake system, in addition to nodes, the network needs users who will put up stake to secure the network. Recall that proof-of-stake blockchains rely on both technological security and economic security. This is because the large impact on energy is offset by economics. A proof-of-work blockchain's security is only as strong as the number of nodes securing it whereas a proof-of-stake blockchain's security is dependent on the number of nodes and the value of stake backing the network. Stake is simply economic value. Thus, the process of securing the network in a POS blockchain is called staking. There are two key advantages of POS over POW:

  • POS has far less energy consumption compared with POW. This is vital because of the growing impact of climate change. It is recorded that the seven warmest years in the 1880-2020 climate record have all occurred since 2014.1

  • POS offers greater inclusion of the community in network security, thus achieving greater decentralization. This is because POW tilts the responsibility of network security towards technically savvy people with the means to run a node, which results in increasing levels of centralization over time.

There are three types of participants who stake to secure the Polkadot network---validators, nominators, and collators.

Validators

Validators in Polkadot are like the miners in Bitcoin. They run the nodes that process and verify transactions, create blocks, and store the history of the blockchain. Without them, there would be no network. The key things to note are:

  • They provide the physical infrastructure on which the network runs

  • They have to ensure that they are always online when they need to be (particularly when they are the ones to create a new block).

The process is as simple (and technical) as acquiring the right computer equipment and running the Polkadot code. Once this is deployed, most other things run automatically, with the validator focused more on maintaining his connectivity. For their efforts (economic and physical), the network rewards them with DOT tokens. The total number of validators on the network is an adjustable parameter, in that it changes based on network demand. It started with a few and has now reached 325. The goal is to reach 1,000 validators.

One may look at this number and wonder if this is decentralized enough, especially considering that Bitcoin has over 20,000 miners and Ethereum 1.0 has over 10,000 miners. Well, to understand why 1,000 validators is decentralization enough we need to remember how Polkadot's consensus works. Recall that BABE selects validators at random. By selecting validators at random and keeping the information from them as to who validates what, Polkadot avoids the possibility of collusion or validator tampering. When you add the fact that each block is given to more than one validator, you then see that this becomes more secure.

Now, when it is said that Polkadot will have 1,000 validators, it doesn't mean that there can only be 1,000 people who are validators. Rather, it means that block production and verification will be handled by 1,000 validators at the same time. Every other validator outside of this set will be called a validator candidate (probably wrong, check for verification).

In the end, a low number of validators is useful not only for reducing the energy impact on our environment but also for scalability. If there are 13,000 validators and GRANDPA's code says that to reach finality, 2/3 validators in the active set (those currently participating in network consensus) must agree, then that means every transaction will have to wait for around 7,500 validators to verify the transaction. This will make the network slower than if there were only 200 validators because it's easier for 200 to gossip faster.

The goal of decentralization isn't to have as many validators as possible, but rather, as many network participants as possible. Recall that it's all about ownership, power, and authority. This is why proof-of-stake is a more desirable system. Not many people have the means or mental capacity to run nodes (i.e. become a validator). If the security of the network is only provided by validators or miners, then a large portion of the community won't be able to participate in securing the network. In this way, it would be safe to say that the miners own the network, as they are the only ones tasked with securing it. With proof-of-stake, the average joe who knows nothing about computers or coding can join in securing the network to earn rewards. To be clear, proof-of-work fosters centralization of the system as the network rewards (tokens) are only paid to those securing the network. With POS, more people get rewards and so the power over the network is distributed more broadly. The struggle with POS becomes how to ensure that the staking mechanism fosters greater decentralization and not another kind of centralization. To understand how Polkadot achieves this, let's talk about nominators.

Nominators

If you're reading this book then it's more likely that you are or will be a nominator.  A nominator's role in securing the network is much less technical than a validator's. This is because all a nominator does is to lock their tokens to the relay chain on behalf of validators who do the heavy lifting of running the nodes. Because the bond required to become a validator is high (currently 1.4million DOTs), validators are incentivized to seek support from nominators. Thus, every validator on Polkadot will have many nominators backing them. When rewards are paid to the validator, a portion of those rewards go to the nominators in relation to their stake weight (the number of tokens staked) and the commission percentage set by the validator.

Unlike many POS systems which force a nominator to pick only one validator and bond all their tokens to them, Polkadot uses an advanced mechanism that allows every nominator to choose 16 validators. Recall that not all validators create blocks all the time, and also, the active set of validators is refreshed every era (which is roughly a day on Polkadot).

By choosing 16 validators, the nominator gives themselves higher chances of getting maximum rewards. This is because the relay chain (which you stake your tokens to), has a protocol that optimizes the staking process for all nominators and validators to ensure maximum security. The details of this action are technical and so I offer only a basic summary here.

Maximize nominator participation - the algorithm (protocol) maximizes a nominators participation in consensus by selecting at least one of the nominator's validator for every era. An era is a measure of time in blockchains that is denominated in number of blocks produced. It's like how humans have days. Anyways, when a nominator selects 16 validators, this mechanism ensures that at least one of those sixteen will be in the active set.

Minimize risk of centralization - This is achieved via game theory. It is natural that humans seek that which is most certain. Usually, the most certain always relates with the most popular, such that if many nominators choose one validator, other nominators will be inclined to choose the same validator. This is how centralization occurs because then the validator has more power in the network due to the weight of the stake backing them. In such a scenario, the validator would be able to use their economic power to attack the system. This is bad. To discourage this default behavior of humans, the staking protocol pays out equal rewards to all validators regardless of the weight of stake and number of nominators backing them. When this payment is made to validators with a high stake, only the most staked nominators get rewards, while the others get nothing. The number of nominators who get rewards in such a situation is dynamic and will vary over time. This is intended as a mechanism to force every nominator to constantly review their nominations to ensure that they are getting maximum rewards.

How to nominate

The first step to nominating is to get your DOT tokens. Once done, you choose which interface you would like to nominate with. You can use polkadot.js explorer or the various wallets that are now available, like Fearless wallet, Talisman, and others that are coming. But one key thing to remember is that after you lock your funds for staking, it'll take 28 days for you to get it back if you want to withdraw. As in, from the moment you choose to unstake, it will take 28 days for you to get your tokens back.

To avoid this handicap, you can stake with a third-party that gives you more freedom. Some exchanges (not advised) allow you to withdraw your stake with no delay. The more ideal solution is to use a decentralized version of the same idea. There are projects that give you a new token when you stake your DOT. For example, say you stake your DOT using Acala (more on them later). You will receive LDOT which is short for liquid DOT. The difference between DOT and LDOT is that LDOT earns staking rewards, such that when you go to swap your LDOTs back to DOTs, you will have more DOTs than you did before. But the truly special thing about LDOT is that you can also use it to get other tokens if you're in need of funds without having to wait 28 days.

The real work in nominating is selecting your 16 validators. If you're staking via a third party then you don't need to consider this as the third party (whether centralized or decentralized) will be responsible for choosing the validators. If you're staking on your own, then you need to learn how to select the right validators.

Selecting the right validators

Selecting the right validator is crucial because of the reality of slashing. If you choose a validator who acts maliciously, then you stand a real risk of losing your hard earned tokens. That would be a tragedy. Another reason you want to select the right validators is to maximize your staking rewards. Some validators will earn you more than others and it is your job to maximize your rewards. In selecting the right validators, there are just a few things to consider.

Validator's skin in the game - It's hard for someone to act maliciously or carelessly when they have something to lose. This is also referred to as skin in the game. If a validator doesn't stake any tokens on their behalf then it means that if that validator is slashed, he will lose nothing, with his nominators bearing the full weight of his actions. If he gets rewarded however, he gets to keep some rewards. Thus, it is not advisable to stake on behalf of a validator with no self-stake, unless you trust that they won't act maliciously or be careless about their duties to the relay chain.

Validator's identity - It's hard for someone to act maliciously when their identity is known by everyone on the network. Of course, this isn't going to save you from every wrong validator decision, but it's a reliable rule of thumb to use. People who bring their identity on-chain are more trustworthy than those who don't because their image is on the line. In the case of someone with an on-chain identity, you can reach out to them to find out what's going on. Note however that some shady validators can get slashed and decide to spin up a new validator account with a new identity (probably the same one, only with a few details changed).

Validator's commission - For greater profitability, it is wiser to choose validators with the lowest commissions. A validator with a 50% commission will take 50% of all staking rewards, leaving only 50% for his nominators. One with a 10% commission will take only 10% of nominator's reward. The latter is certainly more profitable than the former.

Validator's slashing history - It's natural to make a decision about a person or entity based on past performance. In the case of validators, you don't want to nominate validators that have had multiple slashes in the past. However, note that sometimes a validator may have a slash that's not entirely their fault. Sometimes, the network runs into problems that causes honest and diligent validators to get slashed.

For more information on the safest way to nominate validators, check out this guide.

Collators

Whereas the validators create and confirm blocks for the relay chain, the collators create and confirm blocks for the parachains. The same mechanisms (BABE and GRANDPA) are at play, only that it relates to the parachain. You can think of collators as the validators of parachains. When Collators on a parachain have come to a consensus on new parachain blocks, they forward these blocks to the relay chain validators for inclusion into the relay chain. In this way, the collators' verified transactions (blocks) are further verified by the validators and added to the relay chain. For the purpose of optimal decentralized security, validators are shuffled between parachains. Say in the first era (spanning x blocks) validators 1, 2, and 3 are assigned to parachain A. This means that the collators of parachain A will forward their transactions to V1, V2, and V3, leaving all the other validators free to verify transactions from other parachains. When these validators are done verifying, they propose these verified transactions to the rest of the validators on the relay chain for further verification before it is added to the relay chain. Remember that most of this is fairly automatic. The validators don't know beforehand which parachain they will validate for. After this first era, V1, V2, and V3 will be rotated away from parachain A, such that a new set of validators will verify transactions for era 2. This strengthens network security by removing the possibility for collusion between collators and validators. Because if in this era there was collusion, then in the next, this collusion will be found out by the honest validators.

TODO - Architectural diagram of validators, nominators, and collators.

  1. National Oceanic and Atmospheric Administration. (2021, January). 2020 was Earth's 2nd-hottest year, just behind 2016.https://www.noaa.gov/news/2020-was-earth-s-2nd-hottest-year-just-behind-2016. Accessed: 2021-08-31.

Chapter 4 - Governing the Network

When a Classic left with the Cash

In 2016, $60million in ETH was stolen in the DAO hack. This is a brief summary of how it happened. A large number of people put their Ethereum tokens into a smart contract to fund the first decentralized autonomous organization. $150 million was raised. Less than three months following the fundraising, the smart contract started getting drained of the funds by a hacker. The community flew into panic mode. Soon enough, a group of white hat hackers emerged, trying to stop the black hat hacker. The details of how the hack occurred will be too technical for this book but a non-technical summary is that the black hat hacker took advantage of a flaw in the smart contract code to start draining funds. Interestingly, he could only drain the funds slowly. Thankfully, before he finished, the white hat hackers found a way to stop the bleeding. But then the white hats made a mistake that eventually put the black hat in a position to go scot free. The only solution was to revert the chain and cancel this theft.

You'd think this was an easy decision to make, but it wasn't exactly so. A few things made it somewhat difficult. First, the network had to figure out a way to poll the users of the Ethereum network on what they thought should be done. You see, in the beginning, it was universally believed that the blockchain was immutable, meaning that whatever happened was never to be reverted because it was sealed by cryptography. But given the fact that $60 million had been stolen, ideals had to confront reality. The reality of the situation was that it was possible to change the information on a blockchain. To be clear, if it wasn't possible, then a chain will never be able to get upgraded. Anyways, two camps were vocal about the situation. On the one hand, majority wanted to erase the stolen tokens by going back a few blocks (before the attack). On the other, blockchain purists wanted the immutability of the blockchain to not be tampered with. In the end, a vote was carried out and 80% of the community voted to erase the hack from Ethereum history. To do this, a fork would have to be created. A fork is simply an update to the blockchain (software) that rewrites the code in a fundamental way. The way it works is that if all the nodes on the network update the same code, they all fork together and the network enters a new state while still being the network. Thus, when the update was carried out, it erased all the blocks from the hack forward. When the update was complete, everyone rejoiced that morality had won and the thief would be left with nothing. Or would he?

It soon became apparent that although the Ethereum network had forked into a new chain history (basically, new blocks were being built on the old blocks before the hack), there were still some nodes who didn't run the new upgrade. Basically, they had chosen to stay on the old Ethereum with the theft still in place. Soon, a new kind of panic set in. Were the nodes doing this intentionally? Could it be the hacker? Attempts were made to reach out to the node operators and, in the end, it was clear that it was an intentional act, though the reasons remain unknown. That old chain which refused to get forked into the new Ethereum with no hack, became known as Ethereum Classic. This is a fun story I recommend you should learn more about in Out of the Ether. The reason why I brought it up is that it illuminates the importance of Polkadot's on-chain governance design in combination with forkless upgrades.

You may wonder what the big deal is with Ethereum forking into Ethereum Classic. Based on the philosophy of decentralization (individual freedom), it makes sense to give every network participant the freedom to choose whether they will fork or not, thus preserving the integrity of the chain. But then it poses other important risks for the community. When those miners exited the Ethereum network by staying on the old chain, the security of Ethereum was compromised on three levels.

  1. Miners (which ensure security) left, leaving the network with fewer miners (this isn't such a deal breaker).

  2. The economic security of ETH was threatened as the price per token went into free fall.

  3. The faith of the community was shaken.

That isn't the only time something like that has happened. It also happened with Bitcoin. On that account, the community got into an argument about how fast Bitcoin needed to be. The technical details of the argument revolved around the block size of Bitcoin. Block size simply specifies how many transactions can fit into a block until it is considered full. If a block is too large, then many more transactions can enter the block, ensuring that more transactions get processed per block. But this could also lead to slower transaction times as it may take quite a while for large block to fill up. Some people wanted the block size increased so that Bitcoin could process many more transactions per block than it was. Others thought that tampering with the Bitcoin protocol was heresy. In the case of this conflict, there were no votes, just action. A portion of the network forked (updated their nodes with the new code that reduced block size) into a new network called Bitcoin Cash. Over the years, Bitcoin has been forked into other versions, each time weakening its security by a little bit.

For Bitcoin and Ethereum, these chain splits may seem like child's play, almost like they have/had no impact on the system, but that would be a flawed way to view the situation. That they made it this far despite the attempts isn't proof that their mode of design is optimal. Rather, it points to a problem inherent in all blockchains. If the code is available for everyone to see and copy, then it is easy to fork. If you fork a network enough times, you splinter its  security until you have little left. How can you avoid weakening the strength of the network and its community? Polkadot's answer is having an on-chain governance process that every participant can trust. Couple this governance process with forkless upgrades and you have a blockchain that can always be updated with some measure of agility. To understand how, let's dive into Polkadot's governance mechanism. This section will flow in a Q&A format.

Governance on Polkadot

  1. What is governance used for on polkadot?

The main purpose of governance in any system is to modify the system parameters, including the base code. In the case of countries, those are new bills and revisions to the constitution. In the case of Polkadot, below are a list of some parameters that can be modified by the on-chain governance mechanism:

  • Update user balances (in the case of theft or lost keys for instance)

  • Update the runtime

  • Change the base code

  • Connect or disconnect parachains

  • Etc.

  1. What is the governance structure?

Polkadot's on-chain governance structure has 3 arms, namely the council, technical committee, and the community (it's called referendum chamber in polkadot's wiki but I think that can create a bit of confusion seeing as the referendum chamber is essentially composed of all DOT holders who are willing to vote).

Council - This is a group of 6 - 24 members who represent the all DOT holders in steering the network. Think of them like the House of Parliament or House of Representatives. Their primary purpose is to make proposals that guide the Polkadot ship towards a bright future.

what can they do?

  • Elect technical committee

  • Make proposals to the community for referendum

  • Veto referenda - in the case that a proposal is deemed harmful to the ecosystem, the council can veto the referendum of that proposal. That said, their veto can be overridden via another public vote.

  • Fast-track referenda - in the case of a technical emergency, the council can fast-track a proposal for public vote.

who can join the council?

Any DOT holder.

how are they selected?

Any DOT holder who wishes to join the council only needs to nominate himself via the governance tab on the polkadot.js dashboard. Like in the validation and nomination aspect of the network (staking), DOT holders can nominate council members to govern the network on their behalf by bonding tokens. As such, any DOT holder willing to become a council member should be willing to canvass for nominators because council members are selected based on the weight of stake behind them.

Every two weeks, an election is held to reshuffle the council members (thus ensuring that randomness combats nepotism). This greatly increases community participation in governance as it encourages passive holders to delegate the power of their DOTS to other members willing to govern the network.

what is the voting mechanism?

Selection of candidates to the council is carried out in the same way that validators are chosen to secure the network in staking. Due to the fact that selections are made based on token-weight, this presents the problem of having the network tilt in favor of whales (users with a large number of DOT). There is no perfect solution to this problem but the Phragrém method which is used by polkadot offers an interesting solution. This method of choosing the active set of council members or validators takes into account the token-weight behind each candidate but doesn't make decision solely based on that. Instead, the method optimizes for the following ideal scenario:

  1. Maximize the total amount at stake (hence, maximum economic security)

  2. Maximize the stake behind the minimally staked validator.

  3. Minimize the variance of the stake in the set (such that there isn't too much of a difference between the highest and lowest staked validators).

Thus, the Phragrém method is always optimizing for the highest degree of security for the network.

Although this doesn't render the reliance on token weight inert, it does a decent job of creating a certain degree of fairness all things being considered. To understand the inner workings of the Phragrém method, I recommend reading this wiki.

Technical committee - The TC is composed of the teams that have successfully implemented or specified either a Polkadot runtime or Polkadot Host. They are tasked with ensuring the smooth functioning of the network.

what can they do?

  • Make proposals to the council

  • They are the only arm with the power to initiate a fast-track proposal---usually in the case of a technical emergency

  • Veto referenda---if a referenda poses a security risk to the polkadot relay chain, the TC can veto the referenda by making a recommendation to the council (who is most likely to agree)

how to join the technical committee?

Teams are added or removed from the Technical Committee via simple majority vote of the Council.

Community - this is composed of all DOT holders. They have three main tasks, or rather, three activities they can participate in:

  1. Nominate council members

  2. Create proposals

  3. Vote on referenda

  4. How are decisions made?

Every implemented decision on Polkadot begins with a proposal. A proposal can be made by any of the three arms of governance, though all technical committee proposals are made via the council. As such, there are two proposal queues: one for community-submitted proposals and the other for council- submitted proposals.

Every voting cycle (28 days), the proposal with the most token-weight behind it enters a referendum. There can only be one proposal per referendum, unless in emergency situations when the technical committee has fast-tracked a proposal. In that scenario, there will be 2 proposals voted on in the same cycle. This is the only exception.

If a proposal from the community queue got voted on last voting cycle, then the top proposal in the council-queue will enter the new voting cycle. This alternation helps ensure that both the community and the council (+technical committee) are heard.

(Create graphic with keynote for this. The referendum process. Two queues. Or not)

  1. What is the life cycle of a proposal?

Every proposal made in the on-chain governance mechanism has one of four states it can exist in depending on certain factors.

Seconded - When a community-member makes a proposal, they must bond some DOTs to the proposal. If the proposal is agreeable to other community members, then they can second the proposal by bonding a portion of their own DOTs, thus increasing the token-weight of the proposal. If more community members bond DOTs to the proposal, then the proposal will rise in the community proposal queue until it becomes number 1, at which point it will enter a new stage.

This same process follows for the Council queue, except that it's only council members that can second a proposal from a council member.

Pending - when a proposal is at the top of the queue. At this point, the proposal only has to wait for its turn to enter the referenda.

Cancelled - if a proposal is deemed a threat to the Polkadot relay chain, then that proposal can be cancelled by a unanimous agreement amongst the technical committee. Further, if such a proposal were to make it to the referendum stage before the severe nature of its threat is realized, then a two-thirds majority of the Council can cancel the referendum. If such a cancellation throws up controversy, then the burden of decision making will be passed to the community.

Interestingly, the protocol itself can cancel a proposal by triggering the root origin functionality. Talk about self-preservation.

The tokens bonded to a cancelled proposal are burnt.

Blacklisted - a proposal that poses a significant enough threat to the system (through error in code) can be blacklisted by the protocol using the root origin functionality. A blacklisted proposal can't be added back to the queue unless it's been edited.

  1. How are votes calculated?

In calculating the votes for a referendum, the on-chain governance mechanism makes use of two concepts that are worth understanding.

Conviction multiplier - This is a key aspect where game theory is implemented in ecosystem design. Given the heavy reliance on proof-of-stake, wherein your opinion is only as valid as what you have to lose, a system to level the playing field for members with fewer dots is vital. This is what the conviction multiplier does. Say there are only two voters in a referenda, G and B.

G votes with 20 DOTS

B votes with 90 DOTS

Naturally, we expect that B will win. But when you bring into play the conviction multiplier, things change.

Voting in Polkadot isn't only based on the number of tokens bonded but also on the duration that the tokens are bonded for.

G votes with 20 DOTS for a lock period of 6 voting cycles

B votes with 90 DOTS for a lock period of 1 voting cycle

A voting cycle is 4 weeks. Each cycle increases your conviction multiplier by a factor of 1. Thus, in the above example, here's what the result will look like.

G = 20 x 6 = 120

B = 90 x 1 = 90

As you can see, despite B's higher DOTs, G won because she had greater conviction and was willing to put her tokens where her heart was. To learn more about this interesting mechanism, read this.

How much the conviction multiplier feature helps to balance the scales between community members with a low amount of DOTs and those with higher amount is yet to be seen, but this is definitely better than nothing.

One key thing to note is that tokens used for voting in referendum or nominating council members cannot be transferred to another account. This is the economic incentive/disincentive to make gaming the system for nefarious purposes costly. However, the DOTs can still be used for staking to validators to earn rewards from block production.

Adjusted Quorum Biasing - Another interesting use of game theory in ecosystem design. Depending on who initiates a proposal, there are three different ways of determining the outcome of the referendum.

Simple majority

If a proposal is submitted with a majority approval from the council, then it needs a simple majority of 'aye' or 'nay' to pass or fail. As in, regardless of voter turnout, majority will carry the vote.

Positive turnout bias

For referendum on community-created proposals, the voting mechanism is biased against passing the proposal. As in, the voting mechanism will rather not pass this proposal unless there is an overwhelming community backing behind it. What this means is that if only few voters turn up, then the proposal will pass only if there is an overwhelming majority voting 'aye'. In such a situation (say only 19% of community members show up to vote), it could take as little as 20% 'nays' to overthrow 80% 'ayes'.

If the turnout increases, then the bias against passing will reduce, such that if 100% of participants participate in the vote, it will require only a simple majority 'yes' to pass.

The main problem this solves is that is protects the ecosystem from nefarious actors who initiate proposals with the hope of benefiting off a low turnout of voters (not mentioning any names here, but they know themselves).

Negative turnout bias

The opposite of positive turnout bias. This is the method used by the mechanism in tallying votes in a referendum for a proposal that was unanimously proposed by the council. As in, wherein all the council members agreed to make a proposal. In this scenario, the mechanism is biased against rejecting the proposal. Thus, the lower the number of voters, the lower the percentage of 'yes' needed to pass the proposal. For example, in a 30% voter turnout, only 30% 'ayes' are needed to overthrow 70% 'nays'. The goal of this is to speed up the technical progress of the network because if the council and technical community unanimously agree on the merits of the proposal then it is safe to assume that this change is in the best interest of the ecosystem. The same can't be said of every community-created proposal hence why the differences in vote counting.

Kindly note that every instance of numbers of voters refers doubly to number of DOT holders and the weight of voting stake.

  1. What happens after a referendum?

If the referendum fails, then nothing happens except to return the DOTs bonded to the proposal to the owners.

If the referendum passes, then a 28-day implementation delay is initiated, at the end of which the protocol will implement the outcome of the referendum on its own. Isn't that crazy (in an interesting way of course)? The protocol will update itself without the need for human guidance or confirmation. This is one of the advantages of on-chain governance as implemented by Polkadot. It's also why it's important to cancel or blacklist proposals. If a proposal isn't written with the right code, then that could create a clusterfuck for the Polkadot ecosystem.

Now, all these major questions considered, I feel the need to add on more section.

In defense of Polkadot's governance mechanism

It's not surprising to find a lot of criticism about Polkadot's on-chain governance process. Most times, these criticisms are more from ignorance than strong opinions about specific issues. Thus, this section covers the most common criticisms and their rebuttals.

  1. It's another form of centralization/it will become centralized

Some people believe that a visible and active governance process is just another form of centralization waiting to happen. In truth, I have this fear too. That said, a governance process isn't the creator of centralization, it is people. Currently, many have this idea that Ethereum is fully decentralized in its decision making and that's somewhat true. But what does the Ethereum foundation do? The fees afforded to the foundation's purse, how is the spending tracked by the community? This isn't to suggest that anything untoward is going on. Far from it. I'm only pointing out the things we take for granted. When it comes to making decisions, consider that it's mainly Vitalik's ideas (and the Ethereum foundation) that steer the ship. When he proposes a new idea, other people take it up and champion it. Some critics point out flaws and the thing is tweaked. Eventually, it is implemented. This is a good process, except it's slow and hard to follow if you're not familiar with the flow. I suppose the same can be said about Polkadot (with Gavin Wood and other original builders sitting on the council), but in this case, you can always verify what happened because everything is on-chain.

If theres a treasury, then how does the community know how it's spent? If there's none, then wouldn't the community benefit from having one? Is there an ethereum or Bitcoin treasury that any community member can apply to in a verifiable way? Note that I don't mean filling a Google form and waiting to hear back from the 'team' (only the team can verify this). I mean, an on-chain treasury where anyone who wishes to support the ecosystem can apply and have this application be seen by everyone else?  But beyond funding, the decision making for many crypto projects is currently centralized under the guise of a foundation. Personally, I'm fine with this. It's hard to imagine that the people who built a system will want to destroy it. This is why we trust founders implicitly. I'm just also open to an on-chain way to going about these things. It's good to know who created a proposal and who voted for it.

In the end, we want a better society, which means one that will still reflect the present one, but with new rules. With blockchain as a tool, we can give a shot at fixing or elevating governance. Many mistakes will be made and lessons learnt, but on the whole, it's far better to try. Point to any human society without some sense of a council and warriors. It's not possible. Everyone can't always be talking and deciding, we are all too very lazy.

  1. It gives bad actors (or novices) an opportunity to cause harm to the network

This is a legitimate concern, and thankfully, it has been considered in the design of the current implementation of Polkadot's governance. For one thing, any bad actor who wishes to destroy the network via governance must be willing to spend a lot of money in DOTs. Remember, we're in crypto and it's all about game theory. Thanks to the proof-of-stake nature of governance, anyone wishing to sway votes towards a negative outcome would have to:

  1. Convince a large number of DOT holders to make a bad decision with their DOTs

OR

  1. Fund their bad decision themselves

Either scenario seems like a big ask, unless the DOT market cap tanks.

In the case of novices making unsound proposals that could hurt the ecosystem, the referenda result process stands as a possible checkmate. Another key checkmate is the root system functionality which enables the Polkadot runtime to protect itself against dangerous code. If a proposal in a referendum is deemed to be malicious by the Polkadot relay chain, it will cancel this proposal and blacklist it. That proposal won't be allowed into the proposal queue unless the erroneous code is fixed. Think about that for a moment. The system is able to defend itself. My mind = blown!

  1. It is too complex for the average joe

This I can fully empathize with. Traditional governance is so complicated they have made school departments out of it, teaching it to us for years just so we "get it."

It is to be expected that a governance process that aims to be decentralized has to incorporate many lessons from political science, history, and game theory into its design. This naturally means that the resulting process will not be 'very simple'. Thus, I would ask anyone who says governance is too complex how much effort he put into understanding it. You don't understand the United States constitution in a blog post or a series of blog posts. At least in the case of Polkadot, all you need to understand are the roles and the processes, not a 4,000 page document and 2 million other pages trying to make sense of it. If you really want to "get it" and participate, then you have to put in some work. The average joe understands what a council is, thus, it won't be too much of a leap to get the rest, if he wanted. Why would you own DOTs and not want to know what you own? If he doesn't know how proposals work, then it's because he doesn't have to---or want to---deal with proposals. Admittedly, a bit more can be done to try and simplify the explanation of the governance process. Also, the Polkadot.JS UI can be quite off-putting for someone who isn't familiar. That said, understanding Polkadot's intricate governance process is still a lot easier than understanding one page of any constitution.

  1. Decentralization means no governance---Ethereum and Bitcoin are doing just fine as they are

This one makes me laugh. The cash brothers---Ethereum cash and Bitcoin cash---are the poster boys for this rebuttal. But I'll move away from them. In what sense is it wise not to have a way to resolve conflict? If you are comfortable with how decisions are made in the Ethereum community, then how can you possibly have a problem with a more verifiable way to see how decisions are made? It boggles my mind whenever I consider it. Every decentralized project, with the exception of Bitcoin, has a foundation. What is a foundation? A group of people trusted with steering the network in the right direction. Do we know how decisions are arrived at? What steps are taken? Not always. We get a blog post here and there explaining, but we don't see a vote. Not saying seeing a vote is necessary. The point is that in the other cases, we put a lot of trust without realizing it. Trust is good, it helps us build great things together. My only problem is why anyone would have an issue with a more open way of facilitating this trust. Mind = boggled!

  1. There is too much reliance on DOT, ensuring that the network is always at the mercy of large holders

This is another legitimate concern I struggled with in the past, but then I really thought about it. To understand, there are a few things we need to consider:

  1. He who has more DOTs has a lot more to lose from governance decisions that negatively impact the ecosystem. Thus, those with the highest number of DOTs are incentivized to make changes only when these changes are what's best for the ecosystem. Would it make sense to change the network in favor of someone with 1DOT as opposed to one who has 100kDOTs? If 100k DOTs leave the ecosystem then it's less secure.

  2. Not all whales are bad. In fact, I'd go out on a limb to say that only few are bad.

  3. Almost every DeFi or DAO project also uses token-weighted voting. It's the best solution we've been able to come up thus far.

  4. If the network isn't going in the direction that you want, you are always free to opt out.

The over reliance on DOT is intended as a way to secure the future of the network. Proof-of-stake is proof-of-stake. Why are we fine with securing (validating) the network using proof-of-stake but worry about using it for governance? What would be a better way to come to a consensus on governance decisions? Perhaps a hybrid method where number of voters is balanced with weight of stake. However, I'm neither a political scientist nor a mathematician so I don't know how effective this would be.

It is also possible that the high token dependence can shift if the community later deems this to be necessary. And that's the beauty of Polkadot's upgradable governance process. Much like countries tend to have many constitutions, each intended as an upgrade over the last one. Of course, sometimes intended upgrades are actual downgrades. But then, let's be positive, eh?

  1. Something will go wrong, one way or another

Some people just have a negative bias. I'm familiar because I do too. I imagine the worst outcomes in nearly every situation. In a moving car, I imagine all the ways the car can crash, with each piece of imagination drawing strong reactions from me. So trust me when I say I have considered the possibility of something unforeseen going on with governance or Polkadot. But you know what? The presence of a governance process still gives me faith because whatever goes wrong, all DOT holders can collectively decide what to do with the network. This is because Polkadot is forever upgradable. But people think because a system is upgradable it will be upgraded indefinitely until it breaks. Like I said, this is a negativity bias in play. Every upgrade is proposed only because it has merits for the ecosystem. If an upgrade splits the community in two and we come to a standstill, then we will have to reconcile or die (metaphorically). If we choose death, then surely what we died for was worth fighting for. In any case, life is death and sacrifice (mistakes) is the price we pay for progress.

All in all, Polkadot's on-chain governance is one of the most robust in the space because it incorporates political science, human psychology, and economic theory into its design and implementation.

One major caveat to note. Everything I've written here is subject to change thanks to the on-chain governance mechanism that allows for the adjustment of pretty much any system parameter. Isn't that a good thing? Especially if there are some wrong assumptions that have been made in designing this version of the system. Only time can tell us if we made mistakes and so it makes the most sense to give ourselves the opportunity to make changes for those periods. With Polkadot, we have a process that is seamless and robust.

TO ADD: Section on treasury. 

Treasury---this book was written thanks to the treasury functionality.

Chapter 5 - Expanding the Network

Having seen how the network is composed, we now turn to expanding the network. Parachains are our means of expanding the network, the ultimate proposal for Polkadot. Without parachains, then the relay chain is simply a blank network with staking and governance functionality. Every parachain can be designed however the builders want it to be. To use transaction fees or no fees. To have large blocks or smaller blocks. In short, the parachain is a country unto itself. Thus, you can think of the relay chain as the road and seas that connect different countries. Each country is a self-sovereign layer 1 parachain. However, this can be misleading. A parachain isn't limited to just being a layer 1 blockchain, but can be any kind of network:

  • Public layer 1 network

  • Private layer 1 network

  • Layer 2 scaling solution

  • Bridge (for connecting different blockchains)

  • Etc. etc.

This is possible because the relay chain makes no assumptions about the entities that connect to it, rather accepting them as they are, so long as they are built using the same language---in this case, that's substrate. Substrate is the framework for building modern blockchains created by Parity, the team building Polkadot. Every blockchain or network built with substrate is compatible with Polkadot and so can be connected as a parachain.

But really, what is a parachain? What does it mean to be one? Simply, parachains are like the children of the relay chain in that they are secured by the economic power of the relay chain. Also, they are able to use the immense computing resources of the relay chain, where computing resources simply means that parachains are prioritized by the relay chain validators, such that when a new parachain block has been created by collators (parachain validators), the relay chain validators instantly seek to add this new transaction to the block. The grand benefits of parachains are two-fold:

  • Shared security

  • Interoperability

The concept of shared security should be understood by now. It's interoperability that will enter full focus now because it's truly the holy grail.

Parachain interoperability

I believe that this is Polkadot's killer feature. If you're unfamiliar with blockchains then this feature may not seem so grand to you. That said, I'll try to make you see why parachain interoperability is the key to unimaginable innovation in the blockchain space.

Decentralized Finance and decentralized digital ownership (via NFTs) grew into the powerhouses that they are today thanks largely to interoperability. Interoperability, in this context, simply means trustless communication between different automated systems/networks. Usually, when most projects say they are interoperable, they mean it in the sense that tokens from one blockchain can be moved to another blockchain and vice versa. Always, this token transfer is done via a bridge. A bridge's mechanism is simple to understand. To see, let's use an example.

I want to send Bitcoin to Ethereum. How do I do this with a bridge? I go to the bridge (which is just a regular website) and make the transfer. A pretty straightforward process achieved in a few clicks. What I don't see is that the tokens I moved from Bitcoin to Ethereum are technically still on the Bitcoin network. This is because the bridge's method of transfer is to freeze my tokens on the Bitcoin network (by sending it to an address on the Bitcoin network that was specially made for this purpose). When this is done, the tokens are locked in the Bitcoin network and then a new set of tokens (sometimes called wrapped BTC) are minted on the Ethereum network and sent to my account. Like I said, a straightforward process. But this isn't true interoperability, not in the sense Polkadot means it.

There are two aspects to interoperability

  1. Sending tokens and messages

  2. Calling functions

The first aspect is pretty trivial in today's blockchain industry. The second is relatively unheard of, and it's where all the magic lies. For blockchain A to call a function of blockchain B means that blockchain A can operate blockchain B without a human intermediary (such that every transaction has to be signed but the human). For example, blockchain A could call a smart contract on blockchain B, who will in turn respond to blockchain A, giving it whatever information or running whatever computation that's requested. Inter-operate! Let's use an example to make it make more sense.

User requests to use his valuable NFT on chain B as a collateral on chain A (a DeFi-focused chain) to take a loan. But before chain A can accept this loan request, it needs to confirm a few things:

  1. Is the user who he says he is?

  2. Does the user own said NFT?

  3. What's the true value of said NFT?

Asides these questions, chain A also needs to:

  1. Mint an NFT to represent the loan position

  2. Send tokens to chain B

To confirm this information, Defi Chain A needs to talk to other chains. To know the real identity of the user, DeFi chain A talks to identity chain C, who verifies that the user is truly who he says he is, and that he's eligible for the loan. Now, chain A decides to check with the two other DeFi chains it has partnerships with to confirm that this user has no outstanding debts. Then, once confirmed, chain A moves on to verify from chain B whether the user actually owns this NFT. Chain B confirms. Chain A then goes on to assess the value of this NFT and confirm if the ratios are fair or if it should adjust it. Thus, it calls a smart contract on chain D, a prediction chain. This prediction chain incentivizes its set of predictors and assessors to analyze the true value of the NFT. The verdict comes in that the NFT is truly valuable. Now DeFi chain A, having confirmed that all is well, proceeds to collect the NFT and lock it in its NFT vault on chain B to earn yields while it gives the user the tokens requested. For the user, all of these many conversations were really just one click. It was the chains that did all the work thanks to strong interoperability.

Thus we see that there are two kind of interoperability---strong and weak. With weak interoperability, the user would have to do all of these manually, signing multiple transactions on different chains. Or, chain A would have to become less focused on its task and become more general purpose so that all these features---identity, prediction, and token minting/issuance will be available on its  smart contract layer, making it easier to interoperate. This situation leads to serious scalability problems as can be evidenced by the slow speed and gas wars on Ethereum.

Note that I've added more steps than are necessary for such a transaction for descriptive purposes only.

Now, given the immense benefits parachains have over other layer-1 chains, it's clear to see why there would be such great competition to become a parachain. Unfortunately, the relay chain can't have an infinite number of parachains because resources are finite. According to the polkadot whitepaper, the plan is to have 100 parachains connected in the next half decade. But this presents a problem. How do we determine who gets the parachain slots?

Parachain Slot Auctions & Crowdloans

Whenever there are only a few items and many buyers, the most sensible way to distribute these resources are auctions. This guarantees that the resources are distributed to those who value them the most. For Polkadot, a decentralized system with technological and economic security to worry about, finding the best way to distribute such high value resources is paramount. This is where the parachain slot auctions come in. The PSAs are a robust mechanism that help allocate parachain slots to the highest bidder. The full details of how it achieves this are below.

Every parachain slot auction lasts 1 week. During this week, parachain teams make their bids. At the expiration of the auction period, a winner is determined. But this is the simple description of what happens. Now let's get into a bit more detail.

Each 1 week of parachain slot auctions is divided into 2 phases, the opening phase and closing phase. The two phases are necessary because Polkadot uses a novel on-chain candle auction. The traditional way to run an auction would be to set a timer and let the highest bidder win once the timer runs out. Because Polkadot is trying to maximize the economic security of the network, this auction style presents a major problem. It doesn't incentivize bidders to make their best bids early, leaving the system exposed to auction snipping.

For example, Bob wants to bid for a painting with $40,000 but decides to start out at $15,000 to feel the market. When his bid is topped, he adds an extra $500 and bids again. Again he is topped. Again he adds. On and on, until the timer is at the last 3 seconds with Bob winning at $28,000. Then comes the last second and Alice snipes Bob's bid with a $28,500 bid. Bob loses out on the auction and the artist loses out on a larger commission (given that $28,500 is much lower than Bob's true budget of $40,000). To discourage such acts during auctions, a new method was invented called the candle auction. The purpose of it was to introduce some randomness to the end time of an auction so that participants are encouraged to place their best bids early. In this way, everyone knows the starting point of the auction (when the candle is lit) but no one knows the ending.

Now, implementing the candle auction on a blockchain is not a trivial affair. For one thing, blockchains are not built for randomness. We can't put on a candle and watch it go out. Polkadot's solution is to have something called a retroactive end time. Using the same idea of the candle auction, everyone knows the start time of an auction, but no one knows the end time. This is why the two phases---opening and closing---exist.

In the opening phase, which lasts 2 days, every bid made then will hold greater weight over the outcome of the bidding process. The reason will be seen shortly. In the ending phase, all bids made are subject to the time when they are made. This is because, at the end of 7 days (of auctions), the relay chain uses a verifiable random function to choose which block during the closing phase the auction actually ended at. Whichever parachain candidate has the highest bid on that block will win. So it's possible for the relay chain to decide that the auction ended on the 5th day on block #123456. This means that a parachain candidate which made the highest bid after block #123456 will definitely lose the auctions. This is why the opening phase is important because the relay chain will always consider all bids placed in the opening phase.

A parachain slot can range from 3 months to 2 years on Polkadot (1 year on Kusama) depending on what the team chooses. This introduces another interesting dynamic to the auctions. The relay chain takes two main things into consideration when picking a winner (note, this is hard coded into the relay chain, with no one pulling its strings from the outside):

  • Maximize economic revenue (get the most number of DOTs or KSM)

  • Maximize slot duration (pick the team who wishes to connect for the longest available duration)

This means that a parachain candidate can have the highest bid but for the lowest slot duration (say 1 year as opposed to 2 years on Polkadot). The relay chain will likely choose the candidate with the second highest bid who is bidding for all 2 years.

Now, getting a parachain is a very costly affair. The first parachain slot on Kusama went for 500,000KSM (~$90million). This isn't ideal for decentralization because very few teams will be able to afford such an amount for digital rent. To combat this, Polkadot has a crowdloan feature to enable teams source their parachain bid from the community. This is akin to a funding round with a few key differences:

  • The tokens bonded by the community aren't given to the parachain teams. Instead, they are held by the relay chain. Think of it like staking, except you don't earn staking rewards.

  • If the team doesn't win the auction, the tokens are refunded back to the contributors.

  • If the team wins the auction, the tokens are bonded on the relay chain for the duration of the rent. At the end of this rent period, the tokens are returned to all crowdloan contributors.

Now, to incentivize community members to contribute to their crowdloan for parachain slot auctions, parachain candidate teams offer crowdloan participants a share of their native token (and an NFT in a few cases). For the community member, this becomes a win-win scenario, with the only loss incurred being staking rewards (tokens used for parachain crowdloans and auctions aren't eligible to earn staking rewards).

For example, Karura Network offered its crowdloan contributors over 12 KAR per KSM contributed. Moonriver gave 14MOVR per KSM contributed.

Putting the crowdloan and auction mechanism together, one sees that Polkadot is poised for an unprecedented level of innovation and expansion. I say this because of the evolutionary forces at play.

  1. Because parachain slots have to be won with the help of the community, the best teams will tend to rise to the top first (where best means the teams that can deliver on tech and community engagement. It's possible for the best tech teams to be overshadowed by weaker tech teams who have a firmer grasp of community building).

  2. These slots have to be renewed, keeping the teams on their toes to deliver to their community or grow their revenue so they don't need to crowdloan anymore. Naturally, some projects will be unable to renew their parachain slot. This is both good and bad. Bad for the parachain but good for the ecosystem because it will ensure that no parachains have a permanent slot unless they can generate the funds to keep renewing.

The other exciting aspect of this system design is the appeal of parachain diversity. If there are 3 DeFi chains, they may not all be successful. Instead, maybe only 2 make it (by generating enough revenue and community goodwill). In this case, the third parachain won't renew their slot and downgrade to a parathread. It is reasonable to expect that the chain that replaces that 3rd DeFi chain won't be defi-focused because the ecosystem has reached a DeFi limit. Note that this is only theoretical. The point I'm driving at is that this design encourages greater parachain diversity.

A short take on Parathreads

Now, given that parachain slots are finite, not every project that wishes to become a parachain will be able to do so. Also, becoming a parachain may not be necessary for some projects due to their network demands. Parachains are desired because they have uninterrupted access to the relay chain, being able to create blocks whenever they want. Not all projects (use cases) require such high availability due to their block production mechanism not being so frequent. For these projects, becoming a parathread is far more ideal. A parathread is a pay-as-you-go parachain. You can think of parachains as a subscription service while parathreads are pay-as-you-use.

This model is ideal for a few reasons:

  • Makes it easy for projects to stop becoming parachains---since they don't have to lose their connection to the relay chain totally. Rather, they can write to the relay chain on a as-needed basis.

  • Makes it possible for chains that otherwise would not be able to acquire a full parachain slot to still participate in Polkadot's shared security.

  • Makes it possible for chains that find it economically unsound to become parachains to still benefit from Polkadot's shared security.

How Parathreads will operate

Some of the parachain slots on the Relay Chain will be preserved for parathread execution. These preserved slots are called the parathread pool and they will have no parachains on them. All projects that wish to be Parathreads will join the pool. When they want to add a block to the relay chain, they will send their block candidate to the collator (of that particular parachain slot that has become a parathread pool slot) with a transaction fee. The collators will offer a bid designated in DOT for inclusion of a parathread block candidate.

The Relay Chain validator will select from these bids which block to include to the relay chain. The primary incentive for them is to accept the block candidate with the highest bid, generating the most profit for themselves. According to the Polkadot Wiki, "the tokens from the parathread bids will likely be split 80-20, meaning that 80% goes into Polkadot treasury and 20% goes to the block author. This is the same split that applies also to transaction fees and, like many other parameters in Polkadot, can be changed through a governance mechanism."

A brief overview of interesting parachain candidates (sept 2021)

  1. Acala - DeFi

Acala is a first-of-its-kind decentralized finance consortium, with a vision to create cross-chain open finance infrastructure for the Polkadot ecosystem. Its mission is to be the decentralized financial hub of Polkadot that makes it fast and easy to use or build financial applications, improving trading efficiency and saving valuable time. This means that Acala is like Ethereum, except it was built specifically for the DeFi use case, making it far more efficient at offering DeFi services. The platform offers a suite of core protocols that make it a worthy destination for any DeFi dApp developer and user.

  1. Honzon protocol (aUSD)

Thanks to this protocol, Acala has aUSD, a decentralized, multicollaterized stablecoin that is backed by cross-chain assets. USDT, the biggest stablecoin by market capitalization, is a centralized stablecoin, meaning that a central agent can influence its existence. This isn't ideal for decentralization. On the other hand, DAI, a decentralized stablecoin, is limited by the fact that there's only one type of collateral (ETH) that can be used to mint it. This explains why DAI has a much lower market capitalization in comparison to USDT. Thus, aUSD seeks to offer the best of both worlds. By being decentralized, it avoids the pitfall of USDT and USDC. Further, it can be minted with DOT, ETH, BTC, KSM, and any other token that Acala governance whitelists.

  1. Homa protocol (LDOT)

The Homa protocol is a decentralized staking protocol that enables users get the benefits of staking their DOT without losing their access to liquidity. Thus, instead of staking their DOT to the Polkadot relay chain, a user would stake their DOTs using the homa protocol on the (Acala link) and receive L-DOTs (although not necessarily at a one-to-one ratio). The LDOT stands for liquid DOT which the users are free to use either as collateral to take out stablecoin loans, for transfers, or swapping. When a user wants their DOT back, they can simply return the LDOT to the protocol and get their DOT plus its share of the staking rewards refunded to their wallet immediately, thus avoiding the 28-day unbonding period.

  1. Decentralized exchange

This is a protocol similar to Uniswap, Sushiswap, and other decentralized exchanges that enable users to swap tokens, provide liquidity, and earn rewards.

Acala's goal is to have everyone benefit from the freedom of DeFi without all the complexities that come with decentralization. Already, they have a partnership with Current, an American fintech company, creating a new kind of finance called Hybrid Finance (a blend of decentralized and centralized finance). For example, it will be possible for users who don't have a crypto wallet to earn yields in DeFi from their traditional bank accounts.

  1. HydraDX - DeFi

Although another DeFi-focused layer 1, HydraDX is very different from Acala. A core part of their offering is the Omnipool, a well of liquidity that is deep and diversified enough to withstand anything the market throws at it. Presently, all token trading is carried out in pairs, such that if I want to swap DOT for KSM, I will need to find an exchange that has a DOT/KSM pair. Only then will I be able to swap from DOT to KSM. If no such pool exists in the exchange, then I need to first swap DOT to a token that I can use to swap to KSM. Say, for instance, I find a DOT/USDT pair and a KSM/USDT pair. I will first swap my DOT for USDT before swapping USDT for KSM. This is not capital efficient, nor is it user friendly. Even when decentralized exchanges like Uniswap swap between two tokens that are not paired in a pool, they do so by automatically swapping from one pool to the next.

Thanks to Substrate's power and flexibility, HydraDX is overcoming this limitation by building a single pool (Omnipool) for every asset. The details of this execution is somewhat technical (both financially and technologically) but I'll give a basic summary. To create an Omnipool, HydraDX is using the HDX token as the base token against which all other tokens will trade. In this way, the HDX token acts like a price oracle.

Given that HydraDX is a layer 1, it's omnipool design is not all it has to offer, rather, it's the building block upon which many more financial applications will be built.

  1. KILT - Identity

For long, our data, particularly that which identifies us, has been used to trap, manipulate, and take advantage of us. KILT is looking to challenge that by decentralizing the process of attesting and verifying credentials.

KILT is an open-source blockchain identity protocol for issuing self-sovereign, anonymous and verifiable credentials. KILT enables innovative business models around identity and privacy, addressing the need for reliable identity solutions in the digital world. It allows users to claim personal attributes, have them attested by trusted entities, and store the claims as self-sovereign credentials.

Core to their model is the user's full ownership of rights over his/her identity or credential, such that only the owner can disclose that credential to another party.

In their system design, there are those who verify credentials (attestation professionals), those who need credentials issued (for example, a person applying for a job), and those who need to verify credentials (companies looking to hire competent people).

Once the blockchain is fully up and running, it should be possible to prove to a company who wants to hire you that you are who you say you are. This would be possible because the company only needs to check the KILT blockchain for when your credential was issued. If they seek further verification, they can pay an attestor to verify your credential.

Again, this is the basic idea. But recall that it's a layer 1 and so many more applications can be built on it.

  1. Robonomics - IoT

In my opinion, this is the most interesting parachain candidate building in DotSama. I say this because they are building something that no one else has built---robot economics. Core to their idea is the realization that, with the rise of automation (autonomous robots), there needs to be a framework for robot-to-robot interaction. For example, in a factory there are usually many robots working together to make a product. Presently, in most factories, a human is needed to facilitate communication between robots, such that when an item has left one line, a human moves it to the next line.

A human is only needed because there's no way for the robots to talk to themselves and respond to their actions. By adding the concept of economics to robot interactions, a whole new world of possibilities is opened to us. With Robonomics, it will be possible for a factory robot to speak to a transportation robot, such that when the products are ready, the factory robot pings the transportation robot to come for pickup. To avoid robot spamming, the transportation robot will only react to the factory robot's call if the factory robot has paid some tokens to the transportation robot.

Robonomics is so next level I don't fully comprehend all its implications for the future of work and human-robot interactions.

  1. Phala - Privacy

Phala tackles the issue of trust in the computation cloud. Phala's layer 1 blockchain is a trustless computation platform that enables massive cloud processing without sacrificing data confidentiality. Built around TEE-based privacy technology already embedded into modern processors, Phala's distributed computing cloud is versatile and confidential. By separating the consensus mechanism from computation, Phala ensures processing power is highly scalable but not wasteful. Together, this creates the infrastructure for a powerful, secure, and scalable trustless computing cloud.

Phala will be able to provide computing power to other blockchain applications while protecting the data layer, enabling possibilities like privacy-protected DeFi trading positions and transaction history, co-computing DID confidential data, developing light-node cross-chain bridges, and more.

On-chain services currently being developed on Phala Network include Web3 Analytics: a high-performance smart contract to enable highly concurrent mass data analytics with privacy, paving the way for an alternative to Google Analytics that inherently respects individual confidentiality.

  1. Crust - Data

The cloud has been a great addition to our lives. No longer do we need to store all our digital files on our devices. However, the data you store on centralized cloud servers don't fully belong to you. Also, you can't be certain that your data will always be safe and accessible because there's a single point of failure. Of course, that it is possible doesn't mean it happens or will happen. It's just the reality of the situation. A decentralized cloud has the advantage of not having a single point of failure.

Crust is providing this decentralized cloud storage solution for simple users, heavy users, and developers. With Crust, your data is stored on multiple nodes across the world, ensuring that you can retrieve this data anywhere and anytime. Further, any data stored is fully owned and can only be accessed by you. This is because Crust makes use of advanced data encryption (using TEE-based privacy technology) to encrypt your data before sending it to its nodes. Crust is adaptable to multiple storage layer protocols such as IPFS, and provides support for the application layer. Crust's architecture also has the capability of supporting a decentralized computing layer and building a decentralized cloud ecosystem. All in all, Crust is looking to challenge every centralized cloud storage service in operation---Google, Dropbox, Box, etc.

  1. Zeitgeist - Futarchy

Zeitgeist is a layer 1 blockchain that is built around one of the most out-there ideas in the parachain space. Democracy is an ideal form of governance but it has many drawbacks, chief of which relates to its mode of decision making. Currently, there are vast differences in wealth among nations which cannot be attributed to differences in either natural resources or human abilities. Instead, much of the difference seems to be that the poor nations (many of which are democracies) are those that adopt dumb policies more often. And even rich nations frequently adopt such policies. Thus, futarchy presents itself as a new form of government that alters the way decisions are made. Rather than have people vote on their opinions with no cost attached, all decisions are arrived at via the outcome of a prediction market. The core argument for futarchy is that the market tends to be more right than any other decision making method. Given this, Zeitgeist provides a layer 1 blockchain that enables anyone to create a prediction market for any decision that requires making. This is useful for companies, governments, blockchain communities, DAOs, and any group who have to make a policy decision. Thus, decisions won't be made based on free opinions but on weighted bets. The modus operandi of this chain is "if you feel that strongly about it, then put your money where your mouth is". It is expected that people will be more careful and honest with their opinions when there is a cost attached to it. One can imagine a future where the members of parliament come to a decision based on how they bet. Say for instance the question is "Will reducing taxes create more economic progress?" In a democracy, all members would vote based on opinion. In a futarchy, all members will take a position on whether lowering taxes will lead to economic progress or not. Those with the greatest conviction will put more on the line. Now, in such a situation, who would you go with? The person who has faith in their opinion enough to take a big bet (exposing themselves to losing a lot of money) or the one who isn't brave enough to back their opinion with a big bet?

As an idea, futarchy is truly radical and it will be interesting to see how it plays out on Zeitgeist.

  1. Moonbeam - smart contracts

Moonbeam is an Ethereum-compatible smart contract platform on the Polkadot network that makes it easy to build natively interoperable applications. This Ethereum compatibility allows developers to deploy existing Solidity smart contracts and DApp frontends to Moonbeam with minimal changes. Given the successful launch of their Moonriver, their canary network on Kusama, some have started to dub it Ethereum 3.0. Of course, some of the people who say this only want the MOVR tokens to go up in price. That said, the tag isn't unfounded. For one thing, Moonbeam's near-perfect Ethereum compatibility makes it an easy destination for all Ethereum dApps. On Moonbeam, Ethereum developers can build richer dApps that don't suffer from the limitation on Ethereum---unreasonable gas fees, lack of scheduling, etc.

These are just a few of the many parachain candidates building on Polkadot. Below are a few good places to find more projects:

An important point to note: not all projects that call themselves parachains are parachains in reality. Unless a project is plugged to the relay chain (via winning a parachain slot auction), it is only a parachain candidate.

Epilogue - Participating in the Network

At the beginning of the book it may have been difficult to imagine why we would need many chains, but now I hope this section has been able to convince you that the future is truly multi-chain. If anything, I hope you have gained a greater appreciation for the infinite versatility of a layer 0 protocol like Polkadot. It enables unimaginable innovation and this is what the future thrives on. Without innovation we'd never be able to eradicate problems that plague us in the present. Our present is in dire need of innovation. There are far too many problems still left unresolved for humanity and the planet as a whole. The goal of every technology should be to make life better, but not life in the narrow sense of the word that only takes humanity into account. That's the kind of thinking that led us to a climate crisis. Life, as I use it here, refers to plants, animals, atmosphere, and everything we can't do without. The hope for decentralization is that many people can be more empathetic than a few. If a decentralized protocol becomes the enemy of life (freedom, peace, fairness), I hope that those controlling it will be human enough to put overall life before prosperity. If we can't do this, we are doomed to repeat the mistakes made in web2.

(work in progress)