It all started with Satoshi Nakamoto’s whitepaper that was published in 2008. Before this paper was published there was no known way to create an authentic digital currency, without the help of a centralized authority. The main issue was the problem of double spending.
What is the Double Spending Problem?
Any digital currency is just another form of digital files. There is no authority stopping anyone from copying these files and sending them to multiple people. Only solution of this issue, before Bitcoin, was to trust a central authority to manage these digital files. If that single authority cheats then the user is doomed and only way for them to reinforce the breached contract is by taking help of the law which we know is slow,expensive and uncertain. Another big issue was that this centralisation makes the system prone to a single point of failure.
Satoshi Nakamoto whitepaper gave a solution for the double spending problem and made it possible to make digital payments without a need for a central authority, we all are aware of a currency named Bitcoin. This paper solved this problem by using a trust-less peer to peer network. Instead of storing data only in a centralized ledger the data is broadcasted throughout the network using gossip protocol and every peer updates its own ledger. This way within a small period of time the whole network has the same copy of ledger or we can say that whole network has the same state. As you go through this blog things will become more clear.
What is a transaction and what is a block?
A transaction is an exchange of assets between 2 users, for example bitcoins are assets on the bitcoin blockchain. A block is a collection of these transactions. Every single transaction is not propagated throughout the network instead a block once filled(blocks have a fixed max size) is propagated in the network.
Exchange of assets
All the blocks are lined up one after other and each block includes the hash of previous block, in this way forming a chain.
Hash from previous block is stored in next block
How is double spending prevented?
Network is composed of nodes(the peers). Some of the nodes are miners. Any node can become a miner, no permission is needed because it is a public ledger. Miners compete with each other to solve a computational intensive puzzle. One who solves it first broadcasts the block which has a collection of transactions that miner validates and confirms that there is no double spending. He also broadcasts the solution of the puzzle so that everyone can verify that he has actually solved the puzzle. All nodes also verify the transactions in the broadcasted block before adding that block in their own copy of ledger. In case a miner has added a double spend transaction in the block the nodes will reject that block and that block will be dropped.
Why would anyone want to be a miner?
Miner who solves the puzzle and broadcasts the block gets a fixed number of native currency for eg: bitcoins in bitcoin blockchain, miner also gets the fees payed by user for making a transaction. Miner can choose the transactions that he wants to add in his block, generally miners choose transactions with high fees first to maximise their profit.
Why do we need to waste all this energy to solve a puzzle?
Consider the following attack scenario to understand.
Suppose an attacker wants to double spend a transaction that is in block number 1000 and current block number is 1005. Attacker will make a change in block number 1000 but he can change it only in his own node, the state of blockchain is same at all other nodes. Attack will be successful only if attacker is able to make that change in ledger of majority of nodes.
Attacker forks his own chain from the main chain and adds new blocks to this forked chain and hopes that everyone in the network accepts his chain and make his attack successful.
There can be two cases from here.
- Attacker’s hashing power (computational power to solve the puzzle) is less then 50% of the total hashing power. The speed with which his chain size increases will be less than that of the honest chain.
- Attacker’s hashing power is more then 50 % of the total hashing power. The speed with which his chain size increases will be more than that of the honest chain.
All nodes follow the longest chain rule i.e. the longest chain has most work done on it and so it is honest.
In the former case, attacker chain length will be less than honest chain, the probability of successful attack is small and hence attacker will not be able to double spend.
In the latter case attacker chain length will get longer than honest chain and suppose that after 2 hours, length of honest chain is now 1010 and that of attacker’s chain is 1011. All nodes will update to the chain of attacker and the blocks from 1000 to 1010 mined in honest chain will be dropped. Deeper in the chain we have to make a change, more computational power will be spent. If the value of double spent exceeds the computational power cost, it is not sensible to perform such an attack.
Once many blocks are mined on top of a block the transactions in that block may be considered as irreversible.
This attack scenario explains the importance of solving a computational expensive puzzle.
This requirement that expensive computations be performed in order to facilitate transactions on the blockchain is popularly known as Proof Of Work.
Mining Bitcoins not Gold
Scalability issue with blockchain
Scalability is the last hurdle
Bitcoin and Ethereum are based on above explained technology and we all know how popular they are today. Despite the amazing technology there are some problems. The main issue that this technology is facing today is the problem of scalability.
The throughput is small, for bitcoin it is in single digits while throughput of Visa is in 1000s of tranactions per second. As more and more people start adopting bitcoin, the transaction fees will rise (demand is more than supply) thus making small value transactions in bitcoin futile(Fees will be more than the value of transaction).
Recently on Ethereum, a game named cryptokitties took off and the traffic became high thus increasing the transaction fees and number of pending transactions by many folds. The issue of scalability is the biggest barrier for mass adoption of these currencies.
Throughput of blockchain is limited by the fixed size of a block and the propagation time of a new block through the whole peer to peer network.
Solutions to the Scalability Problem
The Scalability issue is the most prominent field of research in the blockchain world. Many different solutions are being proposed to solve the issue. These solutions can be classified in 2 types:
Layer 1 Solutions
These solutions change the blockchain protocols to deal with the problem of scalability.
Segregated Witness (SegWit)
This is exclusive to Bitcoin. It is a small improvement in the bitcoin protocol, it increases the throughput by fitting more transactions in a single block by re-weighing the signatures of transaction data. Signature data of every transaction is moved from main chain to the parallel side chain which frees up space in the block. Still the throughput will be in single digits and hence not a solution for mass adoption of bitcoin. SegWit is currently active in the present bitcoin blockchain.
Block Size Increase
Right now as per bitcoin protocol the size of the block is limited to 1 MB this limits the throughput of the bitcoin network.
why don’t we just increase the size of the block?
This is currently a topic of debate, a part of bitcoin community believes that increasing block size is necessary for mass adoption of Bitcoin. As it will prevent increase of gas price at times of high traffic. They also believe that SegWit is not a permanent fix and size of blocks must be increased. When SegWit was implemented this community forked a new blockchain ‘Bitcoin Cash’ which does not implement SegWit and has a block size of 8MB.
Other part of the community believes that increasing the block size will centralise the Bitcoin network as with increase in block size the amount of processing power required to mine a block will increase this will make it impossible for small scale miners to mine a block and all the power will shift to a handful of miners thus making 51% attack more possible. Some of them also believe that Bitcoin should not be used for every day purposes and it should only be used as a store of value like gold.
Increasing block size will cause other problems as well. Size of the block is related to the propagation time of a new block through the network. More the size of the block more time it takes for each node to validate transactions in it. A node propagates a block only after it has validated the block. Increasing block size will increase the propagation time of new block through the whole network.
Suppose there are 2 honest miners A and B, in two different parts of the world. A solves the puzzle and broadcasts his block in the network. Before this block reaches B, B has also solved the puzzle and he also broadcasts his block as he is not yet aware of the block mined by A. So some of the nodes in the network have added the block mined by A to their local copy of ledger and others have added the block mined by B. Ultimately one of these blocks gets dropped. This is known as chain reorganization.
Although the dropped block had honest transactions it got dropped and all that hashrate was wasted which could have been used to mine another block which would have made the network more secure. More the size of the block more the wastage of hashrate.
Any transaction that takes place on the ethereum network has to be validated and stored by each node in the network so that every node has the same state. This puts a limit on the throughput on a protocol level and hence no matter what the implementation, without changing the protocol it is difficult to solve the scalability issue.
What if all nodes don’t have to process each transaction? If the network is divided into some sections which can work semi-independently, each section could process a different batch of transactions and hence increase the throughput by many folds. Each of these sections is termed as ‘shard’. This is the idea behind sharding.
Layer 2 Solutions
These solutions don’t change anything on the protocol level and are built on top of the same protocols, a kind of a second layer on top of Layer1 hence the name.
The purpose is to make maximum possible use from available throughput. We try to squeeze in maximum possible number of operations. This works by creating a second layer which is hinged around first layer. All the transactions in Layer2 take place off chain, those transactions need not to be included in Layer1 instantly. All the transactions are recorded off chain and the net result is finally pushed in the Layer1 thus giving them security of Layer 1.
Although the finality of the transaction is less in Layer 2 transactions than Layer 1 transactions, Layer2 transactions are also secure and final enough for many practical purposes. State Channels and Plasma are examples of proposed Layer2 solutions.
In the next part of this series we will have more in depth discussion on Plasma and State Channels.
Latest posts by Techracers (see all)
- Blockchain Meetup by Techracers - August 8, 2018
- Techracers will be at 2nd Annual Fintech Week: Silicon Valley 2018 Conference, Are You? - August 8, 2018
- PODCAST on What are Smart Contracts & ICOs? - August 6, 2018