Ethereum is one of the most popular blockchain protocols, previously it used to work with a Proof of Work model and now has moved to Proof of Stake. In the proof of work system there is something called a Miner, which is someone that offers computing power in order to solve a mathematical puzzle in exchange for tokens from the blockchain protocol. In Ethereum these miners had the ability to build transaction blocks in a way that would maximize the amount of profit (tokens) they would make from each block. In this article I am going to explain how this process of maximizing the amount of value a miner would get, more commonly called Miner Extractable Value (or Maximal Extractable Value), has changed the Ethereum ecosystem and why it is one of the most important aspects of blockchain protocols.
Transaction Order
In order to have transactions processed people have to pay a fee, in Ethereum's case is called gas, so that the miner has an incentive to validate their transaction, the higher the fee (gas) the higher the chance the miner will give that transaction a higher priority. Over time people realised that there is a lot of value in knowing which transactions are going to happen first, so a lot of attacks started happening because of that, some of the most popular were front-running, sandwich attacks, bandit attacks and DEX arbitrage.
What is a mempool and how does it work?
Before transactions become part of the oficial Ethereum blockchain history they go through a network of nodes in order to validate them, each one of these nodes has it's own history and a list of unconfirmed transactions or blocks which is called a mempool. An analogy would be an exchange, where people place transactions but they are not executed right away, they only happen after someone fulfill's their order, the difference is that in Ethereum the equivalent of someone fulfilling their order would be the miner validating the transaction and including it in a block.
Because Ethereum works using a peer-to-peer network protocol, each node is only connected with a set of neighbors and not the entire network of nodes. Also, some of the nodes off load the work to mine for specialized GPUs and hardware that exists outside of the chain, this means in Ethereum it was possible for a miner to validate transactions and build blocks completely outside of the chain and send the entire blocks to other node's mempools only after the block was already built. This is one of the crucial points on why MEV is considered to be a centralizing force.
Searchers
Because there is money to be made by observing the transactions that are happening and in what order they will be included in a block, a group of people starts to specialize in creating bots that will take advantage of these opportunities, these people are often called "Searchers".
RPC Providers
RPC or Remote Procedure Call is a networking method used in programming to communicate between clients and servers, this is what is used to connect the 'outside world' to the Ethereum network. It is based on JSON commands that anyone can use in order to communicate with nodes in the network. So if you build your own node you can configure it to determine who can have access to it in order to send transactions, allowing you to build an application that receives transactions and than passes(relays) them to your own node.
Understanding transaction flow on Node's mempools
In Proof of Work the 'oficial' chain is the one that has the highest difficulty to solve, which is the one that is going to be the longer chain because each block increases the difficulty for the next block, so it´s important to understand that at any given moment there can be different 'forks' in the blockchain, so multiple different histories can exist at the same time. Let's say that node A receives 10 blocks per minute and node B receives 5 blocks per minute, because each node in the network is connected eventually both of the nodes will receive all of the transactions, but the problem here is since node A receives more transactions than node B, there is a delay for node B to update it´s history, which means it becomes more likely that node A will have control over the transaction flow of the blocks, because it receives transactions faster, as discussed earlier the order of transactions really matter, so node A will make most of the money.
Not only that but if node A has connections to searchers than what it can do is make an agreement with them to receive their transactions off chain, build the blocks off chain and only then send those blocks through the mempool, this is what a company called Flashbots started doing. This gives anyone that send transactions through them a massive advantage because their transactions will only be seen by other nodes once they are already included in a block, the flip side is they will have to trust the relayer, in this case Flashbots, and the miners associated with them to not steal their MEV (front running them, stealing their DEX arbitrage, etc...) and to not censor their transactions.
Why use blocks?
You might be asking yourself, why not just make it so that nodes can only send transactions to each other and not full blocks? This is a design choice from the people that created Ethereum, the data structure that they decided to use was a merkle patricia trie, without going into too much detail, both in proof of work and proof of stake consensus mechanisms you need to find a way for multiple nodes to agree on the history, this is also commonly called the The Byzantine Generals Problem, this means that it is necessary to keep track of different hashes of blocks and transactions, because of the nature of the data structure it becomes more optimal to batch transactions into blocks instead of having to validate and send them to other nodes separately.
Conclusion
Transaction order is one of the most important things to consider when designing a blockchain because it creates MEV, which is a centralizing force. In order to deal with this in the Ethereum network, the consensus algorithm was changed from Proof of Work to Proof of Stake and something called Proposer Builder Separation was created, which you can read about it here.