From 9fc006056895ad631d97b09b7c7d6e38be28fff6 Mon Sep 17 00:00:00 2001 From: Leo Arias Date: Wed, 28 Jun 2017 03:40:45 +0000 Subject: Add the packaging metadata to build the solidity snap --- snap/snapcraft.yaml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 snap/snapcraft.yaml diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml new file mode 100644 index 00000000..f0f3310a --- /dev/null +++ b/snap/snapcraft.yaml @@ -0,0 +1,29 @@ +name: solc +version: master +summary: The Solidity Contract-Oriented Programming Language +description: | + Solidity is a contract-oriented, high-level language whose syntax is similar + to that of JavaScript and it is designed to target the Ethereum Virtual + Machine (EVM). + + Solidity is statically typed, supports inheritance, libraries and complex + user-defined types among other features. + + It is possible to create contracts for voting, crowdfunding, blind auctions, + multi-signature wallets and more. + +grade: devel # must be 'stable' to release into candidate/stable channels +confinement: strict + +apps: + solc: + command: solc + plugs: [home] + +parts: + solidity: + source: . + source-type: git + plugin: cmake + build-packages: [build-essential, libboost-all-dev] + stage-packages: [libicu55] -- cgit v1.2.3 From bb503666ead10e695c220a4e4293194eaa0f5d6e Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 3 Jul 2017 14:28:21 +0200 Subject: Bump version. --- CMakeLists.txt | 2 +- Changelog.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d6ed6643..f7220b17 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.12") +set(PROJECT_VERSION "0.4.13") project(solidity VERSION ${PROJECT_VERSION}) # Let's find our dependencies diff --git a/Changelog.md b/Changelog.md index b41852df..7c0c86a5 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,5 @@ +### 0.4.13 (unreleased) + ### 0.4.12 (2017-07-03) Features: -- cgit v1.2.3 From 139c1fe06edc2f97d57afdb490f98a44dccf2f9f Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 3 Jul 2017 20:16:26 +0200 Subject: Run docker deployment on actual releases. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e82da7c0..c0371af2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -221,6 +221,7 @@ deploy: branch: - develop - release + - /^v[0-9]/ # This is the deploy target for the native build (Linux and macOS) # which generates ZIPs per commit and the source tarball. # -- cgit v1.2.3 From 758ad3594d9869ca7a49d5c12120d30e5d18265d Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 3 Jul 2017 20:39:12 +0200 Subject: Some fixes for the PPA release scripts. --- scripts/release_ppa.sh | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/scripts/release_ppa.sh b/scripts/release_ppa.sh index 7c9abecb..4fae90ef 100755 --- a/scripts/release_ppa.sh +++ b/scripts/release_ppa.sh @@ -14,6 +14,21 @@ ## ## It will clone the Solidity git from github, determine the version, ## create a source archive and push it to the ubuntu ppa servers. +## +## This requires the following entries in /etc/dput.cf: +## +## [ethereum-dev] +## fqdn = ppa.launchpad.net +## method = ftp +## incoming = ~ethereum/ethereum-dev +## login = anonymous +## +## [ethereum] +## fqdn = ppa.launchpad.net +## method = ftp +## incoming = ~ethereum/ethereum +## login = anonymous + ## ############################################################################## @@ -28,10 +43,10 @@ fi if [ "$branch" = develop ] then - pparepo=ethereum/ethereum-dev + pparepo=ethereum-dev ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/ethereum-dev/+files else - pparepo=ethereum/ethereum + pparepo=ethereum ppafilesurl=https://launchpad.net/~ethereum/+archive/ubuntu/ethereum/+files fi @@ -192,7 +207,8 @@ EMAIL="$email" dch -v 1:${debversion}-${versionsuffix} "git build of ${commithas # build source package # If packages is rejected because original source is already present, add # -sd to remove it from the .changes file -debuild -S -sa -us -uc +# -d disables the build dependencies check +debuild -S -d -sa -us -uc # prepare .changes file for Launchpad sed -i -e s/UNRELEASED/${distribution}/ -e s/urgency=medium/urgency=low/ ../*.changes @@ -223,6 +239,6 @@ fi debsign --re-sign -k ${keyid} ../${packagename}_${debversion}-${versionsuffix}_source.changes # upload -dput ppa:${pparepo} ../${packagename}_${debversion}-${versionsuffix}_source.changes +dput ${pparepo} ../${packagename}_${debversion}-${versionsuffix}_source.changes done -- cgit v1.2.3 From 0cb93a5f7b0a12d205d9acfc9ed342494c90ab1f Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 4 Jul 2017 18:28:24 +0200 Subject: Test for internal "variable already present" error. --- test/libsolidity/SolidityEndToEndTest.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index a6c01283..c9771fbd 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -9696,6 +9696,33 @@ BOOST_AUTO_TEST_CASE(keccak256_assembly) BOOST_CHECK(callContractFunction("i()") == fromHex("0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470")); } +BOOST_AUTO_TEST_CASE(multi_modifiers) +{ + // This triggered a bug in some version because the variable in the modifier was not + // unregistered correctly. + char const* sourceCode = R"( + contract C { + uint public x; + modifier m1 { + address a1 = msg.sender; + x++; + _; + } + function f1() m1() { + x += 7; + } + function f2() m1() { + x += 3; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f1()") == bytes()); + BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(8))); + BOOST_CHECK(callContractFunction("f2()") == bytes()); + BOOST_CHECK(callContractFunction("x()") == encodeArgs(u256(12))); +} + BOOST_AUTO_TEST_SUITE_END() } -- cgit v1.2.3 From d58e4390942c6347c75cb5d45b503711338e80eb Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 4 Jul 2017 18:28:44 +0200 Subject: Fix internal "variable already present" error. --- libsolidity/codegen/ContractCompiler.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index c358a519..cad388df 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -928,7 +928,10 @@ void ContractCompiler::appendModifierOrFunctionCode() ); } for (VariableDeclaration const* localVariable: modifier.localVariables()) + { + addedVariables.push_back(localVariable); appendStackVariableInitialisation(*localVariable); + } stackSurplus = CompilerUtils::sizeOnStack(modifier.parameters()) + -- cgit v1.2.3 From 2432808793ea737a28f9c75042730724f4d050e8 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 4 Jul 2017 18:58:11 +0200 Subject: Changelog entry. --- Changelog.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changelog.md b/Changelog.md index 7c0c86a5..b4415978 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ ### 0.4.13 (unreleased) +Bugfixes: + * Code Generator: Correctly unregister modifier variables. + ### 0.4.12 (2017-07-03) Features: -- cgit v1.2.3 From b166228a39747a170a2c950b85eb7f712c8852e2 Mon Sep 17 00:00:00 2001 From: Patrick Walters Date: Tue, 4 Jul 2017 23:46:07 -0500 Subject: Update contributing.rst --- docs/contributing.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/contributing.rst b/docs/contributing.rst index 559f9f6a..9d1b2ce3 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -78,10 +78,10 @@ Alternatively, there is a testing script at ``scripts/test.sh`` which executes a Whiskers ======== -*Whiskers* is a templating system similar to `Moustache `_. It is used by the +*Whiskers* is a templating system similar to `Mustache `_. It is used by the compiler in various places to aid readability, and thus maintainability and verifiability, of the code. -The syntax comes with a substantial difference to Moustache: the template markers ``{{`` and ``}}`` are +The syntax comes with a substantial difference to Mustache: the template markers ``{{`` and ``}}`` are replaced by ``<`` and ``>`` in order to aid parsing and avoid conflicts with :ref:`inline-assembly` (The symbols ``<`` and ``>`` are invalid in inline assembly, while ``{`` and ``}`` are used to delimit blocks). Another limitation is that lists are only resolved one depth and they will not recurse. This may change in the future. @@ -91,5 +91,5 @@ A rough specification is the following: Any occurrence of ```` is replaced by the string-value of the supplied variable ``name`` without any escaping and without iterated replacements. An area can be delimited by ``<#name>...``. It is replaced by as many concatenations of its contents as there were sets of variables supplied to the template system, -each time replacing any ```` items by their respective value. Top-level variales can also be used -inside such areas. \ No newline at end of file +each time replacing any ```` items by their respective value. Top-level variables can also be used +inside such areas. -- cgit v1.2.3 From da48bcc51e56d7a088b8e21c45aa12299babbd39 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 5 Jul 2017 18:24:51 +0200 Subject: Only output AST if the analysis was successful. --- Changelog.md | 1 + libsolidity/interface/StandardCompiler.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index b4415978..8e740866 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ### 0.4.13 (unreleased) Bugfixes: + * Compiler Interface: Only output AST if analysis was successful. * Code Generator: Correctly unregister modifier variables. ### 0.4.12 (2017-07-03) diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index e677afc8..4aeabbdd 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -357,7 +357,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) if (errors.size() > 0) output["errors"] = errors; - bool parsingSuccess = m_compilerStack.state() >= CompilerStack::State::ParsingSuccessful; + bool analysisSuccess = m_compilerStack.state() >= CompilerStack::State::AnalysisSuccessful; bool compilationSuccess = m_compilerStack.state() == CompilerStack::State::CompilationSuccessful; /// Inconsistent state - stop here to receive error reports from users @@ -366,7 +366,7 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) output["sources"] = Json::objectValue; unsigned sourceIndex = 0; - for (auto const& source: parsingSuccess ? m_compilerStack.sourceNames() : vector()) + for (auto const& source: analysisSuccess ? m_compilerStack.sourceNames() : vector()) { Json::Value sourceResult = Json::objectValue; sourceResult["id"] = sourceIndex++; -- cgit v1.2.3 From 75f7f7e1e69329ec0413e51979fefd23c9b982f7 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 5 Jul 2017 17:02:02 +0200 Subject: Do not omit error type. --- Changelog.md | 1 + libsolidity/interface/StandardCompiler.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index b4415978..de4207a9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ Bugfixes: * Code Generator: Correctly unregister modifier variables. + * Error Output: Do not omit the error type. ### 0.4.12 (2017-07-03) diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index e677afc8..1f51851d 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -71,7 +71,7 @@ Json::Value formatErrorWithException( ) { string message; - string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _message, _scannerFromSourceName); + string formattedMessage = SourceReferenceFormatter::formatExceptionInformation(_exception, _type, _scannerFromSourceName); // NOTE: the below is partially a copy from SourceReferenceFormatter SourceLocation const* location = boost::get_error_info(_exception); @@ -271,12 +271,12 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) for (auto const& error: m_compilerStack.errors()) { - auto err = dynamic_pointer_cast(error); + Error const& err = dynamic_cast(*error); errors.append(formatErrorWithException( *error, - err->type() == Error::Type::Warning, - err->typeName(), + err.type() == Error::Type::Warning, + err.typeName(), "general", "", scannerFromSourceName -- cgit v1.2.3 From dd34277ca60fcd9803a6fbb5a5944a1ed2533c73 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 5 Jul 2017 19:38:00 +0200 Subject: Warn if local storage reference variable does not use "storage" explicitly. --- Changelog.md | 3 +++ libsolidity/analysis/ReferencesResolver.cpp | 15 ++++++++++- libsolidity/analysis/TypeChecker.cpp | 10 +++++--- test/libsolidity/SolidityNameAndTypeResolution.cpp | 30 ++++++++++++++++++++-- 4 files changed, 51 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index b4415978..f5abbd52 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ ### 0.4.13 (unreleased) +Features: + * Type Checker: Warn if a local storage reference variable does not explicitly use the keyword ``storage``. + Bugfixes: * Code Generator: Correctly unregister modifier variables. diff --git a/libsolidity/analysis/ReferencesResolver.cpp b/libsolidity/analysis/ReferencesResolver.cpp index 2a5f27df..cc95c294 100644 --- a/libsolidity/analysis/ReferencesResolver.cpp +++ b/libsolidity/analysis/ReferencesResolver.cpp @@ -289,7 +289,20 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable) typeLoc = DataLocation::Memory; } else if (varLoc == Location::Default) - typeLoc = _variable.isCallableParameter() ? DataLocation::Memory : DataLocation::Storage; + { + if (_variable.isCallableParameter()) + typeLoc = DataLocation::Memory; + else + { + typeLoc = DataLocation::Storage; + if (!_variable.isStateVariable()) + m_errorReporter.warning( + _variable.location(), + "Variable is declared as a storage pointer. " + "Use an explicit \"storage\" keyword to silence this warning." + ); + } + } else typeLoc = varLoc == Location::Memory ? DataLocation::Memory : DataLocation::Storage; isPointer = !_variable.isStateVariable(); diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 1563467c..7306a36d 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -854,10 +854,12 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) if (auto ref = dynamic_cast(type(varDecl).get())) { if (ref->dataStoredIn(DataLocation::Storage)) - m_errorReporter.warning( - varDecl.location(), - "Uninitialized storage pointer. Did you mean ' memory " + varDecl.name() + "'?" - ); + { + string errorText{"Uninitialized storage pointer."}; + if (varDecl.referenceLocation() == VariableDeclaration::Location::Default) + errorText += " Did you mean ' memory " + varDecl.name() + "'?"; + m_errorReporter.warning(varDecl.location(), errorText); + } } else if (dynamic_cast(type(varDecl).get())) m_errorReporter.typeError( diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index d0aee3d0..e04d50e8 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -2817,7 +2817,7 @@ BOOST_AUTO_TEST_CASE(uninitialized_mapping_array_variable) char const* sourceCode = R"( contract C { function f() { - mapping(uint => uint)[] x; + mapping(uint => uint)[] storage x; x; } } @@ -3103,7 +3103,7 @@ BOOST_AUTO_TEST_CASE(non_initialized_references) } function f() { - s x; + s storage x; x.a = 2; } } @@ -6144,6 +6144,32 @@ BOOST_AUTO_TEST_CASE(shadowing_warning_can_be_removed) CHECK_SUCCESS_NO_WARNINGS(text); } +BOOST_AUTO_TEST_CASE(warn_unspecified_storage) +{ + char const* text = R"( + contract C { + struct S { uint a; } + S x; + function f() { + S storage y = x; + y; + } + } + )"; + CHECK_SUCCESS_NO_WARNINGS(text); + text = R"( + contract C { + struct S { uint a; } + S x; + function f() { + S y = x; + y; + } + } + )"; + CHECK_WARNING(text, "is declared as a storage pointer. Use an explicit \"storage\" keyword to silence this warning"); +} + BOOST_AUTO_TEST_SUITE_END() -- cgit v1.2.3 From 0400e61e284bd595384d859752d97993b1f5ca45 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 5 Jul 2017 19:45:12 +0200 Subject: Deprecate throw. --- Changelog.md | 3 ++- libsolidity/analysis/SyntaxChecker.cpp | 10 ++++++++++ libsolidity/analysis/SyntaxChecker.h | 3 +++ test/libsolidity/SolidityNameAndTypeResolution.cpp | 12 ++++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index c5085f1b..8ba06aaf 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,11 +1,12 @@ ### 0.4.13 (unreleased) Features: + * Syntax Checker: Deprecated "throw" in favour of require(), assert() and revert(). * Type Checker: Warn if a local storage reference variable does not explicitly use the keyword ``storage``. Bugfixes: - * Compiler Interface: Only output AST if analysis was successful. * Code Generator: Correctly unregister modifier variables. + * Compiler Interface: Only output AST if analysis was successful. * Error Output: Do not omit the error type. ### 0.4.12 (2017-07-03) diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 02e2fdcf..bde0e616 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -135,6 +135,16 @@ bool SyntaxChecker::visit(Break const& _breakStatement) return true; } +bool SyntaxChecker::visit(Throw const& _throwStatement) +{ + m_errorReporter.warning( + _throwStatement.location(), + "\"throw\" is deprecated in favour of \"revert()\", \"require()\" and \"assert()\"." + ); + + return true; +} + bool SyntaxChecker::visit(UnaryOperation const& _operation) { if (_operation.getOperator() == Token::Add) diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index ec6ac434..fb5cc6d7 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -33,6 +33,7 @@ namespace solidity * - whether continue/break is in a for/while loop. * - whether a modifier contains at least one '_' * - issues deprecation warnings for unary '+' + * - issues deprecation warning for throw */ class SyntaxChecker: private ASTConstVisitor { @@ -59,6 +60,8 @@ private: virtual bool visit(Continue const& _continueStatement) override; virtual bool visit(Break const& _breakStatement) override; + virtual bool visit(Throw const& _throwStatement) override; + virtual bool visit(UnaryOperation const& _operation) override; virtual bool visit(PlaceholderStatement const& _placeholderStatement) override; diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index e04d50e8..108128f7 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -5860,6 +5860,18 @@ BOOST_AUTO_TEST_CASE(using_interface_complex) success(text); } +BOOST_AUTO_TEST_CASE(warn_about_throw) +{ + char const* text = R"( + contract C { + function f() { + throw; + } + } + )"; + CHECK_WARNING(text, "\"throw\" is deprecated"); +} + BOOST_AUTO_TEST_CASE(bare_revert) { char const* text = R"( -- cgit v1.2.3 From f09c55f89c4d15c02fee9175ce38ca35a6e3828f Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 6 Jul 2017 11:06:13 +0200 Subject: Release date for 0.4.13 --- Changelog.md | 2 +- docs/bugs_by_version.json | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index 8ba06aaf..4d84d7a1 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,4 +1,4 @@ -### 0.4.13 (unreleased) +### 0.4.13 (2017-07-06) Features: * Syntax Checker: Deprecated "throw" in favour of require(), assert() and revert(). diff --git a/docs/bugs_by_version.json b/docs/bugs_by_version.json index cab79f05..d6802eec 100644 --- a/docs/bugs_by_version.json +++ b/docs/bugs_by_version.json @@ -301,6 +301,10 @@ "bugs": [], "released": "2017-07-03" }, + "0.4.13": { + "bugs": [], + "released": "2017-07-06" + }, "0.4.2": { "bugs": [ "SkipEmptyStringLiteral", -- cgit v1.2.3