How does the peer-to-peer network of a blockchain work?
A peer-to-peer system makes it possible to transfer value between two users by eliminating the need for an intermediary. This is the case with blockchain technology, where nodes record transactions on the blockchain network by verifying each other.
Eliminating the middleman
Blockchain is a collective upgrade. It is a decentralised system, which means that anyone can choose to participate in the network by validating transactions together with other participants with equal responsibility.
In a normal situation, when we pay someone with a bank transfer, the bank acts as intermediary.
This means that the bank:
- provides the infrastructure used to send payments
- guarantees the security of our operations
- verifies the correct execution of transactions
- updates its database storing all transactions
- … and in return for this they charge fees (and the bureaucracy of opening a current account).
On the blockchain, the same thing happens, with one fundamental exception: the single operator is replaced by thousands of operators. However, it is not people themselves who do the necessary work, but computers and devices belonging to individuals or companies. Any device that connects to the interface of a blockchain is called a node. Since anyone can open a node, in some cases even with a laptop, they can be located anywhere in the world.
In general, nodes are all devices that store the blockchain’s transaction history. Each node contains a complete record of all transactions that have been recorded on that blockchain, i.e. an up-to-date copy of the ledger or ledger.
Nodes can also decide to become validators, or in the case of Bitcoin, miners.
A validator or miner is a type of node that not only stores a copy of the blockchain, but is also responsible for checking transactions transmitted to the blockchain and recording them on the blockchain.
The validators of a network ensure that the rules of the protocol are followed and that all transactions take place correctly.
Since there is no central authority telling the nodes what to do or controlling their actions (as a bank does with its operator), they must be able to agree on their work. Furthermore, there must be a mechanism that drives the nodes to act for the common interest and not for selfish interests. This mechanism is the consensus algorithm. The consensus algorithm is written into the protocol. A protocol is a set of rules that define the way in which two or more entities talk to each other.
For instance, the HTTP protocol allows dialogue between client and server. In most common cases, HTTP allows a web browser to connect to the server hosting a certain site and thus to display this website on the computer or smartphone interface.
Similarly, the protocol of a blockchain regulates the relationship between the nodes of the network and how they reach consensus.
What are consensus algorithms?
Consensus algorithms owe their name to the fact that they allow validators in a network to reach a consensus regarding the validity of the addition of transactions organised in new blocks. The interaction between validators is based on the respect and fulfilment of rules written in the protocol in the form of code. Any interaction or configuration that falls outside these rules is excluded a priori, so it cannot occur. This is why it is said that on the blockchain, the code is the law.
If, for example, we consider the Bitcoin blockchain, the Bitcoin protocol is the set of rules that defines the very structure of the blockchain and its entire functioning: from the way transactions are requested and recorded and the cryptographic functions used, to how fees and wallets work, and even the consensus algorithm.
Each protocol has its own consensus algorithm. Bitcoin for instance achieves consensus on transactions according to Proof-of-Work.
Decentralised consensus and the immutability of transactions make the blockchain both error-free and immune to manipulation, thus increasing not only the security of the network compared to classical databases, but also the reliability of the recorded information.
Finally, although all recorded transactions are searchable, the blockchain does not require users to register and does not provide for prior checking of them, thus offering a high level of anonymity.
How does a transaction take place on the blockchain?
There are different models for achieving consensus. Regardless of the technical specificities that distinguish the various blockchains, the validation and consensus mechanism basically consists of the following procedure:
- validator nodes are informed in real time of a transaction
- validators agree on the validity of the transaction
- a selected validator confirms and records the transaction and/or blocking
- Request. The request to transfer n cryptocurrencies from wallet A to wallet B is transmitted over the network of nodes.
- Verification. Nodes see the transaction. Some special types of nodes – miners or validators – verify the validity of the transaction and reach a consensus on validity.
- Registration. If deemed valid, the transaction is recorded in a blockchain block irreversibly and immutably.
- Update. Nodes update their copies of the blockchain. Now all nodes know that wallet A can no longer send those specific cryptocurrencies back to wallet B or another wallet (so-called double spending) because it has already transferred them and they no longer belong to it.
Summary of concepts
- A node is any device connected to a blockchain that holds an up-to-date copy of it
- A blockchain protocol defines the way the system is to function; it is the set of rules that allows nodes to exchange information and validate blocks.
- A consensus algorithm is the mechanism by which these rules are enforced, allowing nodes to reach consensus on a given transaction.
Blockchain is a technology that allows money to be sent directly between two people (peer-to-peer) without going through a bank, credit card company or payment service. Instead of a bank, a network of nodes validates and records the transaction between the parties.
For the first time in history, the blockchain allows two people to exchange value through a decentralised network of nodes capable of reaching a consensus without the need for a controlling authority to act as arbiter. This is possible because the blockchain is not based on trust but relies on a complex consensus mechanism.