-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sane limits for certain EVM parameters (#1985)
* sane * some clarifications * remove cruft * some clarifications * propose spec changes * limit the scope to EVM only * more rationale * group affected opcodes by ranges * Rename to EIP-1985 * Add discussion URL to EIP-1985 * Include a reference to EIP106 * Add more rationale * fix typo * Remove unfounded worry * mention timestamp being 64-bit value in Aleth * resolved an TODO item as Rationale entry
- Loading branch information
Showing
1 changed file
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
--- | ||
eip: 1985 | ||
title: Sane limits for certain EVM parameters | ||
author: Alex Beregszaszi (@axic), Paweł Bylica (@chfast) | ||
discussions-to: https://ethereum-magicians.org/t/eip-1985-sane-limits-for-certain-evm-parameters/3224 | ||
status: Draft | ||
type: Standards Track | ||
category: Core | ||
created: 2018-08-01 | ||
--- | ||
|
||
## Abstract | ||
|
||
Introduce an explicit value range for certain EVM parameters | ||
(such as gas limit, block number, block timestamp, size field when returning/copying data within EVM). | ||
Some of these already have an implicit value range due to various (practical) reasons. | ||
|
||
## Motivation | ||
|
||
Having such an explicit value range can help in creating compatible client implementations, | ||
in certain cases it can also offer minor speed improvements, | ||
and can reduce the effort needed to create consensus critical test cases | ||
by eliminating unrealistic edge cases. | ||
|
||
## Specification | ||
|
||
If `block.number >= {FORK_BLOCK}`, the following value ranges are introduced. | ||
They restrict the results (i.e. values pushed to the stack) of the opcodes listed below. | ||
|
||
1. *gas*, *gas limit*, *block gas limit* | ||
is a range between `0` and `9223372036854775807` (`2**63 - 1`). | ||
It affects following the opcodes: | ||
- `GASLIMIT` (`0x45`), | ||
- `GAS` (`0x5a`). | ||
|
||
2. *block number*, *timestamp* | ||
is a range between `0` and `9223372036854775807` (`2**63 - 1`). | ||
It affects the following opcodes: | ||
- `TIMESTAMP` (`0x42`), | ||
- `NUMBER` (`0x43`). | ||
|
||
3. *account address* | ||
is a range between `0` and `1461501637330902918203684832716283019655932542975` (`2**160 - 1`). | ||
It affects the following opcodes: | ||
- `ADDRESS` (`0x30`), | ||
- `ORIGIN` (`0x32`), | ||
- `CALLER` (`0x33`), | ||
- `COINBASE` (`0x41`), | ||
- `CREATE` (`0xf0`), | ||
- `CREATE2` (`0xf5`). | ||
|
||
4. *buffer size* | ||
is a range between `0` and `4294967295` (`2**32 - 1`). | ||
It affects the following opcodes: | ||
- `CALLDATASIZE` (`0x36`), | ||
- `CODESIZE` (`0x38`), | ||
- `EXTCODESIZE` (`0x3b`), | ||
- `RETURNDATASIZE` (`0x3d`), | ||
- `MSIZE` (`0x59`). | ||
|
||
|
||
## Rationale | ||
|
||
These limits have been: | ||
- proposed by [EVMC] | ||
- implemented partially by certain clients, such as [Aleth], [geth], [Parity] and [ethereumjs] | ||
- allowed by certain test cases in the [Ethereum testing suite] | ||
- and implicitly also allowed by certain assumptions, such as due to gas limits some of these values cannot grow past a certain limit | ||
|
||
Most of the limits proposed in this document have been previously explored and tested in [EVMC]. | ||
|
||
Using the `2**63 - 1` constant to limit some of the ranges: | ||
- allows using signed 64-bit integer type to represent it, | ||
what helps programming languages not having unsigned types, | ||
- makes arithmetic simpler (e.g. checking out-of-gas conditions is simple as `gas_counter < 0`). | ||
|
||
### Timestamp | ||
|
||
The [Yellow Paper] defines the timestamp in block as "A scalar value equal to the reasonable output of Unix’s time() at this block’s inception". | ||
IEEE Std 1003.1-2001 (POSIX.1) leaves that definition implementation defined. | ||
|
||
### Addresses | ||
|
||
The size of addresses is specified in the [Yellow Paper] as 20 bytes. | ||
E.g. the `COINBASE` instruction is specified to return *H*<sub>c</sub> ∈ 𝔹<sub>20</sub> which has 20 bytes. | ||
|
||
### 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] | ||
|
||
## Backwards Compatibility | ||
|
||
All of these limits are already enforced mostly through the block gas limit. Since the out of range case results in a transaction failure, there should not be a change in behaviour. | ||
|
||
## Test Cases | ||
|
||
TBA | ||
|
||
## Implementation | ||
|
||
TBA | ||
|
||
## References | ||
|
||
[EIP-106](https://github.com/ethereum/EIPs/issues/106) proposed the block gas limit to be limited at `2**63 - 1`. | ||
|
||
## TODO | ||
|
||
1. Does the gas limit apply to the gas argument for call instructions? | ||
|
||
## Copyright | ||
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). | ||
|
||
[EVMC]: https://github.com/ethereum/evmc | ||
[Aleth]: https://github.com/ethereum/aleth | ||
[geth]: https://github.com/ethereum/go-ethereum | ||
[Parity]: https://github.com/paritytech/parity-ethereum | ||
[ethereumjs]: https://github.com/ethereumjs | ||
[Ethereum testing suite]: https://github.com/ethereum/tests | ||
[Yellow Paper]: https://github.com/ethereum/yellowpaper |