本文 Hash(SHA 1):b366289db9b21c3e9b6668c274e4a179be57a463

Number: Lianyuan Security Knowledge No.008

In the past few years, the blockchain economy has experienced exponential growth, especially in 2022, when the locked value of the DeFi ecosystem reached a peak of $300 billion. Web3 has developed to the present, and various attack methods and logical security vulnerabilities have emerged. Since 2017, the maximum extractable value (MEV) has been at the forefront of the attack methods for the amount of loss on the ETH chain. The ChainSource Security Team has made relevant analysis and sorting of the basic principles and protection methods of MEV, hoping to help readers improve their ability to protect the security of their own assets.

MEV Basic Principles

MEV, the full name of which is Maximum Extractable Value, was also called Miner Extractable Value in the POW era of Ethereum. It was renamed Maximum Extractable Value after a large number of blockchains were converted to POS, because block producers are no longer the only role that determines the order of transactions (currently the roles with these two permissions are miners and validators, and previously there were only miners).

MEV refers to the measure of profit earned by participants such as validators or sequencers by performing selective operations on transactions (including transactions, sorting transactions, and reordering transactions) within the blocks they produce.

Validators: Participants responsible for validating transactions and producing blocks;

Sequencer: The participant responsible for deciding the order of transactions;

Include transactions: select which transactions will be included in the block;

Exclude transactions: select which transactions will not be included in the block;

Reorder transactions: determine the order of transactions in a block;

Currently, hackers using MEV mainly target wallet addresses that have obtained airdrop snapshot qualifications and whose pledged tokens are about to be unlocked. The prerequisite for hackers to launch such attacks is to obtain the wallet private key, and then turn on dynamic Gas monitoring, waiting for the user's tokens or Gas fees to arrive before sending a withdrawal transaction in the same block or adjacent blocks, which is called a front-running transaction. We call this type of monitoring robot a Sweeper robot.

Protection methods (taking ETH as an example)

First of all, there are two ideas for this type of protection. Since the goal is to compete with hackers in terms of speed, the first approach is to increase the Gas price and the Nonce of transaction sorting.

Because Ethereum's transaction fee = Gas (quantity) * Gas ​​Price (unit price), and the Gas Limit capacity of each Ethereum block is fixed, whoever has a higher Gas Price will have their transaction packaged into the block for confirmation first. In addition, the nonce in Ethereum represents the number of transactions. This concept should be combined with the fact that Ethereum itself is account-based, so each different account maintains its own nonce, and each transaction of each Ethereum account will have a unique nonce, which can prevent replay attacks (the same transaction is processed multiple times) and allow the EVM virtual machine to clarify the order of transactions (for example, if the nonce of a transaction is 5, then before this transaction is processed, the transaction with a nonce of 4 in the account must have been processed)

The second idea is to connect to nodes with faster confirmation speed and higher transaction obfuscation.

If you want to change the connection node, the first recommendation here is the TAICHI network node. This network is a privacy and security solution based on blockchains such as ETH and Solana. It introduces a series of relay nodes to achieve transaction obfuscation and privacy protection. These nodes are responsible for receiving user transaction requests and mixing them with other transactions to hide the source and purpose of the transaction.

Relay nodes: These nodes are the core of the TAICHI network, and they are responsible for receiving, mixing, and forwarding transactions;

Transaction mixing: By mixing multiple transactions together, relay nodes are able to effectively hide the source and purpose of individual transactions;

Privacy protection: This method can effectively prevent on-chain data analysis and tracking, protecting user privacy;

The way Sweeper works is to monitor transaction records in the public memory pool to achieve preemptive transactions, but the TAICHI node allows us to submit signed transactions directly to miners without broadcasting through the public memory pool, which means that Sweeper is very likely to be unable to monitor, and there is a possibility of preemptive Sweeper (the public memory pool refers to the collection of transactions that have been broadcast but not yet packaged into the block).

The second recommended node is FlashProtect. FlashProtect is a solution to the MEV problem in the Ethereum system provided by the FlashBots organization. It works by packaging the user's transactions and sending them directly to the miners through Flashbots instead of through the public memory pool, to prevent malicious miners and robots from finding and using these transactions in the public memory pool to use MEV to extract funds. Its disadvantage is that the transaction speed is very slow because it uses the Flashbots memory pool, which has far fewer validators than the public memory pool.

Conclusion

In general, various protection methods are also aimed at maintaining the sorting process of decentralized transactions and ensuring that smart contracts handle transactions in a fair manner, but the most fundamental solution must be to make adjustments from the perspective of miners and validators.

Lianyuan Technology is a company focusing on blockchain security. Our core work includes blockchain security research, on-chain data analysis, and asset and contract vulnerability rescue. We have successfully recovered many stolen digital assets for individuals and institutions. At the same time, we are committed to providing industry organizations with project security analysis reports, on-chain traceability and technical consulting/support services.

Thank you for reading, we will continue to focus on and share blockchain security content.