The Berlin hard fork bug caused by the gas consumption difference of the 0x10 address

avatar
Tokenview
3 years ago
This article is approximately 530 words,and reading the entire article takes about 1 minutes
The source of the OpenEthereum bug at block #12244294: OpenEthereum includes a precompiled list of EVM implementations!

Ethereum OpenEthereum single client in the block #12244294The bug at caused the Ethereum network to shut down at that time, and it was unable to keep up with the network after the problematic block was generated. So what was the cause of this accident?

Use the Tokenview Ethereum browser to view the transaction that triggered the accident:https://eth.tokenview.com/cn/tx/0x7006f38fa2e6654fae1a781aefc5885fe0cb8f778b1add10636eaf7e34279247

This is a contract call transaction, which distributes ETH from KuCoin exchange to other addresses.

The Berlin hard fork bug caused by the gas consumption difference of the 0x10 address

Lets carefully analyze the contract calling process:

The Berlin hard fork bug caused by the gas consumption difference of the 0x10 address

1. In the Data Input column of the browser, the parameters of the contract call are displayed. The first line indicates that the address list starts from 40 (hexadecimal) bytes, which is 64 bytes. The fourth line in the figure, The second line indicates that the list of the transfer amount starts from the 1a0 (hexadecimal) byte, that is, 416 bytes, the 15th line of the data input column.

2. The transfer is carried out in the order of the address list, and the amount transferred to each address corresponds to the list of transfer data one by one.

3. Now we start to traverse the address list, look at the 10 (hexadecimal) in the third line, which means that we will transfer ETH to the next 16 addresses.

The Berlin hard fork bug caused by the gas consumption difference of the 0x10 address

According to the order in the figure, when counting to the 10th, the found value becomes 10. This value is actually the length of the list representing the transfer amount. But according to the instructions in the third line, it should be transferred to 16 addresses, then the contract will use 0x10 as the address to continue the transfer operation, and transfer 0 ETH to the address 0x10.

In fact, 0x10 is one of the special addresses of the EVM, which is entirely within the EVMs list of precompiled contracts. It is a precompiled contract asserted by EIP-2537 for the BLS pairing cryptography program, butThis EIP has not been deployed to the mainnet yet.

secondary title

The gas consumption of the 0x10 address diverges

The Berlin hard fork changed the measurement method of Gas consumption in EVM. After the implementation of EIP-2929, if the state storage operation is performed on the same storage slot multiple times in a transaction, the first execution will consume more Gas, and the subsequent execution will consume less gas.

This is the source of the OpenEthereum bug at block #12244294: OpenEthereum includes a precompiled list of EVM implementations.Therefore, OpenEthereum will give a gas discount to the transaction that accesses 0x10 in this transaction. However, most active clients of the network do not implement EIP-2929 in this way, and they only provide gas discounts for transactions that access activated precompiled contracts.

As a result, the OpenEthereum clients calculation of how much Gas was consumed by the transaction diverged from other clients in the network.

This OpenEthereum single-client downtime caused by gas consumption divergence is not serious enough to cause a major chain fork, but it also reminds us to use multi-client implementation to improve resistance.

It is undeniable that blockchain technology is still in the process of constantly trying and advancing. Defi and NFT, which broke out in 2021, will also spread to more audiences at an unprecedented speed. Tokenview hopes to join hands with more developers to create better blocks. chain world.

Original article, author:Tokenview。Reprint/Content Collaboration/For Reporting, Please Contact report@odaily.email;Illegal reprinting must be punished by law.

ODAILY reminds readers to establish correct monetary and investment concepts, rationally view blockchain, and effectively improve risk awareness; We can actively report and report any illegal or criminal clues discovered to relevant departments.

Recommended Reading
Editor’s Picks