EIP-2803: Rich Transactions
Support 'rich transactions' by allowing transactions from externally owned accounts to execute bytecode directly.
作者 | Micah Zoltu |
---|---|
讨论-To | https://ethereum-magicians.org/t/rich-transactions-via-evm-bytecode-execution-from-externally-owned-accounts/4025 |
状态 | Stagnant |
类型 | Standards Track |
分类 | Core |
创建日期 | 2020-07-18 |
英文版 | https://eips.ethereum.org/EIPS/eip-2803 |
摘要
If a transaction has a to
of address x
, then the data
of the transaction will be treated as EVM bytecode and it will be executed from the context of the CALLER
of the transaction (aka: the transaction signer).
动机
Many Ethereum DApps presently require users to approve multiple transactions in order to produce one effect - for example, the common pattern of first approving a contract to spend a token, then calling that contract. This results in a poor user-experience, and complicates the experience of interacting with DApps.
Making it possible for externally owned accounts to execute EVM bytecode directly allows a single transaction to execute multiple contract calls, allowing DApps to provide a streamlined experience, where every interaction results in at most one transaction.
While this is in principle possible today using contract wallets, other UX issues, such as the need to fund a sending account with gas money, lack of support for contract wallets in browser integrations, and lack of a consistent API for contract wallets has led to poor adoption of these.This EIP is a way of enhancing the utility of existing EOAs, in the spirit of “don’t let the perfect be the enemy of the good”.
规范
A new reserved address is specified at x
, in the range used for precompiles. When a transaction is sent to this address from an externally owned account, the payload of the transaction is treated as EVM bytecode, and executed with the signer of the transaction as the current account. For clarity:
- The
ADDRESS
opcode returns the address of the EOA that signed the transaction. - The
BALANCE
opcode returns the balance of the EOA that signed the transaction. - Any
CALL
operations that send value take their value from the EOA that signed the transaction. CALL
will set theCALLER
to the EOA (notx
).DELEGATECALL
preserves the EOA as the owning account.- The
CALLER
andORIGIN
opcodes both return the address of the EOA that signed the transaction. - There is no code associated with the precompile address.
CODE*
andEXTCODE*
opcodes behave the same as they do for any empty address. CALLDATA*
opcodes operate on the transaction payload as expected.SLOAD
andSSTORE
operate on the storage of the EOA. As a result, an EOA can have data in storage, that persists between transactions.- The
SELFDESTRUCT
opcode does nothing. - All other opcodes behave as expected for a call to a contract address.
- The transaction is invalid if there is any value attached.
- A call to the precompile address from a contract has no special effect and is equivalent to a call to a nonexistent precompile or an empty address.
基本原理
The intent of this EIP is for the new precompile to act in all ways possible like a DELEGATECALL
from an externally owned account. Some changes are required to reflect the fact that the code being executed is not stored on chain, and for special cases such as SELFDESTRUCT
, to prevent introducing new edge-cases such as the ability to zero-out an EOA’s nonce.
A precompile was used rather than a new EIP-2718 transaction type because a precompile allows us to have a rich transaction with any type of EIP-2718 transaction.
向后兼容性
This EIP introduces a new feature that will need to be implemented in a future hard fork. No backwards compatibility issues with existing code are expected.
Contracts or DApps that assume that an EOA cannot atomically perform multiple operations may be affected by this change, as this now makes it possible for EOAs to execute multiple atomic operations together. The authors do not believe this is a significant use-case, as this ‘protection’ is already trivially defeated by miners.
版权声明
Copyright and related rights waived via CC0.
参考文献
Please cite this document as:
Micah Zoltu, "EIP-2803: Rich Transactions [DRAFT]," Ethereum Improvement Proposals, no. 2803, July 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2803.