Skip to content

Commit

Permalink
Merge pull request ethereum#3261 from ethereum/develop
Browse files Browse the repository at this point in the history
Merge develop into release for 0.4.19
  • Loading branch information
chriseth authored Nov 30, 2017
2 parents 9cf6e91 + d0af0c1 commit c4cbbb0
Show file tree
Hide file tree
Showing 99 changed files with 4,500 additions and 666 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ prerelease.txt
build/
docs/_build
docs/utils/__pycache__
docs/utils/*.pyc

# vim stuff
*.swp
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(EthPolicy)
eth_policy()

# project name and version should be set after cmake_policy CMP0048
set(PROJECT_VERSION "0.4.18")
set(PROJECT_VERSION "0.4.19")
project(solidity VERSION ${PROJECT_VERSION})

option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF)
Expand Down
15 changes: 15 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
### 0.4.19 (2017-11-30)

Features:
* Code Generator: New ABI decoder which supports structs and arbitrarily nested
arrays and checks input size (activate using ``pragma experimental ABIEncoderV2;``).
* General: Allow constant variables to be used as array length.
* Inline Assembly: ``if`` statement.
* Standard JSON: Support the ``outputSelection`` field for selective compilation of target artifacts.
* Syntax Checker: Turn the usage of ``callcode`` into an error as experimental 0.5.0 feature.
* Type Checker: Improve address checksum warning.
* Type Checker: More detailed errors for invalid array lengths (such as division by zero).

Bugfixes:

### 0.4.18 (2017-10-18)

Features:
Expand All @@ -11,6 +25,7 @@ Features:
* Type Checker: Do not add members of ``address`` to contracts as experimental 0.5.0 feature.
* Type Checker: Force interface functions to be external as experimental 0.5.0 feature.
* Type Checker: Require ``storage`` or ``memory`` keyword for local variables as experimental 0.5.0 feature.
* Compiler Interface: Better formatted error message for long source snippets

Bugfixes:
* Code Generator: Allocate one byte per memory byte array element instead of 32.
Expand Down
9 changes: 5 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ build_script:
- cd %APPVEYOR_BUILD_FOLDER%
- scripts\release.bat %CONFIGURATION%
- ps: $bytecodedir = git show -s --format="%cd-%H" --date=short

test_script:
- cd %APPVEYOR_BUILD_FOLDER%\build\test\%CONFIGURATION%
- soltest.exe --show-progress -- --no-ipc --no-smt
# Skip bytecode compare if private key is not available
- cd %APPVEYOR_BUILD_FOLDER%
- ps: if ($env:priv_key) {
scripts\bytecodecompare\storebytecode.bat $Env:CONFIGURATION $bytecodedir
}

test_script:
- cd %APPVEYOR_BUILD_FOLDER%
- cd %APPVEYOR_BUILD_FOLDER%\build\test\%CONFIGURATION%
- soltest.exe --show-progress -- --no-ipc --no-smt

artifacts:
- path: solidity-windows.zip
Expand Down
49 changes: 27 additions & 22 deletions docs/abi-spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ on the type of ``X`` being
Note that in the dynamic case, ``head(X(i))`` is well-defined since the lengths of
the head parts only depend on the types and not the values. Its value is the offset
of the beginning of ``tail(X(i))`` relative to the start of ``enc(X)``.

- ``T[k]`` for any ``T`` and ``k``:

``enc(X) = enc((X[0], ..., X[k-1]))``

i.e. it is encoded as if it were a tuple with ``k`` elements
of the same type.

- ``T[]`` where ``X`` has ``k`` elements (``k`` is assumed to be of type ``uint256``):

``enc(X) = enc(k) enc([X[1], ..., X[k]])``
Expand Down Expand Up @@ -326,19 +326,19 @@ An event description is a JSON object with fairly similar fields:

- ``anonymous``: ``true`` if the event was declared as ``anonymous``.

For example,
For example,

::

pragma solidity ^0.4.0;
pragma solidity ^0.4.0;

contract Test {
function Test(){ b = 0x12345678901234567890123456789012; }
event Event(uint indexed a, bytes32 b)
event Event2(uint indexed a, bytes32 b)
function foo(uint a) { Event(a, b); }
bytes32 b;
}
contract Test {
function Test(){ b = 0x12345678901234567890123456789012; }
event Event(uint indexed a, bytes32 b);
event Event2(uint indexed a, bytes32 b);
function foo(uint a) { Event(a, b); }
bytes32 b;
}

would result in the JSON:

Expand Down Expand Up @@ -377,11 +377,11 @@ As an example, the code

::

contract Test {
struct S { uint a; uint[] b; T[] c; }
struct T { uint x; uint y; }
function f(S s, T t, uint a) { }
}
contract Test {
struct S { uint a; uint[] b; T[] c; }
struct T { uint x; uint y; }
function f(S s, T t, uint a) { }
}

would result in the JSON:

Expand Down Expand Up @@ -451,13 +451,18 @@ Non-standard Packed Mode
Solidity supports a non-standard packed mode where:

- no :ref:`function selector <abi_function_selector>` is encoded,
- short types are not zero padded and
- types shorter than 32 bytes are neither zero padded nor sign extended and
- dynamic types are encoded in-place and without the length.

As an example encoding ``uint1, bytes1, uint8, string`` with values ``1, 0x42, 0x2424, "Hello, world!"`` results in ::
As an example encoding ``int1, bytes1, uint16, string`` with values ``-1, 0x42, 0x2424, "Hello, world!"`` results in ::

0x0142242448656c6c6f2c20776f726c6421
^^ uint1(1)
0xff42242448656c6c6f2c20776f726c6421
^^ int1(-1)
^^ bytes1(0x42)
^^^^ uint8(0x2424)
^^^^ uint16(0x2424)
^^^^^^^^^^^^^^^^^^^^^^^^^^ string("Hello, world!") without a length field

More specifically, each statically-sized type takes as many bytes as its range has
and dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded without
their length field. This means that the encoding is ambiguous as soon as there are two
dynamically-sized elements.
34 changes: 26 additions & 8 deletions docs/assembly.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ This assembly language can also be used as "inline assembly" inside Solidity
source code. We start with describing how to use inline assembly and how it
differs from standalone assembly and then specify assembly itself.

.. note::
TODO: Write about how scoping rules of inline assembly are a bit different
and the complications that arise when for example using internal functions
of libraries. Furthermore, write about the symbols defined by the compiler.

.. _inline-assembly:

Inline Assembly
Expand All @@ -31,6 +26,7 @@ arising when writing manual assembly by the following features:
* access to external variables: ``function f(uint x) { assembly { x := sub(x, 1) } }``
* labels: ``let x := 10 repeat: x := sub(x, 1) jumpi(repeat, eq(x, 0))``
* loops: ``for { let i := 0 } lt(i, x) { i := add(i, 1) } { y := mul(2, y) }``
* if statements: ``if slt(x, 0) { x := sub(0, x) }``
* switch statements: ``switch x case 0 { y := mul(x, 2) } default { y := 0 }``
* function calls: ``function f(x) -> y { switch x case 0 { y := 1 } default { y := mul(x, f(sub(x, 1))) } }``

Expand All @@ -41,6 +37,11 @@ We now want to describe the inline assembly language in detail.
at a low level. This discards several important safety
features of Solidity.

.. note::
TODO: Write about how scoping rules of inline assembly are a bit different
and the complications that arise when for example using internal functions
of libraries. Furthermore, write about the symbols defined by the compiler.

Example
-------

Expand Down Expand Up @@ -400,7 +401,7 @@ Labels
Another problem in EVM assembly is that ``jump`` and ``jumpi`` use absolute addresses
which can change easily. Solidity inline assembly provides labels to make the use of
jumps easier. Note that labels are a low-level feature and it is possible to write
efficient assembly without labels, just using assembly functions, loops and switch instructions
efficient assembly without labels, just using assembly functions, loops, if and switch instructions
(see below). The following code computes an element in the Fibonacci series.

.. code::
Expand Down Expand Up @@ -523,6 +524,21 @@ is performed by replacing the variable's value on the stack by the new value.
=: v // instruction style assignment, puts the result of sload(10) into v
}
If
--

The if statement can be used for conditionally executing code.
There is no "else" part, consider using "switch" (see below) if
you need multiple alternatives.

.. code::
{
if eq(value, 0) { revert(0, 0) }
}
The curly braces for the body are required.

Switch
------

Expand Down Expand Up @@ -622,7 +638,7 @@ Things to Avoid
---------------

Inline assembly might have a quite high-level look, but it actually is extremely
low-level. Function calls, loops and switches are converted by simple
low-level. Function calls, loops, ifs and switches are converted by simple
rewriting rules and after that, the only thing the assembler does for you is re-arranging
functional-style opcodes, managing jump labels, counting stack height for
variable access and removing stack slots for assembly-local variables when the end
Expand Down Expand Up @@ -669,7 +685,7 @@ for the Solidity compiler. In this form, it tries to achieve several goals:
3. Control flow should be easy to detect to help in formal verification and optimization.

In order to achieve the first and last goal, assembly provides high-level constructs
like ``for`` loops, ``switch`` statements and function calls. It should be possible
like ``for`` loops, ``if`` and ``switch`` statements and function calls. It should be possible
to write assembly programs that do not make use of explicit ``SWAP``, ``DUP``,
``JUMP`` and ``JUMPI`` statements, because the first two obfuscate the data flow
and the last two obfuscate control flow. Furthermore, functional statements of
Expand Down Expand Up @@ -875,6 +891,7 @@ Grammar::
FunctionalAssemblyAssignment |
AssemblyAssignment |
LabelDefinition |
AssemblyIf |
AssemblySwitch |
AssemblyFunctionDefinition |
AssemblyFor |
Expand All @@ -891,6 +908,7 @@ Grammar::
IdentifierList = Identifier ( ',' Identifier)*
AssemblyAssignment = '=:' Identifier
LabelDefinition = Identifier ':'
AssemblyIf = 'if' FunctionalAssemblyExpression AssemblyBlock
AssemblySwitch = 'switch' FunctionalAssemblyExpression AssemblyCase*
( 'default' AssemblyBlock )?
AssemblyCase = 'case' FunctionalAssemblyExpression AssemblyBlock
Expand Down
4 changes: 4 additions & 0 deletions docs/bugs_by_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@
"bugs": [],
"released": "2017-10-18"
},
"0.4.19": {
"bugs": [],
"released": "2017-11-30"
},
"0.4.2": {
"bugs": [
"ZeroFunctionSelector",
Expand Down
Loading

0 comments on commit c4cbbb0

Please sign in to comment.