We are now ready to move on to communicating and processing of transactions in a peer-to-peer network (Drescher 2017 and Bashir 2018). As we are not going to technical details in this course, only an overview of these is given here.
We discussed peer-to-peer networks in the beginning of this course, and many of these networks, including blockchain networks, work on the Internet. The communications on the Internet are prone to failures and challenges and therefore the blockchain network should accommodate for these. Messages that are sent are not guaranteed to reach their recipients, messages may arrive more than once and in different order than in which they were sent. However, at the same time all the nodes in the blockchain should have identical information on the contents of the blockchain all the time. How can this be resolved?
First, the messages are sent from peer to peer, so that whenever a node receives a message it sends it to all the nodes it has a connection with. Each node orders the information with the help of time stamps included in all transaction data and block headers. Combined, this will keep the network alive while distributing information effectively. Along with forwarding new transaction data, ownership-related information is transferred in the network also when new nodes enter the network which means they receive the whole blockchain data structure for their safe-keeping and check-up when they function in the network.
How do nodes then process the information transferred in the network? Usually, e.g., in Bitcoin, blockchains employ a rhythm, where all the nodes either evaluate a new block of transactions and determine if it is valid or not or then they try to create a new block which contains the new transactions that take place in the network (for more details, see Bashir 2018). This algorithm ensures every node has some computational work to do, and that they are all working for the same goal. The rhythm is kept by the fact that when a node receives a message containing new block it will start to evaluate its correctness. When the evaluation stops, the node will start verifying new transaction data and creating a new block out of this data.
Each node processes new blocks while sending these blocks forward to other nodes. The nodes also check new transaction data if they are correct, depending on the use of the blockchain network. When valid transaction data is collected, each node starts creating a new Merkle tree out of the transaction data and building a new block by creating a solved hash puzzle. When a new block has been created, all the nodes individually solve for its hash puzzle and then verify the correctness of its transaction data. After that, each node adds valid blocks into their blockchain data. Then a similar process on new, freshly arrived transactions is begun. If invalid blocks are added to the blockchain data structure, when discovered, the block and all its preceding blocks are deleted from the blockchain data structure.
These functions guarantee correct functioning of the blockchain network. As the data is immutable and the connection between nodes is coherent, the blockchain will uphold its data structure truthful and is safe from malicious peers trying to take advantage of the transactions in the network. However, there is still the problem of keeping all the nodes informed of all the transactions taking place so that they are equally aware what takes place in the network. Dealing with the flow of information, there are issues like double-spending, which we will discuss in the next Chapter.
Detailed description of working principles of Ethereum: https://ethereum.org/en/whitepaper/