diff options
-rw-r--r-- | .circleci/config.yml | 4 | ||||
-rw-r--r-- | docs/050-breaking-changes.rst | 2 | ||||
-rw-r--r-- | docs/abi-spec.rst | 13 | ||||
-rw-r--r-- | docs/installing-solidity.rst | 52 | ||||
-rw-r--r-- | docs/introduction-to-smart-contracts.rst | 2 | ||||
-rw-r--r-- | docs/solidity-by-example.rst | 2 | ||||
-rw-r--r-- | docs/types.rst | 4 | ||||
-rw-r--r-- | libevmasm/Assembly.cpp | 13 | ||||
-rw-r--r-- | libevmasm/CommonSubexpressionEliminator.cpp | 2 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 4 | ||||
-rw-r--r-- | libsolidity/analysis/ViewPureChecker.cpp | 8 | ||||
-rw-r--r-- | libsolidity/ast/AST.cpp | 11 | ||||
-rw-r--r-- | libsolidity/ast/AST.h | 2 | ||||
-rw-r--r-- | libsolidity/ast/Types.cpp | 2 | ||||
-rw-r--r-- | libsolidity/codegen/CompilerUtils.h | 2 | ||||
-rw-r--r-- | libsolidity/parsing/Scanner.cpp | 2 | ||||
-rw-r--r-- | scripts/codespell_whitelist.txt | 1 | ||||
-rw-r--r-- | test/compilationTests/zeppelin/token/VestedToken.sol | 2 | ||||
-rw-r--r-- | test/libsolidity/syntaxTests/types/address/literal_to_address.sol | 1 |
19 files changed, 80 insertions, 49 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index 8766883d..f8e380d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -141,7 +141,7 @@ jobs: build_x86_mac: macos: - xcode: "9.0" + xcode: "10.0.0" environment: TERM: xterm steps: @@ -236,7 +236,7 @@ jobs: test_x86_mac: macos: - xcode: "9.0" + xcode: "10.0.0" environment: TERM: xterm steps: diff --git a/docs/050-breaking-changes.rst b/docs/050-breaking-changes.rst index b49dd1e0..9094000e 100644 --- a/docs/050-breaking-changes.rst +++ b/docs/050-breaking-changes.rst @@ -53,7 +53,7 @@ Semantic and Syntactic Changes This section highlights changes that affect syntax and semantics. -* The functions ``.call()``, ``.delegatecall()`, ``staticcall()``, +* The functions ``.call()``, ``.delegatecall()``, ``staticcall()``, ``keccak256()``, ``sha256()`` and ``ripemd160()`` now accept only a single ``bytes`` argument. Moreover, the argument is not padded. This was changed to make more explicit and clear how the arguments are concatenated. Change every diff --git a/docs/abi-spec.rst b/docs/abi-spec.rst index 7c9d9f9e..f31d9d45 100644 --- a/docs/abi-spec.rst +++ b/docs/abi-spec.rst @@ -102,18 +102,19 @@ them. |:ref:`struct<structs>` |``tuple`` | +-------------------------------+-----------------------------------------------------------------------------+ -Formal Specification of the Encoding -==================================== +Design Criteria for the Encoding +================================ -We will now formally specify the encoding, such that it will have the following -properties, which are especially useful if some arguments are nested arrays: - -Properties: +The encoding is designed to have the following properties, which are especially useful if some arguments are nested arrays: 1. The number of reads necessary to access a value is at most the depth of the value inside the argument array structure, i.e. four reads are needed to retrieve ``a_i[k][l][r]``. In a previous version of the ABI, the number of reads scaled linearly with the total number of dynamic parameters in the worst case. 2. The data of a variable or array element is not interleaved with other data and it is relocatable, i.e. it only uses relative "addresses". + +Formal Specification of the Encoding +==================================== + We distinguish static and dynamic types. Static types are encoded in-place and dynamic types are encoded at a separately allocated location after the current block. **Definition:** The following types are called "dynamic": diff --git a/docs/installing-solidity.rst b/docs/installing-solidity.rst index ba373b8f..9d4be70d 100644 --- a/docs/installing-solidity.rst +++ b/docs/installing-solidity.rst @@ -154,28 +154,18 @@ Gentoo Linux also provides a solidity package that can be installed using ``emer Building from Source ==================== -Clone the Repository --------------------- - -To clone the source code, execute the following command: - -.. code-block:: bash - - git clone --recursive https://github.com/ethereum/solidity.git - cd solidity - -If you want to help developing Solidity, -you should fork Solidity and add your personal fork as a second remote: - -.. code-block:: bash - - git remote add personal git@github.com:[username]/solidity.git +Prerequisites - Linux +--------------------- -Solidity has git submodules. Ensure they are properly loaded: +You need to install the following dependencies for Linux builds of Solidity: -.. code-block:: bash ++-----------------------------------+-------------------------------------------------------+ +| Software | Notes | ++===================================+=======================================================+ +| `Git for Linux`_ | Command-line tool for retrieving source from Github. | ++-----------------------------------+-------------------------------------------------------+ - git submodule update --init --recursive +.. _Git for Linux: https://git-scm.com/download/linux Prerequisites - macOS --------------------- @@ -203,7 +193,7 @@ if you ever want to start again from scratch. Prerequisites - Windows ----------------------- -You will need to install the following dependencies for Windows builds of Solidity: +You need to install the following dependencies for Windows builds of Solidity: +-----------------------------------+-------------------------------------------------------+ | Software | Notes | @@ -238,6 +228,28 @@ in Visual Studio 2017 Build Tools or Visual Studio 2017: .. _Visual Studio 2017: https://www.visualstudio.com/vs/ .. _Visual Studio 2017 Build Tools: https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017 +Clone the Repository +-------------------- + +To clone the source code, execute the following command: + +.. code-block:: bash + + git clone --recursive https://github.com/ethereum/solidity.git + cd solidity + +If you want to help developing Solidity, +you should fork Solidity and add your personal fork as a second remote: + +.. code-block:: bash + + git remote add personal git@github.com:[username]/solidity.git + +Solidity has git submodules. Ensure they are properly loaded: + +.. code-block:: bash + + git submodule update --init --recursive External Dependencies --------------------- diff --git a/docs/introduction-to-smart-contracts.rst b/docs/introduction-to-smart-contracts.rst index 5e841417..f5d5f89e 100644 --- a/docs/introduction-to-smart-contracts.rst +++ b/docs/introduction-to-smart-contracts.rst @@ -33,7 +33,7 @@ Storage The first line simply tells that the source code is written for Solidity version 0.4.0 or anything newer that does not break functionality -(up to, but not including, version 0.5.0). This is to ensure that the +(up to, but not including, version 0.6.0). This is to ensure that the contract is not compilable with a new (breaking) compiler version, where it could behave differently. So-called pragmas are common instructions for compilers about how to treat the source code (e.g. `pragma once <https://en.wikipedia.org/wiki/Pragma_once>`_). diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index 0f9a71ab..1bbd42f8 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -242,7 +242,7 @@ activate themselves. mapping(address => uint) pendingReturns; // Set to true at the end, disallows any change. - // By defaul initialized to `false`. + // By default initialized to `false`. bool ended; // Events that will be emitted on changes. diff --git a/docs/types.rst b/docs/types.rst index 84c448ff..dfe77728 100644 --- a/docs/types.rst +++ b/docs/types.rst @@ -499,9 +499,9 @@ terminate the string literal. Newline only terminates the string literal if it i Hexadecimal Literals -------------------- -Hexademical Literals are prefixed with the keyword ``hex`` and are enclosed in double or single-quotes (``hex"001122FF"``). Their content must be a hexadecimal string and their value will be the binary representation of those values. +Hexadecimal literals are prefixed with the keyword ``hex`` and are enclosed in double or single-quotes (``hex"001122FF"``). Their content must be a hexadecimal string and their value will be the binary representation of those values. -Hexademical Literals behave like String Literals and have the same convertibility restrictions. +Hexadecimal literals behave like string literals and have the same convertibility restrictions. .. index:: enum diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 63452f36..c2eaa1ca 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -41,10 +41,19 @@ void Assembly::append(Assembly const& _a) auto newDeposit = m_deposit + _a.deposit(); for (AssemblyItem i: _a.m_items) { - if (i.type() == Tag || i.type() == PushTag) + switch (i.type()) + { + case Tag: + case PushTag: i.setData(i.data() + m_usedTags); - else if (i.type() == PushSub || i.type() == PushSubSize) + break; + case PushSub: + case PushSubSize: i.setData(i.data() + m_subs.size()); + break; + default: + break; + } append(i); } m_deposit = newDeposit; diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index 293cb02c..39485dd9 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -160,7 +160,7 @@ AssemblyItems CSECodeGenerator::generateCode( if (seqNr < _initialSequenceNumber) // Invalid sequenced operation. // @todo quick fix for now. Proper fix needs to choose representative with higher - // sequence number during dependency analyis. + // sequence number during dependency analysis. BOOST_THROW_EXCEPTION(StackTooDeepException()); sequencedExpressions.insert(make_pair(seqNr, id)); } diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 3d119c82..bc040623 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2398,11 +2398,11 @@ void TypeChecker::endVisit(Literal const& _literal) _literal.annotation().type = make_shared<AddressType>(StateMutability::Payable); string msg; - if (_literal.value().length() != 42) // "0x" + 40 hex digits + if (_literal.valueWithoutUnderscores().length() != 42) // "0x" + 40 hex digits // looksLikeAddress enforces that it is a hex literal starting with "0x" msg = "This looks like an address but is not exactly 40 hex digits. It is " + - to_string(_literal.value().length() - 2) + + to_string(_literal.valueWithoutUnderscores().length() - 2) + " hex digits."; else if (!_literal.passesAddressChecksum()) { diff --git a/libsolidity/analysis/ViewPureChecker.cpp b/libsolidity/analysis/ViewPureChecker.cpp index 113a3177..b0cacc43 100644 --- a/libsolidity/analysis/ViewPureChecker.cpp +++ b/libsolidity/analysis/ViewPureChecker.cpp @@ -292,11 +292,11 @@ void ViewPureChecker::endVisit(FunctionCall const& _functionCall) if (_functionCall.annotation().kind != FunctionCallKind::FunctionCall) return; - StateMutability mut = dynamic_cast<FunctionType const&>(*_functionCall.expression().annotation().type).stateMutability(); + StateMutability mutability = dynamic_cast<FunctionType const&>(*_functionCall.expression().annotation().type).stateMutability(); // We only require "nonpayable" to call a payble function. - if (mut == StateMutability::Payable) - mut = StateMutability::NonPayable; - reportMutability(mut, _functionCall.location()); + if (mutability == StateMutability::Payable) + mutability = StateMutability::NonPayable; + reportMutability(mutability, _functionCall.location()); } bool ViewPureChecker::visit(MemberAccess const& _memberAccess) diff --git a/libsolidity/ast/AST.cpp b/libsolidity/ast/AST.cpp index a11b1146..d9264230 100644 --- a/libsolidity/ast/AST.cpp +++ b/libsolidity/ast/AST.cpp @@ -633,6 +633,11 @@ IdentifierAnnotation& Identifier::annotation() const return dynamic_cast<IdentifierAnnotation&>(*m_annotation); } +ASTString Literal::valueWithoutUnderscores() const +{ + return boost::erase_all_copy(value(), "_"); +} + bool Literal::isHexNumber() const { if (token() != Token::Number) @@ -648,20 +653,20 @@ bool Literal::looksLikeAddress() const if (!isHexNumber()) return false; - return abs(int(value().length()) - 42) <= 1; + return abs(int(valueWithoutUnderscores().length()) - 42) <= 1; } bool Literal::passesAddressChecksum() const { solAssert(isHexNumber(), "Expected hex number"); - return dev::passesAddressChecksum(value(), true); + return dev::passesAddressChecksum(valueWithoutUnderscores(), true); } string Literal::getChecksummedAddress() const { solAssert(isHexNumber(), "Expected hex number"); /// Pad literal to be a proper hex address. - string address = value().substr(2); + string address = valueWithoutUnderscores().substr(2); if (address.length() > 40) return string(); address.insert(address.begin(), 40 - address.size(), '0'); diff --git a/libsolidity/ast/AST.h b/libsolidity/ast/AST.h index f3464f92..b84f9730 100644 --- a/libsolidity/ast/AST.h +++ b/libsolidity/ast/AST.h @@ -1679,6 +1679,8 @@ public: /// @returns the non-parsed value of the literal ASTString const& value() const { return *m_value; } + ASTString valueWithoutUnderscores() const; + SubDenomination subDenomination() const { return m_subDenomination; } /// @returns true if this is a number with a hex prefix. diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index fd72bf41..e45fc81d 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -499,7 +499,7 @@ u256 AddressType::literalValue(Literal const* _literal) const { solAssert(_literal, ""); solAssert(_literal->value().substr(0, 2) == "0x", ""); - return u256(_literal->value()); + return u256(_literal->valueWithoutUnderscores()); } TypePointer AddressType::unaryOperatorResult(Token::Value _operator) const diff --git a/libsolidity/codegen/CompilerUtils.h b/libsolidity/codegen/CompilerUtils.h index ad3d7327..bd8170ad 100644 --- a/libsolidity/codegen/CompilerUtils.h +++ b/libsolidity/codegen/CompilerUtils.h @@ -260,7 +260,7 @@ public: /// Stack post: <shifted_value> void rightShiftNumberOnStack(unsigned _bits); - /// Appends code that computes tha Keccak-256 hash of the topmost stack element of 32 byte type. + /// Appends code that computes the Keccak-256 hash of the topmost stack element of 32 byte type. void computeHashStatic(); /// Bytes we need to the start of call data. diff --git a/libsolidity/parsing/Scanner.cpp b/libsolidity/parsing/Scanner.cpp index 0f6d6996..9a7f85cb 100644 --- a/libsolidity/parsing/Scanner.cpp +++ b/libsolidity/parsing/Scanner.cpp @@ -601,7 +601,7 @@ void Scanner::scanToken() { tie(token, m, n) = scanIdentifierOrKeyword(); - // Special case for hexademical literals + // Special case for hexadecimal literals if (token == Token::Hex) { // reset diff --git a/scripts/codespell_whitelist.txt b/scripts/codespell_whitelist.txt index 31f03981..0f5013cb 100644 --- a/scripts/codespell_whitelist.txt +++ b/scripts/codespell_whitelist.txt @@ -1,3 +1,4 @@ iff nd assignend +uint diff --git a/test/compilationTests/zeppelin/token/VestedToken.sol b/test/compilationTests/zeppelin/token/VestedToken.sol index 2cd607bc..c9469f16 100644 --- a/test/compilationTests/zeppelin/token/VestedToken.sol +++ b/test/compilationTests/zeppelin/token/VestedToken.sol @@ -234,7 +234,7 @@ contract VestedToken is StandardToken, LimitedTransferToken { } /** - * @dev Calculate the date when the holder can trasfer all its tokens + * @dev Calculate the date when the holder can transfer all its tokens * @param holder address The address of the holder * @return An uint256 representing the date of the last transferable tokens. */ diff --git a/test/libsolidity/syntaxTests/types/address/literal_to_address.sol b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol index 9d599ea5..20ee56de 100644 --- a/test/libsolidity/syntaxTests/types/address/literal_to_address.sol +++ b/test/libsolidity/syntaxTests/types/address/literal_to_address.sol @@ -4,5 +4,6 @@ contract C { a = address(1); address b = 0x0123456789012345678901234567890123456789; b = 0x9876543210987654321098765432109876543210; + b = 0x9876_5432_1098_7654_3210_9876_5432_1098_7654_3210; } } |