Explanation with examples
Blockchain in simple words
Trust as a foundation
Since ancient times, people have been preoccupied with the problem of preserving reliable information, how events were perceived by contemporaries, and not by ungrateful descendants rewriting history to please current political preferences. A radical approach was used by the Egyptian pharaohs, who carved out the words of truth about their great deeds on the obelisks.
The inscription on one obelisk can be destroyed. But if there are many obelisks with similar records, and they are located in different countries, the task becomes more difficult. And the more there are, the more difficult it will be to come to an agreement. It’s another matter if the truth about their victories is cut out on obelisks (nodes or in modern terminology — nodes of a distributed database). Then it makes sense to maintain your node (obelisk) as well.
The blockchain can be compared to an obelisk made up of stacked blocks. The lower block cannot be pulled out — the whole pyramid will fall apart. The more blocks there are above your block with the “truth” — the more difficult it is to replace it, and this must also be done on all the other pyramids.
On the stone block, not only the deeds of the pharaohs, but also the records of ordinary people can be engraved. For example, Paul transferred ownership of the land to Alex. The main thing is that Paul should agree with the creator of the block, in modern terminology, the “miner”, so that he makes a record and organizes the placement of new blocks on all pyramids.
Every miner wants to get money for installing a block he chopped down. And the blocks still need to be dispersed along different “obelisks” — this takes time. The result is a situation where different blocks are located at the top of the obelisks of different countries. And the builders need to come to an agreement (consensus) — which blocks to leave, because in the end all “obelisks” (versions of the truth) should be the same.
The most democratic choice is according to the work spent on construction (proof of work, PoW). The miner, who has quickly cut down the next block correctly, will have time to dilute it into a larger number of “pyramids”. Where its blocks will be installed, miners will start doing the following. The pyramid builder, who received blocks from competing miners, will choose blocks from a higher pyramid, because he does not want to do the hard work in vain and will bet on the leader.
Everyone supports a more promising version of the final pyramid, so there is a kind of absentee voting of builders, and a responsible vote — they are responsible for the correct choice with their hard work. The miner who is the first to cut down the next block is more likely to win, but the probability of success will depend on the time gap with competitors and the speed of work of the builders of other pyramids who supported his “version of truth”.
The art of finding consensus
In the Bitcoin blockchain, six blocks on top are considered to ensure that the underlying structure remains unchanged. The capacity spent on their manufacture serves as a guarantee. However, in an extraordinary situation affecting the interests of the majority of miners, the option is not excluded when the owners of the pyramids agree and demolish a larger number of blocks (hard fork).
In the Ethereum blockchain, such an agreement was reached after a successful attack by an attacker on The Dao project. This is an extremely rare situation, so if there is an error in the record, it will not be possible to correct it retroactively.
Another problem is that miners can unite in artels (pools) and jointly make blocks, dividing the proceeds among themselves. If such a “artel” takes a dominant position in the market (concentrates more than half of the capacity in its hands), it will be able to impose its version of the truth on other players (“50 percent” attack).
The increase in the complexity of cutting a block increases the time for its production, the time for the delivery of previously produced blocks and, as a result, makes it easier to reach consensus. On the other hand, it reduces the speed of building pyramids. So you have to find a compromise and take into account the development of tools that speed up the work of miners.
Multiple duplication of records in independent “pyramids”, the dependence of new blocks on old ones (if you pull out the old block, the whole pyramid will fall apart) and the method of consensus when choosing new blocks are the main principles of building a blockchain.
In digital time, stone blocks were replaced by digital ones, but the principle remained the same. New blocks depend on old ones, and the more network nodes with registries of records, the more stable and reliable. But there were also innovations related to cryptography.
The new user of the blockchain network receives a storage, something like a mailbox in the entrance of the house, and keys (open and closed). Anyone who knows the address of a mailbox can throw money or a letter into it, but only the owner of the key can get it. This is a private key that cannot be lost or transferred to another — otherwise no one can help a person.
Using a private key, a person signs a message transmitted in a transaction (a record for cutting down on a block), in fact, he encrypts the hash of the message with his private key. Hashing means converting an arbitrary amount of data into a bit string of a given length. The bitcoin blockchain uses SHA-256 as a hash function.
A block of transactions is collected by special craftsmen (miners). The block records the transfer of letters (money, documents) from one “mailbox” (wallet) to another. The miner checks (validates) the records — whether it complies with the protocol (rules adopted in a particular blockchain), the correctness of the electronic signature, whether there is enough money to transfer in the wallet, and discards the unusable ones.
When using PoW, a miner has to solve a complex computational problem — analogous to the hard work of carving a stone block. Select the value of the service field so that the final value of the hash function of the block, including the hashes of transactions and the hash of the previous block (linking to a chain, an analogue of placing a block on top of a block), is less than the specified value, for example, it starts with ten zeros. In fact, miners competing for the right to sign a block and receive a reward for this pay with the used computing power.
Economic model, potential threats
The PoW method consumes a huge amount of resources, and it is very inefficient — all miners “cut” blocks, but in the final version there will be only one. According to researchers at the University of Cambridge, over the past year, bitcoin production consumed more electricity than the whole of Argentina consumed.
But the method has proven to be reliable and safe. It is used in the most popular blockchains — Bitcoin and Ethereum, although it has been criticized for wastefulness, especially in the context of the struggle for the environment and the reduction of consumed resources.
The most popular alternative methods are Proof of Stake (PoS) and its variation — Delegated Proof of Stake (DPoS). They do not waste huge computing power, builders do not compete in the speed of “cutting” heavy blocks, the complexity of the task is not important. Delegates collecting a block from transactions, who were voted for by the participants in DPoS or directly by the participants — the owners of wallets (PoS), no longer have to mine, spending huge computing resources in the struggle for the right to be the first to find the coveted figure.
They are selected according to the established rules (protocol), while the probability of performing the work will be higher for the participant who contributed a large share to the project.
In PoS terminology, a block builder is called a forger. Forgers use the public keys of users to check the correctness of records and the availability of money in wallets, and then sign the block with their private key. The forger of the winning block receives commissions.
The more cryptocurrencies a participant has, the more likely it is to get into delegates (forgers). The more money a person can lose in the event of a project collapse (users refuse to use the blockchain and the constructed pyramids will no longer be needed by anyone), the more responsible he will reat his work and will not distort information in collusion with the attacker.
There are more theoretically possible attack vectors on PoS blockchains. Saving energy resources when using PoS leads to the ease of block cutting and, accordingly, the ease of supporting the construction of several “columns” at once. Blockchain developers have to think about punishment mechanisms that support multiple chains of players to prevent a “side-branch” attack — an attacker creating an alternative blockchain that includes distorted information.
In addition, there is a problem of centralization of capital in PoS systems. The more money, the more blocks you can build and earn on transaction fees. As a result, the operation of the network is controlled by a limited number of people, which is especially often manifested in DPoS — the “delegated” version of PoS.
Blockchain is a version of the collective truth in an environment where the risks of loss from information distortion outweigh the cost of building and maintaining the network.