mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Misspelling and terms inconsistencies (#14280)
* Installing solidity tweeks * A few more misspells * More inconsistencies fixed * Removed contractions according to our guide.
This commit is contained in:
parent
a0933fa80a
commit
3eedc635c4
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -36,7 +36,7 @@ assignees: ''
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Please provide a *minimal* source code example to trigger the bug you have found.
|
Please provide a *minimal* source code example to trigger the bug you have found.
|
||||||
Please also mention any command line flags that are necessary for triggering the bug.
|
Please also mention any command-line flags that are necessary for triggering the bug.
|
||||||
Provide as much information as necessary to reproduce the bug.
|
Provide as much information as necessary to reproduce the bug.
|
||||||
|
|
||||||
```solidity
|
```solidity
|
||||||
|
@ -117,7 +117,7 @@ Use `solAssert` and `solUnimplementedAssert` generously to check assumptions tha
|
|||||||
1. {Typename} + {qualifiers} + {name}.
|
1. {Typename} + {qualifiers} + {name}.
|
||||||
2. Only one per line.
|
2. Only one per line.
|
||||||
3. Associate */& with type, not variable (at ends with parser, but more readable, and safe if in conjunction with (b)).
|
3. Associate */& with type, not variable (at ends with parser, but more readable, and safe if in conjunction with (b)).
|
||||||
4. Favour declarations close to use; don't habitually declare at top of scope ala C.
|
4. Favour declarations close to use; do not habitually declare at top of scope ala C.
|
||||||
5. Pass non-trivial parameters as const reference, unless the data is to be copied into the function, then either pass by const reference or by value and use std::move.
|
5. Pass non-trivial parameters as const reference, unless the data is to be copied into the function, then either pass by const reference or by value and use std::move.
|
||||||
6. If a function returns multiple values, use std::tuple (std::pair acceptable) or better introduce a struct type. Do not use */& arguments.
|
6. If a function returns multiple values, use std::tuple (std::pair acceptable) or better introduce a struct type. Do not use */& arguments.
|
||||||
7. Use parameters of pointer type only if ``nullptr`` is a valid argument, use references otherwise. Often, ``std::optional`` is better suited than a raw pointer.
|
7. Use parameters of pointer type only if ``nullptr`` is a valid argument, use references otherwise. Often, ``std::optional`` is better suited than a raw pointer.
|
||||||
|
@ -52,7 +52,7 @@ At least a day before the release:
|
|||||||
- [ ] Create a [release on GitHub](https://github.com/ethereum/solidity/releases/new).
|
- [ ] Create a [release on GitHub](https://github.com/ethereum/solidity/releases/new).
|
||||||
Set the target to the ``develop`` branch and the tag to the new version, e.g. ``v0.8.5``.
|
Set the target to the ``develop`` branch and the tag to the new version, e.g. ``v0.8.5``.
|
||||||
Include the following warning: ``**The release is still in progress and the binaries may not yet be available from all sources.**``.
|
Include the following warning: ``**The release is still in progress and the binaries may not yet be available from all sources.**``.
|
||||||
Don't publish it yet - click the ``Save draft`` button instead.
|
Do not publish it yet - click the ``Save draft`` button instead.
|
||||||
- [ ] Thank voluntary contributors in the GitHub release notes.
|
- [ ] Thank voluntary contributors in the GitHub release notes.
|
||||||
Use ``scripts/list_contributors.sh v<previous version>`` to get initial list of names.
|
Use ``scripts/list_contributors.sh v<previous version>`` to get initial list of names.
|
||||||
Remove different variants of the same name manually before using the output.
|
Remove different variants of the same name manually before using the output.
|
||||||
|
@ -137,7 +137,7 @@ For most of the topics the compiler will provide suggestions.
|
|||||||
``payable`` or create a new internal function for the program logic that
|
``payable`` or create a new internal function for the program logic that
|
||||||
uses ``msg.value``.
|
uses ``msg.value``.
|
||||||
|
|
||||||
* For clarity reasons, the command line interface now requires ``-`` if the
|
* For clarity reasons, the command-line interface now requires ``-`` if the
|
||||||
standard input is used as source.
|
standard input is used as source.
|
||||||
|
|
||||||
Deprecated Elements
|
Deprecated Elements
|
||||||
@ -147,18 +147,18 @@ This section lists changes that deprecate prior features or syntax. Note that
|
|||||||
many of these changes were already enabled in the experimental mode
|
many of these changes were already enabled in the experimental mode
|
||||||
``v0.5.0``.
|
``v0.5.0``.
|
||||||
|
|
||||||
Command Line and JSON Interfaces
|
Command-line and JSON Interfaces
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
* The command line option ``--formal`` (used to generate Why3 output for
|
* The command-line option ``--formal`` (used to generate Why3 output for
|
||||||
further formal verification) was deprecated and is now removed. A new
|
further formal verification) was deprecated and is now removed. A new
|
||||||
formal verification module, the SMTChecker, is enabled via ``pragma
|
formal verification module, the SMTChecker, is enabled via ``pragma
|
||||||
experimental SMTChecker;``.
|
experimental SMTChecker;``.
|
||||||
|
|
||||||
* The command line option ``--julia`` was renamed to ``--yul`` due to the
|
* The command-line option ``--julia`` was renamed to ``--yul`` due to the
|
||||||
renaming of the intermediate language ``Julia`` to ``Yul``.
|
renaming of the intermediate language ``Julia`` to ``Yul``.
|
||||||
|
|
||||||
* The ``--clone-bin`` and ``--combined-json clone-bin`` command line options
|
* The ``--clone-bin`` and ``--combined-json clone-bin`` command-line options
|
||||||
were removed.
|
were removed.
|
||||||
|
|
||||||
* Remappings with empty prefix are disallowed.
|
* Remappings with empty prefix are disallowed.
|
||||||
|
@ -12,7 +12,7 @@ For the full list check
|
|||||||
Changes the Compiler Might not Warn About
|
Changes the Compiler Might not Warn About
|
||||||
=========================================
|
=========================================
|
||||||
|
|
||||||
This section lists changes where the behaviour of your code might
|
This section lists changes where the behavior of your code might
|
||||||
change without the compiler telling you about it.
|
change without the compiler telling you about it.
|
||||||
|
|
||||||
* The resulting type of an exponentiation is the type of the base. It used to be the smallest type
|
* The resulting type of an exponentiation is the type of the base. It used to be the smallest type
|
||||||
@ -105,13 +105,13 @@ Interface Changes
|
|||||||
=================
|
=================
|
||||||
|
|
||||||
This section lists changes that are unrelated to the language itself, but that have an effect on the interfaces of
|
This section lists changes that are unrelated to the language itself, but that have an effect on the interfaces of
|
||||||
the compiler. These may change the way how you use the compiler on the command line, how you use its programmable
|
the compiler. These may change the way how you use the compiler on the command-line, how you use its programmable
|
||||||
interface, or how you analyze the output produced by it.
|
interface, or how you analyze the output produced by it.
|
||||||
|
|
||||||
New Error Reporter
|
New Error Reporter
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
A new error reporter was introduced, which aims at producing more accessible error messages on the command line.
|
A new error reporter was introduced, which aims at producing more accessible error messages on the command-line.
|
||||||
It is enabled by default, but passing ``--old-reporter`` falls back to the the deprecated old error reporter.
|
It is enabled by default, but passing ``--old-reporter`` falls back to the the deprecated old error reporter.
|
||||||
|
|
||||||
Metadata Hash Options
|
Metadata Hash Options
|
||||||
@ -119,9 +119,9 @@ Metadata Hash Options
|
|||||||
|
|
||||||
The compiler now appends the `IPFS <https://ipfs.io/>`_ hash of the metadata file to the end of the bytecode by default
|
The compiler now appends the `IPFS <https://ipfs.io/>`_ hash of the metadata file to the end of the bytecode by default
|
||||||
(for details, see documentation on :doc:`contract metadata <metadata>`). Before 0.6.0, the compiler appended the
|
(for details, see documentation on :doc:`contract metadata <metadata>`). Before 0.6.0, the compiler appended the
|
||||||
`Swarm <https://ethersphere.github.io/swarm-home/>`_ hash by default, and in order to still support this behaviour,
|
`Swarm <https://ethersphere.github.io/swarm-home/>`_ hash by default, and in order to still support this behavior,
|
||||||
the new command line option ``--metadata-hash`` was introduced. It allows you to select the hash to be produced and
|
the new command-line option ``--metadata-hash`` was introduced. It allows you to select the hash to be produced and
|
||||||
appended, by passing either ``ipfs`` or ``swarm`` as value to the ``--metadata-hash`` command line option.
|
appended, by passing either ``ipfs`` or ``swarm`` as value to the ``--metadata-hash`` command-line option.
|
||||||
Passing the value ``none`` completely removes the hash.
|
Passing the value ``none`` completely removes the hash.
|
||||||
|
|
||||||
These changes can also be used via the :ref:`Standard JSON Interface<compiler-api>` and effect the metadata JSON generated by the compiler.
|
These changes can also be used via the :ref:`Standard JSON Interface<compiler-api>` and effect the metadata JSON generated by the compiler.
|
||||||
|
@ -10,18 +10,18 @@ For the full list check
|
|||||||
Silent Changes of the Semantics
|
Silent Changes of the Semantics
|
||||||
===============================
|
===============================
|
||||||
|
|
||||||
This section lists changes where existing code changes its behaviour without
|
This section lists changes where existing code changes its behavior without
|
||||||
the compiler notifying you about it.
|
the compiler notifying you about it.
|
||||||
|
|
||||||
* Arithmetic operations revert on underflow and overflow. You can use ``unchecked { ... }`` to use
|
* Arithmetic operations revert on underflow and overflow. You can use ``unchecked { ... }`` to use
|
||||||
the previous wrapping behaviour.
|
the previous wrapping behavior.
|
||||||
|
|
||||||
Checks for overflow are very common, so we made them the default to increase readability of code,
|
Checks for overflow are very common, so we made them the default to increase readability of code,
|
||||||
even if it comes at a slight increase of gas costs.
|
even if it comes at a slight increase of gas costs.
|
||||||
|
|
||||||
* ABI coder v2 is activated by default.
|
* ABI coder v2 is activated by default.
|
||||||
|
|
||||||
You can choose to use the old behaviour using ``pragma abicoder v1;``.
|
You can choose to use the old behavior using ``pragma abicoder v1;``.
|
||||||
The pragma ``pragma experimental ABIEncoderV2;`` is still valid, but it is deprecated and has no effect.
|
The pragma ``pragma experimental ABIEncoderV2;`` is still valid, but it is deprecated and has no effect.
|
||||||
If you want to be explicit, please use ``pragma abicoder v2;`` instead.
|
If you want to be explicit, please use ``pragma abicoder v2;`` instead.
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ New Restrictions
|
|||||||
|
|
||||||
This section lists changes that might cause existing contracts to not compile anymore.
|
This section lists changes that might cause existing contracts to not compile anymore.
|
||||||
|
|
||||||
* There are new restrictions related to explicit conversions of literals. The previous behaviour in
|
* There are new restrictions related to explicit conversions of literals. The previous behavior in
|
||||||
the following cases was likely ambiguous:
|
the following cases was likely ambiguous:
|
||||||
|
|
||||||
1. Explicit conversions from negative literals and literals larger than ``type(uint160).max`` to
|
1. Explicit conversions from negative literals and literals larger than ``type(uint160).max`` to
|
||||||
@ -106,7 +106,7 @@ This section lists changes that might cause existing contracts to not compile an
|
|||||||
|
|
||||||
* The global functions ``log0``, ``log1``, ``log2``, ``log3`` and ``log4`` have been removed.
|
* The global functions ``log0``, ``log1``, ``log2``, ``log3`` and ``log4`` have been removed.
|
||||||
|
|
||||||
These are low-level functions that were largely unused. Their behaviour can be accessed from inline assembly.
|
These are low-level functions that were largely unused. Their behavior can be accessed from inline assembly.
|
||||||
|
|
||||||
* ``enum`` definitions cannot contain more than 256 members.
|
* ``enum`` definitions cannot contain more than 256 members.
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ A function description is a JSON object with the fields:
|
|||||||
blockchain state <pure-functions>`), ``view`` (:ref:`specified to not modify the blockchain
|
blockchain state <pure-functions>`), ``view`` (:ref:`specified to not modify the blockchain
|
||||||
state <view-functions>`), ``nonpayable`` (function does not accept Ether - the default) and ``payable`` (function accepts Ether).
|
state <view-functions>`), ``nonpayable`` (function does not accept Ether - the default) and ``payable`` (function accepts Ether).
|
||||||
|
|
||||||
Constructor, receive, and fallback never have ``name`` or ``outputs``. Receive and fallback don't have ``inputs`` either.
|
Constructor, receive, and fallback never have ``name`` or ``outputs``. Receive and fallback do not have ``inputs`` either.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Sending non-zero Ether to non-payable function will revert the transaction.
|
Sending non-zero Ether to non-payable function will revert the transaction.
|
||||||
|
@ -362,7 +362,7 @@ in memory is automatically considered memory-safe and does not need to be annota
|
|||||||
.. warning::
|
.. warning::
|
||||||
It is your responsibility to make sure that the assembly actually satisfies the memory model. If you annotate
|
It is your responsibility to make sure that the assembly actually satisfies the memory model. If you annotate
|
||||||
an assembly block as memory-safe, but violate one of the memory assumptions, this **will** lead to incorrect and
|
an assembly block as memory-safe, but violate one of the memory assumptions, this **will** lead to incorrect and
|
||||||
undefined behaviour that cannot easily be discovered by testing.
|
undefined behavior that cannot easily be discovered by testing.
|
||||||
|
|
||||||
In case you are developing a library that is meant to be compatible across multiple versions
|
In case you are developing a library that is meant to be compatible across multiple versions
|
||||||
of Solidity, you can use a special comment to annotate an assembly block as memory-safe:
|
of Solidity, you can use a special comment to annotate an assembly block as memory-safe:
|
||||||
@ -375,4 +375,4 @@ of Solidity, you can use a special comment to annotate an assembly block as memo
|
|||||||
}
|
}
|
||||||
|
|
||||||
Note that we will disallow the annotation via comment in a future breaking release; so, if you are not concerned with
|
Note that we will disallow the annotation via comment in a future breaking release; so, if you are not concerned with
|
||||||
backwards-compatibility with older compiler versions, prefer using the dialect string.
|
backward-compatibility with older compiler versions, prefer using the dialect string.
|
||||||
|
@ -154,7 +154,7 @@ Modifiers
|
|||||||
- ``anonymous`` for events: Does not store event signature as topic.
|
- ``anonymous`` for events: Does not store event signature as topic.
|
||||||
- ``indexed`` for event parameters: Stores the parameter as topic.
|
- ``indexed`` for event parameters: Stores the parameter as topic.
|
||||||
- ``virtual`` for functions and modifiers: Allows the function's or modifier's
|
- ``virtual`` for functions and modifiers: Allows the function's or modifier's
|
||||||
behaviour to be changed in derived contracts.
|
behavior to be changed in derived contracts.
|
||||||
- ``override``: States that this function, modifier or public state variable changes
|
- ``override``: States that this function, modifier or public state variable changes
|
||||||
the behaviour of a function or modifier in a base contract.
|
the behavior of a function or modifier in a base contract.
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
Function Modifiers
|
Function Modifiers
|
||||||
******************
|
******************
|
||||||
|
|
||||||
Modifiers can be used to change the behaviour of functions in a declarative way.
|
Modifiers can be used to change the behavior of functions in a declarative way.
|
||||||
For example,
|
For example,
|
||||||
you can use a modifier to automatically check a condition prior to executing the function.
|
you can use a modifier to automatically check a condition prior to executing the function.
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ Reverting a state change is not considered a "state modification", as only chang
|
|||||||
state made previously in code that did not have the ``view`` or ``pure`` restriction
|
state made previously in code that did not have the ``view`` or ``pure`` restriction
|
||||||
are reverted and that code has the option to catch the ``revert`` and not pass it on.
|
are reverted and that code has the option to catch the ``revert`` and not pass it on.
|
||||||
|
|
||||||
This behaviour is also in line with the ``STATICCALL`` opcode.
|
This behavior is also in line with the ``STATICCALL`` opcode.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
It is not possible to prevent functions from reading the state at the level
|
It is not possible to prevent functions from reading the state at the level
|
||||||
|
@ -54,7 +54,7 @@ Details are given in the following example.
|
|||||||
// accessed externally via `this`, though.
|
// accessed externally via `this`, though.
|
||||||
contract Destructible is Owned {
|
contract Destructible is Owned {
|
||||||
// The keyword `virtual` means that the function can change
|
// The keyword `virtual` means that the function can change
|
||||||
// its behaviour in derived classes ("overriding").
|
// its behavior in derived classes ("overriding").
|
||||||
function destroy() virtual public {
|
function destroy() virtual public {
|
||||||
if (msg.sender == owner) selfdestruct(owner);
|
if (msg.sender == owner) selfdestruct(owner);
|
||||||
}
|
}
|
||||||
@ -115,7 +115,7 @@ Details are given in the following example.
|
|||||||
|
|
||||||
// Here, we only specify `override` and not `virtual`.
|
// Here, we only specify `override` and not `virtual`.
|
||||||
// This means that contracts deriving from `PriceFeed`
|
// This means that contracts deriving from `PriceFeed`
|
||||||
// cannot change the behaviour of `destroy` anymore.
|
// cannot change the behavior of `destroy` anymore.
|
||||||
function destroy() public override(Destructible, Named) { Named.destroy(); }
|
function destroy() public override(Destructible, Named) { Named.destroy(); }
|
||||||
function get() public view returns(uint r) { return info; }
|
function get() public view returns(uint r) { return info; }
|
||||||
|
|
||||||
@ -293,7 +293,7 @@ and ends at a contract mentioning a function with that signature
|
|||||||
that does not override.
|
that does not override.
|
||||||
|
|
||||||
If you do not mark a function that overrides as ``virtual``, derived
|
If you do not mark a function that overrides as ``virtual``, derived
|
||||||
contracts can no longer change the behaviour of that function.
|
contracts can no longer change the behavior of that function.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ One way is directly in the inheritance list (``is Base(7)``). The other is in
|
|||||||
the way a modifier is invoked as part of
|
the way a modifier is invoked as part of
|
||||||
the derived constructor (``Base(y * y)``). The first way to
|
the derived constructor (``Base(y * y)``). The first way to
|
||||||
do it is more convenient if the constructor argument is a
|
do it is more convenient if the constructor argument is a
|
||||||
constant and defines the behaviour of the contract or
|
constant and defines the behavior of the contract or
|
||||||
describes it. The second way has to be used if the
|
describes it. The second way has to be used if the
|
||||||
constructor arguments of the base depend on those of the
|
constructor arguments of the base depend on those of the
|
||||||
derived contract. Arguments have to be given either in the
|
derived contract. Arguments have to be given either in the
|
||||||
|
@ -45,7 +45,7 @@ reporting issues, please mention the following details:
|
|||||||
* Source code (if applicable).
|
* Source code (if applicable).
|
||||||
* Operating system.
|
* Operating system.
|
||||||
* Steps to reproduce the issue.
|
* Steps to reproduce the issue.
|
||||||
* Actual vs. expected behaviour.
|
* Actual vs. expected behavior.
|
||||||
|
|
||||||
Reducing the source code that caused the issue to a bare minimum is always
|
Reducing the source code that caused the issue to a bare minimum is always
|
||||||
very helpful, and sometimes even clarifies a misunderstanding.
|
very helpful, and sometimes even clarifies a misunderstanding.
|
||||||
@ -114,7 +114,7 @@ Running ``build/test/soltest`` or its wrapper ``scripts/soltest.sh`` is sufficie
|
|||||||
|
|
||||||
The ``./scripts/tests.sh`` script executes most Solidity tests automatically,
|
The ``./scripts/tests.sh`` script executes most Solidity tests automatically,
|
||||||
including those bundled into the `Boost C++ Test Framework <https://www.boost.org/doc/libs/release/libs/test/doc/html/index.html>`_
|
including those bundled into the `Boost C++ Test Framework <https://www.boost.org/doc/libs/release/libs/test/doc/html/index.html>`_
|
||||||
application ``soltest`` (or its wrapper ``scripts/soltest.sh``), as well as command line tests and
|
application ``soltest`` (or its wrapper ``scripts/soltest.sh``), as well as command-line tests and
|
||||||
compilation tests.
|
compilation tests.
|
||||||
|
|
||||||
The test system automatically tries to discover the location of
|
The test system automatically tries to discover the location of
|
||||||
@ -239,7 +239,7 @@ provides a way to edit, update or skip the current contract file, or quit the ap
|
|||||||
|
|
||||||
It offers several options for failing tests:
|
It offers several options for failing tests:
|
||||||
|
|
||||||
- ``edit``: ``isoltest`` tries to open the contract in an editor so you can adjust it. It either uses the editor given on the command line (as ``isoltest --editor /path/to/editor``), in the environment variable ``EDITOR`` or just ``/usr/bin/editor`` (in that order).
|
- ``edit``: ``isoltest`` tries to open the contract in an editor so you can adjust it. It either uses the editor given on the command-line (as ``isoltest --editor /path/to/editor``), in the environment variable ``EDITOR`` or just ``/usr/bin/editor`` (in that order).
|
||||||
- ``update``: Updates the expectations for contract under test. This updates the annotations by removing unmet expectations and adding missing expectations. The test is then run again.
|
- ``update``: Updates the expectations for contract under test. This updates the annotations by removing unmet expectations and adding missing expectations. The test is then run again.
|
||||||
- ``skip``: Skips the execution of this particular test.
|
- ``skip``: Skips the execution of this particular test.
|
||||||
- ``quit``: Quits ``isoltest``.
|
- ``quit``: Quits ``isoltest``.
|
||||||
@ -350,7 +350,7 @@ The AFL documentation states that the corpus (the initial input files) should no
|
|||||||
too large. The files themselves should not be larger than 1 kB and there should be
|
too large. The files themselves should not be larger than 1 kB and there should be
|
||||||
at most one input file per functionality, so better start with a small number of.
|
at most one input file per functionality, so better start with a small number of.
|
||||||
There is also a tool called ``afl-cmin`` that can trim input files
|
There is also a tool called ``afl-cmin`` that can trim input files
|
||||||
that result in similar behaviour of the binary.
|
that result in similar behavior of the binary.
|
||||||
|
|
||||||
Now run the fuzzer (the ``-m`` extends the size of memory to 60 MB):
|
Now run the fuzzer (the ``-m`` extends the size of memory to 60 MB):
|
||||||
|
|
||||||
|
@ -365,13 +365,13 @@ i.e. the following is not valid: ``(x, uint y) = (1, 2);``
|
|||||||
.. warning::
|
.. warning::
|
||||||
Be careful when assigning to multiple variables at the same time when
|
Be careful when assigning to multiple variables at the same time when
|
||||||
reference types are involved, because it could lead to unexpected
|
reference types are involved, because it could lead to unexpected
|
||||||
copying behaviour.
|
copying behavior.
|
||||||
|
|
||||||
Complications for Arrays and Structs
|
Complications for Arrays and Structs
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
The semantics of assignments are more complicated for non-value types like arrays and structs,
|
The semantics of assignments are more complicated for non-value types like arrays and structs,
|
||||||
including ``bytes`` and ``string``, see :ref:`Data location and assignment behaviour <data-location-assignment>` for details.
|
including ``bytes`` and ``string``, see :ref:`Data location and assignment behavior <data-location-assignment>` for details.
|
||||||
|
|
||||||
In the example below the call to ``g(x)`` has no effect on ``x`` because it creates
|
In the example below the call to ``g(x)`` has no effect on ``x`` because it creates
|
||||||
an independent copy of the storage value in memory. However, ``h(x)`` successfully modifies ``x``
|
an independent copy of the storage value in memory. However, ``h(x)`` successfully modifies ``x``
|
||||||
@ -510,7 +510,7 @@ additional checks.
|
|||||||
Since Solidity 0.8.0, all arithmetic operations revert on over- and underflow by default,
|
Since Solidity 0.8.0, all arithmetic operations revert on over- and underflow by default,
|
||||||
thus making the use of these libraries unnecessary.
|
thus making the use of these libraries unnecessary.
|
||||||
|
|
||||||
To obtain the previous behaviour, an ``unchecked`` block can be used:
|
To obtain the previous behavior, an ``unchecked`` block can be used:
|
||||||
|
|
||||||
.. code-block:: solidity
|
.. code-block:: solidity
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ The ``revert`` statement takes a custom error as direct argument without parenth
|
|||||||
|
|
||||||
revert CustomError(arg1, arg2);
|
revert CustomError(arg1, arg2);
|
||||||
|
|
||||||
For backwards-compatibility reasons, there is also the ``revert()`` function, which uses parentheses
|
For backward-compatibility reasons, there is also the ``revert()`` function, which uses parentheses
|
||||||
and accepts a string:
|
and accepts a string:
|
||||||
|
|
||||||
revert();
|
revert();
|
||||||
|
@ -86,7 +86,7 @@ Packing arguments
|
|||||||
Now that we have identified what information to include in the signed message,
|
Now that we have identified what information to include in the signed message,
|
||||||
we are ready to put the message together, hash it, and sign it. For simplicity,
|
we are ready to put the message together, hash it, and sign it. For simplicity,
|
||||||
we concatenate the data. The `ethereumjs-abi <https://github.com/ethereumjs/ethereumjs-abi>`_
|
we concatenate the data. The `ethereumjs-abi <https://github.com/ethereumjs/ethereumjs-abi>`_
|
||||||
library provides a function called ``soliditySHA3`` that mimics the behaviour of
|
library provides a function called ``soliditySHA3`` that mimics the behavior of
|
||||||
Solidity's ``keccak256`` function applied to arguments encoded using ``abi.encodePacked``.
|
Solidity's ``keccak256`` function applied to arguments encoded using ``abi.encodePacked``.
|
||||||
Here is a JavaScript function that creates the proper signature for the ``ReceiverPays`` example:
|
Here is a JavaScript function that creates the proper signature for the ``ReceiverPays`` example:
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ Modular Contracts
|
|||||||
A modular approach to building your contracts helps you reduce the complexity
|
A modular approach to building your contracts helps you reduce the complexity
|
||||||
and improve the readability which will help to identify bugs and vulnerabilities
|
and improve the readability which will help to identify bugs and vulnerabilities
|
||||||
during development and code review.
|
during development and code review.
|
||||||
If you specify and control the behaviour of each module in isolation, the
|
If you specify and control the behavior of each module in isolation, the
|
||||||
interactions you have to consider are only those between the module specifications
|
interactions you have to consider are only those between the module specifications
|
||||||
and not every other moving part of the contract.
|
and not every other moving part of the contract.
|
||||||
In the example below, the contract uses the ``move`` method
|
In the example below, the contract uses the ``move`` method
|
||||||
|
@ -10,12 +10,12 @@ Versioning
|
|||||||
==========
|
==========
|
||||||
|
|
||||||
Solidity versions follow `Semantic Versioning <https://semver.org>`_. In
|
Solidity versions follow `Semantic Versioning <https://semver.org>`_. In
|
||||||
addition, patch level releases with major release 0 (i.e. 0.x.y) will not
|
addition, patch-level releases with major release 0 (i.e. 0.x.y) will not
|
||||||
contain breaking changes. That means code that compiles with version 0.x.y
|
contain breaking changes. That means code that compiles with version 0.x.y
|
||||||
can be expected to compile with 0.x.z where z > y.
|
can be expected to compile with 0.x.z where z > y.
|
||||||
|
|
||||||
In addition to releases, we provide **nightly development builds** with the
|
In addition to releases, we provide **nightly development builds** to make
|
||||||
intention of making it easy for developers to try out upcoming features and
|
it easy for developers to try out upcoming features and
|
||||||
provide early feedback. Note, however, that while the nightly builds are usually
|
provide early feedback. Note, however, that while the nightly builds are usually
|
||||||
very stable, they contain bleeding-edge code from the development branch and are
|
very stable, they contain bleeding-edge code from the development branch and are
|
||||||
not guaranteed to be always working. Despite our best efforts, they might
|
not guaranteed to be always working. Despite our best efforts, they might
|
||||||
@ -33,12 +33,12 @@ Remix
|
|||||||
|
|
||||||
`Access Remix online <https://remix.ethereum.org/>`_, you do not need to install anything.
|
`Access Remix online <https://remix.ethereum.org/>`_, you do not need to install anything.
|
||||||
If you want to use it without connection to the Internet, go to
|
If you want to use it without connection to the Internet, go to
|
||||||
https://github.com/ethereum/remix-live/tree/gh-pages and download the ``.zip`` file as
|
https://github.com/ethereum/remix-live/tree/gh-pages#readme and follow the instructions on that page.
|
||||||
explained on that page. Remix is also a convenient option for testing nightly builds
|
Remix is also a convenient option for testing nightly builds
|
||||||
without installing multiple Solidity versions.
|
without installing multiple Solidity versions.
|
||||||
|
|
||||||
Further options on this page detail installing commandline Solidity compiler software
|
Further options on this page detail installing command-line Solidity compiler software
|
||||||
on your computer. Choose a commandline compiler if you are working on a larger contract
|
on your computer. Choose a command-line compiler if you are working on a larger contract
|
||||||
or if you require more compilation options.
|
or if you require more compilation options.
|
||||||
|
|
||||||
.. _solcjs:
|
.. _solcjs:
|
||||||
@ -54,7 +54,7 @@ the full-featured compiler, ``solc``. The usage of ``solcjs`` is documented insi
|
|||||||
`repository <https://github.com/ethereum/solc-js>`_.
|
`repository <https://github.com/ethereum/solc-js>`_.
|
||||||
|
|
||||||
Note: The solc-js project is derived from the C++
|
Note: The solc-js project is derived from the C++
|
||||||
`solc` by using Emscripten which means that both use the same compiler source code.
|
`solc` by using Emscripten, which means that both use the same compiler source code.
|
||||||
`solc-js` can be used in JavaScript projects directly (such as Remix).
|
`solc-js` can be used in JavaScript projects directly (such as Remix).
|
||||||
Please refer to the solc-js repository for instructions.
|
Please refer to the solc-js repository for instructions.
|
||||||
|
|
||||||
@ -64,18 +64,18 @@ Please refer to the solc-js repository for instructions.
|
|||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
The commandline executable is named ``solcjs``.
|
The command-line executable is named ``solcjs``.
|
||||||
|
|
||||||
The commandline options of ``solcjs`` are not compatible with ``solc`` and tools (such as ``geth``)
|
The command-line options of ``solcjs`` are not compatible with ``solc`` and tools (such as ``geth``)
|
||||||
expecting the behaviour of ``solc`` will not work with ``solcjs``.
|
expecting the behavior of ``solc`` will not work with ``solcjs``.
|
||||||
|
|
||||||
Docker
|
Docker
|
||||||
======
|
======
|
||||||
|
|
||||||
Docker images of Solidity builds are available using the ``solc`` image from the ``ethereum`` organisation.
|
Docker images of Solidity builds are available using the ``solc`` image from the ``ethereum`` organization.
|
||||||
Use the ``stable`` tag for the latest released version, and ``nightly`` for potentially unstable changes in the develop branch.
|
Use the ``stable`` tag for the latest released version, and ``nightly`` for potentially unstable changes in the develop branch.
|
||||||
|
|
||||||
The Docker image runs the compiler executable, so you can pass all compiler arguments to it.
|
The Docker image runs the compiler executable so that you can pass all compiler arguments to it.
|
||||||
For example, the command below pulls the stable version of the ``solc`` image (if you do not have it already),
|
For example, the command below pulls the stable version of the ``solc`` image (if you do not have it already),
|
||||||
and runs it in a new container, passing the ``--help`` argument.
|
and runs it in a new container, passing the ``--help`` argument.
|
||||||
|
|
||||||
@ -83,13 +83,13 @@ and runs it in a new container, passing the ``--help`` argument.
|
|||||||
|
|
||||||
docker run ethereum/solc:stable --help
|
docker run ethereum/solc:stable --help
|
||||||
|
|
||||||
You can also specify release build versions in the tag, for example, for the 0.5.4 release.
|
For example, You can specify release build versions in the tag for the 0.5.4 release.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
docker run ethereum/solc:0.5.4 --help
|
docker run ethereum/solc:0.5.4 --help
|
||||||
|
|
||||||
To use the Docker image to compile Solidity files on the host machine mount a
|
To use the Docker image to compile Solidity files on the host machine, mount a
|
||||||
local folder for input and output, and specify the contract to compile. For example.
|
local folder for input and output, and specify the contract to compile. For example.
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
@ -97,7 +97,7 @@ local folder for input and output, and specify the contract to compile. For exam
|
|||||||
docker run -v /local/path:/sources ethereum/solc:stable -o /sources/output --abi --bin /sources/Contract.sol
|
docker run -v /local/path:/sources ethereum/solc:stable -o /sources/output --abi --bin /sources/Contract.sol
|
||||||
|
|
||||||
You can also use the standard JSON interface (which is recommended when using the compiler with tooling).
|
You can also use the standard JSON interface (which is recommended when using the compiler with tooling).
|
||||||
When using this interface it is not necessary to mount any directories as long as the JSON input is
|
When using this interface, it is not necessary to mount any directories as long as the JSON input is
|
||||||
self-contained (i.e. it does not refer to any external files that would have to be
|
self-contained (i.e. it does not refer to any external files that would have to be
|
||||||
:ref:`loaded by the import callback <initial-vfs-content-standard-json-with-import-callback>`).
|
:ref:`loaded by the import callback <initial-vfs-content-standard-json-with-import-callback>`).
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ The nightly version can be installed using these commands:
|
|||||||
sudo apt-get install solc
|
sudo apt-get install solc
|
||||||
|
|
||||||
Furthermore, some Linux distributions provide their own packages. These packages are not directly
|
Furthermore, some Linux distributions provide their own packages. These packages are not directly
|
||||||
maintained by us, but usually kept up-to-date by the respective package maintainers.
|
maintained by us but usually kept up-to-date by the respective package maintainers.
|
||||||
|
|
||||||
For example, Arch Linux has packages for the latest development version:
|
For example, Arch Linux has packages for the latest development version:
|
||||||
|
|
||||||
@ -212,12 +212,12 @@ out-of-the-box but it is also meant to be friendly to third-party tools:
|
|||||||
HTTPS without any authentication, rate limiting or the need to use git.
|
HTTPS without any authentication, rate limiting or the need to use git.
|
||||||
- Content is served with correct `Content-Type` headers and lenient CORS configuration so that it
|
- Content is served with correct `Content-Type` headers and lenient CORS configuration so that it
|
||||||
can be directly loaded by tools running in the browser.
|
can be directly loaded by tools running in the browser.
|
||||||
- Binaries do not require installation or unpacking (with the exception of older Windows builds
|
- Binaries do not require installation or unpacking (exception for older Windows builds
|
||||||
bundled with necessary DLLs).
|
bundled with necessary DLLs).
|
||||||
- We strive for a high level of backwards-compatibility. Files, once added, are not removed or moved
|
- We strive for a high level of backward-compatibility. Files, once added, are not removed or moved
|
||||||
without providing a symlink/redirect at the old location. They are also never modified
|
without providing a symlink/redirect at the old location. They are also never modified
|
||||||
in place and should always match the original checksum. The only exception would be broken or
|
in place and should always match the original checksum. The only exception would be broken or
|
||||||
unusable files with a potential to cause more harm than good if left as is.
|
unusable files with the potential to cause more harm than good if left as is.
|
||||||
- Files are served over both HTTP and HTTPS. As long as you obtain the file list in a secure way
|
- Files are served over both HTTP and HTTPS. As long as you obtain the file list in a secure way
|
||||||
(via git, HTTPS, IPFS or just have it cached locally) and verify hashes of the binaries
|
(via git, HTTPS, IPFS or just have it cached locally) and verify hashes of the binaries
|
||||||
after downloading them, you do not have to use HTTPS for the binaries themselves.
|
after downloading them, you do not have to use HTTPS for the binaries themselves.
|
||||||
@ -228,7 +228,7 @@ that we do not rename them if the naming convention changes and we do not add bu
|
|||||||
that were not supported at the time of release. This only happens in ``solc-bin``.
|
that were not supported at the time of release. This only happens in ``solc-bin``.
|
||||||
|
|
||||||
The ``solc-bin`` repository contains several top-level directories, each representing a single platform.
|
The ``solc-bin`` repository contains several top-level directories, each representing a single platform.
|
||||||
Each one contains a ``list.json`` file listing the available binaries. For example in
|
Each one includes a ``list.json`` file listing the available binaries. For example in
|
||||||
``emscripten-wasm32/list.json`` you will find the following information about version 0.7.4:
|
``emscripten-wasm32/list.json`` you will find the following information about version 0.7.4:
|
||||||
|
|
||||||
.. code-block:: json
|
.. code-block:: json
|
||||||
@ -259,7 +259,7 @@ This means that:
|
|||||||
- The file might in future be available on Swarm at `16c5f09109c793db99fe35f037c6092b061bd39260ee7a677c8a97f18c955ab1`_.
|
- The file might in future be available on Swarm at `16c5f09109c793db99fe35f037c6092b061bd39260ee7a677c8a97f18c955ab1`_.
|
||||||
- You can verify the integrity of the binary by comparing its keccak256 hash to
|
- You can verify the integrity of the binary by comparing its keccak256 hash to
|
||||||
``0x300330ecd127756b824aa13e843cb1f43c473cb22eaf3750d5fb9c99279af8c3``. The hash can be computed
|
``0x300330ecd127756b824aa13e843cb1f43c473cb22eaf3750d5fb9c99279af8c3``. The hash can be computed
|
||||||
on the command line using ``keccak256sum`` utility provided by `sha3sum`_ or `keccak256() function
|
on the command-line using ``keccak256sum`` utility provided by `sha3sum`_ or `keccak256() function
|
||||||
from ethereumjs-util`_ in JavaScript.
|
from ethereumjs-util`_ in JavaScript.
|
||||||
- You can also verify the integrity of the binary by comparing its sha256 hash to
|
- You can also verify the integrity of the binary by comparing its sha256 hash to
|
||||||
``0x2b55ed5fec4d9625b6c7b3ab1abd2b7fb7dd2a9c68543bf0323db2c7e2d55af2``.
|
``0x2b55ed5fec4d9625b6c7b3ab1abd2b7fb7dd2a9c68543bf0323db2c7e2d55af2``.
|
||||||
@ -310,7 +310,6 @@ This means that:
|
|||||||
|
|
||||||
Building from Source
|
Building from Source
|
||||||
====================
|
====================
|
||||||
|
|
||||||
Prerequisites - All Operating Systems
|
Prerequisites - All Operating Systems
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
@ -341,7 +340,7 @@ The following are dependencies for all builds of Solidity:
|
|||||||
.. note::
|
.. note::
|
||||||
Solidity versions prior to 0.5.10 can fail to correctly link against Boost versions 1.70+.
|
Solidity versions prior to 0.5.10 can fail to correctly link against Boost versions 1.70+.
|
||||||
A possible workaround is to temporarily rename ``<Boost install path>/lib/cmake/Boost-1.70.0``
|
A possible workaround is to temporarily rename ``<Boost install path>/lib/cmake/Boost-1.70.0``
|
||||||
prior to running the cmake command to configure solidity.
|
prior to running the cmake command to configure Solidity.
|
||||||
|
|
||||||
Starting from 0.5.10 linking against Boost 1.70+ should work without manual intervention.
|
Starting from 0.5.10 linking against Boost 1.70+ should work without manual intervention.
|
||||||
|
|
||||||
@ -449,7 +448,7 @@ To clone the source code, execute the following command:
|
|||||||
git clone --recursive https://github.com/ethereum/solidity.git
|
git clone --recursive https://github.com/ethereum/solidity.git
|
||||||
cd solidity
|
cd solidity
|
||||||
|
|
||||||
If you want to help developing Solidity,
|
If you want to help develop Solidity,
|
||||||
you should fork Solidity and add your personal fork as a second remote:
|
you should fork Solidity and add your personal fork as a second remote:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
@ -457,7 +456,7 @@ you should fork Solidity and add your personal fork as a second remote:
|
|||||||
git remote add personal git@github.com:[username]/solidity.git
|
git remote add personal git@github.com:[username]/solidity.git
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
This method will result in a prerelease build leading to e.g. a flag
|
This method will result in a pre-release build leading to e.g. a flag
|
||||||
being set in each bytecode produced by such a compiler.
|
being set in each bytecode produced by such a compiler.
|
||||||
If you want to re-build a released Solidity compiler, then
|
If you want to re-build a released Solidity compiler, then
|
||||||
please use the source tarball on the github release page:
|
please use the source tarball on the github release page:
|
||||||
@ -580,4 +579,4 @@ Example:
|
|||||||
4. A breaking change is introduced --> version is bumped to 0.5.0.
|
4. A breaking change is introduced --> version is bumped to 0.5.0.
|
||||||
5. The 0.5.0 release is made.
|
5. The 0.5.0 release is made.
|
||||||
|
|
||||||
This behaviour works well with the :ref:`version pragma <version_pragma>`.
|
This behavior works well with the :ref:`version pragma <version_pragma>`.
|
||||||
|
@ -564,7 +564,7 @@ contracts, the Ether is forever lost.
|
|||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
From version 0.8.18 and up, the use of ``selfdestruct`` in both Solidity and Yul will trigger a
|
From version 0.8.18 and up, the use of ``selfdestruct`` in both Solidity and Yul will trigger a
|
||||||
deprecation warning, since the ``SELFDESTRUCT`` opcode will eventually undergo breaking changes in behaviour
|
deprecation warning, since the ``SELFDESTRUCT`` opcode will eventually undergo breaking changes in behavior
|
||||||
as stated in `EIP-6049 <https://eips.ethereum.org/EIPS/eip-6049>`_.
|
as stated in `EIP-6049 <https://eips.ethereum.org/EIPS/eip-6049>`_.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
@ -591,7 +591,7 @@ Precompiled Contracts
|
|||||||
There is a small set of contract addresses that are special:
|
There is a small set of contract addresses that are special:
|
||||||
The address range between ``1`` and (including) ``8`` contains
|
The address range between ``1`` and (including) ``8`` contains
|
||||||
"precompiled contracts" that can be called as any other contract
|
"precompiled contracts" that can be called as any other contract
|
||||||
but their behaviour (and their gas consumption) is not defined
|
but their behavior (and their gas consumption) is not defined
|
||||||
by EVM code stored at that address (they do not contain code)
|
by EVM code stored at that address (they do not contain code)
|
||||||
but instead is implemented in the EVM execution environment itself.
|
but instead is implemented in the EVM execution environment itself.
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ The IR-based code generator was introduced with an aim to not only allow
|
|||||||
code generation to be more transparent and auditable but also
|
code generation to be more transparent and auditable but also
|
||||||
to enable more powerful optimization passes that span across functions.
|
to enable more powerful optimization passes that span across functions.
|
||||||
|
|
||||||
You can enable it on the command line using ``--via-ir``
|
You can enable it on the command-line using ``--via-ir``
|
||||||
or with the option ``{"viaIR": true}`` in standard-json and we
|
or with the option ``{"viaIR": true}`` in standard-json and we
|
||||||
encourage everyone to try it out!
|
encourage everyone to try it out!
|
||||||
|
|
||||||
For several reasons, there are tiny semantic differences between the old
|
For several reasons, there are tiny semantic differences between the old
|
||||||
and the IR-based code generator, mostly in areas where we would not
|
and the IR-based code generator, mostly in areas where we would not
|
||||||
expect people to rely on this behaviour anyway.
|
expect people to rely on this behavior anyway.
|
||||||
This section highlights the main differences between the old and the IR-based codegen.
|
This section highlights the main differences between the old and the IR-based codegen.
|
||||||
|
|
||||||
Semantic Only Changes
|
Semantic Only Changes
|
||||||
|
@ -147,7 +147,7 @@ explanatory purposes.
|
|||||||
"useLiteralContent": true
|
"useLiteralContent": true
|
||||||
},
|
},
|
||||||
// Optional: Optimizer settings. The fields "enabled" and "runs" are deprecated
|
// Optional: Optimizer settings. The fields "enabled" and "runs" are deprecated
|
||||||
// and are only given for backwards-compatibility.
|
// and are only given for backward-compatibility.
|
||||||
"optimizer": {
|
"optimizer": {
|
||||||
"details": {
|
"details": {
|
||||||
"constantOptimizer": false,
|
"constantOptimizer": false,
|
||||||
@ -241,7 +241,7 @@ relevant part of the bytecode can be decoded with a CBOR decoder.
|
|||||||
Check the `Metadata Playground <https://playground.sourcify.dev/>`_ to see it in action.
|
Check the `Metadata Playground <https://playground.sourcify.dev/>`_ to see it in action.
|
||||||
|
|
||||||
Whereas release builds of solc use a 3 byte encoding of the version as shown
|
Whereas release builds of solc use a 3 byte encoding of the version as shown
|
||||||
above (one byte each for major, minor and patch version number), prerelease builds
|
above (one byte each for major, minor and patch version number), pre-release builds
|
||||||
will instead use a complete version string including commit hash and build date.
|
will instead use a complete version string including commit hash and build date.
|
||||||
|
|
||||||
The commandline flag ``--no-cbor-metadata`` can be used to skip metadata
|
The commandline flag ``--no-cbor-metadata`` can be used to skip metadata
|
||||||
|
@ -139,7 +139,7 @@ The initial content of the VFS depends on how you invoke the compiler:
|
|||||||
|
|
||||||
#. **Standard input**
|
#. **Standard input**
|
||||||
|
|
||||||
On the command line it is also possible to provide the source by sending it to compiler's
|
On the command-line it is also possible to provide the source by sending it to compiler's
|
||||||
standard input:
|
standard input:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
@ -345,13 +345,13 @@ of the compiler.
|
|||||||
CLI Path Normalization and Stripping
|
CLI Path Normalization and Stripping
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
On the command line the compiler behaves just as you would expect from any other program:
|
On the command-line the compiler behaves just as you would expect from any other program:
|
||||||
it accepts paths in a format native to the platform and relative paths are relative to the current
|
it accepts paths in a format native to the platform and relative paths are relative to the current
|
||||||
working directory.
|
working directory.
|
||||||
The source unit names assigned to files whose paths are specified on the command line, however,
|
The source unit names assigned to files whose paths are specified on the command-line, however,
|
||||||
should not change just because the project is being compiled on a different platform or because the
|
should not change just because the project is being compiled on a different platform or because the
|
||||||
compiler happens to have been invoked from a different directory.
|
compiler happens to have been invoked from a different directory.
|
||||||
To achieve this, paths to source files coming from the command line must be converted to a canonical
|
To achieve this, paths to source files coming from the command-line must be converted to a canonical
|
||||||
form, and, if possible, made relative to the base path or one of the include paths.
|
form, and, if possible, made relative to the base path or one of the include paths.
|
||||||
|
|
||||||
The normalization rules are as follows:
|
The normalization rules are as follows:
|
||||||
@ -408,7 +408,7 @@ The resulting file path becomes the source unit name.
|
|||||||
Prior to version 0.8.8, CLI path stripping was not performed and the only normalization applied
|
Prior to version 0.8.8, CLI path stripping was not performed and the only normalization applied
|
||||||
was the conversion of path separators.
|
was the conversion of path separators.
|
||||||
When working with older versions of the compiler it is recommended to invoke the compiler from
|
When working with older versions of the compiler it is recommended to invoke the compiler from
|
||||||
the base path and to only use relative paths on the command line.
|
the base path and to only use relative paths on the command-line.
|
||||||
|
|
||||||
.. index:: ! allowed paths, ! --allow-paths, remapping; target
|
.. index:: ! allowed paths, ! --allow-paths, remapping; target
|
||||||
.. _allowed-paths:
|
.. _allowed-paths:
|
||||||
@ -421,7 +421,7 @@ locations that are considered safe by default:
|
|||||||
|
|
||||||
- Outside of Standard JSON mode:
|
- Outside of Standard JSON mode:
|
||||||
|
|
||||||
- The directories containing input files listed on the command line.
|
- The directories containing input files listed on the command-line.
|
||||||
- The directories used as :ref:`remapping <import-remapping>` targets.
|
- The directories used as :ref:`remapping <import-remapping>` targets.
|
||||||
If the target is not a directory (i.e does not end with ``/``, ``/.`` or ``/..``) the directory
|
If the target is not a directory (i.e does not end with ``/``, ``/.`` or ``/..``) the directory
|
||||||
containing the target is used instead.
|
containing the target is used instead.
|
||||||
@ -551,7 +551,7 @@ you checked out to ``/project/dapp-bin_old``, then you can run:
|
|||||||
This means that all imports in ``module2`` point to the old version but imports in ``module1``
|
This means that all imports in ``module2`` point to the old version but imports in ``module1``
|
||||||
point to the new version.
|
point to the new version.
|
||||||
|
|
||||||
Here are the detailed rules governing the behaviour of remappings:
|
Here are the detailed rules governing the behavior of remappings:
|
||||||
|
|
||||||
#. **Remappings only affect the translation between import paths and source unit names.**
|
#. **Remappings only affect the translation between import paths and source unit names.**
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ Integrated (Ethereum) Development Environments
|
|||||||
Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
|
Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
|
||||||
|
|
||||||
* `Dapp <https://dapp.tools/>`_
|
* `Dapp <https://dapp.tools/>`_
|
||||||
Tool for building, testing and deploying smart contracts from the command line.
|
Tool for building, testing and deploying smart contracts from the command-line.
|
||||||
|
|
||||||
* `Embark <https://framework.embarklabs.io/>`_
|
* `Embark <https://framework.embarklabs.io/>`_
|
||||||
Developer platform for building and deploying decentralized applications.
|
Developer platform for building and deploying decentralized applications.
|
||||||
|
@ -97,7 +97,7 @@ Overflow
|
|||||||
|
|
||||||
The contract above shows an overflow check example.
|
The contract above shows an overflow check example.
|
||||||
The SMTChecker does not check underflow and overflow by default for Solidity >=0.8.7,
|
The SMTChecker does not check underflow and overflow by default for Solidity >=0.8.7,
|
||||||
so we need to use the command line option ``--model-checker-targets "underflow,overflow"``
|
so we need to use the command-line option ``--model-checker-targets "underflow,overflow"``
|
||||||
or the JSON option ``settings.modelChecker.targets = ["underflow", "overflow"]``.
|
or the JSON option ``settings.modelChecker.targets = ["underflow", "overflow"]``.
|
||||||
See :ref:`this section for targets configuration<smtchecker_targets>`.
|
See :ref:`this section for targets configuration<smtchecker_targets>`.
|
||||||
Here, it reports the following:
|
Here, it reports the following:
|
||||||
@ -412,7 +412,7 @@ is already "locked", so it would not be possible to change the value of ``x``,
|
|||||||
regardless of what the unknown called code does.
|
regardless of what the unknown called code does.
|
||||||
|
|
||||||
If we "forget" to use the ``mutex`` modifier on function ``set``, the
|
If we "forget" to use the ``mutex`` modifier on function ``set``, the
|
||||||
SMTChecker is able to synthesize the behaviour of the externally called code so
|
SMTChecker is able to synthesize the behavior of the externally called code so
|
||||||
that the assertion fails:
|
that the assertion fails:
|
||||||
|
|
||||||
.. code-block:: text
|
.. code-block:: text
|
||||||
@ -750,7 +750,7 @@ and modulo operations inside Horn rules. Because of that, by default the
|
|||||||
Solidity division and modulo operations are encoded using the constraint
|
Solidity division and modulo operations are encoded using the constraint
|
||||||
``a = b * d + m`` where ``d = a / b`` and ``m = a % b``.
|
``a = b * d + m`` where ``d = a / b`` and ``m = a % b``.
|
||||||
However, other solvers, such as Eldarica, prefer the syntactically precise operations.
|
However, other solvers, such as Eldarica, prefer the syntactically precise operations.
|
||||||
The command line flag ``--model-checker-div-mod-no-slacks`` and the JSON option
|
The command-line flag ``--model-checker-div-mod-no-slacks`` and the JSON option
|
||||||
``settings.modelChecker.divModNoSlacks`` can be used to toggle the encoding
|
``settings.modelChecker.divModNoSlacks`` can be used to toggle the encoding
|
||||||
depending on the used solver preferences.
|
depending on the used solver preferences.
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ captures this concept well.
|
|||||||
|
|
||||||
A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is most important.
|
A style guide is about consistency. Consistency with this style guide is important. Consistency within a project is more important. Consistency within one module or function is most important.
|
||||||
|
|
||||||
But most importantly: **know when to be inconsistent** -- sometimes the style guide just doesn't apply. When in doubt, use your best judgment. Look at other examples and decide what looks best. And don't hesitate to ask!
|
But most importantly: **know when to be inconsistent** -- sometimes the style guide just doesn't apply. When in doubt, use your best judgment. Look at other examples and decide what looks best. And do not hesitate to ask!
|
||||||
|
|
||||||
|
|
||||||
***********
|
***********
|
||||||
@ -448,7 +448,7 @@ No:
|
|||||||
y = 2;
|
y = 2;
|
||||||
longVariable = 3;
|
longVariable = 3;
|
||||||
|
|
||||||
Don't include a whitespace in the receive and fallback functions:
|
Do not include a whitespace in the receive and fallback functions:
|
||||||
|
|
||||||
Yes:
|
Yes:
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ Explicit Conversions
|
|||||||
|
|
||||||
If the compiler does not allow implicit conversion but you are confident a conversion will work,
|
If the compiler does not allow implicit conversion but you are confident a conversion will work,
|
||||||
an explicit type conversion is sometimes possible. This may
|
an explicit type conversion is sometimes possible. This may
|
||||||
result in unexpected behaviour and allows you to bypass some security
|
result in unexpected behavior and allows you to bypass some security
|
||||||
features of the compiler, so be sure to test that the
|
features of the compiler, so be sure to test that the
|
||||||
result is what you want and expect!
|
result is what you want and expect!
|
||||||
|
|
||||||
|
@ -47,8 +47,8 @@ non-persistent area where function arguments are stored, and behaves mostly like
|
|||||||
|
|
||||||
.. _data-location-assignment:
|
.. _data-location-assignment:
|
||||||
|
|
||||||
Data location and assignment behaviour
|
Data location and assignment behavior
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
Data locations are not only relevant for persistency of data, but also for the semantics of assignments:
|
Data locations are not only relevant for persistency of data, but also for the semantics of assignments:
|
||||||
|
|
||||||
@ -582,10 +582,10 @@ and the assignment will effectively garble the length of ``x``.
|
|||||||
To be safe, only enlarge bytes arrays by at most one element during a single
|
To be safe, only enlarge bytes arrays by at most one element during a single
|
||||||
assignment and do not simultaneously index-access the array in the same statement.
|
assignment and do not simultaneously index-access the array in the same statement.
|
||||||
|
|
||||||
While the above describes the behaviour of dangling storage references in the
|
While the above describes the behavior of dangling storage references in the
|
||||||
current version of the compiler, any code with dangling references should be
|
current version of the compiler, any code with dangling references should be
|
||||||
considered to have *undefined behaviour*. In particular, this means that
|
considered to have *undefined behavior*. In particular, this means that
|
||||||
any future version of the compiler may change the behaviour of code that
|
any future version of the compiler may change the behavior of code that
|
||||||
involves dangling references.
|
involves dangling references.
|
||||||
|
|
||||||
Be sure to avoid dangling references in your code!
|
Be sure to avoid dangling references in your code!
|
||||||
@ -641,7 +641,7 @@ Array slices are useful to ABI-decode secondary data passed in function paramete
|
|||||||
/// after doing basic validation on the address argument.
|
/// after doing basic validation on the address argument.
|
||||||
function forward(bytes calldata payload) external {
|
function forward(bytes calldata payload) external {
|
||||||
bytes4 sig = bytes4(payload[:4]);
|
bytes4 sig = bytes4(payload[:4]);
|
||||||
// Due to truncating behaviour, bytes4(payload) performs identically.
|
// Due to truncating behavior, bytes4(payload) performs identically.
|
||||||
// bytes4 sig = bytes4(payload);
|
// bytes4 sig = bytes4(payload);
|
||||||
if (sig == bytes4(keccak256("setOwner(address)"))) {
|
if (sig == bytes4(keccak256("setOwner(address)"))) {
|
||||||
address owner = abi.decode(payload[4:], (address));
|
address owner = abi.decode(payload[4:], (address));
|
||||||
|
@ -140,7 +140,7 @@ Exponentiation
|
|||||||
|
|
||||||
Exponentiation is only available for unsigned types in the exponent. The resulting type
|
Exponentiation is only available for unsigned types in the exponent. The resulting type
|
||||||
of an exponentiation is always equal to the type of the base. Please take care that it is
|
of an exponentiation is always equal to the type of the base. Please take care that it is
|
||||||
large enough to hold the result and prepare for potential assertion failures or wrapping behaviour.
|
large enough to hold the result and prepare for potential assertion failures or wrapping behavior.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
In checked mode, exponentiation only uses the comparatively cheap ``exp`` opcode for small bases.
|
In checked mode, exponentiation only uses the comparatively cheap ``exp`` opcode for small bases.
|
||||||
|
@ -336,7 +336,7 @@ Furthermore, all functions of the current contract are callable directly includi
|
|||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
From version 0.8.18 and up, the use of ``selfdestruct`` in both Solidity and Yul will trigger a
|
From version 0.8.18 and up, the use of ``selfdestruct`` in both Solidity and Yul will trigger a
|
||||||
deprecation warning, since the ``SELFDESTRUCT`` opcode will eventually undergo breaking changes in behaviour
|
deprecation warning, since the ``SELFDESTRUCT`` opcode will eventually undergo breaking changes in behavior
|
||||||
as stated in `EIP-6049 <https://eips.ethereum.org/EIPS/eip-6049>`_.
|
as stated in `EIP-6049 <https://eips.ethereum.org/EIPS/eip-6049>`_.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
@ -54,7 +54,7 @@ or ../ <direct-imports>` are treated as relative to the directories specified us
|
|||||||
Furthermore, the part of the path added via these options will not appear in the contract metadata.
|
Furthermore, the part of the path added via these options will not appear in the contract metadata.
|
||||||
|
|
||||||
For security reasons the compiler has :ref:`restrictions on what directories it can access <allowed-paths>`.
|
For security reasons the compiler has :ref:`restrictions on what directories it can access <allowed-paths>`.
|
||||||
Directories of source files specified on the command line and target paths of
|
Directories of source files specified on the command-line and target paths of
|
||||||
remappings are automatically allowed to be accessed by the file reader, but everything
|
remappings are automatically allowed to be accessed by the file reader, but everything
|
||||||
else is rejected by default.
|
else is rejected by default.
|
||||||
Additional paths (and their subdirectories) can be allowed via the
|
Additional paths (and their subdirectories) can be allowed via the
|
||||||
@ -114,15 +114,15 @@ Setting the EVM Version to Target
|
|||||||
*********************************
|
*********************************
|
||||||
|
|
||||||
When you compile your contract code you can specify the Ethereum virtual machine
|
When you compile your contract code you can specify the Ethereum virtual machine
|
||||||
version to compile for to avoid particular features or behaviours.
|
version to compile for to avoid particular features or behaviors.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
||||||
Compiling for the wrong EVM version can result in wrong, strange and failing
|
Compiling for the wrong EVM version can result in wrong, strange and failing
|
||||||
behaviour. Please ensure, especially if running a private chain, that you
|
behavior. Please ensure, especially if running a private chain, that you
|
||||||
use matching EVM versions.
|
use matching EVM versions.
|
||||||
|
|
||||||
On the command line, you can select the EVM version as follows:
|
On the command-line, you can select the EVM version as follows:
|
||||||
|
|
||||||
.. code-block:: shell
|
.. code-block:: shell
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ Input Description
|
|||||||
"bzzr://56ab...",
|
"bzzr://56ab...",
|
||||||
"ipfs://Qma...",
|
"ipfs://Qma...",
|
||||||
"/tmp/path/to/file.sol"
|
"/tmp/path/to/file.sol"
|
||||||
// If files are used, their directories should be added to the command line via
|
// If files are used, their directories should be added to the command-line via
|
||||||
// `--allow-paths <path>`.
|
// `--allow-paths <path>`.
|
||||||
]
|
]
|
||||||
// If language is set to "SolidityAST", an AST needs to be supplied under the "ast" key.
|
// If language is set to "SolidityAST", an AST needs to be supplied under the "ast" key.
|
||||||
|
@ -960,7 +960,7 @@ the ``dup`` and ``swap`` instructions as well as ``jump`` instructions, labels a
|
|||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
From version 0.8.18 and up, the use of ``selfdestruct`` in both Solidity and Yul will trigger a
|
From version 0.8.18 and up, the use of ``selfdestruct`` in both Solidity and Yul will trigger a
|
||||||
deprecation warning, since the ``SELFDESTRUCT`` opcode will eventually undergo breaking changes in behaviour
|
deprecation warning, since the ``SELFDESTRUCT`` opcode will eventually undergo breaking changes in behavior
|
||||||
as stated in `EIP-6049 <https://eips.ethereum.org/EIPS/eip-6049>`_.
|
as stated in `EIP-6049 <https://eips.ethereum.org/EIPS/eip-6049>`_.
|
||||||
|
|
||||||
In some internal dialects, there are additional functions:
|
In some internal dialects, there are additional functions:
|
||||||
@ -995,7 +995,7 @@ Its first and only argument must be a string literal and uniquely represents the
|
|||||||
Identifiers can be arbitrary but when the compiler produces Yul code from Solidity sources,
|
Identifiers can be arbitrary but when the compiler produces Yul code from Solidity sources,
|
||||||
it uses a library name qualified with the name of the source unit that defines that library.
|
it uses a library name qualified with the name of the source unit that defines that library.
|
||||||
To link the code with a particular library address, the same identifier must be provided to the
|
To link the code with a particular library address, the same identifier must be provided to the
|
||||||
``--libraries`` option on the command line.
|
``--libraries`` option on the command-line.
|
||||||
|
|
||||||
For example this code
|
For example this code
|
||||||
|
|
||||||
@ -1076,12 +1076,12 @@ or even opcodes unknown to the Solidity compiler, care has to be taken
|
|||||||
when using ``verbatim`` together with the optimizer. Even when the
|
when using ``verbatim`` together with the optimizer. Even when the
|
||||||
optimizer is switched off, the code generator has to determine
|
optimizer is switched off, the code generator has to determine
|
||||||
the stack layout, which means that e.g. using ``verbatim`` to modify
|
the stack layout, which means that e.g. using ``verbatim`` to modify
|
||||||
the stack height can lead to undefined behaviour.
|
the stack height can lead to undefined behavior.
|
||||||
|
|
||||||
The following is a non-exhaustive list of restrictions on
|
The following is a non-exhaustive list of restrictions on
|
||||||
verbatim bytecode that are not checked by
|
verbatim bytecode that are not checked by
|
||||||
the compiler. Violations of these restrictions can result in
|
the compiler. Violations of these restrictions can result in
|
||||||
undefined behaviour.
|
undefined behavior.
|
||||||
|
|
||||||
- Control-flow should not jump into or out of verbatim blocks,
|
- Control-flow should not jump into or out of verbatim blocks,
|
||||||
but it can jump within the same verbatim block.
|
but it can jump within the same verbatim block.
|
||||||
|
@ -82,7 +82,7 @@ solc/solc <sol file> --optimize --ir-optimized --yul-optimizations <sequence>
|
|||||||
### How to choose good parameters
|
### How to choose good parameters
|
||||||
Choosing good parameters for a genetic algorithm is not a trivial task but phaser's defaults are generally enough to find a sequence that gives results comparable or better than one hand-crafted by an experienced developer for a given set of programs.
|
Choosing good parameters for a genetic algorithm is not a trivial task but phaser's defaults are generally enough to find a sequence that gives results comparable or better than one hand-crafted by an experienced developer for a given set of programs.
|
||||||
The difficult part is providing a fairly representative set of input files.
|
The difficult part is providing a fairly representative set of input files.
|
||||||
If the files you give don't need certain optimisations the tool will find sequences that don't use these optimisations and perform badly for programs that could benefit from them.
|
If the files you give do not need certain optimisations the tool will find sequences that do not use these optimisations and perform badly for programs that could benefit from them.
|
||||||
If all the provided files greatly benefit from a specific optimisation, the sequence may not work well for programs that do not.
|
If all the provided files greatly benefit from a specific optimisation, the sequence may not work well for programs that do not.
|
||||||
|
|
||||||
We have conducted [a set of rough experiments](https://github.com/ethereum/solidity/issues/7806#issuecomment-598644491) to evaluate some combinations of parameter values.
|
We have conducted [a set of rough experiments](https://github.com/ethereum/solidity/issues/7806#issuecomment-598644491) to evaluate some combinations of parameter values.
|
||||||
@ -91,5 +91,5 @@ The conclusions were used to adjust the defaults but you might still benefit fro
|
|||||||
1. The algorithm that performed the best was `GEWEP`.
|
1. The algorithm that performed the best was `GEWEP`.
|
||||||
2. Using longer sequences in the initial population yields better results. The algorithm is good at removing superfluous steps.
|
2. Using longer sequences in the initial population yields better results. The algorithm is good at removing superfluous steps.
|
||||||
3. Preserving the top sequences from previous rounds improves results. Elite should contain at least a few individuals, especially when using the `classic` algorithm.
|
3. Preserving the top sequences from previous rounds improves results. Elite should contain at least a few individuals, especially when using the `classic` algorithm.
|
||||||
4. Don't set mutation/deletion/addition chance too high. It makes results worse because it destroys the good patterns preserved by crossover. Values around 1-5% seem to work best.
|
4. Do not set mutation/deletion/addition chance too high. It makes results worse because it destroys the good patterns preserved by crossover. Values around 1-5% seem to work best.
|
||||||
5. Keep the algorithm running for 1000 rounds or more. It usually finds good sequences faster than that but it can shorten them significantly if you let it run longer. This is especially important when starting with long sequences.
|
5. Keep the algorithm running for 1000 rounds or more. It usually finds good sequences faster than that but it can shorten them significantly if you let it run longer. This is especially important when starting with long sequences.
|
||||||
|
Loading…
Reference in New Issue
Block a user