A quick explanation of what the point of the EIP 2929 gas cost increases in Berlin is

Cryptocurrency News and Public Mining Pools

A quick explanation of what the point of the EIP 2929 gas cost increases in Berlin is

The Berlin hard fork primarily consisted of gas cost change EIPs: EIP 2565 (modexp gas cost reduction), EIP 2929 (SLOAD and *CALL gas cost increase), and EIPs 2718 and 2930 to support compatibility for contracts affected by the gas cost increase as well as setting the stage for future upgrades.

By far the most important of these is EIP 2929. The core idea is this: the gas cost of SLOAD is increased from 800 to 2100, and the gas cost for CALL (including STATICCALL, DELEGATECALL and other opcodes) and external contract queries (BALANCE, EXTCODESIZE…) is increased from 700 to 2600, but only in the case where the address or storage slot is being accessed for the first time in that transaction.

The purpose of this is further DoS protection: earlier research showed that storage access is the largest remaining DoS vulnerability in the Ethereum protocol, and it was possible to create some blocks that simply repeatedly accessed many accounts that would take as long as 80 seconds to process. The fix was a simple quick fix: make the thing that takes a long time (storage accesses requiring disk access) cost more gas, so this DoS issue can be ~3x weaker. In parallel with this, there has been some excellent work in the client teams implementing on-disk storage caches, reducing the number of database lookups required for storage loads and plugging this hole even further.

The gas cost repricing and these client improvements together make the existing chain safer, and make higher gas limits safer than they are today. After EIP 2929, the main reason to avoid large gas limit increases may actually be not DoS concerns, but state size growth (those these two things interplay: storage loads cost more when there is more storage). Hence, work on state expiry and statelessness is going to be important, and probably should be priority #1 post-merge.

A second longer-term benefit of this repricing is that the maximum theoretical witness size for stateless verification is reduced by ~3x. We are going to need another repricing for reading code (something like: 500 gas per 31-byte chunk of code accessed), but this can be done later.

Notable, the EIP only increases the gas cost of the first access per transaction. Subsequent accesses are actually made cheaper (100 gas in all cases). Additionally, calls to precompiles always cost 100 gas including the first call. This has some excellent positive consequences:

  • Any use case of SLOAD followed by SSTORE (or SSTORE followed by SLOAD) of the same slot becomes cheaper. This is because the first storage read or write pays for accessing the storage slot, so it is already "warm" and the second read or write is cheaper; instead of a cost of 800 + 5000, we get a cost of 2100 + 2900 (approximately), a reduction of ~800. This may make ERC20 sends cheaper.
  • Self-calling becomes cheaper
  • Calls to precompiles become cheaper (this is especially valuable for low-gas-cost precompiles that many need to get called many times, like ECADD)

The first-access rule was added because when an account or storage slot is accessed the second time, that account or storage slot should already be cached in memory, so an expensive disk access is not required. And of course, two accesses of the same value also only require one witness entry.

TLDR:

  • Yes, some things will get more expensive. But they have to be for security.
  • But on the other hand, things that should have been cheaper all along (storing then loading the same slot) will finally be cheaper.
  • Another important benefit is that moderately increasing the gas limit becomes safer. The main remaining impediment to large gas limit increases will likely be state size issues.

submitted by /u/vbuterin
[link] [comments]