Skip to content

Commit 27f915c

Browse files
Merge pull request #14931 from mattaereal/develop
Document the possibility of high-level external calls to precompiled contracts
2 parents db53ca5 + 513535a commit 27f915c

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

docs/control-structures.rst

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,35 @@ otherwise, the ``value`` option would not be available.
111111
the ``value`` and ``gas`` settings are lost, only
112112
``feed.info{value: 10, gas: 800}()`` performs the function call.
113113

114-
Due to the fact that the EVM considers a call to a non-existing contract to
115-
always succeed, Solidity uses the ``extcodesize`` opcode to check that
116-
the contract that is about to be called actually exists (it contains code)
117-
and causes an exception if it does not. This check is skipped if the return
118-
data will be decoded after the call and thus the ABI decoder will catch the
119-
case of a non-existing contract.
114+
.. warning::
115+
Due to the fact that the EVM considers a call to a non-existing contract to
116+
always succeed, Solidity uses the ``extcodesize`` opcode to check that
117+
the contract that is about to be called actually exists (it contains code)
118+
and causes an exception if it does not. This check is skipped if the return
119+
data will be decoded after the call and thus the ABI decoder will catch the
120+
case of a non-existing contract.
120121

121-
Note that this check is not performed in case of :ref:`low-level calls <address_related>` which
122-
operate on addresses rather than contract instances.
122+
This check is not performed in case of :ref:`low-level calls <address_related>` which
123+
operate on addresses rather than contract instances.
123124

124-
.. note::
125+
.. warning::
125126
Be careful when using high-level calls to
126127
:ref:`precompiled contracts <precompiledContracts>`,
127128
since the compiler considers them non-existing according to the
128129
above logic even though they execute code and can return data.
129130

131+
.. note::
132+
Since the version 0.8.10, the compiler does not check ``extcodesize`` on
133+
high-level external calls if return data is expected, because an empty code
134+
will be unable to return data, and the ABI decoder will revert.
135+
As a consequence, this allows high-level external calls to precompiled
136+
contracts, since they can return data despite having no code
137+
associated with their addresses.
138+
139+
Read about :ref:`precompiled contracts <precompiledContracts>` and
140+
:ref:`low-level calls <address_related>`
141+
for more information.
142+
130143
Function calls also cause exceptions if the called contract itself
131144
throws an exception or goes out of gas.
132145

@@ -901,4 +914,4 @@ in scope in the block that follows.
901914
out-of-gas situation and not a deliberate error condition:
902915
The caller always retains at least 1/64th of the gas in a call and thus
903916
even if the called contract goes out of gas, the caller still
904-
has some gas left.
917+
has some gas left.

0 commit comments

Comments
 (0)