diff options
-rw-r--r-- | docs/abi-spec.rst | 20 | ||||
-rw-r--r-- | docs/conf.py | 2 | ||||
-rw-r--r-- | docs/contracts.rst | 5 | ||||
-rwxr-xr-x | scripts/install_deps.sh | 2 | ||||
-rwxr-xr-x | test/cmdlineTests.sh | 98 |
5 files changed, 72 insertions, 55 deletions
diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 367bb965..2c01c4a1 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -609,7 +609,9 @@ Through ``abi.encodePacked()``, Solidity supports a non-standard packed mode whe - 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 ``int8, bytes1, uint16, string`` with values ``-1, 0x42, 0x2424, "Hello, world!"`` results in: +This packed mode is mainly used for indexed event parameters. + +As an example, the encoding of ``int8(-1), bytes1(0x42), uint16(0x2424), string("Hello, world!")`` results in: .. code-block:: none @@ -619,12 +621,18 @@ As an example encoding ``int8, bytes1, uint16, string`` with values ``-1, 0x42, ^^^^ 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. +More specifically: + - Each value type takes as many bytes as its range has. + - The encoding of a struct or fixed-size array is the concatenation of the + encoding of its members/elements without any separator or padding. + - Mapping members of structs are ignored as usual. + - Dynamically-sized types like ``string``, ``bytes`` or ``uint[]`` are encoded without + their length field. + +In general, the encoding is ambiguous as soon as there are two dynamically-sized elements, +because of the missing length field. If padding is needed, explicit type conversions can be used: ``abi.encodePacked(uint16(0x12)) == hex"0012"``. Since packed encoding is not used when calling functions, there is no special support -for prepending a function selector. +for prepending a function selector. Since the encoding is ambiguous, there is no decoding function. diff --git a/docs/conf.py b/docs/conf.py index 233ff7b6..08a5a045 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -53,7 +53,7 @@ master_doc = 'index' # General information about the project. project = 'Solidity' -copyright = '2016-2018, Ethereum' +copyright = '2016-2019, Ethereum' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/contracts.rst b/docs/contracts.rst index 682cb378..746f6e00 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -585,9 +585,8 @@ return variables and then using ``return;`` to leave the function. Returning Multiple Values ------------------------- -When a function has multiple return types, the statement ``return (v0, v1, ..., vn) can be used to return multiple values. -vn)`` can return multiple values. The number of components must be -the same as the number of return types. +When a function has multiple return types, the statement ``return (v0, v1, ..., vn)`` can be used to return multiple values. +The number of components must be the same as the number of return types. .. index:: ! view function, function;view diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index 09d5a249..0d1620c4 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -352,7 +352,7 @@ case $(uname -s) in # CentOS needs some more testing. This is the general idea of packages # needed, but some tweaking/improvements can definitely happen #------------------------------------------------------------------------------ - CentOS) + CentOS*) read -p "This script will heavily modify your system in order to allow for compilation of Solidity. Are you sure? [Y/N]" -n 1 -r if [[ $REPLY =~ ^[Yy]$ ]]; then # Make Sure we have the EPEL repos diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index 9d2ffa5f..fc84d8a0 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -100,17 +100,19 @@ printTask "Testing unknown options..." failed=$? set -e - if [ "$output" == "unrecognised option '--allow=test'" ] && [ $failed -ne 0 ] ; then - echo "Passed" + if [ "$output" == "unrecognised option '--allow=test'" ] && [ $failed -ne 0 ] + then + echo "Passed" else - printError "Incorrect response to unknown options: $STDERR" - exit 1 + printError "Incorrect response to unknown options: $STDERR" + exit 1 fi ) # General helper function for testing SOLC behaviour, based on file name, compile opts, exit code, stdout and stderr. # An failure is expected. -test_solc_behaviour() { +function test_solc_behaviour() +{ local filename="${1}" local solc_args="${2}" local solc_stdin="${3}" @@ -122,7 +124,8 @@ test_solc_behaviour() { if [[ "$exit_code_expected" = "" ]]; then exit_code_expected="0"; fi set +e - if [[ "$solc_stdin" = "" ]]; then + if [[ "$solc_stdin" = "" ]] + then "$SOLC" "${filename}" ${solc_args} 1>$stdout_path 2>$stderr_path else "$SOLC" "${filename}" ${solc_args} <$solc_stdin 1>$stdout_path 2>$stderr_path @@ -130,7 +133,8 @@ test_solc_behaviour() { exitCode=$? set -e - if [[ "$solc_args" == *"--standard-json"* ]]; then + if [[ "$solc_args" == *"--standard-json"* ]] + then sed -i -e 's/{[^{]*Warning: This is a pre-release compiler version[^}]*},\{0,1\}//' "$stdout_path" sed -i -e 's/"errors":\[\],\{0,1\}//' "$stdout_path" else @@ -138,13 +142,15 @@ test_solc_behaviour() { sed -i -e 's/ Consider adding "pragma .*$//' "$stderr_path" fi - if [[ $exitCode -ne "$exit_code_expected" ]]; then + if [[ $exitCode -ne "$exit_code_expected" ]] + then printError "Incorrect exit code. Expected $exit_code_expected but got $exitCode." rm -f $stdout_path $stderr_path exit 1 fi - if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]]; then + if [[ "$(cat $stdout_path)" != "${stdout_expected}" ]] + then printError "Incorrect output on stdout received. Expected:" echo -e "${stdout_expected}" @@ -154,7 +160,8 @@ test_solc_behaviour() { exit 1 fi - if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]]; then + if [[ "$(cat $stderr_path)" != "${stderr_expected}" ]] + then printError "Incorrect output on stderr received. Expected:" echo -e "${stderr_expected}" @@ -179,46 +186,43 @@ test_solc_behaviour "${0}" "ctx:=/some/remapping/target" "" "" 1 "Invalid remapp printTask "Running standard JSON commandline tests..." ( -cd "$REPO_ROOT"/test/cmdlineTests/ -for file in *.json -do - args="--standard-json" - stdin="$REPO_ROOT/test/cmdlineTests/$file" - stdout=$(cat $file.stdout 2>/dev/null || true) - exitCode=$(cat $file.exit 2>/dev/null || true) - err=$(cat $file.err 2>/dev/null || true) - printTask " - $file" - test_solc_behaviour "" "$args" "$stdin" "$stdout" "$exitCode" "$err" -done + cd "$REPO_ROOT"/test/cmdlineTests/ + for file in *.json + do + args="--standard-json" + stdin="$REPO_ROOT/test/cmdlineTests/$file" + stdout=$(cat $file.stdout 2>/dev/null || true) + exitCode=$(cat $file.exit 2>/dev/null || true) + err=$(cat $file.err 2>/dev/null || true) + printTask " - $file" + test_solc_behaviour "" "$args" "$stdin" "$stdout" "$exitCode" "$err" + done ) printTask "Running general commandline tests..." ( -cd "$REPO_ROOT"/test/cmdlineTests/ -for file in *.sol -do - args=$(cat $file.args 2>/dev/null || true) - stdout=$(cat $file.stdout 2>/dev/null || true) - exitCode=$(cat $file.exit 2>/dev/null || true) - err=$(cat $file.err 2>/dev/null || true) - printTask " - $file" - test_solc_behaviour "$file" "$args" "" "$stdout" "$exitCode" "$err" -done + cd "$REPO_ROOT"/test/cmdlineTests/ + for file in *.sol + do + args=$(cat $file.args 2>/dev/null || true) + stdout=$(cat $file.stdout 2>/dev/null || true) + exitCode=$(cat $file.exit 2>/dev/null || true) + err=$(cat $file.err 2>/dev/null || true) + printTask " - $file" + test_solc_behaviour "$file" "$args" "" "$stdout" "$exitCode" "$err" + done ) printTask "Compiling various other contracts and libraries..." ( -cd "$REPO_ROOT"/test/compilationTests/ -for dir in * -do - if [ "$dir" != "README.md" ] - then + cd "$REPO_ROOT"/test/compilationTests/ + for dir in */ + do echo " - $dir" cd "$dir" compileFull -w *.sol */*.sol cd .. - fi -done + done ) printTask "Compiling all examples from the documentation..." @@ -293,7 +297,8 @@ SOLTMPDIR=$(mktemp -d) ) rm -rf "$SOLTMPDIR" -test_solc_assembly_output() { +function test_solc_assembly_output() +{ local input="${1}" local expected="${2}" local solc_args="${3}" @@ -342,7 +347,8 @@ SOLTMPDIR=$(mktemp -d) set -e # This should fail - if [[ !("$output" =~ "No input files given") || ($result == 0) ]] ; then + if [[ !("$output" =~ "No input files given") || ($result == 0) ]] + then printError "Incorrect response to empty input arg list: $STDERR" exit 1 fi @@ -353,7 +359,8 @@ SOLTMPDIR=$(mktemp -d) set -e # The contract should be compiled - if [[ "$result" != 0 ]] ; then + if [[ "$result" != 0 ]] + then exit 1 fi @@ -361,7 +368,8 @@ SOLTMPDIR=$(mktemp -d) set +e output=$(echo '' | "$SOLC" --ast - 2>/dev/null) set -e - if [[ $? != 0 ]] ; then + if [[ $? != 0 ]] + then exit 1 fi ) @@ -379,14 +387,16 @@ SOLTMPDIR=$(mktemp -d) do set +e "$REPO_ROOT"/build/test/tools/solfuzzer --quiet < "$f" - if [ $? -ne 0 ]; then + if [ $? -ne 0 ] + then printError "Fuzzer failed on:" cat "$f" exit 1 fi "$REPO_ROOT"/build/test/tools/solfuzzer --without-optimizer --quiet < "$f" - if [ $? -ne 0 ]; then + if [ $? -ne 0 ] + then printError "Fuzzer (without optimizer) failed on:" cat "$f" exit 1 |