Consensus is a necessity for blockchains, but what does this actually mean and why is it important?
Let's take a look at it from the perspective of a blockchain.
A thread. ↓
1. The Client-Server Model
Most applications nowadays work with the so-called client-server model.
Client applications interface with a central server that is owned by one entity.
This server decides what information to store and what to return to clients.
If the owner decides to change the data, they can simply do so. Many users wouldn't sometimes even notice that data was altered.
The client-server architecture is a centralized application style. Users are always at the mercy of the owner of a service.
2. Decentralized Applications
Decentralized applications don't rely on a client-server architecture. They primarily work by using peer-to-peer protocols.
There is no more central server that all clients talk to. Instead, they talk to each other.
In such a model, there is a huge problem that needs to be solved.
If all those clients exchange information, what stops some of them from saying something different than the others. And who should be trusted in this case?
This problem is especially critical for blockchains that usually come with a dedicated currency.
It would be a worst-case scenario if no one could stop anyone from taking currency tokens from your account and putting them into their own one or simply deleting them.
Other than that, even outside of the monetary space, data is essential to its owner.
If that data is altered or deleted, it does damages. This needs to be prevented, or the system itself loses trust.
Without trust, there is less if not even no instigation to use a system.
3. Consensus Protocols
There is a multitude of consensus protocols for different use cases. They are not exclusive to blockchains.
If you ever worked with Kafka, you perhaps know that it always comes with the need for a Zookeeper node (or, even better, more).
Kafka topic leader election (when a node fails) is based on a consensus protocol where multiple Zookeeper nodes decide which of the remaining Kafka instances becomes the new leader of a particular topic.
This is only an example of a permissioned variant of a consensus protocol. The participants are known and can authenticate themselves.
In the case of blockchains, however, permissionless consensus protocols are used. In a peer-to-peer network, all participants are unknown.
Clients usually only talk to a small portion of the system.
Because clients only talk to a part of the system, there is always a portion of the network unknown. But clients still need to trust even the unknown parts of the system.
Consensus Protocols are designed to achieve consensus in a system.
They are a set of algorithms and steps that, given the same input on every client, lead to the same result for everyone.
All participants can verify whether what they see is correct or whether a choice is valid.
The protocols themselves don't prevent incorrect or fraudful data, they provide a way to filter that data out. Clients can then simply ignore it.
The participants of the network agree on what the truth is together.
Some participants may disagree but it's usually a majority vote. You could say that the process is somehow democratic.
In blockchain space, getting this consensus usually requires mining or validating, depending on the protocol used by the specific blockchain.
When Bitcoin miners use up all those precious Nvidia graphics cards and energy, they do this to contribute to the system's consensus.
In this specific case, they do a complicated calculation (hashing) multiple times by guessing a random integer to get a pre-defined result (a hash).
This result, the nonce, is then included in a new block and can be verified for correctness by everyone.
Every participant can check whether that nonce and its block are correct.
Guessing the nonce and verifying the result builds the consensus of the Bitcoin network. Clients can agree on which blocks are actually correct and which are not.
Other factors are included, like the longest verifiable chain being accepted as the truth and more, so the protocol is a little more complex than presented here.
But you should hopefully still get a general idea of the system itself.
There is never THE consensus protocol.
Different blockchains use different consensus protocols and alter them to fit their needs.
It's more important to choose one that fits the specific case and works well (enough) to guarantee some form of security and stability in a system.
4. Conclusion
Consensus protocols in blockchain space ensure that the system behaves correctly, although there is no central controlling entity.
They come in a multitude of flavors, and research on more is ongoing.
Their job is to build security and trust.
Without security and trust, such systems would have no value to be used.
This is why consensus plays a crucial part in blockchains.
As already stated, you can use those protocols for a lot more than only decentralized networks, so feel free to research.
You might or might not end up needing this knowledge at some point.
5. Thread end
That's it for this thread.
I hope you found something useful for you in it.
If you enjoyed reading this thread, consider dropping a like, retweet the first tweet, and follow me (@oliverjumpertz) for more content like this.
• • •
Missing some Tweet in this thread? You can try to
force a refresh
It's the consensus protocol behind Bitcoin and, according to some people, the sole reason for climate change due to its insane energy consumption.
Let's take a closer look at this consensus protocol.
A thread. ↓
1. Basics
The Proof-Of-Work protocol creates a system in which one party (the prover) has to prove to one or multiple other parties (the verifiers) that they put in a certain amount of work for some purpose.
The prover's work is moderately hard to very hard, while the verifiers can pretty quickly check whether the proof is correct.
This creates an asymmetric system.
The original idea was to create protection against DDoS attacks and spam.
Do you know what many dApp developers struggle with?
Which data to put on-chain. More data on the chain can drive the cost up. Too much data might render your app unusable. Storing fewer data might not be an option.
Here are some ideas for you to fix this.
A thread. ↓
1. Use A Dedicated Database
This approach will make your dApp into an app.
If you bring in central data storage, you can circumvent the limits of some blockchains, but it doesn't keep the promise of being decentralized.
You can store anything that you can't store on-chain in your database and associate it with a user.
Whenever you need that type of data, you fetch it from your database.