Skip to content

Commit

Permalink
Update EIP-1380: fix typo in EIP 1380 (ethereum#7961)
Browse files Browse the repository at this point in the history
* fix typo in EIP 1380

* linting fix
  • Loading branch information
WillXing authored and blacksnow2 committed Jul 21, 2024
1 parent 2706238 commit 2340e9f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions EIPS/eip-1380.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ requires: 150
---

## Abstract

Reduce the gas cost for call instructions, when the goal is to run a new instance of the currently loaded contract.

## Motivation

The current gas cost of 700 for all call types (`CALL`, `DELEGATECALL`, `CALLCODE` and `STATICCALL`) does not take into account that a call to a contract itself
does not need to perform additional I/O operations, because the current contract code has already been loaded into memory.

Expand All @@ -26,32 +28,38 @@ must be swapped in and out of the calling functions context. A desired feature i
them through `JUMP` requires a bigger effort from the compiler as opposed to being able to use `CALL`s.

Using call-to-self provides the guarantee that when making an internal call the function can rely on a clear reset state of memory or context, benefiting both
contract writers and contract consumers against potentially undetetected edge cases were memory could poison the context of the internal function.
contract writers and contract consumers against potentially undetected edge cases were memory could poison the context of the internal function.

Because of the `JUMP` usage for internal functions a smart contract languages are also at risk of reaching the stack depth limit considerbly faster, if nested
Because of the `JUMP` usage for internal functions a smart contract languages are also at risk of reaching the stack depth limit considerably faster, if nested
function calls with many in and/or outputs are required.

Reducing the gas cost, and thereby incentivising of using call-to-self instead of `JUMP`s for the internal function implementation will also benefit static
analyzers and tracers.

## Specification

If `block.number >= FORK_BLKNUM`, then decrease the cost of `CALL`, `DELEGATECALL`, `CALLCODE` and `STATICCALL` from 700 to 40,
if and only if, the destination address of the call equals to the address of the caller.

## Rationale

EIP150 has increased the cost of these instructions from 40 to 700 to more fairly charge for loading new contracts from disk, e.g. to reflect the I/O charge more closely.
By assuming that 660 is the cost of loading a contract from disk, one can assume that the original 40 gas is a fair cost of creating a new VM instance of an already loaded contract code.

## Backwards Compatibility

This should pose no risk to backwards compatibility. Currently existing contracts should not notice the difference, just see cheaper execution.
With EIP150 contract (and language) developers had a lesson that relying on strict gas costs is not feasible as costs may change.
The impact of this EIP is even less that of EIP150 because the costs are changing downwards and not upwards.

## Test Cases

TBA

## Implementation

TBA

## Copyright

Copyright and related rights waived via [CC0](../LICENSE.md).

0 comments on commit 2340e9f

Please sign in to comment.