Blockchain technology has been around for a long time now. It is a peer-peer, distributed and append-only database. In this discussion, we analyze the role CAP theorem plays in blockchain technology.
About CAP Theorem
CAP Theorem, also called as Brewer's Theorem proposed by Eric Brewer, identifies three specific system properties for any distributed/decentralized system. They are: Consistency, Availability and Partition Tolerance
- CONSISTENCY - Any read gives the latest write on the nodes.
- AVAILABILITY - At any point of time irrespective of whether the read is the latest write, client always gets a response without an error.
- PARTITIONING - In a distributed network of nodes, even though there is no possibility for the whole network to go down, there is possibility for partitions between nodes. This partition attributes to the delay or latency between nodes communicating in the network.
According to the CAP theorem, in any distributed network it is impossible to provide more than two of these three properties as a guaranteed feature
Application of CAP Theorem in Blockchain Technology
Let's try and analyze blockchain in terms of its features and see if CAP Theorem applies to blockchain at all.
PartitionING is an inherent feature of any distributed system. That leaves us with only two choices to pick from: Consistency or availability
Scenario: Picking Availability over Consistency
If we pick Availability over Consistency in blockchain, any reads that happen are not guaranteed to be up-to-date. Although, there is a response from the network at all times, the purpose of the blockchain being a single source of truth is taken away.
On the other hand, lack of Consistency is something we simply can’t have in any monetary system. Consistency always takes priority in blockchain technology.
Say we consider Availability as an optional feature, This would force the network to be unavailable when there is a Partition – which would disrupt consensus. Hence, availability cannot be sacrificed in blockchain technology since consensus is key.
Does That Mean Blockchain Violates CAP Theorem ?
Simply Put - NO, blockchain does not violate the CAP theorem
Those interested in blockchain, opt for AP (Availability + Partition) + Strong/Eventual Consistency.
Let’s consider Bitcoin – which uses Proof of Work as it’s consensus mechanism. Currently, bitcoin maintains a Read & Write protocol. The protocol is designed to consider the longest chain as the accepted main chain. A transaction is confirmed only if it is “X” number of blocks deep into the chain. Although a probabilistic model, it is left to the users to choose the value for X. Currently, for large transactions, a minimum of 6 blocks wait is considered a win. The same kind of protocol has been used in other blockchains as well Ex: Ethereum. There has been a lot of debate on whether to term this as strong or eventual consistency.
To summarize, configuring a client doesn't violate CAP theorem. It’s just a tradeoff between consistency and availability.
Get my upcoming eBook for Free!
"The Mango Guide TO Understanding Blockchain"
Offer Valid For FIRST 500 registrations only