-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
For blocks where block.number >= METROPOLIS_HARDFORK_BLKNUM
, make the following changes:
- The 1024 call stack limit no longer exists
- Still keep track of the call stack depth; however, if the call stack depth is at least 1024 (ie. in and only in those execution environments which would never be reachable in the current Ethereum implementation because they would trigger the max call stack depth exception), a
CALL
,CALLCODE
,CREATE
orDELEGATECALL
can allocate a maximum of(g * 63) // 64
gas to the child, whereg
is the remaining gas in the message at the time the call is made, after subtracting gas costs for the call and for memory expansion.
Option B: allow any amount of gas to be required, and if the amount of gas required is too high then don't throw an exception, instead just limit it to the maximum. Option B1: the maximum is 100% for call depths up to 1024 and 63/64 as above after, option B2: the maximum is 63/64 as above at all depths. If the limit is equal to the maximum, then if the call throws, immediately set the parent gas to 0 (this preserves a nice safety property that currently exists in contracts by default).
Assuming a block gas limit of 10**9
(a safe upper limit for the foreseeable future), and a minimum gas cost of ~50 for a call + pushing stack arguments + doing the arithmetic of * 63 / 64, we can compute a maximum de-facto stack depth of 1024 + log(10**9 / 50) / log(64 / 63) = 2091
, so the stack depth remains very safely bounded. However, with this mechanism for enforcing a maximum call stack depth, contracts no longer have to worry about the remaining call stack depth in the execution environment they are running in, and possible attacks or bugs if the depth is too low, and instead only need to worry about the single limiting variable of gas.