We have been learning how Bitcoin mining works and the Proof-of-Work algorithm that validates it. In this article, we will try to understand more deeply how it is possible to create a universal truth accepted by all who are part of the network and without anyone having to trust anyone. You can instead check for yourself that all transactions already made follow the rules defined by the network.
One of the mantras of the Bitcoin community is "Don't trust, verify."
Traditional payment systems depend on the trust that stakeholders have in a central entity. This entity is assigned the function of verifying and validating all transactions. On the Bitcoin network, on the contrary, each node verifies and validates each transaction, forming its own copy of the blockchain. This copy will be identical to all copies for all nodes. This is possible, although this network is based on information transmitted over an open network and insecure connections.
Although there is no explicit security in the transmission of information on the network, the entire process is impossible to reverse due to the large number of nodes that maintain the network. Bitcoin's security is in the numbers. In the large number of us who keep their copy of the blockchain.
The revolutionary element of blockchain technology is the emerging consensus achieved in a decentralized network. The decentralized consensus emerges from the connection between 4 processes that occur independently in the nodes distributed by the network. These processes are numbered below.
1 - Independent verification of each transaction, for each complete node.
To prevent invalid transactions from being transmitted, each complete node checks any transaction it receives in order to validate it. To achieve this goal, a well-defined list of criteria follows, which includes, for example, controlling the size of the transaction in bytes or rejecting the transaction if the sum of the value of the inputs is less than the sum of the value of the outputs.
Only after verifying that transaction, will the node propagate that transaction over the network to other nodes, which will verify it again.
2 - Independent aggregation of these transactions in blocks, by mining nodes where they include the Proof-of-Work algorithm as evidence of the invested computing.
As we saw in the article on Proof-of-Work, each mining node, after validating each transaction, will add them to the memory pool where they will wait to be integrated into a candidate block. When this happens, hundreds of transactions will be grouped in a block and the nodes will start looking for the solution for the Proof-of-Work algorithm.
When it is able to find a solution that is less than the target, the node will immediately send that block over the network in order to claim for itself the right to publish that block and the reward of the new currencies.
3 - Independent verification of new blocks by each node and assembly on the blockchain.
After being "mined", the node sends the block to the network. Each node that receives this block will check it according to well-defined rules, where they will be checked, for example, that the date stamp is not more than two hours in the future (thus allowing for time errors) or that the first ( and only the first) transaction is a valid coinbase transaction. The transaction that delivers the bitcoins generated as a reward for publishing that block.
If, in the coinbase transaction, miners indicate that they should be paid bitcoin themselves, why not address 100 or 200 bitcoin to themselves?Because the block has to be validated by all other nodes in the network in order to be added to the chain, so that the network recognizes the right to spend those bitcoins. If the miner includes an invalid transaction, that block will not be included and the funds invested by the miner to find the solution to the problem will have been spent in vain.
Valid blocks are taken over by the other nodes that include them at the top of your copy of the blockchain. When this happens it means that the other nodes validate and accept that block and, from that moment on, the node is in possession of the bitcoins it has mined, being recognized by the network, the right to spend those bitcoins.
4 - Independent selection, by each node, of the chain that proves to have the highest amount of cumulative computation through Proof-of-Work.
The last step towards network consensus is to add the block to the blockchain by selecting the chain with the highest amount of Proof-of-Work. Usually, this chain will be the chain with the largest number of blocks. The node will try to identify the parent block using a field included in the current block that indicates it. In most cases it will be the end of the current chain. By selecting the valid chain with the most cumulative work, all nodes will reach consensus across the network. Temporary discrepancies disappear as more work is accumulated in one of the chains. Mining nodes “vote” on the longest chain when choosing the chain to which they will add the blocks they “mine”.
At the end of this process, the chain will be extended by another block and a new competition is started to add the next block.
From the consensus that is achieved by the growth and maintenance of private copies of the blockchain, comes the strength of Bitcoin.
It is this decentralization that makes Bitcoin unalterable and “unbreakable”.
Changing a transaction for your own benefit would mean changing 51% of the blockchain copies, to change the network consensus. To achieve this, it would have to have more computing power than half the computers that are today dedicated to mining bitcoin. At the moment, there are more than 10,000 nodes that supply the network with a total of 100 million Terahashes per second. This number is a 1 with 18 zeros behind - 100 000 000 000 000 000 000 000. That is, every second, in the total Bitcoin network, this number of attempts are made to discover the solution for the Proof-of-Work that allows publish the next block!