Centralization vs Decentralization in Bitcoin
Decentralization in bitcoin is achieved through clever technical engineering. It is said that decentralization is neither all nor nothing. Which means that almost all systems residing in this universe are not purely centralized or decentralized.
For example, we can take the case of messaging. The messaging service is decentralized as anyone can send any message to anyone around the world and again it is centralized since it is controlled by the messaging servers and service providers.
The same is also applicable for bitcoin since:
- The peer to peer network that bitcoin has is completely decentralized and anyone on that network can run bitcoin nodes and send bitcoins to anyone around the world.
- The mining done is kind of centralized as it requires high power to mine bitcoin thus incurs high electrical costs and making it not so feasible for everyone to run a node.
- The software of bitcoin which defines the rules and policies of the network is also kind of centralized as they are run by the core-developers.
What is Distributed Consensus and How is it Achieved
In one of the previous articles, we saw that how we have eradicated the double spend attack in snail coin. So, here we would see how we can make that snail coin decentralized such that no single authority controls it and to achieve that we need consensus in the network.
Now, why is consensus important?
Let’s say, we have a large worldwide application that is backed by several nodes and those nodes are responsible for updating the databases and the application takes some data from the user and saves it to the database and maybe retrieve it in the future when the user needs it. So, assume that there are some faulty nodes. If there is no consensus then some of the databases will have the value stored which was taken from user and others won’t. Thus, there will be an inconsistent database which is a big problem. On the other hand, if there is a consensus among the nodes then none of the data gets stored and users can be asked to retry their action.
Thus, in simple words, consensus can be defined as, when there is n number of nodes in a network and when consensus kicks in, the protocol terminates and all correct (non-faulty) nodes stick to the same value and the value should have been proposed by a correct node and not an arbitrary value.
However, it is also true that consensus can be hard to achieve as nodes might crash or be malicious and the network can have faults and latency. Due to which some problems arise when consensus is not reached. The most common and popular one is Byzantine general problem.
Nevertheless, to make consensus work bitcoin does two things:
- Gives incentives; solves distributed consensus problem from a currency standpoint of view.
- Consensus in bitcoin happens over a long time; as time increases exponentially, the probability of error decreases.
Why not having Identity is important in Bitcoin
It is indeed clever to think why we can’t identify nodes using some identity that is faulty or malicious and remove them. In Bitcoin like the users, nodes are not given any real identity and that is for two reasons:
- To avoid Sybil attacks. Sybil is an adversary who pretends to deploy several nodes in a network, but the truth is that it is a single node which is controlled by the adversary.
- The prime goal of bitcoin is to make anonymity a priority.
Simplified version of Consensus Algorithm
- New transactions are broadcasted to the network and all nodes get notified of it.
- Nodes collect new transactions, confirms it and puts in a block.
- A node is selected (we will learn in the later parts on what basis a node is selected) who broadcasts its block.
- Every other node verifies the block and accepts it if all transactions in the block are valid (i.e. no double spend, or signature forging is present).
- Nodes acknowledge their acceptance by putting the hash of the block in the next block that they create.
Capability of Malicious Nodes in Bitcoin Network
Now that we have a decent understanding and a bigger picture on how the consensus in bitcoin works and why we cannot give identities to nodes, now it boils down to one question, how can a malicious node affect the network/what can a malicious node do?
Can a malicious node steal coins from one address? Well no, since it cannot forge the cryptographic signature if the underlying cryptography is strong.
Can a malicious node deny service or not process a transaction or restrict a transaction from getting confirmed? Again, the answer is no, as the transaction will be picked by another honest node and put into a block when that node’s turn comes.
So, can a malicious node successfully execute a double spend attack? To answer this question let us investigate the below scenario where Amanda sends bitcoin to Bryan the merchant in exchange for some service.
In the above scenario when Amanda, an adversary tries to pay Bryan for a service she wants to enjoy, a new transaction is broadcasted to the network and let’s say that the node who picked up the transaction was an honest node, so it will simply confirm it and put it in a block (green coloured). If Amanda wants to try a double spend attack it will have to wait until she gets a turn to propose the block. Assume Amanda got to propose the next block (the block after the green block), as she is an adversary, she will not follow the longest path and instead propose a block (red coloured) which points to the block which is just before the green block. Inside the block, we see that A-›A’ which means that Amanda moves the bitcoin to another address of hers.
Now, here is one subtle point that one should appreciate is when one claims that he/she has n number of bitcoins it is nothing more than the nodes in the network acknowledging that the person has n number of bitcoins.
So, if again Amanda takes control of another node and proposes a block which follows the red block then the other honest nodes start following that path and continue building their blocks as honest nodes always select the longest path. Thus, it seems like the double spend attack becomes successful as it is pretty difficult for the nodes to judge which path is valid.
Here forth comes the role of the merchant Bryan which is an important aspect of Bitcoin security. Bryan, on the other hand, will presumably be running a bitcoin node (honest), with help of which when he detects that there has been an attempt to double spend, he can immediately cancel the transaction (if his transaction does not lie in the longest path). To detect a valid spend, the next thing he could do is wait for several confirmations (several block creation gets completed) and see whether his transaction falls within the longest consensus chain. In general, more the number of confirmations less is the probability of the double spend attack to occur. So, as a thumb of rule, usually, people wait for 6 confirmations to mark a transaction as valid.
Well, now that we have created a double spend attack and also saved it from occurring, can we or is there a way to incentivise the nodes that work honestly and by what means shall we determine which node gets to creates and broadcasts the block?
Incentives in Bitcoin – Block Reward
In the bitcoin network, the creator of the block gets an incentive for confirmation of the transactions if and only if the block lies in the longest consensus chain. As nodes do not have any identity, verifying whether a node is honest becomes difficult and that’s why if the block lies in the longest chain the node gets the incentive. Every node, while proposing a block gets the opportunity to add a special transaction in the block which is coin creation transaction to pay itself the block reward if the block is part of the longest chain.
The block reward is the only way by which new bitcoins are generated and its value halves every 4 years. Currently block reward is 25 BTC.
Incentives in Bitcoin – Transaction Charges
As analogous to the traditional monetary system, the creator of the transaction provides an extra money which is said to be the network fee and this fee is completely voluntary.
In order to reach consensus there are mostly two ways in any cryptocurrency operating on blockchain; proof of work and proof of stake
Proof of Stake (POS)
In POS the creator of a new block is chosen in a deterministic way which depends on its wealth i.e. how many coins he or she holds. As opposed to proof of work, miners here do not get any block reward, they simply thrive on the transaction fee. We will discuss on this section in details in our future articles.
Proof of Work (POW)
In POW miners compete among themselves to solve a hash puzzle.
To create a block, one needs to find a nonce such that:
H (nonce|prev_hash|Tx|…|Tx) is very small and the only way to solve it is to try enough nonce randomly until that node is lucky. Nodes compete among themselves to solve the hash puzzle. The solution of the hash puzzle must lie in the target space.
Characteristics of POW
- Difficult to compute: As due to the increasing difficulty and uncertainty of solutions (solutions are found randomly) high hash power is needed. So, few dare to compete.
- Cost is variable: The target is recalculated every 2 weeks as more miners join the mining process and dump more hash powers such that the average time between any two given blocks remain 10 mins. As the number of miners increases, more work needs to be done by an individual miner to mine a new block. Miners are weighed by the hash power to eradicate dishonest node.
A great way to showcase the time required by an individual miner to find the next block provided the miner just found one can be shown as:
For example, say the global hash power is 1000 Mh/s and your hash power is 50 Mh/s then the time required by you to find the next block is: 10*(1000/50) = 200 minutes.
- Others can verify: The nonce should be published along with the solution such that other miners can verify that:
H (nonce|prev_hash|Tx|…|Tx) < Target
Now that we gained a clear picture of POW, the only question we need to answer is the basis of what factors one should be a miner?
When should you Mine
One should consider mining only if the mining reward which consists of block reward (fixed for 4 years) and transaction fee (variable) is greater that mining cost which includes hardware setup (fixed) and electricity cost(variable). Apart from this the mining reward is heavily dependent on the price of 1 BTC as the block reward and transaction fee is paid in bitcoins so, if the price falls down or is too low than the mining cost then the miner will incur a loss.
The ecosystem of bitcoin is kind of interlinked by three main parameters:
The security of blockchain will be strong if and only if there is a healthy mining environment with almost no attackers. Again, the mining environment will be healthy only if the currency that is mined for has some market value as lots of resources are invested in mining. And lastly, the value of a currency will only exist if there is security in the existing blockchain technology such that more people will join in and be confident of the technology.
Hope you learned something from this article. If you did please share and subscribe to our newsletter to receive most update information about our articles.