diff options
author | chriseth <chris@ethereum.org> | 2018-07-12 19:14:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-12 19:14:02 +0800 |
commit | fa8102880f87c5a2806d59f959fd3e8a62dd4dc9 (patch) | |
tree | e6e76488612e182389fc02fcb9e57f4b112a248d /docs | |
parent | 576f3ef18c47c13b92e5b604d19f99018b0300b0 (diff) | |
parent | 38026d311443f5f0f8fb23a928839136b56c97bd (diff) | |
download | dexon-solidity-fa8102880f87c5a2806d59f959fd3e8a62dd4dc9.tar.gz dexon-solidity-fa8102880f87c5a2806d59f959fd3e8a62dd4dc9.tar.zst dexon-solidity-fa8102880f87c5a2806d59f959fd3e8a62dd4dc9.zip |
Merge pull request #4428 from ethereum/enforce_staticcall_view
[BREAKING] Enforce STATICCALL for view and pure
Diffstat (limited to 'docs')
-rw-r--r-- | docs/contracts.rst | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/docs/contracts.rst b/docs/contracts.rst index a745bea8..862ec54d 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -451,6 +451,10 @@ View Functions Functions can be declared ``view`` in which case they promise not to modify the state. +.. note:: + If the compiler's EVM target is Byzantium or newer (default) the opcode + ``STATICCALL`` is used. + The following statements are considered modifying the state: #. Writing to state variables. @@ -464,7 +468,7 @@ The following statements are considered modifying the state: :: - pragma solidity ^0.4.16; + pragma solidity >0.4.24; contract C { function f(uint a, uint b) public view returns (uint) { @@ -479,11 +483,12 @@ The following statements are considered modifying the state: Getter methods are marked ``view``. .. note:: - If invalid explicit type conversions are used, state modifications are possible - even though a ``view`` function was called. - You can switch the compiler to use ``STATICCALL`` when calling such functions and thus - prevent modifications to the state on the level of the EVM by adding - ``pragma experimental "v0.5.0";`` + Prior to version 0.5.0, the compiler did not use the ``STATICCALL`` opcode + for ``view`` functions. + This enabled state modifications in ``view`` functions through the use of + invalid explicit type conversions. + By using ``STATICCALL`` for ``view`` functions, modifications to the + state are prevented on the level of the EVM. .. index:: ! pure function, function;pure @@ -494,6 +499,9 @@ Pure Functions Functions can be declared ``pure`` in which case they promise not to read from or modify the state. +.. note:: + If the compiler's EVM target is Byzantium or newer (default) the opcode ``STATICCALL`` is used. + In addition to the list of state modifying statements explained above, the following are considered reading from the state: #. Reading from state variables. @@ -504,7 +512,7 @@ In addition to the list of state modifying statements explained above, the follo :: - pragma solidity ^0.4.16; + pragma solidity >0.4.24; contract C { function f(uint a, uint b) public pure returns (uint) { @@ -513,11 +521,12 @@ In addition to the list of state modifying statements explained above, the follo } .. note:: - If invalid explicit type conversions are used, state modifications are possible - even though a ``pure`` function was called. - You can switch the compiler to use ``STATICCALL`` when calling such functions and thus - prevent modifications to the state on the level of the EVM by adding - ``pragma experimental "v0.5.0";`` + Prior to version 0.5.0, the compiler did not use the ``STATICCALL`` opcode + for ``pure`` functions. + This enabled state modifications in ``pure`` functions through the use of + invalid explicit type conversions. + By using ``STATICCALL`` for ``pure`` functions, modifications to the + state are prevented on the level of the EVM. .. warning:: It is not possible to prevent functions from reading the state at the level |