Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the possibility of high-level external calls to precompiled contracts #14931

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 25 additions & 9 deletions docs/control-structures.rst
Expand Up @@ -111,22 +111,38 @@ otherwise, the ``value`` option would not be available.
the ``value`` and ``gas`` settings are lost, only
``feed.info{value: 10, gas: 800}()`` performs the function call.

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

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

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

.. note::
Since the 0.8.10 release the compiler does not check ``extcodesize`` on
high-level external calls if return data is expected, because an empty code
will be unable to return data, and the ABI decoder will revert.
As a consequence, this allows high-level external calls to precompiled
contracts possible, since they can return data despite having no code
associated with their addresses.

Read about :ref:`precompiled contracts <precompiledContracts>` and
:ref:`low-level calls <address_related>`
for more information.




Function calls also cause exceptions if the called contract itself
throws an exception or goes out of gas.

Expand Down