Skip to content

Commit 9549d8f

Browse files
authored
Merge pull request #5975 from ethereum/develop
Release 0.5.4
2 parents 10d17f2 + f16c02b commit 9549d8f

File tree

178 files changed

+5608
-1054
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+5608
-1054
lines changed

.circleci/config.yml

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
paths:
6767
- soljson.js
6868
- version.txt
69+
6970
test_emscripten_solcjs:
7071
docker:
7172
- image: circleci/node:10
@@ -84,6 +85,7 @@ jobs:
8485
name: Test solcjs
8586
command: |
8687
test/solcjsTests.sh /tmp/workspace/soljson.js $(cat /tmp/workspace/version.txt)
88+
8789
test_emscripten_external:
8890
docker:
8991
- image: circleci/node:10
@@ -102,6 +104,7 @@ jobs:
102104
name: External tests
103105
command: |
104106
test/externalTests.sh /tmp/workspace/soljson.js || test/externalTests.sh /tmp/workspace/soljson.js
107+
105108
build_x86_linux:
106109
docker:
107110
- image: buildpack-deps:bionic
@@ -114,7 +117,7 @@ jobs:
114117
name: Install build dependencies
115118
command: |
116119
apt-get -qq update
117-
apt-get -qy install cmake libboost-regex-dev libboost-filesystem-dev libboost-test-dev libboost-system-dev libboost-program-options-dev libz3-dev
120+
apt-get -qy install cmake libboost-regex-dev libboost-filesystem-dev libboost-test-dev libboost-system-dev libboost-program-options-dev libcvc4-dev
118121
./scripts/install_obsolete_jsoncpp_1_7_4.sh
119122
- run: *setup_prerelease_commit_hash
120123
- run: *run_build
@@ -124,6 +127,23 @@ jobs:
124127
paths:
125128
- "*"
126129

130+
build_x86_linux_cxx17:
131+
docker:
132+
- image: buildpack-deps:disco
133+
environment:
134+
TERM: xterm
135+
CMAKE_OPTIONS: -DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/cxx17.cmake
136+
steps:
137+
- checkout
138+
- run:
139+
name: Install build dependencies
140+
command: |
141+
apt-get -qq update
142+
apt-get -qy install cmake libboost-regex-dev libboost-filesystem-dev libboost-test-dev libboost-system-dev libboost-program-options-dev libcvc4-dev
143+
./scripts/install_obsolete_jsoncpp_1_7_4.sh
144+
- run: *setup_prerelease_commit_hash
145+
- run: *run_build
146+
127147
build_x86_archlinux:
128148
docker:
129149
- image: archlinux/base
@@ -145,29 +165,31 @@ jobs:
145165
- test/soltest
146166
- test/tools/solfuzzer
147167

148-
build_x86_clang7:
168+
build_x86_clang7_asan:
149169
docker:
150170
- image: buildpack-deps:cosmic
151171
environment:
152172
TERM: xterm
153173
CC: /usr/bin/clang-7
154174
CXX: /usr/bin/clang++-7
155-
CMAKE_OPTIONS: -DLLL=ON
175+
CMAKE_OPTIONS: -DSANITIZE=address -DCMAKE_BUILD_TYPE=Debug
156176
steps:
157177
- checkout
158178
- run:
159179
name: Install build dependencies
160180
command: |
161181
apt-get -qq update
162-
apt-get -qy install clang-7 cmake libboost-regex-dev libboost-filesystem-dev libboost-test-dev libboost-system-dev libboost-program-options-dev libz3-dev
182+
apt-get -qy install clang-7 cmake libboost-regex-dev libboost-filesystem-dev libboost-test-dev libboost-system-dev libboost-program-options-dev libcvc4-dev
163183
./scripts/install_obsolete_jsoncpp_1_7_4.sh
164184
- run: *setup_prerelease_commit_hash
165185
- run: *run_build
166186
- store_artifacts: *solc_artifact
167187
- persist_to_workspace:
168188
root: build
169189
paths:
170-
- "*"
190+
- solc/solc
191+
- test/soltest
192+
- test/tools/solfuzzer
171193

172194
build_x86_mac:
173195
macos:
@@ -249,7 +271,7 @@ jobs:
249271
name: Install dependencies
250272
command: |
251273
apt-get -qq update
252-
apt-get -qy install libz3-dev libleveldb1v5 python-pip
274+
apt-get -qy install libcvc4-dev libleveldb1v5 python-pip
253275
pip install codecov
254276
- run: mkdir -p test_results
255277
- run:
@@ -268,6 +290,36 @@ jobs:
268290
path: test_results/
269291
destination: test_results/
270292

293+
test_x86_clang7_asan:
294+
docker:
295+
- image: buildpack-deps:cosmic
296+
environment:
297+
TERM: xterm
298+
steps:
299+
- checkout
300+
- attach_workspace:
301+
at: build
302+
- run:
303+
name: Install dependencies
304+
command: |
305+
apt-get -qq update
306+
apt-get -qy install llvm-7-dev libcvc4-dev libleveldb1v5 python-pip
307+
# This is needed to resolve the symbols. Since we're using clang7 in the build, we must use the appropriate symbolizer.
308+
update-alternatives --install /usr/bin/llvm-symbolizer llvm-symbolizer /usr/bin/llvm-symbolizer-7 1
309+
- run: mkdir -p test_results
310+
- run:
311+
name: Run tests with ASAN
312+
command: |
313+
ulimit -a
314+
# Increase stack size because ASan makes stack frames bigger and that breaks our assumptions (in tests).
315+
ulimit -s 16384
316+
build/test/soltest --logger=JUNIT,test_suite,test_results/result.xml -- --no-ipc --testpath test
317+
- store_test_results:
318+
path: test_results/
319+
- store_artifacts:
320+
path: test_results/
321+
destination: test_results/
322+
271323
test_x86_archlinux:
272324
docker:
273325
- image: archlinux/base
@@ -350,12 +402,19 @@ workflows:
350402
requires:
351403
- build_emscripten
352404
- build_x86_linux: *build_on_tags
353-
- build_x86_clang7: *build_on_tags
405+
- build_x86_linux_cxx17: *build_on_tags
406+
- build_x86_clang7_asan: *build_on_tags
354407
- build_x86_mac: *build_on_tags
355408
- test_x86_linux:
356409
<<: *build_on_tags
357410
requires:
358411
- build_x86_linux
412+
- test_x86_clang7_asan:
413+
filters:
414+
branches:
415+
only: develop
416+
requires:
417+
- build_x86_clang7_asan
359418
- test_x86_mac:
360419
<<: *build_on_tags
361420
requires:

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,11 @@ matrix:
5858
before_install:
5959
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
6060
- sudo add-apt-repository -y ppa:mhier/libboost-latest
61-
- sudo add-apt-repository -y ppa:hvr/z3
6261
- sudo apt-get update -qq
6362
install:
6463
- sudo apt-get install -qq g++-8 gcc-8
6564
- sudo apt-get install -qq libboost1.67-dev
6665
- sudo apt-get install -qq libleveldb1
67-
- sudo apt-get install -qq libz3-dev
6866
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
6967
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 90
7068

@@ -78,13 +76,11 @@ matrix:
7876
before_install:
7977
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
8078
- sudo add-apt-repository -y ppa:mhier/libboost-latest
81-
- sudo add-apt-repository -y ppa:hvr/z3
8279
- sudo apt-get update -qq
8380
install:
8481
- sudo apt-get install -qq g++-8 gcc-8
8582
- sudo apt-get install -qq libboost1.67-dev
8683
- sudo apt-get install -qq libleveldb1
87-
- sudo apt-get install -qq libz3-dev
8884
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
8985
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 90
9086

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ include(EthPolicy)
1010
eth_policy()
1111

1212
# project name and version should be set after cmake_policy CMP0048
13-
set(PROJECT_VERSION "0.5.3")
13+
set(PROJECT_VERSION "0.5.4")
1414
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES CXX)
1515

1616
option(LLL "Build LLL" OFF)

Changelog.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
### 0.5.4 (2019-02-12)
2+
3+
Language Features:
4+
* Allow calldata structs without dynamically encoded members with ABIEncoderV2.
5+
6+
7+
Compiler Features:
8+
* ABIEncoderV2: Implement packed encoding.
9+
* C API (``libsolc`` / raw ``soljson.js``): Introduce ``solidity_free`` method which releases all internal buffers to save memory.
10+
* Commandline Interface: Adds new option ``--new-reporter`` for improved diagnostics formatting
11+
along with ``--color`` and ``--no-color`` for colorized output to be forced (or explicitly disabled).
12+
13+
14+
Bugfixes:
15+
* Code Generator: Defensively pad allocation of creationCode and runtimeCode to multiples of 32 bytes.
16+
* Commandline Interface: Allow yul optimizer only for strict assembly.
17+
* Parser: Disallow empty import statements.
18+
* Type Checker: Disallow mappings with data locations other than ``storage``.
19+
* Type Checker: Fix internal error when a struct array index does not fit into a uint256.
20+
* Type System: Properly report packed encoded size for arrays and structs (mostly unused until now).
21+
22+
23+
Build System:
24+
* Add support for continuous fuzzing via Google oss-fuzz
25+
* SMT: If using Z3, require version 4.6.0 or newer.
26+
* Soltest: Add parser that is used in the file-based unit test environment.
27+
* Ubuntu PPA Packages: Use CVC4 as SMT solver instead of Z3
28+
29+
130
### 0.5.3 (2019-01-22)
231

332
Language Features:

cmake/EthCompilerSettings.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
7474
# into errors, which makes sense.
7575
# http://stackoverflow.com/questions/21617158/how-to-silence-unused-command-line-argument-error-with-clang-without-disabling-i
7676
add_compile_options(-Qunused-arguments)
77-
7877
elseif(EMSCRIPTEN)
7978
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --memory-init-file 0")
8079
# Leave only exported symbols as public and aggressively remove others
@@ -124,6 +123,7 @@ elseif (DEFINED MSVC)
124123
add_compile_options(/wd4800) # disable forcing value to bool 'true' or 'false' (performance warning) (4800)
125124
add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement
126125
add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions
126+
add_compile_options(/utf-8) # enable utf-8 encoding (solves warning 4819)
127127

128128
# disable empty object file warning
129129
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")

cmake/EthOptions.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ macro(configure_project)
33

44
# features
55
eth_default_option(COVERAGE OFF)
6+
eth_default_option(OSSFUZZ OFF)
67

78
# components
89
eth_default_option(TESTS ON)

cmake/FindZ3.cmake

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
if (USE_Z3)
22
find_path(Z3_INCLUDE_DIR NAMES z3++.h PATH_SUFFIXES z3)
33
find_library(Z3_LIBRARY NAMES z3)
4+
find_program(Z3_EXECUTABLE z3 PATH_SUFFIXES bin)
5+
6+
if(Z3_INCLUDE_DIR AND Z3_LIBRARY AND Z3_EXECUTABLE)
7+
execute_process (COMMAND ${Z3_EXECUTABLE} -version
8+
OUTPUT_VARIABLE libz3_version_str
9+
ERROR_QUIET
10+
OUTPUT_STRIP_TRAILING_WHITESPACE)
11+
12+
string(REGEX REPLACE "^Z3 version ([0-9.]+).*" "\\1"
13+
Z3_VERSION_STRING "${libz3_version_str}")
14+
unset(libz3_version_str)
15+
endif()
16+
mark_as_advanced(Z3_VERSION_STRING z3_DIR)
17+
418
include(FindPackageHandleStandardArgs)
5-
find_package_handle_standard_args(Z3 DEFAULT_MSG Z3_LIBRARY Z3_INCLUDE_DIR)
19+
find_package_handle_standard_args(Z3
20+
REQUIRED_VARS Z3_LIBRARY Z3_INCLUDE_DIR
21+
VERSION_VAR Z3_VERSION_STRING)
622

723
if (NOT TARGET Z3::Z3)
824
add_library(Z3::Z3 UNKNOWN IMPORTED)

cmake/toolchains/cxx17.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Require C++17.
2+
set(CMAKE_CXX_STANDARD 17)
3+
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
4+
set(CMAKE_CXX_EXTENSIONS OFF)

docs/abi-spec.rst

Lines changed: 66 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,22 @@ In effect, a log entry using this ABI is described as:
418418

419419
- ``address``: the address of the contract (intrinsically provided by Ethereum);
420420
- ``topics[0]``: ``keccak(EVENT_NAME+"("+EVENT_ARGS.map(canonical_type_of).join(",")+")")`` (``canonical_type_of`` is a function that simply returns the canonical type of a given argument, e.g. for ``uint indexed foo``, it would return ``uint256``). If the event is declared as ``anonymous`` the ``topics[0]`` is not generated;
421-
- ``topics[n]``: ``EVENT_INDEXED_ARGS[n - 1]`` (``EVENT_INDEXED_ARGS`` is the series of ``EVENT_ARGS`` that are indexed);
422-
- ``data``: ``abi_serialise(EVENT_NON_INDEXED_ARGS)`` (``EVENT_NON_INDEXED_ARGS`` is the series of ``EVENT_ARGS`` that are not indexed, ``abi_serialise`` is the ABI serialisation function used for returning a series of typed values from a function, as described above).
423-
424-
For all fixed-length Solidity types, the ``EVENT_INDEXED_ARGS`` array contains the 32-byte encoded value directly. However, for *types of dynamic length*, which include ``string``, ``bytes``, and arrays, ``EVENT_INDEXED_ARGS`` will contain the *Keccak hash* of the packed encoded value (see :ref:`abi_packed_mode`), rather than the encoded value directly. This allows applications to efficiently query for values of dynamic-length types (by setting the hash of the encoded value as the topic), but leaves applications unable to decode indexed values they have not queried for. For dynamic-length types, application developers face a trade-off between fast search for predetermined values (if the argument is indexed) and legibility of arbitrary values (which requires that the arguments not be indexed). Developers may overcome this tradeoff and achieve both efficient search and arbitrary legibility by defining events with two arguments — one indexed, one not — intended to hold the same value.
421+
- ``topics[n]``: ``abi_encode(EVENT_INDEXED_ARGS[n - 1])`` (``EVENT_INDEXED_ARGS`` is the series of ``EVENT_ARGS`` that are indexed);
422+
- ``data``: ABI encoding of ``EVENT_NON_INDEXED_ARGS`` (``EVENT_NON_INDEXED_ARGS`` is the series of ``EVENT_ARGS`` that are not indexed, ``abi_encode`` is the ABI encoding function used for returning a series of typed values from a function, as described above).
423+
424+
For all types of length at most 32 bytes, the ``EVENT_INDEXED_ARGS`` array contains
425+
the value directly, padded or sign-extended (for signed integers) to 32 bytes, just as for regular ABI encoding.
426+
However, for all "complex" types or types of dynamic length, including all arrays, ``string``, ``bytes`` and structs,
427+
``EVENT_INDEXED_ARGS`` will contain the *Keccak hash* of a special in-place encoded value
428+
(see :ref:`indexed_event_encoding`), rather than the encoded value directly.
429+
This allows applications to efficiently query for values of dynamic-length types
430+
(by setting the hash of the encoded value as the topic), but leaves applications unable
431+
to decode indexed values they have not queried for. For dynamic-length types,
432+
application developers face a trade-off between fast search for predetermined values
433+
(if the argument is indexed) and legibility of arbitrary values (which requires that
434+
the arguments not be indexed). Developers may overcome this tradeoff and achieve both
435+
efficient search and arbitrary legibility by defining events with two arguments — one
436+
indexed, one not — intended to hold the same value.
425437

426438
.. _abi_json:
427439

@@ -608,8 +620,9 @@ Through ``abi.encodePacked()``, Solidity supports a non-standard packed mode whe
608620

609621
- types shorter than 32 bytes are neither zero padded nor sign extended and
610622
- dynamic types are encoded in-place and without the length.
623+
- array elements are padded, but still encoded in-place
611624

612-
This packed mode is mainly used for indexed event parameters.
625+
Furthermore, structs as well as nested arrays are not supported.
613626

614627
As an example, the encoding of ``int16(-1), bytes1(0x42), uint16(0x03), string("Hello, world!")`` results in:
615628

@@ -622,12 +635,18 @@ As an example, the encoding of ``int16(-1), bytes1(0x42), uint16(0x03), string("
622635
^^^^^^^^^^^^^^^^^^^^^^^^^^ string("Hello, world!") without a length field
623636
624637
More specifically:
625-
- Each value type takes as many bytes as its range has.
626-
- The encoding of a struct or fixed-size array is the concatenation of the
627-
encoding of its members/elements without any separator or padding.
628-
- Mapping members of structs are ignored as usual.
629-
- Dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded without
630-
their length field.
638+
- During the encoding, everything is encoded in-place. This means that there is
639+
no distinction between head and tail, as in the ABI encoding, and the length
640+
of an array is not encoded.
641+
- The direct arguments of ``abi.encodePacked`` are encoded without padding,
642+
as long as they are not arrays (or ``string`` or ``bytes``).
643+
- The encoding of an array is the concatenation of the
644+
encoding of its elements **with** padding.
645+
- Dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded
646+
without their length field.
647+
- The encoding of ``string`` or ``bytes`` does not apply padding at the end
648+
unless it is part of an array or struct (then it is padded to a multiple of
649+
32 bytes).
631650

632651
In general, the encoding is ambiguous as soon as there are two dynamically-sized elements,
633652
because of the missing length field.
@@ -636,3 +655,39 @@ If padding is needed, explicit type conversions can be used: ``abi.encodePacked(
636655

637656
Since packed encoding is not used when calling functions, there is no special support
638657
for prepending a function selector. Since the encoding is ambiguous, there is no decoding function.
658+
659+
.. warning::
660+
661+
If you use ``keccak256(abi.encodePacked(a, b))`` and both ``a`` and ``b`` are dynamic types,
662+
it is easy to craft collisions in the hash value by moving parts of ``a`` into ``b`` and
663+
vice-versa. More specifically, ``abi.encodePacked("a", "bc") == abi.encodePacked("ab", "c")``.
664+
If you use ``abi.encodePacked`` for signatures, authentication or data integrity, make
665+
sure to always use the same types and check that at most one of them is dynamic.
666+
Unless there is a compelling reason, ``abi.encode`` should be preferred.
667+
668+
669+
.. _indexed_event_encoding:
670+
671+
Encoding of Indexed Event Parameters
672+
====================================
673+
674+
Indexed event parameters that are not value types, i.e. arrays and structs are not
675+
stored directly but instead a keccak256-hash of an encoding is stored. This encoding
676+
is defined as follows:
677+
678+
- the encoding of a ``bytes`` and ``string`` value is just the string contents
679+
without any padding or length prefix.
680+
- the encoding of a struct is the concatenation of the encoding of its members,
681+
always padded to a multiple of 32 bytes (even ``bytes`` and ``string``).
682+
- the encoding of an array (both dynamically- and statically-sized) is
683+
the concatenation of the encoding of its elements, always padded to a multiple
684+
of 32 bytes (even ``bytes`` and ``string``) and without any length prefix
685+
686+
In the above, as usual, a negative number is padded by sign extension and not zero padded.
687+
``bytesNN`` types are padded on the right while ``uintNN`` / ``intNN`` are padded on the left.
688+
689+
.. warning::
690+
691+
The encoding of a struct is ambiguous if it contains more than one dynamically-sized
692+
array. Because of that, always re-check the event data and do not rely on the search result
693+
based on the indexed parameters alone.

docs/bugs_by_version.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,5 +624,9 @@
624624
"0.5.3": {
625625
"bugs": [],
626626
"released": "2019-01-22"
627+
},
628+
"0.5.4": {
629+
"bugs": [],
630+
"released": "2019-02-12"
627631
}
628632
}

0 commit comments

Comments
 (0)