From de857c27f3f4c339414d642709c49d67be8ee05f Mon Sep 17 00:00:00 2001 From: "Luoh Ren-Shan (LCamel)" Date: Thu, 21 Jul 2022 20:55:45 +0800 Subject: [PATCH 001/109] Modify the metadata document. --- docs/metadata.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/metadata.rst b/docs/metadata.rst index 1220f7822b..590b281c40 100644 --- a/docs/metadata.rst +++ b/docs/metadata.rst @@ -21,9 +21,12 @@ the :ref:`Standard JSON Interface`. You have to publish the metadata file to IPFS, Swarm, or another service so that others can access it. You create the file by using the ``solc --metadata`` -command that generates a file called ``ContractName_meta.json``. It contains -IPFS and Swarm references to the source code, so you have to upload all source -files and the metadata file. +command together with the ``--output-dir`` parameter. Without the parameter, +it will only be written to standard out. +It contains IPFS and Swarm references to the source code, so you have to +upload all source files and the metadata file. For IPFS, The hash contained +in the CID returned by ``ipfs add`` (not the direct sha2-256 hash of the file) +shall match with the one contained in the bytecode. The metadata file has the following format. The example below is presented in a human-readable way. Properly formatted metadata should use quotes correctly, From 4d4a030a01aa2d82c488af8c8e290ea24b221682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?AN=20=E2=9D=A6?= <108299225+krakxn@users.noreply.github.com> Date: Tue, 26 Jul 2022 12:32:53 +0530 Subject: [PATCH 002/109] Minor grammar fixes --- docs/abi-spec.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 08c75fbec5..9164ae6a12 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -13,7 +13,7 @@ The Contract Application Binary Interface (ABI) is the standard way to interact from outside the blockchain and for contract-to-contract interaction. Data is encoded according to its type, as described in this specification. The encoding is not self describing and thus requires a schema in order to decode. -We assume the interface functions of a contract are strongly typed, known at compilation time and static. +We assume that the interface functions of a contract are strongly typed, known at compilation time and static. We assume that all contracts will have the interface definitions of any contracts they call available at compile-time. This specification does not address contracts whose interface is dynamic or otherwise known only at run-time. @@ -29,7 +29,7 @@ first (left, high-order in big-endian) four bytes of the Keccak-256 hash of the the function. The signature is defined as the canonical expression of the basic prototype without data location specifier, i.e. the function name with the parenthesised list of parameter types. Parameter types are split by a single -comma - no spaces are used. +comma — no spaces are used. .. note:: The return type of a function is not part of this signature. In @@ -133,7 +133,7 @@ The encoding is designed to have the following properties, which are especially previous version of the ABI, the number of reads scaled linearly with the total number of dynamic parameters in the worst case. -2. The data of a variable or array element is not interleaved with other data and it is +2. The data of a variable or an array element is not interleaved with other data and it is relocatable, i.e. it only uses relative "addresses". @@ -252,7 +252,7 @@ Given the contract: } -Thus for our ``Foo`` example if we wanted to call ``baz`` with the parameters ``69`` and +Thus, for our ``Foo`` example if we wanted to call ``baz`` with the parameters ``69`` and ``true``, we would pass 68 bytes total, which can be broken down into: - ``0xcdcd77c0``: the Method ID. This is derived as the first 4 bytes of the Keccak hash of @@ -597,7 +597,7 @@ Errors look as follows: .. note:: There can be multiple errors with the same name and even with identical signature - in the JSON array, for example if the errors originate from different + in the JSON array; for example, if the errors originate from different files in the smart contract or are referenced from another smart contract. For the ABI, only the name of the error itself is relevant and not where it is defined. @@ -646,7 +646,7 @@ would result in the JSON: Handling tuple types -------------------- -Despite that names are intentionally not part of the ABI encoding they do make a lot of sense to be included +Despite the fact that names are intentionally not part of the ABI encoding, they do make a lot of sense to be included in the JSON to enable displaying it to the end user. The structure is nested in the following way: An object with members ``name``, ``type`` and potentially ``components`` describes a typed variable. @@ -654,7 +654,7 @@ The canonical type is determined until a tuple type is reached and the string de to that point is stored in ``type`` prefix with the word ``tuple``, i.e. it will be ``tuple`` followed by a sequence of ``[]`` and ``[k]`` with integers ``k``. The components of the tuple are then stored in the member ``components``, -which is of array type and has the same structure as the top-level object except that +which is of an array type and has the same structure as the top-level object except that ``indexed`` is not allowed there. As an example, the code @@ -738,10 +738,10 @@ Strict Encoding Mode ==================== Strict encoding mode is the mode that leads to exactly the same encoding as defined in the formal specification above. -This means offsets have to be as small as possible while still not creating overlaps in the data areas and thus no gaps are +This means that offsets have to be as small as possible while still not creating overlaps in the data areas, and thus no gaps are allowed. -Usually, ABI decoders are written in a straightforward way just following offset pointers, but some decoders +Usually, ABI decoders are written in a straightforward way by just following offset pointers, but some decoders might enforce strict mode. The Solidity ABI decoder currently does not enforce strict mode, but the encoder always creates data in strict mode. @@ -777,7 +777,7 @@ More specifically: encoding of its elements **with** padding. - Dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded without their length field. -- The encoding of ``string`` or ``bytes`` does not apply padding at the end +- The encoding of ``string`` or ``bytes`` does not apply padding at the end, unless it is part of an array or struct (then it is padded to a multiple of 32 bytes). @@ -805,7 +805,7 @@ Encoding of Indexed Event Parameters ==================================== Indexed event parameters that are not value types, i.e. arrays and structs are not -stored directly but instead a keccak256-hash of an encoding is stored. This encoding +stored directly but instead a Keccak-256 hash of an encoding is stored. This encoding is defined as follows: - the encoding of a ``bytes`` and ``string`` value is just the string contents From 14f63cc7e804eab82d420b6d9ee8e86ff877bb96 Mon Sep 17 00:00:00 2001 From: LCamel Date: Wed, 3 Aug 2022 22:12:11 +0800 Subject: [PATCH 003/109] Update docs/metadata.rst Co-authored-by: Daniel Kirchner --- docs/metadata.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/metadata.rst b/docs/metadata.rst index 590b281c40..e92a7c0d58 100644 --- a/docs/metadata.rst +++ b/docs/metadata.rst @@ -22,9 +22,9 @@ the :ref:`Standard JSON Interface`. You have to publish the metadata file to IPFS, Swarm, or another service so that others can access it. You create the file by using the ``solc --metadata`` command together with the ``--output-dir`` parameter. Without the parameter, -it will only be written to standard out. -It contains IPFS and Swarm references to the source code, so you have to -upload all source files and the metadata file. For IPFS, The hash contained +the metadata will be written to standard output. +The metadata contains IPFS and Swarm references to the source code, so you have to +upload all source files in addition to the metadata file. For IPFS, the hash contained in the CID returned by ``ipfs add`` (not the direct sha2-256 hash of the file) shall match with the one contained in the bytecode. From d7531b716fc09080cdee02098a53968e0d165dd4 Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Mon, 8 Aug 2022 12:38:56 +0200 Subject: [PATCH 004/109] Tidy up and update .gitignore --- .gitignore | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 0ec3f7ace8..f91c0207f5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,13 @@ -commit_hash.txt -prerelease.txt +/commit_hash.txt +/prerelease.txt # Compiled Object files *.slo *.lo *.o *.obj +*.pyc +__pycache__ # Precompiled Headers *.gch @@ -16,9 +18,6 @@ prerelease.txt *.dylib *.dll -# Fortran module files -*.mod - # Compiled Static libraries *.lai *.la @@ -33,14 +32,9 @@ prerelease.txt # Build directory /build* emscripten_build/ -docs/_build -docs/_static/robots.txt -__pycache__ -docs/utils/*.pyc -/deps/downloads/ -deps/install -deps/cache -cmake-build-*/ +/docs/_build +/docs/_static/robots.txt +/deps # vim stuff [._]*.sw[a-p] @@ -50,18 +44,15 @@ cmake-build-*/ *~ # IDE files -.idea -.vscode -browse.VC.db -CMakeLists.txt.user +/.idea/ +/.vscode/ +/browse.VC.db +/CMakeLists.txt.user /CMakeSettings.json /.vs /.cproject /.project -# place to put local temporary files -tmp - # OS specific local files .DS_Store Thumbs.db From cc11c6f3d55ca01a350b0874d3f92584f8f773b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 15:24:48 +0200 Subject: [PATCH 005/109] Set version to 0.8.17 --- CMakeLists.txt | 2 +- Changelog.md | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0662d118b9..2aca61d300 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.8.16") +set(PROJECT_VERSION "0.8.17") # OSX target needed in order to support std::visit set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14") project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX) diff --git a/Changelog.md b/Changelog.md index f22e119c46..8468321e9f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,17 @@ +### 0.8.17 (unreleased) + +Important Bugfixes: + + +Language Features: + + +Compiler Features: + + +Bugfixes: + + ### 0.8.16 (2022-08-08) Important Bugfixes: From c1cbffc814348bd11cab356c5879749abd4f15a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 15:57:29 +0200 Subject: [PATCH 006/109] update_bugs_by_version: Use pathlib --- scripts/update_bugs_by_version.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/scripts/update_bugs_by_version.py b/scripts/update_bugs_by_version.py index d1577bfc11..56daf1513d 100755 --- a/scripts/update_bugs_by_version.py +++ b/scripts/update_bugs_by_version.py @@ -6,20 +6,20 @@ # This makes it possible to use this script as part of CI to check # that the list is up to date. -import os import json import re import sys +from pathlib import Path def comp(version_string): return [int(c) for c in version_string.split('.')] -path = os.path.dirname(os.path.realpath(__file__)) -with open(path + '/../docs/bugs.json', encoding='utf8') as bugsFile: - bugs = json.load(bugsFile) +root_path = Path(__file__).resolve().parent.parent + +bugs = json.loads((root_path / 'docs/bugs.json').read_text(encoding='utf8')) versions = {} -with open(path + '/../Changelog.md', encoding='utf8') as changelog: +with (root_path / 'Changelog.md').open(encoding='utf8') as changelog: for line in changelog: m = re.search(r'^### (\S+) \((\d+-\d+-\d+)\)$', line) if m: @@ -36,8 +36,6 @@ def comp(version_string): value['bugs'] += [bug['name']] new_contents = json.dumps(versions, sort_keys=True, indent=4, separators=(',', ': ')) -with open(path + '/../docs/bugs_by_version.json', 'r', encoding='utf8') as bugs_by_version: - old_contents = bugs_by_version.read() -with open(path + '/../docs/bugs_by_version.json', 'w', encoding='utf8') as bugs_by_version: - bugs_by_version.write(new_contents) +old_contents = (root_path / 'docs/bugs_by_version.json').read_text(encoding='utf8') +(root_path / 'docs/bugs_by_version.json').write_text(new_contents, encoding='utf8') sys.exit(old_contents != new_contents) From 8874627ddaa6dab89f3e0862cea70362e64fdd52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 16:19:06 +0200 Subject: [PATCH 007/109] update_bugs_by_version: Don't fail when the list gets updated --- scripts/update_bugs_by_version.py | 11 ++++++----- test/cmdlineTests.sh | 11 ++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/update_bugs_by_version.py b/scripts/update_bugs_by_version.py index 56daf1513d..442cd0fdcd 100755 --- a/scripts/update_bugs_by_version.py +++ b/scripts/update_bugs_by_version.py @@ -8,7 +8,6 @@ import json import re -import sys from pathlib import Path def comp(version_string): @@ -35,7 +34,9 @@ def comp(version_string): continue value['bugs'] += [bug['name']] -new_contents = json.dumps(versions, sort_keys=True, indent=4, separators=(',', ': ')) -old_contents = (root_path / 'docs/bugs_by_version.json').read_text(encoding='utf8') -(root_path / 'docs/bugs_by_version.json').write_text(new_contents, encoding='utf8') -sys.exit(old_contents != new_contents) +(root_path / 'docs/bugs_by_version.json').write_text(json.dumps( + versions, + sort_keys=True, + indent=4, + separators=(',', ': ') +), encoding='utf8') diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 250d10a6ef..79e9d64a58 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -355,7 +355,7 @@ function test_via_ir_equivalence() for yul_file in $(find . -name "${output_file_prefix}*.yul" | sort -V); do bin_output_two_stage+=$( - msg_on_error --no-stderr "$SOLC" --strict-assembly --bin "${optimizer_flags[@]}" "$yul_file" | + msg_on_error --no-stderr "$SOLC" --strict-assembly --bin "${optimizer_flags[@]}" "$yul_file" | sed '/^Binary representation:$/d' | sed '/^=======/d' ) @@ -375,8 +375,13 @@ function test_via_ir_equivalence() ## RUN -echo "Checking that the bug list is up to date..." -"$REPO_ROOT"/scripts/update_bugs_by_version.py +SOLTMPDIR=$(mktemp -d) +printTask "Checking that the bug list is up to date..." +cp "${REPO_ROOT}/docs/bugs_by_version.json" "${SOLTMPDIR}/original_bugs_by_version.json" +"${REPO_ROOT}/scripts/update_bugs_by_version.py" +diff --unified "${SOLTMPDIR}/original_bugs_by_version.json" "${REPO_ROOT}/docs/bugs_by_version.json" || \ + fail "The bug list in bugs_by_version.json was out of date and has been updated. Please investigate and submit a bugfix if necessary." +rm -r "$SOLTMPDIR" printTask "Testing unknown options..." ( From c2d4e03c55bea39d338e98c904c1c2fb8161e2eb Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 8 Aug 2022 17:40:32 +0200 Subject: [PATCH 008/109] Add blog post link to bug list. --- docs/bugs.json | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/bugs.json b/docs/bugs.json index bdea0a7c2c..421bb007c0 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -4,6 +4,7 @@ "name": "AbiReencodingHeadOverflowWithStaticArrayCleanup", "summary": "ABI-encoding a tuple with a statically-sized calldata array in the last component would corrupt 32 leading bytes of its first dynamically encoded component.", "description": "When ABI-encoding a statically-sized calldata array, the compiler always pads the data area to a multiple of 32-bytes and ensures that the padding bytes are zeroed. In some cases, this cleanup used to be performed by always writing exactly 32 bytes, regardless of how many needed to be zeroed. This was done with the assumption that the data that would eventually occupy the area past the end of the array had not yet been written, because the encoder processes tuple components in the order they were given. While this assumption is mostly true, there is an important corner case: dynamically encoded tuple components are stored separately from the statically-sized ones in an area called the *tail* of the encoding and the tail immediately follows the *head*, which is where the statically-sized components are placed. The aforementioned cleanup, if performed for the last component of the head would cross into the tail and overwrite up to 32 bytes of the first component stored there with zeros. The only array type for which the cleanup could actually result in an overwrite were arrays with ``uint256`` or ``bytes32`` as the base element type and in this case the size of the corrupted area was always exactly 32 bytes. The problem affected tuples at any nesting level. This included also structs, which are encoded as tuples in the ABI. Note also that lists of parameters and return values of functions, events and errors are encoded as tuples.", + "link": "https://blog.soliditylang.org/2022/08/08/calldata-tuple-reencoding-head-overflow-bug/", "introduced": "0.5.8", "fixed": "0.8.16", "severity": "medium", From 9a429e23007a35da3177b540035314844f9c6cc5 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Tue, 9 Aug 2022 12:40:00 +0200 Subject: [PATCH 009/109] Fix ICE on invalid tuple assignments. --- Changelog.md | 1 + libsolidity/analysis/TypeChecker.cpp | 9 ++++++++- .../tuple_to_function_assignment.sol | 17 +++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/libsolidity/syntaxTests/tupleAssignments/tuple_to_function_assignment.sol diff --git a/Changelog.md b/Changelog.md index 8468321e9f..18066a7751 100644 --- a/Changelog.md +++ b/Changelog.md @@ -10,6 +10,7 @@ Compiler Features: Bugfixes: + * Type Checker: Fix internal compiler error on tuple assignments with invalid left-hand side. ### 0.8.16 (2022-08-08) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 5b64bcea8b..de3cdc847b 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -166,8 +166,15 @@ void TypeChecker::checkDoubleStorageAssignment(Assignment const& _assignment) ); } }; + + TupleExpression const* lhsTupleExpression = dynamic_cast(&_assignment.leftHandSide()); + if (!lhsTupleExpression) + { + solAssert(m_errorReporter.hasErrors()); + return; + } count( - dynamic_cast(_assignment.leftHandSide()), + *lhsTupleExpression, dynamic_cast(*type(_assignment.rightHandSide())), count ); diff --git a/test/libsolidity/syntaxTests/tupleAssignments/tuple_to_function_assignment.sol b/test/libsolidity/syntaxTests/tupleAssignments/tuple_to_function_assignment.sol new file mode 100644 index 0000000000..898c791015 --- /dev/null +++ b/test/libsolidity/syntaxTests/tupleAssignments/tuple_to_function_assignment.sol @@ -0,0 +1,17 @@ +contract C { + function f() internal pure {} + function g() internal pure returns (uint256) {} + function h() internal pure returns (uint256, uint256) {} + function test() public pure { + f() = (); + g() = (uint256(1)); + h() = (uint256(1), uint256(2)); + h() = (); + } +} +// ---- +// TypeError 4247: (184-187): Expression has to be an lvalue. +// TypeError 4247: (196-199): Expression has to be an lvalue. +// TypeError 4247: (218-221): Expression has to be an lvalue. +// TypeError 4247: (252-255): Expression has to be an lvalue. +// TypeError 7407: (258-260): Type tuple() is not implicitly convertible to expected type tuple(uint256,uint256). From 6439955e834b1a1b6ae5f4a9aba857e04e4fefea Mon Sep 17 00:00:00 2001 From: Pranay Date: Wed, 10 Aug 2022 13:54:02 +0530 Subject: [PATCH 010/109] Update the default free memory pointer in Yul.rst The solidity docs and [Inline assembly memory management](https://docs.soliditylang.org/en/v0.8.15/assembly.html#memory-management) suggest the actual allocate-able memory starts from `0x80`. The above yul example defaults the free memory pointer to `0x60` in initialisation cases. --- docs/yul.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/yul.rst b/docs/yul.rst index d920f21240..6156d9ad67 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -1162,7 +1162,7 @@ An example Yul Object is shown below: code { function allocate(size) -> ptr { ptr := mload(0x40) - if iszero(ptr) { ptr := 0x60 } + if iszero(ptr) { ptr := 0x80 } mstore(0x40, add(ptr, size)) } From 664b7bfbdabef0391fd490618e38ed5c45108621 Mon Sep 17 00:00:00 2001 From: Roman Figurin Date: Mon, 11 Jul 2022 22:28:10 +0800 Subject: [PATCH 011/109] [Docs] Fixed link to internal-function-calls --- docs/contracts/functions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index eebd1d45a8..94a427d72d 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -79,7 +79,7 @@ Function parameters can be used as any other local variable and they can also be parameter. This functionality is possible if you enable the ABI coder v2 by adding ``pragma abicoder v2;`` to your source file. - An :ref:`internal function` can accept a + An :ref:`internal function` can accept a multi-dimensional array without enabling the feature. .. index:: return array, return string, array, string, array of strings, dynamic array, variably sized array, return struct, struct From bbf6ecf69dbd3fa8e93aad89fca15b3610cc091e Mon Sep 17 00:00:00 2001 From: Roman Figurin Date: Wed, 13 Jul 2022 09:29:14 +0800 Subject: [PATCH 012/109] [Docs] Updated a part about abicoder v2 and multi-dimensional array for external-function-calls --- docs/contracts/functions.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index 94a427d72d..c7b7cc56b5 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -74,13 +74,13 @@ Function parameters can be used as any other local variable and they can also be .. note:: - An :ref:`external function` cannot accept a - multi-dimensional array as an input - parameter. This functionality is possible if you enable the ABI coder v2 - by adding ``pragma abicoder v2;`` to your source file. + Until version 0.6.0 it was not possible to use a multi-dimensional array or a struct + as an input for an :ref:`external function`. + ``abicoder v2`` made it possible and it's been enabled by default since version 0.8.0 + (before that you had to enable it with ``pragma abicoder v2;``). An :ref:`internal function` can accept a - multi-dimensional array without enabling the feature. + multi-dimensional array or a struct without any restrictions. .. index:: return array, return string, array, string, array of strings, dynamic array, variably sized array, return struct, struct From 213f951dbb2a855366f27dd258b6b07f078ca945 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 10 Aug 2022 16:50:42 +0200 Subject: [PATCH 013/109] Make gas diff stats script executable. --- scripts/gas_diff_stats.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/gas_diff_stats.py diff --git a/scripts/gas_diff_stats.py b/scripts/gas_diff_stats.py old mode 100644 new mode 100755 From d066dd2bc0677e4b371471ede7f8ba034e36d21e Mon Sep 17 00:00:00 2001 From: wechman Date: Fri, 22 Jul 2022 10:16:04 +0200 Subject: [PATCH 014/109] Calldata validation tests --- .../calldata_dynamic_array_to_memory.sol | 27 ++++++++ .../calldata_nested_array_reencode.sol | 45 ++++++++---- .../calldata_overlapped_dynamic_arrays.sol | 43 ++++++++++++ ...ldata_overlapped_nested_dynamic_arrays.sol | 37 ++++++++++ .../calldata_struct_array_reencode.sol | 56 +++++++++++++++ ...dimensional_dynamic_array_index_access.sol | 42 +++++++++++ .../abiEncoderV2/calldata_with_garbage.sol | 69 +++++++++++++++++++ 7 files changed, 304 insertions(+), 15 deletions(-) create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol create mode 100644 test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol new file mode 100644 index 0000000000..6bc20432db --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol @@ -0,0 +1,27 @@ +pragma abicoder v2; + +contract C { + function f(uint[][] calldata a) public returns (uint[][] memory) { + return a; + } + + function g(uint[][][] calldata a) public returns (uint[][][] memory) { + return a; + } + + function h(uint[2][][] calldata a) public returns (uint[2][][] memory) { + return a; + } +} + +// ==== +// compileViaYul: also +// ---- +// f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 -> 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 +// f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8, 9 -> 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 +// f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8 -> FAILURE +// g(uint256[][][]): 0x20, 2, 0x40, 0x60, 0, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 -> 0x20, 2, 0x40, 0x60, 0, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 +// g(uint256[][][]): 0x20, 2, 0x40, 0x60, 0, 2, 0x40, 0xa0, 2, 5, 6, 2, 7 -> FAILURE +// h(uint256[2][][]): 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8 -> 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8 +// h(uint256[2][][]): 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8, 9 -> 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7, 8 +// h(uint256[2][][]): 0x20, 2, 0x40, 0x60, 0, 2, 5, 6, 7 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol index 0872a7f5d5..f62f105c8f 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol @@ -1,22 +1,37 @@ pragma abicoder v2; contract C { - function h(uint[][] calldata a) public { - abi.encode(a); - } - struct S { uint[] x; } - function f(S calldata a) public { - abi.encode(a); - } + function f(uint[][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function g(uint8[][][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function h(uint16[][2][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function i(uint16[][][1] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + function j(uint16[2][][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } } // ==== // revertStrings: debug +// compileViaYul: also // ---- -// h(uint256[][]): 0x20, 1, 0x20, 0 -> -// h(uint256[][]): 0x20, 1, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// h(uint256[][]): 0x20, 1, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// h(uint256[][]): 0x20, 1, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// f((uint256[])): 0x20, 0x20, 0 -> -// f((uint256[])): 0x20, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// f((uint256[])): 0x20, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" -// f((uint256[])): 0x20, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f(uint256[][]): 0x20, 1, 0x20, 0 -> 0x20, 0x80, 0x20, 1, 0x20, 0 +// f(uint256[][]): 0x20, 1, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f(uint256[][]): 0x20, 1, 0x20, 2 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// f(uint256[][]): 0x20, 1, 0x20, 3 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 0 -> 0x20, 0x01a0, 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 0 +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access offset" +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0 -> 0x20, 0x01e0, 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0 +// g(uint8[][][]): 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0, 1 -> 0x20, 0x01e0, 0x20, 2, 0x40, 0x0140, 2, 0x40, 0x80, 1, 10, 2, 11, 12, 1, 0x20, 0 +// h(uint16[][2][]): 0x20, 2, 0x40, 0x0120, 0x40, 0x80, 1, 10, 2, 11, 12, 0x40, 0x60, 0, 1, 13 -> 0x20, 0x0200, 0x20, 2, 0x40, 288, 0x40, 0x80, 1, 10, 2, 11, 12, 0x40, 0x60, 0, 1, 13 +// h(uint16[][2][]): 0x20, 2, 0x40, 0x0120, 0x40, 0x80, 1, 10, 2, 11, 12, 0x40, 0x60, 0, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// i(uint16[][][1]): 0x20, 0x20, 2, 0x40, 0x80, 1, 10, 2, 11, 12 -> 0x20, 0x0140, 0x20, 0x20, 2, 0x40, 0x80, 1, 10, 2, 11, 12 +// i(uint16[][][1]): 0x20, 0x20, 2, 0x40, 0x80, 1, 10, 2, 11 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" +// j(uint16[2][][]): 0x20, 2, 0x40, 0xa0, 1, 0x0a, 11, 2, 12, 13, 14, 15 -> 0x20, 0x0180, 0x20, 2, 0x40, 0xa0, 1, 10, 11, 2, 12, 13, 14, 15 +// j(uint16[2][][]): 0x20, 2, 0x40, 0xa0, 1, 0x0a, 11, 2, 12, 13, 14 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol new file mode 100644 index 0000000000..7d197fcb58 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol @@ -0,0 +1,43 @@ +pragma abicoder v2; + +contract C { + uint[] s; + uint[2] n; + + function f_memory(uint[] calldata a, uint[2] calldata b) public returns (uint[] memory, uint[2] memory) { + return (a, b); + } + + function f_encode(uint[] calldata a, uint[2] calldata b) public returns (bytes memory) { + return abi.encode(a, b); + } + + function f_which(uint[] calldata a, uint[2] calldata b, uint which) public returns (bytes memory) { + return abi.encode(a[which], b[1]); + } + + function f_storage(uint[] calldata a, uint[2] calldata b ) public returns (bytes memory) { + s = a; + n = b; + return abi.encode(s); + } +} + +// ==== +// compileViaYul: also +// ---- +// f_memory(uint256[],uint256[2]): 0x20, 1, 2 -> 0x60, 0x01, 0x02, 1, 2 +// f_memory(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x60, 1, 2, 2, 5, 6 +// f_memory(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE +// f_encode(uint256[],uint256[2]): 0x20, 1, 2 -> 0x20, 0xa0, 0x60, 1, 2, 1, 2 +// f_encode(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x20, 0xc0, 0x60, 1, 2, 2, 5, 6 +// f_encode(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE +// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1, 5 -> 0x20, 0x40, 5, 2 +// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1, 5, 6 -> 0x20, 0x40, 5, 2 +// f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1 -> FAILURE +// f_storage(uint256[],uint256[2]): 0x20, 1, 2 -> 0x20, 0x60, 0x20, 1, 2 +// gas irOptimized: 111653 +// gas legacy: 112987 +// gas legacyOptimized: 112104 +// f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x20, 0x80, 0x20, 2, 5, 6 +// f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol new file mode 100644 index 0000000000..6ec079a818 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol @@ -0,0 +1,37 @@ +pragma abicoder v2; + +contract C { + uint[] s; + uint[2] n; + + function f_memory(uint[][] calldata a) public returns (uint[][] memory) { + return a; + } + + function f_encode(uint[][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function f_which(uint[][] calldata a, uint which) public returns (uint[] memory) { + return a[which]; + } +} + +// ==== +// compileViaYul: also +// ---- +// f_memory(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 2, 0x40, 0xa0, 2, 1, 2, 2, 1, 2 +// f_memory(uint256[][]): 0x20, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 2, 0x40, 0xa0, 2, 1, 2, 1, 2 +// f_memory(uint256[][]): 0x20, 2, 0, 0x60, 2, 1, 2 -> 0x20, 2, 0x40, 0x60, 0, 1, 2 +// f_memory(uint256[][]): 0x20, 2, 0, 0x60, 2, 2, 2 -> FAILURE +// f_encode(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 0x0140, 0x20, 2, 0x40, 0xa0, 2, 1, 2, 2, 1, 2 +// f_encode(uint256[][]): 0x20, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 0x0120, 0x20, 2, 0x40, 0xa0, 2, 1, 2, 1, 2 +// f_encode(uint256[][]): 0x20, 2, 0, 0x60, 2, 1, 2 -> 0x20, 0xe0, 0x20, 2, 0x40, 0x60, 0, 1, 2 +// f_encode(uint256[][]): 0x20, 2, 0, 0x60, 2, 2, 2 -> FAILURE +// f_which(uint256[][],uint256): 0x40, 0, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 2, 1, 2 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 2, 1, 2 +// f_which(uint256[][],uint256): 0x40, 0, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 2, 1, 2 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 1, 2 +// f_which(uint256[][],uint256): 0x40, 0, 2, 0, 0x60, 2, 1, 2 -> 0x20, 0 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0, 0x60, 2, 1, 2 -> 0x20, 1, 2 +// f_which(uint256[][],uint256): 0x40, 1, 2, 0, 0x60, 2, 2, 2 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol new file mode 100644 index 0000000000..17f0e1f84d --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol @@ -0,0 +1,56 @@ +pragma abicoder v2; + +contract C { + struct D { uint[] x; } + struct S { uint x; } + + function f(D calldata a) public returns (bytes memory){ + return abi.encode(a); + } + + function g(D[2] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function h(D[][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function i(D[2][] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function j(S[] memory a) public returns (bytes memory) { + return abi.encode(a); + } + + function k(S[2] memory a) public returns (bytes memory) { + return abi.encode(a); + } + + function l(S[][] memory a) public returns (bytes memory) { + return abi.encode(a); + } + +} + +// ==== +// compileViaYul: also +// ---- +// f((uint256[])): 0x20, 0x20, 0 -> 0x20, 0x60, 0x20, 0x20, 0 +// f((uint256[])): 0x20, 0x20, 1 -> FAILURE +// f((uint256[])): 0x20, 0x20, 2 -> FAILURE +// f((uint256[])): 0x20, 0x20, 3 -> FAILURE +// g((uint256[])[2]): 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 -> 0x20, 0x0140, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 +// g((uint256[])[2]): 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1 -> FAILURE +// h((uint256[])[][]): 0x20, 0x02, 0x40, 0x0180, 2, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3, 1, 0x20, 0x20, 1, 1 -> 0x20, 0x0260, 0x20, 2, 0x40, 0x0180, 2, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3, 1, 0x20, 0x20, 1, 1 +// h((uint256[])[][]): 0x20, 0x02, 0x40, 0x0180, 2, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3, 1, 0x20, 0x20, 1 -> FAILURE +// i((uint256[])[2][]): 0x20, 1, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 -> 0x20, 0x0180, 0x20, 1, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1, 3 +// i((uint256[])[2][]): 0x20, 1, 0x20, 0x40, 0xc0, 0x20, 2, 1, 2, 0x20, 1 -> FAILURE +// j((uint256)[]): 0x20, 2, 1, 2 -> 0x20, 0x80, 0x20, 2, 1, 2 +// j((uint256)[]): 0x20, 2, 1 -> FAILURE +// k((uint256)[2]): 1, 2 -> 0x20, 0x40, 1, 2 +// k((uint256)[2]): 1 -> FAILURE +// l((uint256)[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9 -> 0x20, 0x0160, 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9 +// l((uint256)[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9, 10 -> 0x20, 0x0160, 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8, 9 +// l((uint256)[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 3, 7, 8 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol new file mode 100644 index 0000000000..073bb25e28 --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol @@ -0,0 +1,42 @@ +pragma abicoder v2; + +contract C { + struct S { uint[] a; } + + function f(uint[][] calldata s, uint i, uint j) public pure returns (bytes memory) { + return abi.encode(s[i][j]); + } + + function g(uint[][][] calldata s, uint i, uint j, uint k) public pure returns (bytes memory) { + return abi.encode(s[i][j][k]); + } + + function h(uint[][][1] calldata s, uint i) public pure returns (bytes memory) { + return abi.encode(s[0][i]); + } + + function k(S[][] calldata s, uint i, uint j) public pure returns (bytes memory) { + return abi.encode(s[i][j].a); + } + + function l(S[2][2] calldata s, uint i, uint j) public pure returns (bytes memory) { + return abi.encode(s[i][j].a); + } +} + +// ==== +// compileViaYul: also +// revertStrings: debug +// ---- +// f(uint256[][],uint256,uint256): 0x60, 0, 0, 2, 0x40, 0x80, 1, 7, 1, 8 -> 0x20, 0x20, 7 +// f(uint256[][],uint256,uint256): 0x60, 1, 0, 2, 0x40, 0x80, 1, 7, 1, 8 -> 0x20, 0x20, 8 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 0, 0, 0, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> 0x20, 0x20, 4 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 1, 0, 1, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> 0x20, 0x20, 6 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 1, 0, 2, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> FAILURE, hex"4e487b71", 0x32 +// g(uint256[][][],uint256,uint256,uint256): 0x80, 2, 0, 1, 2, 0x40, 0xc0, 1, 0x20, 1, 4, 2, 0x40, 0xa0, 2, 5, 6, 1, 7 -> FAILURE, hex"4e487b71", 0x32 +// h(uint256[][][1],uint256): 0x40, 1, 0x20, 2, 0x40, 0xA0, 2, 5, 6, 3, 7, 8, 9 -> 0x20, 0xa0, 0x20, 3, 7, 8, 9 +// h(uint256[][][1],uint256): 0x40, 2, 0x20, 2, 0x40, 0xA0, 2, 5, 6, 3, 7, 8, 9 -> FAILURE, hex"4e487b71", 0x32 +// k((uint256[])[][],uint256,uint256): 0x60, 0, 0, 2, 0x40, 0xe0, 1, 0x20, 0x20, 1, 6, 2, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> 0x20, 0x60, 0x20, 1, 6 +// k((uint256[])[][],uint256,uint256): 0x60, 0, 1, 2, 0x40, 0xe0, 1, 0x20, 0x20, 1, 6, 2, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> FAILURE, hex"4e487b71", 0x32 +// l((uint256[])[2][2],uint256,uint256): 0x60, 1, 1, 0x40, 0x0140, 0x40, 0xa0, 0x20, 1, 5, 0x20, 1, 6, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> 0x20, 0x80, 0x20, 2, 8, 9 +// l((uint256[])[2][2],uint256,uint256): 0x60, 1, 2, 0x40, 0x0140, 0x40, 0xa0, 0x20, 1, 5, 0x20, 1, 6, 0x40, 0xa0, 0x20, 1, 7, 0x20, 2, 8, 9 -> FAILURE, hex"4e487b71", 0x32 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol new file mode 100644 index 0000000000..ef5ece3f0a --- /dev/null +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol @@ -0,0 +1,69 @@ +pragma abicoder v2; + +contract C { + uint[] aTmp; + uint[2] bTmp; + + function f_memory(uint[] calldata a) public returns (uint[] memory) { + return a; + } + + function f_encode(uint[] calldata a) public returns (bytes memory) { + return abi.encode(a); + } + + function f_storage(uint[] calldata a) public returns (bytes memory) { + aTmp = a; + return abi.encode(aTmp); + } + + function f_index(uint[] calldata a, uint which) public returns (uint) { + return a[which]; + } + + function g_memory(uint[] calldata a, uint[2] calldata b) public returns (uint[] memory, uint[2] memory) { + return (a, b); + } + + function g_encode(uint[] calldata a, uint[2] calldata b) public returns (bytes memory) { + return abi.encode(a, b); + } + + function g_storage(uint[] calldata a, uint[2] calldata b) public returns (bytes memory) { + aTmp = a; + bTmp = b; + return abi.encode(aTmp, bTmp); + } + + function g_index(uint[] calldata a, uint[2] calldata b, uint which) public returns (uint, uint) { + return (a[which], b[0]); + } +} + +// ==== +// compileViaYul: also +// ---- +// f_memory(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0 +// f_memory(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 1, 7 +// f_memory(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE +// f_encode(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0x40, 0x20, 0 +// f_encode(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 0x60, 0x20, 1, 7 +// f_encode(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE +// f_storage(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0x40, 0x20, 0 +// f_storage(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 0x60, 0x20, 1, 7 +// f_storage(uint256[]): 0x80, 9, 9, 9, 2, 7 -> FAILURE +// f_index(uint256[],uint256): 0xa0, 0, 9, 9, 9, 2, 7, 8 -> 7 +// f_index(uint256[],uint256): 0xa0, 1, 9, 9, 9, 2, 7, 8 -> 8 +// f_index(uint256[],uint256): 0xa0, 2, 9, 9, 9, 2, 7, 8 -> FAILURE, hex"4e487b71", 0x32 +// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x60, 1, 2, 0 +// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x60, 1, 2, 1, 7 +// g_memory(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE +// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x20, 0x80, 0x60, 1, 2, 0 +// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x20, 0xa0, 0x60, 1, 2, 1, 7 +// g_encode(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE +// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 0 -> 0x20, 0x80, 0x60, 1, 2, 0 +// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 1, 7 -> 0x20, 0xa0, 0x60, 1, 2, 1, 7 +// g_storage(uint256[],uint256[2]): 0xc0, 1, 2, 9, 9, 9, 2, 7 -> FAILURE +// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 0, 9, 9, 9, 2, 7, 8 -> 7, 1 +// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 1, 9, 9, 9, 2, 7, 8 -> 8, 1 +// g_index(uint256[],uint256[2],uint256): 0xe0, 1, 2, 1, 9, 9, 9, 2, 7 -> FAILURE From 123a4107959df322d333ce957c54b61aa2b8cd02 Mon Sep 17 00:00:00 2001 From: wechman Date: Wed, 10 Aug 2022 13:06:17 +0200 Subject: [PATCH 015/109] fixup! Calldata validation tests --- .../abiEncoderV2/calldata_overlapped_dynamic_arrays.sol | 4 ++-- .../calldata_overlapped_nested_dynamic_arrays.sol | 6 +++--- .../semanticTests/abiEncoderV2/calldata_with_garbage.sol | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol index 7d197fcb58..d8bca264be 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol @@ -13,13 +13,13 @@ contract C { } function f_which(uint[] calldata a, uint[2] calldata b, uint which) public returns (bytes memory) { - return abi.encode(a[which], b[1]); + return abi.encode(a[which], b[1]); } function f_storage(uint[] calldata a, uint[2] calldata b ) public returns (bytes memory) { s = a; n = b; - return abi.encode(s); + return abi.encode(s); } } diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol index 6ec079a818..6dd4920299 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol @@ -5,15 +5,15 @@ contract C { uint[2] n; function f_memory(uint[][] calldata a) public returns (uint[][] memory) { - return a; + return a; } function f_encode(uint[][] calldata a) public returns (bytes memory) { - return abi.encode(a); + return abi.encode(a); } function f_which(uint[][] calldata a, uint which) public returns (uint[] memory) { - return a[which]; + return a[which]; } } diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol index ef5ece3f0a..1bc887c7dd 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol @@ -5,11 +5,11 @@ contract C { uint[2] bTmp; function f_memory(uint[] calldata a) public returns (uint[] memory) { - return a; + return a; } function f_encode(uint[] calldata a) public returns (bytes memory) { - return abi.encode(a); + return abi.encode(a); } function f_storage(uint[] calldata a) public returns (bytes memory) { From 60e7e4a24c25b222b3376386cc549a2f72097fb4 Mon Sep 17 00:00:00 2001 From: wechman Date: Wed, 10 Aug 2022 13:26:18 +0200 Subject: [PATCH 016/109] fixup! Calldata validation tests --- .../abiEncoderV2/calldata_dynamic_array_to_memory.sol | 2 -- .../abiEncoderV2/calldata_nested_array_reencode.sol | 1 - .../abiEncoderV2/calldata_overlapped_dynamic_arrays.sol | 2 -- .../abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol | 2 -- .../abiEncoderV2/calldata_struct_array_reencode.sol | 2 -- .../calldata_three_dimensional_dynamic_array_index_access.sol | 1 - .../semanticTests/abiEncoderV2/calldata_with_garbage.sol | 2 -- 7 files changed, 12 deletions(-) diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol index 6bc20432db..f044d6f05a 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_dynamic_array_to_memory.sol @@ -14,8 +14,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 -> 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 // f(uint256[][]): 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8, 9 -> 0x20, 2, 0x40, 0xa0, 2, 5, 6, 2, 7, 8 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol index f62f105c8f..96573fb4ba 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_nested_array_reencode.sol @@ -19,7 +19,6 @@ contract C { } // ==== // revertStrings: debug -// compileViaYul: also // ---- // f(uint256[][]): 0x20, 1, 0x20, 0 -> 0x20, 0x80, 0x20, 1, 0x20, 0 // f(uint256[][]): 0x20, 1, 0x20, 1 -> FAILURE, hex"08c379a0", 0x20, 0x1e, "Invalid calldata access stride" diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol index d8bca264be..3b829d82cb 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol @@ -23,8 +23,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f_memory(uint256[],uint256[2]): 0x20, 1, 2 -> 0x60, 0x01, 0x02, 1, 2 // f_memory(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x60, 1, 2, 2, 5, 6 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol index 6dd4920299..f7ed9daf45 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_nested_dynamic_arrays.sol @@ -17,8 +17,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f_memory(uint256[][]): 0x20, 2, 0x40, 0x40, 2, 1, 2 -> 0x20, 2, 0x40, 0xa0, 2, 1, 2, 2, 1, 2 // f_memory(uint256[][]): 0x20, 2, 0x40, 0x60, 2, 1, 2 -> 0x20, 2, 0x40, 0xa0, 2, 1, 2, 1, 2 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol index 17f0e1f84d..d456cdfcc2 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_struct_array_reencode.sol @@ -34,8 +34,6 @@ contract C { } -// ==== -// compileViaYul: also // ---- // f((uint256[])): 0x20, 0x20, 0 -> 0x20, 0x60, 0x20, 0x20, 0 // f((uint256[])): 0x20, 0x20, 1 -> FAILURE diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol index 073bb25e28..a97c4f6d8a 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_three_dimensional_dynamic_array_index_access.sol @@ -25,7 +25,6 @@ contract C { } // ==== -// compileViaYul: also // revertStrings: debug // ---- // f(uint256[][],uint256,uint256): 0x60, 0, 0, 2, 0x40, 0x80, 1, 7, 1, 8 -> 0x20, 0x20, 7 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol index 1bc887c7dd..b126928546 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_with_garbage.sol @@ -40,8 +40,6 @@ contract C { } } -// ==== -// compileViaYul: also // ---- // f_memory(uint256[]): 0x80, 9, 9, 9, 0 -> 0x20, 0 // f_memory(uint256[]): 0x80, 9, 9, 9, 1, 7 -> 0x20, 1, 7 From 99ac7e09bb37e50104fa21b7a7b38e491ff2fd57 Mon Sep 17 00:00:00 2001 From: wechman Date: Thu, 11 Aug 2022 07:55:10 +0200 Subject: [PATCH 017/109] fixup! Calldata validation tests --- .../abiEncoderV2/calldata_overlapped_dynamic_arrays.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol index 3b829d82cb..1ec1ca4c56 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/calldata_overlapped_dynamic_arrays.sol @@ -35,7 +35,7 @@ contract C { // f_which(uint256[],uint256[2],uint256): 0x40, 1, 2, 1 -> FAILURE // f_storage(uint256[],uint256[2]): 0x20, 1, 2 -> 0x20, 0x60, 0x20, 1, 2 // gas irOptimized: 111653 -// gas legacy: 112987 +// gas legacy: 112979 // gas legacyOptimized: 112104 // f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5, 6 -> 0x20, 0x80, 0x20, 2, 5, 6 // f_storage(uint256[],uint256[2]): 0x40, 1, 2, 5 -> FAILURE From 9290ccb9087fd8f1fddcf496061c197bb9d05db2 Mon Sep 17 00:00:00 2001 From: Yuvraj Singh Date: Fri, 8 Jul 2022 19:25:04 +0530 Subject: [PATCH 018/109] Added build flag to disable pedantic builds --- CMakeLists.txt | 4 +++ cmake/EthCompilerSettings.cmake | 56 +++++++++++++++++++-------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aca61d300..d8de3d1498 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,7 @@ endif() option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF) option(SOLC_STATIC_STDLIBS "Link solc against static versions of libgcc and libstdc++ on supported platforms" OFF) option(STRICT_Z3_VERSION "Use the latest version of Z3" ON) +option(PEDANTIC "Enable extra warnings and pedantic build flags. Treat all warnings as errors." ON) # Setup cccache. include(EthCcache) @@ -48,6 +49,9 @@ include_directories(SYSTEM ${JSONCPP_INCLUDE_DIR}) find_package(Threads) +if(NOT PEDANTIC) + message(WARNING "-- Pedantic build flags turned off. Warnings will not make compilation fail. This is NOT recommended in development builds.") +endif() # Figure out what compiler and system are we using include(EthCompilerSettings) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 0ddeb452a9..01eee4b984 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -23,7 +23,9 @@ if(NOT EMSCRIPTEN) endif() endif() -eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough) +if(PEDANTIC) + eth_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough) +endif() # Prevent the path of the source directory from ending up in the binary via __FILE__ macros. eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/solidity") @@ -32,39 +34,45 @@ eth_add_cxx_compiler_flag_if_supported("-fmacro-prefix-map=${CMAKE_SOURCE_DIR}=/ # if the argument was not wrapped in a call. This happens when moving a local # variable in a return statement when the variable is the same type as the # return type or using a move to create a new object from a temporary object. -eth_add_cxx_compiler_flag_if_supported(-Wpessimizing-move) +if(PEDANTIC) + eth_add_cxx_compiler_flag_if_supported(-Wpessimizing-move) +endif() # -Wredundant-move warns when an implicit move would already be made, so the # std::move call is not needed, such as when moving a local variable in a return # that is different from the return type. -eth_add_cxx_compiler_flag_if_supported(-Wredundant-move) +if(PEDANTIC) + eth_add_cxx_compiler_flag_if_supported(-Wredundant-move) +endif() if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) # Enables all the warnings about constructions that some users consider questionable, # and that are easy to avoid. Also enable some extra warning flags that are not # enabled by -Wall. Finally, treat at warnings-as-errors, which forces developers # to fix warnings as they arise, so they don't accumulate "to be fixed later". - add_compile_options(-Wall) - add_compile_options(-Wextra) - add_compile_options(-Werror) - add_compile_options(-pedantic) - add_compile_options(-Wmissing-declarations) - add_compile_options(-Wno-unknown-pragmas) - add_compile_options(-Wimplicit-fallthrough) - add_compile_options(-Wsign-conversion) - add_compile_options(-Wconversion) + if(PEDANTIC) + add_compile_options(-Wall) + add_compile_options(-Wextra) + add_compile_options(-Werror) + add_compile_options(-pedantic) + add_compile_options(-Wmissing-declarations) + add_compile_options(-Wno-unknown-pragmas) + add_compile_options(-Wimplicit-fallthrough) + add_compile_options(-Wsign-conversion) + add_compile_options(-Wconversion) - check_cxx_compiler_flag(-Wextra-semi WEXTRA_SEMI) - if(WEXTRA_SEMI) - add_compile_options($<$:-Wextra-semi>) + check_cxx_compiler_flag(-Wextra-semi WEXTRA_SEMI) + if(WEXTRA_SEMI) + add_compile_options($<$:-Wextra-semi>) + endif() + eth_add_cxx_compiler_flag_if_supported(-Wfinal-dtor-non-final-class) + eth_add_cxx_compiler_flag_if_supported(-Wnewline-eof) + eth_add_cxx_compiler_flag_if_supported(-Wsuggest-destructor-override) + eth_add_cxx_compiler_flag_if_supported(-Wduplicated-cond) + eth_add_cxx_compiler_flag_if_supported(-Wduplicate-enum) + eth_add_cxx_compiler_flag_if_supported(-Wlogical-op) + eth_add_cxx_compiler_flag_if_supported(-Wno-unknown-attributes) endif() - eth_add_cxx_compiler_flag_if_supported(-Wfinal-dtor-non-final-class) - eth_add_cxx_compiler_flag_if_supported(-Wnewline-eof) - eth_add_cxx_compiler_flag_if_supported(-Wsuggest-destructor-override) - eth_add_cxx_compiler_flag_if_supported(-Wduplicated-cond) - eth_add_cxx_compiler_flag_if_supported(-Wduplicate-enum) - eth_add_cxx_compiler_flag_if_supported(-Wlogical-op) - eth_add_cxx_compiler_flag_if_supported(-Wno-unknown-attributes) # Configuration-specific compiler settings. set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g3 -DETH_DEBUG") @@ -158,7 +166,9 @@ elseif (DEFINED MSVC) add_compile_options(/MP) # enable parallel compilation add_compile_options(/EHsc) # specify Exception Handling Model in msvc - add_compile_options(/WX) # enable warnings-as-errors + if(PEDANTIC) + add_compile_options(/WX) # enable warnings-as-errors + endif() add_compile_options(/wd4068) # disable unknown pragma warning (4068) add_compile_options(/wd4996) # disable unsafe function warning (4996) add_compile_options(/wd4503) # disable decorated name length exceeded, name was truncated (4503) From b7847c9f07869058215af2a79507414d3df1368a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 11 Aug 2022 15:35:38 +0200 Subject: [PATCH 019/109] installing-solidity.rst: Mention the PEDANTIC flag --- docs/installing-solidity.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst index 9d6e666d25..9a613d75d3 100644 --- a/docs/installing-solidity.rst +++ b/docs/installing-solidity.rst @@ -354,6 +354,17 @@ The following are dependencies for all builds of Solidity: If you do this, however, please remember to pass the ``--no-smt`` option to ``scripts/tests.sh`` to skip the SMT tests. +.. note:: + By default the build is performed in *pedantic mode*, which enables extra warnings and tells the + compiler to treat all warnings as errors. + This forces developers to fix warnings as they arise, so they do not accumulate "to be fixed later". + If you are only interested in creating a release build and do not intend to modify the source code + to deal with such warnings, you can pass ``-DPEDANTIC=OFF`` option to CMake to disable this mode. + Doing this is not recommended for general use but may be necessary when using a toolchain we are + not testing with or trying to build an older version with newer tools. + If you encounter such warnings, please consider + `reporting them `_. + Minimum Compiler Versions ^^^^^^^^^^^^^^^^^^^^^^^^^ From 351efae5f8bc1c7da978fa210e7e6cff8ab2ad7c Mon Sep 17 00:00:00 2001 From: Marenz Date: Tue, 9 Aug 2022 17:12:40 +0200 Subject: [PATCH 020/109] Little enhancements to the ppa release script --- .gitignore | 3 +++ scripts/release_ppa.sh | 53 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index f91c0207f5..4f17171816 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ /commit_hash.txt /prerelease.txt +# Auth config for ppa release +/.release_ppa_auth + # Compiled Object files *.slo *.lo diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index 827b1fa97f..aca49dca63 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -9,13 +9,18 @@ ## If the given branch is "release", the resulting package will be uploaded to ## ethereum/ethereum PPA, or ethereum/ethereum-dev PPA otherwise. ## -## The gnupg key for "builds@ethereum.org" has to be present in order to sign -## the package. -## ## It will clone the Solidity git from github, determine the version, ## create a source archive and push it to the ubuntu ppa servers. ## -## This requires the following entries in /etc/dput.cf: +## To interact with launchpad, you need to set the variables $LAUNCHPAD_EMAIL +## and $LAUNCHPAD_KEYID in the file .release_ppa_auth in the root directory of +## the project to your launchpad email and pgp keyid. +## This could for example look like this: +## +## LAUNCHPAD_EMAIL=your-launchpad-email@ethereum.org +## LAUNCHPAD_KEYID=123ABCFFFFFFFF +## +## Additionally the following entries in /etc/dput.cf are required: ## ## [ethereum-dev] ## fqdn = ppa.launchpad.net @@ -34,11 +39,17 @@ ## method = ftp ## incoming = ~ethereum/ethereum-static ## login = anonymous - ## ############################################################################## -set -ev +set -e + + +REPO_ROOT="$(dirname "$0")/.." + +# for the "fail" function +# shellcheck source=scripts/common.sh +source "${REPO_ROOT}/scripts/common.sh" if [ -z "$1" ] then @@ -51,17 +62,39 @@ is_release() { [[ "${branch}" =~ ^v[0-9]+(\.[0-9]+)*$ ]] } -keyid=379F4801D622CDCF -email=builds@ethereum.org +# source keyid and email from .release_ppa_auth +if [[ -e .release_ppa_auth ]] +then + # shellcheck source=/dev/null + source "${REPO_ROOT}/.release_ppa_auth" +fi + +[[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \ + fail "Error: Couldn't find variables \$LAUNCHPAD_KEYID or \$LAUNCHPAD_EMAIL in sourced file .release_ppa_auth (check top comment in $0 for more information)." + packagename=solc +# This needs to be a still active release static_build_distribution=impish DISTRIBUTIONS="focal impish jammy kinetic" +function checkDputEntries { + local pattern="$1" + grep "${pattern}" /etc/dput.cf --quiet || \ + fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in ${0} for more information)." +} + if is_release then DISTRIBUTIONS="$DISTRIBUTIONS STATIC" + + # Sanity checks + checkDputEntries "\[ethereum\]" + checkDputEntries "\[ethereum-static\]" +else + # Sanity check + checkDputEntries "\[ethereum-dev\]" fi for distribution in $DISTRIBUTIONS @@ -245,7 +278,7 @@ chmod +x debian/rules versionsuffix=0ubuntu1~${distribution} # bump version / add entry to changelog -EMAIL="$email" dch -v "1:${debversion}-${versionsuffix}" "git build of ${commithash}" +EMAIL="$LAUNCHPAD_EMAIL" dch -v "1:${debversion}-${versionsuffix}" "git build of ${commithash}" # build source package @@ -287,7 +320,7 @@ fi ) # sign the package -debsign --re-sign -k "${keyid}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" +debsign --re-sign -k "${LAUNCHPAD_KEYID}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" # upload dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" From 0fab970eb932cc6886ddcbdfa260490c37515e81 Mon Sep 17 00:00:00 2001 From: Marenz Date: Wed, 10 Aug 2022 20:02:12 +0200 Subject: [PATCH 021/109] Remove old distributions in release_ppa script --- scripts/release_ppa.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index aca49dca63..6e3eae01cc 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -75,9 +75,9 @@ fi packagename=solc # This needs to be a still active release -static_build_distribution=impish +static_build_distribution=focal -DISTRIBUTIONS="focal impish jammy kinetic" +DISTRIBUTIONS="focal jammy kinetic" function checkDputEntries { local pattern="$1" From e3ed29d3b3615bc3e0419c1b8a5db8cef68f3b90 Mon Sep 17 00:00:00 2001 From: Bhargava Shastry Date: Mon, 8 Aug 2022 10:59:58 +0200 Subject: [PATCH 022/109] Permit multiple indirections in coding calldata to and from memory/calldata. --- test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp | 17 ++--- .../tools/ossfuzz/SolidityEvmoneInterface.cpp | 68 ++++++++----------- test/tools/ossfuzz/SolidityEvmoneInterface.h | 2 +- test/tools/ossfuzz/abiV2Proto.proto | 1 + test/tools/ossfuzz/abiV2ProtoFuzzer.cpp | 33 ++++----- test/tools/ossfuzz/protoToAbiV2.cpp | 67 +++++++++++++----- test/tools/ossfuzz/protoToAbiV2.h | 34 +++++++++- test/tools/ossfuzz/solProtoFuzzer.cpp | 9 +-- 8 files changed, 138 insertions(+), 93 deletions(-) diff --git a/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp b/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp index 6a12878e15..78697a9ddd 100644 --- a/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp +++ b/test/tools/ossfuzz/AbiV2IsabelleFuzzer.cpp @@ -36,7 +36,7 @@ static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; DEFINE_PROTO_FUZZER(Contract const& _contract) { - ProtoConverter converter; + ProtoConverter converter(_contract.seed()); string contractSource = converter.contractToString(_contract); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) @@ -69,14 +69,11 @@ DEFINE_PROTO_FUZZER(Contract const& _contract) {} ); auto result = evmoneUtil.compileDeployAndExecute(encodedData); - if (result.has_value()) - { - solAssert(result->status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted."); - if (result->status_code == EVMC_SUCCESS) - solAssert( - EvmoneUtility::zeroWord(result->output_data, result->output_size), - "Proto ABIv2 fuzzer: ABIv2 coding failure found." - ); - } + solAssert(result.status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted."); + if (result.status_code == EVMC_SUCCESS) + solAssert( + EvmoneUtility::zeroWord(result.output_data, result.output_size), + "Proto ABIv2 fuzzer: ABIv2 coding failure found." + ); } } diff --git a/test/tools/ossfuzz/SolidityEvmoneInterface.cpp b/test/tools/ossfuzz/SolidityEvmoneInterface.cpp index ff9fcf2d8d..884e35a8c0 100644 --- a/test/tools/ossfuzz/SolidityEvmoneInterface.cpp +++ b/test/tools/ossfuzz/SolidityEvmoneInterface.cpp @@ -128,7 +128,7 @@ evmc::result EvmoneUtility::deployAndExecute( return callResult; } -optional EvmoneUtility::compileDeployAndExecute(string _fuzzIsabelle) +evmc::result EvmoneUtility::compileDeployAndExecute(string _fuzzIsabelle) { map libraryAddressMap; // Stage 1: Compile and deploy library if present. @@ -136,51 +136,43 @@ optional EvmoneUtility::compileDeployAndExecute(string _fuzzIsabel { m_compilationFramework.contractName(m_libraryName); auto compilationOutput = m_compilationFramework.compileContract(); - if (compilationOutput.has_value()) - { - CompilerOutput cOutput = compilationOutput.value(); - // Deploy contract and signal failure if deploy failed - evmc::result createResult = deployContract(cOutput.byteCode); - solAssert( - createResult.status_code == EVMC_SUCCESS, - "SolidityEvmoneInterface: Library deployment failed" - ); - libraryAddressMap[m_libraryName] = EVMHost::convertFromEVMC(createResult.create_address); - m_compilationFramework.libraryAddresses(libraryAddressMap); - } - else - return {}; + solAssert(compilationOutput.has_value(), "Compiling library failed"); + CompilerOutput cOutput = compilationOutput.value(); + // Deploy contract and signal failure if deploy failed + evmc::result createResult = deployContract(cOutput.byteCode); + solAssert( + createResult.status_code == EVMC_SUCCESS, + "SolidityEvmoneInterface: Library deployment failed" + ); + libraryAddressMap[m_libraryName] = EVMHost::convertFromEVMC(createResult.create_address); + m_compilationFramework.libraryAddresses(libraryAddressMap); } // Stage 2: Compile, deploy, and execute contract, optionally using library // address map. m_compilationFramework.contractName(m_contractName); auto cOutput = m_compilationFramework.compileContract(); - if (cOutput.has_value()) - { - solAssert( - !cOutput->byteCode.empty() && !cOutput->methodIdentifiersInContract.empty(), - "SolidityEvmoneInterface: Invalid compilation output." - ); - - string methodName; - if (!_fuzzIsabelle.empty()) - // TODO: Remove this once a cleaner solution is found for querying - // isabelle test entry point. At the moment, we are sure that the - // entry point is the second method in the contract (hence the ++) - // but not its name. - methodName = (++cOutput->methodIdentifiersInContract.begin())->asString() + - _fuzzIsabelle.substr(2, _fuzzIsabelle.size()); - else - methodName = cOutput->methodIdentifiersInContract[m_methodName].asString(); + solAssert(cOutput.has_value(), "Compiling contract failed"); + solAssert( + !cOutput->byteCode.empty() && !cOutput->methodIdentifiersInContract.empty(), + "SolidityEvmoneInterface: Invalid compilation output." + ); - return deployAndExecute( - cOutput->byteCode, - methodName - ); - } + string methodName; + if (!_fuzzIsabelle.empty()) + // TODO: Remove this once a cleaner solution is found for querying + // isabelle test entry point. At the moment, we are sure that the + // entry point is the second method in the contract (hence the ++) + // but not its name. + methodName = (++cOutput->methodIdentifiersInContract.begin())->asString() + + _fuzzIsabelle.substr(2, _fuzzIsabelle.size()); else - return {}; + methodName = cOutput->methodIdentifiersInContract[m_methodName].asString(); + + return deployAndExecute( + cOutput->byteCode, + methodName + ); } optional EvmoneUtility::compileContract() diff --git a/test/tools/ossfuzz/SolidityEvmoneInterface.h b/test/tools/ossfuzz/SolidityEvmoneInterface.h index 734caf560a..d6826cb891 100644 --- a/test/tools/ossfuzz/SolidityEvmoneInterface.h +++ b/test/tools/ossfuzz/SolidityEvmoneInterface.h @@ -122,7 +122,7 @@ class EvmoneUtility /// and executing test configuration. /// @param _isabelleData contains encoding data to be passed to the /// isabelle test entry point. - std::optional compileDeployAndExecute(std::string _isabelleData = {}); + evmc::result compileDeployAndExecute(std::string _isabelleData = {}); /// Compares the contents of the memory address pointed to /// by `_result` of `_length` bytes to u256 zero. /// @returns true if `_result` is zero, false diff --git a/test/tools/ossfuzz/abiV2Proto.proto b/test/tools/ossfuzz/abiV2Proto.proto index 1afc031767..ec6fe1d55e 100644 --- a/test/tools/ossfuzz/abiV2Proto.proto +++ b/test/tools/ossfuzz/abiV2Proto.proto @@ -92,6 +92,7 @@ message Contract { required VarDecl state_vars = 1; required TestFunction testfunction = 2; required Test test = 3; + required uint32 seed = 4; } package solidity.test.abiv2fuzzer; diff --git a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp index 977d1bc455..6d792a70c5 100644 --- a/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp +++ b/test/tools/ossfuzz/abiV2ProtoFuzzer.cpp @@ -35,7 +35,7 @@ static evmc::VM evmone = evmc::VM{evmc_create_evmone()}; DEFINE_PROTO_FUZZER(Contract const& _input) { - string contract_source = ProtoConverter{}.contractToString(_input); + string contract_source = ProtoConverter{_input.seed()}.contractToString(_input); if (const char* dump_path = getenv("PROTO_FUZZER_DUMP_PATH")) { @@ -61,21 +61,18 @@ DEFINE_PROTO_FUZZER(Contract const& _input) ); // Invoke test function auto result = evmoneUtil.compileDeployAndExecute(); - if (result.has_value()) - { - // We don't care about EVM One failures other than EVMC_REVERT - solAssert(result->status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted"); - if (result->status_code == EVMC_SUCCESS) - if (!EvmoneUtility::zeroWord(result->output_data, result->output_size)) - { - solidity::bytes resultAsBytes; - for (size_t i = 0; i < result->output_size; i++) - resultAsBytes.push_back(result->output_data[i]); - cout << solidity::util::toHex(resultAsBytes) << endl; - solAssert( - false, - "Proto ABIv2 fuzzer: ABIv2 coding failure found" - ); - } - } + // We don't care about EVM One failures other than EVMC_REVERT + solAssert(result.status_code != EVMC_REVERT, "Proto ABIv2 fuzzer: EVM One reverted"); + if (result.status_code == EVMC_SUCCESS) + if (!EvmoneUtility::zeroWord(result.output_data, result.output_size)) + { + solidity::bytes res; + for (size_t i = 0; i < result.output_size; i++) + res.push_back(result.output_data[i]); + cout << solidity::util::toHex(res) << endl; + solAssert( + false, + "Proto ABIv2 fuzzer: ABIv2 coding failure found" + ); + } } diff --git a/test/tools/ossfuzz/protoToAbiV2.cpp b/test/tools/ossfuzz/protoToAbiV2.cpp index a444228a1e..f20c0482c9 100644 --- a/test/tools/ossfuzz/protoToAbiV2.cpp +++ b/test/tools/ossfuzz/protoToAbiV2.cpp @@ -416,16 +416,7 @@ void ProtoConverter::appendTypedParamsExternal( Delimiter _delimiter ) { - std::string qualifiedTypeString = ( - _isValueType ? - _typeString : - _typeString + " calldata" - ); - m_typedParamsExternal << Whiskers(R"( )") - ("delimiter", delimiterToString(_delimiter)) - ("type", qualifiedTypeString) - ("varName", _varName) - .render(); + m_externalParamsRep.push_back({_delimiter, _isValueType, _typeString, _varName}); m_untypedParamsExternal << Whiskers(R"()") ("delimiter", delimiterToString(_delimiter)) ("varName", _varName) @@ -475,7 +466,25 @@ std::string ProtoConverter::typedParametersAsString(CalleeType _calleeType) case CalleeType::PUBLIC: return m_typedParamsPublic.str(); case CalleeType::EXTERNAL: - return m_typedParamsExternal.str(); + { + ostringstream typedParamsExternal; + for (auto const& i: m_externalParamsRep) + { + Delimiter del = get<0>(i); + bool valueType = get<1>(i); + string typeString = get<2>(i); + string varName = get<3>(i); + bool isCalldata = randomBool(/*probability=*/0.5); + string location = (isCalldata ? "calldata" : "memory"); + string qualifiedTypeString = (valueType ? typeString : typeString + " " + location); + typedParamsExternal << Whiskers(R"( )") + ("delimiter", delimiterToString(del)) + ("type", qualifiedTypeString) + ("varName", varName) + .render(); + } + return typedParamsExternal.str(); + } } } @@ -666,6 +675,33 @@ string ProtoConverter::calldataHelperFunctions() return 0; })"; + /// These are indirections to test memory-calldata codings more robustly. + stringstream indirections; + unsigned numIndirections = randomNumberOneToN(s_maxIndirections); + for (unsigned i = 1; i <= numIndirections; i++) + { + bool finalIndirection = i == numIndirections; + string mutability = (finalIndirection ? "pure" : "view"); + indirections << Whiskers(R"( + function coder_calldata_external_i() external returns (uint) { + + + return 0; + + return this.coder_calldata_external_i(); + + } + )") + ("N", to_string(i)) + ("parameters", typedParametersAsString(CalleeType::EXTERNAL)) + ("mutability", mutability) + ("finalIndirection", finalIndirection) + ("equality_checks", equalityChecksAsString()) + ("NPlusOne", to_string(i + 1)) + ("untyped_parameters", m_untypedParamsExternal.str()) + .render(); + } + // These are callee functions that encode from storage, decode to // memory/calldata and check if decoded value matches storage value // return true on successful match, false otherwise @@ -676,18 +712,15 @@ string ProtoConverter::calldataHelperFunctions() } function coder_calldata_external() external view returns (uint) { - return this.coder_calldata_external_indirection(); - } - - function coder_calldata_external_indirection() external pure returns (uint) { - - return 0; + return this.coder_calldata_external_i1(); } + )") ("parameters_memory", typedParametersAsString(CalleeType::PUBLIC)) ("equality_checks", equalityChecksAsString()) ("parameters_calldata", typedParametersAsString(CalleeType::EXTERNAL)) ("untyped_parameters", m_untypedParamsExternal.str()) + ("indirections", indirections.str()) .render(); return calldataHelperFuncs.str(); diff --git a/test/tools/ossfuzz/protoToAbiV2.h b/test/tools/ossfuzz/protoToAbiV2.h index 3e7f47994e..d549113537 100644 --- a/test/tools/ossfuzz/protoToAbiV2.h +++ b/test/tools/ossfuzz/protoToAbiV2.h @@ -15,6 +15,7 @@ #include #include +#include #include /** @@ -134,13 +135,16 @@ namespace solidity::test::abiv2fuzzer { +using RandomEngine = std::mt19937_64; +using Distribution = std::uniform_int_distribution; +using Bernoulli = std::bernoulli_distribution; /// Converts a protobuf input into a Solidity program that tests /// abi coding. class ProtoConverter { public: - ProtoConverter(): + ProtoConverter(unsigned _seed): m_isStateVar(true), m_counter(0), m_varCounter(0), @@ -148,7 +152,9 @@ class ProtoConverter m_isLastDynParamRightPadded(false), m_structCounter(0), m_numStructsAdded(0) - {} + { + m_random = std::make_unique(_seed); + } ProtoConverter(ProtoConverter const&) = delete; ProtoConverter(ProtoConverter&&) = delete; @@ -173,6 +179,13 @@ class ProtoConverter EXTERNAL }; + /// Each external parameter representation contains the following: + /// - Delimiter prefix + /// - Boolean that is true if value type, false otherwise + /// - String representation of type + /// - Parameter name + using ParameterPack = std::tuple; + /// Visitors for various Protobuf types /// Visit top-level contract specification void visit(Contract const&); @@ -381,6 +394,16 @@ class ProtoConverter /// Convert delimter to a comma or null string. static std::string delimiterToString(Delimiter _delimiter, bool _space = true); + /// Generates number in the range [1, @param _n] uniformly at random. + unsigned randomNumberOneToN(unsigned _n) + { + return Distribution(1, _n)(*m_random); + } + /// Generates boolean that has a bernoulli distribution defined by @param _p. + bool randomBool(double _p) + { + return Bernoulli{_p}(*m_random); + } /// Contains the test program std::ostringstream m_output; @@ -388,7 +411,6 @@ class ProtoConverter /// checks to be encoded in the test program std::ostringstream m_checks; /// Contains typed parameter list to be passed to callee functions - std::ostringstream m_typedParamsExternal; std::ostringstream m_typedParamsPublic; /// Contains parameter list to be passed to callee functions std::ostringstream m_untypedParamsExternal; @@ -418,10 +440,16 @@ class ProtoConverter unsigned m_numStructsAdded; /// Enum stating abiv2 coder to be tested Contract_Test m_test; + /// Representation of external parameters + std::vector m_externalParamsRep; + /// Random number generator + std::unique_ptr m_random; /// Prefixes for declared and parameterized variable names static auto constexpr s_localVarNamePrefix = "lv_"; static auto constexpr s_stateVarNamePrefix = "sv_"; static auto constexpr s_paramNamePrefix = "p_"; + /// Maximum number of indirections to test calldata coding + static unsigned constexpr s_maxIndirections = 5; }; /// Visitor interface for Solidity protobuf types. diff --git a/test/tools/ossfuzz/solProtoFuzzer.cpp b/test/tools/ossfuzz/solProtoFuzzer.cpp index a752e21199..f7acc6c10d 100644 --- a/test/tools/ossfuzz/solProtoFuzzer.cpp +++ b/test/tools/ossfuzz/solProtoFuzzer.cpp @@ -79,13 +79,10 @@ DEFINE_PROTO_FUZZER(Program const& _input) methodName ); auto minimalResult = evmoneUtil.compileDeployAndExecute(); - if (minimalResult.has_value()) - { - solAssert(minimalResult->status_code != EVMC_REVERT, "Sol proto fuzzer: Evmone reverted."); - if (minimalResult->status_code == EVMC_SUCCESS) + solAssert(minimalResult.status_code != EVMC_REVERT, "Sol proto fuzzer: Evmone reverted."); + if (minimalResult.status_code == EVMC_SUCCESS) solAssert( - EvmoneUtility::zeroWord(minimalResult->output_data, minimalResult->output_size), + EvmoneUtility::zeroWord(minimalResult.output_data, minimalResult.output_size), "Proto solc fuzzer: Output incorrect" ); - } } From 2282ea5e56ab25ded9693d3b51b6dee1760c43ea Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Mon, 20 Jun 2022 19:19:20 -0300 Subject: [PATCH 023/109] Added overflow checks after multiplication operation is executed. --- Changelog.md | 1 + libsolidity/codegen/YulUtilFunctions.cpp | 44 ++++++++++++------ test/formal/checked_int_mul_12.py | 46 +++++++++++++++++++ test/formal/checked_int_mul_16.py | 43 ----------------- ..._uint_mul_16.py => checked_uint_mul_12.py} | 24 +++++----- .../formal/signed_integer_cleanup_function.py | 41 +++++++++++++++++ .../unsigned_integer_cleanup_function.py | 40 ++++++++++++++++ test/formal/util.py | 15 ++++++ .../abiEncoderV2/storage_array_encoding.sol | 4 +- .../copying/array_copy_including_array.sol | 8 ++-- .../array/copying/array_copy_nested_array.sol | 2 +- .../array_copy_storage_storage_struct.sol | 2 +- .../copying/array_copy_target_leftover.sol | 6 +-- .../array_nested_calldata_to_storage.sol | 2 +- .../array_of_struct_calldata_to_storage.sol | 2 +- .../externalContracts/base64.sol | 18 ++++---- .../externalContracts/ramanujan_pi.sol | 8 ++-- .../semanticTests/externalContracts/snark.sol | 2 +- .../externalContracts/strings.sol | 12 ++--- .../salted_create_with_value.sol | 6 +-- .../viaYul/detect_mul_overflow_signed.sol | 21 +++++++++ 21 files changed, 243 insertions(+), 104 deletions(-) create mode 100644 test/formal/checked_int_mul_12.py delete mode 100644 test/formal/checked_int_mul_16.py rename test/formal/{checked_uint_mul_16.py => checked_uint_mul_12.py} (58%) create mode 100644 test/formal/signed_integer_cleanup_function.py create mode 100644 test/formal/unsigned_integer_cleanup_function.py diff --git a/Changelog.md b/Changelog.md index 18066a7751..d91eccb314 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,6 +7,7 @@ Language Features: Compiler Features: + * Code Generator: More efficient overflow checks for multiplication. Bugfixes: diff --git a/libsolidity/codegen/YulUtilFunctions.cpp b/libsolidity/codegen/YulUtilFunctions.cpp index b24cf4f901..b66189f054 100644 --- a/libsolidity/codegen/YulUtilFunctions.cpp +++ b/libsolidity/codegen/YulUtilFunctions.cpp @@ -684,28 +684,46 @@ string YulUtilFunctions::overflowCheckedIntMulFunction(IntegerType const& _type) function (x, y) -> product { x := (x) y := (y) + let product_raw := mul(x, y) + product := (product_raw) - // overflow, if x > 0, y > 0 and x > (maxValue / y) - if and(and(sgt(x, 0), sgt(y, 0)), gt(x, div(, y))) { () } - // underflow, if x > 0, y < 0 and y < (minValue / x) - if and(and(sgt(x, 0), slt(y, 0)), slt(y, sdiv(, x))) { () } - // underflow, if x < 0, y > 0 and x < (minValue / y) - if and(and(slt(x, 0), sgt(y, 0)), slt(x, sdiv(, y))) { () } - // overflow, if x < 0, y < 0 and x < (maxValue / y) - if and(and(slt(x, 0), slt(y, 0)), slt(x, sdiv(, y))) { () } + + + // special case + if and(slt(x, 0), eq(y, )) { () } + + // overflow, if x != 0 and y != product/x + if iszero( + or( + iszero(x), + eq(y, sdiv(product, x)) + ) + ) { () } + + if iszero(eq(product, product_raw)) { () } + - // overflow, if x != 0 and y > (maxValue / x) - if and(iszero(iszero(x)), gt(y, div(, x))) { () } + + // overflow, if x != 0 and y != product/x + if iszero( + or( + iszero(x), + eq(y, div(product, x)) + ) + ) { () } + + if iszero(eq(product, product_raw)) { () } + - product := mul(x, y) } )") ("functionName", functionName) ("signed", _type.isSigned()) - ("maxValue", toCompactHexWithPrefix(u256(_type.maxValue()))) - ("minValue", toCompactHexWithPrefix(u256(_type.minValue()))) ("cleanupFunction", cleanupFunction(_type)) ("panic", panicFunction(PanicCode::UnderOverflow)) + ("minValue", toCompactHexWithPrefix(u256(_type.minValue()))) + ("256bit", _type.numBits() == 256) + ("gt128bit", _type.numBits() > 128) .render(); }); } diff --git a/test/formal/checked_int_mul_12.py b/test/formal/checked_int_mul_12.py new file mode 100644 index 0000000000..ea13f01940 --- /dev/null +++ b/test/formal/checked_int_mul_12.py @@ -0,0 +1,46 @@ +from opcodes import AND, SDIV, MUL, EQ, ISZERO, OR, SLT +from rule import Rule +from util import BVSignedUpCast, BVSignedMin, BVSignedCleanupFunction +from z3 import BVMulNoOverflow, BVMulNoUnderflow, BitVec, Not, Or + +""" +Overflow checked signed integer multiplication. +""" + +# Approximation with 16-bit base types. +n_bits = 12 + +for type_bits in [4, 6, 8, 12]: + + rule = Rule() + + # Input vars + X_short = BitVec('X', type_bits) + Y_short = BitVec('Y', type_bits) + + # Z3's overflow and underflow conditions + actual_overflow = Not(BVMulNoOverflow(X_short, Y_short, True)) + actual_underflow = Not(BVMulNoUnderflow(X_short, Y_short)) + + # cast to full n_bits values + X = BVSignedUpCast(X_short, n_bits) + Y = BVSignedUpCast(Y_short, n_bits) + product_raw = MUL(X, Y) + #remove any overflown bits + product = BVSignedCleanupFunction(product_raw, type_bits) + + # Constants + min_value = BVSignedMin(type_bits, n_bits) + + # Overflow and underflow checks in YulUtilFunction::overflowCheckedIntMulFunction + if type_bits > n_bits / 2: + sol_overflow_check_1 = ISZERO(OR(ISZERO(X), EQ(Y, SDIV(product, X)))) + if type_bits == n_bits: + sol_overflow_check_2 = AND(SLT(X, 0), EQ(Y, min_value)) + sol_overflow_check = Or(sol_overflow_check_1 != 0, sol_overflow_check_2 != 0) + else: + sol_overflow_check = (sol_overflow_check_1 != 0) + else: + sol_overflow_check = (ISZERO(EQ(product, product_raw)) != 0) + + rule.check(Or(actual_overflow, actual_underflow), sol_overflow_check) diff --git a/test/formal/checked_int_mul_16.py b/test/formal/checked_int_mul_16.py deleted file mode 100644 index b2f9eb852a..0000000000 --- a/test/formal/checked_int_mul_16.py +++ /dev/null @@ -1,43 +0,0 @@ -from opcodes import AND, DIV, GT, SDIV, SGT, SLT -from rule import Rule -from util import BVSignedMax, BVSignedMin, BVSignedUpCast -from z3 import BVMulNoOverflow, BVMulNoUnderflow, BitVec, Not, Or - -""" -Overflow checked signed integer multiplication. -""" - -# Approximation with 16-bit base types. -n_bits = 16 -type_bits = 8 - -while type_bits <= n_bits: - - rule = Rule() - - # Input vars - X_short = BitVec('X', type_bits) - Y_short = BitVec('Y', type_bits) - - # Z3's overflow and underflow conditions - actual_overflow = Not(BVMulNoOverflow(X_short, Y_short, True)) - actual_underflow = Not(BVMulNoUnderflow(X_short, Y_short)) - - # cast to full n_bits values - X = BVSignedUpCast(X_short, n_bits) - Y = BVSignedUpCast(Y_short, n_bits) - - # Constants - maxValue = BVSignedMax(type_bits, n_bits) - minValue = BVSignedMin(type_bits, n_bits) - - # Overflow and underflow checks in YulUtilFunction::overflowCheckedIntMulFunction - overflow_check_1 = AND(AND(SGT(X, 0), SGT(Y, 0)), GT(X, DIV(maxValue, Y))) - underflow_check_1 = AND(AND(SGT(X, 0), SLT(Y, 0)), SLT(Y, SDIV(minValue, X))) - underflow_check_2 = AND(AND(SLT(X, 0), SGT(Y, 0)), SLT(X, SDIV(minValue, Y))) - overflow_check_2 = AND(AND(SLT(X, 0), SLT(Y, 0)), SLT(X, SDIV(maxValue, Y))) - - rule.check(actual_overflow, Or(overflow_check_1 != 0, overflow_check_2 != 0)) - rule.check(actual_underflow, Or(underflow_check_1 != 0, underflow_check_2 != 0)) - - type_bits *= 2 diff --git a/test/formal/checked_uint_mul_16.py b/test/formal/checked_uint_mul_12.py similarity index 58% rename from test/formal/checked_uint_mul_16.py rename to test/formal/checked_uint_mul_12.py index 1c60de47be..a386fcfa4f 100644 --- a/test/formal/checked_uint_mul_16.py +++ b/test/formal/checked_uint_mul_12.py @@ -1,6 +1,6 @@ -from opcodes import AND, ISZERO, GT, DIV +from opcodes import ISZERO, DIV, MUL, EQ, OR from rule import Rule -from util import BVUnsignedUpCast, BVUnsignedMax +from util import BVUnsignedUpCast, BVUnsignedCleanupFunction from z3 import BitVec, Not, BVMulNoOverflow """ @@ -8,10 +8,9 @@ """ # Approximation with 16-bit base types. -n_bits = 16 -type_bits = 8 +n_bits = 12 -while type_bits <= n_bits: +for type_bits in [4, 6, 8, 12]: rule = Rule() @@ -25,13 +24,14 @@ # cast to full n_bits values X = BVUnsignedUpCast(X_short, n_bits) Y = BVUnsignedUpCast(Y_short, n_bits) + product_raw = MUL(X, Y) + #remove any overflown bits + product = BVUnsignedCleanupFunction(product_raw, type_bits) - # Constants - maxValue = BVUnsignedMax(type_bits, n_bits) - - # Overflow check in YulUtilFunction::overflowCheckedIntMulFunction - overflow_check = AND(ISZERO(ISZERO(X)), GT(Y, DIV(maxValue, X))) + # Overflow check in YulUtilFunction::overflowCheckedIntMulFunctions + if type_bits > n_bits / 2: + overflow_check = ISZERO(OR(ISZERO(X), EQ(Y, DIV(product, X)))) + else: + overflow_check = ISZERO(EQ(product, product_raw)) rule.check(overflow_check != 0, actual_overflow) - - type_bits *= 2 diff --git a/test/formal/signed_integer_cleanup_function.py b/test/formal/signed_integer_cleanup_function.py new file mode 100644 index 0000000000..2b7b0e440b --- /dev/null +++ b/test/formal/signed_integer_cleanup_function.py @@ -0,0 +1,41 @@ +from opcodes import SIGNEXTEND +from rule import Rule +from util import BVSignedCleanupFunction, BVSignedUpCast +from z3 import BitVec, BitVecVal, Concat + +""" +Overflow checked signed integer multiplication. +""" + +n_bits = 256 + +# Check that YulUtilFunction::cleanupFunction cleanup matches BVSignedCleanupFunction +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X = BitVec('X', n_bits) + arg = BitVecVal(type_bits / 8 - 1, n_bits) + + cleaned_reference = BVSignedCleanupFunction(X, type_bits) + cleaned = SIGNEXTEND(arg, X) + + rule.check(cleaned, cleaned_reference) + + +# Check that BVSignedCleanupFunction properly cleans up values. +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X_short = BitVec('X', type_bits) + dirt = BitVec('dirt', n_bits - type_bits) + + X = BVSignedUpCast(X_short, n_bits) + X_dirty = Concat(dirt, X_short) + X_cleaned = BVSignedCleanupFunction(X_dirty, type_bits) + + + rule.check(X, X_cleaned) diff --git a/test/formal/unsigned_integer_cleanup_function.py b/test/formal/unsigned_integer_cleanup_function.py new file mode 100644 index 0000000000..42296f89ba --- /dev/null +++ b/test/formal/unsigned_integer_cleanup_function.py @@ -0,0 +1,40 @@ +from opcodes import AND +from rule import Rule +from util import BVUnsignedCleanupFunction, BVUnsignedUpCast +from z3 import BitVec, BitVecVal, Concat + +""" +Overflow checked unsigned integer multiplication. +""" + +n_bits = 256 + +# Check that YulUtilFunction::cleanupFunction cleanup matches BVUnsignedCleanupFunction +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X = BitVec('X', n_bits) + mask = BitVecVal((1 << type_bits) - 1, n_bits) + + cleaned_reference = BVUnsignedCleanupFunction(X, type_bits) + cleaned = AND(X, mask) + + rule.check(cleaned, cleaned_reference) + +# Check that BVUnsignedCleanupFunction properly cleans up values. +for type_bits in range(8,256,8): + + rule = Rule() + + # Input vars + X_short = BitVec('X', type_bits) + dirt = BitVec('dirt', n_bits - type_bits) + + X = BVUnsignedUpCast(X_short, n_bits) + X_dirty = Concat(dirt, X_short) + X_cleaned = BVUnsignedCleanupFunction(X_dirty, type_bits) + + + rule.check(X, X_cleaned) diff --git a/test/formal/util.py b/test/formal/util.py index 8d0debbef4..8fc261fdcf 100644 --- a/test/formal/util.py +++ b/test/formal/util.py @@ -25,3 +25,18 @@ def BVSignedMax(type_bits, n_bits): def BVSignedMin(type_bits, n_bits): assert type_bits <= n_bits return BitVecVal(-(1 << (type_bits - 1)), n_bits) + +def BVSignedCleanupFunction(x, type_bits): + assert x.size() >= type_bits + sign_mask = BitVecVal(1, x.size()) << (type_bits - 1) + bit_mask = (BitVecVal(1, x.size()) << type_bits) - 1 + return If( + x & sign_mask == 0, + x & bit_mask, + x | ~bit_mask + ) + +def BVUnsignedCleanupFunction(x, type_bits): + assert x.size() >= type_bits + bit_mask = (BitVecVal(1, x.size()) << type_bits) - 1 + return x & bit_mask diff --git a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol index 5f71fc7e2a..16f365bd43 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/storage_array_encoding.sol @@ -18,10 +18,10 @@ contract C { // EVMVersion: >homestead // ---- // h(uint256[2][]): 0x20, 3, 123, 124, 223, 224, 323, 324 -> 32, 256, 0x20, 3, 123, 124, 223, 224, 323, 324 -// gas irOptimized: 180726 +// gas irOptimized: 180829 // gas legacy: 184921 // gas legacyOptimized: 181506 // i(uint256[2][2]): 123, 124, 223, 224 -> 32, 128, 123, 124, 223, 224 -// gas irOptimized: 112453 +// gas irOptimized: 112464 // gas legacy: 115460 // gas legacyOptimized: 112990 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol index b98ddec9d7..c3958abac6 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_including_array.sol @@ -35,12 +35,12 @@ contract c { } // ---- // test() -> 0x02000202 -// gas irOptimized: 4649903 -// gas legacy: 4578320 -// gas legacyOptimized: 4548312 +// gas irOptimized: 4649835 +// gas legacy: 4578446 +// gas legacyOptimized: 4548309 // storageEmpty -> 1 // clear() -> 0, 0 -// gas irOptimized: 4477229 +// gas irOptimized: 4477223 // gas legacy: 4410748 // gas legacyOptimized: 4382489 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol index d8907cf030..a85765cd98 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_nested_array.sol @@ -13,6 +13,6 @@ contract c { // ---- // test(uint256[2][]): 32, 3, 7, 8, 9, 10, 11, 12 -> 10 -// gas irOptimized: 689768 +// gas irOptimized: 689759 // gas legacy: 686268 // gas legacyOptimized: 685688 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol index 0225f421cf..3fc10b7a27 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_struct.sol @@ -17,7 +17,7 @@ contract c { } // ---- // test() -> 4, 5 -// gas irOptimized: 238692 +// gas irOptimized: 238623 // gas legacy: 238736 // gas legacyOptimized: 237159 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol index 6c07ceec7e..f2d02ee578 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_target_leftover.sol @@ -19,6 +19,6 @@ contract c { // compileToEwasm: also // ---- // test() -> 0xffffffff, 0x0000000000000000000000000a00090008000700060005000400030002000100, 0x0000000000000000000000000000000000000000000000000000000000000000 -// gas irOptimized: 124817 -// gas legacy: 186028 -// gas legacyOptimized: 165692 +// gas irOptimized: 124910 +// gas legacy: 187414 +// gas legacyOptimized: 165659 diff --git a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol index c737a5b044..02872f8dde 100644 --- a/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_nested_calldata_to_storage.sol @@ -42,6 +42,6 @@ contract c { // test2(uint256[][2]): 0x20, 0x40, 0x40, 2, 23, 42 -> 2, 65 // gas irOptimized: 157567 // test3(uint256[2][]): 0x20, 2, 23, 42, 23, 42 -> 2, 65 -// gas irOptimized: 134633 +// gas irOptimized: 134644 // test4(uint256[2][2]): 23, 42, 23, 42 -> 65 // gas irOptimized: 111271 diff --git a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol index a8bacdda68..a7487a64fe 100644 --- a/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/array_of_struct_calldata_to_storage.sol @@ -17,4 +17,4 @@ contract C { // compileViaYul: true // ---- // f((uint128,uint64,uint128)[]): 0x20, 3, 0, 0, 12, 0, 11, 0, 10, 0, 0 -> 10, 11, 12 -// gas irOptimized: 119740 +// gas irOptimized: 119737 diff --git a/test/libsolidity/semanticTests/externalContracts/base64.sol b/test/libsolidity/semanticTests/externalContracts/base64.sol index 84ece36bea..de5def9958 100644 --- a/test/libsolidity/semanticTests/externalContracts/base64.sol +++ b/test/libsolidity/semanticTests/externalContracts/base64.sol @@ -33,9 +33,9 @@ contract test { // EVMVersion: >=constantinople // ---- // constructor() -// gas irOptimized: 441142 -// gas legacy: 755907 -// gas legacyOptimized: 538354 +// gas irOptimized: 438352 +// gas legacy: 750723 +// gas legacyOptimized: 536620 // encode_inline_asm(bytes): 0x20, 0 -> 0x20, 0 // encode_inline_asm(bytes): 0x20, 1, "f" -> 0x20, 4, "Zg==" // encode_inline_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8=" @@ -51,10 +51,10 @@ contract test { // encode_no_asm(bytes): 0x20, 5, "fooba" -> 0x20, 8, "Zm9vYmE=" // encode_no_asm(bytes): 0x20, 6, "foobar" -> 0x20, 8, "Zm9vYmFy" // encode_inline_asm_large() -// gas irOptimized: 1382042 -// gas legacy: 1646033 -// gas legacyOptimized: 1206033 +// gas irOptimized: 1387042 +// gas legacy: 1688033 +// gas legacyOptimized: 1205033 // encode_no_asm_large() -// gas irOptimized: 3311099 -// gas legacy: 4723077 -// gas legacyOptimized: 2909077 +// gas irOptimized: 3316099 +// gas legacy: 4765077 +// gas legacyOptimized: 2908077 diff --git a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol index bf62bb81a0..b4b7054a4f 100644 --- a/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol +++ b/test/libsolidity/semanticTests/externalContracts/ramanujan_pi.sol @@ -33,10 +33,10 @@ contract test { } // ---- // constructor() -// gas irOptimized: 422763 -// gas legacy: 654526 -// gas legacyOptimized: 474842 +// gas irOptimized: 430305 +// gas legacy: 649335 +// gas legacyOptimized: 473132 // prb_pi() -> 3141592656369545286 // gas irOptimized: 57478 -// gas legacy: 98903 +// gas legacy: 103112 // gas legacyOptimized: 75735 diff --git a/test/libsolidity/semanticTests/externalContracts/snark.sol b/test/libsolidity/semanticTests/externalContracts/snark.sol index 10c16c4b7d..7d04b5af65 100644 --- a/test/libsolidity/semanticTests/externalContracts/snark.sol +++ b/test/libsolidity/semanticTests/externalContracts/snark.sol @@ -297,5 +297,5 @@ contract Test { // verifyTx() -> true // ~ emit Verified(string): 0x20, 0x16, "Successfully verified." // gas irOptimized: 95261 -// gas legacy: 113239 +// gas legacy: 116473 // gas legacyOptimized: 83670 diff --git a/test/libsolidity/semanticTests/externalContracts/strings.sol b/test/libsolidity/semanticTests/externalContracts/strings.sol index edbf82a292..654562ef09 100644 --- a/test/libsolidity/semanticTests/externalContracts/strings.sol +++ b/test/libsolidity/semanticTests/externalContracts/strings.sol @@ -49,9 +49,9 @@ contract test { } // ---- // constructor() -// gas irOptimized: 675980 -// gas legacy: 1101298 -// gas legacyOptimized: 743666 +// gas irOptimized: 670586 +// gas legacy: 1096108 +// gas legacyOptimized: 741962 // toSlice(string): 0x20, 11, "hello world" -> 11, 0xa0 // gas irOptimized: 22660 // gas legacy: 23190 @@ -69,6 +69,6 @@ contract test { // gas legacy: 31621 // gas legacyOptimized: 27914 // benchmark(string,bytes32): 0x40, 0x0842021, 8, "solidity" -> 0x2020 -// gas irOptimized: 2017767 -// gas legacy: 4294510 -// gas legacyOptimized: 2327982 +// gas irOptimized: 2017770 +// gas legacy: 4294552 +// gas legacyOptimized: 2327981 diff --git a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol index 8bd823e39d..d51b99b59a 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create_with_value.sol @@ -21,6 +21,6 @@ contract A { // EVMVersion: >=constantinople // ---- // f(), 10 ether -> 3007, 3008, 3009 -// gas irOptimized: 268645 -// gas legacy: 402016 -// gas legacyOptimized: 288087 +// gas irOptimized: 255997 +// gas legacy: 387712 +// gas legacyOptimized: 283266 diff --git a/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol b/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol index dd1953d005..a9581c49f7 100644 --- a/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol +++ b/test/libsolidity/semanticTests/viaYul/detect_mul_overflow_signed.sol @@ -5,6 +5,9 @@ contract C { function g(int8 a, int8 b) public pure returns (int8 x) { x = a * b; } + function h(int160 a, int160 b) public pure returns (int160 x) { + x = a * b; + } } // ==== // compileToEwasm: also @@ -15,6 +18,9 @@ contract C { // f(int256,int256): 0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 2 -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE // f(int256,int256): 0x4000000000000000000000000000000000000000000000000000000000000000, 2 -> FAILURE, hex"4e487b71", 0x11 // f(int256,int256): 2, 0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -> 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE +// f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// f(int256,int256): -1, 0x8000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// f(int256,int256): 0x8000000000000000000000000000000000000000000000000000000000000000, -1 -> FAILURE, hex"4e487b71", 0x11 // f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 # positive, negative # // f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 # positive, negative # // f(int256,int256): 2, 0x4000000000000000000000000000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 # positive, negative # @@ -61,3 +67,18 @@ contract C { // g(int8,int8): -64, -2 -> FAILURE, hex"4e487b71", 0x11 // g(int8,int8): -2, -63 -> 126 // g(int8,int8): -2, -64 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): -1, 1 -> -1 +// h(int160,int160): 1, -1 -> -1 +// h(int160,int160): -1, 2 -> -2 +// h(int160,int160): 2, -1 -> -2 +// h(int160,int160): -1, 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): -1, 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000, -1 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000004000000000000000000000000000000000000000, -2 -> 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 +// h(int160,int160): -2, 0x0000000000000000000000004000000000000000000000000000000000000000 -> 0xFFFFFFFFFFFFFFFFFFFFFFFF8000000000000000000000000000000000000000 +// h(int160,int160): -2, 0x0000000000000000000000004000000000000000000000000000000000000001 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000004000000000000000000000000000000000000001, -2 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000004000000000000000000000000000000000000001, 2 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 2, 0x0000000000000000000000004000000000000000000000000000000000000001 -> FAILURE, hex"4e487b71", 0x11 +// h(int160,int160): 0x0000000000000000000000003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, 2 -> 0x0000000000000000000000007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE +// h(int160,int160): 2, 0x0000000000000000000000004000000000000000000000000000000000000001 -> FAILURE, hex"4e487b71", 0x11 From f1a5bc7ed948be8354def3d896f55119ecceda3d Mon Sep 17 00:00:00 2001 From: aathan Date: Wed, 23 Mar 2022 09:07:34 -0700 Subject: [PATCH 024/109] Update reference-types.rst Clarify comment using language similar to that in the Array section of the documentation. Previously it said simply "Because of that..." but what the word "that" was about, was not evident. --- docs/types/reference-types.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index 911a12eecb..a9f44d7100 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -379,8 +379,10 @@ Array Members uint[2**20] aLotOfIntegers; // Note that the following is not a pair of dynamic arrays but a // dynamic array of pairs (i.e. of fixed size arrays of length two). - // Because of that, T[] is always a dynamic array of T, even if T - // itself is an array. + // In Solidity, T[k] and T[] are always arrays with elements of type T, + // even if T itself is an array. + // Because of that, bool[2][] is a dynamic array of elements + // that are bool[2]. This is different from other languages, like C. // Data location for all state variables is storage. bool[2][] pairsOfFlags; From 9d5fb1bf8bed9cb5aac6ce6021ced4489d3a757a Mon Sep 17 00:00:00 2001 From: aathan Date: Wed, 23 Mar 2022 21:39:16 -0700 Subject: [PATCH 025/109] Update operators.rst --- docs/types/operators.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/types/operators.rst b/docs/types/operators.rst index 1c26e627d5..1d71352d60 100644 --- a/docs/types/operators.rst +++ b/docs/types/operators.rst @@ -18,7 +18,9 @@ and the type of the operator's result: In case one of the operands is a :ref:`literal number ` it is first converted to its "mobile type", which is the smallest type that can hold the value (unsigned types of the same bit-width are considered "smaller" than the signed types). -If both are literal numbers, the operation is computed with arbitrary precision. +If both are literal numbers, the operation is computed with effectively unlimited precision in +that the expression is evaluated to whatever precision is necessary so that none is lost +when the result is used with a non-literal type. The operator's result type is the same as the type the operation is performed in, except for comparison operators where the result is always ``bool``. From 0561bd6b00e133876b7f51114c50709e1678f60b Mon Sep 17 00:00:00 2001 From: aathan Date: Thu, 24 Mar 2022 12:26:03 -0700 Subject: [PATCH 026/109] Update control-structures.rst --- docs/control-structures.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/control-structures.rst b/docs/control-structures.rst index de3b58485c..18a522217f 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -150,8 +150,8 @@ throws an exception or goes out of gas. use ``f.value(x).gas(g)()``. This was deprecated in Solidity 0.6.2 and is no longer possible since Solidity 0.7.0. -Named Calls and Anonymous Function Parameters ---------------------------------------------- +Function Calls with Named Parameters +------------------------------------ Function call arguments can be given by name, in any order, if they are enclosed in ``{ }`` as can be seen in the following @@ -176,11 +176,13 @@ parameters from the function declaration, but can be in arbitrary order. } -Omitted Function Parameter Names --------------------------------- +Omitted Names in Function Definitions +------------------------------------- -The names of unused parameters (especially return parameters) can be omitted. -Those parameters will still be present on the stack, but they are inaccessible. +The names of parameters and return values in the function declaration can be omitted. +Those items with omitted names will still be present on the stack, but they are +inaccessible by name. An omitted return value name +can still return a value to the caller by use of the ``return`` statement. .. code-block:: solidity From ffbb6f159e1e39cbd8fc0994f5ef63f5ec0e4f2d Mon Sep 17 00:00:00 2001 From: aathan Date: Sat, 23 Apr 2022 10:55:34 -0700 Subject: [PATCH 027/109] Update value-types.rst --- docs/types/value-types.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index 6aebdaf4fc..5972ea8182 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -210,6 +210,11 @@ an exception to this rule. declare its type as ``address payable`` to make this requirement visible. Also, try to make this distinction or conversion as early as possible. + The distinction between ``address`` and ``address payable`` was introduced with version 0.5.0. + Also starting from that version, contracts are not implicitly convertible to the ``address`` type, but can still be explicitly converted to + ``address`` or to ``address payable``, if they have a receive or payable fallback function. + + Operators: * ``<=``, ``<``, ``==``, ``!=``, ``>=`` and ``>`` @@ -223,9 +228,7 @@ Operators: or you can use ``address(uint160(uint256(b)))``, which results in ``0x777788889999AaAAbBbbCcccddDdeeeEfFFfCcCc``. .. note:: - The distinction between ``address`` and ``address payable`` was introduced with version 0.5.0. - Also starting from that version, contracts do not derive from the address type, but can still be explicitly converted to - ``address`` or to ``address payable``, if they have a receive or payable fallback function. + Mixed-case hexadecimal numbers conforming to `EIP-55 `_ are automatically treated as literals of the ``address`` type. See :ref:`Address Literals`. .. _members-of-addresses: From 18ce69ebbd51e0e6e25a1638d85a2e766d758196 Mon Sep 17 00:00:00 2001 From: aathan Date: Thu, 24 Mar 2022 10:25:01 -0700 Subject: [PATCH 028/109] Update reference-types.rst --- docs/types/reference-types.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index a9f44d7100..c2b293ba13 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -85,8 +85,10 @@ Data locations are not only relevant for persistency of data, but also for the s // The following does not work; it would need to create a new temporary / // unnamed array in storage, but storage is "statically" allocated: // y = memoryArray; - // This does not work either, since it would "reset" the pointer, but there - // is no sensible location it could point to. + // On the other hand: "delete y" is not valid, as assignments to local variables + // referencing storage objects can only be made from existing storage objects. + // It would "reset" the pointer, but there is no sensible location it could point to. + // See "delete" under Operators // delete y; g(x); // calls g, handing over a reference to x h(x); // calls h and creates an independent, temporary copy in memory From 898ad25aaba84ee4986ab5f3e0001a71aaec796d Mon Sep 17 00:00:00 2001 From: Leo Date: Sat, 13 Aug 2022 13:44:03 +0200 Subject: [PATCH 029/109] Review suggestions --- docs/types/reference-types.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/types/reference-types.rst b/docs/types/reference-types.rst index c2b293ba13..a6b5728c95 100644 --- a/docs/types/reference-types.rst +++ b/docs/types/reference-types.rst @@ -85,10 +85,10 @@ Data locations are not only relevant for persistency of data, but also for the s // The following does not work; it would need to create a new temporary / // unnamed array in storage, but storage is "statically" allocated: // y = memoryArray; - // On the other hand: "delete y" is not valid, as assignments to local variables + // Similarly, "delete y" is not valid, as assignments to local variables // referencing storage objects can only be made from existing storage objects. // It would "reset" the pointer, but there is no sensible location it could point to. - // See "delete" under Operators + // For more details see the documentation of the "delete" operator. // delete y; g(x); // calls g, handing over a reference to x h(x); // calls h and creates an independent, temporary copy in memory From ec4ccf81830b39522fe9074b61fc67bf687954f7 Mon Sep 17 00:00:00 2001 From: minami Date: Thu, 4 Aug 2022 15:51:22 +0900 Subject: [PATCH 030/109] Improve docs of possible function inputs and outputs --- docs/contracts/functions.rst | 26 ++++++++++---------------- docs/layout-of-source-files.rst | 21 ++++++++++++--------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/docs/contracts/functions.rst b/docs/contracts/functions.rst index c7b7cc56b5..f14e4b8a54 100644 --- a/docs/contracts/functions.rst +++ b/docs/contracts/functions.rst @@ -72,16 +72,6 @@ with two integers, you would use something like the following: Function parameters can be used as any other local variable and they can also be assigned to. -.. note:: - - Until version 0.6.0 it was not possible to use a multi-dimensional array or a struct - as an input for an :ref:`external function`. - ``abicoder v2`` made it possible and it's been enabled by default since version 0.8.0 - (before that you had to enable it with ``pragma abicoder v2;``). - - An :ref:`internal function` can accept a - multi-dimensional array or a struct without any restrictions. - .. index:: return array, return string, array, string, array of strings, dynamic array, variably sized array, return struct, struct Return Variables @@ -139,12 +129,16 @@ If you use an early ``return`` to leave a function that has return variables, you must provide return values together with the return statement. .. note:: - You cannot return some types from non-internal functions, notably - multi-dimensional dynamic arrays and structs. If you enable the - ABI coder v2 by adding ``pragma abicoder v2;`` - to your source file then more types are available, but - ``mapping`` types are still limited to inside a single contract and you - cannot transfer them. + You cannot return some types from non-internal functions. + This includes the types listed below and any composite types that recursively contain them: + + - mappings, + - internal function types, + - reference types with location set to ``storage``, + - multi-dimensional arrays (applies only to :ref:`ABI coder v1 `), + - structs (applies only to :ref:`ABI coder v1 `). + + This restriction does not apply to library functions because of their different :ref:`internal ABI `. .. _multi-return: diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index 729951142a..cd231c1fce 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -56,7 +56,7 @@ you have to add the pragma to all your files if you want to enable it in your whole project. If you :ref:`import` another file, the pragma from that file does *not* automatically apply to the importing file. -.. index:: ! pragma, version +.. index:: ! pragma;version .. _version_pragma: @@ -91,6 +91,9 @@ these follow the same syntax used by `npm Date: Sat, 13 Aug 2022 18:39:46 +0530 Subject: [PATCH 031/109] Updated yul.rst with feedback. Updated yul.rst with explanation of 0x60 pointer choice. --- docs/yul.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/yul.rst b/docs/yul.rst index 6156d9ad67..7ce0101699 100644 --- a/docs/yul.rst +++ b/docs/yul.rst @@ -1162,7 +1162,8 @@ An example Yul Object is shown below: code { function allocate(size) -> ptr { ptr := mload(0x40) - if iszero(ptr) { ptr := 0x80 } + // Note that Solidity generated IR code reserves memory offset ``0x60`` as well, but a pure Yul object is free to use memory as it chooses. + if iszero(ptr) { ptr := 0x60 } mstore(0x40, add(ptr, size)) } @@ -1191,6 +1192,7 @@ An example Yul Object is shown below: code { function allocate(size) -> ptr { ptr := mload(0x40) + // Note that Solidity generated IR code reserves memory offset ``0x60`` as well, but a pure Yul object is free to use memory as it chooses. if iszero(ptr) { ptr := 0x60 } mstore(0x40, add(ptr, size)) } From 4682c0192038981184856c1151e6453c0df1dc8a Mon Sep 17 00:00:00 2001 From: Leonid Pospelov Date: Sun, 14 Aug 2022 03:07:01 +0300 Subject: [PATCH 032/109] Update ASTJsonExporter.cpp --- libsolidity/ast/ASTJsonExporter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libsolidity/ast/ASTJsonExporter.cpp b/libsolidity/ast/ASTJsonExporter.cpp index 939fc79c6c..e7e7a01439 100644 --- a/libsolidity/ast/ASTJsonExporter.cpp +++ b/libsolidity/ast/ASTJsonExporter.cpp @@ -37,8 +37,6 @@ #include -#include - #include #include #include @@ -629,7 +627,7 @@ bool ASTJsonExporter::visit(InlineAssembly const& _node) Json::Value externalReferencesJson = Json::arrayValue; - ranges::sort(externalReferences); + std::sort(externalReferences.begin(), externalReferences.end()); for (Json::Value& it: externalReferences | ranges::views::values) externalReferencesJson.append(std::move(it)); From 32aa0003789776f9380a7e0cb80bcc91c012cc57 Mon Sep 17 00:00:00 2001 From: Leonid Pospelov Date: Sun, 14 Aug 2022 03:14:15 +0300 Subject: [PATCH 033/109] Update FullInliner.cpp --- libyul/optimiser/FullInliner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libyul/optimiser/FullInliner.cpp b/libyul/optimiser/FullInliner.cpp index f4a8aee856..9ffe871faf 100644 --- a/libyul/optimiser/FullInliner.cpp +++ b/libyul/optimiser/FullInliner.cpp @@ -224,7 +224,7 @@ bool FullInliner::shallInline(FunctionCall const& _funCall, YulString _callSite) break; } - return (size < (aggressiveInlining ? 8 : 6) || (constantArg && size < (aggressiveInlining ? 16 : 12))); + return (size < (aggressiveInlining ? 8u : 6u) || (constantArg && size < (aggressiveInlining ? 16u : 12u))); } void FullInliner::tentativelyUpdateCodeSize(YulString _function, YulString _callSite) From 5da46581bd71439871843b3833e641176fe6f14c Mon Sep 17 00:00:00 2001 From: Marenz Date: Thu, 21 Jul 2022 17:27:24 +0200 Subject: [PATCH 034/109] Document in ``solc --help`` usage of ``--metadata`` better. --- solc/CommandLineParser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 9b4490875a..319f29de60 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -565,7 +565,7 @@ General Information)").c_str(), ( (g_strOutputDir + ",o").c_str(), po::value()->value_name("path"), - "If given, creates one file per component and contract/file at the specified directory." + "If given, creates one file per output component and contract/file at the specified directory." ) ( g_strOverwrite.c_str(), @@ -718,7 +718,7 @@ General Information)").c_str(), (CompilerOutputs::componentName(&CompilerOutputs::signatureHashes).c_str(), "Function signature hashes of the contracts.") (CompilerOutputs::componentName(&CompilerOutputs::natspecUser).c_str(), "Natspec user documentation of all contracts.") (CompilerOutputs::componentName(&CompilerOutputs::natspecDev).c_str(), "Natspec developer documentation of all contracts.") - (CompilerOutputs::componentName(&CompilerOutputs::metadata).c_str(), "Combined Metadata JSON whose Swarm hash is stored on-chain.") + (CompilerOutputs::componentName(&CompilerOutputs::metadata).c_str(), "Combined Metadata JSON whose IPFS hash is stored on-chain.") (CompilerOutputs::componentName(&CompilerOutputs::storageLayout).c_str(), "Slots, offsets and types of the contract's state variables.") ; desc.add(outputComponents); From 730950fb637c86cb6941ebf3dcf5ec18554618ab Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Mon, 15 Aug 2022 13:45:42 +0200 Subject: [PATCH 035/109] [buildpack] Switch from aarlt/comment-on-pr@v1.2.0 to unsplash/comment-on-pr@v1.3.1. --- .github/workflows/buildpack-deps.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/buildpack-deps.yml b/.github/workflows/buildpack-deps.yml index 535d15239a..f07cdcf409 100644 --- a/.github/workflows/buildpack-deps.yml +++ b/.github/workflows/buildpack-deps.yml @@ -37,6 +37,6 @@ jobs: - name: comment PR if: "env.DOCKER_IMAGE" - uses: aarlt/comment-on-pr@v1.2.0 + uses: unsplash/comment-on-pr@b5610c6125a7197eaec80072ea35ef53e1fc6035 #v1.3.1 with: msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." \ No newline at end of file From e996fe6247d34e28214909504c483c55fc50bf58 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 6 Apr 2022 18:33:42 +0200 Subject: [PATCH 036/109] Yul Optimizer: Simplify start offset of zero-length operations. --- Changelog.md | 1 + libyul/optimiser/DataFlowAnalyzer.cpp | 2 +- libyul/optimiser/DataFlowAnalyzer.h | 2 +- libyul/optimiser/ExpressionSimplifier.cpp | 29 +++++++++++++++++++ libyul/optimiser/ExpressionSimplifier.h | 1 + .../side_effects_in_for_condition.yul | 4 +-- .../expressionSimplifier/zero_length_read.yul | 21 ++++++++++++++ 7 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 test/libyul/yulOptimizerTests/expressionSimplifier/zero_length_read.yul diff --git a/Changelog.md b/Changelog.md index d91eccb314..dfa237e2d6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -8,6 +8,7 @@ Language Features: Compiler Features: * Code Generator: More efficient overflow checks for multiplication. + * Yul Optimizer: Simplify the starting offset of zero-length operations to zero. Bugfixes: diff --git a/libyul/optimiser/DataFlowAnalyzer.cpp b/libyul/optimiser/DataFlowAnalyzer.cpp index 7e98fe5178..ba8e6fb88b 100644 --- a/libyul/optimiser/DataFlowAnalyzer.cpp +++ b/libyul/optimiser/DataFlowAnalyzer.cpp @@ -411,7 +411,7 @@ bool DataFlowAnalyzer::inScope(YulString _variableName) const return false; } -optional DataFlowAnalyzer::valueOfIdentifier(YulString const& _name) +optional DataFlowAnalyzer::valueOfIdentifier(YulString const& _name) const { if (AssignedValue const* value = variableValue(_name)) if (Literal const* literal = get_if(value->value)) diff --git a/libyul/optimiser/DataFlowAnalyzer.h b/libyul/optimiser/DataFlowAnalyzer.h index 4a8cc7445d..b82f437538 100644 --- a/libyul/optimiser/DataFlowAnalyzer.h +++ b/libyul/optimiser/DataFlowAnalyzer.h @@ -148,7 +148,7 @@ class DataFlowAnalyzer: public ASTModifier bool inScope(YulString _variableName) const; /// Returns the literal value of the identifier, if it exists. - std::optional valueOfIdentifier(YulString const& _name); + std::optional valueOfIdentifier(YulString const& _name) const; enum class StoreLoadLocation { Memory = 0, diff --git a/libyul/optimiser/ExpressionSimplifier.cpp b/libyul/optimiser/ExpressionSimplifier.cpp index 8c3a038f10..caf74cfb7a 100644 --- a/libyul/optimiser/ExpressionSimplifier.cpp +++ b/libyul/optimiser/ExpressionSimplifier.cpp @@ -23,7 +23,11 @@ #include #include +#include #include +#include + +#include using namespace std; using namespace solidity; @@ -44,4 +48,29 @@ void ExpressionSimplifier::visit(Expression& _expression) [this](YulString _var) { return variableValue(_var); } )) _expression = match->action().toExpression(debugDataOf(_expression)); + + if (auto* functionCall = get_if(&_expression)) + if (optional instruction = toEVMInstruction(m_dialect, functionCall->functionName.name)) + for (auto op: evmasm::SemanticInformation::readWriteOperations(*instruction)) + if (op.startParameter && op.lengthParameter) + { + Expression& startArgument = functionCall->arguments.at(*op.startParameter); + Expression const& lengthArgument = functionCall->arguments.at(*op.lengthParameter); + if ( + knownToBeZero(lengthArgument) && + !knownToBeZero(startArgument) && + !holds_alternative(startArgument) + ) + startArgument = Literal{debugDataOf(startArgument), LiteralKind::Number, "0"_yulstring, {}}; + } +} + +bool ExpressionSimplifier::knownToBeZero(Expression const& _expression) const +{ + if (auto const* literal = get_if(&_expression)) + return valueOfLiteral(*literal) == 0; + else if (auto const* identifier = get_if(&_expression)) + return valueOfIdentifier(identifier->name) == 0; + else + return false; } diff --git a/libyul/optimiser/ExpressionSimplifier.h b/libyul/optimiser/ExpressionSimplifier.h index 324ff419ad..662c8c3899 100644 --- a/libyul/optimiser/ExpressionSimplifier.h +++ b/libyul/optimiser/ExpressionSimplifier.h @@ -54,6 +54,7 @@ class ExpressionSimplifier: public DataFlowAnalyzer explicit ExpressionSimplifier(Dialect const& _dialect): DataFlowAnalyzer(_dialect, MemoryAndStorage::Ignore) {} + bool knownToBeZero(Expression const& _expression) const; }; } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul index bd567a69a6..9c3a5c8ba2 100644 --- a/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/side_effects_in_for_condition.yul @@ -1,5 +1,5 @@ { - for {} div(create(0, 1, 0), shl(msize(), 1)) {} + for {} div(create(0, 1, 1), shl(msize(), 1)) {} { } } @@ -10,7 +10,7 @@ // // { // { -// for { } div(create(0, 1, 0), shl(msize(), 1)) { } +// for { } div(create(0, 1, 1), shl(msize(), 1)) { } // { } // } // } diff --git a/test/libyul/yulOptimizerTests/expressionSimplifier/zero_length_read.yul b/test/libyul/yulOptimizerTests/expressionSimplifier/zero_length_read.yul new file mode 100644 index 0000000000..ee7464932d --- /dev/null +++ b/test/libyul/yulOptimizerTests/expressionSimplifier/zero_length_read.yul @@ -0,0 +1,21 @@ +{ + revert(calldataload(0), 0) + revert(call(0,0,0,0,0,0,0), 0) + calldatacopy(calldataload(1), calldataload(2), 0) + return(calldataload(3), 0) + codecopy(calldataload(4), calldataload(5), sub(42,42)) +} +// ---- +// step: expressionSimplifier +// +// { +// { +// let _1 := 0 +// revert(0, _1) +// pop(call(_1, _1, _1, _1, _1, _1, _1)) +// revert(0, _1) +// calldatacopy(0, calldataload(2), _1) +// return(0, _1) +// codecopy(0, calldataload(5), 0) +// } +// } From 733b0f63f6c333e110036e2160e07e9ec99922dc Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Thu, 16 Jun 2022 17:08:05 +0200 Subject: [PATCH 037/109] Disable failing chainlink tests. --- test/externalTests/chainlink.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/externalTests/chainlink.sh b/test/externalTests/chainlink.sh index f99dbededb..9f50e1486f 100755 --- a/test/externalTests/chainlink.sh +++ b/test/externalTests/chainlink.sh @@ -92,6 +92,10 @@ function chainlink_test sed -i "s|\(it\)\(('cannot remove a consumer from a nonexistent subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts sed -i "s|\(it\)\(('cannot remove a consumer after it is already removed'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts sed -i "s|\(it\)\(('fails to fulfill without being a valid consumer'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + # TODO: check why these two are needed due to this PR. + sed -i "s|\(it\)\(('cannot fund a nonexistent subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + sed -i "s|\(it\)\(('can cancel a subscription'\)|\1.skip\2|g" test/v0.8/dev/VRFCoordinatorV2Mock.test.ts + # Disable tests with hard-coded gas expectations. sed -i "s|\(it\)\(('not use too much gas \[ @skip-coverage \]'\)|\1.skip\2|g" test/v0.6/FluxAggregator.test.ts From a9c21863d481c3fdc8d0b50b006c7b229818edcd Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Wed, 10 Aug 2022 18:45:38 +0200 Subject: [PATCH 038/109] Update tests. --- .../debug_info_in_yul_and_evm_asm_print_all/output | 2 +- .../output | 2 +- .../output | 2 +- test/cmdlineTests/ir_compiler_subobjects/output | 2 +- .../output | 2 +- .../ir_with_assembly_no_memoryguard_runtime/output | 2 +- .../output.json | 2 +- .../output.json | 2 +- .../output.json | 2 +- test/cmdlineTests/viair_subobjects/output | 2 +- .../abiEncoderV1/abi_encode_calldata_slice.sol | 4 ++-- .../abiEncoderV2/abi_encode_calldata_slice.sol | 4 ++-- .../copying/array_copy_storage_storage_dyn_dyn.sol | 2 +- .../copying/function_type_array_to_storage.sol | 4 ++-- .../semanticTests/array/dynamic_array_cleanup.sol | 2 +- .../array/dynamic_arrays_in_storage.sol | 2 +- .../semanticTests/array/fixed_array_cleanup.sol | 2 +- ...te_array_pop_long_storage_empty_garbage_ref.sol | 2 +- .../semanticTests/array/push/nested_bytes_push.sol | 2 +- .../semanticTests/array/push/push_no_args_2d.sol | 4 ++-- .../array/push/push_no_args_bytes.sol | 2 +- .../events/event_dynamic_array_storage.sol | 2 +- .../events/event_dynamic_array_storage_v2.sol | 2 +- .../event_dynamic_nested_array_storage_v2.sol | 2 +- .../events/event_emit_from_other_contract.sol | 2 +- .../semanticTests/events/event_indexed_string.sol | 2 +- .../externalContracts/FixedFeeRegistrar.sol | 2 +- .../semanticTests/externalContracts/base64.sol | 6 +++--- .../functionCall/gas_and_value_basic.sol | 2 +- .../functionCall/gas_and_value_brace_syntax.sol | 2 +- .../structs/struct_delete_storage_with_array.sol | 2 +- test/libsolidity/semanticTests/structs/structs.sol | 2 +- .../userDefinedValueType/calldata.sol | 2 +- .../various/contract_binary_dependencies.sol | 2 +- .../various/swap_in_storage_overwrite.sol | 2 +- .../viaYul/array_storage_index_access.sol | 14 +++++++------- .../viaYul/array_storage_index_zeroed_test.sol | 8 ++++---- .../viaYul/array_storage_push_empty.sol | 4 ++-- .../viaYul/copy_struct_invalid_ir_bug.sol | 2 +- 39 files changed, 55 insertions(+), 55 deletions(-) diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output index af83c9f36a..115bf34cc2 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_all/output @@ -194,7 +194,7 @@ object "C_6" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output index dc4ea45fd7..33faf3cf19 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_location_only/output @@ -193,7 +193,7 @@ object "C_6" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output index b2ad57c308..3307150233 100644 --- a/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output +++ b/test/cmdlineTests/debug_info_in_yul_and_evm_asm_print_none/output @@ -182,7 +182,7 @@ object "C_6" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/ir_compiler_subobjects/output b/test/cmdlineTests/ir_compiler_subobjects/output index 5cacb6c16b..0a505a4acd 100644 --- a/test/cmdlineTests/ir_compiler_subobjects/output +++ b/test/cmdlineTests/ir_compiler_subobjects/output @@ -71,7 +71,7 @@ object "D_16" { returndatacopy(pos, _2, returndatasize()) revert(pos, returndatasize()) } - return(mload(64), _2) + return(_2, _2) } } revert(0, 0) diff --git a/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output b/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output index 41f353269f..50915c8dc3 100644 --- a/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output +++ b/test/cmdlineTests/ir_with_assembly_no_memoryguard_creation/output @@ -22,7 +22,7 @@ object "D_12" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output index c406d4f7ed..b81febf73d 100644 --- a/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output +++ b/test/cmdlineTests/ir_with_assembly_no_memoryguard_runtime/output @@ -24,7 +24,7 @@ object "D_8" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(128, _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json index 30895c160a..2fe90b70ef 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_all/output.json @@ -199,7 +199,7 @@ object \"C_6\" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json index 6ee9874d38..3600f633c8 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_location_only/output.json @@ -198,7 +198,7 @@ object \"C_6\" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json index a32ee05806..7393f8b444 100644 --- a/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json +++ b/test/cmdlineTests/standard_debug_info_in_yul_and_evm_asm_print_none/output.json @@ -187,7 +187,7 @@ object \"C_6\" { { if callvalue() { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } - return(memoryguard(0x80), _1) + return(_1, _1) } } revert(0, 0) diff --git a/test/cmdlineTests/viair_subobjects/output b/test/cmdlineTests/viair_subobjects/output index 51fdae9244..500472f8a8 100644 --- a/test/cmdlineTests/viair_subobjects/output +++ b/test/cmdlineTests/viair_subobjects/output @@ -83,7 +83,7 @@ object "D_16" { returndatacopy(pos, _2, returndatasize()) revert(pos, returndatasize()) } - return(mload(64), _2) + return(_2, _2) } } revert(0, 0) diff --git a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol index 069c32370e..67680b8527 100644 --- a/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV1/abi_encode_calldata_slice.sol @@ -59,10 +59,10 @@ contract C { // EVMVersion: >homestead // ---- // test_bytes() -> -// gas irOptimized: 362445 +// gas irOptimized: 362400 // gas legacy: 414569 // gas legacyOptimized: 319271 // test_uint256() -> -// gas irOptimized: 511910 +// gas irOptimized: 511919 // gas legacy: 581876 // gas legacyOptimized: 442757 diff --git a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol index 7ebac64ea4..0d2e4f9c07 100644 --- a/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol +++ b/test/libsolidity/semanticTests/abiEncoderV2/abi_encode_calldata_slice.sol @@ -60,10 +60,10 @@ contract C { // EVMVersion: >homestead // ---- // test_bytes() -> -// gas irOptimized: 362445 +// gas irOptimized: 362400 // gas legacy: 414569 // gas legacyOptimized: 319271 // test_uint256() -> -// gas irOptimized: 511910 +// gas irOptimized: 511919 // gas legacy: 581876 // gas legacyOptimized: 442757 diff --git a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol index aa508fe4df..5e12fa657d 100644 --- a/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol +++ b/test/libsolidity/semanticTests/array/copying/array_copy_storage_storage_dyn_dyn.sol @@ -15,7 +15,7 @@ contract c { // ---- // setData1(uint256,uint256,uint256): 10, 5, 4 -> // copyStorageStorage() -> -// gas irOptimized: 111374 +// gas irOptimized: 111368 // gas legacy: 109278 // gas legacyOptimized: 109268 // getData2(uint256): 5 -> 10, 4 diff --git a/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol b/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol index 17c97d2006..1e8760250a 100644 --- a/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol +++ b/test/libsolidity/semanticTests/array/copying/function_type_array_to_storage.sol @@ -46,11 +46,11 @@ contract C { } // ---- // test() -> 0x20, 0x14, "[a called][b called]" -// gas irOptimized: 116688 +// gas irOptimized: 116673 // gas legacy: 119030 // gas legacyOptimized: 117021 // test2() -> 0x20, 0x14, "[b called][a called]" // test3() -> 0x20, 0x14, "[b called][a called]" -// gas irOptimized: 103268 +// gas irOptimized: 103256 // gas legacy: 102814 // gas legacyOptimized: 101706 diff --git a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol index dc11953cd8..4454914a97 100644 --- a/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/dynamic_array_cleanup.sol @@ -14,7 +14,7 @@ contract c { // ---- // storageEmpty -> 1 // fill() -> -// gas irOptimized: 519490 +// gas irOptimized: 519487 // gas legacy: 521584 // gas legacyOptimized: 517027 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol index 32ed7032da..8ff67048c3 100644 --- a/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol +++ b/test/libsolidity/semanticTests/array/dynamic_arrays_in_storage.sol @@ -42,7 +42,7 @@ contract c { // ---- // getLengths() -> 0, 0 // setLengths(uint256,uint256): 48, 49 -> -// gas irOptimized: 111450 +// gas irOptimized: 111448 // gas legacy: 108571 // gas legacyOptimized: 100417 // getLengths() -> 48, 49 diff --git a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol index 5a3116e0cf..310217cfdc 100644 --- a/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol +++ b/test/libsolidity/semanticTests/array/fixed_array_cleanup.sol @@ -12,7 +12,7 @@ contract c { // ---- // storageEmpty -> 1 // fill() -> -// gas irOptimized: 465380 +// gas irOptimized: 465345 // gas legacy: 471280 // gas legacyOptimized: 467500 // storageEmpty -> 0 diff --git a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol index 66fb16775b..ccb4de6e1c 100644 --- a/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol +++ b/test/libsolidity/semanticTests/array/pop/byte_array_pop_long_storage_empty_garbage_ref.sol @@ -15,7 +15,7 @@ contract c { } // ---- // test() -> -// gas irOptimized: 142639 +// gas irOptimized: 142636 // gas legacy: 164430 // gas legacyOptimized: 158513 // storageEmpty -> 1 diff --git a/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol b/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol index 8a962ad43f..71a21820d2 100644 --- a/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol +++ b/test/libsolidity/semanticTests/array/push/nested_bytes_push.sol @@ -13,6 +13,6 @@ contract C { } // ---- // f() -> -// gas irOptimized: 179173 +// gas irOptimized: 179170 // gas legacy: 181066 // gas legacyOptimized: 180435 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol index a99d30b415..e9a521fbff 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_2d.sol @@ -27,14 +27,14 @@ contract C { // ---- // l() -> 0 // f(uint256,uint256): 42, 64 -> -// gas irOptimized: 112482 +// gas irOptimized: 112476 // gas legacy: 108105 // gas legacyOptimized: 101987 // l() -> 1 // ll(uint256): 0 -> 43 // a(uint256,uint256): 0, 42 -> 64 // f(uint256,uint256): 84, 128 -> -// gas irOptimized: 116270 +// gas irOptimized: 116264 // gas legacy: 107525 // gas legacyOptimized: 96331 // l() -> 2 diff --git a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol index 3c7b8b44bb..6027558455 100644 --- a/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol +++ b/test/libsolidity/semanticTests/array/push/push_no_args_bytes.sol @@ -21,7 +21,7 @@ contract C { // ---- // l() -> 0 // g(uint256): 70 -> -// gas irOptimized: 183587 +// gas irOptimized: 183584 // gas legacy: 183811 // gas legacyOptimized: 179218 // l() -> 70 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol index f0bd89903b..f9f06134fe 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_storage.sol @@ -13,6 +13,6 @@ contract C { // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c -// gas irOptimized: 113514 +// gas irOptimized: 113511 // gas legacy: 116381 // gas legacyOptimized: 114425 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol index b8553d4b49..a2862d6897 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_array_storage_v2.sol @@ -14,6 +14,6 @@ contract C { // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[]): 0x20, 0x03, 0x2a, 0x2b, 0x2c -// gas irOptimized: 113514 +// gas irOptimized: 113511 // gas legacy: 116381 // gas legacyOptimized: 114425 diff --git a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol index bab70e69b7..a625e3de33 100644 --- a/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol +++ b/test/libsolidity/semanticTests/events/event_dynamic_nested_array_storage_v2.sol @@ -15,6 +15,6 @@ contract C { // ---- // createEvent(uint256): 42 -> // ~ emit E(uint256[][]): 0x20, 0x02, 0x40, 0xa0, 0x02, 0x2a, 0x2b, 0x02, 0x2c, 0x2d -// gas irOptimized: 185145 +// gas irOptimized: 185142 // gas legacy: 187603 // gas legacyOptimized: 184566 diff --git a/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol b/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol index 2626a3b00f..300efd739c 100644 --- a/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol +++ b/test/libsolidity/semanticTests/events/event_emit_from_other_contract.sol @@ -15,7 +15,7 @@ contract C { } // ---- // constructor() -> -// gas irOptimized: 167934 +// gas irOptimized: 166854 // gas legacy: 250376 // gas legacyOptimized: 174522 // deposit(bytes32), 18 wei: 0x1234 -> diff --git a/test/libsolidity/semanticTests/events/event_indexed_string.sol b/test/libsolidity/semanticTests/events/event_indexed_string.sol index 1ef41edb7e..08dd7ce66e 100644 --- a/test/libsolidity/semanticTests/events/event_indexed_string.sol +++ b/test/libsolidity/semanticTests/events/event_indexed_string.sol @@ -17,6 +17,6 @@ contract C { // ---- // deposit() -> // ~ emit E(string,uint256[4]): #0xa7fb06bb999a5eb9aff9e0779953f4e1e4ce58044936c2f51c7fb879b85c08bd, #0xe755d8cc1a8cde16a2a31160dcd8017ac32d7e2f13215b29a23cdae40a78aa81 -// gas irOptimized: 333479 +// gas irOptimized: 333476 // gas legacy: 388679 // gas legacyOptimized: 374441 diff --git a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol index b56ec7801f..d281d6f273 100644 --- a/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol +++ b/test/libsolidity/semanticTests/externalContracts/FixedFeeRegistrar.sol @@ -74,7 +74,7 @@ contract FixedFeeRegistrar is Registrar { } // ---- // constructor() -// gas irOptimized: 411435 +// gas irOptimized: 415761 // gas legacy: 933867 // gas legacyOptimized: 487352 // reserve(string), 69 ether: 0x20, 3, "abc" -> diff --git a/test/libsolidity/semanticTests/externalContracts/base64.sol b/test/libsolidity/semanticTests/externalContracts/base64.sol index de5def9958..5133da878f 100644 --- a/test/libsolidity/semanticTests/externalContracts/base64.sol +++ b/test/libsolidity/semanticTests/externalContracts/base64.sol @@ -33,7 +33,7 @@ contract test { // EVMVersion: >=constantinople // ---- // constructor() -// gas irOptimized: 438352 +// gas irOptimized: 438376 // gas legacy: 750723 // gas legacyOptimized: 536620 // encode_inline_asm(bytes): 0x20, 0 -> 0x20, 0 @@ -51,10 +51,10 @@ contract test { // encode_no_asm(bytes): 0x20, 5, "fooba" -> 0x20, 8, "Zm9vYmE=" // encode_no_asm(bytes): 0x20, 6, "foobar" -> 0x20, 8, "Zm9vYmFy" // encode_inline_asm_large() -// gas irOptimized: 1387042 +// gas irOptimized: 1387039 // gas legacy: 1688033 // gas legacyOptimized: 1205033 // encode_no_asm_large() -// gas irOptimized: 3316099 +// gas irOptimized: 3316107 // gas legacy: 4765077 // gas legacyOptimized: 2908077 diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol index 49e841690b..977f1a56a4 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_basic.sol @@ -39,7 +39,7 @@ contract test { // ---- // constructor(), 20 wei -> -// gas irOptimized: 262130 +// gas irOptimized: 261698 // gas legacy: 402654 // gas legacyOptimized: 274470 // sendAmount(uint256): 5 -> 5 diff --git a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol index 4fbcaf1beb..48365a61ac 100644 --- a/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol +++ b/test/libsolidity/semanticTests/functionCall/gas_and_value_brace_syntax.sol @@ -38,7 +38,7 @@ contract test { // ---- // constructor(), 20 wei -> -// gas irOptimized: 262130 +// gas irOptimized: 261698 // gas legacy: 402654 // gas legacyOptimized: 274470 // sendAmount(uint256): 5 -> 5 diff --git a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol index a78b5dd65b..15acf7a2fb 100644 --- a/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol +++ b/test/libsolidity/semanticTests/structs/struct_delete_storage_with_array.sol @@ -42,7 +42,7 @@ contract C { } // ---- // f() -> -// gas irOptimized: 121660 +// gas irOptimized: 121657 // gas legacy: 122132 // gas legacyOptimized: 121500 // g() -> diff --git a/test/libsolidity/semanticTests/structs/structs.sol b/test/libsolidity/semanticTests/structs/structs.sol index a4cafdb0f2..ada5534ca5 100644 --- a/test/libsolidity/semanticTests/structs/structs.sol +++ b/test/libsolidity/semanticTests/structs/structs.sol @@ -30,7 +30,7 @@ contract test { // ---- // check() -> false // set() -> -// gas irOptimized: 134433 +// gas irOptimized: 134436 // gas legacy: 135277 // gas legacyOptimized: 134064 // check() -> true diff --git a/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol b/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol index c532603b67..fe7ea4596a 100644 --- a/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol +++ b/test/libsolidity/semanticTests/userDefinedValueType/calldata.sol @@ -49,7 +49,7 @@ contract C { } // ---- // test_f() -> true -// gas irOptimized: 122070 +// gas irOptimized: 122053 // gas legacy: 126150 // gas legacyOptimized: 123163 // test_g() -> true diff --git a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol index 351428c4f1..561e316880 100644 --- a/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol +++ b/test/libsolidity/semanticTests/various/contract_binary_dependencies.sol @@ -20,4 +20,4 @@ contract C { // compileToEwasm: also // ---- // constructor() -> -// gas irOptimized: 101063 +// gas irOptimized: 100415 diff --git a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol index 713d711969..129a78931f 100644 --- a/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol +++ b/test/libsolidity/semanticTests/various/swap_in_storage_overwrite.sol @@ -29,7 +29,7 @@ contract c { // x() -> 0, 0 // y() -> 0, 0 // set() -> -// gas irOptimized: 109694 +// gas irOptimized: 109691 // gas legacy: 109732 // gas legacyOptimized: 109682 // x() -> 1, 2 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol index 4dd06e9984..8ef60a53b5 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_access.sol @@ -16,33 +16,33 @@ contract C { // ---- // test_indices(uint256): 1 -> // test_indices(uint256): 129 -> -// gas irOptimized: 3018687 +// gas irOptimized: 3018684 // gas legacy: 3068883 // gas legacyOptimized: 3011615 // test_indices(uint256): 5 -> -// gas irOptimized: 372543 +// gas irOptimized: 372540 // gas legacy: 369151 // gas legacyOptimized: 366139 // test_indices(uint256): 10 -> // test_indices(uint256): 15 -> // gas irOptimized: 72860 // test_indices(uint256): 0xFF -> -// gas irOptimized: 3410255 +// gas irOptimized: 3410252 // gas legacy: 3509577 // gas legacyOptimized: 3397597 // test_indices(uint256): 1000 -> -// gas irOptimized: 18206122 +// gas irOptimized: 18206119 // gas legacy: 18599999 // gas legacyOptimized: 18176944 // test_indices(uint256): 129 -> -// gas irOptimized: 2756955 +// gas irOptimized: 2756952 // gas legacy: 2770413 // gas legacyOptimized: 2716289 // test_indices(uint256): 128 -> -// gas irOptimized: 411903 +// gas irOptimized: 411900 // gas legacy: 464968 // gas legacyOptimized: 418168 // test_indices(uint256): 1 -> -// gas irOptimized: 368571 +// gas irOptimized: 368568 // gas legacy: 363389 // gas legacyOptimized: 361809 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol index 8b83e1807b..b1bcd82733 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_index_zeroed_test.sol @@ -52,18 +52,18 @@ contract C { // ---- // test_zeroed_indicies(uint256): 1 -> // test_zeroed_indicies(uint256): 5 -> -// gas irOptimized: 131177 +// gas irOptimized: 131174 // gas legacy: 132301 // gas legacyOptimized: 129539 // test_zeroed_indicies(uint256): 10 -> -// gas irOptimized: 174780 +// gas irOptimized: 174777 // gas legacy: 177188 // gas legacyOptimized: 172112 // test_zeroed_indicies(uint256): 15 -> -// gas irOptimized: 198025 +// gas irOptimized: 198022 // gas legacy: 201738 // gas legacyOptimized: 194427 // test_zeroed_indicies(uint256): 0xFF -> -// gas irOptimized: 6097915 +// gas irOptimized: 6097912 // gas legacy: 6159333 // gas legacyOptimized: 6026177 diff --git a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol index 7f402d7d13..270b92ffaf 100644 --- a/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol +++ b/test/libsolidity/semanticTests/viaYul/array_storage_push_empty.sol @@ -12,11 +12,11 @@ contract C { // EVMVersion: >=petersburg // ---- // pushEmpty(uint256): 128 -// gas irOptimized: 406801 +// gas irOptimized: 406798 // gas legacy: 416903 // gas legacyOptimized: 398280 // pushEmpty(uint256): 256 -// gas irOptimized: 691029 +// gas irOptimized: 691026 // gas legacy: 714315 // gas legacyOptimized: 687372 // pushEmpty(uint256): 38869 -> FAILURE # out-of-gas # diff --git a/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol b/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol index de367f8daa..502e4bde17 100644 --- a/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol +++ b/test/libsolidity/semanticTests/viaYul/copy_struct_invalid_ir_bug.sol @@ -21,6 +21,6 @@ contract C { } // ---- // f() -> -// gas irOptimized: 112999 +// gas irOptimized: 113019 // gas legacy: 112931 // gas legacyOptimized: 112602 From ee2c4cddcd3dc5ff4c24982966eb9e97c146c87b Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Mon, 15 Aug 2022 17:37:08 +0200 Subject: [PATCH 039/109] test/cmdlineTests.sh: fix verbosity. --- test/cmdlineTests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 79e9d64a58..7728f1f6de 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -311,7 +311,7 @@ function test_solc_assembly_output function test_via_ir_equivalence() { SOLTMPDIR=$(mktemp -d) - pushd "$SOLTMPDIR" + pushd "$SOLTMPDIR" > /dev/null (( $# <= 2 )) || fail "This function accepts at most two arguments." @@ -369,7 +369,7 @@ function test_via_ir_equivalence() diff_values "$bin_output_two_stage" "$bin_output_via_ir" --ignore-space-change --ignore-blank-lines - popd + popd > /dev/null rm -r "$SOLTMPDIR" } From b08454e49ddf1c35ef0f2edf4c93221f78db0687 Mon Sep 17 00:00:00 2001 From: minami Date: Tue, 16 Aug 2022 01:12:43 +0900 Subject: [PATCH 040/109] Remove callcode in heading --- docs/introduction-to-smart-contracts.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index ad98047cf7..ef5e55b2a0 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -504,9 +504,9 @@ operations, loops should be preferred over recursive calls. Furthermore, only 63/64th of the gas can be forwarded in a message call, which causes a depth limit of a little less than 1000 in practice. -.. index:: delegatecall, callcode, library +.. index:: delegatecall, library -Delegatecall / Callcode and Libraries +Delegatecall and Libraries ===================================== There exists a special variant of a message call, named **delegatecall** From 1706db2776108bd6bfbd8c34e8391e17dc051e0d Mon Sep 17 00:00:00 2001 From: minami Date: Tue, 16 Aug 2022 01:15:29 +0900 Subject: [PATCH 041/109] Fix underline --- docs/introduction-to-smart-contracts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index ef5e55b2a0..6a31a95045 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -507,7 +507,7 @@ depth limit of a little less than 1000 in practice. .. index:: delegatecall, library Delegatecall and Libraries -===================================== +========================== There exists a special variant of a message call, named **delegatecall** which is identical to a message call apart from the fact that From 0400b435b87763c72f0c7a03a7fa5b2016e637e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 16 Aug 2022 10:05:14 +0200 Subject: [PATCH 042/109] Enable highlighting for more code blocks in the docs --- docs/internals/layout_in_storage.rst | 6 +++--- docs/introduction-to-smart-contracts.rst | 4 +++- docs/natspec-format.rst | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/internals/layout_in_storage.rst b/docs/internals/layout_in_storage.rst index 599cd03d3e..53670eeb85 100644 --- a/docs/internals/layout_in_storage.rst +++ b/docs/internals/layout_in_storage.rst @@ -153,7 +153,7 @@ the :ref:`standard JSON interface `. The output is a JSON object element has the following form: -.. code:: +.. code-block:: json { @@ -181,7 +181,7 @@ The given ``type``, in this case ``t_uint256`` represents an element in ``types``, which has the form: -.. code:: +.. code-block:: json { "encoding": "inplace", @@ -238,7 +238,7 @@ value and reference types, types that are encoded packed, and nested types. bytes b1; } -.. code:: json +.. code-block:: json { "storage": [ diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 6a31a95045..875e5ebc86 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -186,7 +186,9 @@ transactions. To listen for this event, you could use the following JavaScript code, which uses `web3.js `_ to create the ``Coin`` contract object, -and any user interface calls the automatically generated ``balances`` function from above:: +and any user interface calls the automatically generated ``balances`` function from above: + +.. code-block:: javascript Coin.Sent().watch({}, '', function(error, result) { if (!error) { diff --git a/docs/natspec-format.rst b/docs/natspec-format.rst index a66c104629..28848dae43 100644 --- a/docs/natspec-format.rst +++ b/docs/natspec-format.rst @@ -183,7 +183,7 @@ other to be used by the developer. If the above contract is saved as ``ex1.sol`` then you can generate the documentation using: -.. code:: +.. code-block:: shell solc --userdoc --devdoc ex1.sol @@ -202,7 +202,7 @@ User Documentation The above documentation will produce the following user documentation JSON file as output: -.. code:: +.. code-block:: json { "version" : 1, @@ -230,7 +230,7 @@ Developer Documentation Apart from the user documentation file, a developer documentation JSON file should also be produced and should look like this: -.. code:: +.. code-block:: json { "version" : 1, From 6b6cfa17950cc31dd22853bad4a2aedadc0cea4a Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Tue, 16 Aug 2022 16:43:13 +0200 Subject: [PATCH 043/109] Peg hardhat-ethers version --- test/externalTests/gnosis.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/externalTests/gnosis.sh b/test/externalTests/gnosis.sh index 03d7111873..af2b12508a 100755 --- a/test/externalTests/gnosis.sh +++ b/test/externalTests/gnosis.sh @@ -106,6 +106,11 @@ function gnosis_safe_test # pulls @ethersproject/contracts@5.6.1 (latest). Force 5.6.0 to avoid errors due to having two copies. npm install @ethersproject/contracts@5.6.0 + # 2.1.1 started causing failures in safe-contracts external tests after a contract address check was introduced + # in https://github.com/NomicFoundation/hardhat/pull/2916, and so to avoid errors, the package is now pegged. + # TODO: Remove when https://github.com/safe-global/safe-contracts/issues/436 is resolved. + npm install @nomiclabs/hardhat-ethers@2.1.0 + # Hardhat 2.9.5 introduced a bug with handling padded arguments to getStorageAt(). # TODO: Remove when https://github.com/NomicFoundation/hardhat/issues/2709 is fixed. npm install hardhat@2.9.4 From cf3bae0839b4fc6966743335a89488f313ff07b5 Mon Sep 17 00:00:00 2001 From: wechman Date: Tue, 16 Aug 2022 12:34:17 +0200 Subject: [PATCH 044/109] Fix "slot" access via mapping reference in assembly --- libsolidity/ast/Types.cpp | 5 +++ libsolidity/ast/Types.h | 2 ++ .../codegen/ir/IRGeneratorForStatements.cpp | 3 +- .../slot_access_via_mapping_pointer.sol | 32 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 test/libsolidity/semanticTests/inlineAssembly/slot_access_via_mapping_pointer.sol diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index f88d1afcef..6f37257fa2 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -3789,6 +3789,11 @@ TypeResult MappingType::interfaceType(bool _inLibrary) const return this; } +std::vector> MappingType::makeStackItems() const +{ + return {std::make_tuple("slot", TypeProvider::uint256())}; +} + string TypeType::richIdentifier() const { return "t_type" + identifierList(actualType()); diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 553af6c7d0..735bd69025 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -1528,6 +1528,8 @@ class MappingType: public CompositeType bool hasSimpleZeroValueInMemory() const override { solAssert(false, ""); } bool nameable() const override { return true; } + std::vector> makeStackItems() const override; + Type const* keyType() const { return m_keyType; } Type const* valueType() const { return m_valueType; } diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 5eaeed743b..c67bd65c4e 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -173,10 +173,9 @@ struct CopyTranslate: public yul::ASTCopier { solAssert(suffix == "slot" || suffix == "offset"); solAssert(varDecl->isLocalVariable()); + solAssert(!varDecl->type()->isValueType()); if (suffix == "slot") value = IRVariable{*varDecl}.part("slot").name(); - else if (varDecl->type()->isValueType()) - value = IRVariable{*varDecl}.part("offset").name(); else { solAssert(!IRVariable{*varDecl}.hasPart("offset")); diff --git a/test/libsolidity/semanticTests/inlineAssembly/slot_access_via_mapping_pointer.sol b/test/libsolidity/semanticTests/inlineAssembly/slot_access_via_mapping_pointer.sol new file mode 100644 index 0000000000..66f592bb67 --- /dev/null +++ b/test/libsolidity/semanticTests/inlineAssembly/slot_access_via_mapping_pointer.sol @@ -0,0 +1,32 @@ +contract C { + mapping(uint => uint) private m0; + mapping(uint => uint) private m1; + mapping(uint => uint) private m2; + + function f(uint i) public returns (uint slot, uint offset) { + mapping(uint => uint) storage m0Ptr = m0; + mapping(uint => uint) storage m1Ptr = m1; + mapping(uint => uint) storage m2Ptr = m2; + + assembly { + switch i + case 1 { + slot := m1Ptr.slot + offset := m1Ptr.offset + } + case 2 { + slot := m2Ptr.slot + offset := m2Ptr.offset + } + default { + slot := m0Ptr.slot + offset := m0Ptr.offset + } + } + } +} + +// ---- +// f(uint256): 0 -> 0, 0 +// f(uint256): 1 -> 1, 0 +// f(uint256): 2 -> 2, 0 From 1b5332c2b95fd21ae7b172b1c31f870de84de863 Mon Sep 17 00:00:00 2001 From: Marenz Date: Thu, 18 Aug 2022 13:43:16 +0200 Subject: [PATCH 045/109] Fix spelling mistakes and CI spellcheck job --- .circleci/config.yml | 2 +- libevmasm/KnownState.h | 2 +- liblangutil/Scanner.cpp | 2 +- libsolutil/StringUtils.h | 2 +- scripts/codespell_ignored_lines.txt | 20 +++++++++++++++++++ scripts/codespell_whitelist.txt | 13 ------------ test/externalTests/README.md | 2 +- test/libevmasm/Optimiser.cpp | 4 ++-- test/liblangutil/Scanner.cpp | 12 +++++------ .../SolidityExpressionCompiler.cpp | 2 +- .../_prbmath/PRBMathCommon.sol | 2 +- .../_prbmath/PRBMathUD60x18.sol | 2 +- 12 files changed, 36 insertions(+), 29 deletions(-) create mode 100644 scripts/codespell_ignored_lines.txt diff --git a/.circleci/config.yml b/.circleci/config.yml index 510341ef54..9717567ef1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -652,7 +652,7 @@ jobs: pip install --user codespell - run: name: Check spelling - command: ~/.local/bin/codespell -S "*.enc,.git,Dockerfile*" -I ./scripts/codespell_whitelist.txt + command: ~/.local/bin/codespell -S "*.enc,.git,Dockerfile*,LICENSE,codespell_whitelist.txt,codespell_ignored_lines.txt" -I ./scripts/codespell_whitelist.txt -x ./scripts/codespell_ignored_lines.txt - gitter_notify_failure_unless_pr chk_docs_examples: diff --git a/libevmasm/KnownState.h b/libevmasm/KnownState.h index 7231706104..8c28fbb622 100644 --- a/libevmasm/KnownState.h +++ b/libevmasm/KnownState.h @@ -132,7 +132,7 @@ class KnownState /// @returns true if the knowledge about the state of both objects is (known to be) equal. bool operator==(KnownState const& _other) const; - /// Retrieves the current equivalence class fo the given stack element (or generates a new + /// Retrieves the current equivalence class for the given stack element (or generates a new /// one if it does not exist yet). Id stackElement(int _stackHeight, langutil::SourceLocation const& _location); /// @returns the stackElement relative to the current stack height. diff --git a/liblangutil/Scanner.cpp b/liblangutil/Scanner.cpp index 819dafaf5d..d769a93631 100644 --- a/liblangutil/Scanner.cpp +++ b/liblangutil/Scanner.cpp @@ -425,7 +425,7 @@ Token Scanner::scanMultiLineDocComment() while (!isSourcePastEndOfInput()) { - //handle newlines in multline comments + // handle newlines in multiline comments if (atEndOfLine()) { skipWhitespace(); diff --git a/libsolutil/StringUtils.h b/libsolutil/StringUtils.h index a50d679e84..d7e1238509 100644 --- a/libsolutil/StringUtils.h +++ b/libsolutil/StringUtils.h @@ -206,7 +206,7 @@ inline std::string formatNumberReadable( } } -/// Safely converts an usigned integer as string into an unsigned int type. +/// Safely converts an unsigned integer as string into an unsigned int type. /// /// @return the converted number or nullopt in case of an failure (including if it would not fit). inline std::optional toUnsignedInt(std::string const& _value) diff --git a/scripts/codespell_ignored_lines.txt b/scripts/codespell_ignored_lines.txt new file mode 100644 index 0000000000..b7987cc001 --- /dev/null +++ b/scripts/codespell_ignored_lines.txt @@ -0,0 +1,20 @@ + A constant BT = BU; + A constant BU = BV; + A constant FN = FO; + A constant FO = FP; + struct BT { BU m; } + struct BU { BV m; } + struct FN { FO m; } + struct FO { FP m; } +// encode_inline_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8=" +// encode_no_asm(bytes): 0x20, 2, "fo" -> 0x20, 4, "Zm8=" + BOOST_TEST(mutation(chromosome) == Chromosome("fo")); +docker run --rm -v "${OUTPUTDIR}":/tmp/output -v "${SCRIPTDIR}":/tmp/scripts:ro -it trzeci/emscripten:sdk-tag-1.39.3-64bit /tmp/scripts/docker-scripts/rebuild_tags.sh "${TAGS}" /tmp/output "$@" + + + + templ("assignEnd", dynamic ? "end := pos" : ""); + templ("assignEnd", dynamic ? "end := pos" : ""); + templ("assignEnd", "end := pos"); + templ("assignEnd", "end := tail"); + templ("assignEnd", ""); diff --git a/scripts/codespell_whitelist.txt b/scripts/codespell_whitelist.txt index 0350608666..7de8a42fe5 100644 --- a/scripts/codespell_whitelist.txt +++ b/scripts/codespell_whitelist.txt @@ -1,16 +1,3 @@ -iff nd -assignend -uint -mut -BA -FO -ba -fo compilability -errorstring -hist -otion keypair -ether -sur diff --git a/test/externalTests/README.md b/test/externalTests/README.md index 76e39a79b0..8df5b4dfe0 100644 --- a/test/externalTests/README.md +++ b/test/externalTests/README.md @@ -79,7 +79,7 @@ The above is the workflow to use when the update is straightforward and looks sa fine to just modify the branches directly. If this is not the case, it is recommended to first perform the operation on copies of these version-specific branches and test them by creating PRs on `develop` and `breaking` to see if tests pass. The PRs should just modify project scripts in `test/externalScripts/` -to use the updated copies of the branches and can be discarded aferwards without being merged. +to use the updated copies of the branches and can be discarded afterwards without being merged. #### Changes needed after a breaking release of the compiler When a non-backwards-compatible version becomes the most recent release, `breaking` branch diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index aaf5498ec1..f08f227cb3 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -714,10 +714,10 @@ BOOST_AUTO_TEST_CASE(cse_keccak256_twice_same_content_noninterfering_store_in_be Instruction::MSTORE, // m[12] = DUP1 Instruction::DUP12, u256(12 + 32), - Instruction::MSTORE, // does not destoy memory knowledge + Instruction::MSTORE, // does not destroy memory knowledge Instruction::DUP13, u256(128 - 32), - Instruction::MSTORE, // does not destoy memory knowledge + Instruction::MSTORE, // does not destroy memory knowledge u256(0x20), u256(12), Instruction::KECCAK256 // keccak256(m[12..(12+32)]) diff --git a/test/liblangutil/Scanner.cpp b/test/liblangutil/Scanner.cpp index c8a88ec820..c288ed8543 100644 --- a/test/liblangutil/Scanner.cpp +++ b/test/liblangutil/Scanner.cpp @@ -329,7 +329,7 @@ BOOST_AUTO_TEST_CASE(trailing_dot_in_numbers) BOOST_AUTO_TEST_CASE(leading_underscore_decimal_is_identifier) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("_1.2", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Identifier); @@ -339,7 +339,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_decimal_is_identifier) BOOST_AUTO_TEST_CASE(leading_underscore_decimal_after_dot_illegal) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. TestScanner scanner("1._2"); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); @@ -351,7 +351,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_decimal_after_dot_illegal) BOOST_AUTO_TEST_CASE(leading_underscore_exp_are_identifier) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("_1e2", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Identifier); @@ -360,7 +360,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_exp_are_identifier) BOOST_AUTO_TEST_CASE(leading_underscore_exp_after_e_illegal) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("1e_2", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); @@ -379,7 +379,7 @@ BOOST_AUTO_TEST_CASE(leading_underscore_hex_illegal) BOOST_AUTO_TEST_CASE(fixed_number_invalid_underscore_front) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. CharStream stream("12._1234_1234", ""); Scanner scanner(stream); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); @@ -388,7 +388,7 @@ BOOST_AUTO_TEST_CASE(fixed_number_invalid_underscore_front) BOOST_AUTO_TEST_CASE(number_literals_with_trailing_underscore_at_eos) { - // Actual error is cought by SyntaxChecker. + // Actual error is caught by SyntaxChecker. TestScanner scanner("0x123_"); BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Number); BOOST_CHECK_EQUAL(scanner.next(), Token::EOS); diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 4fef140e8f..2741290fc3 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -168,7 +168,7 @@ bytes compileFirstExpression( )); context.appendMissingLowLevelFunctions(); - // NOTE: We intentionally disable optimisations for utility functions to simplfy the tests + // NOTE: We intentionally disable optimisations for utility functions to simplify the tests context.appendYulUtilityFunctions({}); BOOST_REQUIRE(context.appendYulUtilityFunctionsRan()); diff --git a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol index 923b54c2d2..9ec351b6c4 100644 --- a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol +++ b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathCommon.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0; /// @dev Common mathematical functions used in both PRBMathSD59x18 and PRBMathUD60x18. Note that this shared library /// does not always assume the signed 59.18-decimal fixed-point or the unsigned 60.18-decimal fixed-point -// representation. When it does not, it is annonated in the function's NatSpec documentation. +// representation. When it does not, it is annotated in the function's NatSpec documentation. library PRBMathCommon { /// @dev How many trailing decimals can be represented. uint256 internal constant SCALE = 1e18; diff --git a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol index 2732d95b62..0313481f62 100644 --- a/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol +++ b/test/libsolidity/semanticTests/externalContracts/_prbmath/PRBMathUD60x18.sol @@ -28,7 +28,7 @@ library PRBMathUD60x18 { /// @notice Calculates arithmetic average of x and y, rounding down. /// @param x The first operand as an unsigned 60.18-decimal fixed-point number. /// @param y The second operand as an unsigned 60.18-decimal fixed-point number. - /// @return result The arithmetic average as an usigned 60.18-decimal fixed-point number. + /// @return result The arithmetic average as an unsigned 60.18-decimal fixed-point number. function avg(uint256 x, uint256 y) internal pure returns (uint256 result) { // The operations can never overflow. unchecked { From 4addf1e0ade6d7b2d6d03660c98f354ef250a166 Mon Sep 17 00:00:00 2001 From: Alexander Arlt Date: Mon, 15 Aug 2022 19:32:38 +0200 Subject: [PATCH 046/109] [buildpack] Switch to unsplash/comment-on-pr@v1.3.0. --- .github/workflows/buildpack-deps.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/buildpack-deps.yml b/.github/workflows/buildpack-deps.yml index f07cdcf409..e2da2cdea8 100644 --- a/.github/workflows/buildpack-deps.yml +++ b/.github/workflows/buildpack-deps.yml @@ -37,6 +37,9 @@ jobs: - name: comment PR if: "env.DOCKER_IMAGE" - uses: unsplash/comment-on-pr@b5610c6125a7197eaec80072ea35ef53e1fc6035 #v1.3.1 + # NOTE: Can't update to v1.3.1 due to an error: `/entrypoint.sh:5:in 'require_relative': cannot load such file -- /lib/github (LoadError)` + uses: unsplash/comment-on-pr@ffe8f97ccc63ce12c3c23c6885b169db67958d3b #v1.3.0 with: - msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." \ No newline at end of file + msg: "`${{ env.DOCKER_IMAGE }} ${{ env.DOCKER_REPO_DIGEST }}`." + check_for_duplicate_msg: false + From 542ce5ad95e6a41cf12f715824dcb2b07caf2d74 Mon Sep 17 00:00:00 2001 From: Marenz Date: Thu, 18 Aug 2022 15:28:12 +0200 Subject: [PATCH 047/109] Use long option for spellchecker in CI --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9717567ef1..0b146ca0e7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -652,7 +652,7 @@ jobs: pip install --user codespell - run: name: Check spelling - command: ~/.local/bin/codespell -S "*.enc,.git,Dockerfile*,LICENSE,codespell_whitelist.txt,codespell_ignored_lines.txt" -I ./scripts/codespell_whitelist.txt -x ./scripts/codespell_ignored_lines.txt + command: ~/.local/bin/codespell --skip "*.enc,.git,Dockerfile*,LICENSE,codespell_whitelist.txt,codespell_ignored_lines.txt" --ignore-words ./scripts/codespell_whitelist.txt --exclude-file ./scripts/codespell_ignored_lines.txt - gitter_notify_failure_unless_pr chk_docs_examples: From 0e2ab0500092dfb4c2ca6990b3a31e573be991b4 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 13 Jun 2022 15:50:59 +0200 Subject: [PATCH 048/109] libsolutil: Adding findFilesRecursively() helper to find files recursively. --- libsolutil/CommonIO.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/libsolutil/CommonIO.h b/libsolutil/CommonIO.h index e6cd0c1616..56f62f0ac4 100644 --- a/libsolutil/CommonIO.h +++ b/libsolutil/CommonIO.h @@ -48,6 +48,46 @@ inline std::ostream& operator<<(std::ostream& os, bytes const& _bytes) namespace util { +namespace detail +{ + +template +struct RecursiveFileCollector +{ + Predicate predicate; + std::vector result {}; + + RecursiveFileCollector& operator()(boost::filesystem::path const& _directory) + { + if (!boost::filesystem::is_directory(_directory)) + return *this; + auto iterator = boost::filesystem::directory_iterator(_directory); + auto const iteratorEnd = boost::filesystem::directory_iterator(); + + while (iterator != iteratorEnd) + { + if (boost::filesystem::is_directory(iterator->status())) + (*this)(iterator->path()); + + if (predicate(iterator->path())) + result.push_back(iterator->path()); + + ++iterator; + } + return *this; + } +}; + +template +RecursiveFileCollector(Predicate) -> RecursiveFileCollector; +} + +template +std::vector findFilesRecursively(boost::filesystem::path const& _rootDirectory, Predicate _predicate) +{ + return detail::RecursiveFileCollector{_predicate}(_rootDirectory).result; +} + /// Retrieves and returns the contents of the given file as a std::string. /// If the file doesn't exist, it will throw a FileNotFound exception. /// If the file exists but is not a regular file, it will throw NotAFile exception. From b6ba43234e497ced4e14356207d8c621d3803c04 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 13 Jun 2022 15:56:55 +0200 Subject: [PATCH 049/109] lsp: Always load all solidity files from project for analyzing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil Śliwak --- Changelog.md | 1 + libsolidity/lsp/FileRepository.cpp | 6 ++ libsolidity/lsp/LanguageServer.cpp | 65 ++++++++++++++++- libsolidity/lsp/LanguageServer.h | 22 ++++++ libsolidity/lsp/Transport.cpp | 3 + libsolutil/CommonIO.h | 40 ----------- .../lsp/analyze-full-project/C.sol | 6 ++ .../lsp/analyze-full-project/D.sol | 6 ++ .../lsp/analyze-full-project/E.sol | 6 ++ test/lsp.py | 70 ++++++++++++++++++- 10 files changed, 181 insertions(+), 44 deletions(-) create mode 100644 test/libsolidity/lsp/analyze-full-project/C.sol create mode 100644 test/libsolidity/lsp/analyze-full-project/D.sol create mode 100644 test/libsolidity/lsp/analyze-full-project/E.sol diff --git a/Changelog.md b/Changelog.md index dfa237e2d6..f0f8b8485c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ Language Features: Compiler Features: * Code Generator: More efficient overflow checks for multiplication. * Yul Optimizer: Simplify the starting offset of zero-length operations to zero. + * Language Server: Analyze all files in a project by default (can be customized by setting ``'file-load-strategy'`` to ``'directly-opened-and-on-import'`` in LSP settings object). Bugfixes: diff --git a/libsolidity/lsp/FileRepository.cpp b/libsolidity/lsp/FileRepository.cpp index 6ba583c3a5..58bc0bf8de 100644 --- a/libsolidity/lsp/FileRepository.cpp +++ b/libsolidity/lsp/FileRepository.cpp @@ -17,6 +17,7 @@ // SPDX-License-Identifier: GPL-3.0 #include +#include #include #include @@ -25,11 +26,14 @@ #include #include #include +#include #include #include +#include + using namespace std; using namespace solidity; using namespace solidity::lsp; @@ -84,6 +88,7 @@ string FileRepository::sourceUnitNameToUri(string const& _sourceUnitName) const string FileRepository::uriToSourceUnitName(string const& _path) const { + lspAssert(boost::algorithm::starts_with(_path, "file://"), ErrorCode::InternalError, "URI must start with file://"); return stripFileUriSchemePrefix(_path); } @@ -92,6 +97,7 @@ void FileRepository::setSourceByUri(string const& _uri, string _source) // This is needed for uris outside the base path. It can lead to collisions, // but we need to mostly rewrite this in a future version anyway. auto sourceUnitName = uriToSourceUnitName(_uri); + lspDebug(fmt::format("FileRepository.setSourceByUri({}): {}", _uri, _source)); m_sourceUnitNamesToUri.emplace(sourceUnitName, _uri); m_sourceCodes[sourceUnitName] = std::move(_source); } diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 5465406c0b..3020900c0b 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -42,6 +43,8 @@ #include #include +#include + using namespace std; using namespace std::string_literals; using namespace std::placeholders; @@ -118,7 +121,7 @@ LanguageServer::LanguageServer(Transport& _transport): {"cancelRequest", [](auto, auto) {/*nothing for now as we are synchronous */}}, {"exit", [this](auto, auto) { m_state = (m_state == State::ShutdownRequested ? State::ExitRequested : State::ExitWithoutShutdown); }}, {"initialize", bind(&LanguageServer::handleInitialize, this, _1, _2)}, - {"initialized", [](auto, auto) {}}, + {"initialized", bind(&LanguageServer::handleInitialized, this, _1, _2)}, {"$/setTrace", [this](auto, Json::Value const& args) { setTrace(args["value"]); }}, {"shutdown", [this](auto, auto) { m_state = State::ShutdownRequested; }}, {"textDocument/definition", GotoDefinition(*this) }, @@ -147,6 +150,26 @@ Json::Value LanguageServer::toJson(SourceLocation const& _location) void LanguageServer::changeConfiguration(Json::Value const& _settings) { + // The settings item: "file-load-strategy" (enum) defaults to "project-directory" if not (or not correctly) set. + // It can be overridden during client's handshake or at runtime, as usual. + // + // If this value is set to "project-directory" (default), all .sol files located inside the project directory or reachable through symbolic links will be subject to operations. + // + // Operations include compiler analysis, but also finding all symbolic references or symbolic renaming. + // + // If this value is set to "directly-opened-and-on-import", then only currently directly opened files and + // those files being imported directly or indirectly will be included in operations. + if (_settings["file-load-strategy"]) + { + auto const text = _settings["file-load-strategy"].asString(); + if (text == "project-directory") + m_fileLoadStrategy = FileLoadStrategy::ProjectDirectory; + else if (text == "directly-opened-and-on-import") + m_fileLoadStrategy = FileLoadStrategy::DirectlyOpenedAndOnImported; + else + lspAssert(false, ErrorCode::InvalidParams, "Invalid file load strategy: " + text); + } + m_settingsObject = _settings; Json::Value jsonIncludePaths = _settings["include-paths"]; @@ -173,6 +196,23 @@ void LanguageServer::changeConfiguration(Json::Value const& _settings) } } +vector LanguageServer::allSolidityFilesFromProject() const +{ + namespace fs = boost::filesystem; + + std::vector collectedPaths{}; + + // We explicitly decided against including all files from include paths but leave the possibility + // open for a future PR to enable such a feature to be optionally enabled (default disabled). + + auto directoryIterator = fs::recursive_directory_iterator(m_fileRepository.basePath(), fs::symlink_option::recurse); + for (fs::directory_entry const& dirEntry: directoryIterator) + if (dirEntry.path().extension() == ".sol") + collectedPaths.push_back(dirEntry.path()); + + return collectedPaths; +} + void LanguageServer::compile() { // For files that are not open, we have to take changes on disk into account, @@ -181,6 +221,18 @@ void LanguageServer::compile() FileRepository oldRepository(m_fileRepository.basePath(), m_fileRepository.includePaths()); swap(oldRepository, m_fileRepository); + // Load all solidity files from project. + if (m_fileLoadStrategy == FileLoadStrategy::ProjectDirectory) + for (auto const& projectFile: allSolidityFilesFromProject()) + { + lspDebug(fmt::format("adding project file: {}", projectFile.generic_string())); + m_fileRepository.setSourceByUri( + m_fileRepository.sourceUnitNameToUri(projectFile.generic_string()), + util::readFileAsString(projectFile) + ); + } + + // Overwrite all files as opened by the client, including the ones which might potentially have changes. for (string const& fileName: m_openFiles) m_fileRepository.setSourceByUri( fileName, @@ -269,6 +321,7 @@ bool LanguageServer::run() { string const methodName = (*jsonMessage)["method"].asString(); id = (*jsonMessage)["id"]; + lspDebug(fmt::format("received method call: {}", methodName)); if (auto handler = util::valueOrDefault(m_handlers, methodName)) handler(id, (*jsonMessage)["params"]); @@ -278,6 +331,10 @@ bool LanguageServer::run() else m_client.error({}, ErrorCode::ParseError, "\"method\" has to be a string."); } + catch (Json::Exception const&) + { + m_client.error(id, ErrorCode::InvalidParams, "JSON object access error. Most likely due to a badly formatted JSON request message."s); + } catch (RequestError const& error) { m_client.error(id, error.code(), error.comment() ? *error.comment() : ""s); @@ -347,6 +404,12 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) m_client.reply(_id, move(replyArgs)); } +void LanguageServer::handleInitialized(MessageID, Json::Value const&) +{ + if (m_fileLoadStrategy == FileLoadStrategy::ProjectDirectory) + compileAndUpdateDiagnostics(); +} + void LanguageServer::semanticTokensFull(MessageID _id, Json::Value const& _args) { auto uri = _args["textDocument"]["uri"]; diff --git a/libsolidity/lsp/LanguageServer.h b/libsolidity/lsp/LanguageServer.h index ee4f06957f..a05bec4976 100644 --- a/libsolidity/lsp/LanguageServer.h +++ b/libsolidity/lsp/LanguageServer.h @@ -36,6 +36,23 @@ namespace solidity::lsp class RenameSymbol; enum class ErrorCode; +/** + * Enum to mandate what files to take into consideration for source code analysis. + */ +enum class FileLoadStrategy +{ + /// Takes only those files into consideration that are explicitly opened and those + /// that have been directly or indirectly imported. + DirectlyOpenedAndOnImported = 0, + + /// Takes all Solidity (.sol) files within the project root into account. + /// Symbolic links will be followed, even if they lead outside of the project directory + /// (`--allowed-paths` is currently ignored by the LSP). + /// + /// This resembles the closest what other LSPs should be doing already. + ProjectDirectory = 1, +}; + /** * Solidity Language Server, managing one LSP client. * This implements a subset of LSP version 3.16 that can be found at: @@ -68,6 +85,7 @@ class LanguageServer /// Reports an error and returns false if not. void requireServerInitialized(); void handleInitialize(MessageID _id, Json::Value const& _args); + void handleInitialized(MessageID _id, Json::Value const& _args); void handleWorkspaceDidChangeConfiguration(Json::Value const& _args); void setTrace(Json::Value const& _args); void handleTextDocumentDidOpen(Json::Value const& _args); @@ -82,6 +100,9 @@ class LanguageServer /// Compile everything until after analysis phase. void compile(); + + std::vector allSolidityFilesFromProject() const; + using MessageHandler = std::function; Json::Value toRange(langutil::SourceLocation const& _location); @@ -100,6 +121,7 @@ class LanguageServer /// Set of source unit names for which we sent diagnostics to the client in the last iteration. std::set m_nonemptyDiagnostics; FileRepository m_fileRepository; + FileLoadStrategy m_fileLoadStrategy = FileLoadStrategy::ProjectDirectory; frontend::CompilerStack m_compilerStack; diff --git a/libsolidity/lsp/Transport.cpp b/libsolidity/lsp/Transport.cpp index aa85fd6b1a..90c0b20a7a 100644 --- a/libsolidity/lsp/Transport.cpp +++ b/libsolidity/lsp/Transport.cpp @@ -16,6 +16,7 @@ */ // SPDX-License-Identifier: GPL-3.0 #include +#include #include #include @@ -205,11 +206,13 @@ std::string StdioTransport::getline() { std::string line; std::getline(std::cin, line); + lspDebug(fmt::format("Received: {}", line)); return line; } void StdioTransport::writeBytes(std::string_view _data) { + lspDebug(fmt::format("Sending: {}", _data)); auto const bytesWritten = fwrite(_data.data(), 1, _data.size(), stdout); solAssert(bytesWritten == _data.size()); } diff --git a/libsolutil/CommonIO.h b/libsolutil/CommonIO.h index 56f62f0ac4..e6cd0c1616 100644 --- a/libsolutil/CommonIO.h +++ b/libsolutil/CommonIO.h @@ -48,46 +48,6 @@ inline std::ostream& operator<<(std::ostream& os, bytes const& _bytes) namespace util { -namespace detail -{ - -template -struct RecursiveFileCollector -{ - Predicate predicate; - std::vector result {}; - - RecursiveFileCollector& operator()(boost::filesystem::path const& _directory) - { - if (!boost::filesystem::is_directory(_directory)) - return *this; - auto iterator = boost::filesystem::directory_iterator(_directory); - auto const iteratorEnd = boost::filesystem::directory_iterator(); - - while (iterator != iteratorEnd) - { - if (boost::filesystem::is_directory(iterator->status())) - (*this)(iterator->path()); - - if (predicate(iterator->path())) - result.push_back(iterator->path()); - - ++iterator; - } - return *this; - } -}; - -template -RecursiveFileCollector(Predicate) -> RecursiveFileCollector; -} - -template -std::vector findFilesRecursively(boost::filesystem::path const& _rootDirectory, Predicate _predicate) -{ - return detail::RecursiveFileCollector{_predicate}(_rootDirectory).result; -} - /// Retrieves and returns the contents of the given file as a std::string. /// If the file doesn't exist, it will throw a FileNotFound exception. /// If the file exists but is not a regular file, it will throw NotAFile exception. diff --git a/test/libsolidity/lsp/analyze-full-project/C.sol b/test/libsolidity/lsp/analyze-full-project/C.sol new file mode 100644 index 0000000000..d08ba140e5 --- /dev/null +++ b/test/libsolidity/lsp/analyze-full-project/C.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ +} diff --git a/test/libsolidity/lsp/analyze-full-project/D.sol b/test/libsolidity/lsp/analyze-full-project/D.sol new file mode 100644 index 0000000000..93c8e92fcf --- /dev/null +++ b/test/libsolidity/lsp/analyze-full-project/D.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract D +{ +} diff --git a/test/libsolidity/lsp/analyze-full-project/E.sol b/test/libsolidity/lsp/analyze-full-project/E.sol new file mode 100644 index 0000000000..e0e5d19889 --- /dev/null +++ b/test/libsolidity/lsp/analyze-full-project/E.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract E +{ +} diff --git a/test/lsp.py b/test/lsp.py index 543a7ca433..98c16d3f55 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -537,6 +537,18 @@ def at_end(self): """ return self.current_line_tuple is None +class FileLoadStrategy(Enum): + Undefined = auto() + ProjectDirectory = auto() + DirectlyOpenedAndOnImport = auto() + + def lsp_name(self): + if self == FileLoadStrategy.ProjectDirectory: + return 'project-directory' + elif self == FileLoadStrategy.DirectlyOpenedAndOnImport: + return 'directly-opened-and-on-import' + return None + class FileTestRunner: """ Runs all tests in a given file. @@ -898,18 +910,27 @@ def main(self) -> int: return min(max(self.test_counter.failed, self.assertion_counter.failed), 127) - def setup_lsp(self, lsp: JsonRpcProcess, expose_project_root=True): + def setup_lsp( + self, + lsp: JsonRpcProcess, + expose_project_root=True, + file_load_strategy: FileLoadStrategy=FileLoadStrategy.DirectlyOpenedAndOnImport, + project_root_subdir=None + ): """ Prepares the solc LSP server by calling `initialize`, and `initialized` methods. """ + project_root_uri_with_maybe_subdir = self.project_root_uri + if project_root_subdir is not None: + project_root_uri_with_maybe_subdir = self.project_root_uri + '/' + project_root_subdir params = { 'processId': None, - 'rootUri': self.project_root_uri, + 'rootUri': project_root_uri_with_maybe_subdir, # Enable traces to receive the amount of expected diagnostics before # actually receiving them. 'trace': 'messages', - 'initializationOptions': {}, + # 'initializationOptions': {}, 'capabilities': { 'textDocument': { 'publishDiagnostics': {'relatedInformation': True} @@ -923,6 +944,9 @@ def setup_lsp(self, lsp: JsonRpcProcess, expose_project_root=True): } } } + if file_load_strategy != FileLoadStrategy.Undefined: + params['initializationOptions'] = {} + params['initializationOptions']['file-load-strategy'] = file_load_strategy.lsp_name() if not expose_project_root: params['rootUri'] = None lsp.call_method('initialize', params) @@ -1059,6 +1083,14 @@ def open_file_and_wait_for_diagnostics( ) return self.wait_for_diagnostics(solc_process) + def expect_true( + self, + actual, + description="Expected True value", + part=ExpectationFailed.Part.Diagnostics + ) -> None: + self.expect_equal(actual, True, description, part) + def expect_equal( self, actual, @@ -1295,6 +1327,38 @@ def user_interaction_failed_autoupdate(self, test, sub_dir): # }}} # {{{ actual tests + def test_analyze_all_project_files1(self, solc: JsonRpcProcess) -> None: + """ + Tests the option (default) to analyze all .sol project files even when they have not been actively + opened yet. This is how other LSPs (at least for C++) work too and it makes cross-unit tasks + actually correct (e.g. symbolic rename, find all references, ...). + + In this test, we simply open up a custom project and ensure we're receiving the diagnostics + for all existing files in that project (while having none of these files opened). + """ + SUBDIR = 'analyze-full-project' + self.setup_lsp( + solc, + file_load_strategy=FileLoadStrategy.ProjectDirectory, + project_root_subdir=SUBDIR + ) + published_diagnostics = self.wait_for_diagnostics(solc) + self.expect_equal(len(published_diagnostics), 3, "Diagnostic reports for 3 files") + + # C.sol + report = published_diagnostics[0] + self.expect_equal(report['uri'], self.get_test_file_uri('C', SUBDIR), "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + # D.sol + report = published_diagnostics[1] + self.expect_equal(report['uri'], self.get_test_file_uri('D', SUBDIR), "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + # E.sol + report = published_diagnostics[2] + self.expect_equal(report['uri'], self.get_test_file_uri('E', SUBDIR), "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") def test_publish_diagnostics_errors_multiline(self, solc: JsonRpcProcess) -> None: self.setup_lsp(solc) From 122fbc6ff70ddd4a7f21616e1807a2506dbe912b Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 15 Aug 2022 12:36:47 +0200 Subject: [PATCH 050/109] Adds include-paths-nested test case. --- .../lsp/include-paths-nested/A/B/C/foo.sol | 6 +++++ .../lsp/include-paths-nested/A/B/foo.sol | 6 +++++ .../lsp/include-paths-nested/A/foo.sol | 6 +++++ .../lsp/include-paths-nested/foo.sol | 6 +++++ test/lsp.py | 23 +++++++++++++++++++ 5 files changed, 47 insertions(+) create mode 100644 test/libsolidity/lsp/include-paths-nested/A/B/C/foo.sol create mode 100644 test/libsolidity/lsp/include-paths-nested/A/B/foo.sol create mode 100644 test/libsolidity/lsp/include-paths-nested/A/foo.sol create mode 100644 test/libsolidity/lsp/include-paths-nested/foo.sol diff --git a/test/libsolidity/lsp/include-paths-nested/A/B/C/foo.sol b/test/libsolidity/lsp/include-paths-nested/A/B/C/foo.sol new file mode 100644 index 0000000000..d08ba140e5 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/A/B/C/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract C +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested/A/B/foo.sol b/test/libsolidity/lsp/include-paths-nested/A/B/foo.sol new file mode 100644 index 0000000000..0ab2f9c095 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/A/B/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract B +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested/A/foo.sol b/test/libsolidity/lsp/include-paths-nested/A/foo.sol new file mode 100644 index 0000000000..1e31dbd990 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/A/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract A +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested/foo.sol b/test/libsolidity/lsp/include-paths-nested/foo.sol new file mode 100644 index 0000000000..c589b6ae2c --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract RootContract +{ +} diff --git a/test/lsp.py b/test/lsp.py index 98c16d3f55..3e98bffc90 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -1360,6 +1360,29 @@ def test_analyze_all_project_files1(self, solc: JsonRpcProcess) -> None: self.expect_equal(report['uri'], self.get_test_file_uri('E', SUBDIR), "Correct file URI") self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + def test_analyze_all_project_files2(self, solc: JsonRpcProcess) -> None: + """ + Same as first test on that matter but with deeper nesting levels. + """ + SUBDIR = 'include-paths-nested' + EXPECTED_FILES = [ + "A/B/C/foo", + "A/B/foo", + "A/foo", + "foo", + ] + EXPECTED_URIS = [self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES] + self.setup_lsp( + solc, + file_load_strategy=FileLoadStrategy.ProjectDirectory, + project_root_subdir=SUBDIR + ) + published_diagnostics = self.wait_for_diagnostics(solc) + self.expect_equal(len(published_diagnostics), len(EXPECTED_FILES), "Test number of files analyzed.") + for report in published_diagnostics: + self.expect_true(report['uri'] in EXPECTED_URIS, "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + def test_publish_diagnostics_errors_multiline(self, solc: JsonRpcProcess) -> None: self.setup_lsp(solc) TEST_NAME = 'publish_diagnostics_3' From d31e4dcc0ada4d232c52ef29c918592dbf31a1e1 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 15 Aug 2022 14:53:38 +0200 Subject: [PATCH 051/109] lsp: Finishing last missing test wrt complex nested project directory structure and specifying custom includes, while using some (one) of them. --- .../lsp/include-paths-nested-2/A/B/C/foo.sol | 8 ++ .../lsp/include-paths-nested-2/A/B/foo.sol | 6 ++ .../lsp/include-paths-nested-2/A/foo.sol | 6 ++ .../lsp/include-paths-nested-2/foo.sol | 6 ++ .../lsp/other-include-dir/otherlib/second.sol | 7 ++ test/lsp.py | 80 +++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 test/libsolidity/lsp/include-paths-nested-2/A/B/C/foo.sol create mode 100644 test/libsolidity/lsp/include-paths-nested-2/A/B/foo.sol create mode 100644 test/libsolidity/lsp/include-paths-nested-2/A/foo.sol create mode 100644 test/libsolidity/lsp/include-paths-nested-2/foo.sol create mode 100644 test/libsolidity/lsp/other-include-dir/otherlib/second.sol diff --git a/test/libsolidity/lsp/include-paths-nested-2/A/B/C/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/A/B/C/foo.sol new file mode 100644 index 0000000000..d53d359b12 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/A/B/C/foo.sol @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +import "otherlib/second.sol"; + +contract C +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested-2/A/B/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/A/B/foo.sol new file mode 100644 index 0000000000..0ab2f9c095 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/A/B/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract B +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested-2/A/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/A/foo.sol new file mode 100644 index 0000000000..1e31dbd990 --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/A/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract A +{ +} diff --git a/test/libsolidity/lsp/include-paths-nested-2/foo.sol b/test/libsolidity/lsp/include-paths-nested-2/foo.sol new file mode 100644 index 0000000000..c589b6ae2c --- /dev/null +++ b/test/libsolidity/lsp/include-paths-nested-2/foo.sol @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +contract RootContract +{ +} diff --git a/test/libsolidity/lsp/other-include-dir/otherlib/second.sol b/test/libsolidity/lsp/other-include-dir/otherlib/second.sol new file mode 100644 index 0000000000..2f32daac26 --- /dev/null +++ b/test/libsolidity/lsp/other-include-dir/otherlib/second.sol @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: UNLICENSED +pragma solidity >=0.8.0; + +library Second +{ + function f(uint n) public pure returns (uint) { return n + 1; } +} diff --git a/test/lsp.py b/test/lsp.py index 3e98bffc90..e19a591a9f 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -915,6 +915,7 @@ def setup_lsp( lsp: JsonRpcProcess, expose_project_root=True, file_load_strategy: FileLoadStrategy=FileLoadStrategy.DirectlyOpenedAndOnImport, + custom_include_paths: list[str] = [], project_root_subdir=None ): """ @@ -944,11 +945,19 @@ def setup_lsp( } } } + if file_load_strategy != FileLoadStrategy.Undefined: params['initializationOptions'] = {} params['initializationOptions']['file-load-strategy'] = file_load_strategy.lsp_name() + + if len(custom_include_paths) != 0: + if params['initializationOptions'] is None: + params['initializationOptions'] = {} + params['initializationOptions']['include-paths'] = custom_include_paths + if not expose_project_root: params['rootUri'] = None + lsp.call_method('initialize', params) lsp.send_notification('initialized') @@ -1383,6 +1392,40 @@ def test_analyze_all_project_files2(self, solc: JsonRpcProcess) -> None: self.expect_true(report['uri'] in EXPECTED_URIS, "Correct file URI") self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + def test_analyze_all_project_files3(self, solc: JsonRpcProcess) -> None: + """ + Same as first test on that matter but with deeper nesting levels. + """ + SUBDIR = 'include-paths-nested-2' + EXPECTED_FILES = [ + "A/B/C/foo", + "A/B/foo", + "A/foo", + "foo", + ] + IMPLICITLY_LOADED_FILE_COUNT = 1 + EXPECTED_URIS = [self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES] + self.setup_lsp( + solc, + file_load_strategy=FileLoadStrategy.ProjectDirectory, + project_root_subdir=SUBDIR, + custom_include_paths=[f"{self.project_root_dir}/other-include-dir"] + ) + published_diagnostics = self.wait_for_diagnostics(solc) + self.expect_equal(len(published_diagnostics), len(EXPECTED_FILES) + IMPLICITLY_LOADED_FILE_COUNT, "Test number of files analyzed.") + + # All but the last report should be from expected files + for report in published_diagnostics[:-IMPLICITLY_LOADED_FILE_COUNT]: + self.expect_true(report['uri'] in EXPECTED_URIS, "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + # Check last report (should be the custom imported lib). + # This file is analyzed because it was imported via "A/B/C/foo.sol". + report = published_diagnostics[len(EXPECTED_URIS)] + self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/second.sol", "Correct file URI") + self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + + def test_publish_diagnostics_errors_multiline(self, solc: JsonRpcProcess) -> None: self.setup_lsp(solc) TEST_NAME = 'publish_diagnostics_3' @@ -1495,6 +1538,43 @@ def test_custom_includes(self, solc: JsonRpcProcess) -> None: self.expect_equal(len(diagnostics), 1, "no diagnostics") self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62)) + def test_custom_includes_with_full_project(self, solc: JsonRpcProcess) -> None: + """ + Tests loading all all project files while having custom include directories configured. + In such a scenario, all project files should be analyzed and those being included via search path + but not those include files that are not directly nor indirectly included. + """ + self.setup_lsp( + solc, + expose_project_root=True, + project_root_subdir='' + ) + solc.send_notification( + 'workspace/didChangeConfiguration', { + 'settings': { + 'include-paths': [ + f"{self.project_root_dir}/other-include-dir" + ] + } + } + ) + published_diagnostics = self.open_file_and_wait_for_diagnostics(solc, 'include-paths/using-custom-includes') + + self.expect_equal(len(published_diagnostics), 2, "Diagnostic reports for 2 files") + + # test file + report = published_diagnostics[0] + self.expect_equal(report['uri'], self.get_test_file_uri('using-custom-includes', 'include-paths')) + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 0, "no diagnostics") + + # imported file + report = published_diagnostics[1] + self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol") + diagnostics = report['diagnostics'] + self.expect_equal(len(diagnostics), 1, "no diagnostics") + self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62)) + def test_didChange_in_A_causing_error_in_B(self, solc: JsonRpcProcess) -> None: # Reusing another test but now change some file that generates an error in the other. self.test_textDocument_didOpen_with_relative_import(solc) From d0854cb485ad89b0fb8647b728642666b74f97b6 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 22 Aug 2022 11:09:08 +0200 Subject: [PATCH 052/109] Applying CI-reported fixes. --- test/lsp.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/lsp.py b/test/lsp.py index e19a591a9f..eb28e2e55f 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # pragma pylint: disable=too-many-lines # test line 1 +from __future__ import annotations # See: https://github.com/PyCQA/pylint/issues/3320 import argparse import fnmatch import functools @@ -422,7 +423,7 @@ def parse(self): self.next_line() - def parseDiagnostics(self) -> Diagnostics: + def parseDiagnostics(self) -> TestParser.Diagnostics: """ Parse diagnostic expectations specified in the file. Returns a named tuple instance of "Diagnostics" @@ -454,7 +455,7 @@ def parseDiagnostics(self) -> Diagnostics: return self.Diagnostics(**diagnostics) - def parseRequestAndResponse(self) -> RequestAndResponse: + def parseRequestAndResponse(self) -> TestParser.RequestAndResponse: RESPONSE_START = "// <- " REQUEST_END = "// }" COMMENT_PREFIX = "// " @@ -915,7 +916,7 @@ def setup_lsp( lsp: JsonRpcProcess, expose_project_root=True, file_load_strategy: FileLoadStrategy=FileLoadStrategy.DirectlyOpenedAndOnImport, - custom_include_paths: list[str] = [], + custom_include_paths: list[str] = None, project_root_subdir=None ): """ @@ -950,7 +951,7 @@ def setup_lsp( params['initializationOptions'] = {} params['initializationOptions']['file-load-strategy'] = file_load_strategy.lsp_name() - if len(custom_include_paths) != 0: + if custom_include_paths is not None and len(custom_include_paths) != 0: if params['initializationOptions'] is None: params['initializationOptions'] = {} params['initializationOptions']['include-paths'] = custom_include_paths @@ -1412,7 +1413,11 @@ def test_analyze_all_project_files3(self, solc: JsonRpcProcess) -> None: custom_include_paths=[f"{self.project_root_dir}/other-include-dir"] ) published_diagnostics = self.wait_for_diagnostics(solc) - self.expect_equal(len(published_diagnostics), len(EXPECTED_FILES) + IMPLICITLY_LOADED_FILE_COUNT, "Test number of files analyzed.") + self.expect_equal( + len(published_diagnostics), + len(EXPECTED_FILES) + IMPLICITLY_LOADED_FILE_COUNT, + "Test number of files analyzed." + ) # All but the last report should be from expected files for report in published_diagnostics[:-IMPLICITLY_LOADED_FILE_COUNT]: From b22d149e3c68eb353a4141e148f65f9b7d631cc3 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 22 Aug 2022 14:53:15 +0200 Subject: [PATCH 053/109] Adds extra check to only consider regular files (e.g. not directories / device files) for inclusion. --- libsolidity/lsp/LanguageServer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 3020900c0b..e0c7dca8cb 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -207,8 +207,13 @@ vector LanguageServer::allSolidityFilesFromProject() co auto directoryIterator = fs::recursive_directory_iterator(m_fileRepository.basePath(), fs::symlink_option::recurse); for (fs::directory_entry const& dirEntry: directoryIterator) - if (dirEntry.path().extension() == ".sol") - collectedPaths.push_back(dirEntry.path()); + { + if ( + dirEntry.status().type() == fs::file_type::regular_file && + dirEntry.path().extension() == ".sol" + ) + collectedPaths.push_back(dirEntry.path()); + } return collectedPaths; } From 3fc7debbef5f1fbff4f1668cd272e458ccf2ed02 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 24 Aug 2022 10:31:16 +0200 Subject: [PATCH 054/109] lsp: Code-review fixups. --- libsolidity/lsp/LanguageServer.cpp | 27 +++++++++++----- test/lsp.py | 49 ++++++++++++------------------ 2 files changed, 39 insertions(+), 37 deletions(-) diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index e0c7dca8cb..6ea60e0cf6 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -53,9 +53,24 @@ using namespace solidity::lsp; using namespace solidity::langutil; using namespace solidity::frontend; +namespace fs = boost::filesystem; + namespace { +bool resolvesToRegularFile(boost::filesystem::path _path) +{ + fs::file_status fileStatus = fs::status(_path); + + while (fileStatus.type() == fs::file_type::symlink_file) + { + _path = boost::filesystem::read_symlink(_path); + fileStatus = fs::status(_path); + } + + return fileStatus.type() == fs::file_type::regular_file; +} + int toDiagnosticSeverity(Error::Type _errorType) { // 1=Error, 2=Warning, 3=Info, 4=Hint @@ -198,22 +213,18 @@ void LanguageServer::changeConfiguration(Json::Value const& _settings) vector LanguageServer::allSolidityFilesFromProject() const { - namespace fs = boost::filesystem; - - std::vector collectedPaths{}; + vector collectedPaths{}; // We explicitly decided against including all files from include paths but leave the possibility // open for a future PR to enable such a feature to be optionally enabled (default disabled). auto directoryIterator = fs::recursive_directory_iterator(m_fileRepository.basePath(), fs::symlink_option::recurse); for (fs::directory_entry const& dirEntry: directoryIterator) - { if ( - dirEntry.status().type() == fs::file_type::regular_file && - dirEntry.path().extension() == ".sol" + dirEntry.path().extension() == ".sol" && + (dirEntry.status().type() == fs::file_type::regular_file || resolvesToRegularFile(dirEntry.path())) ) - collectedPaths.push_back(dirEntry.path()); - } + collectedPaths.push_back(dirEntry.path()); return collectedPaths; } diff --git a/test/lsp.py b/test/lsp.py index eb28e2e55f..2e097dab0a 100755 --- a/test/lsp.py +++ b/test/lsp.py @@ -539,16 +539,9 @@ def at_end(self): return self.current_line_tuple is None class FileLoadStrategy(Enum): - Undefined = auto() - ProjectDirectory = auto() - DirectlyOpenedAndOnImport = auto() - - def lsp_name(self): - if self == FileLoadStrategy.ProjectDirectory: - return 'project-directory' - elif self == FileLoadStrategy.DirectlyOpenedAndOnImport: - return 'directly-opened-and-on-import' - return None + Undefined = None + ProjectDirectory = 'project-directory' + DirectlyOpenedAndOnImport = 'directly-opened-and-on-import' class FileTestRunner: """ @@ -932,7 +925,6 @@ def setup_lsp( # Enable traces to receive the amount of expected diagnostics before # actually receiving them. 'trace': 'messages', - # 'initializationOptions': {}, 'capabilities': { 'textDocument': { 'publishDiagnostics': {'relatedInformation': True} @@ -949,7 +941,7 @@ def setup_lsp( if file_load_strategy != FileLoadStrategy.Undefined: params['initializationOptions'] = {} - params['initializationOptions']['file-load-strategy'] = file_load_strategy.lsp_name() + params['initializationOptions']['file-load-strategy'] = file_load_strategy.value if custom_include_paths is not None and len(custom_include_paths) != 0: if params['initializationOptions'] is None: @@ -1337,7 +1329,7 @@ def user_interaction_failed_autoupdate(self, test, sub_dir): # }}} # {{{ actual tests - def test_analyze_all_project_files1(self, solc: JsonRpcProcess) -> None: + def test_analyze_all_project_files_flat(self, solc: JsonRpcProcess) -> None: """ Tests the option (default) to analyze all .sol project files even when they have not been actively opened yet. This is how other LSPs (at least for C++) work too and it makes cross-unit tasks @@ -1370,18 +1362,18 @@ def test_analyze_all_project_files1(self, solc: JsonRpcProcess) -> None: self.expect_equal(report['uri'], self.get_test_file_uri('E', SUBDIR), "Correct file URI") self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") - def test_analyze_all_project_files2(self, solc: JsonRpcProcess) -> None: + def test_analyze_all_project_files_nested(self, solc: JsonRpcProcess) -> None: """ Same as first test on that matter but with deeper nesting levels. """ SUBDIR = 'include-paths-nested' - EXPECTED_FILES = [ + EXPECTED_FILES = { "A/B/C/foo", "A/B/foo", "A/foo", "foo", - ] - EXPECTED_URIS = [self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES] + } + EXPECTED_URIS = {self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES} self.setup_lsp( solc, file_load_strategy=FileLoadStrategy.ProjectDirectory, @@ -1389,23 +1381,22 @@ def test_analyze_all_project_files2(self, solc: JsonRpcProcess) -> None: ) published_diagnostics = self.wait_for_diagnostics(solc) self.expect_equal(len(published_diagnostics), len(EXPECTED_FILES), "Test number of files analyzed.") - for report in published_diagnostics: - self.expect_true(report['uri'] in EXPECTED_URIS, "Correct file URI") - self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + self.expect_equal({report['uri'] for report in published_diagnostics}, EXPECTED_URIS) + self.expect_equal([len(report['diagnostics']) for report in published_diagnostics], [0] * len(EXPECTED_URIS)) - def test_analyze_all_project_files3(self, solc: JsonRpcProcess) -> None: + def test_analyze_all_project_files_nested_with_include_paths(self, solc: JsonRpcProcess) -> None: """ Same as first test on that matter but with deeper nesting levels. """ SUBDIR = 'include-paths-nested-2' - EXPECTED_FILES = [ + EXPECTED_FILES = { "A/B/C/foo", "A/B/foo", "A/foo", "foo", - ] + } IMPLICITLY_LOADED_FILE_COUNT = 1 - EXPECTED_URIS = [self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES] + EXPECTED_URIS = {self.get_test_file_uri(x, SUBDIR) for x in EXPECTED_FILES} self.setup_lsp( solc, file_load_strategy=FileLoadStrategy.ProjectDirectory, @@ -1426,9 +1417,9 @@ def test_analyze_all_project_files3(self, solc: JsonRpcProcess) -> None: # Check last report (should be the custom imported lib). # This file is analyzed because it was imported via "A/B/C/foo.sol". - report = published_diagnostics[len(EXPECTED_URIS)] - self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/second.sol", "Correct file URI") - self.expect_equal(len(report['diagnostics']), 0, "no diagnostics") + last_report = published_diagnostics[len(EXPECTED_URIS)] + self.expect_equal(last_report['uri'], self.get_test_file_uri('second', 'other-include-dir/otherlib'), "Correct file URI") + self.expect_equal(len(last_report['diagnostics']), 0, "no diagnostics") def test_publish_diagnostics_errors_multiline(self, solc: JsonRpcProcess) -> None: @@ -1545,7 +1536,7 @@ def test_custom_includes(self, solc: JsonRpcProcess) -> None: def test_custom_includes_with_full_project(self, solc: JsonRpcProcess) -> None: """ - Tests loading all all project files while having custom include directories configured. + Tests loading all project files while having custom include directories configured. In such a scenario, all project files should be analyzed and those being included via search path but not those include files that are not directly nor indirectly included. """ @@ -1577,7 +1568,7 @@ def test_custom_includes_with_full_project(self, solc: JsonRpcProcess) -> None: report = published_diagnostics[1] self.expect_equal(report['uri'], f"{self.project_root_uri}/other-include-dir/otherlib/otherlib.sol") diagnostics = report['diagnostics'] - self.expect_equal(len(diagnostics), 1, "no diagnostics") + self.expect_equal(len(diagnostics), 1) self.expect_diagnostic(diagnostics[0], code=2018, lineNo=5, startEndColumns=(4, 62)) def test_didChange_in_A_causing_error_in_B(self, solc: JsonRpcProcess) -> None: From c8074d2c6e5eaa228e6d37be9a682b4c5a393162 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 24 Aug 2022 15:46:08 +0200 Subject: [PATCH 055/109] lsp: Limit resolvesToRegularFile()'s recursion depth to 10. --- libsolidity/lsp/LanguageServer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 6ea60e0cf6..65eeaf3d50 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -58,14 +58,15 @@ namespace fs = boost::filesystem; namespace { -bool resolvesToRegularFile(boost::filesystem::path _path) +bool resolvesToRegularFile(boost::filesystem::path _path, int maxRecursionDepth = 10) { fs::file_status fileStatus = fs::status(_path); - while (fileStatus.type() == fs::file_type::symlink_file) + while (fileStatus.type() == fs::file_type::symlink_file && maxRecursionDepth > 0) { _path = boost::filesystem::read_symlink(_path); fileStatus = fs::status(_path); + maxRecursionDepth--; } return fileStatus.type() == fs::file_type::regular_file; From 66f48282cc527a531ffa3e850517221cf1b12423 Mon Sep 17 00:00:00 2001 From: khue Date: Mon, 11 Apr 2022 16:50:10 +0700 Subject: [PATCH 056/109] change to common config of 1 job to reuse between osx and ubuntu --- .circleci/config.yml | 53 +++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0b146ca0e7..23fb3ae0a0 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,6 +92,27 @@ commands: event: release condition: on_success + prepare_bytecode_report: + description: "Generate bytecode report and upload it as an artifact." + parameters: + label: + type: string + steps: + - run: mkdir test-cases/ + - run: cd test-cases && ../scripts/isolate_tests.py ../test/ + - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface standard-json --report-file "../bytecode-report-<< parameters.label >>-json.txt" + - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface cli --report-file "../bytecode-report-<< parameters.label >>-cli.txt" + - store_artifacts: + path: bytecode-report-<< parameters.label >>-json.txt + - store_artifacts: + path: bytecode-report-<< parameters.label >>-cli.txt + - persist_to_workspace: + root: . + paths: + - bytecode-report-<< parameters.label >>-json.txt + - bytecode-report-<< parameters.label >>-cli.txt + - gitter_notify_failure_unless_pr + defaults: # -------------------------------------------------------------------------- @@ -1389,20 +1410,8 @@ jobs: - checkout - attach_workspace: at: build - - run: mkdir test-cases/ - - run: cd test-cases && ../scripts/isolate_tests.py ../test/ - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface standard-json --report-file ../bytecode-report-ubuntu-json.txt - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface cli --report-file ../bytecode-report-ubuntu-cli.txt - - store_artifacts: - path: bytecode-report-ubuntu-json.txt - - store_artifacts: - path: bytecode-report-ubuntu-cli.txt - - persist_to_workspace: - root: . - paths: - - bytecode-report-ubuntu-json.txt - - bytecode-report-ubuntu-cli.txt - - gitter_notify_failure_unless_pr + - prepare_bytecode_report: + label: "ubuntu" b_bytecode_osx: <<: *base_osx @@ -1410,20 +1419,8 @@ jobs: - checkout - attach_workspace: at: . - - run: mkdir test-cases/ - - run: cd test-cases && ../scripts/isolate_tests.py ../test/ - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface standard-json --report-file ../bytecode-report-osx-json.txt - - run: cd test-cases && ../scripts/bytecodecompare/prepare_report.py ../build/solc/solc --interface cli --report-file ../bytecode-report-osx-cli.txt - - store_artifacts: - path: bytecode-report-osx-json.txt - - store_artifacts: - path: bytecode-report-osx-cli.txt - - persist_to_workspace: - root: . - paths: - - bytecode-report-osx-json.txt - - bytecode-report-osx-cli.txt - - gitter_notify_failure_unless_pr + - prepare_bytecode_report: + label: "osx" b_bytecode_win: <<: *base_win_cmd From 1cd6f2a486154274a7db4bf57420017c804dfa5d Mon Sep 17 00:00:00 2001 From: Thanh Tran Date: Wed, 24 Aug 2022 15:18:27 +0700 Subject: [PATCH 057/109] Fix warning about DOWNLOAD_EXTRACT_TIMESTAMP on CMake 3.24 --- cmake/EthPolicy.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/EthPolicy.cmake b/cmake/EthPolicy.cmake index cc404e7942..f571a09cee 100644 --- a/cmake/EthPolicy.cmake +++ b/cmake/EthPolicy.cmake @@ -20,4 +20,9 @@ macro (eth_policy) # Allow selecting MSVC runtime library using CMAKE_MSVC_RUNTIME_LIBRARY. cmake_policy(SET CMP0091 NEW) endif() + + # Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24: + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") + cmake_policy(SET CMP0135 NEW) + endif() endmacro() From 318dedf4396f535031753c82de5b643bbce948ec Mon Sep 17 00:00:00 2001 From: Duc Thanh Nguyen Date: Fri, 12 Aug 2022 22:41:04 -0400 Subject: [PATCH 058/109] Update emscripten Dockerfile to 3.1.19 --- scripts/ci/build_emscripten.sh | 11 ++++++++++- scripts/docker/buildpack-deps/Dockerfile.emscripten | 10 +++++++--- scripts/docker/buildpack-deps/README.md | 12 +++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 55d2288c3d..6bc1754f37 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -40,7 +40,8 @@ else BUILD_DIR="$1" fi -apt-get update && apt-get install lz4 +apt-get update +apt-get install lz4 --no-install-recommends WORKSPACE=/root/project @@ -61,12 +62,20 @@ then echo -n "$CIRCLE_SHA1" >commit_hash.txt fi +# Disable warnings for unqualified "move()" calls, introduced and enabled by +# default in clang-16 which is what the emscripten docker image uses. +# Additionally, disable the warning for unknown warnings here, as this script is +# also used with earlier clang versions. +CMAKE_CXX_FLAGS="-Wno-unqualified-std-cast-call -Wno-unknown-warning-option" + + mkdir -p "$BUILD_DIR" cd "$BUILD_DIR" emcmake cmake \ -DCMAKE_BUILD_TYPE=Release \ -DBoost_USE_STATIC_LIBS=1 \ -DBoost_USE_STATIC_RUNTIME=1 \ + -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS}" \ -DTESTS=0 \ .. make soljson diff --git a/scripts/docker/buildpack-deps/Dockerfile.emscripten b/scripts/docker/buildpack-deps/Dockerfile.emscripten index 777d8b2ec3..d52abc2e0f 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.emscripten +++ b/scripts/docker/buildpack-deps/Dockerfile.emscripten @@ -32,11 +32,15 @@ # apparently this currently breaks due to conflicting compatibility headers. # Using $(em-config CACHE)/sysroot/usr seems to work, though, and still has cmake find the # dependencies automatically. -FROM emscripten/emsdk:2.0.33 AS base -LABEL version="11" +FROM emscripten/emsdk:3.1.19 AS base +LABEL version="12" ADD emscripten.jam /usr/src RUN set -ex; \ +\ + apt-get update && \ + apt-get install lz4 --no-install-recommends && \ +\ cd /usr/src; \ git clone https://github.com/Z3Prover/z3.git -b z3-4.8.17 --depth 1 ; \ cd z3; \ @@ -55,7 +59,7 @@ RUN set -ex; \ make ; make install; \ rm -r /usr/src/z3; \ cd /usr/src; \ - +\ wget -q 'https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.bz2' -O boost.tar.bz2; \ test "$(sha256sum boost.tar.bz2)" = "953db31e016db7bb207f11432bef7df100516eeb746843fa0486a222e3fd49cb boost.tar.bz2"; \ tar -xf boost.tar.bz2; \ diff --git a/scripts/docker/buildpack-deps/README.md b/scripts/docker/buildpack-deps/README.md index 004a89e91f..bce45e6159 100644 --- a/scripts/docker/buildpack-deps/README.md +++ b/scripts/docker/buildpack-deps/README.md @@ -18,18 +18,20 @@ located in `develop`. ### Build, Test & Push Note that the whole workflow - including all defined strategies (image variants) - will be triggered, -even if only a single Dockerfile was change. The full workflow will only gets executed, if the corresponding +even if only a single Dockerfile was changed. The full workflow will only get executed, if the corresponding Dockerfile was changed. The execution of workflows of unchanged Dockerfiles will not continue and just return success. See `scripts/ci/docker_upgrade.sh`. If the version check was successful, the docker image will be built using the Dockerfile located in `scripts/docker/buildpack-deps/Dockerfile.*`. -The resulting docker image will be tested by executing -the corresponding `scripts/ci/buildpack-deps_test_*` scripts. These scripts are normally symlinked to `scripts/ci/build.sh`, -except for the `buildpack-deps-ubuntu1604.clang.ossfuzz` docker image, that is symlinked to `scripts/ci/build_ossfuzz.sh`. +The resulting docker image will be tested by executing the corresponding `scripts/ci/buildpack-deps_test_*` scripts. +Some of these scripts are symlinked to `scripts/ci/build.sh`, except the following two: + * `buildpack-deps-ubuntu1604.clang.ossfuzz` => `scripts/ci/build_ossfuzz.sh` + * `buildpack-deps_test_emscripten.sh` => `scripts/ci/build_emscripten.sh` + These scripts `scripts/ci/build.sh` and `scripts/ci/build_ossfuzz.sh` are also used by CircleCI, see `.circleci/config.yml`. If the tests passed successfully, the docker image will get tagged by the version defined within the corresponding `Dockerfile`. Finally, a comment will be added to the PR that contains the full repository, version and repository digest -of the freshly created docker image. \ No newline at end of file +of the freshly created docker image. From 35870549db3accf00964f5cb85cf250663b73e19 Mon Sep 17 00:00:00 2001 From: Marenz Date: Tue, 23 Aug 2022 22:48:42 +0200 Subject: [PATCH 059/109] Dockerfile.emscripten: Use ``&&`` instead of ``;`` everywhere --- .../buildpack-deps/Dockerfile.emscripten | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/scripts/docker/buildpack-deps/Dockerfile.emscripten b/scripts/docker/buildpack-deps/Dockerfile.emscripten index d52abc2e0f..237405c4c6 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.emscripten +++ b/scripts/docker/buildpack-deps/Dockerfile.emscripten @@ -36,16 +36,16 @@ FROM emscripten/emsdk:3.1.19 AS base LABEL version="12" ADD emscripten.jam /usr/src -RUN set -ex; \ -\ +RUN set -ex && \ + \ apt-get update && \ apt-get install lz4 --no-install-recommends && \ -\ - cd /usr/src; \ - git clone https://github.com/Z3Prover/z3.git -b z3-4.8.17 --depth 1 ; \ - cd z3; \ - mkdir build; \ - cd build; \ + \ + cd /usr/src && \ + git clone https://github.com/Z3Prover/z3.git -b z3-4.8.17 --depth 1 && \ + cd z3 && \ + mkdir build && \ + cd build && \ emcmake cmake \ -DCMAKE_INSTALL_PREFIX=$(em-config CACHE)/sysroot/usr \ -DCMAKE_BUILD_TYPE=MinSizeRel \ @@ -55,21 +55,22 @@ RUN set -ex; \ -DZ3_BUILD_EXECUTABLE=OFF \ -DZ3_SINGLE_THREADED=ON \ -DCMAKE_CXX_FLAGS="-s DISABLE_EXCEPTION_CATCHING=0" \ - ..; \ - make ; make install; \ - rm -r /usr/src/z3; \ - cd /usr/src; \ -\ - wget -q 'https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.bz2' -O boost.tar.bz2; \ - test "$(sha256sum boost.tar.bz2)" = "953db31e016db7bb207f11432bef7df100516eeb746843fa0486a222e3fd49cb boost.tar.bz2"; \ - tar -xf boost.tar.bz2; \ - rm boost.tar.bz2; \ - cd boost_1_75_0; \ - mv ../emscripten.jam .; \ - ./bootstrap.sh; \ - echo "using emscripten : : em++ ;" >> project-config.jam ; \ + .. && \ + make && \ + make install && \ + rm -r /usr/src/z3 && \ + cd /usr/src && \ + \ + wget -q 'https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.bz2' -O boost.tar.bz2 && \ + test "$(sha256sum boost.tar.bz2)" = "953db31e016db7bb207f11432bef7df100516eeb746843fa0486a222e3fd49cb boost.tar.bz2" && \ + tar -xf boost.tar.bz2 && \ + rm boost.tar.bz2 && \ + cd boost_1_75_0 && \ + mv ../emscripten.jam . && \ + ./bootstrap.sh && \ + echo "using emscripten : : em++ ;" >> project-config.jam && \ ./b2 toolset=emscripten link=static variant=release threading=single runtime-link=static \ --with-system --with-filesystem --with-test --with-program_options \ cxxflags="-s DISABLE_EXCEPTION_CATCHING=0 -Wno-unused-local-typedef -Wno-variadic-macros -Wno-c99-extensions -Wno-all" \ - --prefix=$(em-config CACHE)/sysroot/usr install; \ + --prefix=$(em-config CACHE)/sysroot/usr install && \ rm -r /usr/src/boost_1_75_0 From 3d54bfd0c35e8a9b480c67b28be27620387e8906 Mon Sep 17 00:00:00 2001 From: tcoyvwac <53616399+tcoyvwac@users.noreply.github.com> Date: Wed, 17 Aug 2022 19:43:51 +0200 Subject: [PATCH 060/109] ast: condense duplicate code AST.cpp: * Added findClause() helper function to anonymous namespace. --- libsolidity/ast/AST.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 04c47a155f..024fc3e38e 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -29,6 +29,8 @@ #include #include +#include + #include #include @@ -38,6 +40,17 @@ using namespace std; using namespace solidity; using namespace solidity::frontend; +namespace +{ +TryCatchClause const* findClause(vector> const& _clauses, optional _errorName = {}) +{ + for (auto const& clause: ranges::views::tail(_clauses)) + if (_errorName.has_value() ? clause->errorName() == _errorName : clause->errorName().empty()) + return clause.get(); + return nullptr; +} +} + ASTNode::ASTNode(int64_t _id, SourceLocation _location): m_id(static_cast(_id)), m_location(std::move(_location)) @@ -981,26 +994,14 @@ TryCatchClause const* TryStatement::successClause() const return m_clauses[0].get(); } -TryCatchClause const* TryStatement::panicClause() const -{ - for (size_t i = 1; i < m_clauses.size(); ++i) - if (m_clauses[i]->errorName() == "Panic") - return m_clauses[i].get(); - return nullptr; +TryCatchClause const* TryStatement::panicClause() const { + return findClause(m_clauses, "Panic"); } -TryCatchClause const* TryStatement::errorClause() const -{ - for (size_t i = 1; i < m_clauses.size(); ++i) - if (m_clauses[i]->errorName() == "Error") - return m_clauses[i].get(); - return nullptr; +TryCatchClause const* TryStatement::errorClause() const { + return findClause(m_clauses, "Error"); } -TryCatchClause const* TryStatement::fallbackClause() const -{ - for (size_t i = 1; i < m_clauses.size(); ++i) - if (m_clauses[i]->errorName().empty()) - return m_clauses[i].get(); - return nullptr; +TryCatchClause const* TryStatement::fallbackClause() const { + return findClause(m_clauses); } From 0475ec81f03e4cd06cb372a5abcfd1bcb8c27c59 Mon Sep 17 00:00:00 2001 From: Marenz Date: Mon, 22 Aug 2022 16:09:38 +0200 Subject: [PATCH 061/109] Cleanup static z3 script to work similar to release_ppa --- scripts/common.sh | 22 +++++++++++++ scripts/deps-ppa/static_z3.sh | 58 ++++++++++++++++++++++------------- scripts/release_ppa.sh | 17 +--------- 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/scripts/common.sh b/scripts/common.sh index 1ea0e1fc1f..98f63ecb80 100644 --- a/scripts/common.sh +++ b/scripts/common.sh @@ -40,6 +40,28 @@ else function printLog { echo "$(tput setaf 3)$1$(tput sgr0)"; } fi +function checkDputEntries +{ + local pattern="$1" + grep "${pattern}" /etc/dput.cf --quiet || \ + fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in release_ppa.sh for more information)." +} + +function sourcePPAConfig +{ + [[ "$LAUNCHPAD_KEYID" == "" && "$LAUNCHPAD_EMAIL" == "" ]] || fail + + # source keyid and email from .release_ppa_auth + if [[ -e .release_ppa_auth ]] + then + # shellcheck source=/dev/null + source "${REPO_ROOT}/.release_ppa_auth" + fi + + [[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \ + fail "Error: Couldn't find variables \$LAUNCHPAD_KEYID or \$LAUNCHPAD_EMAIL in sourced file .release_ppa_auth (check top comment in $0 for more information)." +} + function printStackTrace { printWarning "" diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index a2a632cc2e..e2a5cb6407 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -3,9 +3,6 @@ ## This is used to package .deb packages and upload them to the launchpad ## ppa servers for building. ## -## The gnupg key for "builds@ethereum.org" has to be present in order to sign -## the package. -## ## It will clone the Z3 git from github on the specified version tag, ## create a source archive and push it to the ubuntu ppa servers. ## @@ -16,16 +13,33 @@ ## method = ftp ## incoming = ~ethereum/cpp-build-deps ## login = anonymous - +## +## To interact with launchpad, you need to set the variables $LAUNCHPAD_EMAIL +## and $LAUNCHPAD_KEYID in the file .release_ppa_auth in the root directory of +## the project to your launchpad email and pgp keyid. +## This could for example look like this: +## +## LAUNCHPAD_EMAIL=your-launchpad-email@ethereum.org +## LAUNCHPAD_KEYID=123ABCFFFFFFFF ## ############################################################################## -set -ev +set -e -keyid=70D110489D66E2F6 -email=builds@ethereum.org packagename=z3-static -version=4.8.17 +version="$1" + +REPO_ROOT="$(dirname "$0")/../.." + +# shellcheck source=/dev/null +source "${REPO_ROOT}/scripts/common.sh" + +[[ $version != "" ]] || fail "Usage: $0 " + +sourcePPAConfig + +# Sanity check +checkDputEntries "\[cpp-build-deps\]" DISTRIBUTIONS="focal impish jammy kinetic" @@ -40,7 +54,7 @@ pparepo=cpp-build-deps ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/${pparepo}/+files # Fetch source -git clone --branch z3-${version} https://github.com/Z3Prover/z3.git +git clone --branch "z3-${version}" https://github.com/Z3Prover/z3.git cd z3 debversion="${version}" @@ -50,11 +64,11 @@ CMAKE_OPTIONS="-DZ3_BUILD_LIBZ3_SHARED=OFF -DCMAKE_BUILD_TYPE=Release" # gzip will create different tars all the time and we are not allowed # to upload the same file twice with different contents, so we only # create it once. -if [ ! -e /tmp/${packagename}_${debversion}.orig.tar.gz ] +if [ ! -e "/tmp/${packagename}_${debversion}.orig.tar.gz" ] then - tar --exclude .git -czf /tmp/${packagename}_${debversion}.orig.tar.gz . + tar --exclude .git -czf "/tmp/${packagename}_${debversion}.orig.tar.gz" . fi -cp /tmp/${packagename}_${debversion}.orig.tar.gz ../ +cp "/tmp/${packagename}_${debversion}.orig.tar.gz" ../ # Create debian package information @@ -209,7 +223,7 @@ echo "3.0 (quilt)" > debian/source/format chmod +x debian/rules versionsuffix=1ubuntu0~${distribution} -EMAIL="$email" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}" +EMAIL="$LAUNCHPAD_EMAIL" dch -v "1:${debversion}-${versionsuffix}" "build of ${version}" # build source package # If packages is rejected because original source is already present, add @@ -226,26 +240,26 @@ cd .. orig="${packagename}_${debversion}.orig.tar.gz" # shellcheck disable=SC2012 orig_size=$(ls -l "$orig" | cut -d ' ' -f 5) -orig_sha1=$(sha1sum $orig | cut -d ' ' -f 1) -orig_sha256=$(sha256sum $orig | cut -d ' ' -f 1) -orig_md5=$(md5sum $orig | cut -d ' ' -f 1) +orig_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) +orig_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) +orig_md5=$(md5sum "$orig" | cut -d ' ' -f 1) -if wget --quiet -O $orig-tmp "$ppafilesurl/$orig" +if wget --quiet -O "$orig-tmp" "$ppafilesurl/$orig" then echo "[WARN] Original tarball found in Ubuntu archive, using it instead" - mv $orig-tmp $orig + mv "${orig}-tmp" "$orig" # shellcheck disable=SC2012 new_size=$(ls -l ./*.orig.tar.gz | cut -d ' ' -f 5) - new_sha1=$(sha1sum $orig | cut -d ' ' -f 1) - new_sha256=$(sha256sum $orig | cut -d ' ' -f 1) - new_md5=$(md5sum $orig | cut -d ' ' -f 1) + new_sha1=$(sha1sum "$orig" | cut -d ' ' -f 1) + new_sha256=$(sha256sum "$orig" | cut -d ' ' -f 1) + new_md5=$(md5sum "$orig" | cut -d ' ' -f 1) sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" ./*.dsc sed -i -e "s,$orig_sha1,$new_sha1,g" -e "s,$orig_sha256,$new_sha256,g" -e "s,$orig_size,$new_size,g" -e "s,$orig_md5,$new_md5,g" ./*.changes fi ) # sign the package -debsign --re-sign -k "${keyid}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" +debsign --re-sign -k "${LAUNCHPAD_KEYID}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" # upload dput "${pparepo}" "../${packagename}_${debversion}-${versionsuffix}_source.changes" diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index 6e3eae01cc..ac0a689888 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -47,7 +47,6 @@ set -e REPO_ROOT="$(dirname "$0")/.." -# for the "fail" function # shellcheck source=scripts/common.sh source "${REPO_ROOT}/scripts/common.sh" @@ -62,15 +61,7 @@ is_release() { [[ "${branch}" =~ ^v[0-9]+(\.[0-9]+)*$ ]] } -# source keyid and email from .release_ppa_auth -if [[ -e .release_ppa_auth ]] -then - # shellcheck source=/dev/null - source "${REPO_ROOT}/.release_ppa_auth" -fi - -[[ "$LAUNCHPAD_KEYID" != "" && "$LAUNCHPAD_EMAIL" != "" ]] || \ - fail "Error: Couldn't find variables \$LAUNCHPAD_KEYID or \$LAUNCHPAD_EMAIL in sourced file .release_ppa_auth (check top comment in $0 for more information)." +sourcePPAConfig packagename=solc @@ -79,12 +70,6 @@ static_build_distribution=focal DISTRIBUTIONS="focal jammy kinetic" -function checkDputEntries { - local pattern="$1" - grep "${pattern}" /etc/dput.cf --quiet || \ - fail "Error: Missing ${pattern//\\/} section in /etc/dput.cf (check top comment in ${0} for more information)." -} - if is_release then DISTRIBUTIONS="$DISTRIBUTIONS STATIC" From c5e9b6e66604129fb14124e1d59147e54a9fa983 Mon Sep 17 00:00:00 2001 From: Marenz Date: Thu, 25 Aug 2022 15:07:06 +0200 Subject: [PATCH 062/109] static_z3.sh: Update releases to include only maintained ones --- scripts/deps-ppa/static_z3.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deps-ppa/static_z3.sh b/scripts/deps-ppa/static_z3.sh index e2a5cb6407..fa237ba08f 100755 --- a/scripts/deps-ppa/static_z3.sh +++ b/scripts/deps-ppa/static_z3.sh @@ -41,7 +41,7 @@ sourcePPAConfig # Sanity check checkDputEntries "\[cpp-build-deps\]" -DISTRIBUTIONS="focal impish jammy kinetic" +DISTRIBUTIONS="focal jammy kinetic" for distribution in $DISTRIBUTIONS do From 5849fc3bf154a5ecb90614ec0befdaf591a937f6 Mon Sep 17 00:00:00 2001 From: kuzdogan Date: Thu, 25 Aug 2022 15:25:39 +0200 Subject: [PATCH 063/109] Update contract metadata docs --- docs/metadata.rst | 91 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 18 deletions(-) diff --git a/docs/metadata.rst b/docs/metadata.rst index e92a7c0d58..317ad2204b 100644 --- a/docs/metadata.rst +++ b/docs/metadata.rst @@ -46,20 +46,20 @@ explanatory purposes. // to the language. "compiler": { // Required for Solidity: Version of the compiler - "version": "0.4.6+commit.2dabbdf0.Emscripten.clang", + "version": "0.8.2+commit.661d1103", // Optional: Hash of the compiler binary which produced this output "keccak256": "0x123..." }, - // Required: Compilation source files/source units, keys are file names + // Required: Compilation source files/source units, keys are file paths "sources": { - "myFile.sol": { + "myDirectory/myFile.sol": { // Required: keccak256 hash of the source file "keccak256": "0x123...", // Required (unless "content" is used, see below): Sorted URL(s) - // to the source file, protocol is more or less arbitrary, but a - // Swarm URL is recommended - "urls": [ "bzzr://56ab..." ], + // to the source file, protocol is more or less arbitrary, but an + // IPFS URL is recommended + "urls": [ "bzz-raw://7d7a...", "dweb:/ipfs/QmN..." ], // Optional: SPDX license identifier as given in the source file "license": "MIT" }, @@ -73,7 +73,7 @@ explanatory purposes. // Required: Compiler settings "settings": { - // Required for Solidity: Sorted list of remappings + // Required for Solidity: Sorted list of import remappings "remappings": [ ":g=/dir" ], // Optional: Optimizer settings. The fields "enabled" and "runs" are deprecated // and are only given for backwards-compatibility. @@ -100,15 +100,15 @@ explanatory purposes. } }, "metadata": { - // Reflects the setting used in the input json, defaults to false + // Reflects the setting used in the input json, defaults to "false" "useLiteralContent": true, // Reflects the setting used in the input json, defaults to "ipfs" "bytecodeHash": "ipfs" }, - // Required for Solidity: File and name of the contract or library this + // Required for Solidity: File path and the name of the contract or library this // metadata is created for. "compilationTarget": { - "myFile.sol": "MyContract" + "myDirectory/myFile.sol": "MyContract" }, // Required for Solidity: Addresses for libraries used "libraries": { @@ -118,12 +118,66 @@ explanatory purposes. // Required: Generated information about the contract. "output": { - // Required: ABI definition of the contract + // Required: ABI definition of the contract. See "Contract ABI Specification" "abi": [/* ... */], + // Required: NatSpec developer documentation of the contract. + "devdoc": { + "version": 1 // NatSpec version + "kind": "dev", + // Contents of the @author NatSpec field of the contract + "author": "John Doe", + // Contents of the @title NatSpec field of the contract + "title": "MyERC20: an example ERC20" + // Contents of the @dev NatSpec field of the contract + "details": "Interface of the ERC20 standard as defined in the EIP. See https://eips.ethereum.org/EIPS/eip-20 for details", + "methods": { + "transfer(address,uint256)": { + // Contents of the @dev NatSpec field of the method + "details": "Returns a boolean value indicating whether the operation succeeded. Must be called by the token holder address", + // Contents of the @param NatSpec fields of the method + "params": { + "_value": "The amount tokens to be transferred", + "_to": "The receiver address" + } + // Contents of the @return NatSpec field. + "returns": { + // Return var name (here "success") if exists. "_0" as key if return var is unnamed + "success": "a boolean value indicating whether the operation succeeded" + } + } + }, + "stateVariables": { + "owner": { + // Contents of the @dev NatSpec field of the state variable + "details": "Must be set during contract creation. Can then only be changed by the owner" + } + } + "events": { + "Transfer(address,address,uint256)": { + "details": "Emitted when `value` tokens are moved from one account (`from`) toanother (`to`)." + "params": { + "from": "The sender address" + "to": "The receiver address" + "value": "The token amount" + } + } + } + }, // Required: NatSpec user documentation of the contract - "userdoc": [/* ... */], - // Required: NatSpec developer documentation of the contract - "devdoc": [/* ... */] + "userdoc": { + "version": 1 // NatSpec version + "kind": "user", + "methods": { + "transfer(address,uint256)": { + "notice": "Transfers `_value` tokens to address `_to`" + } + }, + "events": { + "Transfer(address,address,uint256)": { + "notice": "`_value` tokens have been moved from `from` to `to`" + } + } + } } } @@ -160,7 +214,7 @@ to the end of the deployed bytecode 0x00 0x33 So in order to retrieve the data, the end of the deployed bytecode can be checked -to match that pattern and use the IPFS hash to retrieve the file. +to match that pattern and the IPFS hash can be used to retrieve the file (if pinned/published). 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 @@ -184,14 +238,15 @@ Usage for Automatic Interface Generation and NatSpec ==================================================== The metadata is used in the following way: A component that wants to interact -with a contract (e.g. Mist or any wallet) retrieves the code of the contract, -from that the IPFS/Swarm hash of a file which is then retrieved. That file +with a contract (e.g. a wallet) retrieves the code of the contract. +It decodes the CBOR encoded section containing the IPFS/Swarm hash of the +metadata file. With that hash, the metadata file is retrieved. That file is JSON-decoded into a structure like above. The component can then use the ABI to automatically generate a rudimentary user interface for the contract. -Furthermore, the wallet can use the NatSpec user documentation to display a confirmation message to the user +Furthermore, the wallet can use the NatSpec user documentation to display a human-readable confirmation message to the user whenever they interact with the contract, together with requesting authorization for the transaction signature. From 484c9d3ff0bfd2d5c76b5eff4b1dab13ee30572d Mon Sep 17 00:00:00 2001 From: Marenz Date: Thu, 25 Aug 2022 16:33:56 +0200 Subject: [PATCH 064/109] Update docker images for emscripten. --- .circleci/config.yml | 4 ++-- scripts/build_emscripten.sh | 4 ++-- scripts/ci/build_emscripten.sh | 5 +++-- scripts/docker/buildpack-deps/README.md | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 23fb3ae0a0..af193b50fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,8 +21,8 @@ parameters: default: "solbuildpackpusher/solidity-buildpack-deps@sha256:048002d71a1f86f83dedb79dd057760b752256c75646ba5ad5c1bbe92e1695aa" emscripten-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:emscripten-11 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:0ad7c65e8c54d926ba9cb80d56246e4fc49f9284ad5188aaaa4834f46ab0c315" + # solbuildpackpusher/solidity-buildpack-deps:emscripten-12 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:65a82268792a5a2ee85ad432baf04a056c3a4006941ab3a4416eb1a0614883f3" evm-version: type: string default: london diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index 841cc26b31..a678d08ab3 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -34,7 +34,7 @@ else BUILD_DIR="$1" fi -# solbuildpackpusher/solidity-buildpack-deps:emscripten-11 +# solbuildpackpusher/solidity-buildpack-deps:emscripten-12 docker run -v "$(pwd):/root/project" -w /root/project \ - solbuildpackpusher/solidity-buildpack-deps@sha256:0ad7c65e8c54d926ba9cb80d56246e4fc49f9284ad5188aaaa4834f46ab0c315 \ + solbuildpackpusher/solidity-buildpack-deps@sha256:65a82268792a5a2ee85ad432baf04a056c3a4006941ab3a4416eb1a0614883f3 \ ./scripts/ci/build_emscripten.sh "$BUILD_DIR" diff --git a/scripts/ci/build_emscripten.sh b/scripts/ci/build_emscripten.sh index 6bc1754f37..f2e475c2ae 100755 --- a/scripts/ci/build_emscripten.sh +++ b/scripts/ci/build_emscripten.sh @@ -62,11 +62,12 @@ then echo -n "$CIRCLE_SHA1" >commit_hash.txt fi -# Disable warnings for unqualified "move()" calls, introduced and enabled by +# Disable warnings for unqualified `move()` calls, introduced and enabled by # default in clang-16 which is what the emscripten docker image uses. # Additionally, disable the warning for unknown warnings here, as this script is # also used with earlier clang versions. -CMAKE_CXX_FLAGS="-Wno-unqualified-std-cast-call -Wno-unknown-warning-option" +# TODO: This can be removed if and when all usages of `move()` in our codebase use the `std::` qualifier. +CMAKE_CXX_FLAGS="-Wno-unqualified-std-cast-call" mkdir -p "$BUILD_DIR" diff --git a/scripts/docker/buildpack-deps/README.md b/scripts/docker/buildpack-deps/README.md index bce45e6159..7f6352581c 100644 --- a/scripts/docker/buildpack-deps/README.md +++ b/scripts/docker/buildpack-deps/README.md @@ -35,3 +35,5 @@ These scripts `scripts/ci/build.sh` and `scripts/ci/build_ossfuzz.sh` are also u If the tests passed successfully, the docker image will get tagged by the version defined within the corresponding `Dockerfile`. Finally, a comment will be added to the PR that contains the full repository, version and repository digest of the freshly created docker image. + +The files `.circleci/config.yml` and `scripts/build_emscripten.sh` need to be updated with the new hash posted in the comment. From 71c3c26b2913880fa2e2945741409c844a659e15 Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Wed, 24 Aug 2022 12:23:57 +0200 Subject: [PATCH 065/109] Fix inconsistent nested dependency in safe-contracts --- test/externalTests/gnosis.sh | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/test/externalTests/gnosis.sh b/test/externalTests/gnosis.sh index af2b12508a..81e5180c60 100755 --- a/test/externalTests/gnosis.sh +++ b/test/externalTests/gnosis.sh @@ -31,8 +31,8 @@ BINARY_TYPE="$1" BINARY_PATH="$(realpath "$2")" SELECTED_PRESETS="$3" -function compile_fn { npm run build; } -function test_fn { npm test; } +function compile_fn { npx npm run build; } +function test_fn { npx npm test; } function gnosis_safe_test { @@ -87,33 +87,44 @@ function gnosis_safe_test sed -i "s|it\(('can only be called from Safe itself'\)|it.skip\1|g" test/libraries/Migration.spec.ts sed -i "s|it\(('should enforce delegatecall to MultiSend'\)|it.skip\1|g" test/libraries/MultiSend.spec.ts + # Force nested abstract-provider dependencies to be at version 5.6.0. Version 5.7.0 of @ethersproject/abstract-provider + # introduced a new field in FeeData, which causes clashes unless all dependency packages of abstract-provider are pegged + # to the same version. As we've already had to peg @ethersproject/contracts to 5.6.0 earlier, we are doing so now with + # @ethersproject/abstract-provider as well. + jq '.overrides."@ethersproject/abstract-provider"="5.6.0" | + .overrides."@ethersproject/abstract-signer@5.6.0" + ."@ethersproject/abstract-provider"="5.6.0"' package.json > package.json.tmp + mv package.json.tmp package.json + neutralize_package_lock neutralize_package_json_hooks force_hardhat_compiler_binary "$config_file" "$BINARY_TYPE" "$BINARY_PATH" force_hardhat_compiler_settings "$config_file" "$(first_word "$SELECTED_PRESETS")" "$config_var" - npm install - npm install hardhat-gas-reporter + # npm@8.3.0+ is required for `overrides` support + npm install npm@>8.3.0 + npx npm install + npx npm install hardhat-gas-reporter # Typescript compilation fails with typescript >= 4.7: # Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective` - npm install "typescript@<4.7.0" + npx npm install "typescript@<4.7.0" # With ethers.js 5.6.2 many tests for revert messages fail. # TODO: Remove when https://github.com/ethers-io/ethers.js/discussions/2849 is resolved. - npm install ethers@5.6.1 + npx npm install ethers@5.6.1 # Note that ethers@5.6.1 depends on @ethersproject/contracts@5.6.0 while the dependency on hardhat-deploy # pulls @ethersproject/contracts@5.6.1 (latest). Force 5.6.0 to avoid errors due to having two copies. - npm install @ethersproject/contracts@5.6.0 + npx npm install @ethersproject/contracts@5.6.0 # 2.1.1 started causing failures in safe-contracts external tests after a contract address check was introduced # in https://github.com/NomicFoundation/hardhat/pull/2916, and so to avoid errors, the package is now pegged. # TODO: Remove when https://github.com/safe-global/safe-contracts/issues/436 is resolved. - npm install @nomiclabs/hardhat-ethers@2.1.0 + npx npm install @nomiclabs/hardhat-ethers@2.1.0 # Hardhat 2.9.5 introduced a bug with handling padded arguments to getStorageAt(). # TODO: Remove when https://github.com/NomicFoundation/hardhat/issues/2709 is fixed. - npm install hardhat@2.9.4 + npx npm install hardhat@2.9.4 replace_version_pragmas [[ $BINARY_TYPE == solcjs ]] && force_solc_modules "${DIR}/solc/dist" From e99e93ff5b528912d51a2e3b7c0c67e37180214b Mon Sep 17 00:00:00 2001 From: Leo Alt Date: Mon, 29 Aug 2022 11:15:53 +0200 Subject: [PATCH 066/109] Fix pylint warning --- scripts/common/rest_api_helpers.py | 4 ++-- test/scripts/test_externalTests_benchmark_downloader.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/common/rest_api_helpers.py b/scripts/common/rest_api_helpers.py index 4068a5e1e3..31f973e818 100644 --- a/scripts/common/rest_api_helpers.py +++ b/scripts/common/rest_api_helpers.py @@ -48,7 +48,7 @@ def query_api(url: str, params: Mapping[str, str], debug_requests=False) -> dict if len(params) > 0: print(f'QUERY: {params}') - response = requests.get(url, params=params) + response = requests.get(url, params=params, timeout=60) response.raise_for_status() if debug_requests: @@ -67,7 +67,7 @@ def download_file(url: str, target_path: Path, overwrite=False): if not overwrite and target_path.exists(): raise FileAlreadyExists(f"Refusing to overwrite existing file: '{target_path}'.") - with requests.get(url, stream=True) as request: + with requests.get(url, stream=True, timeout=60) as request: with open(target_path, 'wb') as target_file: shutil.copyfileobj(request.raw, target_file) diff --git a/test/scripts/test_externalTests_benchmark_downloader.py b/test/scripts/test_externalTests_benchmark_downloader.py index e29d140112..aead618470 100644 --- a/test/scripts/test_externalTests_benchmark_downloader.py +++ b/test/scripts/test_externalTests_benchmark_downloader.py @@ -31,7 +31,7 @@ def _git_run_command_mock(command): "If you have updated the code, please remember to add matching command fixtures above." ) -def _requests_get_mock(url, params): +def _requests_get_mock(url, params, timeout): response_mock = Mock() if url == 'https://api.github.com/repos/ethereum/solidity/pulls/12818': @@ -174,6 +174,7 @@ def _requests_get_mock(url, params): "The test tried to perform an unexpected GET request.\n" f"URL: {url}\n" + (f"query: {params}\n" if len(params) > 0 else "") + + f"timeout: {timeout}\n" + "If you have updated the code, please remember to add matching response fixtures above." ) From a2a80401ed4c54f8fc212edf577129f0d2087628 Mon Sep 17 00:00:00 2001 From: nishant-sachdeva Date: Fri, 26 Aug 2022 20:48:30 +0530 Subject: [PATCH 067/109] Meetings on Mondays and Wednesdays should happen at the same time --- docs/contributing.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index ceb0b44ed3..9da7f02d0f 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -30,8 +30,7 @@ Team Calls If you have issues or pull requests to discuss, or are interested in hearing what the team and contributors are working on, you can join our public team calls: -- Mondays at 3pm CET/CEST. -- Wednesdays at 2pm CET/CEST. +- Mondays and Wednesdays at 3pm CET/CEST. Both calls take place on `Jitsi `_. From eb644b1d8e53daf6123b273ec5f77276bc3c7da0 Mon Sep 17 00:00:00 2001 From: MeetRajput00 Date: Mon, 29 Aug 2022 16:48:14 +0530 Subject: [PATCH 068/109] fixed grammar typo in readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ccd8dc6346..1f00465323 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ For a good overview and starting point, please check out the official [Solidity Solidity is a statically-typed curly-braces programming language designed for developing smart contracts that run on the Ethereum Virtual Machine. Smart contracts are programs that are executed inside a peer-to-peer -network where nobody has special authority over the execution, and thus they allow to implement tokens of value, +network where nobody has special authority over the execution, and thus they allow anyone to implement tokens of value, ownership, voting, and other kinds of logic. When deploying contracts, you should use the latest released version of From f508494f52feb45f22404801389175ce12e77013 Mon Sep 17 00:00:00 2001 From: Marenz Date: Mon, 29 Aug 2022 15:23:29 +0200 Subject: [PATCH 069/109] Fix undefined order of evaluation --- libyul/backends/evm/EVMDialect.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 35fa5f88eb..c86be6f695 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -82,7 +82,8 @@ pair createEVMFunction( _assembly.appendInstruction(_instruction); }; - return {f.name, move(f)}; + YulString name = f.name; + return {name, move(f)}; } pair createFunction( From 81c4604b8a880c02a6b850133845b5c8114f938b Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Sun, 28 Aug 2022 19:26:34 -0300 Subject: [PATCH 070/109] Clarify effect of memory unsafe assembly --- docs/assembly.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/assembly.rst b/docs/assembly.rst index 6ad9ebdad7..b527ffbafd 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -289,8 +289,8 @@ perform additional memory optimizations, if it can rely on certain assumptions a While we recommend to always respect Solidity's memory model, inline assembly allows you to use memory in an incompatible way. Therefore, moving stack variables to memory and additional memory optimizations are, -by default, disabled in the presence of any inline assembly block that contains a memory operation or assigns -to Solidity variables in memory. +by default, globally disabled in the presence of any inline assembly block that contains a memory operation +or assigns to Solidity variables in memory. However, you can specifically annotate an assembly block to indicate that it in fact respects Solidity's memory model as follows: From 216d38cefebecc499818ec160153bdf969c59c5d Mon Sep 17 00:00:00 2001 From: nishant-sachdeva Date: Mon, 29 Aug 2022 22:41:19 +0530 Subject: [PATCH 071/109] added yul exception to compiler error types --- docs/using-the-compiler.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index 3c2ec38f9b..d6bf94a2cb 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -614,8 +614,9 @@ Error Types 10. ``Exception``: Unknown failure during compilation - this should be reported as an issue. 11. ``CompilerError``: Invalid use of the compiler stack - this should be reported as an issue. 12. ``FatalError``: Fatal error not processed correctly - this should be reported as an issue. -13. ``Warning``: A warning, which didn't stop the compilation, but should be addressed if possible. -14. ``Info``: Information that the compiler thinks the user might find useful, but is not dangerous and does not necessarily need to be addressed. +13. ``YulException``: Error during Yul Code generation - this should be reported as an issue. +14. ``Warning``: A warning, which didn't stop the compilation, but should be addressed if possible. +15. ``Info``: Information that the compiler thinks the user might find useful, but is not dangerous and does not necessarily need to be addressed. .. _compiler-tools: From 99400a6121a8709e2f9c1464ae92cb5de2fe2724 Mon Sep 17 00:00:00 2001 From: minaminao Date: Tue, 30 Aug 2022 09:35:12 +0900 Subject: [PATCH 072/109] Fix typo --- docs/internals/optimizer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/internals/optimizer.rst b/docs/internals/optimizer.rst index 97a250eeda..5ad0f19e55 100644 --- a/docs/internals/optimizer.rst +++ b/docs/internals/optimizer.rst @@ -683,7 +683,7 @@ Conflicting values are resolved in the following way: - "unused", "undecided" -> "undecided" - "unused", "used" -> "used" -- "undecided, "used" -> "used" +- "undecided", "used" -> "used" For for-loops, the condition, body and post-part are visited twice, taking the joining control-flow at the condition into account. From a08d39ce8474887ad3eea8d84dd158e469bb3f0e Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Tue, 30 Aug 2022 10:05:49 +0200 Subject: [PATCH 073/109] Update issue selector, and remove auto labeling --- .github/ISSUE_TEMPLATE/config.yml | 11 +++++++---- .github/ISSUE_TEMPLATE/feature_request.md | 2 ++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index b4e9b3d505..c34dedb740 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,14 +1,17 @@ blank_issues_enabled: false contact_links: - name: Bug Report - url: https://github.com/ethereum/solidity/issues/new?template=bug_report.md&projects=ethereum/solidity/43&labels=bug+%3Abug%3A - about: Bug reports about the Solidity Compiler. + url: https://github.com/ethereum/solidity/issues/new?template=bug_report.md&projects=ethereum/solidity/43 + about: Bug reports for the Solidity Compiler. - name: Documentation Issue - url: https://github.com/ethereum/solidity/issues/new?template=documentation_issue.md&projects=ethereum/solidity/43&labels=documentation+%3Abook%3A + url: https://github.com/ethereum/solidity/issues/new?template=documentation_issue.md&projects=ethereum/solidity/43 about: Solidity documentation. - name: Feature Request - url: https://github.com/ethereum/solidity/issues/new?template=feature_request.md&projects=ethereum/solidity/43&labels=feature + url: https://github.com/ethereum/solidity/issues/new?template=feature_request.md&projects=ethereum/solidity/43 about: Solidity language or infrastructure feature requests. - name: Report a security vulnerability url: https://github.com/ethereum/solidity/security/policy about: Please review our security policy for more details. + - name: Initiate a language design or feedback discussion + url: https://forum.soliditylang.org + about: Open a thread on the Solidity forum. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 900e6977ce..e5cc0f79c1 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -10,6 +10,8 @@ name: Feature Request - [Solidity chat](https://gitter.im/ethereum/solidity) - [Stack Overflow](https://ethereum.stackexchange.com/) - Ensure the issue isn't already reported (check `feature` and `language design` labels). +- If you feel uncertain about your feature request, perhaps it's better to open a language design or feedback forum thread via the issue selector, or by going to the forum directly. + - [Solidity forum](https://forum.soliditylang.org/) *Delete the above section and the instructions in the sections below before submitting* --> From 776f74dc306ab4abbf9ab0b402e41e2a2a8dafdf Mon Sep 17 00:00:00 2001 From: Emmanuel Oaikhenan Date: Tue, 30 Aug 2022 09:23:15 +0100 Subject: [PATCH 074/109] Grammer fix --- docs/layout-of-source-files.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/layout-of-source-files.rst b/docs/layout-of-source-files.rst index cd231c1fce..9a58478586 100644 --- a/docs/layout-of-source-files.rst +++ b/docs/layout-of-source-files.rst @@ -105,7 +105,7 @@ arrays and structs. Apart from supporting more types, it involves more extensive validation and safety checks, which may result in higher gas costs, but also heightened security. It is considered non-experimental as of Solidity 0.6.0 and it is enabled by default starting -with Solidity 0.8.0. There old coder can still be selected using ``pragma abicoder v1;``. +with Solidity 0.8.0. The old ABI coder can still be selected using ``pragma abicoder v1;``. The set of types supported by the new encoder is a strict superset of the ones supported by the old one. Contracts that use it can interact with ones From f7cc29bec181e50d2942e600a7e077c27c2f77ef Mon Sep 17 00:00:00 2001 From: Marenz Date: Tue, 23 Aug 2022 19:28:45 +0200 Subject: [PATCH 075/109] Add std:: qualifier to move() calls --- libevmasm/Assembly.cpp | 10 ++--- libevmasm/CommonSubexpressionEliminator.cpp | 4 +- libevmasm/ConstantOptimiser.cpp | 4 +- libevmasm/ControlFlowGraph.cpp | 4 +- libevmasm/Inliner.cpp | 4 +- libevmasm/KnownState.cpp | 6 +-- libevmasm/PathGasMeter.cpp | 8 ++-- libsmtutil/CHCSmtLib2Interface.cpp | 4 +- libsmtutil/SMTLib2Interface.cpp | 6 +-- libsmtutil/SMTPortfolio.cpp | 2 +- libsmtutil/Z3CHCInterface.cpp | 2 +- libsolc/libsolc.cpp | 4 +- libsolidity/analysis/DeclarationContainer.cpp | 2 +- libsolidity/analysis/FunctionCallGraph.cpp | 4 +- libsolidity/analysis/NameAndTypeResolver.cpp | 4 +- libsolidity/analysis/ReferencesResolver.cpp | 2 +- libsolidity/analysis/TypeChecker.cpp | 8 ++-- libsolidity/ast/AST.cpp | 2 +- libsolidity/ast/AST.h | 4 +- libsolidity/ast/ASTJsonExporter.cpp | 12 +++--- libsolidity/ast/ASTJsonImporter.cpp | 6 +-- libsolidity/ast/TypeProvider.cpp | 2 +- libsolidity/ast/Types.cpp | 6 +-- libsolidity/codegen/CompilerContext.cpp | 2 +- libsolidity/codegen/ContractCompiler.cpp | 2 +- libsolidity/codegen/ExpressionCompiler.cpp | 8 ++-- libsolidity/codegen/ExpressionCompiler.h | 2 +- libsolidity/codegen/LValue.cpp | 2 +- .../codegen/MultiUseYulFunctionCollector.cpp | 4 +- .../codegen/ir/IRGenerationContext.cpp | 6 +-- libsolidity/codegen/ir/IRGenerator.cpp | 14 +++---- .../codegen/ir/IRGeneratorForStatements.cpp | 14 +++---- libsolidity/formal/ArraySlicePredicate.cpp | 2 +- libsolidity/formal/BMC.cpp | 8 ++-- libsolidity/formal/CHC.cpp | 6 +-- libsolidity/formal/EncodingContext.cpp | 2 +- libsolidity/formal/EncodingContext.h | 2 +- libsolidity/formal/Invariants.cpp | 4 +- libsolidity/formal/ModelChecker.cpp | 2 +- libsolidity/formal/Predicate.cpp | 6 +-- libsolidity/formal/SMTEncoder.cpp | 4 +- libsolidity/formal/SymbolicState.cpp | 16 ++++---- libsolidity/formal/SymbolicVariables.cpp | 30 +++++++-------- libsolidity/interface/ABI.cpp | 2 +- libsolidity/interface/CompilerStack.cpp | 6 +-- libsolidity/interface/ImportRemapper.cpp | 2 +- libsolidity/interface/Natspec.cpp | 8 ++-- libsolidity/interface/StandardCompiler.cpp | 8 ++-- libsolidity/interface/StorageLayout.cpp | 6 +-- libsolidity/lsp/FileRepository.cpp | 6 +-- libsolidity/lsp/GotoDefinition.cpp | 4 +- libsolidity/lsp/LanguageServer.cpp | 18 ++++----- libsolidity/lsp/Transport.cpp | 24 ++++++------ libsolidity/parsing/DocStringParser.cpp | 2 +- libsolidity/parsing/Parser.cpp | 24 ++++++------ libsolutil/Whiskers.cpp | 8 ++-- libyul/AsmParser.cpp | 18 ++++----- libyul/AsmPrinter.cpp | 2 +- libyul/ControlFlowSideEffectsCollector.cpp | 2 +- libyul/ObjectParser.cpp | 8 ++-- libyul/backends/evm/ConstantOptimiser.cpp | 6 +-- libyul/backends/evm/ControlFlowGraph.h | 2 +- .../backends/evm/ControlFlowGraphBuilder.cpp | 8 ++-- libyul/backends/evm/EVMCodeTransform.cpp | 10 ++--- libyul/backends/evm/EVMDialect.cpp | 2 +- libyul/backends/evm/EthAssemblyAdapter.cpp | 2 +- .../evm/OptimizedEVMCodeTransform.cpp | 4 +- libyul/backends/evm/StackLayoutGenerator.cpp | 12 +++--- libyul/backends/wasm/BinaryTransform.cpp | 36 +++++++++--------- libyul/backends/wasm/EVMToEwasmTranslator.cpp | 2 +- libyul/backends/wasm/TextTransform.cpp | 8 ++-- libyul/backends/wasm/WasmCodeTransform.cpp | 22 +++++------ libyul/backends/wasm/WasmDialect.cpp | 2 +- libyul/optimiser/ConditionalSimplifier.h | 2 +- libyul/optimiser/DeadCodeEliminator.h | 2 +- libyul/optimiser/ForLoopInitRewriter.cpp | 2 +- libyul/optimiser/FunctionSpecializer.cpp | 12 +++--- libyul/optimiser/KnowledgeBase.cpp | 2 +- libyul/optimiser/NameDispenser.cpp | 2 +- libyul/optimiser/NameSimplifier.cpp | 2 +- libyul/optimiser/ReasoningBasedSimplifier.cpp | 4 +- libyul/optimiser/StackCompressor.cpp | 2 +- libyul/optimiser/StackToMemoryMover.cpp | 32 ++++++++-------- .../UnusedFunctionParameterPruner.cpp | 2 +- libyul/optimiser/UnusedStoreBase.cpp | 28 +++++++------- libyul/optimiser/UnusedStoreEliminator.cpp | 2 +- test/CommonSyntaxTest.cpp | 8 ++-- test/EVMHost.cpp | 2 +- test/Metadata.cpp | 2 +- test/TestCaseReader.cpp | 2 +- test/libevmasm/Optimiser.cpp | 2 +- test/liblangutil/Scanner.cpp | 4 +- test/libsolidity/GasTest.cpp | 2 +- test/libsolidity/SMTCheckerTest.cpp | 2 +- test/libsolidity/SemanticTest.cpp | 6 +-- .../SolidityExecutionFramework.cpp | 2 +- test/libsolidity/util/TestFileParser.cpp | 2 +- test/libyul/ObjectParser.cpp | 2 +- test/libyul/Parser.cpp | 2 +- test/solc/Common.cpp | 2 +- test/yulPhaser/FitnessMetrics.cpp | 2 +- test/yulPhaser/ProgramCache.cpp | 2 +- test/yulPhaser/TestHelpers.cpp | 2 +- tools/yulPhaser/Chromosome.cpp | 2 +- tools/yulPhaser/GeneticAlgorithms.cpp | 2 +- tools/yulPhaser/Mutations.cpp | 8 ++-- tools/yulPhaser/PairSelections.h | 2 +- tools/yulPhaser/Phaser.cpp | 38 +++++++++---------- tools/yulPhaser/Population.cpp | 14 +++---- tools/yulPhaser/Program.cpp | 6 +-- tools/yulPhaser/Selections.h | 2 +- 111 files changed, 362 insertions(+), 362 deletions(-) diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 43e06ef9ba..8e06da8ae9 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -52,7 +52,7 @@ AssemblyItem const& Assembly::append(AssemblyItem _i) { assertThrow(m_deposit >= 0, AssemblyException, "Stack underflow."); m_deposit += static_cast(_i.deposit()); - m_items.emplace_back(move(_i)); + m_items.emplace_back(std::move(_i)); if (!m_items.back().location().isValid() && m_currentSourceLocation.isValid()) m_items.back().setLocation(m_currentSourceLocation); m_items.back().m_modifierDepth = m_currentModifierDepth; @@ -254,7 +254,7 @@ Json::Value Assembly::assemblyJSON(map const& _sourceIndices, if (!data.empty()) jsonItem["value"] = data; jsonItem["source"] = sourceIndex; - code.append(move(jsonItem)); + code.append(std::move(jsonItem)); if (item.type() == AssemblyItemType::Tag) { @@ -265,7 +265,7 @@ Json::Value Assembly::assemblyJSON(map const& _sourceIndices, jumpdest["source"] = sourceIndex; if (item.m_modifierDepth != 0) jumpdest["modifierDepth"] = static_cast(item.m_modifierDepth); - code.append(move(jumpdest)); + code.append(std::move(jumpdest)); } } if (_includeSourceList) @@ -464,7 +464,7 @@ map const& Assembly::optimiseInternal( } if (optimisedItems.size() < m_items.size()) { - m_items = move(optimisedItems); + m_items = std::move(optimisedItems); count++; } } @@ -478,7 +478,7 @@ map const& Assembly::optimiseInternal( *this ); - m_tagReplacements = move(tagReplacements); + m_tagReplacements = std::move(tagReplacements); return *m_tagReplacements; } diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index abae23a830..19b275cb6f 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -48,8 +48,8 @@ vector CommonSubexpressionEliminator::getOptimizedItems() { m_breakingItem = nullptr; m_storeOperations.clear(); - m_initialState = move(nextInitialState); - m_state = move(nextState); + m_initialState = std::move(nextInitialState); + m_state = std::move(nextState); }); map initialStackContents; diff --git a/libevmasm/ConstantOptimiser.cpp b/libevmasm/ConstantOptimiser.cpp index a639bc6fc4..37ac4c18bd 100644 --- a/libevmasm/ConstantOptimiser.cpp +++ b/libevmasm/ConstantOptimiser.cpp @@ -244,8 +244,8 @@ AssemblyItems ComputeMethod::findRepresentation(u256 const& _value) bigint newGas = gasNeeded(newRoutine); if (newGas < bestGas) { - bestGas = move(newGas); - routine = move(newRoutine); + bestGas = std::move(newGas); + routine = std::move(newRoutine); } } return routine; diff --git a/libevmasm/ControlFlowGraph.cpp b/libevmasm/ControlFlowGraph.cpp index d6d8adf4a3..cb648f90f2 100644 --- a/libevmasm/ControlFlowGraph.cpp +++ b/libevmasm/ControlFlowGraph.cpp @@ -236,12 +236,12 @@ void ControlFlowGraph::gatherKnowledge() item.state = _state->copy(); item.blocksSeen = _currentItem.blocksSeen; item.blocksSeen.insert(_currentItem.blockId); - workQueue.push_back(move(item)); + workQueue.push_back(std::move(item)); }; while (!workQueue.empty()) { - WorkQueueItem item = move(workQueue.back()); + WorkQueueItem item = std::move(workQueue.back()); workQueue.pop_back(); //@todo we might have to do something like incrementing the sequence number for each JUMPDEST assertThrow(!!item.blockId, OptimizerException, ""); diff --git a/libevmasm/Inliner.cpp b/libevmasm/Inliner.cpp index 527e6ae388..d365e312a9 100644 --- a/libevmasm/Inliner.cpp +++ b/libevmasm/Inliner.cpp @@ -257,7 +257,7 @@ void Inliner::optimise() if (auto exitItem = shouldInline(*tag, nextItem, *inlinableBlock)) { newItems += inlinableBlock->items | ranges::views::drop_last(1); - newItems.emplace_back(move(*exitItem)); + newItems.emplace_back(std::move(*exitItem)); // We are removing one push tag to the block we inline. --inlinableBlock->pushTagCount; @@ -277,5 +277,5 @@ void Inliner::optimise() newItems.emplace_back(item); } - m_items = move(newItems); + m_items = std::move(newItems); } diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index 841affab0a..1e886f7ab0 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -252,7 +252,7 @@ void KnownState::reduceToCommonKnowledge(KnownState const& _other, bool _combine map shiftedStack; for (auto const& stackElement: m_stackElements) shiftedStack[stackElement.first - stackDiff] = stackElement.second; - m_stackElements = move(shiftedStack); + m_stackElements = std::move(shiftedStack); m_stackHeight = _other.m_stackHeight; } @@ -333,7 +333,7 @@ KnownState::StoreOperation KnownState::storeInStorage( for (auto const& storageItem: m_storageContent) if (m_expressionClasses->knownToBeDifferent(storageItem.first, _slot) || storageItem.second == _value) storageContents.insert(storageItem); - m_storageContent = move(storageContents); + m_storageContent = std::move(storageContents); AssemblyItem item(Instruction::SSTORE, _location); Id id = m_expressionClasses->find(item, {_slot, _value}, true, m_sequenceNumber); @@ -365,7 +365,7 @@ KnownState::StoreOperation KnownState::storeInMemory(Id _slot, Id _value, Source for (auto const& memoryItem: m_memoryContent) if (m_expressionClasses->knownToBeDifferentBy32(memoryItem.first, _slot)) memoryContents.insert(memoryItem); - m_memoryContent = move(memoryContents); + m_memoryContent = std::move(memoryContents); AssemblyItem item(Instruction::MSTORE, _location); Id id = m_expressionClasses->find(item, {_slot, _value}, true, m_sequenceNumber); diff --git a/libevmasm/PathGasMeter.cpp b/libevmasm/PathGasMeter.cpp index b7c985f1bc..c165985cff 100644 --- a/libevmasm/PathGasMeter.cpp +++ b/libevmasm/PathGasMeter.cpp @@ -44,7 +44,7 @@ GasMeter::GasConsumption PathGasMeter::estimateMax( auto path = make_unique(); path->index = _startIndex; path->state = _state->copy(); - queue(move(path)); + queue(std::move(path)); GasMeter::GasConsumption gas; while (!m_queue.empty() && !gas.isInfinite) @@ -60,14 +60,14 @@ void PathGasMeter::queue(std::unique_ptr&& _newPath) ) return; m_highestGasUsagePerJumpdest[_newPath->index] = _newPath->gas; - m_queue[_newPath->index] = move(_newPath); + m_queue[_newPath->index] = std::move(_newPath); } GasMeter::GasConsumption PathGasMeter::handleQueueItem() { assertThrow(!m_queue.empty(), OptimizerException, ""); - unique_ptr path = move(m_queue.rbegin()->second); + unique_ptr path = std::move(m_queue.rbegin()->second); m_queue.erase(--m_queue.end()); shared_ptr state = path->state; @@ -129,7 +129,7 @@ GasMeter::GasConsumption PathGasMeter::handleQueueItem() newPath->largestMemoryAccess = meter.largestMemoryAccess(); newPath->state = state->copy(); newPath->visitedJumpdests = path->visitedJumpdests; - queue(move(newPath)); + queue(std::move(newPath)); } if (branchStops) diff --git a/libsmtutil/CHCSmtLib2Interface.cpp b/libsmtutil/CHCSmtLib2Interface.cpp index 630eb06193..c9b5f60531 100644 --- a/libsmtutil/CHCSmtLib2Interface.cpp +++ b/libsmtutil/CHCSmtLib2Interface.cpp @@ -44,7 +44,7 @@ CHCSmtLib2Interface::CHCSmtLib2Interface( ): CHCSolverInterface(_queryTimeout), m_smtlib2(make_unique(_queryResponses, _smtCallback, m_queryTimeout)), - m_queryResponses(move(_queryResponses)), + m_queryResponses(std::move(_queryResponses)), m_smtCallback(_smtCallback) { reset(); @@ -195,7 +195,7 @@ void CHCSmtLib2Interface::declareFunction(string const& _name, SortPointer const void CHCSmtLib2Interface::write(string _data) { - m_accumulatedOutput += move(_data) + "\n"; + m_accumulatedOutput += std::move(_data) + "\n"; } string CHCSmtLib2Interface::querySolver(string const& _input) diff --git a/libsmtutil/SMTLib2Interface.cpp b/libsmtutil/SMTLib2Interface.cpp index bd74cf2c98..3e117913aa 100644 --- a/libsmtutil/SMTLib2Interface.cpp +++ b/libsmtutil/SMTLib2Interface.cpp @@ -45,8 +45,8 @@ SMTLib2Interface::SMTLib2Interface( optional _queryTimeout ): SolverInterface(_queryTimeout), - m_queryResponses(move(_queryResponses)), - m_smtCallback(move(_smtCallback)) + m_queryResponses(std::move(_queryResponses)), + m_smtCallback(std::move(_smtCallback)) { reset(); } @@ -264,7 +264,7 @@ string SMTLib2Interface::toSmtLibSort(vector const& _sorts) void SMTLib2Interface::write(string _data) { smtAssert(!m_accumulatedOutput.empty(), ""); - m_accumulatedOutput.back() += move(_data) + "\n"; + m_accumulatedOutput.back() += std::move(_data) + "\n"; } string SMTLib2Interface::checkSatAndGetValuesCommand(vector const& _expressionsToEvaluate) diff --git a/libsmtutil/SMTPortfolio.cpp b/libsmtutil/SMTPortfolio.cpp index aec9b0a1cd..77a404a475 100644 --- a/libsmtutil/SMTPortfolio.cpp +++ b/libsmtutil/SMTPortfolio.cpp @@ -41,7 +41,7 @@ SMTPortfolio::SMTPortfolio( SolverInterface(_queryTimeout) { if (_enabledSolvers.smtlib2) - m_solvers.emplace_back(make_unique(move(_smtlib2Responses), move(_smtCallback), m_queryTimeout)); + m_solvers.emplace_back(make_unique(std::move(_smtlib2Responses), std::move(_smtCallback), m_queryTimeout)); #ifdef HAVE_Z3 if (_enabledSolvers.z3 && Z3Interface::available()) m_solvers.emplace_back(make_unique(m_queryTimeout)); diff --git a/libsmtutil/Z3CHCInterface.cpp b/libsmtutil/Z3CHCInterface.cpp index 82dca48788..bfbc9841b6 100644 --- a/libsmtutil/Z3CHCInterface.cpp +++ b/libsmtutil/Z3CHCInterface.cpp @@ -101,7 +101,7 @@ tuple Z3CHCInterface::que { result = CheckResult::UNSATISFIABLE; auto invariants = m_z3Interface->fromZ3Expr(m_solver.get_answer()); - return {result, move(invariants), {}}; + return {result, std::move(invariants), {}}; } case z3::check_result::unknown: { diff --git a/libsolc/libsolc.cpp b/libsolc/libsolc.cpp index 48cf7e0f88..4ceeeac6fa 100644 --- a/libsolc/libsolc.cpp +++ b/libsolc/libsolc.cpp @@ -56,7 +56,7 @@ string takeOverAllocation(char const* _data) for (auto iter = begin(solidityAllocations); iter != end(solidityAllocations); ++iter) if (iter->data() == _data) { - string chunk = move(*iter); + string chunk = std::move(*iter); solidityAllocations.erase(iter); return chunk; } @@ -109,7 +109,7 @@ ReadCallback::Callback wrapReadCallback(CStyleReadFileCallback _readCallback, vo string compile(string _input, CStyleReadFileCallback _readCallback, void* _readContext) { StandardCompiler compiler(wrapReadCallback(_readCallback, _readContext)); - return compiler.compile(move(_input)); + return compiler.compile(std::move(_input)); } } diff --git a/libsolidity/analysis/DeclarationContainer.cpp b/libsolidity/analysis/DeclarationContainer.cpp index 6d13243af4..b6cd3eef01 100644 --- a/libsolidity/analysis/DeclarationContainer.cpp +++ b/libsolidity/analysis/DeclarationContainer.cpp @@ -210,7 +210,7 @@ void DeclarationContainer::populateHomonyms(back_insert_iterator _it) ResolvingSettings settings; settings.recursive = true; settings.alsoInvisible = true; - vector const& declarations = m_enclosingContainer->resolveName(name, move(settings)); + vector const& declarations = m_enclosingContainer->resolveName(name, std::move(settings)); if (!declarations.empty()) _it = make_pair(location, declarations); } diff --git a/libsolidity/analysis/FunctionCallGraph.cpp b/libsolidity/analysis/FunctionCallGraph.cpp index 45da1b4f0d..e941c99c55 100644 --- a/libsolidity/analysis/FunctionCallGraph.cpp +++ b/libsolidity/analysis/FunctionCallGraph.cpp @@ -61,7 +61,7 @@ CallGraph FunctionCallGraphBuilder::buildCreationGraph(ContractDefinition const& builder.m_currentNode = CallGraph::SpecialNode::Entry; builder.processQueue(); - return move(builder.m_graph); + return std::move(builder.m_graph); } CallGraph FunctionCallGraphBuilder::buildDeployedGraph( @@ -109,7 +109,7 @@ CallGraph FunctionCallGraphBuilder::buildDeployedGraph( builder.m_currentNode = CallGraph::SpecialNode::Entry; builder.processQueue(); - return move(builder.m_graph); + return std::move(builder.m_graph); } bool FunctionCallGraphBuilder::visit(FunctionCall const& _functionCall) diff --git a/libsolidity/analysis/NameAndTypeResolver.cpp b/libsolidity/analysis/NameAndTypeResolver.cpp index 63a19a4cb9..1b58d3c9ab 100644 --- a/libsolidity/analysis/NameAndTypeResolver.cpp +++ b/libsolidity/analysis/NameAndTypeResolver.cpp @@ -184,7 +184,7 @@ vector NameAndTypeResolver::nameFromCurrentScope(ASTString c ResolvingSettings settings; settings.recursive = true; settings.alsoInvisible = _includeInvisibles; - return m_currentScope->resolveName(_name, move(settings)); + return m_currentScope->resolveName(_name, std::move(settings)); } Declaration const* NameAndTypeResolver::pathFromCurrentScope(vector const& _path) const @@ -204,7 +204,7 @@ std::vector NameAndTypeResolver::pathFromCurrentScopeWithAll settings.recursive = true; settings.alsoInvisible = false; settings.onlyVisibleAsUnqualifiedNames = true; - vector candidates = m_currentScope->resolveName(_path.front(), move(settings)); + vector candidates = m_currentScope->resolveName(_path.front(), std::move(settings)); for (size_t i = 1; i < _path.size() && candidates.size() == 1; i++) { diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index bf1fef7aa8..50b1656ef8 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -276,7 +276,7 @@ void ReferencesResolver::operator()(yul::Identifier const& _identifier) return; } - m_yulAnnotation->externalReferences[&_identifier].suffix = move(suffix); + m_yulAnnotation->externalReferences[&_identifier].suffix = std::move(suffix); m_yulAnnotation->externalReferences[&_identifier].declaration = declarations.front(); } diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index de3cdc847b..1025e6576f 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1639,7 +1639,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) if (components.size() == 1) _tuple.annotation().type = type(*components[0]); else - _tuple.annotation().type = TypeProvider::tuple(move(types)); + _tuple.annotation().type = TypeProvider::tuple(std::move(types)); // If some of the components are not LValues, the error is reported above. _tuple.annotation().isLValue = true; _tuple.annotation().isPure = false; @@ -1710,7 +1710,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple) if (components.size() == 1) _tuple.annotation().type = type(*components[0]); else - _tuple.annotation().type = TypeProvider::tuple(move(types)); + _tuple.annotation().type = TypeProvider::tuple(std::move(types)); } _tuple.annotation().isLValue = false; @@ -2811,8 +2811,8 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) } funcCallAnno.type = returnTypes.size() == 1 ? - move(returnTypes.front()) : - TypeProvider::tuple(move(returnTypes)); + std::move(returnTypes.front()) : + TypeProvider::tuple(std::move(returnTypes)); break; } diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index 04c47a155f..9cb5ae0f9f 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -239,7 +239,7 @@ vector ContractDefinition::interfaceErrors(bool _require result += (*annotation().creationCallGraph)->usedErrors + (*annotation().deployedCallGraph)->usedErrors; - return util::convertContainer>(move(result)); + return util::convertContainer>(std::move(result)); } vector, FunctionTypePointer>> const& ContractDefinition::interfaceFunctionList(bool _includeInheritedFunctions) const diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index e688b66d19..d6e41bb5f0 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -358,7 +358,7 @@ class ImportDirective: public Declaration ): Declaration(_id, _location, _unitAlias, std::move(_unitAliasLocation)), m_path(std::move(_path)), - m_symbolAliases(move(_symbolAliases)) + m_symbolAliases(std::move(_symbolAliases)) { } void accept(ASTVisitor& _visitor) override; @@ -1503,7 +1503,7 @@ class InlineAssembly: public Statement ): Statement(_id, _location, _docString), m_dialect(_dialect), - m_flags(move(_flags)), + m_flags(std::move(_flags)), m_operations(std::move(_operations)) {} void accept(ASTVisitor& _visitor) override; diff --git a/libsolidity/ast/ASTJsonExporter.cpp b/libsolidity/ast/ASTJsonExporter.cpp index e7e7a01439..d308cd90ca 100644 --- a/libsolidity/ast/ASTJsonExporter.cpp +++ b/libsolidity/ast/ASTJsonExporter.cpp @@ -336,15 +336,15 @@ bool ASTJsonExporter::visit(UsingForDirective const& _node) { Json::Value functionNode; functionNode["function"] = toJson(*function); - functionList.append(move(functionNode)); + functionList.append(std::move(functionNode)); } - attributes.emplace_back("functionList", move(functionList)); + attributes.emplace_back("functionList", std::move(functionList)); } else attributes.emplace_back("libraryName", toJson(*_node.functionsOrLibrary().front())); attributes.emplace_back("global", _node.global()); - setJsonNode(_node, "UsingForDirective", move(attributes)); + setJsonNode(_node, "UsingForDirective", std::move(attributes)); return false; } @@ -518,7 +518,7 @@ bool ASTJsonExporter::visit(ModifierInvocation const& _node) else if (dynamic_cast(declaration)) attributes.emplace_back("kind", "baseConstructorSpecifier"); } - setJsonNode(_node, "ModifierInvocation", move(attributes)); + setJsonNode(_node, "ModifierInvocation", std::move(attributes)); return false; } @@ -645,9 +645,9 @@ bool ASTJsonExporter::visit(InlineAssembly const& _node) flags.append(*flag); else flags.append(Json::nullValue); - attributes.emplace_back(make_pair("flags", move(flags))); + attributes.emplace_back(make_pair("flags", std::move(flags))); } - setJsonNode(_node, "InlineAssembly", move(attributes)); + setJsonNode(_node, "InlineAssembly", std::move(attributes)); return false; } diff --git a/libsolidity/ast/ASTJsonImporter.cpp b/libsolidity/ast/ASTJsonImporter.cpp index df329ae720..96c37003e5 100644 --- a/libsolidity/ast/ASTJsonImporter.cpp +++ b/libsolidity/ast/ASTJsonImporter.cpp @@ -299,7 +299,7 @@ ASTPointer ASTJsonImporter::createImportDirective(Json::Value c path, unitAlias, createNameSourceLocation(_node), - move(symbolAliases) + std::move(symbolAliases) ); astAssert(_node["absolutePath"].isString(), "Expected 'absolutePath' to be a string!"); @@ -391,7 +391,7 @@ ASTPointer ASTJsonImporter::createUsingForDirective(Json::Val return createASTNode( _node, - move(functions), + std::move(functions), !_node.isMember("libraryName"), _node["typeName"].isNull() ? nullptr : convertJsonToASTNode(_node["typeName"]), memberAsBool(_node, "global") @@ -686,7 +686,7 @@ ASTPointer ASTJsonImporter::createInlineAssembly(Json::Value con _node, nullOrASTString(_node, "documentation"), dialect, - move(flags), + std::move(flags), operations ); } diff --git a/libsolidity/ast/TypeProvider.cpp b/libsolidity/ast/TypeProvider.cpp index 97d230d2e4..91d1da4be5 100644 --- a/libsolidity/ast/TypeProvider.cpp +++ b/libsolidity/ast/TypeProvider.cpp @@ -404,7 +404,7 @@ TupleType const* TypeProvider::tuple(vector members) if (members.empty()) return &m_emptyTuple; - return createAndGet(move(members)); + return createAndGet(std::move(members)); } ReferenceType const* TypeProvider::withLocation(ReferenceType const* _type, DataLocation _location, bool _isPointer) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index f88d1afcef..34a6f4268c 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -125,7 +125,7 @@ MemberList::Member::Member(Declaration const* _declaration, Type const* _type): {} MemberList::Member::Member(Declaration const* _declaration, Type const* _type, string _name): - name(move(_name)), + name(std::move(_name)), type(_type), declaration(_declaration) { @@ -305,7 +305,7 @@ MemberList const& Type::members(ASTNode const* _currentScope) const MemberList::MemberMap members = nativeMembers(_currentScope); if (_currentScope) members += boundFunctions(*this, *_currentScope); - m_members[_currentScope] = make_unique(move(members)); + m_members[_currentScope] = make_unique(std::move(members)); } return *m_members[_currentScope]; } @@ -2737,7 +2737,7 @@ Type const* TupleType::mobileType() const else mobiles.push_back(nullptr); } - return TypeProvider::tuple(move(mobiles)); + return TypeProvider::tuple(std::move(mobiles)); } FunctionType::FunctionType(FunctionDefinition const& _function, Kind _kind): diff --git a/libsolidity/codegen/CompilerContext.cpp b/libsolidity/codegen/CompilerContext.cpp index dbd1a17300..f1cc5b6dd7 100644 --- a/libsolidity/codegen/CompilerContext.cpp +++ b/libsolidity/codegen/CompilerContext.cpp @@ -199,7 +199,7 @@ void CompilerContext::appendYulUtilityFunctions(OptimiserSettings const& _optimi if (!code.empty()) { appendInlineAssembly( - yul::reindent("{\n" + move(code) + "\n}"), + yul::reindent("{\n" + std::move(code) + "\n}"), {}, m_externallyUsedYulFunctions, true, diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index bdad481731..a89dbb21b8 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -1293,7 +1293,7 @@ bool ContractCompiler::visit(Return const& _return) Type const* expectedType; if (expression->annotation().type->category() == Type::Category::Tuple || types.size() != 1) - expectedType = TypeProvider::tuple(move(types)); + expectedType = TypeProvider::tuple(std::move(types)); else expectedType = types.front(); compileExpression(*expression, expectedType); diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 95087aa02d..3ee8244475 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -71,7 +71,7 @@ Type const* closestType(Type const* _type, Type const* _targetType, bool _isShif solAssert(tempComponents[i], ""); } } - return TypeProvider::tuple(move(tempComponents)); + return TypeProvider::tuple(std::move(tempComponents)); } else return _targetType->dataStoredIn(DataLocation::Storage) ? _type->mobileType() : _targetType; @@ -391,7 +391,7 @@ bool ExpressionCompiler::visit(TupleExpression const& _tuple) if (_tuple.annotation().willBeWrittenTo) { solAssert(!!m_currentLValue, ""); - lvalues.push_back(move(m_currentLValue)); + lvalues.push_back(std::move(m_currentLValue)); } } else if (_tuple.annotation().willBeWrittenTo) @@ -399,9 +399,9 @@ bool ExpressionCompiler::visit(TupleExpression const& _tuple) if (_tuple.annotation().willBeWrittenTo) { if (_tuple.components().size() == 1) - m_currentLValue = move(lvalues[0]); + m_currentLValue = std::move(lvalues[0]); else - m_currentLValue = make_unique(m_context, move(lvalues)); + m_currentLValue = make_unique(m_context, std::move(lvalues)); } } return false; diff --git a/libsolidity/codegen/ExpressionCompiler.h b/libsolidity/codegen/ExpressionCompiler.h index b583b8327e..13e1e3106e 100644 --- a/libsolidity/codegen/ExpressionCompiler.h +++ b/libsolidity/codegen/ExpressionCompiler.h @@ -151,7 +151,7 @@ void ExpressionCompiler::setLValue(Expression const& _expression, Arguments cons solAssert(!m_currentLValue, "Current LValue not reset before trying to set new one."); std::unique_ptr lvalue = std::make_unique(m_context, _arguments...); if (_expression.annotation().willBeWrittenTo) - m_currentLValue = move(lvalue); + m_currentLValue = std::move(lvalue); else lvalue->retrieveValue(_expression.location(), true); } diff --git a/libsolidity/codegen/LValue.cpp b/libsolidity/codegen/LValue.cpp index aa7524c933..2708d319d8 100644 --- a/libsolidity/codegen/LValue.cpp +++ b/libsolidity/codegen/LValue.cpp @@ -557,7 +557,7 @@ TupleObject::TupleObject( CompilerContext& _compilerContext, std::vector>&& _lvalues ): - LValue(_compilerContext), m_lvalues(move(_lvalues)) + LValue(_compilerContext), m_lvalues(std::move(_lvalues)) { } diff --git a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp index 69d30c6c83..39df884495 100644 --- a/libsolidity/codegen/MultiUseYulFunctionCollector.cpp +++ b/libsolidity/codegen/MultiUseYulFunctionCollector.cpp @@ -33,7 +33,7 @@ using namespace solidity::util; string MultiUseYulFunctionCollector::requestedFunctions() { - string result = move(m_code); + string result = std::move(m_code); m_code.clear(); m_requestedFunctions.clear(); return result; @@ -47,7 +47,7 @@ string MultiUseYulFunctionCollector::createFunction(string const& _name, functio string fun = _creator(); solAssert(!fun.empty(), ""); solAssert(fun.find("function " + _name + "(") != string::npos, "Function not properly named."); - m_code += move(fun); + m_code += std::move(fun); } return _name; } diff --git a/libsolidity/codegen/ir/IRGenerationContext.cpp b/libsolidity/codegen/ir/IRGenerationContext.cpp index 5d39bf4b5f..cb1c371dc9 100644 --- a/libsolidity/codegen/ir/IRGenerationContext.cpp +++ b/libsolidity/codegen/ir/IRGenerationContext.cpp @@ -121,7 +121,7 @@ void IRGenerationContext::addStateVariable( unsigned _byteOffset ) { - m_stateVariables[&_declaration] = make_pair(move(_storageOffset), _byteOffset); + m_stateVariables[&_declaration] = make_pair(std::move(_storageOffset), _byteOffset); } string IRGenerationContext::newYulVariable() @@ -137,12 +137,12 @@ void IRGenerationContext::initializeInternalDispatch(InternalDispatchMap _intern for (auto function: functions) enqueueFunctionForCodeGeneration(*function); - m_internalDispatchMap = move(_internalDispatch); + m_internalDispatchMap = std::move(_internalDispatch); } InternalDispatchMap IRGenerationContext::consumeInternalDispatchMap() { - InternalDispatchMap internalDispatch = move(m_internalDispatchMap); + InternalDispatchMap internalDispatch = std::move(m_internalDispatchMap); m_internalDispatchMap.clear(); return internalDispatch; } diff --git a/libsolidity/codegen/ir/IRGenerator.cpp b/libsolidity/codegen/ir/IRGenerator.cpp index 7c76f8344b..a13a353015 100644 --- a/libsolidity/codegen/ir/IRGenerator.cpp +++ b/libsolidity/codegen/ir/IRGenerator.cpp @@ -113,7 +113,7 @@ pair IRGenerator::run( } asmStack.optimize(); - return {move(ir), asmStack.print(m_context.soliditySourceProvider())}; + return {std::move(ir), asmStack.print(m_context.soliditySourceProvider())}; } string IRGenerator::generate( @@ -214,7 +214,7 @@ string IRGenerator::generate( // NOTE: Function pointers can be passed from creation code via storage variables. We need to // get all the functions they could point to into the dispatch functions even if they're never // referenced by name in the deployed code. - m_context.initializeInternalDispatch(move(internalDispatchMap)); + m_context.initializeInternalDispatch(std::move(internalDispatchMap)); // Do not register immutables to avoid assignment. t("DeployedObject", IRNames::deployedObject(_contract)); @@ -236,8 +236,8 @@ string IRGenerator::generate( solAssert(_contract.annotation().creationCallGraph->get() != nullptr, ""); solAssert(_contract.annotation().deployedCallGraph->get() != nullptr, ""); - verifyCallGraph(collectReachableCallables(**_contract.annotation().creationCallGraph), move(creationFunctionList)); - verifyCallGraph(collectReachableCallables(**_contract.annotation().deployedCallGraph), move(deployedFunctionList)); + verifyCallGraph(collectReachableCallables(**_contract.annotation().creationCallGraph), std::move(creationFunctionList)); + verifyCallGraph(collectReachableCallables(**_contract.annotation().deployedCallGraph), std::move(deployedFunctionList)); return t.render(); } @@ -317,7 +317,7 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin }); } - templ("cases", move(cases)); + templ("cases", std::move(cases)); return templ.render(); }); } @@ -944,7 +944,7 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract) generateFunctionWithModifierInner(*constructor); } } - t("userDefinedConstructorBody", move(body)); + t("userDefinedConstructorBody", std::move(body)); return t.render(); }); @@ -1117,7 +1117,7 @@ void IRGenerator::resetContext(ContractDefinition const& _contract, ExecutionCon m_context.soliditySourceProvider() ); newContext.copyFunctionIDsFrom(m_context); - m_context = move(newContext); + m_context = std::move(newContext); m_context.setMostDerivedContract(_contract); for (auto const& var: ContractType(_contract).stateVariables()) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 5eaeed743b..679510cd68 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -827,17 +827,17 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp) expr = "iszero(" + expr + ")"; } else if (op == Token::Equal) - expr = "eq(" + move(args) + ")"; + expr = "eq(" + std::move(args) + ")"; else if (op == Token::NotEqual) - expr = "iszero(eq(" + move(args) + "))"; + expr = "iszero(eq(" + std::move(args) + "))"; else if (op == Token::GreaterThanOrEqual) - expr = "iszero(" + string(isSigned ? "slt(" : "lt(") + move(args) + "))"; + expr = "iszero(" + string(isSigned ? "slt(" : "lt(") + std::move(args) + "))"; else if (op == Token::LessThanOrEqual) - expr = "iszero(" + string(isSigned ? "sgt(" : "gt(") + move(args) + "))"; + expr = "iszero(" + string(isSigned ? "sgt(" : "gt(") + std::move(args) + "))"; else if (op == Token::GreaterThan) - expr = (isSigned ? "sgt(" : "gt(") + move(args) + ")"; + expr = (isSigned ? "sgt(" : "gt(") + std::move(args) + ")"; else if (op == Token::LessThan) - expr = (isSigned ? "slt(" : "lt(") + move(args) + ")"; + expr = (isSigned ? "slt(" : "lt(") + std::move(args) + ")"; else solAssert(false, "Unknown comparison operator."); define(_binOp) << expr << "\n"; @@ -1109,7 +1109,7 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) messageArgumentType ); - appendCode() << move(requireOrAssertFunction) << "(" << IRVariable(*arguments[0]).name(); + appendCode() << std::move(requireOrAssertFunction) << "(" << IRVariable(*arguments[0]).name(); if (messageArgumentType && messageArgumentType->sizeOnStack() > 0) appendCode() << ", " << IRVariable(*arguments[1]).commaSeparatedList(); appendCode() << ")\n"; diff --git a/libsolidity/formal/ArraySlicePredicate.cpp b/libsolidity/formal/ArraySlicePredicate.cpp index 85fced9062..f73985f181 100644 --- a/libsolidity/formal/ArraySlicePredicate.cpp +++ b/libsolidity/formal/ArraySlicePredicate.cpp @@ -86,6 +86,6 @@ pair ArraySlicePredicate::create(So return {false, m_slicePredicates[tupleName] = { {&slice, &header, &loop}, - {move(rule1), move(rule2), move(rule3), move(rule4)} + {std::move(rule1), std::move(rule2), std::move(rule3), std::move(rule4)} }}; } diff --git a/libsolidity/formal/BMC.cpp b/libsolidity/formal/BMC.cpp index bf36187916..0466bfbac4 100644 --- a/libsolidity/formal/BMC.cpp +++ b/libsolidity/formal/BMC.cpp @@ -76,7 +76,7 @@ void BMC::analyze(SourceUnit const& _source, map, vector> BMC::modelExpressions() expressionName = m_charStreamProvider.charStream(*uf->location().sourceName).text( uf->location() ); - expressionNames.push_back(move(expressionName)); + expressionNames.push_back(std::move(expressionName)); } return {expressionsToEvaluate, expressionNames}; @@ -888,7 +888,7 @@ void BMC::addVerificationTarget( if (_type == VerificationTargetType::ConstantCondition) checkVerificationTarget(target); else - m_verificationTargets.emplace_back(move(target)); + m_verificationTargets.emplace_back(std::move(target)); } /// Solving. @@ -964,7 +964,7 @@ void BMC::checkCondition( message.str(), SecondarySourceLocation().append(modelMessage.str(), SourceLocation{}) .append(SMTEncoder::callStackMessage(_callStack)) - .append(move(secondaryLocation)) + .append(std::move(secondaryLocation)) ); break; } diff --git a/libsolidity/formal/CHC.cpp b/libsolidity/formal/CHC.cpp index 267ea92699..3d5c3e6c3b 100644 --- a/libsolidity/formal/CHC.cpp +++ b/libsolidity/formal/CHC.cpp @@ -1422,7 +1422,7 @@ vector CHC::currentStateVariables(ContractDefinition const& smtutil::Expression CHC::currentEqualInitialVarsConstraints(vector const& _vars) const { return fold(_vars, smtutil::Expression(true), [this](auto&& _conj, auto _var) { - return move(_conj) && currentValue(*_var) == m_context.variable(*_var)->valueAtIndex(0); + return std::move(_conj) && currentValue(*_var) == m_context.variable(*_var)->valueAtIndex(0); }); } @@ -1566,7 +1566,7 @@ tuple CHC::query tie(resultNoOpt, invariantNoOpt, cexNoOpt) = m_interface->query(_query); if (resultNoOpt == CheckResult::SATISFIABLE) - cex = move(cexNoOpt); + cex = std::move(cexNoOpt); spacer->setSpacerOptions(true); } @@ -1817,7 +1817,7 @@ void CHC::checkAndReportTarget( predicates.insert(pred); map> invariants = collectInvariants(invariant, predicates, m_settings.invariants); for (auto pred: invariants | ranges::views::keys) - m_invariants[pred] += move(invariants.at(pred)); + m_invariants[pred] += std::move(invariants.at(pred)); } else if (result == CheckResult::SATISFIABLE) { diff --git a/libsolidity/formal/EncodingContext.cpp b/libsolidity/formal/EncodingContext.cpp index f9edd7db32..2000efd07e 100644 --- a/libsolidity/formal/EncodingContext.cpp +++ b/libsolidity/formal/EncodingContext.cpp @@ -211,5 +211,5 @@ void EncodingContext::addAssertion(smtutil::Expression const& _expr) if (m_assertions.empty()) m_assertions.push_back(_expr); else - m_assertions.back() = _expr && move(m_assertions.back()); + m_assertions.back() = _expr && std::move(m_assertions.back()); } diff --git a/libsolidity/formal/EncodingContext.h b/libsolidity/formal/EncodingContext.h index 7c001f452b..35e54ed76b 100644 --- a/libsolidity/formal/EncodingContext.h +++ b/libsolidity/formal/EncodingContext.h @@ -63,7 +63,7 @@ class EncodingContext smtutil::Expression newVariable(std::string _name, smtutil::SortPointer _sort) { solAssert(m_solver, ""); - return m_solver->newVariable(move(_name), move(_sort)); + return m_solver->newVariable(std::move(_name), std::move(_sort)); } struct IdCompare diff --git a/libsolidity/formal/Invariants.cpp b/libsolidity/formal/Invariants.cpp index 10d342ed47..9177a4d431 100644 --- a/libsolidity/formal/Invariants.cpp +++ b/libsolidity/formal/Invariants.cpp @@ -55,9 +55,9 @@ map> collectInvariants( auto arg0 = _expr->arguments.at(0); auto arg1 = _expr->arguments.at(1); if (starts_with(arg0.name, t)) - equalities.insert({arg0.name, {arg0, move(arg1)}}); + equalities.insert({arg0.name, {arg0, std::move(arg1)}}); else if (starts_with(arg1.name, t)) - equalities.insert({arg1.name, {arg1, move(arg0)}}); + equalities.insert({arg1.name, {arg1, std::move(arg0)}}); } for (auto const& arg: _expr->arguments) _addChild(&arg); diff --git a/libsolidity/formal/ModelChecker.cpp b/libsolidity/formal/ModelChecker.cpp index cf7a398ec2..0d624f9e08 100644 --- a/libsolidity/formal/ModelChecker.cpp +++ b/libsolidity/formal/ModelChecker.cpp @@ -38,7 +38,7 @@ ModelChecker::ModelChecker( ReadCallback::Callback const& _smtCallback ): m_errorReporter(_errorReporter), - m_settings(move(_settings)), + m_settings(std::move(_settings)), m_context(), m_bmc(m_context, m_uniqueErrorReporter, _smtlib2Responses, _smtCallback, m_settings, _charStreamProvider), m_chc(m_context, m_uniqueErrorReporter, _smtlib2Responses, _smtCallback, m_settings, _charStreamProvider) diff --git a/libsolidity/formal/Predicate.cpp b/libsolidity/formal/Predicate.cpp index 91513a00c0..d4b6994cf5 100644 --- a/libsolidity/formal/Predicate.cpp +++ b/libsolidity/formal/Predicate.cpp @@ -50,13 +50,13 @@ Predicate const* Predicate::create( vector _scopeStack ) { - smt::SymbolicFunctionVariable predicate{_sort, move(_name), _context}; + smt::SymbolicFunctionVariable predicate{_sort, std::move(_name), _context}; string functorName = predicate.currentName(); solAssert(!m_predicates.count(functorName), ""); return &m_predicates.emplace( std::piecewise_construct, std::forward_as_tuple(functorName), - std::forward_as_tuple(move(predicate), _type, _node, _contractContext, move(_scopeStack)) + std::forward_as_tuple(std::move(predicate), _type, _node, _contractContext, std::move(_scopeStack)) ).first->second; } @@ -67,7 +67,7 @@ Predicate::Predicate( ContractDefinition const* _contractContext, vector _scopeStack ): - m_predicate(move(_predicate)), + m_predicate(std::move(_predicate)), m_type(_type), m_node(_node), m_contractContext(_contractContext), diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index 8c5dd647e2..e779fbeb88 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -2977,7 +2977,7 @@ set const& SMTEncoder::contract resolvedFunctions.insert(baseFunction); } } - m_contractFunctions.emplace(&_contract, move(resolvedFunctions)); + m_contractFunctions.emplace(&_contract, std::move(resolvedFunctions)); } return m_contractFunctions.at(&_contract); } @@ -2991,7 +2991,7 @@ set const& SMTEncoder::contract for (auto const* baseFun: base->definedFunctions()) allFunctions.insert(baseFun); - m_contractFunctionsWithoutVirtual.emplace(&_contract, move(allFunctions)); + m_contractFunctionsWithoutVirtual.emplace(&_contract, std::move(allFunctions)); } return m_contractFunctionsWithoutVirtual.at(&_contract); diff --git a/libsolidity/formal/SymbolicState.cpp b/libsolidity/formal/SymbolicState.cpp index b1fd7978fa..0679cee8ab 100644 --- a/libsolidity/formal/SymbolicState.cpp +++ b/libsolidity/formal/SymbolicState.cpp @@ -32,8 +32,8 @@ BlockchainVariable::BlockchainVariable( map _members, EncodingContext& _context ): - m_name(move(_name)), - m_members(move(_members)), + m_name(std::move(_name)), + m_members(std::move(_members)), m_context(_context) { vector members; @@ -94,12 +94,12 @@ smtutil::Expression SymbolicState::balance() const smtutil::Expression SymbolicState::balance(smtutil::Expression _address) const { - return smtutil::Expression::select(balances(), move(_address)); + return smtutil::Expression::select(balances(), std::move(_address)); } smtutil::Expression SymbolicState::blockhash(smtutil::Expression _blockNumber) const { - return smtutil::Expression::select(m_tx.member("blockhash"), move(_blockNumber)); + return smtutil::Expression::select(m_tx.member("blockhash"), std::move(_blockNumber)); } void SymbolicState::newBalances() @@ -114,13 +114,13 @@ void SymbolicState::transfer(smtutil::Expression _from, smtutil::Expression _to, { unsigned indexBefore = m_state.index(); addBalance(_from, 0 - _value); - addBalance(_to, move(_value)); + addBalance(_to, std::move(_value)); unsigned indexAfter = m_state.index(); solAssert(indexAfter > indexBefore, ""); m_state.newVar(); /// Do not apply the transfer operation if _from == _to. auto newState = smtutil::Expression::ite( - move(_from) == move(_to), + std::move(_from) == std::move(_to), m_state.value(indexBefore), m_state.value(indexAfter) ); @@ -132,7 +132,7 @@ void SymbolicState::addBalance(smtutil::Expression _address, smtutil::Expression auto newBalances = smtutil::Expression::store( balances(), _address, - balance(_address) + move(_value) + balance(_address) + std::move(_value) ); m_state.assignMember("balances", newBalances); } @@ -322,7 +322,7 @@ void SymbolicState::buildABIFunctions(set const& _abiFuncti functions[name] = functionSort; } - m_abi = make_unique("abi", move(functions), m_context); + m_abi = make_unique("abi", std::move(functions), m_context); } smtutil::Expression SymbolicState::abiFunction(frontend::FunctionCall const* _funCall) diff --git a/libsolidity/formal/SymbolicVariables.cpp b/libsolidity/formal/SymbolicVariables.cpp index f0fa7df861..799ac4adb4 100644 --- a/libsolidity/formal/SymbolicVariables.cpp +++ b/libsolidity/formal/SymbolicVariables.cpp @@ -38,7 +38,7 @@ SymbolicVariable::SymbolicVariable( ): m_type(_type), m_originalType(_originalType), - m_uniqueName(move(_uniqueName)), + m_uniqueName(std::move(_uniqueName)), m_context(_context), m_ssa(make_unique()) { @@ -52,8 +52,8 @@ SymbolicVariable::SymbolicVariable( string _uniqueName, EncodingContext& _context ): - m_sort(move(_sort)), - m_uniqueName(move(_uniqueName)), + m_sort(std::move(_sort)), + m_uniqueName(std::move(_uniqueName)), m_context(_context), m_ssa(make_unique()) { @@ -108,7 +108,7 @@ SymbolicBoolVariable::SymbolicBoolVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(m_type->category() == frontend::Type::Category::Bool, ""); } @@ -119,7 +119,7 @@ SymbolicIntVariable::SymbolicIntVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _originalType, move(_uniqueName), _context) + SymbolicVariable(_type, _originalType, std::move(_uniqueName), _context) { solAssert(isNumber(*m_type), ""); } @@ -128,7 +128,7 @@ SymbolicAddressVariable::SymbolicAddressVariable( string _uniqueName, EncodingContext& _context ): - SymbolicIntVariable(TypeProvider::uint(160), TypeProvider::uint(160), move(_uniqueName), _context) + SymbolicIntVariable(TypeProvider::uint(160), TypeProvider::uint(160), std::move(_uniqueName), _context) { } @@ -138,7 +138,7 @@ SymbolicFixedBytesVariable::SymbolicFixedBytesVariable( string _uniqueName, EncodingContext& _context ): - SymbolicIntVariable(TypeProvider::uint(_numBytes * 8), _originalType, move(_uniqueName), _context) + SymbolicIntVariable(TypeProvider::uint(_numBytes * 8), _originalType, std::move(_uniqueName), _context) { } @@ -147,7 +147,7 @@ SymbolicFunctionVariable::SymbolicFunctionVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context), + SymbolicVariable(_type, _type, std::move(_uniqueName), _context), m_declaration(m_context.newVariable(currentName(), m_sort)) { solAssert(m_type->category() == frontend::Type::Category::Function, ""); @@ -158,7 +158,7 @@ SymbolicFunctionVariable::SymbolicFunctionVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(move(_sort), move(_uniqueName), _context), + SymbolicVariable(std::move(_sort), std::move(_uniqueName), _context), m_declaration(m_context.newVariable(currentName(), m_sort)) { solAssert(m_sort->kind == Kind::Function, ""); @@ -219,7 +219,7 @@ SymbolicEnumVariable::SymbolicEnumVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(isEnum(*m_type), ""); } @@ -229,7 +229,7 @@ SymbolicTupleVariable::SymbolicTupleVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(isTuple(*m_type), ""); } @@ -239,7 +239,7 @@ SymbolicTupleVariable::SymbolicTupleVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(move(_sort), move(_uniqueName), _context) + SymbolicVariable(std::move(_sort), std::move(_uniqueName), _context) { solAssert(m_sort->kind == Kind::Tuple, ""); } @@ -288,7 +288,7 @@ SymbolicArrayVariable::SymbolicArrayVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _originalType, move(_uniqueName), _context), + SymbolicVariable(_type, _originalType, std::move(_uniqueName), _context), m_pair( smtSort(*_type), m_uniqueName + "_length_pair", @@ -303,7 +303,7 @@ SymbolicArrayVariable::SymbolicArrayVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(move(_sort), move(_uniqueName), _context), + SymbolicVariable(std::move(_sort), std::move(_uniqueName), _context), m_pair( std::make_shared( "array_length_pair", @@ -346,7 +346,7 @@ SymbolicStructVariable::SymbolicStructVariable( string _uniqueName, EncodingContext& _context ): - SymbolicVariable(_type, _type, move(_uniqueName), _context) + SymbolicVariable(_type, _type, std::move(_uniqueName), _context) { solAssert(isNonRecursiveStruct(*m_type), ""); auto const* structType = dynamic_cast(_type); diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index eab1801c6a..cbfa361227 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -134,7 +134,7 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) formatType(p->name(), *type, *p->annotation().type, false) ); } - abi.emplace(move(errorJson)); + abi.emplace(std::move(errorJson)); } Json::Value abiJson{Json::arrayValue}; diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index c53bf93216..702d5a0d20 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -208,7 +208,7 @@ void CompilerStack::setRemappings(vector _remappings) solThrow(CompilerError, "Must set remappings before parsing."); for (auto const& remapping: _remappings) solAssert(!remapping.prefix.empty(), ""); - m_importRemapper.setRemappings(move(_remappings)); + m_importRemapper.setRemappings(std::move(_remappings)); } void CompilerStack::setViaIR(bool _viaIR) @@ -407,7 +407,7 @@ void CompilerStack::importASTs(map const& _sources) src.first, true // imported from AST ); - m_sources[path] = move(source); + m_sources[path] = std::move(source); } m_stackState = ParsedAndImported; m_importedSources = true; @@ -793,7 +793,7 @@ Json::Value CompilerStack::generatedSources(string const& _contractName, bool _r sources[0]["name"] = sourceName; sources[0]["id"] = sourceIndex; sources[0]["language"] = "Yul"; - sources[0]["contents"] = move(source); + sources[0]["contents"] = std::move(source); } } diff --git a/libsolidity/interface/ImportRemapper.cpp b/libsolidity/interface/ImportRemapper.cpp index 9d55610132..4d4fa42d45 100644 --- a/libsolidity/interface/ImportRemapper.cpp +++ b/libsolidity/interface/ImportRemapper.cpp @@ -35,7 +35,7 @@ void ImportRemapper::setRemappings(vector _remappings) { for (auto const& remapping: _remappings) solAssert(!remapping.prefix.empty(), ""); - m_remappings = move(_remappings); + m_remappings = std::move(_remappings); } SourceUnitName ImportRemapper::apply(ImportPath const& _path, string const& _context) const diff --git a/libsolidity/interface/Natspec.cpp b/libsolidity/interface/Natspec.cpp index 4496904937..566b676078 100644 --- a/libsolidity/interface/Natspec.cpp +++ b/libsolidity/interface/Natspec.cpp @@ -92,7 +92,7 @@ Json::Value Natspec::userDocumentation(ContractDefinition const& _contractDef) { Json::Value errorDoc{Json::objectValue}; errorDoc["notice"] = value; - doc["errors"][error->functionType(true)->externalSignature()].append(move(errorDoc)); + doc["errors"][error->functionType(true)->externalSignature()].append(std::move(errorDoc)); } } @@ -140,10 +140,10 @@ Json::Value Natspec::devDocumentation(ContractDefinition const& _contractDef) ); if (!jsonReturn.empty()) - method["returns"] = move(jsonReturn); + method["returns"] = std::move(jsonReturn); if (!method.empty()) - doc["methods"][it.second->externalSignature()] = move(method); + doc["methods"][it.second->externalSignature()] = std::move(method); } } @@ -230,7 +230,7 @@ Json::Value Natspec::extractCustomDoc(multimap const& _tags) return Json::nullValue; Json::Value result{Json::objectValue}; for (auto& [tag, value]: concatenated) - result[tag] = move(value); + result[tag] = std::move(value); return result; } diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 24bcddba9c..c6cd741c15 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -403,7 +403,7 @@ Json::Value collectEVMObject( if (_runtimeObject && _artifactRequested("immutableReferences")) output["immutableReferences"] = formatImmutableReferences(_object.immutableReferences); if (_artifactRequested("generatedSources")) - output["generatedSources"] = move(_generatedSources); + output["generatedSources"] = std::move(_generatedSources); return output; } @@ -966,7 +966,7 @@ std::variant StandardCompiler: if (sourceContracts[source].empty()) return formatFatalError("JSONError", "Source contracts must be a non-empty array."); } - ret.modelCheckerSettings.contracts = {move(sourceContracts)}; + ret.modelCheckerSettings.contracts = {std::move(sourceContracts)}; } if (modelCheckerSettings.isMember("divModNoSlacks")) @@ -1076,7 +1076,7 @@ Json::Value StandardCompiler::compileSolidity(StandardCompiler::InputsAndSetting compilerStack.setViaIR(_inputsAndSettings.viaIR); compilerStack.setEVMVersion(_inputsAndSettings.evmVersion); compilerStack.setParserErrorRecovery(_inputsAndSettings.parserErrorRecovery); - compilerStack.setRemappings(move(_inputsAndSettings.remappings)); + compilerStack.setRemappings(std::move(_inputsAndSettings.remappings)); compilerStack.setOptimiserSettings(std::move(_inputsAndSettings.optimiserSettings)); compilerStack.setRevertStringBehaviour(_inputsAndSettings.revertStrings); if (_inputsAndSettings.debugInfoSelection.has_value()) @@ -1582,7 +1582,7 @@ Json::Value StandardCompiler::formatFunctionDebugData( fun["entryPoint"] = Json::nullValue; fun["parameterSlots"] = Json::UInt64(info.params); fun["returnSlots"] = Json::UInt64(info.returns); - ret[name] = move(fun); + ret[name] = std::move(fun); } return ret; diff --git a/libsolidity/interface/StorageLayout.cpp b/libsolidity/interface/StorageLayout.cpp index 74d7ccf4bb..76c840db57 100644 --- a/libsolidity/interface/StorageLayout.cpp +++ b/libsolidity/interface/StorageLayout.cpp @@ -40,8 +40,8 @@ Json::Value StorageLayout::generate(ContractDefinition const& _contractDef) variables.append(generate(*var, slot, offset)); Json::Value layout; - layout["storage"] = move(variables); - layout["types"] = move(m_types); + layout["storage"] = std::move(variables); + layout["types"] = std::move(m_types); return layout; } @@ -81,7 +81,7 @@ void StorageLayout::generate(Type const* _type) auto const& offsets = structType->storageOffsetsOfMember(member->name()); members.append(generate(*member, offsets.first, offsets.second)); } - typeInfo["members"] = move(members); + typeInfo["members"] = std::move(members); typeInfo["encoding"] = "inplace"; } else if (auto mappingType = dynamic_cast(_type)) diff --git a/libsolidity/lsp/FileRepository.cpp b/libsolidity/lsp/FileRepository.cpp index 58bc0bf8de..4e8ebbb123 100644 --- a/libsolidity/lsp/FileRepository.cpp +++ b/libsolidity/lsp/FileRepository.cpp @@ -62,7 +62,7 @@ string FileRepository::sourceUnitNameToUri(string const& _sourceUnitName) const if (!regex_search(inputPath, windowsDriveLetterPath)) return inputPath; else - return "/" + move(inputPath); + return "/" + std::move(inputPath); }; if (m_sourceUnitNamesToUri.count(_sourceUnitName)) @@ -124,7 +124,7 @@ Result FileRepository::tryResolvePath(std::string const boost::filesystem::path canonicalPath = boost::filesystem::path(prefix) / boost::filesystem::path(_strippedSourceUnitName); if (boost::filesystem::exists(canonicalPath)) - candidates.push_back(move(canonicalPath)); + candidates.push_back(std::move(canonicalPath)); } if (candidates.empty()) @@ -169,7 +169,7 @@ frontend::ReadCallback::Result FileRepository::readFile(string const& _kind, str auto contents = readFileAsString(resolvedPath.get()); solAssert(m_sourceCodes.count(_sourceUnitName) == 0, ""); m_sourceCodes[_sourceUnitName] = contents; - return ReadCallback::Result{true, move(contents)}; + return ReadCallback::Result{true, std::move(contents)}; } catch (std::exception const& _exception) { diff --git a/libsolidity/lsp/GotoDefinition.cpp b/libsolidity/lsp/GotoDefinition.cpp index 26fb686dbb..532792c177 100644 --- a/libsolidity/lsp/GotoDefinition.cpp +++ b/libsolidity/lsp/GotoDefinition.cpp @@ -44,13 +44,13 @@ void GotoDefinition::operator()(MessageID _id, Json::Value const& _args) // Handles all expressions that can have one or more declaration annotation. if (auto const* declaration = referencedDeclaration(expression)) if (auto location = declarationLocation(declaration)) - locations.emplace_back(move(location.value())); + locations.emplace_back(std::move(location.value())); } else if (auto const* identifierPath = dynamic_cast(sourceNode)) { if (auto const* declaration = identifierPath->annotation().referencedDeclaration) if (auto location = declarationLocation(declaration)) - locations.emplace_back(move(location.value())); + locations.emplace_back(std::move(location.value())); } else if (auto const* importDirective = dynamic_cast(sourceNode)) { diff --git a/libsolidity/lsp/LanguageServer.cpp b/libsolidity/lsp/LanguageServer.cpp index 65eeaf3d50..ce68dbef35 100644 --- a/libsolidity/lsp/LanguageServer.cpp +++ b/libsolidity/lsp/LanguageServer.cpp @@ -202,7 +202,7 @@ void LanguageServer::changeConfiguration(Json::Value const& _settings) else typeFailureCount++; } - m_fileRepository.setIncludePaths(move(includePaths)); + m_fileRepository.setIncludePaths(std::move(includePaths)); } else ++typeFailureCount; @@ -289,7 +289,7 @@ void LanguageServer::compileAndUpdateDiagnostics() string message = error->typeName() + ":"; if (string const* comment = error->comment()) message += " " + *comment; - jsonDiag["message"] = move(message); + jsonDiag["message"] = std::move(message); jsonDiag["range"] = toRange(*location); if (auto const* secondary = error->secondarySourceLocation()) @@ -318,8 +318,8 @@ void LanguageServer::compileAndUpdateDiagnostics() params["uri"] = m_fileRepository.sourceUnitNameToUri(sourceUnitName); if (!diagnostics.empty()) m_nonemptyDiagnostics.insert(sourceUnitName); - params["diagnostics"] = move(diagnostics); - m_client.notify("textDocument/publishDiagnostics", move(params)); + params["diagnostics"] = std::move(diagnostics); + m_client.notify("textDocument/publishDiagnostics", std::move(params)); } } @@ -418,7 +418,7 @@ void LanguageServer::handleInitialize(MessageID _id, Json::Value const& _args) replyArgs["capabilities"]["semanticTokensProvider"]["full"] = true; // XOR requests.full.delta = true replyArgs["capabilities"]["renameProvider"] = true; - m_client.reply(_id, move(replyArgs)); + m_client.reply(_id, std::move(replyArgs)); } void LanguageServer::handleInitialized(MessageID, Json::Value const&) @@ -480,7 +480,7 @@ void LanguageServer::handleTextDocumentDidOpen(Json::Value const& _args) string text = _args["textDocument"]["text"].asString(); string uri = _args["textDocument"]["uri"].asString(); m_openFiles.insert(uri); - m_fileRepository.setSourceByUri(uri, move(text)); + m_fileRepository.setSourceByUri(uri, std::move(text)); compileAndUpdateDiagnostics(); } @@ -516,10 +516,10 @@ void LanguageServer::handleTextDocumentDidChange(Json::Value const& _args) ); string buffer = m_fileRepository.sourceUnits().at(sourceUnitName); - buffer.replace(static_cast(change->start), static_cast(change->end - change->start), move(text)); - text = move(buffer); + buffer.replace(static_cast(change->start), static_cast(change->end - change->start), std::move(text)); + text = std::move(buffer); } - m_fileRepository.setSourceByUri(uri, move(text)); + m_fileRepository.setSourceByUri(uri, std::move(text)); } compileAndUpdateDiagnostics(); diff --git a/libsolidity/lsp/Transport.cpp b/libsolidity/lsp/Transport.cpp index 90c0b20a7a..5af723128a 100644 --- a/libsolidity/lsp/Transport.cpp +++ b/libsolidity/lsp/Transport.cpp @@ -67,7 +67,7 @@ optional Transport::receive() return nullopt; } - return {move(jsonMessage)}; + return {std::move(jsonMessage)}; } void Transport::trace(std::string _message, Json::Value _extra) @@ -76,9 +76,9 @@ void Transport::trace(std::string _message, Json::Value _extra) { Json::Value params; if (_extra.isObject()) - params = move(_extra); - params["message"] = move(_message); - notify("$/logTrace", move(params)); + params = std::move(_extra); + params["message"] = std::move(_message); + notify("$/logTrace", std::move(params)); } } @@ -101,30 +101,30 @@ optional> Transport::parseHeaders() if (!headers.emplace(boost::trim_copy(name), boost::trim_copy(value)).second) return nullopt; } - return {move(headers)}; + return {std::move(headers)}; } void Transport::notify(string _method, Json::Value _message) { Json::Value json; - json["method"] = move(_method); - json["params"] = move(_message); - send(move(json)); + json["method"] = std::move(_method); + json["params"] = std::move(_message); + send(std::move(json)); } void Transport::reply(MessageID _id, Json::Value _message) { Json::Value json; - json["result"] = move(_message); - send(move(json), _id); + json["result"] = std::move(_message); + send(std::move(json), _id); } void Transport::error(MessageID _id, ErrorCode _code, string _message) { Json::Value json; json["error"]["code"] = static_cast(_code); - json["error"]["message"] = move(_message); - send(move(json), _id); + json["error"]["message"] = std::move(_message); + send(std::move(json), _id); } void Transport::send(Json::Value _json, MessageID _id) diff --git a/libsolidity/parsing/DocStringParser.cpp b/libsolidity/parsing/DocStringParser.cpp index 5c07950edc..7e6e158b76 100644 --- a/libsolidity/parsing/DocStringParser.cpp +++ b/libsolidity/parsing/DocStringParser.cpp @@ -116,7 +116,7 @@ multimap DocStringParser::parse() currPos = nlPos + 1; } } - return move(m_docTags); + return std::move(m_docTags); } DocStringParser::iter DocStringParser::parseDocTagLine(iter _pos, iter _end, bool _appending) diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 9ccb1aca38..afa70609d9 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -274,7 +274,7 @@ ASTPointer Parser::parseImportDirective() expectToken(Token::As); tie(alias, aliasLocation) = expectIdentifierWithLocation(); } - symbolAliases.emplace_back(ImportDirective::SymbolAlias{move(id), move(alias), aliasLocation}); + symbolAliases.emplace_back(ImportDirective::SymbolAlias{std::move(id), std::move(alias), aliasLocation}); if (m_scanner->currentToken() != Token::Comma) break; advance(); @@ -302,7 +302,7 @@ ASTPointer Parser::parseImportDirective() fatalParserError(6326_error, "Import path cannot be empty."); nodeFactory.markEndPosition(); expectToken(Token::Semicolon); - return nodeFactory.createNode(path, unitAlias, unitAliasLocation, move(symbolAliases)); + return nodeFactory.createNode(path, unitAlias, unitAliasLocation, std::move(symbolAliases)); } std::pair Parser::parseContractKind() @@ -496,7 +496,7 @@ ASTPointer Parser::parseOverrideSpecifier() expectToken(Token::RParen); } - return nodeFactory.createNode(move(overrides)); + return nodeFactory.createNode(std::move(overrides)); } StateMutability Parser::parseStateMutability() @@ -686,7 +686,7 @@ ASTPointer Parser::parseStructDefinition() } nodeFactory.markEndPosition(); expectToken(Token::RBrace); - return nodeFactory.createNode(move(name), move(nameLocation), move(members)); + return nodeFactory.createNode(std::move(name), std::move(nameLocation), std::move(members)); } ASTPointer Parser::parseEnumValue() @@ -918,7 +918,7 @@ pair, SourceLocation> Parser::expectIdentifierWithLocation SourceLocation nameLocation = currentLocation(); ASTPointer name = expectIdentifierToken(); - return {move(name), move(nameLocation)}; + return {std::move(name), std::move(nameLocation)}; } ASTPointer Parser::parseEventDefinition() @@ -957,7 +957,7 @@ ASTPointer Parser::parseErrorDefinition() ASTPointer parameters = parseParameterList({}); nodeFactory.markEndPosition(); expectToken(Token::Semicolon); - return nodeFactory.createNode(name, move(nameLocation), documentation, parameters); + return nodeFactory.createNode(name, std::move(nameLocation), documentation, parameters); } ASTPointer Parser::parseUsingDirective() @@ -996,7 +996,7 @@ ASTPointer Parser::parseUsingDirective() } nodeFactory.markEndPosition(); expectToken(Token::Semicolon); - return nodeFactory.createNode(move(functions), usesBraces, typeName, global); + return nodeFactory.createNode(std::move(functions), usesBraces, typeName, global); } ASTPointer Parser::parseModifierInvocation() @@ -1014,7 +1014,7 @@ ASTPointer Parser::parseModifierInvocation() } else nodeFactory.setEndPositionFromNode(name); - return nodeFactory.createNode(name, move(arguments)); + return nodeFactory.createNode(name, std::move(arguments)); } ASTPointer Parser::parseIdentifier() @@ -1052,7 +1052,7 @@ ASTPointer Parser::parseUserDefinedValueTypeDefi expectToken(Token::Semicolon); return nodeFactory.createNode( name, - move(nameLocation), + std::move(nameLocation), typeName ); } @@ -1377,7 +1377,7 @@ ASTPointer Parser::parseInlineAssembly(ASTPointer con BOOST_THROW_EXCEPTION(FatalError()); location.end = nativeLocationOf(*block).end; - return make_shared(nextID(), location, _docString, dialect, move(flags), block); + return make_shared(nextID(), location, _docString, dialect, std::move(flags), block); } ASTPointer Parser::parseIfStatement(ASTPointer const& _docString) @@ -1710,9 +1710,9 @@ pair Parser::tryParseIndexAcce IndexAccessedPath iap = parseIndexAccessedPath(); if (m_scanner->currentToken() == Token::Identifier || TokenTraits::isLocationSpecifier(m_scanner->currentToken())) - return make_pair(LookAheadInfo::VariableDeclaration, move(iap)); + return make_pair(LookAheadInfo::VariableDeclaration, std::move(iap)); else - return make_pair(LookAheadInfo::Expression, move(iap)); + return make_pair(LookAheadInfo::Expression, std::move(iap)); } ASTPointer Parser::parseVariableDeclarationStatement( diff --git a/libsolutil/Whiskers.cpp b/libsolutil/Whiskers.cpp index 340527bdd1..043f2dd76e 100644 --- a/libsolutil/Whiskers.cpp +++ b/libsolutil/Whiskers.cpp @@ -32,7 +32,7 @@ using namespace std; using namespace solidity::util; Whiskers::Whiskers(string _template): - m_template(move(_template)) + m_template(std::move(_template)) { } @@ -41,7 +41,7 @@ Whiskers& Whiskers::operator()(string _parameter, string _value) checkParameterValid(_parameter); checkParameterUnknown(_parameter); checkTemplateContainsTags(_parameter, {""}); - m_parameters[move(_parameter)] = move(_value); + m_parameters[std::move(_parameter)] = std::move(_value); return *this; } @@ -50,7 +50,7 @@ Whiskers& Whiskers::operator()(string _parameter, bool _value) checkParameterValid(_parameter); checkParameterUnknown(_parameter); checkTemplateContainsTags(_parameter, {"?", "/"}); - m_conditions[move(_parameter)] = _value; + m_conditions[std::move(_parameter)] = _value; return *this; } @@ -65,7 +65,7 @@ Whiskers& Whiskers::operator()( for (auto const& element: _values) for (auto const& val: element) checkParameterValid(val.first); - m_listParameters[move(_listParameter)] = move(_values); + m_listParameters[std::move(_listParameter)] = std::move(_values); return *this; } diff --git a/libyul/AsmParser.cpp b/libyul/AsmParser.cpp index ba4bf11157..8043c758a2 100644 --- a/libyul/AsmParser.cpp +++ b/libyul/AsmParser.cpp @@ -88,7 +88,7 @@ void Parser::updateLocationEndFrom( DebugData updatedDebugData = *_debugData; updatedDebugData.nativeLocation.end = _location.end; updatedDebugData.originLocation.end = _location.end; - _debugData = make_shared(move(updatedDebugData)); + _debugData = make_shared(std::move(updatedDebugData)); break; } case UseSourceLocationFrom::LocationOverride: @@ -98,7 +98,7 @@ void Parser::updateLocationEndFrom( { DebugData updatedDebugData = *_debugData; updatedDebugData.nativeLocation.end = _location.end; - _debugData = make_shared(move(updatedDebugData)); + _debugData = make_shared(std::move(updatedDebugData)); break; } } @@ -246,7 +246,7 @@ optional> Parser::parseSrcComment( { shared_ptr sourceName = m_sourceNames->at(static_cast(sourceIndex.value())); solAssert(sourceName, ""); - return {{tail, SourceLocation{start.value(), end.value(), move(sourceName)}}}; + return {{tail, SourceLocation{start.value(), end.value(), std::move(sourceName)}}}; } return {{tail, SourceLocation{}}}; } @@ -313,7 +313,7 @@ Statement Parser::parseStatement() _if.condition = make_unique(parseExpression()); _if.body = parseBlock(); updateLocationEndFrom(_if.debugData, nativeLocationOf(_if.body)); - return Statement{move(_if)}; + return Statement{std::move(_if)}; } case Token::Switch: { @@ -331,7 +331,7 @@ Statement Parser::parseStatement() if (_switch.cases.empty()) fatalParserError(2418_error, "Switch statement without any cases."); updateLocationEndFrom(_switch.debugData, nativeLocationOf(_switch.cases.back().body)); - return Statement{move(_switch)}; + return Statement{std::move(_switch)}; } case Token::For: return parseForLoop(); @@ -371,7 +371,7 @@ Statement Parser::parseStatement() case Token::LParen: { Expression expr = parseCall(std::move(elementary)); - return ExpressionStatement{debugDataOf(expr), move(expr)}; + return ExpressionStatement{debugDataOf(expr), std::move(expr)}; } case Token::Comma: case Token::AssemblyAssign: @@ -414,7 +414,7 @@ Statement Parser::parseStatement() assignment.value = make_unique(parseExpression()); updateLocationEndFrom(assignment.debugData, nativeLocationOf(*assignment.value)); - return Statement{move(assignment)}; + return Statement{std::move(assignment)}; } default: fatalParserError(6913_error, "Call or assignment expected."); @@ -485,11 +485,11 @@ Expression Parser::parseExpression() nativeLocationOf(_identifier), "Builtin function \"" + _identifier.name.str() + "\" must be called." ); - return move(_identifier); + return std::move(_identifier); }, [&](Literal& _literal) -> Expression { - return move(_literal); + return std::move(_literal); } }, operation); } diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp index fb0fa565e4..54733cc435 100644 --- a/libyul/AsmPrinter.cpp +++ b/libyul/AsmPrinter.cpp @@ -197,7 +197,7 @@ string AsmPrinter::operator()(ForLoop const& _forLoop) delim = ' '; return locationComment + - ("for " + move(pre) + delim + move(condition) + delim + move(post) + "\n") + + ("for " + std::move(pre) + delim + std::move(condition) + delim + std::move(post) + "\n") + (*this)(_forLoop.body); } diff --git a/libyul/ControlFlowSideEffectsCollector.cpp b/libyul/ControlFlowSideEffectsCollector.cpp index 6e96712a08..19eb8275d0 100644 --- a/libyul/ControlFlowSideEffectsCollector.cpp +++ b/libyul/ControlFlowSideEffectsCollector.cpp @@ -92,7 +92,7 @@ void ControlFlowBuilder::operator()(FunctionDefinition const& _function) m_currentNode->successors.emplace_back(flow.exit); - m_functionFlows[&_function] = move(flow); + m_functionFlows[&_function] = std::move(flow); m_leave = nullptr; } diff --git a/libyul/ObjectParser.cpp b/libyul/ObjectParser.cpp index afd4b7d94e..1a2d8b33a4 100644 --- a/libyul/ObjectParser.cpp +++ b/libyul/ObjectParser.cpp @@ -88,7 +88,7 @@ shared_ptr ObjectParser::parseObject(Object* _containingObject) expectToken(Token::LBrace); - ret->code = parseCode(move(sourceNameMapping)); + ret->code = parseCode(std::move(sourceNameMapping)); while (currentToken() != Token::RBrace) { @@ -113,7 +113,7 @@ shared_ptr ObjectParser::parseCode(optional _sourceNames) fatalParserError(4846_error, "Expected keyword \"code\"."); advance(); - return parseBlock(move(_sourceNames)); + return parseBlock(std::move(_sourceNames)); } optional ObjectParser::tryParseSourceNameMapping() const @@ -156,7 +156,7 @@ optional ObjectParser::tryParseSourceNameMapping() const Token const next = scanner.next(); if (next == Token::EOS) - return {move(sourceNames)}; + return {std::move(sourceNames)}; if (next != Token::Comma) break; scanner.next(); @@ -172,7 +172,7 @@ optional ObjectParser::tryParseSourceNameMapping() const shared_ptr ObjectParser::parseBlock(optional _sourceNames) { - Parser parser(m_errorReporter, m_dialect, move(_sourceNames)); + Parser parser(m_errorReporter, m_dialect, std::move(_sourceNames)); shared_ptr block = parser.parseInline(m_scanner); yulAssert(block || m_errorReporter.hasErrors(), "Invalid block but no error!"); return block; diff --git a/libyul/backends/evm/ConstantOptimiser.cpp b/libyul/backends/evm/ConstantOptimiser.cpp index aecd00bf4f..59e987b693 100644 --- a/libyul/backends/evm/ConstantOptimiser.cpp +++ b/libyul/backends/evm/ConstantOptimiser.cpp @@ -130,7 +130,7 @@ Representation const& RepresentationFinder::findRepresentation(u256 const& _valu if (numberEncodingSize(~_value) < numberEncodingSize(_value)) // Negated is shorter to represent - routine = min(move(routine), represent("not"_yulstring, findRepresentation(~_value))); + routine = min(std::move(routine), represent("not"_yulstring, findRepresentation(~_value))); // Decompose value into a * 2**k + b where abs(b) << 2**k for (unsigned bits = 255; bits > 8 && m_maxSteps > 0; --bits) @@ -171,10 +171,10 @@ Representation const& RepresentationFinder::findRepresentation(u256 const& _valu if (m_maxSteps > 0) m_maxSteps--; - routine = min(move(routine), move(newRoutine)); + routine = min(std::move(routine), std::move(newRoutine)); } yulAssert(MiniEVMInterpreter{m_dialect}.eval(*routine.expression) == _value, "Invalid expression generated."); - return m_cache[_value] = move(routine); + return m_cache[_value] = std::move(routine); } Representation RepresentationFinder::represent(u256 const& _value) const diff --git a/libyul/backends/evm/ControlFlowGraph.h b/libyul/backends/evm/ControlFlowGraph.h index 8ca2076a04..b267b8461f 100644 --- a/libyul/backends/evm/ControlFlowGraph.h +++ b/libyul/backends/evm/ControlFlowGraph.h @@ -236,7 +236,7 @@ struct CFG BasicBlock& makeBlock(std::shared_ptr _debugData) { - return blocks.emplace_back(BasicBlock{move(_debugData), {}, {}}); + return blocks.emplace_back(BasicBlock{std::move(_debugData), {}, {}}); } }; diff --git a/libyul/backends/evm/ControlFlowGraphBuilder.cpp b/libyul/backends/evm/ControlFlowGraphBuilder.cpp index 855d96fbd3..1980fb4424 100644 --- a/libyul/backends/evm/ControlFlowGraphBuilder.cpp +++ b/libyul/backends/evm/ControlFlowGraphBuilder.cpp @@ -532,7 +532,7 @@ Stack const& ControlFlowGraphBuilder::visitFunctionCall(FunctionCall const& _cal return TemporarySlot{_call, _i}; }) | ranges::to, // operation - move(builtinCall) + std::move(builtinCall) }).output; } else @@ -607,8 +607,8 @@ void ControlFlowGraphBuilder::makeConditionalJump( { yulAssert(m_currentBlock, ""); m_currentBlock->exit = CFG::BasicBlock::ConditionalJump{ - move(_debugData), - move(_condition), + std::move(_debugData), + std::move(_condition), &_nonZero, &_zero }; @@ -624,7 +624,7 @@ void ControlFlowGraphBuilder::jump( ) { yulAssert(m_currentBlock, ""); - m_currentBlock->exit = CFG::BasicBlock::Jump{move(_debugData), &_target, backwards}; + m_currentBlock->exit = CFG::BasicBlock::Jump{std::move(_debugData), &_target, backwards}; _target.entries.emplace_back(m_currentBlock); m_currentBlock = &_target; } diff --git a/libyul/backends/evm/EVMCodeTransform.cpp b/libyul/backends/evm/EVMCodeTransform.cpp index ce55782747..7c9bf05cf1 100644 --- a/libyul/backends/evm/EVMCodeTransform.cpp +++ b/libyul/backends/evm/EVMCodeTransform.cpp @@ -64,9 +64,9 @@ CodeTransform::CodeTransform( m_builtinContext(_builtinContext), m_allowStackOpt(_allowStackOpt), m_useNamedLabelsForFunctions(_useNamedLabelsForFunctions), - m_identifierAccessCodeGen(move(_identifierAccessCodeGen)), - m_context(move(_context)), - m_delayedReturnVariables(move(_delayedReturnVariables)), + m_identifierAccessCodeGen(std::move(_identifierAccessCodeGen)), + m_context(std::move(_context)), + m_delayedReturnVariables(std::move(_delayedReturnVariables)), m_functionExitLabel(_functionExitLabel) { if (!m_context) @@ -406,11 +406,11 @@ void CodeTransform::operator()(FunctionDefinition const& _function) if (!m_allowStackOpt) subTransform.setupReturnVariablesAndFunctionExit(); - subTransform.m_assignedNamedLabels = move(m_assignedNamedLabels); + subTransform.m_assignedNamedLabels = std::move(m_assignedNamedLabels); subTransform(_function.body); - m_assignedNamedLabels = move(subTransform.m_assignedNamedLabels); + m_assignedNamedLabels = std::move(subTransform.m_assignedNamedLabels); m_assembly.setSourceLocation(originLocationOf(_function)); if (!subTransform.m_stackErrors.empty()) diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index c86be6f695..0f5c307e32 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -383,7 +383,7 @@ BuiltinFunctionForEVM const* EVMDialect::verbatimFunction(size_t _arguments, siz } ).second; builtinFunction.isMSize = true; - function = make_shared(move(builtinFunction)); + function = make_shared(std::move(builtinFunction)); } return function.get(); } diff --git a/libyul/backends/evm/EthAssemblyAdapter.cpp b/libyul/backends/evm/EthAssemblyAdapter.cpp index 5d7b4cbf45..685f56cbc0 100644 --- a/libyul/backends/evm/EthAssemblyAdapter.cpp +++ b/libyul/backends/evm/EthAssemblyAdapter.cpp @@ -96,7 +96,7 @@ void EthAssemblyAdapter::appendLinkerSymbol(std::string const& _linkerSymbol) void EthAssemblyAdapter::appendVerbatim(bytes _data, size_t _arguments, size_t _returnVariables) { - m_assembly.appendVerbatim(move(_data), _arguments, _returnVariables); + m_assembly.appendVerbatim(std::move(_data), _arguments, _returnVariables); } void EthAssemblyAdapter::appendJump(int _stackDiffAfter, JumpType _jumpType) diff --git a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp index 08987b5654..db73ba2a7a 100644 --- a/libyul/backends/evm/OptimizedEVMCodeTransform.cpp +++ b/libyul/backends/evm/OptimizedEVMCodeTransform.cpp @@ -61,7 +61,7 @@ vector OptimizedEVMCodeTransform::run( optimizedCodeTransform(*dfg->entry); for (Scope::Function const* function: dfg->functions) optimizedCodeTransform(dfg->functionInfo.at(function)); - return move(optimizedCodeTransform.m_stackErrors); + return std::move(optimizedCodeTransform.m_stackErrors); } void OptimizedEVMCodeTransform::operator()(CFG::FunctionCall const& _call) @@ -459,7 +459,7 @@ void OptimizedEVMCodeTransform::operator()(CFG::BasicBlock const& _block) { // Restore the stack afterwards for the non-zero case below. ScopeGuard stackRestore([storedStack = m_stack, this]() { - m_stack = move(storedStack); + m_stack = std::move(storedStack); m_assembly.setStackHeight(static_cast(m_stack.size())); }); diff --git a/libyul/backends/evm/StackLayoutGenerator.cpp b/libyul/backends/evm/StackLayoutGenerator.cpp index 4f9a1e2a19..8b39b364f8 100644 --- a/libyul/backends/evm/StackLayoutGenerator.cpp +++ b/libyul/backends/evm/StackLayoutGenerator.cpp @@ -65,7 +65,7 @@ map> StackLayoutGenerator: stackTooDeepErrors[YulString{}] = reportStackTooDeep(_cfg, YulString{}); for (auto const& function: _cfg.functions) if (auto errors = reportStackTooDeep(_cfg, function->name); !errors.empty()) - stackTooDeepErrors[function->name] = move(errors); + stackTooDeepErrors[function->name] = std::move(errors); return stackTooDeepErrors; } @@ -324,8 +324,8 @@ Stack StackLayoutGenerator::propagateStackThroughBlock(Stack _exitStack, CFG::Ba Stack newStack = propagateStackThroughOperation(stack, operation, _aggressiveStackCompression); if (!_aggressiveStackCompression && !findStackTooDeep(newStack, stack).empty()) // If we had stack errors, run again with aggressive stack compression. - return propagateStackThroughBlock(move(_exitStack), _block, true); - stack = move(newStack); + return propagateStackThroughBlock(std::move(_exitStack), _block, true); + stack = std::move(newStack); } return stack; @@ -715,13 +715,13 @@ void StackLayoutGenerator::fillInJunk(CFG::BasicBlock const& _block) util::BreadthFirstSearch breadthFirstSearch{{_entry}}; breadthFirstSearch.run([&](CFG::BasicBlock const* _block, auto _addChild) { auto& blockInfo = m_layout.blockInfos.at(_block); - blockInfo.entryLayout = Stack{_numJunk, JunkSlot{}} + move(blockInfo.entryLayout); + blockInfo.entryLayout = Stack{_numJunk, JunkSlot{}} + std::move(blockInfo.entryLayout); for (auto const& operation: _block->operations) { auto& operationEntryLayout = m_layout.operationEntryLayout.at(&operation); - operationEntryLayout = Stack{_numJunk, JunkSlot{}} + move(operationEntryLayout); + operationEntryLayout = Stack{_numJunk, JunkSlot{}} + std::move(operationEntryLayout); } - blockInfo.exitLayout = Stack{_numJunk, JunkSlot{}} + move(blockInfo.exitLayout); + blockInfo.exitLayout = Stack{_numJunk, JunkSlot{}} + std::move(blockInfo.exitLayout); std::visit(util::GenericVisitor{ [&](CFG::BasicBlock::MainExit const&) {}, diff --git a/libyul/backends/wasm/BinaryTransform.cpp b/libyul/backends/wasm/BinaryTransform.cpp index 321792b08d..03f385d805 100644 --- a/libyul/backends/wasm/BinaryTransform.cpp +++ b/libyul/backends/wasm/BinaryTransform.cpp @@ -239,12 +239,12 @@ static map const builtins = { bytes prefixSize(bytes _data) { size_t size = _data.size(); - return lebEncode(size) + move(_data); + return lebEncode(size) + std::move(_data); } bytes makeSection(Section _section, bytes _data) { - return toBytes(_section) + prefixSize(move(_data)); + return toBytes(_section) + prefixSize(std::move(_data)); } /// This is a kind of run-length-encoding of local types. @@ -306,7 +306,7 @@ bytes BinaryTransform::run(Module const& _module) // TODO should we prefix and / or shorten the name? bytes data = BinaryTransform::run(module); size_t const length = data.size(); - ret += customSection(name, move(data)); + ret += customSection(name, std::move(data)); // Skip all the previous sections and the size field of this current custom section. size_t const offset = ret.size() - length; subModulePosAndSize[name] = {offset, length}; @@ -321,10 +321,10 @@ bytes BinaryTransform::run(Module const& _module) } BinaryTransform bt( - move(globalIDs), - move(functionIDs), - move(functionTypes), - move(subModulePosAndSize) + std::move(globalIDs), + std::move(functionIDs), + std::move(functionTypes), + std::move(subModulePosAndSize) ); ret += bt.codeSection(_module.functions); @@ -378,7 +378,7 @@ bytes BinaryTransform::operator()(BuiltinCall const& _call) yulAssert(builtins.count(_call.functionName), "Builtin " + _call.functionName + " not found"); // NOTE: the dialect ensures we have the right amount of arguments bytes args = visit(_call.arguments); - bytes ret = move(args) + toBytes(builtins.at(_call.functionName)); + bytes ret = std::move(args) + toBytes(builtins.at(_call.functionName)); if ( _call.functionName.find(".load") != string::npos || _call.functionName.find(".store") != string::npos @@ -500,7 +500,7 @@ bytes BinaryTransform::operator()(FunctionDefinition const& _function) yulAssert(m_labels.empty(), "Stray labels."); - return prefixSize(move(ret)); + return prefixSize(std::move(ret)); } BinaryTransform::Type BinaryTransform::typeOf(FunctionImport const& _import) @@ -602,7 +602,7 @@ bytes BinaryTransform::typeSection(map> co index++; } - return makeSection(Section::TYPE, lebEncode(index) + move(result)); + return makeSection(Section::TYPE, lebEncode(index) + std::move(result)); } bytes BinaryTransform::importSection( @@ -620,7 +620,7 @@ bytes BinaryTransform::importSection( toBytes(importKind) + lebEncode(_functionTypes.at(import.internalName)); } - return makeSection(Section::IMPORT, move(result)); + return makeSection(Section::IMPORT, std::move(result)); } bytes BinaryTransform::functionSection( @@ -631,7 +631,7 @@ bytes BinaryTransform::functionSection( bytes result = lebEncode(_functions.size()); for (auto const& fun: _functions) result += lebEncode(_functionTypes.at(fun.name)); - return makeSection(Section::FUNCTION, move(result)); + return makeSection(Section::FUNCTION, std::move(result)); } bytes BinaryTransform::memorySection() @@ -639,7 +639,7 @@ bytes BinaryTransform::memorySection() bytes result = lebEncode(1); result.push_back(static_cast(LimitsKind::Min)); result.push_back(1); // initial length - return makeSection(Section::MEMORY, move(result)); + return makeSection(Section::MEMORY, std::move(result)); } bytes BinaryTransform::globalSection(vector const& _globals) @@ -656,7 +656,7 @@ bytes BinaryTransform::globalSection(vector con toBytes(Opcode::End); } - return makeSection(Section::GLOBAL, move(result)); + return makeSection(Section::GLOBAL, std::move(result)); } bytes BinaryTransform::exportSection(map const& _functionIDs) @@ -666,13 +666,13 @@ bytes BinaryTransform::exportSection(map const& _functionIDs) result += encodeName("memory") + toBytes(Export::Memory) + lebEncode(0); if (hasMain) result += encodeName("main") + toBytes(Export::Function) + lebEncode(_functionIDs.at("main")); - return makeSection(Section::EXPORT, move(result)); + return makeSection(Section::EXPORT, std::move(result)); } bytes BinaryTransform::customSection(string const& _name, bytes _data) { - bytes result = encodeName(_name) + move(_data); - return makeSection(Section::CUSTOM, move(result)); + bytes result = encodeName(_name) + std::move(_data); + return makeSection(Section::CUSTOM, std::move(result)); } bytes BinaryTransform::codeSection(vector const& _functions) @@ -680,7 +680,7 @@ bytes BinaryTransform::codeSection(vector const& _func bytes result = lebEncode(_functions.size()); for (FunctionDefinition const& fun: _functions) result += (*this)(fun); - return makeSection(Section::CODE, move(result)); + return makeSection(Section::CODE, std::move(result)); } bytes BinaryTransform::visit(vector const& _expressions) diff --git a/libyul/backends/wasm/EVMToEwasmTranslator.cpp b/libyul/backends/wasm/EVMToEwasmTranslator.cpp index 359cc023bb..d36b1cda39 100644 --- a/libyul/backends/wasm/EVMToEwasmTranslator.cpp +++ b/libyul/backends/wasm/EVMToEwasmTranslator.cpp @@ -92,7 +92,7 @@ Object EVMToEwasmTranslator::run(Object const& _object) Object ret; ret.name = _object.name; - ret.code = make_shared(move(ast)); + ret.code = make_shared(std::move(ast)); ret.debugData = _object.debugData; ret.analysisInfo = make_shared(); diff --git a/libyul/backends/wasm/TextTransform.cpp b/libyul/backends/wasm/TextTransform.cpp index 9880f5ee5f..62596ba6e8 100644 --- a/libyul/backends/wasm/TextTransform.cpp +++ b/libyul/backends/wasm/TextTransform.cpp @@ -90,7 +90,7 @@ string TextTransform::run(wasm::Module const& _module) ret += "\n"; for (auto const& f: _module.functions) ret += transform(f) + "\n"; - return move(ret) + ")\n"; + return std::move(ret) + ")\n"; } string TextTransform::operator()(wasm::Literal const& _literal) @@ -159,7 +159,7 @@ string TextTransform::operator()(wasm::If const& _if) string TextTransform::operator()(wasm::Loop const& _loop) { string label = _loop.labelName.empty() ? "" : " $" + _loop.labelName; - return "(loop" + move(label) + "\n" + indented(joinTransformed(_loop.statements, '\n')) + ")\n"; + return "(loop" + std::move(label) + "\n" + indented(joinTransformed(_loop.statements, '\n')) + ")\n"; } string TextTransform::operator()(wasm::Branch const& _branch) @@ -180,7 +180,7 @@ string TextTransform::operator()(wasm::Return const&) string TextTransform::operator()(wasm::Block const& _block) { string label = _block.labelName.empty() ? "" : " $" + _block.labelName; - return "(block" + move(label) + "\n" + indented(joinTransformed(_block.statements, '\n')) + "\n)\n"; + return "(block" + std::move(label) + "\n" + indented(joinTransformed(_block.statements, '\n')) + "\n)\n"; } string TextTransform::indented(string const& _in) @@ -230,7 +230,7 @@ string TextTransform::joinTransformed(vector const& _expressio string t = visit(e); if (!t.empty() && !ret.empty() && ret.back() != '\n') ret += _separator; - ret += move(t); + ret += std::move(t); } return ret; } diff --git a/libyul/backends/wasm/WasmCodeTransform.cpp b/libyul/backends/wasm/WasmCodeTransform.cpp index 32c7745334..2d895d3fe0 100644 --- a/libyul/backends/wasm/WasmCodeTransform.cpp +++ b/libyul/backends/wasm/WasmCodeTransform.cpp @@ -68,7 +68,7 @@ wasm::Expression WasmCodeTransform::generateMultiAssignment( ) { yulAssert(!_variableNames.empty(), ""); - wasm::LocalAssignment assignment{move(_variableNames.front()), std::move(_firstValue)}; + wasm::LocalAssignment assignment{std::move(_variableNames.front()), std::move(_firstValue)}; if (_variableNames.size() == 1) return { std::move(assignment) }; @@ -80,10 +80,10 @@ wasm::Expression WasmCodeTransform::generateMultiAssignment( yulAssert(allocatedIndices.size() == _variableNames.size() - 1, ""); wasm::Block block; - block.statements.emplace_back(move(assignment)); + block.statements.emplace_back(std::move(assignment)); for (size_t i = 1; i < _variableNames.size(); ++i) block.statements.emplace_back(wasm::LocalAssignment{ - move(_variableNames.at(i)), + std::move(_variableNames.at(i)), make_unique(wasm::GlobalVariable{m_globalVariables.at(allocatedIndices[i - 1]).variableName}) }); return { std::move(block) }; @@ -99,7 +99,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::VariableDeclaration const& _ } if (_varDecl.value) - return generateMultiAssignment(move(variableNames), visit(*_varDecl.value)); + return generateMultiAssignment(std::move(variableNames), visit(*_varDecl.value)); else return wasm::BuiltinCall{"nop", {}}; } @@ -109,7 +109,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::Assignment const& _assignmen vector variableNames; for (auto const& var: _assignment.variableNames) variableNames.emplace_back(var.name.str()); - return generateMultiAssignment(move(variableNames), visit(*_assignment.value)); + return generateMultiAssignment(std::move(variableNames), visit(*_assignment.value)); } wasm::Expression WasmCodeTransform::operator()(yul::ExpressionStatement const& _statement) @@ -134,7 +134,7 @@ void WasmCodeTransform::importBuiltinFunction(BuiltinFunction const* _builtin, s }; for (auto const& param: _builtin->parameters) imp.paramTypes.emplace_back(translatedType(param)); - m_functionsToImport[internalName] = move(imp); + m_functionsToImport[internalName] = std::move(imp); } } @@ -199,7 +199,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::If const& _if) else yulAssert(false, "Invalid condition type"); - return wasm::If{make_unique(move(condition)), visit(_if.body.statements), {}}; + return wasm::If{make_unique(std::move(condition)), visit(_if.body.statements), {}}; } wasm::Expression WasmCodeTransform::operator()(yul::Switch const& _switch) @@ -224,7 +224,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::Switch const& _switch) visitReturnByValue(*c.value) )}; wasm::If ifStmnt{ - make_unique(move(comparison)), + make_unique(std::move(comparison)), visit(c.body.statements), {} }; @@ -234,7 +234,7 @@ wasm::Expression WasmCodeTransform::operator()(yul::Switch const& _switch) ifStmnt.elseStatements = make_unique>(); nextBlock = ifStmnt.elseStatements.get(); } - currentBlock->emplace_back(move(ifStmnt)); + currentBlock->emplace_back(std::move(ifStmnt)); currentBlock = nextBlock; } else @@ -275,8 +275,8 @@ wasm::Expression WasmCodeTransform::operator()(yul::ForLoop const& _for) loop.statements += visit(_for.post.statements); loop.statements.emplace_back(wasm::Branch{wasm::Label{loop.labelName}}); - statements += make_vector(move(loop)); - return wasm::Block{breakLabel, move(statements)}; + statements += make_vector(std::move(loop)); + return wasm::Block{breakLabel, std::move(statements)}; } wasm::Expression WasmCodeTransform::operator()(yul::Break const&) diff --git a/libyul/backends/wasm/WasmDialect.cpp b/libyul/backends/wasm/WasmDialect.cpp index 817d53467a..b724ba69e6 100644 --- a/libyul/backends/wasm/WasmDialect.cpp +++ b/libyul/backends/wasm/WasmDialect.cpp @@ -269,7 +269,7 @@ void WasmDialect::addFunction( vector> _literalArguments ) { - YulString name{move(_name)}; + YulString name{std::move(_name)}; BuiltinFunction& f = m_functions[name]; f.name = name; f.parameters = std::move(_params); diff --git a/libyul/optimiser/ConditionalSimplifier.h b/libyul/optimiser/ConditionalSimplifier.h index 5df56476a3..e558a1c6cf 100644 --- a/libyul/optimiser/ConditionalSimplifier.h +++ b/libyul/optimiser/ConditionalSimplifier.h @@ -64,7 +64,7 @@ class ConditionalSimplifier: public ASTModifier Dialect const& _dialect, std::map _sideEffects ): - m_dialect(_dialect), m_functionSideEffects(move(_sideEffects)) + m_dialect(_dialect), m_functionSideEffects(std::move(_sideEffects)) {} Dialect const& m_dialect; std::map m_functionSideEffects; diff --git a/libyul/optimiser/DeadCodeEliminator.h b/libyul/optimiser/DeadCodeEliminator.h index 2c166a8361..ae8c1b2a6a 100644 --- a/libyul/optimiser/DeadCodeEliminator.h +++ b/libyul/optimiser/DeadCodeEliminator.h @@ -63,7 +63,7 @@ class DeadCodeEliminator: public ASTModifier DeadCodeEliminator( Dialect const& _dialect, std::map _sideEffects - ): m_dialect(_dialect), m_functionSideEffects(move(_sideEffects)) {} + ): m_dialect(_dialect), m_functionSideEffects(std::move(_sideEffects)) {} Dialect const& m_dialect; std::map m_functionSideEffects; diff --git a/libyul/optimiser/ForLoopInitRewriter.cpp b/libyul/optimiser/ForLoopInitRewriter.cpp index 345dd12664..7cfa16b4f7 100644 --- a/libyul/optimiser/ForLoopInitRewriter.cpp +++ b/libyul/optimiser/ForLoopInitRewriter.cpp @@ -40,7 +40,7 @@ void ForLoopInitRewriter::operator()(Block& _block) (*this)(forLoop.post); vector rewrite; swap(rewrite, forLoop.pre.statements); - rewrite.emplace_back(move(forLoop)); + rewrite.emplace_back(std::move(forLoop)); return { std::move(rewrite) }; } else diff --git a/libyul/optimiser/FunctionSpecializer.cpp b/libyul/optimiser/FunctionSpecializer.cpp index 1d14db18be..4555e2f8fc 100644 --- a/libyul/optimiser/FunctionSpecializer.cpp +++ b/libyul/optimiser/FunctionSpecializer.cpp @@ -65,7 +65,7 @@ void FunctionSpecializer::operator()(FunctionCall& _f) if (ranges::any_of(arguments, [](auto& _a) { return _a.has_value(); })) { - YulString oldName = move(_f.functionName.name); + YulString oldName = std::move(_f.functionName.name); auto newName = m_nameDispenser.newName(oldName); m_oldToNewMap[oldName].emplace_back(make_pair(newName, arguments)); @@ -106,12 +106,12 @@ FunctionDefinition FunctionSpecializer::specialize( VariableDeclaration{ _f.debugData, vector{newFunction.parameters[index]}, - make_unique(move(*argument)) + make_unique(std::move(*argument)) } ); newFunction.body.statements = - move(missingVariableDeclarations) + move(newFunction.body.statements); + std::move(missingVariableDeclarations) + std::move(newFunction.body.statements); // Only take those indices that cannot be specialized, i.e., whose value is `nullopt`. newFunction.parameters = @@ -120,7 +120,7 @@ FunctionDefinition FunctionSpecializer::specialize( applyMap(_arguments, [&](auto const& _v) { return !_v; }) ); - newFunction.name = move(_newName); + newFunction.name = std::move(_newName); return newFunction; } @@ -146,10 +146,10 @@ void FunctionSpecializer::run(OptimiserStepContext& _context, Block& _ast) f.m_oldToNewMap.at(functionDefinition.name), [&](auto& _p) -> Statement { - return f.specialize(functionDefinition, move(_p.first), move(_p.second)); + return f.specialize(functionDefinition, std::move(_p.first), std::move(_p.second)); } ); - return move(out) + make_vector(move(functionDefinition)); + return std::move(out) + make_vector(std::move(functionDefinition)); } } diff --git a/libyul/optimiser/KnowledgeBase.cpp b/libyul/optimiser/KnowledgeBase.cpp index 460f6707ff..77848cce04 100644 --- a/libyul/optimiser/KnowledgeBase.cpp +++ b/libyul/optimiser/KnowledgeBase.cpp @@ -89,7 +89,7 @@ optional KnowledgeBase::valueIfKnownConstant(YulString _a) Expression KnowledgeBase::simplify(Expression _expression) { m_counter = 0; - return simplifyRecursively(move(_expression)); + return simplifyRecursively(std::move(_expression)); } Expression KnowledgeBase::simplifyRecursively(Expression _expression) diff --git a/libyul/optimiser/NameDispenser.cpp b/libyul/optimiser/NameDispenser.cpp index 01d33919f0..d43b6802fe 100644 --- a/libyul/optimiser/NameDispenser.cpp +++ b/libyul/optimiser/NameDispenser.cpp @@ -37,7 +37,7 @@ using namespace solidity::util; NameDispenser::NameDispenser(Dialect const& _dialect, Block const& _ast, set _reservedNames): NameDispenser(_dialect, NameCollector(_ast).names() + _reservedNames) { - m_reservedNames = move(_reservedNames); + m_reservedNames = std::move(_reservedNames); } NameDispenser::NameDispenser(Dialect const& _dialect, set _usedNames): diff --git a/libyul/optimiser/NameSimplifier.cpp b/libyul/optimiser/NameSimplifier.cpp index dfe1df9f49..0eb568beb2 100644 --- a/libyul/optimiser/NameSimplifier.cpp +++ b/libyul/optimiser/NameSimplifier.cpp @@ -111,7 +111,7 @@ void NameSimplifier::findSimplification(YulString const& _name) { YulString newName{name}; m_context.dispenser.markUsed(newName); - m_translations[_name] = move(newName); + m_translations[_name] = std::move(newName); } } diff --git a/libyul/optimiser/ReasoningBasedSimplifier.cpp b/libyul/optimiser/ReasoningBasedSimplifier.cpp index 94c7102bdc..af39978edb 100644 --- a/libyul/optimiser/ReasoningBasedSimplifier.cpp +++ b/libyul/optimiser/ReasoningBasedSimplifier.cpp @@ -71,7 +71,7 @@ void ReasoningBasedSimplifier::operator()(If& _if) { Literal trueCondition = m_dialect.trueLiteral(); trueCondition.debugData = debugDataOf(*_if.condition); - _if.condition = make_unique(move(trueCondition)); + _if.condition = make_unique(std::move(trueCondition)); } else { @@ -83,7 +83,7 @@ void ReasoningBasedSimplifier::operator()(If& _if) { Literal falseCondition = m_dialect.zeroLiteralForType(m_dialect.boolType); falseCondition.debugData = debugDataOf(*_if.condition); - _if.condition = make_unique(move(falseCondition)); + _if.condition = make_unique(std::move(falseCondition)); _if.body = yul::Block{}; // Nothing left to be done. return; diff --git a/libyul/optimiser/StackCompressor.cpp b/libyul/optimiser/StackCompressor.cpp index 6e33078a0a..a6173996f2 100644 --- a/libyul/optimiser/StackCompressor.cpp +++ b/libyul/optimiser/StackCompressor.cpp @@ -176,7 +176,7 @@ void eliminateVariables( varsToEliminate += chooseVarsToEliminate(candidates[functionName], static_cast(numVariables)); } - Rematerialiser::run(_dialect, _ast, move(varsToEliminate)); + Rematerialiser::run(_dialect, _ast, std::move(varsToEliminate)); // Do not remove functions. set allFunctions = NameCollector{_ast, NameCollector::OnlyFunctions}.names(); UnusedPruner::runUntilStabilised(_dialect, _ast, _allowMSizeOptimization, nullptr, allFunctions); diff --git a/libyul/optimiser/StackToMemoryMover.cpp b/libyul/optimiser/StackToMemoryMover.cpp index 4256809236..74d05635e3 100644 --- a/libyul/optimiser/StackToMemoryMover.cpp +++ b/libyul/optimiser/StackToMemoryMover.cpp @@ -50,7 +50,7 @@ vector generateMemoryStore( Identifier{_debugData, memoryStoreFunction->name}, { Literal{_debugData, LiteralKind::Number, _mpos, {}}, - move(_value) + std::move(_value) } }}); return result; @@ -95,7 +95,7 @@ void StackToMemoryMover::run( ) ); stackToMemoryMover(_block); - _block.statements += move(stackToMemoryMover.m_newFunctionDefinitions); + _block.statements += std::move(stackToMemoryMover.m_newFunctionDefinitions); } StackToMemoryMover::StackToMemoryMover( @@ -106,7 +106,7 @@ StackToMemoryMover::StackToMemoryMover( m_context(_context), m_memoryOffsetTracker(_memoryOffsetTracker), m_nameDispenser(_context.dispenser), -m_functionReturnVariables(move(_functionReturnVariables)) +m_functionReturnVariables(std::move(_functionReturnVariables)) { auto const* evmDialect = dynamic_cast(&_context.dialect); yulAssert( @@ -156,7 +156,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) newFunctionName, stackParameters, {}, - move(_functionDefinition.body) + std::move(_functionDefinition.body) }); // Generate new names for the arguments to maintain disambiguation. std::map newArgumentNames; @@ -165,7 +165,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) for (auto& parameter: _functionDefinition.parameters) parameter.name = util::valueOrDefault(newArgumentNames, parameter.name, parameter.name); // Replace original function by a call to the new function and an assignment to the return variable from memory. - _functionDefinition.body = Block{_functionDefinition.debugData, move(memoryVariableInits)}; + _functionDefinition.body = Block{_functionDefinition.debugData, std::move(memoryVariableInits)}; _functionDefinition.body.statements.emplace_back(ExpressionStatement{ _functionDefinition.debugData, FunctionCall{ @@ -189,7 +189,7 @@ void StackToMemoryMover::operator()(FunctionDefinition& _functionDefinition) } if (!memoryVariableInits.empty()) - _functionDefinition.body.statements = move(memoryVariableInits) + move(_functionDefinition.body.statements); + _functionDefinition.body.statements = std::move(memoryVariableInits) + std::move(_functionDefinition.body.statements); _functionDefinition.returnVariables = _functionDefinition.returnVariables | ranges::views::filter( not_fn(m_memoryOffsetTracker) @@ -214,7 +214,7 @@ void StackToMemoryMover::operator()(Block& _block) m_context.dialect, debugData, *offset, - _stmt.value ? *move(_stmt.value) : Literal{debugData, LiteralKind::Number, "0"_yulstring, {}} + _stmt.value ? *std::move(_stmt.value) : Literal{debugData, LiteralKind::Number, "0"_yulstring, {}} ); else return {}; @@ -245,7 +245,7 @@ void StackToMemoryMover::operator()(Block& _block) vector memoryAssignments; vector variableAssignments; - VariableDeclaration tempDecl{debugData, {}, move(_stmt.value)}; + VariableDeclaration tempDecl{debugData, {}, std::move(_stmt.value)}; yulAssert(rhsMemorySlots.size() == _lhsVars.size(), ""); for (auto&& [lhsVar, rhsSlot]: ranges::views::zip(_lhsVars, rhsMemorySlots)) @@ -265,26 +265,26 @@ void StackToMemoryMover::operator()(Block& _block) m_context.dialect, _stmt.debugData, *offset, - move(*rhs) + std::move(*rhs) ); else variableAssignments.emplace_back(StatementType{ debugData, - { move(lhsVar) }, - move(rhs) + { std::move(lhsVar) }, + std::move(rhs) }); } vector result; if (tempDecl.variables.empty()) - result.emplace_back(ExpressionStatement{debugData, *move(tempDecl.value)}); + result.emplace_back(ExpressionStatement{debugData, *std::move(tempDecl.value)}); else - result.emplace_back(move(tempDecl)); + result.emplace_back(std::move(tempDecl)); reverse(memoryAssignments.begin(), memoryAssignments.end()); - result += move(memoryAssignments); + result += std::move(memoryAssignments); reverse(variableAssignments.begin(), variableAssignments.end()); - result += move(variableAssignments); - return OptionalStatements{move(result)}; + result += std::move(variableAssignments); + return OptionalStatements{std::move(result)}; }; util::iterateReplacing( diff --git a/libyul/optimiser/UnusedFunctionParameterPruner.cpp b/libyul/optimiser/UnusedFunctionParameterPruner.cpp index 75e8325a3e..6ce097f42d 100644 --- a/libyul/optimiser/UnusedFunctionParameterPruner.cpp +++ b/libyul/optimiser/UnusedFunctionParameterPruner.cpp @@ -118,7 +118,7 @@ void UnusedFunctionParameterPruner::run(OptimiserStepContext& _context, Block& _ originalFunction.returnVariables = filter(originalFunction.returnVariables, used.second); - return make_vector(move(originalFunction), move(linkingFunction)); + return make_vector(std::move(originalFunction), std::move(linkingFunction)); } } diff --git a/libyul/optimiser/UnusedStoreBase.cpp b/libyul/optimiser/UnusedStoreBase.cpp index de13a23ccb..49f5508427 100644 --- a/libyul/optimiser/UnusedStoreBase.cpp +++ b/libyul/optimiser/UnusedStoreBase.cpp @@ -40,7 +40,7 @@ void UnusedStoreBase::operator()(If const& _if) TrackedStores skipBranch{m_stores}; (*this)(_if.body); - merge(m_stores, move(skipBranch)); + merge(m_stores, std::move(skipBranch)); } void UnusedStoreBase::operator()(Switch const& _switch) @@ -56,17 +56,17 @@ void UnusedStoreBase::operator()(Switch const& _switch) if (!c.value) hasDefault = true; (*this)(c.body); - branches.emplace_back(move(m_stores)); + branches.emplace_back(std::move(m_stores)); m_stores = preState; } if (hasDefault) { - m_stores = move(branches.back()); + m_stores = std::move(branches.back()); branches.pop_back(); } for (auto& branch: branches) - merge(m_stores, move(branch)); + merge(m_stores, std::move(branch)); } void UnusedStoreBase::operator()(FunctionDefinition const& _functionDefinition) @@ -97,7 +97,7 @@ void UnusedStoreBase::operator()(ForLoop const& _forLoop) TrackedStores zeroRuns{m_stores}; (*this)(_forLoop.body); - merge(m_stores, move(m_forLoopInfo.pendingContinueStmts)); + merge(m_stores, std::move(m_forLoopInfo.pendingContinueStmts)); m_forLoopInfo.pendingContinueStmts = {}; (*this)(_forLoop.post); @@ -110,50 +110,50 @@ void UnusedStoreBase::operator()(ForLoop const& _forLoop) (*this)(_forLoop.body); - merge(m_stores, move(m_forLoopInfo.pendingContinueStmts)); + merge(m_stores, std::move(m_forLoopInfo.pendingContinueStmts)); m_forLoopInfo.pendingContinueStmts.clear(); (*this)(_forLoop.post); visit(*_forLoop.condition); // Order of merging does not matter because "max" is commutative and associative. - merge(m_stores, move(oneRun)); + merge(m_stores, std::move(oneRun)); } else // Shortcut to avoid horrible runtime. shortcutNestedLoop(zeroRuns); // Order of merging does not matter because "max" is commutative and associative. - merge(m_stores, move(zeroRuns)); - merge(m_stores, move(m_forLoopInfo.pendingBreakStmts)); + merge(m_stores, std::move(zeroRuns)); + merge(m_stores, std::move(m_forLoopInfo.pendingBreakStmts)); m_forLoopInfo.pendingBreakStmts.clear(); } void UnusedStoreBase::operator()(Break const&) { - m_forLoopInfo.pendingBreakStmts.emplace_back(move(m_stores)); + m_forLoopInfo.pendingBreakStmts.emplace_back(std::move(m_stores)); m_stores.clear(); } void UnusedStoreBase::operator()(Continue const&) { - m_forLoopInfo.pendingContinueStmts.emplace_back(move(m_stores)); + m_forLoopInfo.pendingContinueStmts.emplace_back(std::move(m_stores)); m_stores.clear(); } void UnusedStoreBase::merge(TrackedStores& _target, TrackedStores&& _other) { - util::joinMap(_target, move(_other), []( + util::joinMap(_target, std::move(_other), []( map& _assignmentHere, map&& _assignmentThere ) { - return util::joinMap(_assignmentHere, move(_assignmentThere), State::join); + return util::joinMap(_assignmentHere, std::move(_assignmentThere), State::join); }); } void UnusedStoreBase::merge(TrackedStores& _target, vector&& _source) { for (TrackedStores& ts: _source) - merge(_target, move(ts)); + merge(_target, std::move(ts)); _source.clear(); } diff --git a/libyul/optimiser/UnusedStoreEliminator.cpp b/libyul/optimiser/UnusedStoreEliminator.cpp index 0e6acdeea0..754c02ac5d 100644 --- a/libyul/optimiser/UnusedStoreEliminator.cpp +++ b/libyul/optimiser/UnusedStoreEliminator.cpp @@ -186,7 +186,7 @@ void UnusedStoreEliminator::visit(Statement const& _statement) m_stores[YulString{}].insert({&_statement, initialState}); vector operations = operationsFromFunctionCall(*funCall); yulAssert(operations.size() == 1, ""); - m_storeOperations[&_statement] = move(operations.front()); + m_storeOperations[&_statement] = std::move(operations.front()); } } diff --git a/test/CommonSyntaxTest.cpp b/test/CommonSyntaxTest.cpp index 5b66aea302..f794439de8 100644 --- a/test/CommonSyntaxTest.cpp +++ b/test/CommonSyntaxTest.cpp @@ -245,10 +245,10 @@ vector CommonSyntaxTest::parseExpectations(istream& _stream) string errorMessage(it, line.end()); expectations.emplace_back(SyntaxTestError{ - move(errorType), - move(errorId), - move(errorMessage), - move(sourceName), + std::move(errorType), + std::move(errorId), + std::move(errorMessage), + std::move(sourceName), locationStart, locationEnd }); diff --git a/test/EVMHost.cpp b/test/EVMHost.cpp index 6c5cb6912f..118a517fba 100644 --- a/test/EVMHost.cpp +++ b/test/EVMHost.cpp @@ -50,7 +50,7 @@ evmc::VM& EVMHost::getVM(string const& _path) if (vm && errorCode == EVMC_LOADER_SUCCESS) { if (vm.get_capabilities() & (EVMC_CAPABILITY_EVM1 | EVMC_CAPABILITY_EWASM)) - vms[_path] = make_unique(evmc::VM(move(vm))); + vms[_path] = make_unique(evmc::VM(std::move(vm))); else cerr << "VM loaded neither supports EVM1 nor EWASM" << endl; } diff --git a/test/Metadata.cpp b/test/Metadata.cpp index 27e5332af5..88a1f7b42f 100644 --- a/test/Metadata.cpp +++ b/test/Metadata.cpp @@ -162,7 +162,7 @@ std::optional> parseCBORMetadata(bytes const& _metadata) { string key = parser.readKey(); string value = parser.readValue(); - ret[move(key)] = move(value); + ret[std::move(key)] = std::move(value); } return ret; } diff --git a/test/TestCaseReader.cpp b/test/TestCaseReader.cpp index d9015b55f6..43e4a6fc36 100644 --- a/test/TestCaseReader.cpp +++ b/test/TestCaseReader.cpp @@ -194,7 +194,7 @@ pair TestCaseReader::parseSourcesAndSettingsWithLineNumber(is } // Register the last source as the main one sources[currentSourceName] = currentSource; - return {{move(sources), move(externalSources), move(currentSourceName)}, lineNumber}; + return {{std::move(sources), std::move(externalSources), std::move(currentSourceName)}, lineNumber}; } string TestCaseReader::parseSimpleExpectations(istream& _file) diff --git a/test/libevmasm/Optimiser.cpp b/test/libevmasm/Optimiser.cpp index f08f227cb3..6fc3c5a743 100644 --- a/test/libevmasm/Optimiser.cpp +++ b/test/libevmasm/Optimiser.cpp @@ -143,7 +143,7 @@ namespace for (BasicBlock const& block: cfg.optimisedBlocks()) copy(output.begin() + static_cast(block.begin), output.begin() + static_cast(block.end), back_inserter(optItems)); - output = move(optItems); + output = std::move(optItems); } return output; } diff --git a/test/liblangutil/Scanner.cpp b/test/liblangutil/Scanner.cpp index c288ed8543..9e196b0f54 100644 --- a/test/liblangutil/Scanner.cpp +++ b/test/liblangutil/Scanner.cpp @@ -150,11 +150,11 @@ struct TestScanner { unique_ptr stream; unique_ptr scanner; - explicit TestScanner(string _text) { reset(move(_text)); } + explicit TestScanner(string _text) { reset(std::move(_text)); } void reset(std::string _text) { - stream = make_unique(move(_text), ""); + stream = make_unique(std::move(_text), ""); scanner = make_unique(*stream); } diff --git a/test/libsolidity/GasTest.cpp b/test/libsolidity/GasTest.cpp index fd215cb940..030472e8a1 100644 --- a/test/libsolidity/GasTest.cpp +++ b/test/libsolidity/GasTest.cpp @@ -58,7 +58,7 @@ void GasTest::parseExpectations(std::istream& _stream) { string kind = line.substr(3, line.length() - 4); boost::trim(kind); - currentKind = &m_expectations[move(kind)]; + currentKind = &m_expectations[std::move(kind)]; } else if (!currentKind) BOOST_THROW_EXCEPTION(runtime_error("No function kind specified. Expected \"creation:\", \"external:\" or \"internal:\".")); diff --git a/test/libsolidity/SMTCheckerTest.cpp b/test/libsolidity/SMTCheckerTest.cpp index 10084b0143..eed911b1a7 100644 --- a/test/libsolidity/SMTCheckerTest.cpp +++ b/test/libsolidity/SMTCheckerTest.cpp @@ -77,7 +77,7 @@ SMTCheckerTest::SMTCheckerTest(string const& _filename): SyntaxTest(_filename, E return filtered; }; if (m_modelCheckerSettings.invariants.invariants.empty()) - m_expectations = removeInv(move(m_expectations)); + m_expectations = removeInv(std::move(m_expectations)); auto const& ignoreInv = m_reader.stringSetting("SMTIgnoreInv", "yes"); if (ignoreInv == "no") diff --git a/test/libsolidity/SemanticTest.cpp b/test/libsolidity/SemanticTest.cpp index 785a32fdc3..9cf2b8d521 100644 --- a/test/libsolidity/SemanticTest.cpp +++ b/test/libsolidity/SemanticTest.cpp @@ -61,7 +61,7 @@ SemanticTest::SemanticTest( m_sideEffectHooks(makeSideEffectHooks()), m_enforceCompileToEwasm(_enforceCompileToEwasm), m_enforceGasCost(_enforceGasCost), - m_enforceGasCostMinValue(move(_enforceGasCostMinValue)) + m_enforceGasCostMinValue(std::move(_enforceGasCostMinValue)) { static set const compileViaYulAllowedValues{"also", "true", "false"}; static set const yulRunTriggers{"also", "true"}; @@ -457,14 +457,14 @@ TestCase::TestResult SemanticTest::runTest( success = false; test.setFailure(!m_transactionSuccessful); - test.setRawBytes(move(output)); + test.setRawBytes(std::move(output)); test.setContractABI(m_compiler.contractABI(m_compiler.lastContractName(m_sources.mainSourceFile))); } vector effects; for (SideEffectHook const& hook: m_sideEffectHooks) effects += hook(test.call()); - test.setSideEffects(move(effects)); + test.setSideEffects(std::move(effects)); success &= test.call().expectedSideEffects == test.call().actualSideEffects; } diff --git a/test/libsolidity/SolidityExecutionFramework.cpp b/test/libsolidity/SolidityExecutionFramework.cpp index 70d0b2a6e4..cb47cf45e8 100644 --- a/test/libsolidity/SolidityExecutionFramework.cpp +++ b/test/libsolidity/SolidityExecutionFramework.cpp @@ -109,7 +109,7 @@ bytes SolidityExecutionFramework::multiSourceCompileContract( try { asmStack.optimize(); - obj = move(*asmStack.assemble(yul::YulStack::Machine::EVM).bytecode); + obj = std::move(*asmStack.assemble(yul::YulStack::Machine::EVM).bytecode); obj.link(_libraryAddresses); break; } diff --git a/test/libsolidity/util/TestFileParser.cpp b/test/libsolidity/util/TestFileParser.cpp index 4ad0701e48..915586ad2d 100644 --- a/test/libsolidity/util/TestFileParser.cpp +++ b/test/libsolidity/util/TestFileParser.cpp @@ -178,7 +178,7 @@ vector TestFileParser::parseFunctionCall accept(Token::Newline, true); call.expectedSideEffects = parseFunctionCallSideEffects(); - calls.emplace_back(move(call)); + calls.emplace_back(std::move(call)); } } catch (TestParserError const& _e) diff --git a/test/libyul/ObjectParser.cpp b/test/libyul/ObjectParser.cpp index bee0025afa..be3de930de 100644 --- a/test/libyul/ObjectParser.cpp +++ b/test/libyul/ObjectParser.cpp @@ -122,7 +122,7 @@ tuple, ErrorList> tryGetSourceLocationMapping(string _so ErrorReporter reporter(errors); Dialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(EVMVersion::berlin()); ObjectParser objectParser{reporter, dialect}; - CharStream stream(move(source), ""); + CharStream stream(std::move(source), ""); auto object = objectParser.parse(make_shared(stream), false); BOOST_REQUIRE(object && object->debugData); return {object->debugData->sourceNames, std::move(errors)}; diff --git a/test/libyul/Parser.cpp b/test/libyul/Parser.cpp index 49152e7f86..511ed6c190 100644 --- a/test/libyul/Parser.cpp +++ b/test/libyul/Parser.cpp @@ -65,7 +65,7 @@ shared_ptr parse(string const& _source, Dialect const& _dialect, ErrorRep auto parserResult = yul::Parser( errorReporter, _dialect, - move(indicesToSourceNames) + std::move(indicesToSourceNames) ).parse(stream); if (parserResult) { diff --git a/test/solc/Common.cpp b/test/solc/Common.cpp index ead9b798da..8e2e329e4f 100644 --- a/test/solc/Common.cpp +++ b/test/solc/Common.cpp @@ -91,5 +91,5 @@ string test::stripPreReleaseWarning(string const& _stderrContent) }; string output = regex_replace(_stderrContent, preReleaseWarningRegex, ""); - return regex_replace(move(output), noOutputRegex, ""); + return regex_replace(std::move(output), noOutputRegex, ""); } diff --git a/test/yulPhaser/FitnessMetrics.cpp b/test/yulPhaser/FitnessMetrics.cpp index bd063bf1f4..bde15a537f 100644 --- a/test/yulPhaser/FitnessMetrics.cpp +++ b/test/yulPhaser/FitnessMetrics.cpp @@ -64,7 +64,7 @@ class ProgramBasedMetricFixture Program optimisedProgram(Program _program) const { [[maybe_unused]] size_t originalSize = _program.codeSize(m_weights); - Program result = move(_program); + Program result = std::move(_program); result.optimise(m_chromosome.optimisationSteps()); // Make sure that the program and the chromosome we have chosen are suitable for the test diff --git a/test/yulPhaser/ProgramCache.cpp b/test/yulPhaser/ProgramCache.cpp index 3a84aad679..2dab86fcda 100644 --- a/test/yulPhaser/ProgramCache.cpp +++ b/test/yulPhaser/ProgramCache.cpp @@ -52,7 +52,7 @@ class ProgramCacheFixture Program optimisedProgram(Program _program, string _abbreviatedOptimisationSteps) const { - Program result = move(_program); + Program result = std::move(_program); result.optimise(Chromosome::genesToSteps(_abbreviatedOptimisationSteps)); return result; } diff --git a/test/yulPhaser/TestHelpers.cpp b/test/yulPhaser/TestHelpers.cpp index 1df5c4e54d..50afd70a3e 100644 --- a/test/yulPhaser/TestHelpers.cpp +++ b/test/yulPhaser/TestHelpers.cpp @@ -30,7 +30,7 @@ using namespace solidity::phaser::test; function phaser::test::wholeChromosomeReplacement(Chromosome _newChromosome) { - return [_newChromosome = move(_newChromosome)](Chromosome const&) { return _newChromosome; }; + return [_newChromosome = std::move(_newChromosome)](Chromosome const&) { return _newChromosome; }; } function phaser::test::geneSubstitution(size_t _geneIndex, string _geneValue) diff --git a/tools/yulPhaser/Chromosome.cpp b/tools/yulPhaser/Chromosome.cpp index 687c669da5..6e8d3544e1 100644 --- a/tools/yulPhaser/Chromosome.cpp +++ b/tools/yulPhaser/Chromosome.cpp @@ -43,7 +43,7 @@ Chromosome Chromosome::makeRandom(size_t _length) for (size_t i = 0; i < _length; ++i) steps.push_back(randomOptimisationStep()); - return Chromosome(move(steps)); + return Chromosome(std::move(steps)); } ostream& phaser::operator<<(ostream& _stream, Chromosome const& _chromosome) diff --git a/tools/yulPhaser/GeneticAlgorithms.cpp b/tools/yulPhaser/GeneticAlgorithms.cpp index 907703738a..ff40d222a7 100644 --- a/tools/yulPhaser/GeneticAlgorithms.cpp +++ b/tools/yulPhaser/GeneticAlgorithms.cpp @@ -71,7 +71,7 @@ Population RandomAlgorithm::runNextRound(Population _population) size_t replacementCount = _population.individuals().size() - elitePopulation.individuals().size(); return - move(elitePopulation) + + std::move(elitePopulation) + Population::makeRandom( _population.fitnessMetric(), replacementCount, diff --git a/tools/yulPhaser/Mutations.cpp b/tools/yulPhaser/Mutations.cpp index 69ec7fc499..873fbbb9ba 100644 --- a/tools/yulPhaser/Mutations.cpp +++ b/tools/yulPhaser/Mutations.cpp @@ -44,7 +44,7 @@ function phaser::geneRandomisation(double _chance) gene ); - return Chromosome(move(genes)); + return Chromosome(std::move(genes)); }; } @@ -57,7 +57,7 @@ function phaser::geneDeletion(double _chance) if (!SimulationRNG::bernoulliTrial(_chance)) genes.push_back(gene); - return Chromosome(move(genes)); + return Chromosome(std::move(genes)); }; } @@ -77,7 +77,7 @@ function phaser::geneAddition(double _chance) genes.push_back(Chromosome::randomGene()); } - return Chromosome(move(genes)); + return Chromosome(std::move(genes)); }; } @@ -102,7 +102,7 @@ function phaser::mutationSequence(vector> _mutation { Chromosome mutatedChromosome = _chromosome; for (size_t i = 0; i < _mutations.size(); ++i) - mutatedChromosome = _mutations[i](move(mutatedChromosome)); + mutatedChromosome = _mutations[i](std::move(mutatedChromosome)); return mutatedChromosome; }; diff --git a/tools/yulPhaser/PairSelections.h b/tools/yulPhaser/PairSelections.h index 2bdc62a242..12532c76ab 100644 --- a/tools/yulPhaser/PairSelections.h +++ b/tools/yulPhaser/PairSelections.h @@ -107,7 +107,7 @@ class PairMosaicSelection: public PairSelection { public: explicit PairMosaicSelection(std::vector> _pattern, double _selectionSize = 1.0): - m_pattern(move(_pattern)), + m_pattern(std::move(_pattern)), m_selectionSize(_selectionSize) { assert(m_pattern.size() > 0 || _selectionSize == 0.0); diff --git a/tools/yulPhaser/Phaser.cpp b/tools/yulPhaser/Phaser.cpp index 213e6f15b9..db5ec35ced 100644 --- a/tools/yulPhaser/Phaser.cpp +++ b/tools/yulPhaser/Phaser.cpp @@ -239,8 +239,8 @@ unique_ptr FitnessMetricFactory::build( { for (size_t i = 0; i < _programs.size(); ++i) metrics.push_back(make_unique( - _programCaches[i] != nullptr ? optional{} : move(_programs[i]), - move(_programCaches[i]), + _programCaches[i] != nullptr ? optional{} : std::move(_programs[i]), + std::move(_programCaches[i]), _weights, _options.chromosomeRepetitions )); @@ -251,8 +251,8 @@ unique_ptr FitnessMetricFactory::build( { for (size_t i = 0; i < _programs.size(); ++i) metrics.push_back(make_unique( - _programCaches[i] != nullptr ? optional{} : move(_programs[i]), - move(_programCaches[i]), + _programCaches[i] != nullptr ? optional{} : std::move(_programs[i]), + std::move(_programCaches[i]), _options.relativeMetricScale, _weights, _options.chromosomeRepetitions @@ -266,13 +266,13 @@ unique_ptr FitnessMetricFactory::build( switch (_options.metricAggregator) { case MetricAggregatorChoice::Average: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); case MetricAggregatorChoice::Sum: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); case MetricAggregatorChoice::Maximum: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); case MetricAggregatorChoice::Minimum: - return make_unique(move(metrics)); + return make_unique(std::move(metrics)); default: assertThrow(false, solidity::util::Exception, "Invalid MetricAggregatorChoice value."); } @@ -309,7 +309,7 @@ Population PopulationFactory::build( for (size_t populationSize: _options.randomPopulation) combinedSize += populationSize; - population = move(population) + buildRandom( + population = std::move(population) + buildRandom( combinedSize, _options.minChromosomeLength, _options.maxChromosomeLength, @@ -317,7 +317,7 @@ Population PopulationFactory::build( ); for (string const& populationFilePath: _options.populationFromFile) - population = move(population) + buildFromFile(populationFilePath, _fitnessMetric); + population = std::move(population) + buildFromFile(populationFilePath, _fitnessMetric); return population; } @@ -331,7 +331,7 @@ Population PopulationFactory::buildFromStrings( for (string const& geneSequence: _geneSequences) chromosomes.emplace_back(geneSequence); - return Population(move(_fitnessMetric), move(chromosomes)); + return Population(std::move(_fitnessMetric), std::move(chromosomes)); } Population PopulationFactory::buildRandom( @@ -342,7 +342,7 @@ Population PopulationFactory::buildRandom( ) { return Population::makeRandom( - move(_fitnessMetric), + std::move(_fitnessMetric), _populationSize, _minChromosomeLength, _maxChromosomeLength @@ -354,7 +354,7 @@ Population PopulationFactory::buildFromFile( shared_ptr _fitnessMetric ) { - return buildFromStrings(readLinesFromFile(_filePath), move(_fitnessMetric)); + return buildFromStrings(readLinesFromFile(_filePath), std::move(_fitnessMetric)); } ProgramCacheFactory::Options ProgramCacheFactory::Options::fromCommandLine(po::variables_map const& _arguments) @@ -371,7 +371,7 @@ vector> ProgramCacheFactory::build( { vector> programCaches; for (Program& program: _programs) - programCaches.push_back(_options.programCacheEnabled ? make_shared(move(program)) : nullptr); + programCaches.push_back(_options.programCacheEnabled ? make_shared(std::move(program)) : nullptr); return programCaches; } @@ -400,7 +400,7 @@ vector ProgramFactory::build(Options const& _options) } get(programOrErrors).optimise(Chromosome(_options.prefix).optimisationSteps()); - inputPrograms.push_back(move(get(programOrErrors))); + inputPrograms.push_back(std::move(get(programOrErrors))); } return inputPrograms; @@ -823,12 +823,12 @@ void Phaser::runPhaser(po::variables_map const& _arguments) programCaches, codeWeights ); - Population population = PopulationFactory::build(populationOptions, move(fitnessMetric)); + Population population = PopulationFactory::build(populationOptions, std::move(fitnessMetric)); if (_arguments["mode"].as() == PhaserMode::RunAlgorithm) - runAlgorithm(_arguments, move(population), move(programCaches)); + runAlgorithm(_arguments, std::move(population), std::move(programCaches)); else - printOptimisedProgramsOrASTs(_arguments, population, move(programs), _arguments["mode"].as()); + printOptimisedProgramsOrASTs(_arguments, population, std::move(programs), _arguments["mode"].as()); } void Phaser::runAlgorithm( @@ -844,7 +844,7 @@ void Phaser::runAlgorithm( _population.individuals().size() ); - AlgorithmRunner algorithmRunner(move(_population), move(_programCaches), buildAlgorithmRunnerOptions(_arguments), cout); + AlgorithmRunner algorithmRunner(std::move(_population), std::move(_programCaches), buildAlgorithmRunnerOptions(_arguments), cout); algorithmRunner.run(*geneticAlgorithm); } diff --git a/tools/yulPhaser/Population.cpp b/tools/yulPhaser/Population.cpp index 1dba2e2fd3..d4fe1f0bd0 100644 --- a/tools/yulPhaser/Population.cpp +++ b/tools/yulPhaser/Population.cpp @@ -68,7 +68,7 @@ Population Population::makeRandom( for (size_t i = 0; i < _size; ++i) chromosomes.push_back(Chromosome::makeRandom(_chromosomeLengthGenerator())); - return Population(move(_fitnessMetric), move(chromosomes)); + return Population(std::move(_fitnessMetric), std::move(chromosomes)); } Population Population::makeRandom( @@ -79,7 +79,7 @@ Population Population::makeRandom( ) { return makeRandom( - move(_fitnessMetric), + std::move(_fitnessMetric), _size, std::bind(uniformChromosomeLength, _minChromosomeLength, _maxChromosomeLength) ); @@ -112,7 +112,7 @@ Population Population::crossover(PairSelection const& _selection, function Population::symmetricCrossoverWithRemainder( m_individuals[i].chromosome, m_individuals[j].chromosome ); - crossedIndividuals.emplace_back(move(get<0>(children)), *m_fitnessMetric); - crossedIndividuals.emplace_back(move(get<1>(children)), *m_fitnessMetric); + crossedIndividuals.emplace_back(std::move(get<0>(children)), *m_fitnessMetric); + crossedIndividuals.emplace_back(std::move(get<1>(children)), *m_fitnessMetric); indexSelected[i] = true; indexSelected[j] = true; } @@ -159,7 +159,7 @@ Population operator+(Population _a, Population _b) assert(_a.m_fitnessMetric == _b.m_fitnessMetric); using ::operator+; // Import the std::vector concat operator from CommonData.h - return Population(_a.m_fitnessMetric, move(_a.m_individuals) + move(_b.m_individuals)); + return Population(_a.m_fitnessMetric, std::move(_a.m_individuals) + std::move(_b.m_individuals)); } } @@ -193,7 +193,7 @@ vector Population::chromosomesToIndividuals( { vector individuals; for (auto& chromosome: _chromosomes) - individuals.emplace_back(move(chromosome), _fitnessMetric); + individuals.emplace_back(std::move(chromosome), _fitnessMetric); return individuals; } diff --git a/tools/yulPhaser/Program.cpp b/tools/yulPhaser/Program.cpp index 5c61701d83..c62b8e1303 100644 --- a/tools/yulPhaser/Program.cpp +++ b/tools/yulPhaser/Program.cpp @@ -102,7 +102,7 @@ variant Program::load(CharStream& _sourceCode) void Program::optimise(vector const& _optimisationSteps) { - m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, move(m_ast), _optimisationSteps); + m_ast = applyOptimisationSteps(m_dialect, m_nameDispenser, std::move(m_ast), _optimisationSteps); } ostream& phaser::operator<<(ostream& _stream, Program const& _program) @@ -153,7 +153,7 @@ variant, ErrorList> Program::parseObject(Dialect const& _diale // to refactor ObjectParser and Object to use unique_ptr instead). auto astCopy = make_unique(get(ASTCopier{}(*selectedObject->code))); - return variant, ErrorList>(move(astCopy)); + return variant, ErrorList>(std::move(astCopy)); } variant, ErrorList> Program::analyzeAST(Dialect const& _dialect, Block const& _ast) @@ -168,7 +168,7 @@ variant, ErrorList> Program::analyzeAST(Dialect cons return errors; assert(errorReporter.errors().empty()); - return variant, ErrorList>(move(analysisInfo)); + return variant, ErrorList>(std::move(analysisInfo)); } unique_ptr Program::disambiguateAST( diff --git a/tools/yulPhaser/Selections.h b/tools/yulPhaser/Selections.h index 88264e25a9..bd51cfe78e 100644 --- a/tools/yulPhaser/Selections.h +++ b/tools/yulPhaser/Selections.h @@ -86,7 +86,7 @@ class MosaicSelection: public Selection { public: explicit MosaicSelection(std::vector _pattern, double _selectionSize = 1.0): - m_pattern(move(_pattern)), + m_pattern(std::move(_pattern)), m_selectionSize(_selectionSize) { assert(m_pattern.size() > 0 || _selectionSize == 0.0); From 16c0838f75b9e2f31bae1dd9d4ea3238f44060a3 Mon Sep 17 00:00:00 2001 From: Leo Alt Date: Fri, 26 Aug 2022 14:33:59 +0200 Subject: [PATCH 076/109] Update docker images and tests --- .circleci/config.yml | 16 ++++++------ .circleci/osx_install_dependencies.sh | 4 +-- CMakeLists.txt | 2 +- scripts/build_emscripten.sh | 4 +-- .../abi/abi_encode_packed_hash.sol | 5 ++-- .../abi/abi_encode_with_selector_hash.sol | 9 +++---- .../abi/abi_encode_with_selector_vs_sig.sol | 1 + .../abi/abi_encode_with_sig_hash.sol | 4 +-- .../abi/abi_encode_with_sig_simple.sol | 2 +- .../push_as_lhs_and_rhs_bytes.sol | 3 ++- .../external_calls/call_with_value_1.sol | 2 +- .../external_calls/call_with_value_2.sol | 2 +- .../external_call_from_constructor_3.sol | 3 ++- .../external_call_this_with_value_1.sol | 2 +- .../external_call_with_value_3.sol | 4 +-- ...nal_hash_known_code_state_reentrancy_2.sol | 4 +-- ...h_known_code_state_reentrancy_indirect.sol | 4 ++- .../external_calls/external_reentrancy_1.sol | 1 + .../external_calls/external_reentrancy_2.sol | 4 +-- .../function_selector/homer.sol | 2 +- .../functions_storage_var_1_fail.sol | 1 + .../imports/import_as_module_2.sol | 8 ++++-- .../inheritance/receive_fallback.sol | 2 +- .../modifier_inside_branch_assignment.sol | 4 ++- .../compound_assignment_division_3.sol | 2 +- .../compound_bitwise_string_literal_3.sol | 3 +-- .../smtCheckerTests/out_of_bounds/array_1.sol | 3 ++- .../overflow/signed_guard_sub_overflow.sol | 2 +- .../overflow/simple_overflow.sol | 2 +- .../special/block_vars_chc_internal.sol | 3 ++- .../special/tx_vars_reentrancy_1.sol | 2 +- .../try_catch/try_public_var_mapping.sol | 2 +- .../typecast/bytes_to_fixed_bytes_1.sol | 8 ------ .../typecast/bytes_to_fixed_bytes_1_fail.sol | 25 +++++++++++++++++++ .../typecast/string_to_bytes_push_1.sol | 2 +- .../smtCheckerTests/types/array_branch_1d.sol | 4 ++- 36 files changed, 86 insertions(+), 65 deletions(-) create mode 100644 test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1_fail.sol diff --git a/.circleci/config.yml b/.circleci/config.yml index af193b50fe..f040085b28 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,20 +9,20 @@ version: 2.1 parameters: ubuntu-2004-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-13 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:aa64242ecba4f040a839eadfaf20e8489cf93d1cb96ab90df2b240cdbbfe7f7c" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004-14 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:d1ef23849db4c5462b248d89c111da4009b153cbd5002cb8755b0580312be581" ubuntu-2004-clang-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004.clang-13 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:caaf8d42aaf07397d1540e570f096a4fb1ef11fda7da3f1141d8852ec8322a9e" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu2004.clang-14 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:beb8c91998ec0df99a488900b3723a06f1122f0954fc73786b6c53fd73a6408d" ubuntu-1604-clang-ossfuzz-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-18 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:048002d71a1f86f83dedb79dd057760b752256c75646ba5ad5c1bbe92e1695aa" + # solbuildpackpusher/solidity-buildpack-deps:ubuntu1604.clang.ossfuzz-19 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:8c9bf1813c261d781f4c65fceed2dfb3ecf5be9ecf49bddbd250b570a7f3baea" emscripten-docker-image: type: string - # solbuildpackpusher/solidity-buildpack-deps:emscripten-12 - default: "solbuildpackpusher/solidity-buildpack-deps@sha256:65a82268792a5a2ee85ad432baf04a056c3a4006941ab3a4416eb1a0614883f3" + # solbuildpackpusher/solidity-buildpack-deps:emscripten-13 + default: "solbuildpackpusher/solidity-buildpack-deps@sha256:f1c13f3450d1f2e53ea18ac1ac1a17e932573cb9a5ccd0fd9ef6dd44f6402fa9" evm-version: type: string default: london diff --git a/.circleci/osx_install_dependencies.sh b/.circleci/osx_install_dependencies.sh index 37502a7422..766091fdf1 100755 --- a/.circleci/osx_install_dependencies.sh +++ b/.circleci/osx_install_dependencies.sh @@ -61,11 +61,11 @@ then ./scripts/install_obsolete_jsoncpp_1_7_4.sh # z3 - z3_version="4.8.17" + z3_version="4.11.0" z3_dir="z3-${z3_version}-x64-osx-10.16" z3_package="${z3_dir}.zip" wget "https://github.com/Z3Prover/z3/releases/download/z3-${z3_version}/${z3_package}" - validate_checksum "$z3_package" 189667930517aee07f1ce36485d5924a9a2cb4f8c3c9586b03e714a2c657541a + validate_checksum "$z3_package" b6a4a6d587e4bfb0643db81129f0f447692fae13d4bd1bd4d93f1c0301b75ffc unzip "$z3_package" rm "$z3_package" cp "${z3_dir}/bin/libz3.a" /usr/local/lib diff --git a/CMakeLists.txt b/CMakeLists.txt index d8de3d1498..6680b75b28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ configure_file("${CMAKE_SOURCE_DIR}/cmake/templates/license.h.in" include/licens include(EthOptions) configure_project(TESTS) -set(LATEST_Z3_VERSION "4.8.17") +set(LATEST_Z3_VERSION "4.11.0") set(MINIMUM_Z3_VERSION "4.8.0") find_package(Z3) if (${Z3_FOUND}) diff --git a/scripts/build_emscripten.sh b/scripts/build_emscripten.sh index a678d08ab3..43a402fd63 100755 --- a/scripts/build_emscripten.sh +++ b/scripts/build_emscripten.sh @@ -34,7 +34,7 @@ else BUILD_DIR="$1" fi -# solbuildpackpusher/solidity-buildpack-deps:emscripten-12 +# solbuildpackpusher/solidity-buildpack-deps:emscripten-13 docker run -v "$(pwd):/root/project" -w /root/project \ - solbuildpackpusher/solidity-buildpack-deps@sha256:65a82268792a5a2ee85ad432baf04a056c3a4006941ab3a4416eb1a0614883f3 \ + solbuildpackpusher/solidity-buildpack-deps@sha256:f1c13f3450d1f2e53ea18ac1ac1a17e932573cb9a5ccd0fd9ef6dd44f6402fa9 \ ./scripts/ci/build_emscripten.sh "$BUILD_DIR" diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol index a9608a828a..1cde510697 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_packed_hash.sol @@ -11,7 +11,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- -// Warning 1218: (281-319): CHC: Error trying to invoke SMT solver. -// Warning 6328: (281-319): CHC: Assertion violation might happen here. -// Warning 4661: (281-319): BMC: Assertion violation happens here. +// Warning 6328: (281-319): CHC: Assertion violation happens here.\nCounterexample:\n\na = 0\nb = 0\n\nTransaction trace:\nC.constructor()\nC.abiencodePackedHash(0, 0) diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol index f60d5f52bc..ae6ea018f1 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_hash.sol @@ -13,11 +13,8 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreCex: yes // ---- // Warning 2072: (161-176): Unused local variable. -// Warning 1218: (379-417): CHC: Error trying to invoke SMT solver. -// Warning 1218: (436-474): CHC: Error trying to invoke SMT solver. -// Warning 6328: (379-417): CHC: Assertion violation might happen here. -// Warning 6328: (436-474): CHC: Assertion violation might happen here. -// Warning 4661: (379-417): BMC: Assertion violation happens here. -// Warning 4661: (436-474): BMC: Assertion violation happens here. +// Warning 6328: (379-417): CHC: Assertion violation happens here. +// Warning 6328: (436-474): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol index b5346b049b..66ec1c69bc 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_selector_vs_sig.sol @@ -9,5 +9,6 @@ contract C { // ==== // SMTEngine: all // ---- +// Warning 1218: (294-324): CHC: Error trying to invoke SMT solver. // Warning 6328: (294-324): CHC: Assertion violation might happen here. // Warning 7812: (294-324): BMC: Assertion violation might happen here. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol index 61e755d82d..00836f2288 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_hash.sol @@ -13,7 +13,5 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 1218: (394-432): CHC: Error trying to invoke SMT solver. // Warning 6328: (337-375): CHC: Assertion violation happens here. -// Warning 6328: (394-432): CHC: Assertion violation might happen here. -// Warning 4661: (394-432): BMC: Assertion violation happens here. +// Warning 6328: (394-432): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol index 96f3e48d9c..1fe781974a 100644 --- a/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol +++ b/test/libsolidity/smtCheckerTests/abi/abi_encode_with_sig_simple.sol @@ -25,7 +25,7 @@ contract C { // ---- // Warning 5667: (107-122): Unused function parameter. Remove or comment out the variable name to silence this warning. // Warning 1218: (824-854): CHC: Error trying to invoke SMT solver. -// Warning 6328: (543-573): CHC: Assertion violation happens here. +// Warning 6328: (543-573): CHC: Assertion violation happens here.\nCounterexample:\n\nt = false\nx = 0\ny = 0\nz = 0\nb5 = []\nb6 = []\n\nTransaction trace:\nC.constructor()\nC.abiEncodeSimple(sig, false, 0, 0, 0, a, b) // Warning 6328: (664-694): CHC: Assertion violation happens here. // Warning 6328: (713-743): CHC: Assertion violation happens here. // Warning 6328: (824-854): CHC: Assertion violation might happen here. diff --git a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol index 6126b5b10b..cf86c7c4d5 100644 --- a/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol +++ b/test/libsolidity/smtCheckerTests/array_members/push_as_lhs_and_rhs_bytes.sol @@ -12,5 +12,6 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- -// Warning 6328: (203-244): CHC: Assertion violation happens here. +// Warning 6328: (203-244): CHC: Assertion violation happens here.\nCounterexample:\nb = [0x0, 0x0]\nlength = 2\n\nTransaction trace:\nC.constructor()\nState: b = []\nC.f() diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol index f9293f6930..813185adf4 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_1.sol @@ -12,5 +12,5 @@ contract C { // ---- // Warning 9302: (96-117): Return value of low-level calls not used. // Warning 6328: (121-156): CHC: Assertion violation might happen here. -// Warning 6328: (175-211): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0x0\n\nTransaction trace:\nC.constructor()\nC.g(0x0)\n i.call{value: 10}("") -- untrusted external call +// Warning 6328: (175-211): CHC: Assertion violation happens here. // Warning 4661: (121-156): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol index c386580800..968095bb2b 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/call_with_value_2.sol @@ -11,5 +11,5 @@ contract C { // ---- // Warning 9302: (96-116): Return value of low-level calls not used. // Warning 6328: (120-156): CHC: Assertion violation might happen here. -// Warning 6328: (175-210): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0x0\n\nTransaction trace:\nC.constructor()\nC.g(0x0)\n i.call{value: 0}("") -- untrusted external call +// Warning 6328: (175-210): CHC: Assertion violation happens here. // Warning 4661: (120-156): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol index 9d27d6d3b4..ba0dc90b07 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_from_constructor_3.sol @@ -18,6 +18,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (69-85): CHC: Assertion violation happens here.\nCounterexample:\n\n_x = 100\n = 0\n\nTransaction trace:\nState.constructor()\nState.f(100) -// Warning 6328: (203-217): CHC: Assertion violation happens here.\nCounterexample:\ns = 0, z = 0\n\nTransaction trace:\nC.constructor()\nState: s = 0, z = 0\nC.f() +// Warning 6328: (203-217): CHC: Assertion violation happens here.\nCounterexample:\ns = 0, z = 3\n\nTransaction trace:\nC.constructor()\nState: s = 0, z = 3\nC.f() diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol index c52e0773fb..06390b12ca 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_this_with_value_1.sol @@ -11,4 +11,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (157-192): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.g()\n C.h() -- trusted external call +// Warning 6328: (157-192): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol b/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol index fa7ef4462b..2a535329ac 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_call_with_value_3.sol @@ -14,8 +14,6 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 1218: (202-236): CHC: Error trying to invoke SMT solver. // Warning 6328: (150-183): CHC: Assertion violation might happen here. -// Warning 6328: (202-236): CHC: Assertion violation might happen here. +// Warning 6328: (202-236): CHC: Assertion violation happens here.\nCounterexample:\n\ni = 0\n\nTransaction trace:\nC.constructor()\nC.g(0)\n i.f{value: 20}() -- untrusted external call // Warning 4661: (150-183): BMC: Assertion violation happens here. -// Warning 4661: (202-236): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol index 37509269b6..be9f698e15 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_2.sol @@ -42,6 +42,4 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 2018: (33-88): Function state mutability can be restricted to view -// Warning 1218: (367-381): CHC: Error trying to invoke SMT solver. -// Warning 6328: (367-381): CHC: Assertion violation might happen here. -// Warning 4661: (367-381): BMC: Assertion violation happens here. +// Warning 6328: (367-381): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol index bd779b56a5..ea9764e17b 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_hash_known_code_state_reentrancy_indirect.sol @@ -44,5 +44,7 @@ contract C { // SMTIgnoreCex: yes // SMTIgnoreOS: macos // ---- +// Warning 1218: (437-463): CHC: Error trying to invoke SMT solver. // Warning 6328: (419-433): CHC: Assertion violation happens here. -// Warning 6328: (437-463): CHC: Assertion violation happens here. +// Warning 6328: (437-463): CHC: Assertion violation might happen here. +// Warning 4661: (437-463): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol index 5683a5248b..9cf0d3643f 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_1.sol @@ -15,6 +15,7 @@ contract C { } // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 1218: (206-220): CHC: Error trying to invoke SMT solver. // Warning 6328: (206-220): CHC: Assertion violation might happen here. diff --git a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol index 1e8ce8816a..19ff2bbad8 100644 --- a/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol +++ b/test/libsolidity/smtCheckerTests/external_calls/external_reentrancy_2.sol @@ -13,6 +13,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 1218: (117-131): CHC: Error trying to invoke SMT solver. -// Warning 6328: (117-131): CHC: Assertion violation might happen here. -// Warning 4661: (117-131): BMC: Assertion violation happens here. +// Warning 6328: (117-131): CHC: Assertion violation happens here.\nCounterexample:\nlocked = false\ntarget = 0x0\n\nTransaction trace:\nC.constructor()\nState: locked = true\nC.call(0x0)\n D(target).e() -- untrusted external call, synthesized as:\n C.call(0x0) -- reentrant call diff --git a/test/libsolidity/smtCheckerTests/function_selector/homer.sol b/test/libsolidity/smtCheckerTests/function_selector/homer.sol index 552a4d895c..aaab884880 100644 --- a/test/libsolidity/smtCheckerTests/function_selector/homer.sol +++ b/test/libsolidity/smtCheckerTests/function_selector/homer.sol @@ -43,4 +43,4 @@ contract Homer is ERC165, Simpson { // ==== // SMTEngine: all // ---- -// Warning 6328: (1340-1395): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nHomer.constructor()\nHomer.check()\n Homer.supportsInterface(0x73b6b492) -- internal call\n Homer.supportsInterface(0x01ffc9a7) -- internal call\n Homer.supportsInterface(0x8b9eb9ca) -- internal call +// Warning 6328: (1340-1395): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nHomer.constructor()\nHomer.supportsInterface(0x01ffc9a7)\nHomer.check()\n Homer.supportsInterface(0x73b6b492) -- internal call\n Homer.supportsInterface(0x01ffc9a7) -- internal call\n Homer.supportsInterface(0x8b9eb9ca) -- internal call diff --git a/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol b/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol index a7f0c879f8..e775c97a9a 100644 --- a/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol +++ b/test/libsolidity/smtCheckerTests/functions/functions_storage_var_1_fail.sol @@ -13,5 +13,6 @@ contract C // ==== // SMTEngine: all +// SMTIgnoreOS: macos // ---- // Warning 6328: (112-125): CHC: Assertion violation happens here.\nCounterexample:\na = 0\n\nTransaction trace:\nC.constructor()\nState: a = 0\nC.g()\n C.f(0) -- internal call diff --git a/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol b/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol index 8ddef2da9e..bdf2e349c4 100644 --- a/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol +++ b/test/libsolidity/smtCheckerTests/imports/import_as_module_2.sol @@ -18,5 +18,9 @@ function f(uint _x) pure { // ==== // SMTEngine: all // ---- -// Warning 6328: (A:50-64): CHC: Assertion violation happens here.\nCounterexample:\n\n_y = 0\n\nTransaction trace:\nD.constructor()\nD.g(0)\n s1.sol:f(200) -- internal call\n s1.sol:f(0) -- internal call\n A:f(10) -- internal call\n A:f(0) -- internal call -// Warning 6328: (s1.sol:28-44): CHC: Assertion violation happens here.\nCounterexample:\n\n_y = 0\n\nTransaction trace:\nD.constructor()\nD.g(0)\n s1.sol:f(200) -- internal call\n s1.sol:f(0) -- internal call +// Warning 1218: (A:50-64): CHC: Error trying to invoke SMT solver. +// Warning 1218: (s1.sol:28-44): CHC: Error trying to invoke SMT solver. +// Warning 6328: (A:50-64): CHC: Assertion violation might happen here. +// Warning 6328: (s1.sol:28-44): CHC: Assertion violation might happen here. +// Warning 4661: (s1.sol:28-44): BMC: Assertion violation happens here. +// Warning 4661: (A:50-64): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol b/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol index 95ae120198..3d4c5e06aa 100644 --- a/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol +++ b/test/libsolidity/smtCheckerTests/inheritance/receive_fallback.sol @@ -21,6 +21,6 @@ contract B is A { // ==== // SMTEngine: all // ---- -// Warning 6328: (87-101): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\nTransaction trace:\nA.constructor()\nState: x = 0\nA.receive(){ msg.value: 2 } +// Warning 6328: (87-101): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\nTransaction trace:\nA.constructor()\nState: x = 0\nA.receive(){ msg.value: 1 } // Warning 6328: (136-150): CHC: Assertion violation happens here.\nCounterexample:\nx = 0\n\nTransaction trace:\nA.constructor()\nState: x = 0\nA.g() // Warning 6328: (255-269): CHC: Assertion violation happens here.\nCounterexample:\ny = 0, x = 0\n\nTransaction trace:\nB.constructor()\nState: y = 0, x = 0\nB.fallback() diff --git a/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol b/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol index f8091f9dff..d496baf6c1 100644 --- a/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol +++ b/test/libsolidity/smtCheckerTests/modifiers/modifier_inside_branch_assignment.sol @@ -20,4 +20,6 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (254-267): CHC: Assertion violation happens here.\nCounterexample:\nx = 0, owner = 0x0\ny = 1\n\nTransaction trace:\nC.constructor()\nState: x = 0, owner = 0x0\nC.g(1)\n C.f() -- internal call +// Warning 1218: (254-267): CHC: Error trying to invoke SMT solver. +// Warning 6328: (254-267): CHC: Assertion violation might happen here. +// Warning 4661: (254-267): BMC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol b/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol index aa90aa2529..3e646ec3da 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_assignment_division_3.sol @@ -12,4 +12,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (162-181): CHC: Assertion violation happens here.\nCounterexample:\n\nx = 2\np = 0\n\nTransaction trace:\nC.constructor()\nC.f(2, 0) +// Warning 6328: (162-181): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol index b2d56cb128..3ac248fb22 100644 --- a/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol +++ b/test/libsolidity/smtCheckerTests/operators/compound_bitwise_string_literal_3.sol @@ -18,5 +18,4 @@ contract C { // SMTEngine: all // ---- // Warning 6328: (229-276): CHC: Assertion violation happens here.\nCounterexample:\n\ny = 0x6062606464666060606260646466606060626064646660606062606464666060\nz = 0x6062606464666060606260646466606060626064646660606062606464666060\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (394-437): CHC: Assertion violation might happen here. -// Warning 4661: (394-437): BMC: Assertion violation happens here. +// Warning 6328: (394-437): CHC: Assertion violation happens here.\nCounterexample:\n\ny = 0x63666566676e616263666566676e616263666566676e616263666566676e6162\nz = 0x63666566676e616263666566676e616263666566676e616263666566676e6162\n\nTransaction trace:\nC.constructor()\nC.f() diff --git a/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol b/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol index c26e64fccb..ee57f069d4 100644 --- a/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol +++ b/test/libsolidity/smtCheckerTests/out_of_bounds/array_1.sol @@ -21,6 +21,7 @@ contract C { // SMTIgnoreOS: macos // ---- // Warning 4984: (112-115): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here. +// Warning 3944: (181-184): CHC: Underflow (resulting value less than 0) might happen here. // Warning 6368: (259-263): CHC: Out of bounds access happens here.\nCounterexample:\na = [0], l = 1\n = 0\n\nTransaction trace:\nC.constructor()\nState: a = [], l = 0\nC.p()\nState: a = [0], l = 1\nC.r() -// Info 1180: Contract invariant(s) for :C:\n((a.length + ((- 1) * l)) <= 0)\n // Warning 2661: (112-115): BMC: Overflow (resulting value larger than 2**256 - 1) happens here. +// Warning 4144: (181-184): BMC: Underflow (resulting value less than 0) happens here. diff --git a/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol index b28b6598c7..95221c912e 100644 --- a/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/signed_guard_sub_overflow.sol @@ -8,4 +8,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 4984: (96-101): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.\nCounterexample:\n\nx = 0\ny = (- 57896044618658097711785492504343953926634992332820282019728792003956564819968)\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(0, (- 57896044618658097711785492504343953926634992332820282019728792003956564819968)) +// Warning 4984: (96-101): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.\nCounterexample:\n\nx = 57896044618658097711785492504343953926634992332820282019728792003956564819967\ny = (- 1)\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(57896044618658097711785492504343953926634992332820282019728792003956564819967, (- 1)) diff --git a/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol b/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol index e8cf49a832..d872cb6694 100644 --- a/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol +++ b/test/libsolidity/smtCheckerTests/overflow/simple_overflow.sol @@ -4,4 +4,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 4984: (80-85): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\na = 1\nb = 115792089237316195423570985008687907853269984665640564039457584007913129639935\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(1, 115792089237316195423570985008687907853269984665640564039457584007913129639935) +// Warning 4984: (80-85): CHC: Overflow (resulting value larger than 2**256 - 1) happens here.\nCounterexample:\n\na = 115792089237316195423570985008687907853269984665640564039457584007913129639935\nb = 1\n = 0\n\nTransaction trace:\nC.constructor()\nC.f(115792089237316195423570985008687907853269984665640564039457584007913129639935, 1) diff --git a/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol b/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol index 6e4f5a6209..ab355dbd25 100644 --- a/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol +++ b/test/libsolidity/smtCheckerTests/special/block_vars_chc_internal.sol @@ -31,5 +31,6 @@ contract C { } // ==== // SMTEngine: chc +// SMTIgnoreOS: macos // ---- -// Warning 6328: (770-799): CHC: Assertion violation happens here.\nCounterexample:\ncoin = 0x1e28, dif = 0, gas = 0, number = 0, timestamp = 0\n\nTransaction trace:\nC.constructor()\nState: coin = 0x0, dif = 0, gas = 0, number = 0, timestamp = 0\nC.f(){ block.coinbase: 0x1e28, block.difficulty: 0, block.gaslimit: 0, block.number: 0, block.timestamp: 0 }\n C.g() -- internal call +// Warning 6328: (770-799): CHC: Assertion violation happens here.\nCounterexample:\ncoin = 0x0, dif = 0, gas = 0, number = 0, timestamp = 0\n\nTransaction trace:\nC.constructor()\nState: coin = 0x0, dif = 0, gas = 0, number = 0, timestamp = 0\nC.f(){ block.coinbase: 0x0, block.difficulty: 0, block.gaslimit: 0, block.number: 0, block.timestamp: 0 }\n C.g() -- internal call diff --git a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol index f1fed73c02..7d9c0ca567 100644 --- a/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol +++ b/test/libsolidity/smtCheckerTests/special/tx_vars_reentrancy_1.sol @@ -13,4 +13,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (135-169): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 9726\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 2070 }\n _i.f() -- untrusted external call, synthesized as:\n C.g(0){ msg.value: 0 } -- reentrant call\n _i.f() -- untrusted external call +// Warning 6328: (135-169): CHC: Assertion violation happens here.\nCounterexample:\n\n_i = 0\nx = 868\n\nTransaction trace:\nC.constructor()\nC.g(0){ msg.value: 500 }\n _i.f() -- untrusted external call, synthesized as:\n C.g(0){ msg.value: 0 } -- reentrant call\n _i.f() -- untrusted external call diff --git a/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol b/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol index 627d06a2d0..43f4b5f03f 100644 --- a/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol +++ b/test/libsolidity/smtCheckerTests/try_catch/try_public_var_mapping.sol @@ -21,4 +21,4 @@ contract C { // SMTEngine: all // SMTIgnoreOS: macos // ---- -// Warning 6328: (280-300): CHC: Assertion violation happens here. +// Warning 6328: (280-300): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nC.f() diff --git a/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol index 91166baa8d..1d00e7fe3b 100644 --- a/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol +++ b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1.sol @@ -3,20 +3,12 @@ contract C { bytes memory b = hex"00010203040506070809000102030405060708090001020304050607080900010203040506070809"; bytes8 c = bytes8(b); assert(c == 0x0001020304050607); // should hold - assert(c == 0x0001020304050608); // should fail bytes16 d = bytes16(b); assert(d == 0x00010203040506070809000102030405); - assert(d == 0x00010203040506070809000102030406); // should fail bytes24 e = bytes24(b); assert(e == 0x000102030405060708090001020304050607080900010203); // should hold - assert(e == 0x000102030405060708090001020304050607080900010204); // should fail bytes32 g = bytes32(b); assert(g == 0x0001020304050607080900010203040506070809000102030405060708090001); // should hold - assert(g == 0x0001020304050607080900010203040506070809000102030405060708090002); // should fail } } // ---- -// Warning 6328: (225-256): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x0\ne = 0x0\ng = 0x0\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (352-399): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x010203040506070809000102030405\ne = 0x0\ng = 0x0\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (526-589): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x010203040506070809000102030405\ne = 0x0102030405060708090001020304050607080900010203\ng = 0x0\n\nTransaction trace:\nC.constructor()\nC.f() -// Warning 6328: (732-811): CHC: Assertion violation happens here.\nCounterexample:\n\nc = 0x01020304050607\nd = 0x010203040506070809000102030405\ne = 0x0102030405060708090001020304050607080900010203\ng = 0x01020304050607080900010203040506070809000102030405060708090001\n\nTransaction trace:\nC.constructor()\nC.f() diff --git a/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1_fail.sol b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1_fail.sol new file mode 100644 index 0000000000..40cd27776e --- /dev/null +++ b/test/libsolidity/smtCheckerTests/typecast/bytes_to_fixed_bytes_1_fail.sol @@ -0,0 +1,25 @@ +contract C { + function f() external pure { + bytes memory b = hex"00010203040506070809000102030405060708090001020304050607080900010203040506070809"; + bytes8 c = bytes8(b); + //assert(c == 0x0001020304050607); // should hold + assert(c == 0x0001020304050608); // should fail + bytes16 d = bytes16(b); + //assert(d == 0x00010203040506070809000102030405); + assert(d == 0x00010203040506070809000102030406); // should fail + bytes24 e = bytes24(b); + //assert(e == 0x000102030405060708090001020304050607080900010203); // should hold + assert(e == 0x000102030405060708090001020304050607080900010204); // should fail + bytes32 g = bytes32(b); + //assert(g == 0x0001020304050607080900010203040506070809000102030405060708090001); // should hold + assert(g == 0x0001020304050607080900010203040506070809000102030405060708090002); // should fail + } +} +// ==== +// SMTEngine: all +// SMTIgnoreCex: yes +// ---- +// Warning 6328: (227-258): CHC: Assertion violation happens here. +// Warning 6328: (356-403): CHC: Assertion violation happens here. +// Warning 6328: (532-595): CHC: Assertion violation happens here. +// Warning 6328: (740-819): CHC: Assertion violation happens here. diff --git a/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol b/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol index 4910c417e8..33546b49c0 100644 --- a/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol +++ b/test/libsolidity/smtCheckerTests/typecast/string_to_bytes_push_1.sol @@ -11,4 +11,4 @@ contract C { // ==== // SMTEngine: all // ---- -// Warning 6328: (132-160): CHC: Assertion violation happens here.\nCounterexample:\nx = [0x61, 0x62, 0x63, 0x61]\n\nTransaction trace:\nC.constructor()\nState: x = []\nC.s() +// Warning 6328: (132-160): CHC: Assertion violation happens here.\nCounterexample:\n\n\nTransaction trace:\nC.constructor()\nState: x = []\nC.s() diff --git a/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol b/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol index b04c632e91..b6f19302b8 100644 --- a/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol +++ b/test/libsolidity/smtCheckerTests/types/array_branch_1d.sol @@ -12,4 +12,6 @@ contract C // SMTEngine: all // SMTIgnoreCex: yes // ---- -// Warning 6328: (143-159): CHC: Assertion violation happens here. +// Warning 1218: (143-159): CHC: Error trying to invoke SMT solver. +// Warning 6328: (143-159): CHC: Assertion violation might happen here. +// Warning 4661: (143-159): BMC: Assertion violation happens here. From 22e4e2cdc9770d836e57ee28cfc2a55072e51788 Mon Sep 17 00:00:00 2001 From: Leo Alt Date: Tue, 30 Aug 2022 11:02:14 +0200 Subject: [PATCH 077/109] disable SMT tests for the clang job --- .circleci/config.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f040085b28..f016a48c5e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1087,6 +1087,9 @@ jobs: environment: EVM: << pipeline.parameters.evm-version >> OPTIMIZE: 0 + # The high parallelism in this job is causing the SMT tests to run out of memory, + # so disabling for now. + SOLTEST_FLAGS: --no-smt <<: *steps_soltest t_ubu_release_soltest_all: &t_ubu_release_soltest_all From e96453d585e30dc04e1d9554c3bfd5af852dc3ca Mon Sep 17 00:00:00 2001 From: NoFaceDev Date: Sat, 23 Jul 2022 18:22:06 +0400 Subject: [PATCH 078/109] Added details on placeholders in function-modifiers Author: NoFaceDev Date: Sat Jul 23 18:22:06 2022 +0400 --- docs/contracts/function-modifiers.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/contracts/function-modifiers.rst b/docs/contracts/function-modifiers.rst index 2445895e41..f231195448 100644 --- a/docs/contracts/function-modifiers.rst +++ b/docs/contracts/function-modifiers.rst @@ -111,6 +111,12 @@ whitespace-separated list and are evaluated in the order presented. Modifiers cannot implicitly access or change the arguments and return values of functions they modify. Their values can only be passed to them explicitly at the point of invocation. +In function modifiers, it is necessary to specify when you want the function to which the modifier is +applied to be run. The placeholder statement (denoted by a single underscore character ``_``) is used to +denote where the body of the function being modified should be inserted. Note that the +placeholder operator is different from using underscores as leading or trailing characters in variable +names, which is a stylistic choice. + Explicit returns from a modifier or function body only leave the current modifier or function body. Return variables are assigned and control flow continues after the ``_`` in the preceding modifier. From cbcd8a724b1cccaad8bcfee3d54180fdd441d79b Mon Sep 17 00:00:00 2001 From: Leo Alt Date: Fri, 26 Aug 2022 12:40:23 +0200 Subject: [PATCH 079/109] Update z3 to 4.11.0 --- scripts/docker/buildpack-deps/Dockerfile.emscripten | 4 ++-- .../docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz | 4 ++-- scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 | 2 +- scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/docker/buildpack-deps/Dockerfile.emscripten b/scripts/docker/buildpack-deps/Dockerfile.emscripten index 237405c4c6..ba36541e55 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.emscripten +++ b/scripts/docker/buildpack-deps/Dockerfile.emscripten @@ -33,7 +33,7 @@ # Using $(em-config CACHE)/sysroot/usr seems to work, though, and still has cmake find the # dependencies automatically. FROM emscripten/emsdk:3.1.19 AS base -LABEL version="12" +LABEL version="13" ADD emscripten.jam /usr/src RUN set -ex && \ @@ -42,7 +42,7 @@ RUN set -ex && \ apt-get install lz4 --no-install-recommends && \ \ cd /usr/src && \ - git clone https://github.com/Z3Prover/z3.git -b z3-4.8.17 --depth 1 && \ + git clone https://github.com/Z3Prover/z3.git -b z3-4.11.0 --depth 1 && \ cd z3 && \ mkdir build && \ cd build && \ diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz index 2fe04622bf..d5481604a7 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu1604.clang.ossfuzz @@ -22,7 +22,7 @@ # (c) 2016-2021 solidity contributors. #------------------------------------------------------------------------------ FROM gcr.io/oss-fuzz-base/base-clang:latest as base -LABEL version="18" +LABEL version="19" ARG DEBIAN_FRONTEND=noninteractive @@ -61,7 +61,7 @@ RUN set -ex; \ # Z3 RUN set -ex; \ - git clone --depth 1 -b z3-4.8.17 https://github.com/Z3Prover/z3.git \ + git clone --depth 1 -b z3-4.11.0 https://github.com/Z3Prover/z3.git \ /usr/src/z3; \ cd /usr/src/z3; \ mkdir build; \ diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 index 2f3304c1ee..6cac5cc867 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004 @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base -LABEL version="13" +LABEL version="14" ARG DEBIAN_FRONTEND=noninteractive diff --git a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang index 0a11680b88..dc5acbcdc8 100644 --- a/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang +++ b/scripts/docker/buildpack-deps/Dockerfile.ubuntu2004.clang @@ -22,7 +22,7 @@ # (c) 2016-2019 solidity contributors. #------------------------------------------------------------------------------ FROM buildpack-deps:focal AS base -LABEL version="13" +LABEL version="14" ARG DEBIAN_FRONTEND=noninteractive @@ -38,7 +38,7 @@ RUN set -ex; \ libboost-filesystem-dev libboost-test-dev libboost-system-dev \ libboost-program-options-dev \ clang \ - libz3-static-dev jq \ + libz3-static-dev z3-static jq \ ; \ rm -rf /var/lib/apt/lists/* From 79adec08f25e501226ea31a67711565f5140c390 Mon Sep 17 00:00:00 2001 From: Taylor Ferran Date: Sat, 13 Aug 2022 13:25:27 +0100 Subject: [PATCH 080/109] Add detail about limitation in voting contract example --- docs/examples/voting.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/examples/voting.rst b/docs/examples/voting.rst index ad1c2d30d4..de899da7ab 100644 --- a/docs/examples/voting.rst +++ b/docs/examples/voting.rst @@ -193,5 +193,8 @@ of votes. Possible Improvements ===================== -Currently, many transactions are needed to assign the rights -to vote to all participants. Can you think of a better way? +Currently, many transactions are needed to +assign the rights to vote to all participants. +Moreover, if two or more proposals have the same +number of votes, ``winningProposal()`` is not able +to register a tie. Can you think of a way to fix these issues? \ No newline at end of file From b676944c3ffd07fb5d1c4eccc6f8ac96cbadb9b7 Mon Sep 17 00:00:00 2001 From: Luke Hutchison Date: Sat, 25 Jun 2022 17:49:28 -0600 Subject: [PATCH 081/109] Update security-considerations.rst Explained Checks-Effects-Interactions and added info on Checks-Effects-Events-Interactions --- docs/security-considerations.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index ceadfd0bc0..6507f7c1c2 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -98,7 +98,7 @@ as it uses ``call`` which forwards all remaining gas by default: } To avoid re-entrancy, you can use the Checks-Effects-Interactions pattern as -outlined further below: +demonstrated below: .. code-block:: solidity @@ -116,6 +116,13 @@ outlined further below: } } +The Checks-Effects-Interactions pattern ensures that all code paths through a contract complete all required checks +of the supplied parameters before modifying the contract's state (Checks); only then it makes any changes to the state (Effects); +it may make calls to functions in other contracts *after* all planned state changes have been written to +storage (Interactions). This is a common foolproof way to prevent *re-entrancy attacks*, where an externally called +malicious contract is able to double-spend an allowance, double-withdraw a balance, among other things, by using logic that calls back into the +original contract before it has finalized its transaction. + Note that re-entrancy is not only an effect of Ether transfer but of any function call on another contract. Furthermore, you also have to take multi-contract situations into account. A called contract could modify the From 6e1f0e73b60ca7309e309560dc37694fb2ee3641 Mon Sep 17 00:00:00 2001 From: Leonid Pospelov Date: Wed, 31 Aug 2022 01:50:30 +0300 Subject: [PATCH 082/109] Set CMP0115 to new in EthPolicy --- cmake/EthPolicy.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/EthPolicy.cmake b/cmake/EthPolicy.cmake index f571a09cee..adde3b742f 100644 --- a/cmake/EthPolicy.cmake +++ b/cmake/EthPolicy.cmake @@ -25,4 +25,10 @@ macro (eth_policy) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0") cmake_policy(SET CMP0135 NEW) endif() + + if(POLICY CMP0115) + # speedup of cmake command on Windows + # https://gitlab.kitware.com/cmake/cmake/-/issues/23154 + cmake_policy(SET CMP0115 NEW) + endif() endmacro() From 6d331a8c8aa8db234ef7bb9d89a8cfa86452f00a Mon Sep 17 00:00:00 2001 From: Leonid Pospelov Date: Wed, 31 Aug 2022 12:12:15 +0300 Subject: [PATCH 083/109] Improve comment on CMP0115 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil Śliwak --- cmake/EthPolicy.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/EthPolicy.cmake b/cmake/EthPolicy.cmake index adde3b742f..eb5c37e246 100644 --- a/cmake/EthPolicy.cmake +++ b/cmake/EthPolicy.cmake @@ -27,7 +27,8 @@ macro (eth_policy) endif() if(POLICY CMP0115) - # speedup of cmake command on Windows + # Require explicit extensions for source files, do not guess. + # The extra calls to GetFileAttributesW significantly slow down cmake on Windows. # https://gitlab.kitware.com/cmake/cmake/-/issues/23154 cmake_policy(SET CMP0115 NEW) endif() From 66994b68d797d7802e7d3bcb5dfa3cf73a38e8f0 Mon Sep 17 00:00:00 2001 From: xternet Date: Wed, 31 Aug 2022 15:01:46 +0200 Subject: [PATCH 084/109] README.md: added comma --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f00465323..9637503b0e 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ network where nobody has special authority over the execution, and thus they all ownership, voting, and other kinds of logic. When deploying contracts, you should use the latest released version of -Solidity. This is because breaking changes, as well as new features and bug fixes are +Solidity. This is because breaking changes, as well as new features and bug fixes, are introduced regularly. We currently use a 0.x version number [to indicate this fast pace of change](https://semver.org/#spec-item-4). From e5769d784e9dec348835ec1a83f42dd6cce97b3f Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Mon, 5 Sep 2022 12:11:26 +0200 Subject: [PATCH 085/109] Fix compiler version check in hardhat artifacts json --- test/externalTests/common.sh | 4 ++-- test/externalTests/zeppelin.sh | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/externalTests/common.sh b/test/externalTests/common.sh index c510ebc92f..d8f7e80b8e 100644 --- a/test/externalTests/common.sh +++ b/test/externalTests/common.sh @@ -357,8 +357,8 @@ function hardhat_verify_compiler_version local build_info_files build_info_files=$(find . -path '*artifacts/build-info/*.json') for build_info_file in $build_info_files; do - grep '"solcVersion": "'"${solc_version}"'"' --with-filename "$build_info_file" || fail "Wrong compiler version detected in ${build_info_file}." - grep '"solcLongVersion": "'"${full_solc_version}"'"' --with-filename "$build_info_file" || fail "Wrong compiler version detected in ${build_info_file}." + grep '"solcVersion":[[:blank:]]*"'"${solc_version}"'"' --with-filename "$build_info_file" || fail "Wrong compiler version detected in ${build_info_file}." + grep '"solcLongVersion":[[:blank:]]*"'"${full_solc_version}"'"' --with-filename "$build_info_file" || fail "Wrong compiler version detected in ${build_info_file}." done } diff --git a/test/externalTests/zeppelin.sh b/test/externalTests/zeppelin.sh index 8d73ad1d2e..3cb7a720f1 100755 --- a/test/externalTests/zeppelin.sh +++ b/test/externalTests/zeppelin.sh @@ -108,6 +108,8 @@ function zeppelin_test sed -i "s|it(\('other accounts cannot unpause'\)|it.skip(\1|g" test/token/ERC721/presets/ERC721PresetMinterPauserAutoId.test.js sed -i "s|it(\('prevents initialization'\)|it.skip(\1|g" test/proxy/utils/Initializable.test.js sed -i "s|it(\('divide by 0'\)|it.skip(\1|g" test/utils/math/Math.test.js + sed -i "s|it(\('pending owner resets after renouncing ownership'\)|it.skip(\1|g" test/access/Ownable2Step.test.js + sed -i "s|it(\('guards transfer against invalid user'\)|it.skip(\1|g" test/access/Ownable2Step.test.js # CAUTION:: The following two sed commands depend on the order of occurrence of the relevant patterns in the mentioned files. # Could result in an error in the future. sed -zi "s|it(\('deposit'\)|it.skip(\1|3" test/token/ERC20/extensions/ERC4626.test.js From 1f6a299062381ec3f317d50fa97efd1fbfb3e98e Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Thu, 1 Sep 2022 10:55:29 +0200 Subject: [PATCH 086/109] Add a check for unqualified move --- libyul/backends/evm/EVMDialect.cpp | 2 +- scripts/check_style.sh | 2 ++ solc/CommandLineInterface.cpp | 10 +++++----- solc/CommandLineParser.cpp | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index 0f5c307e32..71b9dba4ce 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -83,7 +83,7 @@ pair createEVMFunction( }; YulString name = f.name; - return {name, move(f)}; + return {name, std::move(f)}; } pair createFunction( diff --git a/scripts/check_style.sh b/scripts/check_style.sh index 601981b5cb..d1ad6bb9e9 100755 --- a/scripts/check_style.sh +++ b/scripts/check_style.sh @@ -54,6 +54,8 @@ FORMATERROR=$( preparedGrep "[a-zA-Z0-9_]\s*[&][a-zA-Z_]" | grep -E -v "return [&]" # right-aligned reference ampersand (needs to exclude return) # right-aligned reference pointer star (needs to exclude return and comments) preparedGrep "[a-zA-Z0-9_]\s*[*][a-zA-Z_]" | grep -E -v -e "return [*]" -e "^* [*]" -e "^*//.*" + # unqualified move check, i.e. make sure that std::move() is used instead of move() + preparedGrep "move\(.+\)" | grep -v "std::move" | grep -E "[^a-z]move" ) | grep -E -v -e "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" -e "^test/" || true ) diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index f841c2b63c..e215405a12 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -498,11 +498,11 @@ void CommandLineInterface::readInputFiles() if (m_options.input.mode == InputMode::StandardJson) { solAssert(!m_standardJsonInput.has_value(), ""); - m_standardJsonInput = move(fileContent); + m_standardJsonInput = std::move(fileContent); } else { - m_fileReader.addOrUpdateFile(infile, move(fileContent)); + m_fileReader.addOrUpdateFile(infile, std::move(fileContent)); m_fileReader.allowDirectory(boost::filesystem::canonical(infile).remove_filename()); } } @@ -546,7 +546,7 @@ map CommandLineInterface::parseAstFromInput() astAssert(ast["sources"][src].isMember(astKey), "astkey is not member"); astAssert(ast["sources"][src][astKey]["nodeType"].asString() == "SourceUnit", "Top-level node should be a 'SourceUnit'"); astAssert(sourceJsons.count(src) == 0, "All sources must have unique names"); - sourceJsons.emplace(src, move(ast["sources"][src][astKey])); + sourceJsons.emplace(src, std::move(ast["sources"][src][astKey])); tmpSources[src] = util::jsonCompactPrint(ast); } } @@ -643,7 +643,7 @@ void CommandLineInterface::processInput() solAssert(m_standardJsonInput.has_value(), ""); StandardCompiler compiler(m_fileReader.reader(), m_options.formatting.json); - sout() << compiler.compile(move(m_standardJsonInput.value())) << endl; + sout() << compiler.compile(std::move(m_standardJsonInput.value())) << endl; m_standardJsonInput.reset(); break; } @@ -977,7 +977,7 @@ void CommandLineInterface::link() while (!src.second.empty() && *prev(src.second.end()) == '\n') src.second.resize(src.second.size() - 1); } - m_fileReader.setSourceUnits(move(sourceCodes)); + m_fileReader.setSourceUnits(std::move(sourceCodes)); } void CommandLineInterface::writeLinkedFiles() diff --git a/solc/CommandLineParser.cpp b/solc/CommandLineParser.cpp index 319f29de60..2c765d0e30 100644 --- a/solc/CommandLineParser.cpp +++ b/solc/CommandLineParser.cpp @@ -309,7 +309,7 @@ void CommandLineParser::parseInputPathsAndRemappings() m_options.input.allowedDirectories.insert(remappingDir.empty() ? "." : remappingDir); } - m_options.input.remappings.emplace_back(move(remapping.value())); + m_options.input.remappings.emplace_back(std::move(remapping.value())); } else if (positionalArg == "-") m_options.input.addStdin = true; @@ -1218,7 +1218,7 @@ void CommandLineParser::processArgs() optional contracts = ModelCheckerContracts::fromString(contractsStr); if (!contracts) solThrow(CommandLineValidationError, "Invalid option for --" + g_strModelCheckerContracts + ": " + contractsStr); - m_options.modelChecker.settings.contracts = move(*contracts); + m_options.modelChecker.settings.contracts = std::move(*contracts); } if (m_args.count(g_strModelCheckerDivModNoSlacks)) From 71a9fb25ed211f0017dc26b71193b8a8e8f8d1bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 15:39:11 +0200 Subject: [PATCH 087/109] ReleaseChecklist: Documentation now gets built automatically from tags --- ReleaseChecklist.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index 6d07ae011c..e5d8cd8fc9 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -3,7 +3,6 @@ ### Requirements - [ ] Lauchpad (Ubuntu One) account - [ ] gnupg key (has to be version 1, gpg2 won't work) for `your-name@ethereum.org` created and uploaded - - [ ] Readthedocs account, access to the Solidity project - [ ] Write access to https://github.com/ethereum/homebrew-ethereum ### Documentation check @@ -50,10 +49,6 @@ - [ ] Run ``scripts/release_ppa.sh v$VERSION`` to create the PPA release (you need the relevant openssl key). - [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. SERIOUSLY: DO NOT PROCEED EARLIER!!! *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA for the destination series ``Trusty``, ``Xenial`` and ``Bionic`` while selecting ``Copy existing binaries``. -### Documentation - - [ ] Build the new version on https://readthedocs.org/projects/solidity/ (select `latest` at the bottom of the page and click `BUILD`). - - [ ] In the admin panel, select `Versions` in the menu and set the default version to the released one. - ### Release solc-js - [ ] Wait until solc-bin was properly deployed. You can test this via remix - a test run through remix is advisable anyway. - [ ] Increment the version number, create a pull request for that, merge it after tests succeeded. @@ -62,6 +57,8 @@ - [ ] Create a tag using ``git tag --annotate v$VERSION`` and push it with ``git push --tags``. ### Post-release + - [ ] Make sure the documentation for the new release has been published successfully. + Go to https://readthedocs.org/projects/solidity/ and verify that the new version is listed, works and is marked as default. - [ ] Publish the blog post. - [ ] Create a commit to increase the version number on ``develop`` in ``CMakeLists.txt`` and add a new skeleton changelog entry. - [ ] Announce on Twitter, including links to the release and the blog post. From dd2f718b996556a5ee76e65b07e8772d2350727f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 16:21:38 +0200 Subject: [PATCH 088/109] ReleaseChecklist: Regenerating the bug list does not require running the whole tests.sh --- ReleaseChecklist.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index e5d8cd8fc9..2bd84b8842 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -14,7 +14,7 @@ ### Changelog - [ ] Sort the changelog entries alphabetically and correct any errors you notice. - [ ] Create a commit on a new branch that updates the ``Changelog`` to include a release date. - - [ ] Run ``./scripts/tests.sh`` to update the bug list. + - [ ] Run ``scripts/update_bugs_by_version.py`` to regenerate ``bugs_by_version.json`` from the changelog and ``bugs.json``. - [ ] Create a pull request and wait for the tests, merge it. ### Create the Release From b9d06b48a2e559b87a5023e43cd9d49f920d4daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 17:46:44 +0200 Subject: [PATCH 089/109] ReleaseChecklist: More detailed steps related to blog posts --- ReleaseChecklist.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index 2bd84b8842..7c78db457d 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -5,17 +5,19 @@ - [ ] gnupg key (has to be version 1, gpg2 won't work) for `your-name@ethereum.org` created and uploaded - [ ] Write access to https://github.com/ethereum/homebrew-ethereum +### Blog Post + - [ ] Create a post on [solidity-blog](https://github.com/ethereum/solidity-blog) in the ``Releases`` category and explain some of the new features or concepts. + - [ ] Create a post on [solidity-blog](https://github.com/ethereum/solidity-blog) in the ``Security Alerts`` category in case of important bug(s). + ### Documentation check - [ ] Run `make linkcheck` from within `docs/` and fix any broken links it finds. Ignore false positives caused by `href` anchors and dummy links not meant to work. -### Blog Post - - [ ] Create a post on https://github.com/ethereum/solidity-blog and explain some of the new features or concepts. - ### Changelog - [ ] Sort the changelog entries alphabetically and correct any errors you notice. - [ ] Create a commit on a new branch that updates the ``Changelog`` to include a release date. - [ ] Run ``scripts/update_bugs_by_version.py`` to regenerate ``bugs_by_version.json`` from the changelog and ``bugs.json``. - [ ] Create a pull request and wait for the tests, merge it. + - [ ] Copy the changelog into the release blog post. ### Create the Release - [ ] Create Github release page: https://github.com/ethereum/solidity/releases/new @@ -59,9 +61,11 @@ ### Post-release - [ ] Make sure the documentation for the new release has been published successfully. Go to https://readthedocs.org/projects/solidity/ and verify that the new version is listed, works and is marked as default. - - [ ] Publish the blog post. + - [ ] Publish the blog posts. - [ ] Create a commit to increase the version number on ``develop`` in ``CMakeLists.txt`` and add a new skeleton changelog entry. - [ ] Announce on Twitter, including links to the release and the blog post. - - [ ] Share announcement on Reddit and Solidity forum. + Use ``#xp`` at the end of the tweet to automatically cross post the announcement to Fosstodon. + - [ ] Share the announcement on Reddit in [``/r/ethdev``](https://reddit.com/r/ethdev/), cross-posted to [``/r/ethereum``](https://reddit.com/r/ethereum/). + - [ ] Share the announcement the [Solidity forum](https://forum.soliditylang.org) in the ``Announcements`` category. - [ ] Update the release information section on [soliditylang.org](https://github.com/ethereum/solidity-portal). - [ ] Lean back, wait for bug reports and repeat from step 1 :) From 3f437da2a40fc1568b07b4003c336fea4a0211d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 18:14:25 +0200 Subject: [PATCH 090/109] ReleaseChecklist: Emphasize separate changelog and version commits --- ReleaseChecklist.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index 7c78db457d..821588f37e 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -13,10 +13,11 @@ - [ ] Run `make linkcheck` from within `docs/` and fix any broken links it finds. Ignore false positives caused by `href` anchors and dummy links not meant to work. ### Changelog - - [ ] Sort the changelog entries alphabetically and correct any errors you notice. - - [ ] Create a commit on a new branch that updates the ``Changelog`` to include a release date. + - [ ] Sort the changelog entries alphabetically and correct any errors you notice. Commit it. + - [ ] Update the changelog to include a release date. - [ ] Run ``scripts/update_bugs_by_version.py`` to regenerate ``bugs_by_version.json`` from the changelog and ``bugs.json``. - - [ ] Create a pull request and wait for the tests, merge it. + Make sure that the resulting ``bugs_by_version.json`` has a new, empty entry for the new version. + - [ ] Commit changes, create a pull request and wait for the tests. Then merge it. - [ ] Copy the changelog into the release blog post. ### Create the Release From 33883059ed1fb2f7915ffad8f2f8c0637f6f4de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 8 Aug 2022 18:17:38 +0200 Subject: [PATCH 091/109] ReleaseChecklist: Add "still in progress" warning and make the release page a single point --- ReleaseChecklist.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index 821588f37e..2a680bd25d 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -21,11 +21,13 @@ - [ ] Copy the changelog into the release blog post. ### Create the Release - - [ ] Create Github release page: https://github.com/ethereum/solidity/releases/new - - [ ] On the release page, select the ``develop`` branch as new target and set tag to the new version (e.g. `v0.8.5`) (make sure you only `SAVE DRAFT` instead of `PUBLISH RELEASE` before the actual release) - - [ ] Thank voluntary contributors in the Github release page (use ``git shortlog -s -n -e v0.5.3..origin/develop``). + - [ ] 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`. + 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. + - [ ] Thank voluntary contributors in the Github release notes (use ``git shortlog -s -n -e v0.5.3..origin/develop``). - [ ] Check that all tests on the latest commit in ``develop`` are green. - - [ ] Click the `PUBLISH RELEASE` button on the release page, creating the tag. + - [ ] Click the `Publish release` button on the release page, creating the tag. - [ ] Wait for the CI runs on the tag itself. ### Upload Release Artifacts and Publish Binaries @@ -62,6 +64,7 @@ ### Post-release - [ ] Make sure the documentation for the new release has been published successfully. Go to https://readthedocs.org/projects/solidity/ and verify that the new version is listed, works and is marked as default. + - [ ] Remove "still in progress" warning from the release notes. - [ ] Publish the blog posts. - [ ] Create a commit to increase the version number on ``develop`` in ``CMakeLists.txt`` and add a new skeleton changelog entry. - [ ] Announce on Twitter, including links to the release and the blog post. From d9f169eb4b346ad1953bcca10f08b6fbe4486258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 9 Aug 2022 10:57:33 +0200 Subject: [PATCH 092/109] ReleaseChecklist: Consistently use double backticks everywhere, fix indents and mismatched parentheses --- ReleaseChecklist.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index 2a680bd25d..3df38321a7 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -2,7 +2,7 @@ ### Requirements - [ ] Lauchpad (Ubuntu One) account - - [ ] gnupg key (has to be version 1, gpg2 won't work) for `your-name@ethereum.org` created and uploaded + - [ ] gnupg key (has to be version 1, gpg2 won't work) for ``your-name@ethereum.org`` created and uploaded - [ ] Write access to https://github.com/ethereum/homebrew-ethereum ### Blog Post @@ -10,7 +10,7 @@ - [ ] Create a post on [solidity-blog](https://github.com/ethereum/solidity-blog) in the ``Security Alerts`` category in case of important bug(s). ### Documentation check - - [ ] Run `make linkcheck` from within `docs/` and fix any broken links it finds. Ignore false positives caused by `href` anchors and dummy links not meant to work. + - [ ] Run ``make linkcheck`` from within ``docs/`` and fix any broken links it finds. Ignore false positives caused by ``href`` anchors and dummy links not meant to work. ### Changelog - [ ] Sort the changelog entries alphabetically and correct any errors you notice. Commit it. @@ -22,12 +22,12 @@ ### Create the Release - [ ] 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.**``. Don't publish it yet - click the ``Save draft`` button instead. - [ ] Thank voluntary contributors in the Github release notes (use ``git shortlog -s -n -e v0.5.3..origin/develop``). - [ ] Check that all tests on the latest commit in ``develop`` are green. - - [ ] Click the `Publish release` button on the release page, creating the tag. + - [ ] Click the ``Publish release`` button on the release page, creating the tag. - [ ] Wait for the CI runs on the tag itself. ### Upload Release Artifacts and Publish Binaries @@ -36,7 +36,7 @@ - [ ] Run ``scripts/create_source_tarball.sh`` while being on the tag to create the source tarball. This will create the tarball in a directory called ``upload``. - [ ] Take the tarball from the upload directory (its name should be ``solidity_x.x.x.tar.gz``, otherwise ``prerelease.txt`` was missing in the step before) and upload the source tarball to the release page. - [ ] Take the ``github-binaries.tar`` tarball from ``c_release_binaries`` run of the tagged commit in circle-ci and add all binaries from it to the release page. - Make sure it contains four binaries: ``solc-windows.exe``, ``solc-macos``, ``solc-static-linux`` and ``soljson.js``. + Make sure it contains four binaries: ``solc-windows.exe``, ``solc-macos``, ``solc-static-linux`` and ``soljson.js``. - [ ] Take the ``solc-bin-binaries.tar`` tarball from ``c_release_binaries`` run of the tagged commit in circle-ci and add all binaries from it to solc-bin. - [ ] Run ``./update --reuse-hashes`` in ``solc-bin`` and verify that the script has updated ``list.js``, ``list.txt`` and ``list.json`` files correctly and that symlinks to the new release have been added in ``solc-bin/wasm/`` and ``solc-bin/emscripten-wasm32/``. - [ ] Create a pull request in solc-bin and merge. @@ -46,13 +46,17 @@ - [ ] Update the version and the hash (``sha256sum solidity_$VERSION.tar.gz``) in https://github.com/ethereum/homebrew-ethereum/blob/master/solidity.rb ### Docker - - [ ] Run ``./scripts/docker_deploy_manual.sh v$VERSION``). + - [ ] Run ``./scripts/docker_deploy_manual.sh v$VERSION``. ### PPA - - [ ] Make sure the ``ethereum/cpp-build-deps`` PPA repository contains libz3-static-dev builds for all current versions of ubuntu. If not run ``scripts/deps-ppa/static-z3.sh`` (after changing email address and key id and adding the missing ubuntu version) and wait for the builds to succeed before continuing. + - [ ] Make sure the ``ethereum/cpp-build-deps`` PPA repository contains ``libz3-static-dev builds`` for all current versions of ubuntu. + If not run ``scripts/deps-ppa/static-z3.sh`` (after changing email address and key id and adding the missing ubuntu version) and wait for the builds to succeed before continuing. - [ ] Change ``scripts/release_ppa.sh`` to match your key's email and key id; double-check that ``DISTRIBUTIONS`` contains the most recent versions. - [ ] Run ``scripts/release_ppa.sh v$VERSION`` to create the PPA release (you need the relevant openssl key). - - [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. SERIOUSLY: DO NOT PROCEED EARLIER!!! *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA for the destination series ``Trusty``, ``Xenial`` and ``Bionic`` while selecting ``Copy existing binaries``. + - [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. + **SERIOUSLY: DO NOT PROCEED EARLIER!!!** + *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA + for the destination series ``Trusty``, ``Xenial`` and ``Bionic`` while selecting ``Copy existing binaries``. ### Release solc-js - [ ] Wait until solc-bin was properly deployed. You can test this via remix - a test run through remix is advisable anyway. From f5c91ec8421c2233133cde0019c8fcb2f3ce94c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 11 Aug 2022 14:42:31 +0200 Subject: [PATCH 093/109] ReleaseChecklist: Don't sort contributor list by number of commits and use long options --- ReleaseChecklist.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index 3df38321a7..e8f94fb05e 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -25,7 +25,7 @@ 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.**``. Don't publish it yet - click the ``Save draft`` button instead. - - [ ] Thank voluntary contributors in the Github release notes (use ``git shortlog -s -n -e v0.5.3..origin/develop``). + - [ ] Thank voluntary contributors in the Github release notes (use ``git shortlog --summary --email v0.5.3..origin/develop``). - [ ] Check that all tests on the latest commit in ``develop`` are green. - [ ] Click the ``Publish release`` button on the release page, creating the tag. - [ ] Wait for the CI runs on the tag itself. From be67e76165990db62b3a20e493225555dc05e80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 11 Aug 2022 14:40:03 +0200 Subject: [PATCH 094/109] ReleaseChecklist: Update the list of requirements --- ReleaseChecklist.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index e8f94fb05e..fa1d0bf34f 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -1,9 +1,15 @@ ## Checklist for making a release: ### Requirements - - [ ] Lauchpad (Ubuntu One) account - - [ ] gnupg key (has to be version 1, gpg2 won't work) for ``your-name@ethereum.org`` created and uploaded - - [ ] Write access to https://github.com/ethereum/homebrew-ethereum + - [ ] Github account with access to [solidity](https://github.com/ethereum/solidity), [solc-js](https://github.com/ethereum/solc-js), + [solc-bin](https://github.com/ethereum/solc-bin), [homebrew-ethereum](https://github.com/ethereum/homebrew-ethereum), + [solidity-blog](https://github.com/ethereum/solidity-blog) and [solidity-portal](https://github.com/ethereum/solidity-portal) repositories. + - [ ] DockerHub account with push rights to the [``solc`` image](https://hub.docker.com/r/ethereum/solc). + - [ ] Lauchpad (Ubuntu One) account with a membership in the ["Ethereum" team](https://launchpad.net/~ethereum) and + a gnupg key for your email in the ``ethereum.org`` domain (has to be version 1, gpg2 won't work). + - [ ] [npm Registry](https://www.npmjs.com) account added as a collaborator for the [``solc`` package](https://www.npmjs.com/package/solc). + - [ ] Access to the [solidity_lang Twitter account](https://twitter.com/solidity_lang). + - [ ] [Reddit](https://www.reddit.com) account that is at least 10 days old with a minimum of 20 comment karma (``/r/ethereum`` requirements). ### Blog Post - [ ] Create a post on [solidity-blog](https://github.com/ethereum/solidity-blog) in the ``Releases`` category and explain some of the new features or concepts. From 98ad27d42ca0f3d0b423b0a1ba898ef7ffda5ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 16 Aug 2022 12:54:10 +0200 Subject: [PATCH 095/109] ReleaseChecklist: Update PPA instructions --- ReleaseChecklist.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index fa1d0bf34f..d5090ed7f0 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -55,13 +55,14 @@ - [ ] Run ``./scripts/docker_deploy_manual.sh v$VERSION``. ### PPA - - [ ] Make sure the ``ethereum/cpp-build-deps`` PPA repository contains ``libz3-static-dev builds`` for all current versions of ubuntu. - If not run ``scripts/deps-ppa/static-z3.sh`` (after changing email address and key id and adding the missing ubuntu version) and wait for the builds to succeed before continuing. - - [ ] Change ``scripts/release_ppa.sh`` to match your key's email and key id; double-check that ``DISTRIBUTIONS`` contains the most recent versions. - - [ ] Run ``scripts/release_ppa.sh v$VERSION`` to create the PPA release (you need the relevant openssl key). - - [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. + - [ ] Create ``.release_ppa_auth`` at the root of your local Solidity checkout and set ``LAUNCHPAD_EMAIL`` and ``LAUNCHPAD_KEYID`` to your key's email and key id. + - [ ] Double-check that the ``DISTRIBUTIONS`` list in ``scripts/release_ppa.sh`` and ``scripts/deps-ppa/static-z3.sh`` contains the most recent versions of Ubuntu. + - [ ] Make sure the [``~ethereum/cpp-build-deps`` PPA repository](https://launchpad.net/~ethereum/+archive/ubuntu/cpp-build-deps) contains ``libz3-static-dev builds`` for all current versions of Ubuntu. + If not, run ``scripts/deps-ppa/static-z3.sh`` (after changing email address and key id) and wait for the builds to succeed before continuing. + - [ ] Run ``scripts/release_ppa.sh v$VERSION`` to create the PPA release. + - [ ] Wait for the [``~ethereum/ethereum-static`` PPA](https://launchpad.net/~ethereum/+archive/ubuntu/ethereum-static) build to be finished and published for *all platforms*. **SERIOUSLY: DO NOT PROCEED EARLIER!!!** - *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA + *After* the static builds are *published*, copy the static package to the [``~ethereum/ethereum`` PPA](https://launchpad.net/~ethereum/+archive/ubuntu/ethereum) for the destination series ``Trusty``, ``Xenial`` and ``Bionic`` while selecting ``Copy existing binaries``. ### Release solc-js From ccc331743cf76f1381730e08de83e22c69ae79e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Mon, 5 Sep 2022 18:19:51 +0200 Subject: [PATCH 096/109] ReleaseChecklist: Markdown formatting for all links --- ReleaseChecklist.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ReleaseChecklist.md b/ReleaseChecklist.md index d5090ed7f0..e1a6a4c1b8 100644 --- a/ReleaseChecklist.md +++ b/ReleaseChecklist.md @@ -48,8 +48,8 @@ - [ ] Create a pull request in solc-bin and merge. ### Homebrew and MacOS - - [ ] Update the version and the hash (``sha256sum solidity_$VERSION.tar.gz``) in https://github.com/Homebrew/homebrew-core/blob/master/Formula/solidity.rb - - [ ] Update the version and the hash (``sha256sum solidity_$VERSION.tar.gz``) in https://github.com/ethereum/homebrew-ethereum/blob/master/solidity.rb + - [ ] Update the version and the hash (``sha256sum solidity_$VERSION.tar.gz``) in the [``solidity`` formula in Homebrew core repository](https://github.com/Homebrew/homebrew-core/blob/master/Formula/solidity.rb). + - [ ] Update the version and the hash (``sha256sum solidity_$VERSION.tar.gz``) in [our custom ``solidity`` Homebrew formula](https://github.com/ethereum/homebrew-ethereum/blob/master/solidity.rb). ### Docker - [ ] Run ``./scripts/docker_deploy_manual.sh v$VERSION``. @@ -74,7 +74,7 @@ ### Post-release - [ ] Make sure the documentation for the new release has been published successfully. - Go to https://readthedocs.org/projects/solidity/ and verify that the new version is listed, works and is marked as default. + Go to the [documentation status page at ReadTheDocs](https://readthedocs.org/projects/solidity/) and verify that the new version is listed, works and is marked as default. - [ ] Remove "still in progress" warning from the release notes. - [ ] Publish the blog posts. - [ ] Create a commit to increase the version number on ``develop`` in ``CMakeLists.txt`` and add a new skeleton changelog entry. From 0d98436de6be9cf95b4c85ca8c07752d5a245c46 Mon Sep 17 00:00:00 2001 From: emmaodia Date: Wed, 31 Aug 2022 11:11:34 +0100 Subject: [PATCH 097/109] Grammar fix --- docs/types/value-types.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/types/value-types.rst b/docs/types/value-types.rst index 5972ea8182..1e8e3e7fd9 100644 --- a/docs/types/value-types.rst +++ b/docs/types/value-types.rst @@ -221,7 +221,7 @@ Operators: .. warning:: If you convert a type that uses a larger byte size to an ``address``, for example ``bytes32``, then the ``address`` is truncated. - To reduce conversion ambiguity version 0.4.24 and higher of the compiler force you make the truncation explicit in the conversion. + To reduce conversion ambiguity, starting with version 0.4.24, the compiler will force you to make the truncation explicit in the conversion. Take for example the 32-byte value ``0x111122223333444455556666777788889999AAAABBBBCCCCDDDDEEEEFFFFCCCC``. You can use ``address(uint160(bytes20(b)))``, which results in ``0x111122223333444455556666777788889999aAaa``, @@ -336,7 +336,7 @@ on ``call``. * ``code`` and ``codehash`` You can query the deployed code for any smart contract. Use ``.code`` to get the EVM bytecode as a -``bytes memory``, which might be empty. Use ``.codehash`` get the Keccak-256 hash of that code +``bytes memory``, which might be empty. Use ``.codehash`` to get the Keccak-256 hash of that code (as a ``bytes32``). Note that ``addr.codehash`` is cheaper than using ``keccak256(addr.code)``. .. note:: From 53059936cc64858eb9419f61ec0189b52f290722 Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Mon, 5 Sep 2022 20:52:46 +0200 Subject: [PATCH 098/109] Pin hardhat version in GP2 external tests --- test/externalTests/gp2.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/externalTests/gp2.sh b/test/externalTests/gp2.sh index c59d67e08c..7df9e9a287 100755 --- a/test/externalTests/gp2.sh +++ b/test/externalTests/gp2.sh @@ -69,6 +69,8 @@ function gp2_test force_hardhat_unlimited_contract_size "$config_file" "$config_var" npm install + npm install hardhat@2.10.2 + # Some dependencies come with pre-built artifacts. We want to build from scratch. rm -r node_modules/@gnosis.pm/safe-contracts/build/ From deab2bf37e04547832f147813e8237bef18226a0 Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Tue, 6 Sep 2022 08:10:55 +0200 Subject: [PATCH 099/109] Add comment to pinned GP2 hardhat version --- test/externalTests/gp2.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/externalTests/gp2.sh b/test/externalTests/gp2.sh index 7df9e9a287..1676d2b78c 100755 --- a/test/externalTests/gp2.sh +++ b/test/externalTests/gp2.sh @@ -69,6 +69,8 @@ function gp2_test force_hardhat_unlimited_contract_size "$config_file" "$config_var" npm install + # New hardhat release breaks GP2 tests, and since GP2 repository has been archived, we are pinning hardhat + # to the previous stable version. See https://github.com/ethereum/solidity/pull/13485 npm install hardhat@2.10.2 # Some dependencies come with pre-built artifacts. We want to build from scratch. From 8c4bbf1f4e753ea2d2cffc7365b300ba9cb75df7 Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Tue, 6 Sep 2022 11:06:31 +0200 Subject: [PATCH 100/109] Pin hardhat version in yield-liquidator tests --- test/externalTests/yield-liquidator.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/externalTests/yield-liquidator.sh b/test/externalTests/yield-liquidator.sh index d2afe2560f..a224433117 100755 --- a/test/externalTests/yield-liquidator.sh +++ b/test/externalTests/yield-liquidator.sh @@ -66,6 +66,10 @@ function yield_liquidator_test force_hardhat_unlimited_contract_size "$config_file" "$config_var" npm install + # 2.11.0 Hardhat release breaks contract compilation. + # TODO: remove when https://github.com/yieldprotocol/yield-liquidator-v2/issues/34 is addressed. + npm install hardhat@2.10.2 + replace_version_pragmas neutralize_packaged_contracts From 71d12099966dfff2a2f3d374990023f73977a03a Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Tue, 6 Sep 2022 17:55:23 +0200 Subject: [PATCH 101/109] Pin hardhat version in bleeps tests --- test/externalTests/bleeps.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/externalTests/bleeps.sh b/test/externalTests/bleeps.sh index 5ad80642e4..22e54ac9ce 100755 --- a/test/externalTests/bleeps.sh +++ b/test/externalTests/bleeps.sh @@ -86,6 +86,10 @@ function bleeps_test npm install npm-run-all npm install + # Causes a test failure with hardhat 2.11.0 (latest at the moment of writing this) + # TODO: Remove when https://github.com/wighawag/bleeps/issues/4 is resolved + npm install hardhat@2.10.2 + # TODO: Bleeps depends on OpenZeppelin 4.3.2, which is affected by # https://github.com/OpenZeppelin/openzeppelin-contracts/pull/3293. # Forcing OZ >= 4.6.0 fixes this but it also causes a lot of unrelated compilation errors. From efe558a989cdacf783bd2b936a6bc30e45f2e527 Mon Sep 17 00:00:00 2001 From: Matheus Aguiar Date: Thu, 1 Sep 2022 16:51:11 -0300 Subject: [PATCH 102/109] Added note about PeepholeOptimizer in docs. --- docs/internals/optimizer.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/internals/optimizer.rst b/docs/internals/optimizer.rst index 5ad0f19e55..3c12f0adfb 100644 --- a/docs/internals/optimizer.rst +++ b/docs/internals/optimizer.rst @@ -26,6 +26,10 @@ One can use ``solc --ir-optimized --optimize`` to produce an optimized Yul IR for a Solidity source. Similarly, one can use ``solc --strict-assembly --optimize`` for a stand-alone Yul mode. +.. note:: + The `peephole optimizer `_ and the inliner are always + enabled by default and can only be turned off via the :ref:`Standard JSON `. + You can find more details on both optimizer modules and their optimization steps below. Benefits of Optimizing Solidity Code From d5e292532669dc450c2c276da6caaf2055c8f228 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 5 Sep 2022 12:55:52 +0200 Subject: [PATCH 103/109] broken yul optimizer test --- .../function_side_effects_3.yul | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/libyul/yulOptimizerTests/unusedStoreEliminator/function_side_effects_3.yul diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_side_effects_3.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_side_effects_3.yul new file mode 100644 index 0000000000..a663454234 --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_side_effects_3.yul @@ -0,0 +1,27 @@ +{ + function conditionallyStop() { + if calldataload(0) { leave } + return(0, 0) + } + let x := 0 + let y := 1 + sstore(x, y) + conditionallyStop() + sstore(x, y) +} +// ---- +// step: unusedStoreEliminator +// +// { +// { +// let x := 0 +// let y := 1 +// conditionallyStop() +// sstore(x, y) +// } +// function conditionallyStop() +// { +// if calldataload(0) { leave } +// return(0, 0) +// } +// } From a33da17300f919b2e730b911bd20813e84d41523 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 5 Sep 2022 11:31:09 +0200 Subject: [PATCH 104/109] Bugfix and tests. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil Śliwak --- libyul/optimiser/UnusedStoreEliminator.cpp | 5 +- .../unused_store_storage_removal_bug.sol | 15 +++++ ...nditionally_terminating_function_call.yul} | 3 +- ...ing_function_call_complex_control_flow.yul | 60 +++++++++++++++++++ ...nally_terminating_function_call_revert.yul | 27 +++++++++ ...onditionally_terminating_function_call.yul | 33 ++++++++++ ...onditionally_terminating_function_call.yul | 23 +++++++ 7 files changed, 164 insertions(+), 2 deletions(-) create mode 100644 test/libsolidity/semanticTests/unused_store_storage_removal_bug.sol rename test/libyul/yulOptimizerTests/unusedStoreEliminator/{function_side_effects_3.yul => store_before_conditionally_terminating_function_call.yul} (79%) create mode 100644 test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_complex_control_flow.yul create mode 100644 test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_revert.yul create mode 100644 test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_indirectly_conditionally_terminating_function_call.yul create mode 100644 test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_unconditionally_terminating_function_call.yul diff --git a/libyul/optimiser/UnusedStoreEliminator.cpp b/libyul/optimiser/UnusedStoreEliminator.cpp index 754c02ac5d..2e96be2e70 100644 --- a/libyul/optimiser/UnusedStoreEliminator.cpp +++ b/libyul/optimiser/UnusedStoreEliminator.cpp @@ -105,10 +105,13 @@ void UnusedStoreEliminator::operator()(FunctionCall const& _functionCall) else sideEffects = m_controlFlowSideEffects.at(_functionCall.functionName.name); + if (sideEffects.canTerminate) + changeUndecidedTo(State::Used, Location::Storage); if (!sideEffects.canContinue) { changeUndecidedTo(State::Unused, Location::Memory); - changeUndecidedTo(sideEffects.canTerminate ? State::Used : State::Unused, Location::Storage); + if (!sideEffects.canTerminate) + changeUndecidedTo(State::Unused, Location::Storage); } } diff --git a/test/libsolidity/semanticTests/unused_store_storage_removal_bug.sol b/test/libsolidity/semanticTests/unused_store_storage_removal_bug.sol new file mode 100644 index 0000000000..87d4ef429a --- /dev/null +++ b/test/libsolidity/semanticTests/unused_store_storage_removal_bug.sol @@ -0,0 +1,15 @@ +contract C { + uint public x; + function f() public { + x = 1; // This write used to be removed by the Yul optimizer due to the StorageWriteRemovalBeforeConditionalTermination bug. + g(); + x = 2; + } + function g() internal { + if (msg.data.length > 4) return; + assembly { return(0, 0) } + } +} +// ---- +// f() -> +// x() -> 1 diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_side_effects_3.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call.yul similarity index 79% rename from test/libyul/yulOptimizerTests/unusedStoreEliminator/function_side_effects_3.yul rename to test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call.yul index a663454234..44fbb70115 100644 --- a/test/libyul/yulOptimizerTests/unusedStoreEliminator/function_side_effects_3.yul +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call.yul @@ -5,7 +5,7 @@ } let x := 0 let y := 1 - sstore(x, y) + sstore(x, y) // used to be removed due to the StorageWriteRemovalBeforeConditionalTermination conditionallyStop() sstore(x, y) } @@ -16,6 +16,7 @@ // { // let x := 0 // let y := 1 +// sstore(x, y) // conditionallyStop() // sstore(x, y) // } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_complex_control_flow.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_complex_control_flow.yul new file mode 100644 index 0000000000..dd88f4973a --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_complex_control_flow.yul @@ -0,0 +1,60 @@ +{ + function conditionallyStop() { + if calldataload(0) { leave } + return(0, 0) + } + function g() { + let a := 0 + let b := 1 + sstore(a, b) + } + let x := 0 + let y := 1 + let z := 2 + switch calldataload(64) + case 0 { + sstore(z, x) + g() + } + default { + sstore(x, z) // used to be removed due to the StorageWriteRemovalBeforeConditionalTermination + } + conditionallyStop() + switch calldataload(32) + case 0 { + revert(0, 0) + } + default { + sstore(x, z) + } +} +// ---- +// step: unusedStoreEliminator +// +// { +// { +// let x := 0 +// let y := 1 +// let z := 2 +// switch calldataload(64) +// case 0 { +// sstore(z, x) +// g() +// } +// default { sstore(x, z) } +// conditionallyStop() +// switch calldataload(32) +// case 0 { revert(0, 0) } +// default { sstore(x, z) } +// } +// function conditionallyStop() +// { +// if calldataload(0) { leave } +// return(0, 0) +// } +// function g() +// { +// let a := 0 +// sstore(a, 1) +// } +// } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_revert.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_revert.yul new file mode 100644 index 0000000000..fc45bb64c5 --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_conditionally_terminating_function_call_revert.yul @@ -0,0 +1,27 @@ +{ + function conditionallyStop() { + if calldataload(0) { leave } + return(0, 0) + } + let x := 0 + let y := 1 + sstore(x, y) // used to be removed due to the to the StorageWriteRemovalBeforeConditionalTermination bug + conditionallyStop() + revert(0,0) +} +// ---- +// step: unusedStoreEliminator +// +// { +// { +// let x := 0 +// sstore(x, 1) +// conditionallyStop() +// revert(0, 0) +// } +// function conditionallyStop() +// { +// if calldataload(0) { leave } +// return(0, 0) +// } +// } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_indirectly_conditionally_terminating_function_call.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_indirectly_conditionally_terminating_function_call.yul new file mode 100644 index 0000000000..1d15078eb9 --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_indirectly_conditionally_terminating_function_call.yul @@ -0,0 +1,33 @@ +{ + function conditionallyStop() { + if calldataload(0) { leave } + returnEmpty() + } + function returnEmpty() { + return(0, 0) + } + let x := 0 + let y := 1 + sstore(x, y) // used to be removed due to a bug + conditionallyStop() + sstore(x, y) +} +// ---- +// step: unusedStoreEliminator +// +// { +// { +// let x := 0 +// let y := 1 +// sstore(x, y) +// conditionallyStop() +// sstore(x, y) +// } +// function conditionallyStop() +// { +// if calldataload(0) { leave } +// returnEmpty() +// } +// function returnEmpty() +// { return(0, 0) } +// } diff --git a/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_unconditionally_terminating_function_call.yul b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_unconditionally_terminating_function_call.yul new file mode 100644 index 0000000000..c104e4d9b7 --- /dev/null +++ b/test/libyul/yulOptimizerTests/unusedStoreEliminator/store_before_unconditionally_terminating_function_call.yul @@ -0,0 +1,23 @@ +{ + function neverStop() { + if calldataload(0) { leave } // prevent inlining + } + let x := 0 + let y := 1 + sstore(x, y) // should be removed + neverStop() + sstore(x, y) +} +// ---- +// step: unusedStoreEliminator +// +// { +// { +// let x := 0 +// let y := 1 +// neverStop() +// sstore(x, y) +// } +// function neverStop() +// { if calldataload(0) { leave } } +// } From d6eb255df4176d130c9275130824b9efd4ce0b46 Mon Sep 17 00:00:00 2001 From: Daniel Kirchner Date: Mon, 5 Sep 2022 13:22:33 +0200 Subject: [PATCH 105/109] Changelog entry and bug list entry. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kamil Śliwak --- Changelog.md | 1 + docs/bugs.json | 13 +++++++++++++ docs/bugs_by_version.json | 7 ++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index f0f8b8485c..c03dbb6d1e 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ### 0.8.17 (unreleased) Important Bugfixes: + * Yul Optimizer: Prevent the incorrect removal of storage writes before calls to Yul functions that conditionally terminate the external EVM call. Language Features: diff --git a/docs/bugs.json b/docs/bugs.json index 421bb007c0..03dafbe45b 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -1,4 +1,17 @@ [ + { + "uid": "SOL-2022-7", + "name": "StorageWriteRemovalBeforeConditionalTermination", + "summary": "Calling functions that conditionally terminate the external EVM call using the assembly statements ``return(...)`` or ``stop()`` may result in incorrect removals of prior storage writes.", + "description": "A call to a Yul function that conditionally terminates the external EVM call could result in prior storage writes being incorrectly removed by the Yul optimizer. This used to happen in cases in which it would have been valid to remove the store, if the Yul function in question never actually terminated the external call, and the control flow always returned back to the caller instead. Conditional termination within the same Yul block instead of within a called function was not affected. In Solidity with optimized via-IR code generation, any storage write before a function conditionally calling ``return(...)`` or ``stop()`` in inline assembly, may have been incorrectly removed, whenever it would have been valid to remove the write without the ``return(...)`` or ``stop()``. In optimized legacy code generation, only inline assembly that did not refer to any Solidity variables and that involved conditionally-terminating user-defined assembly functions could be affected.", + "link": "https://blog.soliditylang.org/2022/09/08/storage-write-removal-before-conditional-termination/", + "introduced": "0.8.13", + "fixed": "0.8.17", + "severity": "medium/high", + "conditions": { + "yulOptimizer": true + } + }, { "uid": "SOL-2022-6", "name": "AbiReencodingHeadOverflowWithStaticArrayCleanup", diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 3e3847c9b9..df8fdc6334 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -1737,6 +1737,7 @@ }, "0.8.13": { "bugs": [ + "StorageWriteRemovalBeforeConditionalTermination", "AbiReencodingHeadOverflowWithStaticArrayCleanup", "DirtyBytesArrayToStorage", "InlineAssemblyMemorySideEffects", @@ -1747,6 +1748,7 @@ }, "0.8.14": { "bugs": [ + "StorageWriteRemovalBeforeConditionalTermination", "AbiReencodingHeadOverflowWithStaticArrayCleanup", "DirtyBytesArrayToStorage", "InlineAssemblyMemorySideEffects" @@ -1755,12 +1757,15 @@ }, "0.8.15": { "bugs": [ + "StorageWriteRemovalBeforeConditionalTermination", "AbiReencodingHeadOverflowWithStaticArrayCleanup" ], "released": "2022-06-15" }, "0.8.16": { - "bugs": [], + "bugs": [ + "StorageWriteRemovalBeforeConditionalTermination" + ], "released": "2022-08-08" }, "0.8.2": { From f90b25449dd42d877578399b57a46ae0e3e4c6d3 Mon Sep 17 00:00:00 2001 From: Nikola Matic Date: Thu, 8 Sep 2022 15:22:47 +0200 Subject: [PATCH 106/109] Fix SMT checker paper link --- docs/smtchecker.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/smtchecker.rst b/docs/smtchecker.rst index caa901713c..6d2f4373b2 100644 --- a/docs/smtchecker.rst +++ b/docs/smtchecker.rst @@ -684,7 +684,7 @@ Types that are not yet supported are abstracted by a single 256-bit unsigned integer, where their unsupported operations are ignored. For more details on how the SMT encoding works internally, see the paper -`SMT-based Verification of Solidity Smart Contracts `_. +`SMT-based Verification of Solidity Smart Contracts `_. Function Calls ============== From 1649f24767d3828a30ba8646181f1cb836dd8077 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 8 Sep 2022 14:58:56 +0200 Subject: [PATCH 107/109] Add missing changelog entries for a few PRs that will go into 0.8.17 --- Changelog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Changelog.md b/Changelog.md index c03dbb6d1e..2f21b52dc4 100644 --- a/Changelog.md +++ b/Changelog.md @@ -15,6 +15,12 @@ Compiler Features: Bugfixes: * Type Checker: Fix internal compiler error on tuple assignments with invalid left-hand side. + * Yul IR Code Generation: Fix internal compiler error when accessing the ``.slot`` member of a mapping through a storage reference in inline assembly. + + +Build System: + * Allow disabling pedantic warnings and do not treat warnings as errors during compiler build when ``-DPEDANTIC=OFF`` flag is passed to CMake. + * Update emscripten to version 3.1.19. ### 0.8.16 (2022-08-08) From 514842e2a4b52f4fd5576aaf6ccc9b94bc2c082c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 8 Sep 2022 14:38:23 +0200 Subject: [PATCH 108/109] Sort changelog for 0.8.17 alphabetically --- Changelog.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index 2f21b52dc4..500f859de9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -4,13 +4,10 @@ Important Bugfixes: * Yul Optimizer: Prevent the incorrect removal of storage writes before calls to Yul functions that conditionally terminate the external EVM call. -Language Features: - - Compiler Features: * Code Generator: More efficient overflow checks for multiplication. - * Yul Optimizer: Simplify the starting offset of zero-length operations to zero. * Language Server: Analyze all files in a project by default (can be customized by setting ``'file-load-strategy'`` to ``'directly-opened-and-on-import'`` in LSP settings object). + * Yul Optimizer: Simplify the starting offset of zero-length operations to zero. Bugfixes: From 722e9d8693a6b479ee266e7ac2d6eac2310b9a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 8 Sep 2022 14:39:36 +0200 Subject: [PATCH 109/109] Set release date for 0.8.17 and update the bug list --- Changelog.md | 2 +- docs/bugs_by_version.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 500f859de9..2167d5b703 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,4 @@ -### 0.8.17 (unreleased) +### 0.8.17 (2022-09-08) Important Bugfixes: * Yul Optimizer: Prevent the incorrect removal of storage writes before calls to Yul functions that conditionally terminate the external EVM call. diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index df8fdc6334..11ddd40b07 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -1768,6 +1768,10 @@ ], "released": "2022-08-08" }, + "0.8.17": { + "bugs": [], + "released": "2022-09-08" + }, "0.8.2": { "bugs": [ "AbiReencodingHeadOverflowWithStaticArrayCleanup",