Nodes are the pillars of a blockchain network. Each node plays its part in maintaining the network and ensuring consensus about the blockchain’s state. Managing the constant stream of unconfirmed operations that flow across the network is one of a node’s most important duties.
The purpose of the mempool, short for memory pool, is to temporarily store and manage the movement of new operations before they are validated and baked into blocks.
Without a mempool, it would be impossible to control the vast amount of operations that are being constantly made on the Tezos blockchain.
As the number of operations increases, the mempool must manage a greater volume of tasks. One of the most important duties of the mempool is to efficiently manage resources in order to prevent accidental overloading or intentional flooding by adversaries.
To improve overall resiliency, the node uses the actor model, a conceptual model for software architecture in which tasks are performed by individual actors. An actor is a primitive unit of computation that is capable of performing tasks, but is completely separated from other actors and can use various strategies to automatically recover from failure.
How operations are processed inside the mempool
To understand what happens inside the mempool, here is a scenario in which an operation enters and exits the mempool, starting when it is received from the network and ending when it has been baked into a block.
1. A P2P message arrives from the network
A P2P message of the CurrentHead type arrives from the network.
It is then processed by the ChainManager, an actor that is responsible for processing all of the messages that come in from the P2P network once a trusted connection has been established.
The CurrentHead contains only the hashes of operations. In order to get the full details of these operations, Alice’s node...