Author: Xiang, W3.Hitchhiker

 

Regarding the Ethereum Shanghai upgrade, let’s briefly sort out the benefits it can bring.

Referring to the latest public information of Ethereum, the EIP related to the Shanghai upgrade is as follows:

  • Confirmed included EIPs: EIP-3651, EIP-3855, EIP-3860, EIP-4895

  • Possible EIPs: EIP-3540, EIP-3670

  • EIP-4488 and EIP-4844 related to L2 expansion are not included in this upgrade.

     

EIP-3651: Warm COINBASE

 

Speaking of EIP-3651, we have to first introduce a change in EIP-2929:

When the target is not in accessed_addresses, COLD_ACCOUNT_ACCESS_COST (cold account access cost) gas is charged and the address is added to accessed_addresses. Otherwise, WARM_STORAGE_READ_COST (warm storage read cost) gas is charged, and warm read consumes relatively low gas.

Nowadays, direct payment with COINBASE is becoming more and more popular, but the price of accessing COINBASE is currently high; this is because under the access list framework introduced by EIP-2929, COINBASE calculates gas based on the cost of cold account access. After EIP-3651, accessed_addresses will include the address returned by COINBASE (0x41).

 

benefit:

After the modification, COINBASE will reduce gas consumption when paying ERC20 tokens.

 

EIP-3855: PUSH0 instruction

 

EIP-3855 introduces a new instruction (0x5f) to push the constant value 0 into the stack. The Yellow Paper's instruction set for PUSH currently only has PUSH1-PUSH32, which is used to push 1 byte into the stack, up to 32 bytes into the stack.

The existing instruction implementation pushes a value of 0 into the stack by executing PUSH1 0 , which consumes 3 gas in the runtime and an additional 200 gas (2 bytes of storage cost)

With the PUSH0 instruction, there is no need to consume the extra 200 gas.

benefit:

Currently, about 11% of PUSH operations only push in 0, so this EIP can save a certain amount of gas after execution, and can also slightly improve Ethereum's existing TPS.

 

EIP-3860: Limit and compute initialization code

 

Currently, the maximum initcode size is MAX_CODE_SIZE: 24576 (EIP-170), and the new maximum initcode size is (MAX_INITCODE_SIZE = 2 * MAX_CODE_SIZE = 49152), which means that the contract size can be doubled, and contract developers can deploy richer functions. (Contract code that is too large will lead to unsuccessful deployment. PS: The L2 project has also been partially modified to support a higher contract size limit)

In addition, a 2 gas fee is introduced for each 32-byte initcode chunk to represent the cost of jumpdest-analysis. Because during contract creation, the client must perform jumpdest analysis on the initcode before execution. The execution work is linearly proportional to the size of the initcode.

This means that the cost of initcode will increase by 0.0625 gas per byte, and the gas cost of contract deployment will increase slightly.

benefit:

The gas fee for contract deployment is slightly increased, but the contract size can be doubled, and contract developers can write richer functional codes.

 

EIP-4895: Beacon Chain Withdrawals

 

The main content is to determine the main process of withdrawing funds from the beacon chain to EVM. After the deployment is completed, the Ethereum beacon chain staking withdrawal function will be activated.

benefit:

Activate the Ethereum beacon chain staking withdrawal function.

 

EIP-3540: EVM Object Format (EOF) v1

 

This EIP involves major changes and is not necessarily included in the Shanghai upgrade.

The format described in this EIP introduces a simple and extensible format and introduces verification. It achieves the separation of contract code and data.

The new EVM object format is: magic, version, (section_kind, section_size)+, 0,

benefit:

Versioning facilitates the introduction or deprecation of new features (for example, the introduction of account abstraction).

The separation of contract code and data is beneficial to L2 verification (op) and reduces the gas cost of L2 validators;

The separation of contract code and data also makes it easier for on-chain data analysis tools to work.

 

EIP-3670: EOF — Code Verification

 

This EIP is not necessarily included in the Shanghai upgrade, and it introduces code verification when creating contracts in conjunction with EIP-3540. Contracts with undefined instructions are rejected.

benefit:

When creating a contract, code verification can be introduced