EIPs/EIPS/eip-214.md

52 lines
3.1 KiB
Markdown
Raw Normal View History

---
2018-03-21 12:51:05 +00:00
eip: 214
title: New opcode STATICCALL
Switch validator to eipv (#2860) * switch to eipv * fix * fix * 1153 remove trailing whitespace * remove file name checks * 615 remo whitespace before comma * 884 remove extra single-quotes * 1337 remove whitespace before comma * 1057 remove extra spaces after comma * 2470 update created date to Y/M/D format * 1078 update required eips to be in ascending order * 2477 update required eips to be in ascending order * 1271 remove extra whitespace * 2767 required eipupdated to be in ascending order * 2525 update created date to Y/M/D format * 2458 remove trailing whitespace * 1884 remove trailing whitespace * 712 authors should be on a single line * 601 remove extra whitespace * 1485 remove unneeded parentheses * 634 remove trailing whitespace * 2657 update discussions-to to correct spelling * 2009 remove trailing whitespace * 998 required eips updated to be in ascending order * 1186 remove trailing whitespace * 1470 remove extra whitespace * 1895 update created date to Y/M/D format * 2747 remove extra whitespace * 1613 remove leading whitespace * 1571 can'have both handle and email in author field * 1191 remove trailing whitespace * 1973 remove trailing whitespace * 196 don't wrap title field * 1679 required eips must be in ascending order * 1620 author can't have both handle and email * 197 don't line wrap title field * 2378 remove extra newline * 1355 author can't have both handle and email * 698 update created date to Y/M/D format * 2193 required eips must be in ascending order * 214 remove extra info after author email * use v0.0.3 of eipv * 1 remove malformed field * bump eipv to v0.0.4 * cache eipv build * 1485 remove extra author info * 2771 removing extra whitespaces
2020-08-10 10:18:25 -06:00
author: Vitalik Buterin <vitalik@ethereum.org>, Christian Reitwiessner <chris@ethereum.org>
type: Standards Track
2018-03-21 12:51:05 +00:00
category: Core
status: Final
created: 2017-02-13
---
2017-02-13 14:50:04 +01:00
## Simple Summary
To increase smart contract security, this proposal adds a new opcode that can be used to call another contract (or itself) while disallowing any modifications to the state during the call (and its subcalls, if present).
## Abstract
2017-05-18 15:35:34 +02:00
This proposal adds a new opcode that can be used to call another contract (or itself) while disallowing any modifications to the state during the call (and its subcalls, if present). Any opcode that attempts to perform such a modification (see below for details) will result in an exception instead of performing the modification.
2017-02-13 14:50:04 +01:00
## Motivation
2017-11-27 17:58:21 +01:00
Currently, there is no restriction about what a called contract can do, as long as the computation can be performed with the amount of gas provided. This poses certain difficulties about smart contract engineers; after a regular call, unless you know the called contract, you cannot make any assumptions about the state of the contracts. Furthermore, because you cannot know the order of transactions before they are confirmed by miners, not even an outside observer can be sure about that in all cases.
2017-05-18 15:35:34 +02:00
2017-11-27 17:58:21 +01:00
This EIP adds a way to call other contracts and restrict what they can do in the simplest way. It can be safely assumed that the state of all accounts is the same before and after a static call.
2017-02-13 14:50:04 +01:00
## Specification
2017-06-16 16:59:56 +02:00
Introduce a new `STATIC` flag to the virtual machine. This flag is set to `false` initially. Its value is always copied to sub-calls with an exception for the new opcode below.
2017-05-18 15:35:34 +02:00
2017-02-13 14:50:04 +01:00
Opcode: `0xfa`.
2017-07-03 18:30:31 +02:00
`STATICCALL` functions equivalently to a `CALL`, except it takes only 6 arguments (the "value" argument is not included and taken to be zero), and calls the child with the `STATIC` flag set to `true` for the execution of the child. Once this call returns, the flag is reset to its value before the call.
2017-05-18 15:35:34 +02:00
2017-08-24 11:40:35 +02:00
Any attempts to make state-changing operations inside an execution instance with `STATIC` set to `true` will instead throw an exception. These operations include `CREATE`, `CREATE2`, `LOG0`, `LOG1`, `LOG2`, `LOG3`, `LOG4`, `SSTORE`, and `SELFDESTRUCT`. They also include `CALL` with a non-zero value. As an exception, `CALLCODE` is not considered state-changing, even with a non-zero value.
2017-02-13 14:50:04 +01:00
## Rationale
This allows contracts to make calls that are clearly non-state-changing, reassuring developers and reviewers that re-entrancy bugs or other problems cannot possibly arise from that particular call; it is a pure function that returns an output and does nothing else. This may also make purely functional HLLs easier to implement.
## Backwards Compatibility
2017-05-18 15:35:34 +02:00
This proposal adds a new opcode but does not modify the behaviour of other opcodes and thus is backwards compatible for old contracts that do not use the new opcode and are not called via the new opcode.
2017-02-13 14:50:04 +01:00
## Test Cases
To be written.
## Implementation
2017-12-04 11:13:15 +01:00
## Copyright
Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).