Skip to content

Commit

Permalink
Merge pull request #9186 from ethereum/develop
Browse files Browse the repository at this point in the history
Merge develop into release for 0.6.10
  • Loading branch information
chriseth authored Jun 11, 2020
2 parents 3e3065a + bb6d677 commit 00c0fca
Show file tree
Hide file tree
Showing 146 changed files with 1,685 additions and 641 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ include(EthPolicy)
eth_policy()

# project name and version should be set after cmake_policy CMP0048
set(PROJECT_VERSION "0.6.9")
set(PROJECT_VERSION "0.6.10")
# OSX target needed in order to support std::visit
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
project(solidity VERSION ${PROJECT_VERSION} LANGUAGES C CXX)
Expand Down
19 changes: 19 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
### 0.6.10 (2020-06-11)

Important Bugfixes:
* Fixed a bug related to internal library functions with ``calldata`` parameters called via ``using for``.


Compiler Features:
* Commandline Interface: Re-group help screen.
* Output compilation error codes in standard-json and when using ``--error-codes``.
* Yul: Raise warning for switch statements that only have a default and no other cases.


Bugfixes:
* SMTChecker: Fix internal error when encoding tuples of tuples.
* SMTChecker: Fix aliasing soundness after pushing to an array pointer.
* Type system: Fix internal compiler error on calling externally a function that returns variables with calldata location.
* Type system: Fix bug where a bound function was not found if ``using for`` is applied to explicit reference types.


### 0.6.9 (2020-06-04)

Language Features:
Expand Down
8 changes: 4 additions & 4 deletions ReleaseChecklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
- [ ] Readthedocs account, access to the Solidity project
- [ ] Write access to https://github.com/ethereum/homebrew-ethereum

### Pre-release
- [ ] Ensure that a Github project exists for the release.
- [ ] Check that all issues and pull requests from the Github project to be released are merged to ``develop``.
### Blog Post
- [ ] Create a post on https://github.com/ethereum/solidity-blog and explain some of the new features or concepts.

### Changelog
- [ ] Sort the changelog entries alphabetically and correct any errors you notice.
Expand All @@ -33,8 +32,9 @@
- [ ] Wait for the ``~ethereum/ubuntu/ethereum-static`` PPA build to be finished and published for *all platforms*. SERIOUSLY: DO NOT PROCEED EARLIER!!! *After* the static builds are *published*, copy the static package to the ``~ethereum/ubuntu/ethereum`` PPA for the destination series ``Trusty`` and ``Xenial`` while selecting ``Copy existing binaries``.
- [ ] Check that the Docker release was pushed to Docker Hub (this still seems to have problems, run ``./scripts/docker_deploy_manual.sh v0.x.x``).

### Homebrew
### Homebrew and MacOS
- [ ] Update the version and the hash (``sha256sum solidity_x.x.x.tar.gz``) in https://github.com/ethereum/homebrew-ethereum/blob/master/solidity.rb
- [ ] Take the binary from the ``b_osx`` run of the released commit in circle-ci and add it to the release page as ``solc-macos``.

### Documentation
- [ ] Build the new version on https://readthedocs.org/projects/solidity/ (select `latest` on the bottom of the page and click `BUILD`)
Expand Down
3 changes: 2 additions & 1 deletion docs/060-breaking-changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ For most of the topics the compiler will provide suggestions.
storage arrays.

* The new keyword ``abstract`` can be used to mark contracts as abstract. It has to be used
if a contract does not implement all its functions.
if a contract does not implement all its functions. Abstract contracts cannot be created using the ``new`` operator,
and it is not possible to generate bytecode for them during compilation.

* Libraries have to implement all their functions, not only the internal ones.

Expand Down
8 changes: 6 additions & 2 deletions docs/Solidity.g4
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ userDefinedTypeName
: identifier ( '.' identifier )* ;

mapping
: 'mapping' '(' (elementaryTypeName | userDefinedTypeName) '=>' typeName ')' ;
: 'mapping' '(' mappingKey '=>' typeName ')' ;

mappingKey
: elementaryTypeName
| userDefinedTypeName ;

functionTypeName
: 'function' parameterList modifierList returnParameters? ;
Expand Down Expand Up @@ -470,7 +474,7 @@ SingleQuotedStringCharacter
: ~['\r\n\\] | ('\\' .) ;
VersionLiteral
: [0-9]+ '.' [0-9]+ ('.' [0-9]+)? ;
: [0-9]+ ( '.' [0-9]+ ('.' [0-9]+)? )? ;
WS
: [ \t\r\n\u000C]+ -> skip ;
Expand Down
2 changes: 1 addition & 1 deletion docs/abi-spec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Function Selector
=================

The first four bytes of the call data for a function call specifies the function to be called. It is the
first (left, high-order in big-endian) four bytes of the Keccak-256 (SHA-3) hash of the signature of
first (left, high-order in big-endian) four bytes of the Keccak-256 hash of the signature of
the function. The signature is defined as the canonical expression of the basic prototype without data
location specifier, i.e.
the function name with the parenthesised list of parameter types. Parameter types are split by a single
Expand Down
8 changes: 8 additions & 0 deletions docs/bugs.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
[
{
"name": "UsingForCalldata",
"summary": "Function calls to internal library functions with calldata parameters called via ``using for`` can result in invalid data being read.",
"description": "Function calls to internal library functions using the ``using for`` mechanism copied all calldata parameters to memory first and passed them on like that, regardless of whether it was an internal or an external call. Due to that, the called function would receive a memory pointer that is interpreted as a calldata pointer. Since dynamically sized arrays are passed using two stack slots for calldata, but only one for memory, this can lead to stack corruption. An affected library call will consider the JUMPDEST to which it is supposed to return as part of its arguments and will instead jump out to whatever was on the stack before the call.",
"introduced": "0.6.9",
"fixed": "0.6.10",
"severity": "very low"
},
{
"name": "MissingEscapingInFormatting",
"summary": "String literals containing double backslash characters passed directly to external or encoding function calls can lead to a different string being used when ABIEncoderV2 is enabled.",
Expand Down
8 changes: 7 additions & 1 deletion docs/bugs_by_version.json
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,10 @@
],
"released": "2020-01-02"
},
"0.6.10": {
"bugs": [],
"released": "2020-06-11"
},
"0.6.2": {
"bugs": [
"MissingEscapingInFormatting",
Expand Down Expand Up @@ -1165,7 +1169,9 @@
"released": "2020-05-14"
},
"0.6.9": {
"bugs": [],
"bugs": [
"UsingForCalldata"
],
"released": "2020-06-04"
}
}
8 changes: 4 additions & 4 deletions docs/contracts/inheritance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ not known in the context of the class where it is used,
although its type is known. This is similar for ordinary
virtual method lookup.

.. _function-overriding:

.. index:: ! overriding;function

.. _function-overriding:

Function Overriding
===================

Expand Down Expand Up @@ -317,10 +317,10 @@ of the variable:
While public state variables can override external functions, they themselves cannot
be overridden.

.. _modifier-overriding:

.. index:: ! overriding;modifier

.. _modifier-overriding:

Modifier Overriding
===================

Expand Down
8 changes: 7 additions & 1 deletion docs/types/reference-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,13 @@ Array slices are useful to ABI-decode secondary data passed in function paramete
/// Forward call to "setOwner(address)" that is implemented by client
/// after doing basic validation on the address argument.
function forward(bytes calldata _payload) external {
bytes4 sig = abi.decode(_payload[:4], (bytes4));
// Since ABI decoding requires padded data, we cannot
// use abi.decode(_payload[:4], (bytes4)).
bytes4 sig =
_payload[0] |
(bytes4(_payload[1]) >> 8) |
(bytes4(_payload[2]) >> 16) |
(bytes4(_payload[3]) >> 24);
if (sig == bytes4(keccak256("setOwner(address)"))) {
address owner = abi.decode(_payload[4:], (address));
require(owner != address(0), "Address of owner cannot be zero.");
Expand Down
4 changes: 3 additions & 1 deletion docs/using-the-compiler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,10 @@ Output Description
"component": "general",
// Mandatory ("error" or "warning")
"severity": "error",
// Optional: unique code for the cause of the error
"errorCode": "3141",
// Mandatory
"message": "Invalid keyword"
"message": "Invalid keyword",
// Optional: the message formatted with source location
"formattedMessage": "sourceFile.sol:100: Invalid keyword"
}
Expand Down
10 changes: 9 additions & 1 deletion liblangutil/SourceReferenceExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ SourceReferenceExtractor::Message SourceReferenceExtractor::extract(util::Except
for (auto const& info: secondaryLocation->infos)
secondary.emplace_back(extract(&info.second, info.first));

return Message{std::move(primary), _category, std::move(secondary)};
return Message{std::move(primary), _category, std::move(secondary), nullopt};
}

SourceReferenceExtractor::Message SourceReferenceExtractor::extract(Error const& _error)
{
string category = (_error.type() == Error::Type::Warning) ? "Warning" : "Error";
Message message = extract(_error, category);
message.errorId = _error.errorId();
return message;
}

SourceReference SourceReferenceExtractor::extract(SourceLocation const* _location, std::string message)
Expand Down
12 changes: 5 additions & 7 deletions liblangutil/SourceReferenceExtractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
*/
#pragma once

#include <liblangutil/Exceptions.h>

#include <iosfwd>
#include <optional>
#include <string>
#include <tuple>
#include <vector>

namespace solidity::util
{
struct Exception;
}

namespace solidity::langutil
{

Expand Down Expand Up @@ -58,18 +56,18 @@ struct SourceReference
}
};

struct SourceLocation;

namespace SourceReferenceExtractor
{
struct Message
{
SourceReference primary;
std::string category; // "Error", "Warning", ...
std::vector<SourceReference> secondary;
std::optional<ErrorId> errorId;
};

Message extract(util::Exception const& _exception, std::string _category);
Message extract(Error const& _error);
SourceReference extract(SourceLocation const* _location, std::string message = "");
}

Expand Down
5 changes: 1 addition & 4 deletions liblangutil/SourceReferenceFormatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ void SourceReferenceFormatter::printExceptionInformation(util::Exception const&

void SourceReferenceFormatter::printErrorInformation(Error const& _error)
{
printExceptionInformation(
_error,
(_error.type() == Error::Type::Warning) ? "Warning" : "Error"
);
printExceptionInformation(SourceReferenceExtractor::extract(_error));
}

void SourceReferenceFormatter::printExceptionInformation(SourceReferenceExtractor::Message const& _msg)
Expand Down
2 changes: 2 additions & 0 deletions liblangutil/SourceReferenceFormatterHuman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ void SourceReferenceFormatterHuman::printExceptionInformation(SourceReferenceExt
{
// exception header line
errorColored() << _msg.category;
if (m_withErrorIds && _msg.errorId.has_value())
errorColored() << " (" << _msg.errorId.value().error << ")";
messageColored() << ": " << _msg.primary.message << '\n';

printSourceLocation(_msg.primary);
Expand Down
18 changes: 6 additions & 12 deletions liblangutil/SourceReferenceFormatterHuman.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,14 @@
#include <sstream>
#include <functional>

namespace solidity::util
{
struct Exception; // forward
}

namespace solidity::langutil
{

struct SourceLocation;
struct SourceReference;

class SourceReferenceFormatterHuman: public SourceReferenceFormatter
{
public:
SourceReferenceFormatterHuman(std::ostream& _stream, bool colored):
SourceReferenceFormatter{_stream}, m_colored{colored}
SourceReferenceFormatterHuman(std::ostream& _stream, bool _colored, bool _withErrorIds):
SourceReferenceFormatter{_stream}, m_colored{_colored}, m_withErrorIds(_withErrorIds)
{}

void printSourceLocation(SourceReference const& _ref) override;
Expand All @@ -54,12 +46,13 @@ class SourceReferenceFormatterHuman: public SourceReferenceFormatter
static std::string formatExceptionInformation(
util::Exception const& _exception,
std::string const& _name,
bool colored = false
bool _colored = false,
bool _withErrorIds = false
)
{
std::ostringstream errorOutput;

SourceReferenceFormatterHuman formatter(errorOutput, colored);
SourceReferenceFormatterHuman formatter(errorOutput, _colored, _withErrorIds);
formatter.printExceptionInformation(_exception, _name);
return errorOutput.str();
}
Expand All @@ -75,6 +68,7 @@ class SourceReferenceFormatterHuman: public SourceReferenceFormatter

private:
bool m_colored;
bool m_withErrorIds;
};

}
29 changes: 16 additions & 13 deletions libsolidity/analysis/OverrideChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct OverrideGraph
std::map<OverrideProxy, int> nodes;
std::map<int, OverrideProxy> nodeInv;
std::map<int, std::set<int>> edges;
int numNodes = 2;
size_t numNodes = 2;
void addEdge(int _a, int _b)
{
edges[_a].insert(_b);
Expand All @@ -82,7 +82,7 @@ struct OverrideGraph
auto it = nodes.find(_function);
if (it != nodes.end())
return it->second;
int currentNode = numNodes++;
int currentNode = static_cast<int>(numNodes++);
nodes[_function] = currentNode;
nodeInv[currentNode] = _function;
if (_function.overrides())
Expand Down Expand Up @@ -116,21 +116,24 @@ struct CutVertexFinder
std::vector<int> m_parent = std::vector<int>(m_graph.numNodes, -1);
std::set<OverrideProxy> m_cutVertices{};

void run(int _u = 0, int _depth = 0)
void run(size_t _u = 0, size_t _depth = 0)
{
m_visited.at(_u) = true;
m_depths.at(_u) = m_low.at(_u) = _depth;
for (int v: m_graph.edges.at(_u))
if (!m_visited.at(v))
m_depths.at(_u) = m_low.at(_u) = static_cast<int>(_depth);
for (int const v: m_graph.edges.at(static_cast<int>(_u)))
{
auto const vInd = static_cast<size_t>(v);
if (!m_visited.at(vInd))
{
m_parent[v] = _u;
run(v, _depth + 1);
if (m_low[v] >= m_depths[_u] && m_parent[_u] != -1)
m_cutVertices.insert(m_graph.nodeInv.at(_u));
m_low[_u] = min(m_low[_u], m_low[v]);
m_parent[vInd] = static_cast<int>(_u);
run(vInd, _depth + 1);
if (m_low[vInd] >= m_depths[_u] && m_parent[_u] != -1)
m_cutVertices.insert(m_graph.nodeInv.at(static_cast<int>(_u)));
m_low[_u] = min(m_low[_u], m_low[vInd]);
}
else if (v != m_parent[_u])
m_low[_u] = min(m_low[_u], m_depths[v]);
m_low[_u] = min(m_low[_u], m_depths[vInd]);
}
}
};

Expand Down Expand Up @@ -213,7 +216,7 @@ bool OverrideProxy::CompareBySignature::operator()(OverrideProxy const& _a, Over
size_t OverrideProxy::id() const
{
return std::visit(GenericVisitor{
[&](auto const* _item) -> size_t { return _item->id(); }
[&](auto const* _item) -> size_t { return static_cast<size_t>(_item->id()); }
}, m_item);
}

Expand Down
Loading

0 comments on commit 00c0fca

Please sign in to comment.