EIP-5920: PAY opcode
Introduces a new opcode, PAY, to send ether to an address without calling any of its functions
| 作者 | Pandapip1, Zainan Victor Zhou |
|---|---|
| 讨论-To | https://ethereum-magicians.org/t/eip-5920-pay-opcode/11717 |
| 状态 | Draft |
| 类型 | Standards Track |
| 分类 | Core |
| 创建日期 | 2022-03-14 |
| 英文版 | https://eips.ethereum.org/EIPS/eip-5920 |
目录
Abstract
This EIP introduces a new opcode, PAY(addr, val), that transfers val wei to the address addr without calling it. After FORK_BLKNUM, this opcode is added to the EVM.
Motivation
Currently, to send ether to an address requires you to call a function of that address, which has a few issues. First of all, it opens a reentrancy attack vector, as the recipient can call back into the sender. Secondly, it opens a DoS vector, so parent functions must be cognizant of the possibility that the recipient will run out of gas or revert. Finally, the CALL opcode is needlessly expensive for simple ether transfers, as it requires the memory and stack to be expanded, the recipient’s full data including code and memory to be loaded, and finally needs to execute a call, which might do other unintentional operations. Having a dedicated opcode for ether transfers solves all of these issues, and would be a useful addition to the EVM.
Specification
| Parameter | Value |
|---|---|
FORK_BLKNUM |
TBD |
PAY_OPCODE |
TBD |
BASE_GAS_COST |
8600 |
COLD_GAS_COST |
11100 |
CREATION_GAS_COST |
32600 |
A new opcode is introduced: PAY (PAY_OPCODE), which:
- Pops two values from the stack:
addrthenval. - Transfers
valwei to the addressaddr.
The cost of this opcode is BASE_GAS_COST if addr is a warm account, COLD_GAS_COST if addr is a cold account that is already in the state trie, or BASE_GAS_COST+CREATION_GAS_COST if addr has not yet been added to the state trie.
Rationale
Gas pricing
The gas pricing is that of a CALL with a positive msg.value, but without any memory expansion costs or “gas sent with call” costs, with a gas reduction of 500 to compensate for the reduced amount of computation.
Argument order
The order of arguments mimicks that of CALL, which pops addr before val. Beyond consistency, though, this ordering aids validators pattern-matching MEV opportunities, so PAY always appears immediately after COINBASE.
向后兼容性
Needs discussion.
Security Considerations
Existing contracts should not rely on their balance being under their control, since it is already possible to send ether to an address without calling it, by creating a temporary contract and immediately SELFDESTRUCTing it, sending the ether to an arbitrary address. However, this opcode does make this process cheaper for already-vulnerable contracts.
Copyright
Copyright and related rights waived via CC0.
参考文献
Please cite this document as:
Pandapip1, Zainan Victor Zhou, "EIP-5920: PAY opcode [DRAFT]," Ethereum Improvement Proposals, no. 5920, March 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5920.