Withdrew PR to flesh it out a bit more. (https: //github .com/ethereum/EIPs/pull/1666)
Transient storage repo, related: https://github.com/androlo/tstorage
Much of this comes from experimenting with transient storage (EIP: Transient storage opcodes).
There are three types of memory involved here:
- EVM-bound memory - protected memory used by the EVM to store things like call-, and returndata. Can be read from contract code.
- Account-bound memory - Lasts throughout an entire transaction and can be written to and read from by contract code. Needs special consideration when a revert happens.
- VM-bound memory. Can only be accessed from a specific VM. Can be written to and read from by contract code.
Add a address->Memory map that lasts throughout an entire transaction.
Add a map,
Map<Address, Memory>to the EVM which binds memories to contract addresses.
TCOPYto work with account-bound memory.
CALLDATACOPYto read from
RETURNDATACOPYto read from
Change call related instructions (
DELEGATECALL, etc.) to write to
REVERTinstructions to write to
accountMemory can be used for data size, and
0x20 and beyond for the data itself. Lifetime of calldata and returndata is now related, and works like returndata does now.
TLOAD cAddr sAddr
TLOAD reads the data stored at address
sAddr in the transient storage of the account with address
Example: if the account with address
0x00...01 wants to read from its own transient storage at address
0x20 , in LLL that would be
(TSTORE 0x00...01 0x20)
TSTORE sAddr val
Stores the 32 byte value
val at address
sAddr in the account’s own transient storage.
TCOPY cAddr sAddr mAddr len
len bytes of data from the address
sAddr in the transient storage of account
cAddr to memory address
The big change is to add a new memory with a different scope, and making other instructions use memory rather then their own special storage locations, instructions, and gas rules. Harmonization + simplification. Also enables reentrancy locks + other things that has to last over an entire transaction.