Merge pull request #10097 from ethereum/develop

Merge develop into breaking.
This commit is contained in:
chriseth
2020-10-23 10:30:24 +02:00
committed by GitHub
61 changed files with 498 additions and 599 deletions
+90
View File
@@ -1505,6 +1505,96 @@ BOOST_AUTO_TEST_CASE(stopAfter_ast_output)
BOOST_CHECK(result["sources"]["a.sol"]["ast"].isObject());
}
BOOST_AUTO_TEST_CASE(dependency_tracking_of_abstract_contract)
{
char const* input = R"(
{
"language": "Solidity",
"sources": {
"BlockRewardAuRaBase.sol": {
"content": " contract Sacrifice { constructor() payable {} } abstract contract BlockRewardAuRaBase { function _transferNativeReward() internal { new Sacrifice(); } function _distributeTokenRewards() internal virtual; } "
},
"BlockRewardAuRaCoins.sol": {
"content": " import \"./BlockRewardAuRaBase.sol\"; contract BlockRewardAuRaCoins is BlockRewardAuRaBase { function transferReward() public { _transferNativeReward(); } function _distributeTokenRewards() internal override {} } "
}
},
"settings": {
"outputSelection": {
"BlockRewardAuRaCoins.sol": {
"BlockRewardAuRaCoins": ["ir", "evm.bytecode.sourceMap"]
}
}
}
}
)";
Json::Value parsedInput;
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
solidity::frontend::StandardCompiler compiler;
Json::Value result = compiler.compile(parsedInput);
BOOST_REQUIRE(result["contracts"].isObject());
BOOST_REQUIRE(result["contracts"].size() == 1);
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"].isObject());
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"].size() == 1);
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"].isObject());
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"].isObject());
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["ir"].isString());
BOOST_REQUIRE(result["contracts"]["BlockRewardAuRaCoins.sol"]["BlockRewardAuRaCoins"]["evm"]["bytecode"].isObject());
BOOST_REQUIRE(result["sources"].isObject());
BOOST_REQUIRE(result["sources"].size() == 2);
}
BOOST_AUTO_TEST_CASE(dependency_tracking_of_abstract_contract_yul)
{
char const* input = R"(
{
"language": "Solidity",
"sources": {
"A.sol": {
"content": "contract A {} contract B {} contract C { constructor() { new B(); } } contract D {}"
}
},
"settings": {
"outputSelection": {
"A.sol": {
"C": ["ir"]
}
}
}
}
)";
Json::Value parsedInput;
BOOST_REQUIRE(util::jsonParseStrict(input, parsedInput));
solidity::frontend::StandardCompiler compiler;
Json::Value result = compiler.compile(parsedInput);
BOOST_REQUIRE(result["contracts"].isObject());
BOOST_REQUIRE(result["contracts"].size() == 1);
BOOST_REQUIRE(result["contracts"]["A.sol"].isObject());
BOOST_REQUIRE(result["contracts"]["A.sol"].size() == 1);
BOOST_REQUIRE(result["contracts"]["A.sol"]["C"].isObject());
BOOST_REQUIRE(result["contracts"]["A.sol"]["C"]["ir"].isString());
const string& irCode = result["contracts"]["A.sol"]["C"]["ir"].asString();
// Make sure C and B contracts are deployed
BOOST_REQUIRE(irCode.find("object \"C") != string::npos);
BOOST_REQUIRE(irCode.find("object \"B") != string::npos);
// Make sure A and D are NOT deployed as they were not requested and are not
// in any dependency
BOOST_REQUIRE(irCode.find("object \"A") == string::npos);
BOOST_REQUIRE(irCode.find("object \"D") == string::npos);
BOOST_REQUIRE(result["sources"].isObject());
BOOST_REQUIRE(result["sources"].size() == 1);
}
BOOST_AUTO_TEST_SUITE_END()
} // end namespaces
@@ -11,5 +11,7 @@ contract D {
return test();
}
}
// ====
// compileViaYul: true
// ----
// f() -> true
@@ -11,5 +11,7 @@ contract D {
return test();
}
}
// ====
// compileViaYul: true
// ----
// f() -> 2
@@ -24,8 +24,11 @@ contract C {
}
// ----
// Warning 1218: (168-184): CHC: Error trying to invoke SMT solver.
// Warning 6328: (168-184): CHC: Assertion violation might happen here.
// Warning 1218: (305-321): CHC: Error trying to invoke SMT solver.
// Warning 6328: (305-321): CHC: Assertion violation might happen here.
// Warning 1218: (448-464): CHC: Error trying to invoke SMT solver.
// Warning 6328: (448-464): CHC: Assertion violation might happen here.
// Warning 6328: (673-689): CHC: Assertion violation happens here.
// Warning 4661: (168-184): BMC: Assertion violation happens here.
// Warning 4661: (305-321): BMC: Assertion violation happens here.
@@ -46,8 +46,11 @@ contract C {
}
// ----
// Warning 1218: (726-745): CHC: Error trying to invoke SMT solver.
// Warning 6328: (726-745): CHC: Assertion violation might happen here.
// Warning 1218: (749-768): CHC: Error trying to invoke SMT solver.
// Warning 6328: (749-768): CHC: Assertion violation might happen here.
// Warning 1218: (772-791): CHC: Error trying to invoke SMT solver.
// Warning 6328: (772-791): CHC: Assertion violation might happen here.
// Warning 6328: (795-814): CHC: Assertion violation happens here.
// Warning 4661: (726-745): BMC: Assertion violation happens here.
// Warning 4661: (749-768): BMC: Assertion violation happens here.
@@ -0,0 +1,20 @@
pragma experimental SMTChecker;
contract A {
function f() external {}
function g(uint256) external {}
}
contract B {
function f() external returns (uint256) {}
function g(uint256) external returns (uint256) {}
}
contract C {
function test1() external pure returns(bytes4, bytes4, bytes4, bytes4) {
return (A.f.selector, A.g.selector, B.f.selector, B.g.selector);
}
function test2() external pure returns(bytes4, bytes4, bytes4, bytes4) {
A a; B b;
return (a.f.selector, a.g.selector, b.f.selector, b.g.selector);
}
}
// ====
@@ -0,0 +1,31 @@
pragma experimental SMTChecker;
contract C {
uint256 public x;
function f() public pure returns (bytes4) {
return this.f.selector;
}
function g() public view returns (bytes4) {
function () pure external returns (bytes4) fun = this.f;
return fun.selector;
}
function i() public pure returns (bytes4) {
return this.x.selector;
}
function check() public view {
assert(f() == 0x26121ff0);
assert(g() == 0x26121ff0);
assert(i() == 0x0c55699c);
assert(i() == 0x26121ff0);
}
}
// ----
// Warning 6328: (470-495): CHC: Assertion violation happens here.
// Warning 6328: (540-565): CHC: Assertion violation happens here.
// Warning 6031: (261-267): Internal error: Expression undefined for SMT solver.
// Warning 7650: (284-296): Assertion checker does not yet support this expression.
// Warning 7650: (284-296): Assertion checker does not yet support this expression.
@@ -0,0 +1,46 @@
pragma experimental SMTChecker;
interface ERC165 {
/// @notice Query if a contract implements an interface
/// @param interfaceID The interface identifier, as specified in ERC-165
/// @dev Interface identification is specified in ERC-165. This function
/// uses less than 30,000 gas.
/// @return `true` if the contract implements `interfaceID` and
/// `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceID) external view returns (bool);
}
interface Simpson {
function is2D() external returns (bool);
function skinColor() external returns (string memory);
}
interface PeaceMaker {
function achieveWorldPeace() external;
}
contract Homer is ERC165, Simpson {
function supportsInterface(bytes4 interfaceID) public pure override returns (bool) {
return
interfaceID == this.supportsInterface.selector || // ERC165
interfaceID == this.is2D.selector ^ this.skinColor.selector; // Simpson
}
function is2D() external pure override returns (bool) {
return true;
}
function skinColor() external pure override returns (string memory) {
return "yellow";
}
function check() public pure {
assert(supportsInterface(type(Simpson).interfaceId));
assert(supportsInterface(type(ERC165).interfaceId));
assert(supportsInterface(type(PeaceMaker).interfaceId));
}
}
// ----
// Warning 6328: (1373-1428): CHC: Assertion violation happens here.
@@ -0,0 +1,8 @@
pragma experimental SMTChecker;
contract C {
function f() public pure {
assert(msg.sig == this.f.selector);
}
}
// ----
@@ -0,0 +1,12 @@
pragma experimental SMTChecker;
contract C {
function g() external pure {
}
function f() public pure {
assert(msg.sig == this.g.selector);
}
}
// ----
// Warning 6328: (125-159): CHC: Assertion violation happens here.
@@ -0,0 +1,14 @@
pragma experimental SMTChecker;
contract C {
int public x;
int public y;
function f() public pure {
assert(this.x.selector != this.y.selector);
assert(this.x.selector == this.y.selector);
}
}
// ----
// Warning 6328: (175-217): CHC: Assertion violation happens here.
@@ -18,6 +18,7 @@ contract Der is Base {
}
}
// ----
// Warning 4984: (der:101-109): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 6328: (der:113-126): CHC: Assertion violation happens here.
// Warning 2661: (base:100-103): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
// Warning 2661: (der:101-109): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -13,4 +13,5 @@ contract Simple {
}
}
// ----
// Warning 6328: (187-201): CHC: Assertion violation might happen here.
// Warning 4661: (187-201): BMC: Assertion violation happens here.
@@ -14,5 +14,6 @@ contract C
// ====
// SMTSolvers: z3
// ----
// Warning 4984: (176-181): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 6328: (189-203): CHC: Assertion violation happens here.
// Warning 2661: (176-181): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -14,4 +14,5 @@ contract C
}
}
// ----
// Warning 4984: (176-181): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 2661: (176-181): BMC: Overflow (resulting value larger than 2**256 - 1) happens here.
@@ -20,5 +20,6 @@ contract LoopFor2 {
// ====
// SMTSolvers: z3
// ----
// Warning 4984: (244-249): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 6328: (373-392): CHC: Assertion violation happens here.
// Warning 6328: (396-415): CHC: Assertion violation happens here.
@@ -25,3 +25,4 @@ contract LoopFor2 {
// ====
// SMTSolvers: z3
// ----
// Warning 4984: (237-242): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
@@ -20,5 +20,6 @@ contract LoopFor2 {
}
}
// ----
// Warning 4984: (229-234): CHC: Overflow (resulting value larger than 2**256 - 1) might happen here.
// Warning 6328: (290-309): CHC: Assertion violation happens here.
// Warning 6328: (313-332): CHC: Assertion violation happens here.
@@ -12,5 +12,6 @@ contract C {
}
}
// ----
// Warning 3046: (141-166): BMC: Division by zero happens here.
// Warning 3046: (263-278): BMC: Division by zero happens here.
// Warning 4281: (141-166): CHC: Division by zero happens here.
// Warning 6328: (170-184): CHC: Assertion violation happens here.
// Warning 4281: (263-278): CHC: Division by zero happens here.
@@ -22,5 +22,7 @@ contract C {
}
// ----
// Warning 6321: (253-260): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
// Warning 3046: (94-109): BMC: Division by zero happens here.
// Warning 3046: (180-195): BMC: Division by zero happens here.
// Warning 4281: (94-109): CHC: Division by zero happens here.
// Warning 6328: (113-126): CHC: Assertion violation happens here.
// Warning 4281: (180-195): CHC: Division by zero happens here.
// Warning 6328: (199-212): CHC: Assertion violation happens here.
@@ -12,5 +12,6 @@ contract C {
}
}
// ----
// Warning 3046: (141-166): BMC: Division by zero happens here.
// Warning 3046: (263-278): BMC: Division by zero happens here.
// Warning 4281: (141-166): CHC: Division by zero happens here.
// Warning 6328: (170-184): CHC: Assertion violation happens here.
// Warning 4281: (263-278): CHC: Division by zero happens here.
@@ -9,3 +9,4 @@ contract C {
}
}
// ----
// Warning 6328: (174-212): CHC: Assertion violation might happen here.
@@ -9,3 +9,4 @@ contract C {
}
}
// ----
// Warning 6328: (166-183): CHC: Assertion violation might happen here.
@@ -11,4 +11,5 @@ contract C {
}
}
// ----
// Warning 6328: (173-192): CHC: Assertion violation might happen here.
// Warning 7812: (173-192): BMC: Assertion violation might happen here.
@@ -10,4 +10,5 @@ contract C {
}
}
// ----
// Warning 6328: (157-172): CHC: Assertion violation might happen here.
// Warning 7812: (157-172): BMC: Assertion violation might happen here.
@@ -5,4 +5,4 @@ contract C {
uint x = 2 / z;
}
// ----
// Warning 6084: (69-74): BMC: Division by zero happens here.
// Warning 4281: (69-74): CHC: Division by zero happens here.
@@ -5,4 +5,4 @@ contract C {
}
}
// ----
// Warning 3046: (111-116): BMC: Division by zero happens here.
// Warning 4281: (111-116): CHC: Division by zero happens here.
@@ -10,3 +10,4 @@ contract C {
}
}
// ----
// Warning 6328: (163-180): CHC: Assertion violation might happen here.
@@ -0,0 +1,6 @@
pragma experimental SMTChecker;
contract C {
function f(bytes calldata b) external pure {
((b[:])[5]);
}
}
@@ -12,6 +12,9 @@ contract C {
}
}
// ----
// Warning 6328: (221-253): CHC: Assertion violation might happen here.
// Warning 6328: (257-289): CHC: Assertion violation might happen here.
// Warning 6328: (293-326): CHC: Assertion violation might happen here.
// Warning 4661: (221-253): BMC: Assertion violation happens here.
// Warning 4661: (257-289): BMC: Assertion violation happens here.
// Warning 4661: (293-326): BMC: Assertion violation happens here.
@@ -9,5 +9,6 @@ contract C {
}
}
// ----
// Warning 6328: (157-189): CHC: Assertion violation might happen here.
// Warning 6328: (193-225): CHC: Assertion violation happens here.
// Warning 4661: (157-189): BMC: Assertion violation happens here.
@@ -6,5 +6,5 @@ contract C {
}
}
// ----
// Warning 4281: (110-115): CHC: Division by zero happens here.
// Warning 4984: (110-115): CHC: Overflow (resulting value larger than 0x80 * 2**248 - 1) happens here.
// Warning 3046: (110-115): BMC: Division by zero happens here.
@@ -6,4 +6,4 @@ contract C {
}
}
// ----
// Warning 3046: (110-115): BMC: Division by zero happens here.
// Warning 4281: (110-115): CHC: Division by zero happens here.
@@ -6,4 +6,4 @@ contract C {
}
}
// ----
// Warning 3046: (113-118): BMC: Division by zero happens here.
// Warning 4281: (113-118): CHC: Division by zero happens here.
@@ -6,4 +6,4 @@ contract C {
}
}
// ----
// Warning 3046: (113-118): BMC: Division by zero happens here.
// Warning 4281: (113-118): CHC: Division by zero happens here.
@@ -0,0 +1,16 @@
pragma experimental SMTChecker;
contract C {
mapping (byte => uint) map;
function f() public {
map[""] = 2;
uint x = map[""];
g("");
byte b = "";
assert(x == map[b]);
assert(x == map["x"]);
}
function g(byte b) internal pure {}
}
// ----
// Warning 6328: (182-203): CHC: Assertion violation happens here.
@@ -0,0 +1,4 @@
pragma experimental SMTChecker;
contract SMT {
bytes32 constant internal NULL_BYTES32 = bytes32('');
}
@@ -6,4 +6,4 @@ contract C {
}
}
// ----
// Warning 3046: (117-120): BMC: Division by zero happens here.
// Warning 4281: (117-120): CHC: Division by zero happens here.