# The Process Of Ethereum Block Building In this article I am going to talk about `MEV(Maximal extractable value)` & `PBS(Proposer/Builder Separation)` & / `Ethereum Block Building Process`. These are always discussed together because these things are closely interconnected and inevitably discussed with each other. ## The Merge The Merge has introduced two significant changes `POS(Proof of Stake)` & `PBS`. Let's leave `POS` apart and talk about `PBS` alone. I think it's important for eth devs to know how and why it's implemented. ### PBS (Proposer/Builder Separation) PBS is a key change introduced with the Merge. It separates the roles of block building and block proposing: 1. Block Builders: Specialized entities that create block contents, optimizing for MEV extraction and transaction ordering. 2. Block Proposers: Validators responsible for choosing and proposing the most valuable block to the network. PBS aims to mitigate some of these concerns by distributing MEV extraction more evenly and reducing the advantages of large, centralized block producers. This separation aims to: - Increase decentralization by allowing more participants in the block creation process. - Reduce the centralization risks associated with MEV extraction. - Improve block efficiency and network performance. Proposer/builder separation (PBS) fixes this by splitting the block construction role from the block proposal role. A separate class of actors called builders build exec block bodies (essentially an ordered list of transactions that becomes the main “payload” of the block), and submit bids. Vitalik covers the logic behind the prioritization as the following: > In the current transaction market, the block proposer (today: a miner, post-merge: a validator) directly chooses which transactions to include in the next block by looking at which transactions in the mempool pay the highest priority fee. This puts the block proposer in a position to use sophisticated strategies to choose which transactions to include, or even include their own, to take advantage of opportunities such as DEX arbitrage and liquidations (hereinafter just called “MEV” for simplicity) to maximize their profits. The complexity of these strategies creates a high fixed cost in running an effective miner or validator, and advantages centralized pools that take on this task on behalf of their participants. ### MEV-Boost >Nonetheless, it was clear to the developers that The Merge was a hard enough goal to tackle without also engineering a way to enshrine PBS (ePBS) within the protocol design itself. Therefore, the community opted to launch optional proto-PBS via a sidecar for validators that allows them to outsource block building on demand. This sidecar is known as MEV-Boost. ------ BlockNative As far as I know there're over 90% of blocks built by `MEV-boost` way. Let's check the differences and go through the detail of block building process. I will use the following two abbreviations to replace semantics. And assuming all the ELs are update to date > consensus layer client -> CL > execution layer client -> EL ##### Block Validation When consensus client is not block producer: 1. Using the `Gossip` p2p protocol inside the ethereum, eth CL receive the block's data and pre-verify the block info and extract the execution payload from the block. 2. CL would send the block payload which includes the transactions to the EL. 3. By caculating the block hash, EL would response with the status `Valid` to CL when all requirements are met. 4. The block that CL received from EL with a `Valid` status code would considered as a validate block. The validate block would verify the block header and then broadcast it to the p2p network. ##### Block Building ![image](https://hackmd.io/_uploads/SyMjEo530.png) (Image Source from ethereum.org) When consensus client is block producer: - Vanilla Builder (without MEV-Boost) 1. The CL would fill beacon block up to execution_payload and send the create block request to the EL. 2. The EL accesses the transaction mempool which has been populated by the transaction gossip protocol (execution p2p). 3. The EL bundles transactions into a block, executes the transactions and generates a block hash. 4. The CL grabs the transactions and block hash from the execution client and adds them to the beacon block. 5. The CL broadcasts the block over the block gossip protocol (consensus p2p).Other clients receive the proposed block via the block gossip protocol and validate as described above. - with MEV-Boost ![image](https://hackmd.io/_uploads/B1l-X-cnR.png) (Image Source from Flashbots Github) When running a sidecar, things are a little different from `ePBS`. First we need to know these entities: `Relay` / `Builder` /`Searcher` and carify their roles. - Relay: a middleware connected between validators and block builders. It performs as a trusted centralized secrow function, preventing validators from changing the block detail. - Builder: Block builders use sophisticated algorithms and often proprietary strategies to create the most profitable blocks possible. This specialization allows for more efficient block creation and MEV extraction while keeping the block proposing process more accessible to a wider range of validators. - Searcher: Searchers refer to those individuals who inspect the mempool and use specialized algorithms to detect and extract MEV opportunities, creating transactions that capitalize on these opportunities, such as by engaging in front-running. Relays act as intermediaries, aggregating constructed blocks from multiple builders. Their role is to identify and forward the most lucrative block to connected validators. It's worth noting that a single validator can interface with multiple relays via MEV-boost. Relays also employ a two-step disclosure process to prevent validators from exploiting MEV opportunities. First, they share only the block header with the validator, who signs and returns it. The relay then reveals the full block, including transactions. If a validator attempts to propose a different block to capitalize on the MEV opportunity, the previously signed header is submitted to the consensus layer, resulting in penalties for the validator due to conflicting signatures. This process is also as known as `commit-reveal mechanism`. The whole process is not the same when it comes to CL is block producer because the job of the EL part is outsource to `mev-boost`. And the CL would propose a block receive from the `mev-boost`. The fee receipent of the block would be set to the block builder and the block builder would construction a transaction that transfer some profit to the validator and the end of the block. Like: ![image](https://hackmd.io/_uploads/rJDTHhc2A.png) ## Reference - [ethereum/libp2p](https://ethereum.org/en/developers/docs/networking-layer/#libp2p) - [Engine API: A Visual Guide](https://hackmd.io/@danielrachi/engine_api#All-together) - [Trading in the Dark: Measuring Reordering Slippage in MEV](https://frontier.tech/measuring-reordering-slippage-in-mev) - [PBS Illustration of BlockNative](https://www.blocknative.com/blog/proposer-builder-separation-ethereum) - [What Does It Take To Be a Block Builder](https://crypticwoods.com/blog/what-does-it-take-to-be-a-block-builder/?source=post_page-----d1dca7dedf30--------------------------------) - [Maximal extractable value](https://ethereum.org/en/developers/docs/mev/) - [TX Life Cycle Thru. Lens of MEV](https://semanticlayer.io/blog/1) - [Enshrine Proposer Builder Separation](https://ethresear.ch/t/why-enshrine-proposer-builder-separation-a-viable-path-to-epbs/15710)