In the Berlin upgrade, what is the significance of EIP-2929 increasing gas costs?

In the Berlin upgrade, what is the significance of EIP-2929 increasing gas costs?

Written by: Vitalik Buterin
Translation: ETH Chinese website

summary

  • Yes, some opcode calls will require more gas overhead, but this must be done to improve safety.

  • But on the other hand, an operation that should have been cheaper all along (a store followed by a load of the same slot) ends up being cheaper.

  • Another important benefit is that it is now safer to increase the gas limit moderately. The main reason to limit the increase in the gas limit is now more about state size.

The EIPs that caused changes in gas costs in the Berlin hard fork are: EIP 2565 (reducing the gas cost of ModExp modular exponentiation operations), EIP 2929 (increasing the gas cost of SLOAD and CALL), and EIP 2718 and 2930, to support the compatibility of contracts affected by the increase in gas costs and pave the way for future upgrades.

Currently, the most important of these EIPs is EIP-2929. Its core content is: the gas cost of SLOAD increases from 800 to 2100, the gas cost of CALL (including STATICCALL, DELEGATECALL and other opcodes) and external contract queries (BALANCE, EXTCODESIZE, etc.) increases from 700 to 2600, but this only happens when the address and storage slot are accessed for the first time in a transaction.

The purpose of this is to further improve the ability to resist DoS attacks: early research showed that the biggest DoS vulnerability in the Ethereum protocol is in storage access, and it is possible to create some blocks that simply access a large number of accounts repeatedly, and the processing time may be as long as 80 seconds. The solution is a simple quick fix: make these operations last longer (storage access requires disk access) to consume more gas, and eventually the DoS problem will be weakened by about 3 times. In the meantime, the client team has done some excellent work - implementing disk storage caching, reducing the number of database queries required for storage loading, and plugging this vulnerability in the long run.

The gas cost repricing combined with these client improvements makes the existing blockchain more secure and makes it safer to provide a gas limit than it is now. After EIP-2929, the main reason to avoid a large gas limit increase is actually no longer the DoS attack problem, but the increase in state size (these two aspects affect each other: storage loading consumes more gas when the storage load becomes larger). Therefore, state expiration and statelessness will become very important, and can even be said to be the top priority after the "merge".

The second biggest long-term benefit of this repricing is that the witness size for stateless verification can theoretically be reduced by up to a factor of 3. For code reading, we will also need a repricing (something like: 500 gas per 31 bytes of code access), but this can be implemented in the future.

Please note: this EIP only increases the gas cost for the first access of each transaction. Subsequent accesses are actually cheaper (100 gas in all cases). In addition, calls to the precompile always cost only 100 gas, including the first call. This has the following positive effects:

  • Any SSTORE after a SLOAD (or SLOAD after an SSTORE) in the same slot will become cheaper. This is because the first storage read or write and the gas fee paid to access the storage slot have already been "warmed up", and the first read and write will be cheaper; so, instead of 800 + 5000 gas, we need to pay 2100 + 2900 (approximately), a reduction of about 800 gas. This may make forwarding of ERC20 protocol standard tokens cheaper.

  • Self-calling becomes cheaper

  • Calls to precompiles become cheaper (this is especially valuable for low gas precompiles that need to be called a lot of times, like ECADD)

The first access rule is added because when an account or storage slot is accessed for the second time, it should already be cached in the content, so no expensive disk access is needed. Of course, two accesses to the same value only require one witness entry.


<<:  Behind the 40 billion yuan "biggest case in the cryptocurrency circle", virtual currency has become a "new channel" for cross-border money laundering

>>:  South Korea’s digital currency regulation sparked public outrage, and the media made official reports into NFTs to “ridicule” them

Recommend

Mole position and destiny chart

Mole position and destiny chart Everyone has mole...

Palmistry diagram career line analysis

Palmistry diagram and career line analysis. Each ...

What kind of face makes women have a miserable life?

Some people give people the impression at first g...

The face of a person with a simple life

Everyone has a different lifestyle. Some people a...

What is the attitude of the CFTC while the SEC is frantically exporting?

For two consecutive days, the U.S. Securities and...

How to tell the marriage age from a woman's marriage line

A person's marriage age can be completely see...

Bitmain S19 series starts shipping, Huawei incident has little impact

Several miners revealed to Wu Blockchain that Bit...

BitGo Launches Low-Cost Bitcoin Open-Source Software

Among the digital asset security platforms, one n...

Mole diagram 10 lucky moles

Illustration of moles and the 10 lucky moles. Mol...

Facial features of people with a tough attitude

People who have a tough attitude in life are ofte...