Remediations for EIP-1283 reentrancy bug

Proposals I’ve seen so far:

  1. Add a condition to SSTORE that causes it to revert if less than 2300 gas remains.
    • Straightforward.
    • Makes the violated invariant (‘the gas stipend is not enough to change state’) explicit.
    • Can be applied without the need to enable it only on a hardfork, since all past transactions meet this requirement (on mainnnet, at least).
  2. Add a new call context that permits LOG opcodes but not changes to state.
    • Adds another call type beyond existing regular/staticcall
    • Makes the violated invariant into a fixed rule
  3. Raise the cost of SSTORE to dirty slots to >=2300 gas
    • Straightforward
    • Makes net gas metering much less useful.
  4. Reduce the gas stipend
    • Straightforward
    • Makes the stipend almost useless.
  5. Increase the cost of writes to dirty slots back to 5000 gas, but add 4800 gas to the refund counter
    • Preserves net gas costs while preventing reentrancy.
    • Still doesn’t make the invariant explicit.
    • Requires callers to supply more gas, just to have it refunded.
  6. Add contract metadata specifying per-contract EVM version, and only apply SSTORE changes to contracts deployed with the new version.
    • Ensures existing contract behaviour doesn’t change.
    • Adds more implementation complexity.
    • General mechanism that can be reused for other EVM changes.
3 Likes