From 3791933765b70cf1574f38c0ed62759498beff4e Mon Sep 17 00:00:00 2001 From: jeancky Date: Tue, 23 Oct 2018 14:22:43 +0800 Subject: [PATCH 1/8] Update README.md --- README.md | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5dc5db804a18..8a5005208887 100644 --- a/README.md +++ b/README.md @@ -14,24 +14,41 @@ Solidity is still under development. So please do not hesitate and open an [issu See the [Solidity documentation](https://solidity.readthedocs.io/en/latest/installing-solidity.html#building-from-source) for build instructions. ``` Build for javascript + cd solidity + +# 1. Prepare to Build solcjson, assume your project dir is "/root/project/solidity" +# a. build from Ubuntu [Optional] docker run -it -v $(pwd):/root/project -w /root/project trzeci/emscripten:sdk-tag-1.35.4-64bit apt-get update apt-get install wget gcc boost +# b. build from macOS [Optional] + +# 2.a install essetial apt-get install -y build-essential +# 2.b if "2.a install build-essential" failed, please install Emscripten from this url: +https://github.com/juj/emsdk/tree/llvm_root + +# 3. check if boost is installed ./scripts/travis-emscripten/install_deps.sh + +# 4. begin to compile ./scripts/travis-emscripten/build_emscripten.sh +# 5. release soljson.js bash tran.sh + ``` ## Windows +``` https://solidity.readthedocs.io/en/latest/installing-solidity.html#building-from-source -安装vs2017 -安装cmake +# install vs2017 +# install cmake scripts\install_deps.bat 部分文件在中文windows下警告被看作错误,改一下文件编码,删除不用的测试就行了 mkdir build cd build cmake -G "Visual Studio 15 2017 Win64" .. cmake --build . --config RelWithDebInfo +``` From 6ae29c71dd6b9652133a67fcce99e16c3df0a6fc Mon Sep 17 00:00:00 2001 From: jeancky Date: Tue, 23 Oct 2018 14:55:21 +0800 Subject: [PATCH 2/8] Adapt soljson build script to MacOS --- .gitignore | 3 ++ scripts/install_cmake.sh | 6 +++- scripts/travis-emscripten/build_emscripten.sh | 29 +++++++++++++------ 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 97abdfe1f302..36dcffab43be 100644 --- a/.gitignore +++ b/.gitignore @@ -48,3 +48,6 @@ boost_1_57_0/ cmake-build-debug/ deps/ +soljson.js + + diff --git a/scripts/install_cmake.sh b/scripts/install_cmake.sh index e334b2c90644..d2b2d286d703 100755 --- a/scripts/install_cmake.sh +++ b/scripts/install_cmake.sh @@ -26,7 +26,11 @@ else FILE=cmake-$VERSION-$OS-x86_64.tar.gz URL=https://cmake.org/files/v3.7/$FILE ERROR=0 - TMPFILE=$(mktemp --tmpdir cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz) + if [ $OS == "Darwin" ];then + TMPFILE=$(mktemp -t cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz) + else + TMPFILE=$(mktemp --tmpdir cmake-$VERSION-$OS-x86_64.XXXXXXXX.tar.gz) + fi echo "Downloading CMake ($URL)..." wget "$URL" -O "$TMPFILE" -nv if ! (shasum -a256 "$TMPFILE" | grep -q "$SHA256"); then diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index 28274ac2fdd0..51e911ef2fee 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -34,6 +34,8 @@ set -ev +OS=`uname -s` + if ! type git &>/dev/null; then # We need git for extracting the commit hash apt-get update @@ -58,27 +60,36 @@ fi # Boost -echo -en 'travis_fold:start:compiling_boost\\r' +echo -en 'travis_fold:start:compiling_boost\r\n' cd "$WORKSPACE"/boost_1_57_0 # if b2 exists, it is a fresh checkout, otherwise it comes from the cache # and is already compiled test -e b2 && ( -sed -i 's|using gcc ;|using gcc : : em++ ;|g' ./project-config.jam -sed -i 's|$(archiver\[1\])|emar|g' ./tools/build/src/tools/gcc.jam -sed -i 's|$(ranlib\[1\])|emranlib|g' ./tools/build/src/tools/gcc.jam + +if [ $OS == "Darwin" ];then + # MacOS + sed -i '' 's|using gcc ;|using gcc : : em++ ;|g' ./project-config.jam + sed -i '' 's|$(archiver\[1\])|emar|g' ./tools/build/src/tools/gcc.jam + sed -i '' 's|$(ranlib\[1\])|emranlib|g' ./tools/build/src/tools/gcc.jam +else + # Linux and Other OS + sed -i 's|using gcc ;|using gcc : : em++ ;|g' ./project-config.jam + sed -i 's|$(archiver\[1\])|emar|g' ./tools/build/src/tools/gcc.jam + sed -i 's|$(ranlib\[1\])|emranlib|g' ./tools/build/src/tools/gcc.jam +fi ./b2 link=static variant=release threading=single runtime-link=static \ system regex filesystem unit_test_framework program_options find . -name 'libboost*.a' -exec cp {} . \; rm -rf b2 libs doc tools more bin.v2 status ) -echo -en 'travis_fold:end:compiling_boost\\r' +echo -en 'travis_fold:end:compiling_boost\r\n' -echo -en 'travis_fold:start:install_cmake.sh\\r' +echo -en 'travis_fold:start:install_cmake.sh\r\n' source $WORKSPACE/scripts/install_cmake.sh -echo -en 'travis_fold:end:install_cmake.sh\\r' +echo -en 'travis_fold:end:install_cmake.sh\r\n' # Build dependent components and solidity itself -echo -en 'travis_fold:start:compiling_solidity\\r' +echo -en 'travis_fold:start:compiling_solidity\r\n' cd $WORKSPACE mkdir -p build cd build @@ -113,4 +124,4 @@ OUTPUT_SIZE=`ls -la soljson.js` echo "Emscripten output size: $OUTPUT_SIZE" -echo -en 'travis_fold:end:compiling_solidity\\r' +echo -en 'travis_fold:end:compiling_solidity\r\n' From 8ea0d80402f7008d2b3b35de11dad2130edfc7bb Mon Sep 17 00:00:00 2001 From: jeancky Date: Tue, 23 Oct 2018 20:22:03 +0800 Subject: [PATCH 3/8] ready for solidity 0.4.25 for Tron --- .gitignore | 7 +- CMakeLists.txt | 2 +- Changelog.md | 19 ++- circle.yml | 18 +++ cmake/EthCompilerSettings.cmake | 11 -- cmake/jsoncpp.cmake | 22 ++-- docs/assembly.rst | 10 +- docs/bugs.json | 44 ++++++- docs/bugs.rst | 14 ++ docs/bugs_by_version.json | 120 +++++++++++++++++- docs/common-patterns.rst | 6 +- docs/contracts.rst | 28 ++-- docs/control-structures.rst | 14 +- docs/frequently-asked-questions.rst | 10 +- docs/index.rst | 2 +- docs/introduction-to-smart-contracts.rst | 12 +- docs/julia.rst | 8 +- docs/miscellaneous.rst | 10 +- docs/security-considerations.rst | 38 +++--- docs/solidity-by-example.rst | 6 +- docs/types.rst | 8 +- docs/units-and-global-variables.rst | 16 +-- docs/utils/SolidityLexer.py | 2 +- libsolidity/analysis/TypeChecker.cpp | 20 +++ libsolidity/parsing/Scanner.cpp | 84 +++++++----- libsolidity/parsing/Scanner.h | 7 +- libsolidity/parsing/Token.h | 2 +- scripts/release.bat | 9 +- scripts/travis-emscripten/build_emscripten.sh | 2 +- test/RPCSession.cpp | 18 +-- .../MultiSigWalletWithDailyLimit.sol | 4 +- .../MultiSigWalletWithDailyLimitFactory.sol | 2 +- .../gnosis/Tokens/EtherToken.sol | 10 +- .../zeppelin/crowdsale/Crowdsale.sol | 6 +- .../zeppelin/ownership/HasNoEther.sol | 10 +- .../zeppelin/ownership/NoOwner.sol | 2 +- test/contracts/LLL_ERC20.cpp | 4 +- test/libsolidity/SolidityEndToEndTest.cpp | 4 +- .../SolidityExpressionCompiler.cpp | 2 +- .../SolidityNameAndTypeResolution.cpp | 2 +- test/libsolidity/SolidityParser.cpp | 10 +- .../combining_hex_and_denomination.sol | 2 +- .../combining_hex_and_denomination_050.sol | 2 +- .../parsing/scientific_notation.sol | 2 +- 44 files changed, 425 insertions(+), 206 deletions(-) diff --git a/.gitignore b/.gitignore index 36dcffab43be..6049a6269293 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,7 @@ build/ docs/_build docs/utils/__pycache__ docs/utils/*.pyc +/deps/downloads/ # vim stuff *.swp @@ -43,11 +44,11 @@ docs/utils/*.pyc .idea browse.VC.db CMakeLists.txt.user - +/CMakeSettings.json boost_1_57_0/ cmake-build-debug/ deps/ - -soljson.js +/.vs +output/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c05208f2045..f30872af6412 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ include(EthPolicy) eth_policy() # project name and version should be set after cmake_policy CMP0048 -set(PROJECT_VERSION "0.4.24") +set(PROJECT_VERSION "0.4.25") project(solidity VERSION ${PROJECT_VERSION}) option(SOLC_LINK_STATIC "Link solc executable statically on supported platforms" OFF) diff --git a/Changelog.md b/Changelog.md index 0a5c0eac91c6..a7cea4f11fb8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,14 @@ +### 0.4.25 (2018-09-12) + +Important Bugfixes: + * Code Generator: Properly perform cleanup for exponentiation and non-256 bit types. + * Type Checker: Report error when using indexed structs in events with experimental ABIEncoderV2. This used to log wrong values. + * Type Checker: Report error when using structs in events without experimental ABIEncoderV2. This used to crash or log the wrong values. + * Parser: Consider all unicode line terminators (LF, VF, FF, CR, NEL, LS, PS) for single-line comments + and string literals. They are invalid in strings and will end comments. + * Parser: Disallow unterminated multi-line comments at the end of input. + * Parser: Treat ``/** /`` as unterminated multi-line comment. + ### 0.4.24 (2018-05-16) Language Features: @@ -361,7 +372,7 @@ Features: * Add ``assert(condition)``, which throws if condition is false (meant for internal errors). * Add ``require(condition)``, which throws if condition is false (meant for invalid input). * Commandline interface: Do not overwrite files unless forced. - * Introduce ``.transfer(value)`` for sending Ether. + * Introduce ``.transfer(value)`` for sending Trx. * Code generator: Support ``revert()`` to abort with rolling back, but not consuming all gas. * Inline assembly: Support ``revert`` (EIP140) as an opcode. * Parser: Support scientific notation in numbers (e.g. ``2e8`` and ``200e-2``). @@ -512,7 +523,7 @@ to explicitly specify if functions can receive trx via the ``payable`` modifier. Furthermore, more situations cause exceptions to be thrown. Minimal changes to be made for upgrade: - - Add ``payable`` to all functions that want to receive Ether + - Add ``payable`` to all functions that want to receive Trx (including the constructor and the fallback function). - Change ``_`` to ``_;`` in modifiers. - Add version pragma to each file: ``pragma solidity ^0.4.0;`` @@ -522,9 +533,9 @@ Breaking Changes: * Source files have to specify the compiler version they are compatible with using e.g. ``pragma solidity ^0.4.0;`` or ``pragma solidity >=0.4.0 <0.4.8;`` - * Functions that want to receive Ether have to specify the + * Functions that want to receive Trx have to specify the new ``payable`` modifier (otherwise they throw). - * Contracts that want to receive Ether with a plain "send" + * Contracts that want to receive Trx with a plain "send" have to implement a fallback function with the ``payable`` modifier. Contracts now throw if no payable fallback function is defined and no function matches the signature. diff --git a/circle.yml b/circle.yml index 4ce3082bf518..7c95fa7ff1f1 100644 --- a/circle.yml +++ b/circle.yml @@ -155,6 +155,23 @@ jobs: - store_artifacts: *solc_artifact - persist_to_workspace: *all_artifacts + test_buglist: + docker: + - image: circleci/node + environment: + TERM: xterm + steps: + - checkout + - run: + name: JS deps + command: | + npm install download + npm install JSONPath + npm install mktemp + - run: + name: Test buglist + command: ./test/buglistTests.js + test_x86_linux: docker: - image: buildpack-deps:artful @@ -217,6 +234,7 @@ workflows: version: 2 build_all: jobs: + - test_buglist: *build_on_tags - build_emscripten: *build_on_tags - test_emscripten_solcjs: <<: *build_on_tags diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 683d1d2e652f..3ae5bf2ab0a2 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -132,17 +132,6 @@ elseif (DEFINED MSVC) add_compile_options(-D_WIN32_WINNT=0x0600) # declare Windows Vista API requirement add_compile_options(-DNOMINMAX) # undefine windows.h MAX && MIN macros cause it cause conflicts with std::min && std::max functions - # Always use Release variant of C++ runtime. - # We don't want to provide Debug variants of all dependencies. Some default - # flags set by CMake must be tweaked. - string(REPLACE "/MDd" "/MD" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/MDd" "/MD" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "/D_DEBUG" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "/RTC1" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - set_property(GLOBAL PROPERTY DEBUG_CONFIGURATIONS OFF) - # disable empty object file warning set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") # warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification diff --git a/cmake/jsoncpp.cmake b/cmake/jsoncpp.cmake index 3d6b37edf947..ea3218efc31c 100644 --- a/cmake/jsoncpp.cmake +++ b/cmake/jsoncpp.cmake @@ -6,13 +6,20 @@ else() set(JSONCPP_CMAKE_COMMAND ${CMAKE_COMMAND}) endif() -include(GNUInstallDirs) set(prefix "${CMAKE_BINARY_DIR}/deps") -set(JSONCPP_LIBRARY "${prefix}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") +set(JSONCPP_LIBRARY "${prefix}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}jsoncpp${CMAKE_STATIC_LIBRARY_SUFFIX}") set(JSONCPP_INCLUDE_DIR "${prefix}/include") -if(NOT MSVC) - set(JSONCPP_EXTRA_FLAGS "-std=c++11") +# TODO: Investigate why this breaks some emscripten builds and +# check whether this can be removed after updating the emscripten +# versions used in the CI runs. +if(EMSCRIPTEN) + # Do not include all flags in CMAKE_CXX_FLAGS for emscripten, + # but only use -std=c++11. Using all flags causes build failures + # at the moment. + set(JSONCPP_CXX_FLAGS -std=c++11) +else() + set(JSONCPP_CXX_FLAGS ${CMAKE_CXX_FLAGS}) endif() set(byproducts "") @@ -30,14 +37,13 @@ ExternalProject_Add(jsoncpp-project CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_INSTALL_LIBDIR=lib # Build static lib but suitable to be included in a shared lib. -DCMAKE_POSITION_INDEPENDENT_CODE=${BUILD_SHARED_LIBS} -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF - -DCMAKE_CXX_FLAGS=${JSONCPP_EXTRA_FLAGS} - # Overwrite build and install commands to force Release build on MSVC. - BUILD_COMMAND cmake --build --config Release - INSTALL_COMMAND cmake --build --config Release --target install + -DCMAKE_CXX_FLAGS=${JSONCPP_CXX_FLAGS} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} ${byproducts} ) diff --git a/docs/assembly.rst b/docs/assembly.rst index 443cb7dac519..ec67f7963aca 100644 --- a/docs/assembly.rst +++ b/docs/assembly.rst @@ -250,11 +250,11 @@ In the grammar, opcodes are represented as pre-defined identifiers. +-------------------------+-----+---+-----------------------------------------------------------------+ | address | | F | address of the current contract / execution context | +-------------------------+-----+---+-----------------------------------------------------------------+ -| balance(a) | | F | wei balance at address a | +| balance(a) | | F | sun balance at address a | +-------------------------+-----+---+-----------------------------------------------------------------+ | caller | | F | call sender (excluding ``delegatecall``) | +-------------------------+-----+---+-----------------------------------------------------------------+ -| callvalue | | F | wei sent together with the current call | +| callvalue | | F | sun sent together with the current call | +-------------------------+-----+---+-----------------------------------------------------------------+ | calldataload(p) | | F | call data starting from position p (32 bytes) | +-------------------------+-----+---+-----------------------------------------------------------------+ @@ -274,15 +274,15 @@ In the grammar, opcodes are represented as pre-defined identifiers. +-------------------------+-----+---+-----------------------------------------------------------------+ | returndatacopy(t, f, s) | `-` | B | copy s bytes from returndata at position f to mem at position t | +-------------------------+-----+---+-----------------------------------------------------------------+ -| create(v, p, s) | | F | create new contract with code mem[p..(p+s)) and send v wei | +| create(v, p, s) | | F | create new contract with code mem[p..(p+s)) and send v sun | | | | | and return the new address | +-------------------------+-----+---+-----------------------------------------------------------------+ | create2(v, n, p, s) | | C | create new contract with code mem[p..(p+s)) at address | | | | | keccak256(
. n . keccak256(mem[p..(p+s))) and send v | -| | | | wei and return the new address | +| | | | sun and return the new address | +-------------------------+-----+---+-----------------------------------------------------------------+ | call(g, a, v, in, | | F | call contract at address a with input mem[in..(in+insize)) | -| insize, out, outsize) | | | providing g gas and v wei and output area | +| insize, out, outsize) | | | providing g gas and v sun and output area | | | | | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) | | | | | and 1 on success | +-------------------------+-----+---+-----------------------------------------------------------------+ diff --git a/docs/bugs.json b/docs/bugs.json index 2d76d2ff171d..60045dc8e1d0 100644 --- a/docs/bugs.json +++ b/docs/bugs.json @@ -1,4 +1,29 @@ [ + { + "name": "ExpExponentCleanup", + "summary": "Using the ** operator with an exponent of type shorter than 256 bits can result in unexpected values.", + "description": "Higher order bits in the exponent are not properly cleaned before the EXP opcode is applied if the type of the exponent expression is smaller than 256 bits and not smaller than the type of the base. In that case, the result might be larger than expected if the exponent is assumed to lie within the value range of the type. Literal numbers as exponents are unaffected as are exponents or bases of type uint256.", + "fixed": "0.4.25", + "severity": "medium/high", + "check": {"regex-source": "[^/]\\*\\* *[^/0-9 ]"} + }, + { + "name": "EventStructWrongData", + "summary": "Using structs in events logged wrong data.", + "description": "If a struct is used in an event, the address of the struct is logged instead of the actual data.", + "introduced": "0.4.17", + "fixed": "0.4.25", + "severity": "very low", + "check": {"ast-compact-json-path": "$..[?(@.nodeType === 'EventDefinition')]..[?(@.nodeType === 'UserDefinedTypeName' && @.typeDescriptions.typeString.startsWith('struct'))]"} + }, + { + "name": "PublicLibFunctionsDoNotReturnNestedArrays", + "summary": "Calls to public library functions (internal functions are safe) that return nested arrays return only zeroes.", + "description": "The compiler does not complain about public library functions (internal functions are safe) returning nested arrays, but it also does not return it correctly. Thus, the function caller receives only zeroes.", + "introduced": "0.4.11", + "fixed": "0.4.22", + "severity": "low" + }, { "name": "OneOfTwoConstructorsSkipped", "summary": "If a contract has both a new-style constructor (using the constructor keyword) and an old-style constructor (a function with the same name as the contract) at the same time, one of them will be ignored.", @@ -7,10 +32,19 @@ "fixed": "0.4.23", "severity": "very low" }, + { + "name": "NestedArrayFunctionCallDecoder", + "summary": "Calling functions that return multi-dimensional fixed-size arrays can result in memory corruption.", + "description": "If Solidity code calls a function that returns a multi-dimensional fixed-size array, array elements are incorrectly interpreted as memory pointers and thus can cause memory corruption if the return values are accessed. Calling functions with multi-dimensional fixed-size arrays is unaffected as is returning fixed-size arrays from function calls. The regular expression only checks if such functions are present, not if they are called, which is required for the contract to be affected.", + "introduced": "0.1.4", + "fixed": "0.4.22", + "severity": "medium", + "check": {"regex-source": "returns[^;{]*\\[\\s*[^\\] \\t\\r\\n\\v\\f][^\\]]*\\]\\s*\\[\\s*[^\\] \\t\\r\\n\\v\\f][^\\]]*\\][^{;]*[;{]"} + }, { "name": "ZeroFunctionSelector", "summary": "It is possible to craft the name of a function such that it is executed instead of the fallback function in very specific circumstances.", - "description": "If a function has a selector consisting only of zeros, is payable and part of a contract that does not have a fallback function and at most five external functions in total, this function is called instead of the fallback function if Ether is sent to the contract without data.", + "description": "If a function has a selector consisting only of zeros, is payable and part of a contract that does not have a fallback function and at most five external functions in total, this function is called instead of the fallback function if Trx is sent to the contract without data.", "fixed": "0.4.18", "severity": "very low" }, @@ -86,16 +120,16 @@ }, { "name": "LibrariesNotCallableFromPayableFunctions", - "summary": "Library functions threw an exception when called from a call that received Ether.", - "description": "Library functions are protected against sending them Ether through a call. Since the DELEGATECALL opcode forwards the information about how much Ether was sent with a call, the library function incorrectly assumed that Ether was sent to the library and threw an exception.", + "summary": "Library functions threw an exception when called from a call that received Trx.", + "description": "Library functions are protected against sending them Trx through a call. Since the DELEGATECALL opcode forwards the information about how much Trx was sent with a call, the library function incorrectly assumed that Trx was sent to the library and threw an exception.", "severity": "low", "introduced": "0.4.0", "fixed": "0.4.2" }, { "name": "SendFailsForZeroEther", - "summary": "The send function did not provide enough gas to the recipient if no Ether was sent with it.", - "description": "The recipient of an Ether transfer automatically receives a certain amount of gas from the EVM to handle the transfer. In the case of a zero-transfer, this gas is not provided which causes the recipient to throw an exception.", + "summary": "The send function did not provide enough gas to the recipient if no Trx was sent with it.", + "description": "The recipient of an Trx transfer automatically receives a certain amount of gas from the EVM to handle the transfer. In the case of a zero-transfer, this gas is not provided which causes the recipient to throw an exception.", "severity": "low", "fixed": "0.4.0" }, diff --git a/docs/bugs.rst b/docs/bugs.rst index 7629830df456..8e3382c8688d 100644 --- a/docs/bugs.rst +++ b/docs/bugs.rst @@ -56,6 +56,20 @@ conditions is an object that can contain a boolean value ``optimizer``, which means that the optimizer has to be switched on to enable the bug. If no conditions are given, assume that the bug is present. +check + This field contains different checks that can be used to determine + whether a smart contract + contains the bug or not. The first type of check are Javascript regular + expressions that are to be matched against the source code ("source-regex"). + If there is no match, then the bug is very likely + not present. If there is a match, the bug might be present. For improved + accuracy, the checks should be applied to the source code after stripping + comments. + The second type of check are patterns to be applied to the compact AST of + the Solidity program ("ast-compact-json-path"). The specified search query + is a `JsonPath `_ expression. + If at least one path of the Solidity AST matches the query, the bug is + likely present. .. literalinclude:: bugs.json :language: js diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index 2fe1d22660e6..ef0846606a3c 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -1,6 +1,7 @@ { "0.1.0": { "bugs": [ + "ExpExponentCleanup", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -18,6 +19,7 @@ }, "0.1.1": { "bugs": [ + "ExpExponentCleanup", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -35,6 +37,7 @@ }, "0.1.2": { "bugs": [ + "ExpExponentCleanup", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -52,6 +55,7 @@ }, "0.1.3": { "bugs": [ + "ExpExponentCleanup", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -69,6 +73,8 @@ }, "0.1.4": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -86,6 +92,8 @@ }, "0.1.5": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -103,6 +111,8 @@ }, "0.1.6": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -121,6 +131,8 @@ }, "0.1.7": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -139,6 +151,8 @@ }, "0.2.0": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -157,6 +171,8 @@ }, "0.2.1": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -175,6 +191,8 @@ }, "0.2.2": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "ECRecoverMalformedInput", "SkipEmptyStringLiteral", @@ -193,6 +211,8 @@ }, "0.3.0": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -211,6 +231,8 @@ }, "0.3.1": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -228,6 +250,8 @@ }, "0.3.2": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -245,6 +269,8 @@ }, "0.3.3": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -261,6 +287,8 @@ }, "0.3.4": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -277,6 +305,8 @@ }, "0.3.5": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -293,6 +323,8 @@ }, "0.3.6": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -307,6 +339,8 @@ }, "0.4.0": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -321,6 +355,8 @@ }, "0.4.1": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -335,6 +371,8 @@ }, "0.4.10": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -345,6 +383,9 @@ }, "0.4.11": { "bugs": [ + "ExpExponentCleanup", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -354,6 +395,9 @@ }, "0.4.12": { "bugs": [ + "ExpExponentCleanup", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput" @@ -362,6 +406,9 @@ }, "0.4.13": { "bugs": [ + "ExpExponentCleanup", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput" @@ -370,6 +417,9 @@ }, "0.4.14": { "bugs": [ + "ExpExponentCleanup", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue" ], @@ -377,32 +427,54 @@ }, "0.4.15": { "bugs": [ + "ExpExponentCleanup", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector" ], "released": "2017-08-08" }, "0.4.16": { "bugs": [ + "ExpExponentCleanup", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector" ], "released": "2017-08-24" }, "0.4.17": { "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector" ], "released": "2017-09-21" }, "0.4.18": { - "bugs": [], + "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder" + ], "released": "2017-10-18" }, "0.4.19": { - "bugs": [], + "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder" + ], "released": "2017-11-30" }, "0.4.2": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -415,29 +487,53 @@ "released": "2016-09-17" }, "0.4.20": { - "bugs": [], + "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder" + ], "released": "2018-02-14" }, "0.4.21": { - "bugs": [], + "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData", + "PublicLibFunctionsDoNotReturnNestedArrays", + "NestedArrayFunctionCallDecoder" + ], "released": "2018-03-07" }, "0.4.22": { "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData", "OneOfTwoConstructorsSkipped" ], "released": "2018-04-16" }, "0.4.23": { - "bugs": [], + "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData" + ], "released": "2018-04-19" }, "0.4.24": { - "bugs": [], + "bugs": [ + "ExpExponentCleanup", + "EventStructWrongData" + ], "released": "2018-05-16" }, + "0.4.25": { + "bugs": [], + "released": "2018-09-12" + }, "0.4.3": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -450,6 +546,8 @@ }, "0.4.4": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -461,6 +559,8 @@ }, "0.4.5": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -473,6 +573,8 @@ }, "0.4.6": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -484,6 +586,8 @@ }, "0.4.7": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -494,6 +598,8 @@ }, "0.4.8": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", @@ -504,6 +610,8 @@ }, "0.4.9": { "bugs": [ + "ExpExponentCleanup", + "NestedArrayFunctionCallDecoder", "ZeroFunctionSelector", "DelegateCallReturnValue", "ECRecoverMalformedInput", diff --git a/docs/common-patterns.rst b/docs/common-patterns.rst index aa01925c6403..07b03cdf6043 100644 --- a/docs/common-patterns.rst +++ b/docs/common-patterns.rst @@ -12,7 +12,7 @@ Withdrawal from Contracts The recommended method of sending funds after an effect is using the withdrawal pattern. Although the most intuitive -method of sending Ether, as a result of an effect, is a +method of sending Trx, as a result of an effect, is a direct ``send`` call, this is not recommended as it introduces a potential security risk. You may read more about this on the :ref:`security_considerations` page. @@ -20,7 +20,7 @@ more about this on the :ref:`security_considerations` page. This is an example of the withdrawal pattern in practice in a contract where the goal is to send the most money to the contract in order to become the "richest", inspired by -`King of the Ether `_. +`King of the Trx `_. In the following contract, if you are usurped as the richest, you will receive the funds of the person who has gone on to @@ -194,7 +194,7 @@ restrictions highly readable. modifier costs(uint _amount) { require( msg.value >= _amount, - "Not enough Ether provided." + "Not enough Trx provided." ); _; if (msg.value > _amount) diff --git a/docs/contracts.rst b/docs/contracts.rst index 746695476fd0..afc53091e825 100644 --- a/docs/contracts.rst +++ b/docs/contracts.rst @@ -350,7 +350,7 @@ inheritable properties of contracts and may be overridden by derived contracts. // It is important to also provide the // `payable` keyword here, otherwise the function will - // automatically reject all Ether sent to it. + // automatically reject all Trx sent to it. function register() public payable costs(price) { registeredAddresses[msg.sender] = true; } @@ -457,7 +457,7 @@ The following statements are considered modifying the state: #. :ref:`Emitting events `. #. :ref:`Creating other contracts `. #. Using ``selfdestruct``. -#. Sending Ether via calls. +#. Sending Trx via calls. #. Calling any function not marked ``view`` or ``pure``. #. Using low-level calls. #. Using inline assembly that contains certain opcodes. @@ -544,16 +544,16 @@ functions match the given function identifier (or if no data was supplied at all). Furthermore, this function is executed whenever the contract receives plain -Ether (without data). Additionally, in order to receive Ether, the fallback function +Trx (without data). Additionally, in order to receive Trx, the fallback function must be marked ``payable``. If no such function exists, the contract cannot receive -Ether through regular transactions. +Trx through regular transactions. In the worst case, the fallback function can only rely on 2300 gas being available (for example when send or transfer is used), leaving not much room to perform other operations except basic logging. The following operations will consume more gas than the 2300 gas stipend: - Writing to storage - Creating a contract - Calling an external function which consumes a large amount of gas -- Sending Ether +- Sending Trx Like any function, the fallback function can execute complex operations as long as there is enough gas passed on to it. @@ -562,17 +562,17 @@ Like any function, the fallback function can execute complex operations as long any payload supplied with the call. .. warning:: - Contracts that receive Ether directly (without a function call, i.e. using ``send`` or ``transfer``) + Contracts that receive Trx directly (without a function call, i.e. using ``send`` or ``transfer``) but do not define a fallback function - throw an exception, sending back the Ether (this was different - before Solidity v0.4.0). So if you want your contract to receive Ether, + throw an exception, sending back the Trx (this was different + before Solidity v0.4.0). So if you want your contract to receive Trx, you have to implement a fallback function. .. warning:: - A contract without a payable fallback function can receive Ether as a recipient of a `coinbase transaction` (aka `miner block reward`) + A contract without a payable fallback function can receive Trx as a recipient of a `coinbase transaction` (aka `miner block reward`) or as a destination of a ``selfdestruct``. - A contract cannot react to such Ether transfers and thus also cannot reject them. This is a design choice of the EVM and Solidity cannot work around it. + A contract cannot react to such Trx transfers and thus also cannot reject them. This is a design choice of the EVM and Solidity cannot work around it. It also means that ``this.balance`` can be higher than the sum of some manual accounting implemented in a contract (i.e. having a counter updated in the fallback function). @@ -583,7 +583,7 @@ Like any function, the fallback function can execute complex operations as long contract Test { // This function is called for all messages sent to // this contract (there is no other function). - // Sending Ether to this contract will cause an exception, + // Sending Trx to this contract will cause an exception, // because the fallback function does not have the `payable` // modifier. function() public { x = 1; } @@ -591,7 +591,7 @@ Like any function, the fallback function can execute complex operations as long } - // This contract keeps all Ether sent to it with no way + // This contract keeps all Trx sent to it with no way // to get it back. contract Sink { function() public payable { } @@ -605,7 +605,7 @@ Like any function, the fallback function can execute complex operations as long // The following will not compile, but even // if someone sends trx to that contract, // the transaction will fail and reject the - // Ether. + // Trx. //test.send(2 trx); } } @@ -1363,7 +1363,7 @@ Restrictions for libraries in comparison to contracts: - No state variables - Cannot inherit nor be inherited -- Cannot receive Ether +- Cannot receive Trx (These might be lifted at a later point.) diff --git a/docs/control-structures.rst b/docs/control-structures.rst index e8c6cbe9796d..0e824ef9b54d 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -123,7 +123,7 @@ actual contract has not been created yet. Functions of other contracts have to be called externally. For an external call, all function arguments have to be copied to memory. -When calling functions of other contracts, the amount of Wei sent with the call and +When calling functions of other contracts, the amount of sun sent with the call and the gas can be specified with special options ``.value()`` and ``.gas()``, respectively:: pragma solidity ^0.4.0; @@ -247,7 +247,7 @@ creation-dependencies are not possible. } } -As seen in the example, it is possible to forward Ether while creating +As seen in the example, it is possible to forward Trx while creating an instance of ``D`` using the ``.value()`` option, but it is not possible to limit the amount of gas. If the creation fails (due to out-of-stack, not enough balance or other problems), @@ -510,8 +510,8 @@ A ``require``-style exception is generated in the following situations: #. If you call a function via a message call but it does not finish properly (i.e. it runs out of gas, has no matching function, or throws an exception itself), except when a low level operation ``call``, ``send``, ``delegatecall`` or ``callcode`` is used. The low level operations never throw exceptions but indicate failures by returning ``false``. #. If you create a contract using the ``new`` keyword but the contract creation does not finish properly (see above for the definition of "not finish properly"). #. If you perform an external function call targeting a contract that contains no code. -#. If your contract receives Ether via a public function without ``payable`` modifier (including the constructor and the fallback function). -#. If your contract receives Ether via a public getter function. +#. If your contract receives Trx via a public function without ``payable`` modifier (including the constructor and the fallback function). +#. If your contract receives Trx via a public getter function. #. If a ``.transfer()`` fails. Internally, Solidity performs a revert operation (instruction ``0xfd``) for a ``require``-style exception and executes an invalid operation @@ -530,18 +530,18 @@ The following example shows how an error string can be used together with revert contract VendingMachine { function buy(uint amount) payable { if (amount > msg.value / 2 trx) - revert("Not enough Ether provided."); + revert("Not enough Trx provided."); // Alternative way to do it: require( amount <= msg.value / 2 trx, - "Not enough Ether provided." + "Not enough Trx provided." ); // Perform the purchase. } } The provided string will be :ref:`abi-encoded ` as if it were a call to a function ``Error(string)``. -In the above example, ``revert("Not enough Ether provided.");`` will cause the following hexadecimal data be +In the above example, ``revert("Not enough Trx provided.");`` will cause the following hexadecimal data be set as error return data: .. code:: diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index f6fed48ab686..5ce8a9b671c2 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -45,7 +45,7 @@ Create a contract that can be killed and return funds First, a word of warning: Killing contracts sounds like a good idea, because "cleaning up" is always good, but as seen above, it does not really clean up. Furthermore, -if Ether is sent to removed contracts, the Ether will be forever lost. +if Trx is sent to removed contracts, the Trx will be forever lost. If you want to deactivate your contracts, it is preferable to **disable** them by changing some internal state which causes all functions to throw. This will make it impossible @@ -247,7 +247,7 @@ Is it possible to get a tx receipt for a transaction executed contract-to-contra No, a function call from one contract to another does not create its own transaction, you have to look in the overall transaction. This is also the reason why several -block explorer do not show Ether sent between contracts correctly. +block explorer do not show Trx sent between contracts correctly. What is the ``memory`` keyword? What does it do? ================================================ @@ -417,7 +417,7 @@ This is a very interesting question. Suppose that we have a contract field set u In this case, the mapping of the struct being copied over into the userList is ignored as there is no "list of mapped keys". Therefore it is not possible to find out which values should be copied over. -How do I initialize a contract with only a specific amount of wei? +How do I initialize a contract with only a specific amount of sun? ================================================================== Currently the approach is a little ugly, but there is little that can be done to improve it. @@ -436,7 +436,7 @@ In this example:: address child; function test() public { - child = (new B).value(10)(); //construct a new B with 10 wei + child = (new B).value(10)(); //construct a new B with 10 sun } } @@ -557,7 +557,7 @@ individual elements. If you want to return the complete array, you have to manually write a function to do that. -What could have happened if an account has storage value(s) but no code? Example: http://test.trx.camp/account/5f740b3a43fbb99724ce93a879805f4dc89178b5 +What could have happened if an account has storage value(s) but no code? Example: http://test.tron.org/account/5f740b3a43fbb99724ce93a879805f4dc89178b5 ========================================================================================================================================================== The last thing a constructor does is returning the code of the contract. diff --git a/docs/index.rst b/docs/index.rst index 4a6b203e0416..ed3e756bcc41 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -104,7 +104,7 @@ Discontinued: * `Mix IDE `_ Qt based IDE for designing, debugging and testing solidity smart contracts. -* `Ethereum Studio `_ +* `Ethereum Studio `_ Specialized web IDE that also provides shell access to a complete Ethereum environment. Solidity Tools diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index d1789c4477e7..0faf1488dbbf 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -301,8 +301,8 @@ Every account has a persistent key-value store mapping 256-bit words to 256-bit words called **storage**. Furthermore, every account has a **balance** in -Ether (in "Wei" to be exact) which can be modified by sending transactions that -include Ether. +Trx (in "sun" to be exact) which can be modified by sending transactions that +include Trx. .. index:: ! transaction @@ -311,7 +311,7 @@ Transactions A transaction is a message that is sent from one account to another account (which might be the same or the special zero-account, see below). -It can include binary data (its payload) and Ether. +It can include binary data (its payload) and Trx. If the target account contains code, that code is executed and the payload is provided as input data. @@ -403,10 +403,10 @@ like its number and timestamp. Message Calls ============= -Contracts can call other contracts or send Ether to non-contract +Contracts can call other contracts or send Trx to non-contract accounts by the means of message calls. Message calls are similar to transactions, in that they have a source, a target, data payload, -Ether, gas and return data. In fact, every transaction consists of +Trx, gas and return data. In fact, every transaction consists of a top-level message call which in turn can create further message calls. A contract can decide how much of its remaining **gas** should be sent @@ -477,7 +477,7 @@ Self-destruct The only possibility that code is removed from the blockchain is when a contract at that address performs the ``selfdestruct`` operation. -The remaining Ether stored at that address is sent to a designated +The remaining Trx stored at that address is sent to a designated target and then the storage and code is removed from the state. .. warning:: Even if a contract's code does not contain a call to ``selfdestruct``, diff --git a/docs/julia.rst b/docs/julia.rst index c9b73db226f1..ee2a399f8931 100644 --- a/docs/julia.rst +++ b/docs/julia.rst @@ -411,11 +411,11 @@ The following functions must be available: +---------------------------------------------+-----------------------------------------------------------------+ | *Execution control* | +---------------------------------------------+-----------------------------------------------------------------+ -| create(v:u256, p:u256, s:u256) | create new contract with code mem[p..(p+s)) and send v wei | +| create(v:u256, p:u256, s:u256) | create new contract with code mem[p..(p+s)) and send v sun | | | and return the new address | +---------------------------------------------+-----------------------------------------------------------------+ | call(g:u256, a:u256, v:u256, in:u256, | call contract at address a with input mem[in..(in+insize)) | -| insize:u256, out:u256, | providing g gas and v wei and output area | +| insize:u256, out:u256, | providing g gas and v sun and output area | | outsize:u256) | mem[out..(out+outsize)) returning 0 on error (eg. out of gas) | | -> r:u256 | and 1 on success | +---------------------------------------------+-----------------------------------------------------------------+ @@ -467,13 +467,13 @@ The following functions must be available: +---------------------------------------------+-----------------------------------------------------------------+ | gasleft() -> gas:u256 | gas still available to execution | +---------------------------------------------+-----------------------------------------------------------------+ -| balance(a:u256) -> v:u256 | wei balance at address a | +| balance(a:u256) -> v:u256 | sun balance at address a | +---------------------------------------------+-----------------------------------------------------------------+ | this() -> address:u256 | address of the current contract / execution context | +---------------------------------------------+-----------------------------------------------------------------+ | caller() -> address:u256 | call sender (excluding delegatecall) | +---------------------------------------------+-----------------------------------------------------------------+ -| callvalue() -> v:u256 | wei sent together with the current call | +| callvalue() -> v:u256 | sun sent together with the current call | +---------------------------------------------+-----------------------------------------------------------------+ | calldataload(p:u256) -> v:u256 | call data starting from position p (32 bytes) | +---------------------------------------------+-----------------------------------------------------------------+ diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index c7c3252855df..4475ad414223 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -332,7 +332,7 @@ Global Variables - ``msg.data`` (``bytes``): complete calldata - ``msg.gas`` (``uint``): remaining gas - deprecated in version 0.4.21 and to be replaced by ``gasleft()`` - ``msg.sender`` (``address``): sender of the message (current call) -- ``msg.value`` (``uint``): number of wei sent with the message +- ``msg.value`` (``uint``): number of sun sent with the message - ``now`` (``uint``): current block timestamp (alias for ``block.timestamp``) - ``tx.gasprice`` (``uint``): gas price of the transaction - ``tx.origin`` (``address``): sender of the transaction (full call chain) @@ -353,9 +353,9 @@ Global Variables - ``super``: the contract one level higher in the inheritance hierarchy - ``selfdestruct(address recipient)``: destroy the current contract, sending its funds to the given address - ``suicide(address recipient)``: a deprecated alias to ``selfdestruct`` -- ``
.balance`` (``uint256``): balance of the :ref:`address` in Wei -- ``
.send(uint256 amount) returns (bool)``: send given amount of Wei to :ref:`address`, returns ``false`` on failure -- ``
.transfer(uint256 amount)``: send given amount of Wei to :ref:`address`, throws on failure +- ``
.balance`` (``uint256``): balance of the :ref:`address` in sun +- ``
.send(uint256 amount) returns (bool)``: send given amount of sun to :ref:`address`, returns ``false`` on failure +- ``
.transfer(uint256 amount)``: send given amount of sun to :ref:`address`, throws on failure .. note:: Do not rely on ``block.timestamp``, ``now`` and ``blockhash`` as a source of randomness, @@ -398,7 +398,7 @@ Modifiers - ``pure`` for functions: Disallows modification or access of state - this is not enforced yet. - ``view`` for functions: Disallows modification of state - this is not enforced yet. -- ``payable`` for functions: Allows them to receive Ether together with a call. +- ``payable`` for functions: Allows them to receive Trx together with a call. - ``constant`` for state variables: Disallows assignment (except initialisation), does not occupy storage slot. - ``constant`` for functions: Same as ``view``. - ``anonymous`` for events: Does not store event signature as topic. diff --git a/docs/security-considerations.rst b/docs/security-considerations.rst index 1aa1314f91fe..38ffd53086eb 100644 --- a/docs/security-considerations.rst +++ b/docs/security-considerations.rst @@ -48,7 +48,7 @@ Re-Entrancy =========== Any interaction from a contract (A) with another contract (B) and any transfer -of Ether hands over control to that contract (B). This makes it possible for B +of Trx hands over control to that contract (B). This makes it possible for B to call back into A before this interaction is completed. To give an example, the following code contains a bug (it is just a snippet and not a complete contract): @@ -69,10 +69,10 @@ complete contract): } The problem is not too serious here because of the limited gas as part -of ``send``, but it still exposes a weakness: Ether transfer can always +of ``send``, but it still exposes a weakness: Trx transfer can always include code execution, so the recipient could be a contract that calls back into ``withdraw``. This would let it get multiple refunds and -basically retrieve all the Ether in the contract. In particular, the +basically retrieve all the Trx in the contract. In particular, the following contract will allow an attacker to refund multiple times as it uses ``call`` which forwards all remaining gas by default: @@ -109,7 +109,7 @@ outlined further below: } } -Note that re-entrancy is not only an effect of Ether transfer but of any +Note that re-entrancy is not only an effect of Trx 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 state of another contract you depend on. @@ -124,19 +124,19 @@ contract to be stalled at a certain point. This may not apply to ``view`` functi to read data from the blockchain. Still, such functions may be called by other contracts as part of on-chain operations and stall those. Please be explicit about such cases in the documentation of your contracts. -Sending and Receiving Ether +Sending and Receiving Trx =========================== -- Neither contracts nor "external accounts" are currently able to prevent that someone sends them Ether. +- Neither contracts nor "external accounts" are currently able to prevent that someone sends them Trx. Contracts can react on and reject a regular transfer, but there are ways - to move Ether without creating a message call. One way is to simply "mine to" + to move Trx without creating a message call. One way is to simply "mine to" the contract address and the second way is using ``selfdestruct(x)``. -- If a contract receives Ether (without a function being called), the fallback function is executed. - If it does not have a fallback function, the Ether will be rejected (by throwing an exception). +- If a contract receives Trx (without a function being called), the fallback function is executed. + If it does not have a fallback function, the Trx will be rejected (by throwing an exception). During the execution of the fallback function, the contract can only rely on the "gas stipend" (2300 gas) being available to it at that time. This stipend is not enough to access storage in any way. - To be sure that your contract can receive Ether in that way, check the gas requirements of the fallback function + To be sure that your contract can receive Trx in that way, check the gas requirements of the fallback function (for example in the "details" section in Remix). - There is a way to forward more gas to the receiving contract using @@ -147,13 +147,13 @@ Sending and Receiving Ether into the sending contract or other state changes you might not have thought of. So it allows for great flexibility for honest users but also for malicious actors. -- If you want to send Ether using ``address.transfer``, there are certain details to be aware of: +- If you want to send Trx using ``address.transfer``, there are certain details to be aware of: 1. If the recipient is a contract, it causes its fallback function to be executed which can, in turn, call back the sending contract. - 2. Sending Ether can fail due to the call depth going above 1024. Since the caller is in total control of the call + 2. Sending Trx can fail due to the call depth going above 1024. Since the caller is in total control of the call depth, they can force the transfer to fail; take this possibility into account or use ``send`` and make sure to always check its return value. Better yet, - write your contract using a pattern where the recipient can withdraw Ether instead. - 3. Sending Ether can also fail because the execution of the recipient contract + write your contract using a pattern where the recipient can withdraw Trx instead. + 3. Sending Trx can also fail because the execution of the recipient contract requires more than the allotted amount of gas (explicitly by using ``require``, ``assert``, ``revert``, ``throw`` or because the operation is just too expensive) - it "runs out of gas" (OOG). @@ -252,12 +252,12 @@ way risky, it is just a way to enable some features that are not yet part of the latest version of Solidity due to backwards compatibility. -Restrict the Amount of Ether +Restrict the Amount of Trx ============================ -Restrict the amount of Ether (or other tokens) that can be stored in a smart +Restrict the amount of Trx (or other tokens) that can be stored in a smart contract. If your source code, the compiler or the platform has a bug, these -funds may be lost. If you want to limit your loss, limit the amount of Ether. +funds may be lost. If you want to limit your loss, limit the amount of Trx. Keep it Small and Modular ========================= @@ -272,7 +272,7 @@ Use the Checks-Effects-Interactions Pattern =========================================== Most functions will first perform some checks (who called the function, -are the arguments in range, did they send enough Ether, does the person +are the arguments in range, did they send enough Trx, does the person have tokens, etc.). These checks should be done first. As the second step, if all checks passed, effects to the state variables @@ -294,7 +294,7 @@ it might be a good idea, especially for new code, to include some kind of fail-safe mechanism: You can add a function in your smart contract that performs some -self-checks like "Has any Ether leaked?", +self-checks like "Has any Trx leaked?", "Is the sum of the tokens equal to the balance of the contract?" or similar things. Keep in mind that you cannot use too much gas for that, so help through off-chain computations might be needed there. diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index c0ad595fe6c9..5de12cce0214 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -89,7 +89,7 @@ of votes. function giveRightToVote(address voter) public { // If the first argument of `require` evaluates // to `false`, execution terminates and all - // changes to the state and to Ether balances + // changes to the state and to Trx balances // are reverted. // This used to consume all gas in old EVM versions, but // not anymore. @@ -273,7 +273,7 @@ activate themselves. // information is already part of // the transaction. The keyword payable // is required for the function to - // be able to receive Ether. + // be able to receive Trx. // Revert the call if the bidding // period is over. @@ -324,7 +324,7 @@ activate themselves. /// to the beneficiary. function auctionEnd() public { // It is a good guideline to structure functions that interact - // with other contracts (i.e. they call functions or send Ether) + // with other contracts (i.e. they call functions or send Trx) // into three phases: // 1. checking conditions // 2. performing actions (potentially changing conditions) diff --git a/docs/types.rst b/docs/types.rst index fb249983820c..b80d1c87cb8b 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -120,7 +120,7 @@ Members of Addresses For a quick reference, see :ref:`address_related`. It is possible to query the balance of an address using the property ``balance`` -and to send Ether (in units of wei) to an address using the ``transfer`` function: +and to send Trx (in units of sun) to an address using the ``transfer`` function: :: @@ -129,7 +129,7 @@ and to send Ether (in units of wei) to an address using the ``transfer`` functio if (x.balance < 10 && myAddress.balance >= 10) x.transfer(10); .. note:: - If ``x`` is a contract address, its code (more specifically: its fallback function, if present) will be executed together with the ``transfer`` call (this is a feature of the EVM and cannot be prevented). If that execution runs out of gas or fails in any way, the Ether transfer will be reverted and the current contract will stop with an exception. + If ``x`` is a contract address, its code (more specifically: its fallback function, if present) will be executed together with the ``transfer`` call (this is a feature of the EVM and cannot be prevented). If that execution runs out of gas or fails in any way, the Trx transfer will be reverted and the current contract will stop with an exception. * ``send`` @@ -138,7 +138,7 @@ Send is the low-level counterpart of ``transfer``. If the execution fails, the c .. warning:: There are some dangers in using ``send``: The transfer fails if the call stack depth is at 1024 (this can always be forced by the caller) and it also fails if the recipient runs out of gas. So in order - to make safe Ether transfers, always check the return value of ``send``, use ``transfer`` or even better: + to make safe Trx transfers, always check the return value of ``send``, use ``transfer`` or even better: use a pattern where the recipient withdraws the money. * ``call``, ``callcode`` and ``delegatecall`` @@ -158,7 +158,7 @@ It is possible to adjust the supplied gas with the ``.gas()`` modifier:: namReg.call.gas(1000000)("register", "MyName"); -Similarly, the supplied Ether value can be controlled too:: +Similarly, the supplied Trx value can be controlled too:: nameReg.call.value(1 trx)("register", "MyName"); diff --git a/docs/units-and-global-variables.rst b/docs/units-and-global-variables.rst index c3b4ef5c10e5..454a63ea51b9 100644 --- a/docs/units-and-global-variables.rst +++ b/docs/units-and-global-variables.rst @@ -4,10 +4,10 @@ Units and Globally Available Variables .. index:: sun, trx -Ether Units +Trx Units =========== -A literal number can take a suffix of ``sun`` or ``trx`` to convert between the subdenominations of Ether, where Ether currency numbers without a postfix are assumed to be Wei, e.g. ``2 trx == 2000000 sun`` evaluates to ``true``. +A literal number can take a suffix of ``sun`` or ``trx`` to convert between the subdenominations of Trx, where Trx currency numbers without a postfix are assumed to be sun, e.g. ``2 trx == 2000000 sun`` evaluates to ``true``. .. index:: time, seconds, minutes, hours, days, weeks, years @@ -67,7 +67,7 @@ Block and Transaction Properties - ``msg.gas`` (``uint``): remaining gas - deprecated in version 0.4.21 and to be replaced by ``gasleft()`` - ``msg.sender`` (``address``): sender of the message (current call) - ``msg.sig`` (``bytes4``): first four bytes of the calldata (i.e. function identifier) -- ``msg.value`` (``uint``): number of wei sent with the message +- ``msg.value`` (``uint``): number of sun sent with the message - ``now`` (``uint``): current block timestamp (alias for ``block.timestamp``) - ``tx.gasprice`` (``uint``): gas price of the transaction - ``tx.origin`` (``address``): sender of the transaction (full call chain) @@ -167,7 +167,7 @@ Note that constants will be packed using the minimum number of bytes required to This means that, for example, ``keccak256(0) == keccak256(uint8(0))`` and ``keccak256(0x12345678) == keccak256(uint32(0x12345678))``. -It might be that you run into Out-of-Gas for ``sha256``, ``ripemd160`` or ``ecrecover`` on a *private blockchain*. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 Wei to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net. +It might be that you run into Out-of-Gas for ``sha256``, ``ripemd160`` or ``ecrecover`` on a *private blockchain*. The reason for this is that those are implemented as so-called precompiled contracts and these contracts only really exist after they received the first message (although their contract code is hardcoded). Messages to non-existing contracts are more expensive and thus the execution runs into an Out-of-Gas error. A workaround for this problem is to first send e.g. 1 sun to each of the contracts before you use them in your actual contracts. This is not an issue on the official or test net. .. index:: balance, send, transfer, call, callcode, delegatecall .. _address_related: @@ -176,11 +176,11 @@ Address Related --------------- ``
.balance`` (``uint256``): - balance of the :ref:`address` in Wei + balance of the :ref:`address` in sun ``
.transfer(uint256 amount)``: - send given amount of Wei to :ref:`address`, throws on failure, forwards 2300 gas stipend, not adjustable + send given amount of sun to :ref:`address`, throws on failure, forwards 2300 gas stipend, not adjustable ``
.send(uint256 amount) returns (bool)``: - send given amount of Wei to :ref:`address`, returns ``false`` on failure, forwards 2300 gas stipend, not adjustable + send given amount of sun to :ref:`address`, returns ``false`` on failure, forwards 2300 gas stipend, not adjustable ``
.call(...) returns (bool)``: issue low-level ``CALL``, returns ``false`` on failure, forwards all available gas, adjustable ``
.callcode(...) returns (bool)``: @@ -193,7 +193,7 @@ For more information, see the section on :ref:`address`. .. warning:: There are some dangers in using ``send``: The transfer fails if the call stack depth is at 1024 (this can always be forced by the caller) and it also fails if the recipient runs out of gas. So in order - to make safe Ether transfers, always check the return value of ``send``, use ``transfer`` or even better: + to make safe Trx transfers, always check the return value of ``send``, use ``transfer`` or even better: Use a pattern where the recipient withdraws the money. .. note:: diff --git a/docs/utils/SolidityLexer.py b/docs/utils/SolidityLexer.py index 50f51cf4f109..0918c974eece 100644 --- a/docs/utils/SolidityLexer.py +++ b/docs/utils/SolidityLexer.py @@ -66,7 +66,7 @@ class SolidityLexer(RegexLexer): ['ufixed%dx%d' % ((i), (j + 8)) for i in range(0, 256, 8) for j in range(0, 256 - i, 8)] + ['fixed%dx%d' % ((i), (j + 8)) for i in range(0, 256, 8) for j in range(0, 256 - i, 8)] ) + r')\b', Keyword.Type, 'slashstartsregex'), - (r'(wei|szabo|finney|ether|seconds|minutes|hours|days|weeks|years)\b', Keyword.Type, 'slashstartsregex'), + (r'(sun|trx|seconds|minutes|hours|days|weeks|years)\b', Keyword.Type, 'slashstartsregex'), (r'(abstract|after|case|catch|default|final|in|inline|let|match|' r'null|of|relocatable|static|switch|try|type|typeof)\b', Keyword.Reserved), (r'(true|false)\b', Keyword.Constant), diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 30302908cfee..2062458ef8a8 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -864,15 +864,35 @@ void TypeChecker::visitManually( bool TypeChecker::visit(EventDefinition const& _eventDef) { + solAssert(_eventDef.visibility() > Declaration::Visibility::Internal, ""); unsigned numIndexed = 0; for (ASTPointer const& var: _eventDef.parameters()) { if (var->isIndexed()) + { numIndexed++; + if ( + _eventDef.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) && + dynamic_cast(type(*var).get()) + ) + m_errorReporter.typeError( + var->location(), + "Indexed reference types cannot yet be used with ABIEncoderV2." + ); + } if (!type(*var)->canLiveOutsideStorage()) m_errorReporter.typeError(var->location(), "Type is required to live outside storage."); if (!type(*var)->interfaceType(false)) m_errorReporter.typeError(var->location(), "Internal or recursive type is not allowed as event parameter type."); + if ( + !_eventDef.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) && + !typeSupportedByOldABIEncoder(*type(*var)) + ) + m_errorReporter.typeError( + var->location(), + "This type is only supported in the new experimental ABI encoder. " + "Use \"pragma experimental ABIEncoderV2;\" to enable the feature." + ); } if (_eventDef.isAnonymous() && numIndexed > 4) m_errorReporter.typeError(_eventDef.location(), "More than 4 indexed arguments for anonymous event."); diff --git a/libsolidity/parsing/Scanner.cpp b/libsolidity/parsing/Scanner.cpp index 6541f6c2ff5b..dbe1f389f5b0 100644 --- a/libsolidity/parsing/Scanner.cpp +++ b/libsolidity/parsing/Scanner.cpp @@ -243,22 +243,17 @@ bool Scanner::skipWhitespace() return sourcePos() != startPosition; } -bool Scanner::skipWhitespaceExceptLF() +void Scanner::skipWhitespaceExceptUnicodeLinebreak() { - int const startPosition = sourcePos(); - while (isWhiteSpace(m_char) && !isLineTerminator(m_char)) + while (isWhiteSpace(m_char) && !isUnicodeLinebreak()) advance(); - // Return whether or not we skipped any characters. - return sourcePos() != startPosition; } Token::Value Scanner::skipSingleLineComment() { - // The line terminator at the end of the line is not considered - // to be part of the single-line comment; it is recognized - // separately by the lexical grammar and becomes part of the - // stream of input elements for the syntactic grammar - while (!isLineTerminator(m_char)) + // Line terminator is not part of the comment. If it is a + // non-ascii line terminator, it will result in a parser error. + while (!isUnicodeLinebreak()) if (!advance()) break; return Token::Whitespace; @@ -268,7 +263,9 @@ Token::Value Scanner::scanSingleLineDocComment() { LiteralScope literal(this, LITERAL_TYPE_COMMENT); advance(); //consume the last '/' at /// - skipWhitespaceExceptLF(); + + skipWhitespaceExceptUnicodeLinebreak(); + while (!isSourcePastEndOfInput()) { if (isLineTerminator(m_char)) @@ -287,6 +284,10 @@ Token::Value Scanner::scanSingleLineDocComment() break; // next line is not a documentation comment, we are done } + else if (isUnicodeLinebreak()) + // Any line terminator that is not '\n' is considered to end the + // comment. + break; addCommentLiteralChar(m_char); advance(); } @@ -321,6 +322,9 @@ Token::Value Scanner::scanMultiLineDocComment() bool endFound = false; bool charsAdded = false; + while (isWhiteSpace(m_char) && !isLineTerminator(m_char)) + advance(); + while (!isSourcePastEndOfInput()) { //handle newlines in multline comments @@ -372,7 +376,7 @@ Token::Value Scanner::scanSlash() if (m_char == '/') { if (!advance()) /* double slash comment directly before EOS */ - return Token::Whitespace; + return Token::Whitespace; else if (m_char == '/') { // doxygen style /// comment @@ -390,24 +394,27 @@ Token::Value Scanner::scanSlash() { // doxygen style /** natspec comment if (!advance()) /* slash star comment before EOS */ - return Token::Whitespace; + return Token::Illegal; else if (m_char == '*') { advance(); //consume the last '*' at /** - skipWhitespaceExceptLF(); - // special case of a closed normal multiline comment - if (!m_source.isPastEndOfInput() && m_source.get(0) == '/') - advance(); //skip the closing slash - else // we actually have a multiline documentation comment + // "/**/" + if (m_char == '/') { - Token::Value comment; - m_nextSkippedComment.location.start = firstSlashPosition; - comment = scanMultiLineDocComment(); - m_nextSkippedComment.location.end = sourcePos(); - m_nextSkippedComment.token = comment; + advance(); //skip the closing slash + return Token::Whitespace; } - return Token::Whitespace; + // we actually have a multiline documentation comment + Token::Value comment; + m_nextSkippedComment.location.start = firstSlashPosition; + comment = scanMultiLineDocComment(); + m_nextSkippedComment.location.end = sourcePos(); + m_nextSkippedComment.token = comment; + if (comment == Token::Illegal) + return Token::Illegal; + else + return Token::Whitespace; } else return skipMultiLineComment(); @@ -435,11 +442,6 @@ void Scanner::scanToken() m_nextToken.location.start = sourcePos(); switch (m_char) { - case '\n': - case ' ': - case '\t': - token = selectToken(Token::Whitespace); - break; case '"': case '\'': token = scanString(); @@ -675,18 +677,38 @@ bool Scanner::scanEscape() if (!scanHexByte(c)) return false; break; + default: + return false; } addLiteralChar(c); return true; } +bool Scanner::isUnicodeLinebreak() +{ + if (0x0a <= m_char && m_char <= 0x0d) + // line feed, vertical tab, form feed, carriage return + return true; + else if (!m_source.isPastEndOfInput(1) && uint8_t(m_source.get(0)) == 0xc2 && uint8_t(m_source.get(1)) == 0x85) + // NEL - U+0085, C2 85 in utf8 + return true; + else if (!m_source.isPastEndOfInput(2) && uint8_t(m_source.get(0)) == 0xe2 && uint8_t(m_source.get(1)) == 0x80 && ( + uint8_t(m_source.get(2)) == 0xa8 || uint8_t(m_source.get(2)) == 0xa9 + )) + // LS - U+2028, E2 80 A8 in utf8 + // PS - U+2029, E2 80 A9 in utf8 + return true; + else + return false; +} + Token::Value Scanner::scanString() { char const quote = m_char; advance(); // consume quote LiteralScope literal(this, LITERAL_TYPE_STRING); - while (m_char != quote && !isSourcePastEndOfInput() && !isLineTerminator(m_char)) + while (m_char != quote && !isSourcePastEndOfInput() && !isUnicodeLinebreak()) { char c = m_char; advance(); @@ -710,7 +732,7 @@ Token::Value Scanner::scanHexString() char const quote = m_char; advance(); // consume quote LiteralScope literal(this, LITERAL_TYPE_STRING); - while (m_char != quote && !isSourcePastEndOfInput() && !isLineTerminator(m_char)) + while (m_char != quote && !isSourcePastEndOfInput()) { char c = m_char; if (!scanHexByte(c)) diff --git a/libsolidity/parsing/Scanner.h b/libsolidity/parsing/Scanner.h index 0adaa6fd2e2f..602532e4729e 100644 --- a/libsolidity/parsing/Scanner.h +++ b/libsolidity/parsing/Scanner.h @@ -197,8 +197,8 @@ class Scanner /// Skips all whitespace and @returns true if something was skipped. bool skipWhitespace(); - /// Skips all whitespace except Line feeds and returns true if something was skipped - bool skipWhitespaceExceptLF(); + /// Skips all whitespace that are neither '\r' nor '\n'. + void skipWhitespaceExceptUnicodeLinebreak(); Token::Value skipSingleLineComment(); Token::Value skipMultiLineComment(); @@ -218,6 +218,9 @@ class Scanner /// is scanned. bool scanEscape(); + /// @returns true iff we are currently positioned at a unicode line break. + bool isUnicodeLinebreak(); + /// Return the current source position. int sourcePos() const { return m_source.position(); } bool isSourcePastEndOfInput() const { return m_source.isPastEndOfInput(); } diff --git a/libsolidity/parsing/Token.h b/libsolidity/parsing/Token.h index 92f89444d1ac..d65a9c07a933 100644 --- a/libsolidity/parsing/Token.h +++ b/libsolidity/parsing/Token.h @@ -180,7 +180,7 @@ namespace solidity K(View, "view", 0) \ K(While, "while", 0) \ \ - /* Ether subdenominations */ \ + /* Trx subdenominations */ \ K(SubSun, "sun", 0) \ K(SubTrx, "trx", 0) \ K(SubSecond, "seconds", 0) \ diff --git a/scripts/release.bat b/scripts/release.bat index be95b35e4aa0..b15b49b7bd28 100644 --- a/scripts/release.bat +++ b/scripts/release.bat @@ -32,12 +32,9 @@ set VERSION=%2 IF "%VERSION%"=="2015" ( set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\redist\x86\Microsoft.VC140.CRT\msvc*.dll" ) ELSE ( - - IF EXIST "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.13.26020\x86\Microsoft.VC141.CRT\" ( - set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\14.13.26020\x86\Microsoft.VC141.CRT\msvc*.dll" - ) ELSE ( - set "DLLS=C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Redist\MSVC\14.13.26020\x86\Microsoft.VC141.CRT\msvc*.dll" - ) + set "DLLS=MSVC_DLLS_NOT_FOUND" + FOR /d %%d IN ("C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Redist\MSVC\*" + "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Redist\MSVC\*") DO set "DLLS=%%d\x86\Microsoft.VC141.CRT\msvc*.dll" ) 7z a solidity-windows.zip ^ diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index 51e911ef2fee..a643f4577401 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -48,7 +48,7 @@ if ! type wget &>/dev/null; then apt-get -y install wget fi -WORKSPACE=/root/project/solidity +WORKSPACE=/Users/jarvis/Workspace/git_zy/solidity # Increase nodejs stack size if [ -e ~/.emscripten ] diff --git a/test/RPCSession.cpp b/test/RPCSession.cpp index f4eae8658385..eebe19972256 100644 --- a/test/RPCSession.cpp +++ b/test/RPCSession.cpp @@ -247,14 +247,14 @@ void RPCSession::test_setChainParams(vector const& _accounts) "gasLimit": "0x1000000000000" }, "accounts": { - "0000000000000000000000000000000000000001": { "wei": "1", "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } }, - "0000000000000000000000000000000000000002": { "wei": "1", "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } }, - "0000000000000000000000000000000000000003": { "wei": "1", "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } }, - "0000000000000000000000000000000000000004": { "wei": "1", "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }, - "0000000000000000000000000000000000000005": { "wei": "1", "precompiled": { "name": "modexp" } }, - "0000000000000000000000000000000000000006": { "wei": "1", "precompiled": { "name": "alt_bn128_G1_add", "linear": { "base": 500, "word": 0 } } }, - "0000000000000000000000000000000000000007": { "wei": "1", "precompiled": { "name": "alt_bn128_G1_mul", "linear": { "base": 40000, "word": 0 } } }, - "0000000000000000000000000000000000000008": { "wei": "1", "precompiled": { "name": "alt_bn128_pairing_product" } } + "0000000000000000000000000000000000000001": { "sun": "1", "precompiled": { "name": "ecrecover", "linear": { "base": 3000, "word": 0 } } }, + "0000000000000000000000000000000000000002": { "sun": "1", "precompiled": { "name": "sha256", "linear": { "base": 60, "word": 12 } } }, + "0000000000000000000000000000000000000003": { "sun": "1", "precompiled": { "name": "ripemd160", "linear": { "base": 600, "word": 120 } } }, + "0000000000000000000000000000000000000004": { "sun": "1", "precompiled": { "name": "identity", "linear": { "base": 15, "word": 3 } } }, + "0000000000000000000000000000000000000005": { "sun": "1", "precompiled": { "name": "modexp" } }, + "0000000000000000000000000000000000000006": { "sun": "1", "precompiled": { "name": "alt_bn128_G1_add", "linear": { "base": 500, "word": 0 } } }, + "0000000000000000000000000000000000000007": { "sun": "1", "precompiled": { "name": "alt_bn128_G1_mul", "linear": { "base": 40000, "word": 0 } } }, + "0000000000000000000000000000000000000008": { "sun": "1", "precompiled": { "name": "alt_bn128_pairing_product" } } } } )"; @@ -262,7 +262,7 @@ void RPCSession::test_setChainParams(vector const& _accounts) Json::Value config; BOOST_REQUIRE(jsonParseStrict(c_configString, config)); for (auto const& account: _accounts) - config["accounts"][account]["wei"] = "0x100000000000000000000000000000000000000000"; + config["accounts"][account]["sun"] = "0x100000000000000000000000000000000000000000"; test_setChainParams(jsonCompactPrint(config)); } diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol index 12c0603c3d8c..7141f86c83d9 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimit.sol @@ -18,7 +18,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { /// @dev Contract constructor sets initial owners, required number of confirmations and daily withdraw limit. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. - /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. + /// @param _dailyLimit Amount in sun, which can be withdrawn without confirmations on a daily basis. function MultiSigWalletWithDailyLimit(address[] _owners, uint _required, uint _dailyLimit) public MultiSigWallet(_owners, _required) @@ -27,7 +27,7 @@ contract MultiSigWalletWithDailyLimit is MultiSigWallet { } /// @dev Allows to change the daily limit. Transaction has to be sent by wallet. - /// @param _dailyLimit Amount in wei. + /// @param _dailyLimit Amount in sun. function changeDailyLimit(uint _dailyLimit) public onlyWallet diff --git a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol index 8a2efa32753f..a640f6be0d7a 100644 --- a/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol +++ b/test/compilationTests/MultiSigWallet/MultiSigWalletWithDailyLimitFactory.sol @@ -10,7 +10,7 @@ contract MultiSigWalletWithDailyLimitFactory is Factory { /// @dev Allows verified creation of multisignature wallet. /// @param _owners List of initial owners. /// @param _required Number of required confirmations. - /// @param _dailyLimit Amount in wei, which can be withdrawn without confirmations on a daily basis. + /// @param _dailyLimit Amount in sun, which can be withdrawn without confirmations on a daily basis. /// @return Returns wallet address. function create(address[] _owners, uint _required, uint _dailyLimit) public diff --git a/test/compilationTests/gnosis/Tokens/EtherToken.sol b/test/compilationTests/gnosis/Tokens/EtherToken.sol index f6e73e5acf26..036408fe3727 100644 --- a/test/compilationTests/gnosis/Tokens/EtherToken.sol +++ b/test/compilationTests/gnosis/Tokens/EtherToken.sol @@ -2,7 +2,7 @@ pragma solidity ^0.4.11; import "../Tokens/StandardToken.sol"; -/// @title Token contract - Token exchanging Ether 1:1 +/// @title Token contract - Token exchanging Trx 1:1 /// @author Stefan George - contract EtherToken is StandardToken { using Math for *; @@ -16,14 +16,14 @@ contract EtherToken is StandardToken { /* * Constants */ - string public constant name = "Ether Token"; - string public constant symbol = "ETH"; + string public constant name = "Trx Token"; + string public constant symbol = "Trx"; uint8 public constant decimals = 18; /* * Public functions */ - /// @dev Buys tokens with Ether, exchanging them 1:1 + /// @dev Buys tokens with Trx, exchanging them 1:1 function deposit() public payable @@ -33,7 +33,7 @@ contract EtherToken is StandardToken { Deposit(msg.sender, msg.value); } - /// @dev Sells tokens in exchange for Ether, exchanging them 1:1 + /// @dev Sells tokens in exchange for Trx, exchanging them 1:1 /// @param value Number of tokens to sell function withdraw(uint value) public diff --git a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol index 6167ac7221b5..068e5fb9fa2b 100644 --- a/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol +++ b/test/compilationTests/zeppelin/crowdsale/Crowdsale.sol @@ -8,7 +8,7 @@ import '../math/SafeMath.sol'; * @dev Crowdsale is a base contract for managing a token crowdsale. * Crowdsales have a start and end block, where investors can make * token purchases and the crowdsale will assign them tokens based - * on a token per ETH rate. Funds collected are forwarded to a wallet + * on a token per trx rate. Funds collected are forwarded to a wallet * as they arrive. */ contract Crowdsale { @@ -24,10 +24,10 @@ contract Crowdsale { // address where funds are collected address public wallet; - // how many token units a buyer gets per wei + // how many token units a buyer gets per sun uint256 public rate; - // amount of raised money in wei + // amount of raised money in sun uint256 public weiRaised; /** diff --git a/test/compilationTests/zeppelin/ownership/HasNoEther.sol b/test/compilationTests/zeppelin/ownership/HasNoEther.sol index 6ac71cba0705..1d532c14a9ac 100644 --- a/test/compilationTests/zeppelin/ownership/HasNoEther.sol +++ b/test/compilationTests/zeppelin/ownership/HasNoEther.sol @@ -3,11 +3,11 @@ pragma solidity ^0.4.11; import "./Ownable.sol"; /** - * @title Contracts that should not own Ether + * @title Contracts that should not own Trx * @author Remco Bloemen - * @dev This tries to block incoming trx to prevent accidental loss of Ether. Should Ether end up + * @dev This tries to block incoming trx to prevent accidental loss of Trx. Should Trx end up * in the contract, it will allow the owner to reclaim this trx. - * @notice Ether can still be send to this contract by: + * @notice Trx can still be send to this contract by: * calling functions labeled `payable` * `selfdestruct(contract_address)` * mining directly to the contract address @@ -15,7 +15,7 @@ import "./Ownable.sol"; contract HasNoEther is Ownable { /** - * @dev Constructor that rejects incoming Ether + * @dev Constructor that rejects incoming Trx * @dev The `payable` flag is added so we can access `msg.value` without compiler warning. If we * leave out payable, then Solidity will allow inheriting contracts to implement a payable * constructor. By doing it this way we prevent a payable constructor from working. Alternatively @@ -34,7 +34,7 @@ contract HasNoEther is Ownable { } /** - * @dev Transfer all Ether held by the contract to the owner. + * @dev Transfer all Trx held by the contract to the owner. */ function reclaimEther() external onlyOwner { if(!owner.send(this.balance)) { diff --git a/test/compilationTests/zeppelin/ownership/NoOwner.sol b/test/compilationTests/zeppelin/ownership/NoOwner.sol index 7215abf3ac8d..67f24b3a959d 100644 --- a/test/compilationTests/zeppelin/ownership/NoOwner.sol +++ b/test/compilationTests/zeppelin/ownership/NoOwner.sol @@ -7,7 +7,7 @@ import "./HasNoContracts.sol"; /** * @title Base contract for contracts that should not own things. * @author Remco Bloemen - * @dev Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens or + * @dev Solves a class of errors where a contract accidentally becomes owner of Trx, Tokens or * Owned contracts. See respective base contracts for details. */ contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts { diff --git a/test/contracts/LLL_ERC20.cpp b/test/contracts/LLL_ERC20.cpp index 89e3cc4e5729..4e12ed33a341 100644 --- a/test/contracts/LLL_ERC20.cpp +++ b/test/contracts/LLL_ERC20.cpp @@ -193,8 +193,8 @@ static char const* erc20Code = R"DELIMITER( (when (> value token-supply) (revert))) ;; -------------------------------------------------------------------------- - ;; Will revert if sent any Ether. We use the macro immediately so as - ;; to abort if sent any Ether during contract deployment. + ;; Will revert if sent any Trx. We use the macro immediately so as + ;; to abort if sent any Trx during contract deployment. (def 'not-payable (when (callvalue) (revert))) diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 6c9d078d7e99..52f8524cb6a3 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -11025,10 +11025,10 @@ BOOST_AUTO_TEST_CASE(scientific_notation) char const* sourceCode = R"( contract C { function f() returns (uint) { - return 2e10 wei; + return 2e10 sun; } function g() returns (uint) { - return 200e-2 wei; + return 200e-2 sun; } function h() returns (uint) { return 2.5e1; diff --git a/test/libsolidity/SolidityExpressionCompiler.cpp b/test/libsolidity/SolidityExpressionCompiler.cpp index 4710005a582a..fcb690a121ad 100644 --- a/test/libsolidity/SolidityExpressionCompiler.cpp +++ b/test/libsolidity/SolidityExpressionCompiler.cpp @@ -216,7 +216,7 @@ BOOST_AUTO_TEST_CASE(int_with_wei_ether_subdenomination) char const* sourceCode = R"( contract test { function test () { - var x = 1 wei; + var x = 1 sun; } } )"; diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 5af676595eaa..fc8117fb1806 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1499,7 +1499,7 @@ BOOST_AUTO_TEST_CASE(overflow_caused_by_ether_units) char const* sourceCode = R"( contract c { function c () public { - a = 115792089237316195423570985008687907853269984665640564039458 ether; + a = 115792089237316195423570985008687907853269984665640564039458 trx; } uint256 a; } diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index 0c801cf62f2a..827c3a9cc298 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -791,15 +791,11 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations) contract c { function c () { - a = 1 wei; - b = 2 szabo; - c = 3 finney; - b = 4 ether; + a = 1 sun; + b = 2 trx; } uint256 a; uint256 b; - uint256 c; - uint256 d; })"; BOOST_CHECK(successParse(text)); } @@ -810,7 +806,7 @@ BOOST_AUTO_TEST_CASE(literal_constants_with_ether_subdenominations_in_expression contract c { function c () { - a = 1 wei * 100 wei + 7 szabo - 3; + a = 1 sun * 100 sun + 7 trx - 3; } uint256 a; })"; diff --git a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol index 3571e8a95150..40b8a52cf352 100644 --- a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol +++ b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination.sol @@ -1,5 +1,5 @@ contract C { - uint constant x = 0x01 wei; + uint constant x = 0x01 sun; } // ---- // Warning: (32-40): Hexadecimal numbers with unit denominations are deprecated. You can use an expression of the form "0x1234 * 1 day" instead. diff --git a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination_050.sol b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination_050.sol index 988659995dae..2a1ff81baae8 100644 --- a/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination_050.sol +++ b/test/libsolidity/syntaxTests/denominations/combining_hex_and_denomination_050.sol @@ -1,6 +1,6 @@ pragma experimental "v0.5.0"; contract C { - uint constant x = 0x01 wei; + uint constant x = 0x01 sun; } // ---- // TypeError: (62-70): Hexadecimal numbers cannot be used with unit denominations. You can use an expression of the form "0x1234 * 1 day" instead. diff --git a/test/libsolidity/syntaxTests/parsing/scientific_notation.sol b/test/libsolidity/syntaxTests/parsing/scientific_notation.sol index 5d6565082c26..5bca20e28d5b 100644 --- a/test/libsolidity/syntaxTests/parsing/scientific_notation.sol +++ b/test/libsolidity/syntaxTests/parsing/scientific_notation.sol @@ -2,6 +2,6 @@ contract test { uint256 a = 2e10; uint256 b = 2E10; uint256 c = 200e-2; - uint256 d = 2E10 wei; + uint256 d = 2E10 sun; uint256 e = 2.5e10; } From 558c25218ecd75d1227a010c701b1858076e26e7 Mon Sep 17 00:00:00 2001 From: jeancky Date: Tue, 23 Oct 2018 20:54:00 +0800 Subject: [PATCH 4/8] reset workspace --- scripts/travis-emscripten/build_emscripten.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/travis-emscripten/build_emscripten.sh b/scripts/travis-emscripten/build_emscripten.sh index a643f4577401..51e911ef2fee 100755 --- a/scripts/travis-emscripten/build_emscripten.sh +++ b/scripts/travis-emscripten/build_emscripten.sh @@ -48,7 +48,7 @@ if ! type wget &>/dev/null; then apt-get -y install wget fi -WORKSPACE=/Users/jarvis/Workspace/git_zy/solidity +WORKSPACE=/root/project/solidity # Increase nodejs stack size if [ -e ~/.emscripten ] From 261fbb256e6a55befbbfaea7515232deadd915db Mon Sep 17 00:00:00 2001 From: jeancky Date: Wed, 24 Oct 2018 10:59:38 +0800 Subject: [PATCH 5/8] update gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6049a6269293..aeb863f5ba63 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,6 @@ boost_1_57_0/ cmake-build-debug/ deps/ /.vs -output/ +#output/ From efe821aad0b2867d16c5175448283ef5b1390e26 Mon Sep 17 00:00:00 2001 From: jeancky Date: Fri, 2 Nov 2018 16:00:12 +0800 Subject: [PATCH 6/8] ignore output --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index aeb863f5ba63..6049a6269293 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,6 @@ boost_1_57_0/ cmake-build-debug/ deps/ /.vs -#output/ +output/ From 87350813ea1d809d63754449c4d0919e2a5e260e Mon Sep 17 00:00:00 2001 From: jeancky Date: Sat, 3 Nov 2018 11:55:52 +0800 Subject: [PATCH 7/8] Update build script --- scripts/check_style.sh | 32 +++++++++++++++++++++++ scripts/create_source_tarball.sh | 1 - scripts/install_deps.sh | 14 +++++----- scripts/install_obsolete_jsoncpp_1_7_4.sh | 16 ++++++++++++ 4 files changed, 56 insertions(+), 7 deletions(-) create mode 100755 scripts/check_style.sh create mode 100755 scripts/install_obsolete_jsoncpp_1_7_4.sh diff --git a/scripts/check_style.sh b/scripts/check_style.sh new file mode 100755 index 000000000000..a8557a54fc7c --- /dev/null +++ b/scripts/check_style.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +REPO_ROOT="$(dirname "$0")"/.. + +( +cd $REPO_ROOT +WHITESPACE=$(git grep -n -I -E "^.*[[:space:]]+$" | grep -v "test/libsolidity/ASTJSON\|test/compilationTests/zeppelin/LICENSE") + +if [[ "$WHITESPACE" != "" ]] +then + echo "Error: Trailing whitespace found:" >&2 + echo "$WHITESPACE" >&2 + exit 1 +fi +) + +( +cd $REPO_ROOT +FORMATERROR=$( +( +git grep -nIE "\<(if|for)\(" -- '*.h' '*.cpp' +git grep -nIE "\\s*\(.*\)\s*\{\s*$" -- '*.h' '*.cpp' +) | egrep -v "^[a-zA-Z\./]*:[0-9]*:\s*\/(\/|\*)" | egrep -v "^test/" +) + +if [[ "$FORMATERROR" != "" ]] +then + echo "Error: Format error for if/for:" >&2 + echo "$FORMATERROR" >&2 + exit 1 +fi +) diff --git a/scripts/create_source_tarball.sh b/scripts/create_source_tarball.sh index 4e9307075e07..632c1daaf763 100755 --- a/scripts/create_source_tarball.sh +++ b/scripts/create_source_tarball.sh @@ -23,7 +23,6 @@ REPO_ROOT="$(dirname "$0")"/.. mkdir "$SOLDIR" # Store the current source git checkout-index -a --prefix="$SOLDIR" - git submodule foreach 'git checkout-index -a --prefix="'"$SOLDIR"'/$path/"' # Store the commit hash echo "$commithash" > "$SOLDIR/commit_hash.txt" if [ -e prerelease.txt -a ! -s prerelease.txt ] diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index fa5551bfe273..b107f7c9b4f3 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -87,9 +87,12 @@ case $(uname -s) in 10.13) echo "Installing solidity dependencies on macOS 10.13 High Sierra." ;; + 10.14) + echo "Installing solidity dependencies on macOS 10.14 Mojave." + ;; *) echo "Unsupported macOS version." - echo "We only support Mavericks, Yosemite, El Capitan, Sierra and High Sierra." + echo "We only support Mavericks, Yosemite, El Capitan, Sierra, High Sierra and Mojave." exit 1 ;; esac @@ -133,19 +136,18 @@ case $(uname -s) in # Arch Linux #------------------------------------------------------------------------------ - Arch) + Arch*|ManjaroLinux) #Arch echo "Installing solidity dependencies on Arch Linux." # All our dependencies can be found in the Arch Linux official repositories. # See https://wiki.archlinux.org/index.php/Official_repositories - # Also adding ethereum-git to allow for testing with the `eth` client sudo pacman -Syu \ base-devel \ boost \ cmake \ git \ - ethereum-git \ + cvc4 ;; #------------------------------------------------------------------------------ @@ -160,7 +162,7 @@ case $(uname -s) in # See https://pkgs.alpinelinux.org/ apk update - apk add boost-dev build-base cmake + apk add boost-dev build-base cmake git ;; @@ -329,7 +331,7 @@ case $(uname -s) in "$install_z3" if [ "$CI" = true ]; then # install Z3 from PPA if the distribution does not provide it - if ! dpkg -l libz3-dev > /dev/null 2>&1 + if ! dpkg -l libz3-dev > /dev/null 2>&1 then sudo apt-add-repository -y ppa:hvr/z3 sudo apt-get -y update diff --git a/scripts/install_obsolete_jsoncpp_1_7_4.sh b/scripts/install_obsolete_jsoncpp_1_7_4.sh new file mode 100755 index 000000000000..0ae7b34cf17f --- /dev/null +++ b/scripts/install_obsolete_jsoncpp_1_7_4.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env sh +set -e + +TEMPDIR=$(mktemp -d) +( + cd $TEMPDIR + wget https://github.com/open-source-parsers/jsoncpp/archive/1.7.4.tar.gz + tar xvzf "1.7.4.tar.gz" + cd "jsoncpp-1.7.4" + mkdir -p build + cd build + cmake -DARCHIVE_INSTALL_DIR=. -G "Unix Makefiles" .. + make + make install +) +rm -rf $TEMPDIR From ceb1d781eeb743fce68061cd6ff976d967d30b68 Mon Sep 17 00:00:00 2001 From: jeancky Date: Sat, 3 Nov 2018 12:27:11 +0800 Subject: [PATCH 8/8] Fix macos 10.14 build problem --- libsolidity/inlineasm/AsmParser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp index d3b0808b48e5..eca0c2c44df8 100644 --- a/libsolidity/inlineasm/AsmParser.cpp +++ b/libsolidity/inlineasm/AsmParser.cpp @@ -606,7 +606,8 @@ bool Parser::isValidNumberLiteral(string const& _literal) { try { - u256(_literal); + auto tmp = u256(_literal); + (void) tmp; } catch (...) {