diff --git a/EIPS/eip-1985.md b/EIPS/eip-1985.md index a2787c62..dd6417eb 100644 --- a/EIPS/eip-1985.md +++ b/EIPS/eip-1985.md @@ -50,14 +50,15 @@ They restrict the results (i.e. values pushed to the stack) of the instructions - `CREATE` (`0xf0`), - `CREATE2` (`0xf5`). -4. *buffer size* +4. *buffer size*, *code size*, *memory size* is a range between `0` and `0xffffffff` (`2**32 - 1`, `4294967295`). It affects the following instructions: - `CALLDATASIZE` (`0x36`), - `CODESIZE` (`0x38`), - `EXTCODESIZE` (`0x3b`), - `RETURNDATASIZE` (`0x3d`), - - `MSIZE` (`0x59`). + - `MSIZE` (`0x59`), + - `PC` (`0x58`). ## Rationale @@ -85,10 +86,24 @@ IEEE Std 1003.1-2001 (POSIX.1) leaves that definition implementation defined. The size of addresses is specified in the [Yellow Paper] as 20 bytes. E.g. the `COINBASE` instruction is specified to return *H*c ∈ 𝔹20 which has 20 bytes. +### Memory size + +Memory expansion cost is not linear and is determined by the following formula: + cost = cost_per_word * number_of_words + (number_of_words ^ 2 / 512) + +Expanding to over `2^32 - 1` bytes would cost `35184774742016` gas. This number fits into the gas limit imposed above (`2 ^ 63 - 1`) and would cost around 35184 Ether in a transaction to exhaust, with a 1 GWei gas cost, which can be attained on mainnet. + +However, setting the limit `2^32 - 1` is beneficial from a VM design perspective and we believe limiting memory should be done via carefully selecting the block gas limit. + +### Code size + +[EIP-170](http://eips.ethereum.org/EIPS/eip-170) has implemented a code size limit of 0x6000, however even before that, it was practically impossible to deploy a code blob exceeding `2**32 - 1` bytes in size. + ### Comparing current implementations - Timestamp is implemented as a 64-bit value in [Aleth], [geth] and [Parity] - Block gas limit is implemented as a 64-bit in [Aleth] and [geth] +- Memory, buffer and code sizes are implemented as 64-bit values in [geth] ## Backwards Compatibility @@ -104,7 +119,8 @@ TBA ## References -[EIP-106](https://github.com/ethereum/EIPs/issues/106) proposed the block gas limit to be limited at `2**63 - 1`. +- [EIP-92](https://github.com/ethereum/EIPs/issues/92) proposed the transaction gas limit to be limited at `2**63 - 1` and had a lengthy discussion about other limits. +- [EIP-106](https://github.com/ethereum/EIPs/issues/106) proposed the block gas limit to be limited at `2**63 - 1`. ## TODO