diff --git a/examples/basic_multicontract/.export.json.swp b/examples/basic_multicontract/.export.json.swp new file mode 100644 index 00000000..53e7f075 Binary files /dev/null and b/examples/basic_multicontract/.export.json.swp differ diff --git a/examples/basic_multicontract/LICENSE b/examples/basic_multicontract/LICENSE new file mode 100644 index 00000000..bb98c924 --- /dev/null +++ b/examples/basic_multicontract/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2018 Truffle + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/examples/basic_multicontract/build/contracts/Bar.json b/examples/basic_multicontract/build/contracts/Bar.json new file mode 100644 index 00000000..fa5c870f --- /dev/null +++ b/examples/basic_multicontract/build/contracts/Bar.json @@ -0,0 +1,1360 @@ +{ + "contractName": "Bar", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "test", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "pure", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.4.25+commit.59dbf8f1\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"test\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"pure\",\"type\":\"function\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol\":\"Bar\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol\":{\"keccak256\":\"0xeb6784b12ae56958d16880dd4d2bb70071728fdc77f4dba77278b1bbbadeec0a\",\"urls\":[\"bzzr://ae942962952eca7224884516601b96c98e37303c7ff082bba31192523c141f07\"]}},\"version\":1}", + "bytecode": "0x6080604052348015600f57600080fd5b50609d8061001e6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f8a8fd6d146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b6000905600a165627a7a72305820fc76e4cc480ddc19670a05f11d40cca4bc0d260e9defbadaca10785b81cd16b60029", + "deployedBytecode": "0x608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f8a8fd6d146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b6000905600a165627a7a72305820fc76e4cc480ddc19670a05f11d40cca4bc0d260e9defbadaca10785b81cd16b60029", + "sourceMap": "34:63:1:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;34:63:1;;;;;;;", + "deployedSourceMap": "34:63:1:-;;;;;;;;;;;;;;;;;;;;;;;;50:45;;8:9:-1;5:2;;;30:1;27;20:12;5:2;50:45:1;;;;;;;;;;;;;;;;;;;;;;;;87:4;50:45;:::o", + "source": "pragma solidity >=0.4.25 <0.6.0;\n\ncontract Bar {\n\tfunction test() public pure returns (uint) {}\n}\n\ncontract Foo {\n\tBar bar;\n\tuint isOne;\n\n\tconstructor(address _bar) public {\n\t\tbar = Bar(_bar);\n\t\t//bar = new Bar();\n\t\tisOne = 0;\n\t}\n\n\tfunction callBar() public {\n\t\tisOne = bar.test();\n\t}\n\n\tfunction echidna_test() public view returns (bool) {\n bar.test();\n\t\treturn isOne == 0;\n\t}\n}\n", + "sourcePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol", + "ast": { + "absolutePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol", + "exportedSymbols": { + "Bar": [ + 23 + ], + "Foo": [ + 69 + ] + }, + "id": 70, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 16, + "literals": [ + "solidity", + ">=", + "0.4", + ".25", + "<", + "0.6", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 23, + "linearizedBaseContracts": [ + 23 + ], + "name": "Bar", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 21, + "nodeType": "Block", + "src": "93:2:1", + "statements": [] + }, + "documentation": null, + "id": 22, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 17, + "nodeType": "ParameterList", + "parameters": [], + "src": "63:2:1" + }, + "payable": false, + "returnParameters": { + "id": 20, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 19, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 22, + "src": "87:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 18, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "87:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "86:6:1" + }, + "scope": 23, + "src": "50:45:1", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "34:63:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 69, + "linearizedBaseContracts": [ + 69 + ], + "name": "Foo", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 25, + "name": "bar", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "115:7:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + }, + "typeName": { + "contractScope": null, + "id": 24, + "name": "Bar", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 23, + "src": "115:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 27, + "name": "isOne", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "125:10:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 26, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "125:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 42, + "nodeType": "Block", + "src": "172:57:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 36, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 32, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "176:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 34, + "name": "_bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 29, + "src": "186:4:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 33, + "name": "Bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "182:3:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Bar_$23_$", + "typeString": "type(contract Bar)" + } + }, + "id": 35, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "182:9:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "src": "176:15:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 37, + "nodeType": "ExpressionStatement", + "src": "176:15:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 38, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "216:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "hexValue": "30", + "id": 39, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "224:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "216:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 41, + "nodeType": "ExpressionStatement", + "src": "216:9:1" + } + ] + }, + "documentation": null, + "id": 43, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 30, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 29, + "name": "_bar", + "nodeType": "VariableDeclaration", + "scope": 43, + "src": "151:12:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 28, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "151:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:14:1" + }, + "payable": false, + "returnParameters": { + "id": 31, + "nodeType": "ParameterList", + "parameters": [], + "src": "172:0:1" + }, + "scope": 69, + "src": "139:90:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 52, + "nodeType": "Block", + "src": "258:26:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 46, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "262:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 47, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "270:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 48, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "270:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "270:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "262:18:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 51, + "nodeType": "ExpressionStatement", + "src": "262:18:1" + } + ] + }, + "documentation": null, + "id": 53, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "callBar", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 44, + "nodeType": "ParameterList", + "parameters": [], + "src": "248:2:1" + }, + "payable": false, + "returnParameters": { + "id": 45, + "nodeType": "ParameterList", + "parameters": [], + "src": "258:0:1" + }, + "scope": 69, + "src": "232:52:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 67, + "nodeType": "Block", + "src": "338:41:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 58, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "344:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 60, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "344:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 61, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "344:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 62, + "nodeType": "ExpressionStatement", + "src": "344:10:1" + }, + { + "expression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 65, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 63, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "365:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 64, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "374:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "365:10:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "functionReturnParameters": 57, + "id": 66, + "nodeType": "Return", + "src": "358:17:1" + } + ] + }, + "documentation": null, + "id": 68, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "echidna_test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 54, + "nodeType": "ParameterList", + "parameters": [], + "src": "308:2:1" + }, + "payable": false, + "returnParameters": { + "id": 57, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 56, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 68, + "src": "332:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 55, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "332:4:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "331:6:1" + }, + "scope": 69, + "src": "287:92:1", + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "99:282:1" + } + ], + "src": "0:382:1" + }, + "legacyAST": { + "absolutePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol", + "exportedSymbols": { + "Bar": [ + 23 + ], + "Foo": [ + 69 + ] + }, + "id": 70, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 16, + "literals": [ + "solidity", + ">=", + "0.4", + ".25", + "<", + "0.6", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 23, + "linearizedBaseContracts": [ + 23 + ], + "name": "Bar", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 21, + "nodeType": "Block", + "src": "93:2:1", + "statements": [] + }, + "documentation": null, + "id": 22, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 17, + "nodeType": "ParameterList", + "parameters": [], + "src": "63:2:1" + }, + "payable": false, + "returnParameters": { + "id": 20, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 19, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 22, + "src": "87:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 18, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "87:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "86:6:1" + }, + "scope": 23, + "src": "50:45:1", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "34:63:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 69, + "linearizedBaseContracts": [ + 69 + ], + "name": "Foo", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 25, + "name": "bar", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "115:7:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + }, + "typeName": { + "contractScope": null, + "id": 24, + "name": "Bar", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 23, + "src": "115:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 27, + "name": "isOne", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "125:10:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 26, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "125:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 42, + "nodeType": "Block", + "src": "172:57:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 36, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 32, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "176:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 34, + "name": "_bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 29, + "src": "186:4:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 33, + "name": "Bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "182:3:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Bar_$23_$", + "typeString": "type(contract Bar)" + } + }, + "id": 35, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "182:9:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "src": "176:15:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 37, + "nodeType": "ExpressionStatement", + "src": "176:15:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 38, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "216:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "hexValue": "30", + "id": 39, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "224:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "216:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 41, + "nodeType": "ExpressionStatement", + "src": "216:9:1" + } + ] + }, + "documentation": null, + "id": 43, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 30, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 29, + "name": "_bar", + "nodeType": "VariableDeclaration", + "scope": 43, + "src": "151:12:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 28, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "151:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:14:1" + }, + "payable": false, + "returnParameters": { + "id": 31, + "nodeType": "ParameterList", + "parameters": [], + "src": "172:0:1" + }, + "scope": 69, + "src": "139:90:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 52, + "nodeType": "Block", + "src": "258:26:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 46, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "262:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 47, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "270:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 48, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "270:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "270:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "262:18:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 51, + "nodeType": "ExpressionStatement", + "src": "262:18:1" + } + ] + }, + "documentation": null, + "id": 53, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "callBar", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 44, + "nodeType": "ParameterList", + "parameters": [], + "src": "248:2:1" + }, + "payable": false, + "returnParameters": { + "id": 45, + "nodeType": "ParameterList", + "parameters": [], + "src": "258:0:1" + }, + "scope": 69, + "src": "232:52:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 67, + "nodeType": "Block", + "src": "338:41:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 58, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "344:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 60, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "344:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 61, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "344:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 62, + "nodeType": "ExpressionStatement", + "src": "344:10:1" + }, + { + "expression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 65, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 63, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "365:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 64, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "374:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "365:10:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "functionReturnParameters": 57, + "id": 66, + "nodeType": "Return", + "src": "358:17:1" + } + ] + }, + "documentation": null, + "id": 68, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "echidna_test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 54, + "nodeType": "ParameterList", + "parameters": [], + "src": "308:2:1" + }, + "payable": false, + "returnParameters": { + "id": 57, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 56, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 68, + "src": "332:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 55, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "332:4:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "331:6:1" + }, + "scope": 69, + "src": "287:92:1", + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "99:282:1" + } + ], + "src": "0:382:1" + }, + "compiler": { + "name": "solc", + "version": "0.4.25+commit.59dbf8f1.Emscripten.clang" + }, + "networks": { + "5777": { + "events": {}, + "links": {}, + "address": "0x2b1A87Cac755d503E968296E19cCbd21da46462F", + "transactionHash": "0x8ee7aebab9a6b4b47270727cbcc8a1733c0518afefcd572b96e920364f0fca3a" + } + }, + "schemaVersion": "3.0.11", + "updatedAt": "2019-07-02T22:09:01.452Z", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/examples/basic_multicontract/build/contracts/Foo.json b/examples/basic_multicontract/build/contracts/Foo.json new file mode 100644 index 00000000..fc2881cc --- /dev/null +++ b/examples/basic_multicontract/build/contracts/Foo.json @@ -0,0 +1,1380 @@ +{ + "contractName": "Foo", + "abi": [ + { + "inputs": [ + { + "name": "_bar", + "type": "address" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": false, + "inputs": [], + "name": "callBar", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "echidna_test", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.4.25+commit.59dbf8f1\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"echidna_test\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"callBar\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"_bar\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol\":\"Foo\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol\":{\"keccak256\":\"0xeb6784b12ae56958d16880dd4d2bb70071728fdc77f4dba77278b1bbbadeec0a\",\"urls\":[\"bzzr://ae942962952eca7224884516601b96c98e37303c7ff082bba31192523c141f07\"]}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b506040516020806102e483398101806040528101908080519060200190929190505050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600181905550506102598061008b6000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806317bf8bac14610051578063acffee6b14610080575b600080fd5b34801561005d57600080fd5b50610066610097565b604051808215151515815260200191505060405180910390f35b34801561008c57600080fd5b50610095610165565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561011e57600080fd5b505af1158015610132573d6000803e3d6000fd5b505050506040513d602081101561014857600080fd5b810190808051906020019092919050505050600060015414905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156101ea57600080fd5b505af11580156101fe573d6000803e3d6000fd5b505050506040513d602081101561021457600080fd5b81019080805190602001909291905050506001819055505600a165627a7a7230582064bd2903f96a9a349e15dd6aad759df3d037ca5f5f2eb800af9a5467a935fa090029", + "deployedBytecode": "0x60806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806317bf8bac14610051578063acffee6b14610080575b600080fd5b34801561005d57600080fd5b50610066610097565b604051808215151515815260200191505060405180910390f35b34801561008c57600080fd5b50610095610165565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561011e57600080fd5b505af1158015610132573d6000803e3d6000fd5b505050506040513d602081101561014857600080fd5b810190808051906020019092919050505050600060015414905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156101ea57600080fd5b505af11580156101fe573d6000803e3d6000fd5b505050506040513d602081101561021457600080fd5b81019080805190602001909291905050506001819055505600a165627a7a7230582064bd2903f96a9a349e15dd6aad759df3d037ca5f5f2eb800af9a5467a935fa090029", + "sourceMap": "99:282:1:-;;;139:90;8:9:-1;5:2;;;30:1;27;20:12;5:2;139:90:1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;186:4;176:3;;:15;;;;;;;;;;;;;;;;;;224:1;216:5;:9;;;;139:90;99:282;;;;;;", + "deployedSourceMap": "99:282:1:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;287:92;;8:9:-1;5:2;;;30:1;27;20:12;5:2;287:92:1;;;;;;;;;;;;;;;;;;;;;;;;;;;232:52;;8:9:-1;5:2;;;30:1;27;20:12;5:2;232:52:1;;;;;;287:92;332:4;344:3;;;;;;;;;;;:8;;;:10;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;344:10:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;344:10:1;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;344:10:1;;;;;;;;;;;;;;;;;374:1;365:5;;:10;358:17;;287:92;:::o;232:52::-;270:3;;;;;;;;;;;:8;;;:10;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;270:10:1;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;270:10:1;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;270:10:1;;;;;;;;;;;;;;;;262:5;:18;;;;232:52::o", + "source": "pragma solidity >=0.4.25 <0.6.0;\n\ncontract Bar {\n\tfunction test() public pure returns (uint) {}\n}\n\ncontract Foo {\n\tBar bar;\n\tuint isOne;\n\n\tconstructor(address _bar) public {\n\t\tbar = Bar(_bar);\n\t\t//bar = new Bar();\n\t\tisOne = 0;\n\t}\n\n\tfunction callBar() public {\n\t\tisOne = bar.test();\n\t}\n\n\tfunction echidna_test() public view returns (bool) {\n bar.test();\n\t\treturn isOne == 0;\n\t}\n}\n", + "sourcePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol", + "ast": { + "absolutePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol", + "exportedSymbols": { + "Bar": [ + 23 + ], + "Foo": [ + 69 + ] + }, + "id": 70, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 16, + "literals": [ + "solidity", + ">=", + "0.4", + ".25", + "<", + "0.6", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 23, + "linearizedBaseContracts": [ + 23 + ], + "name": "Bar", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 21, + "nodeType": "Block", + "src": "93:2:1", + "statements": [] + }, + "documentation": null, + "id": 22, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 17, + "nodeType": "ParameterList", + "parameters": [], + "src": "63:2:1" + }, + "payable": false, + "returnParameters": { + "id": 20, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 19, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 22, + "src": "87:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 18, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "87:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "86:6:1" + }, + "scope": 23, + "src": "50:45:1", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "34:63:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 69, + "linearizedBaseContracts": [ + 69 + ], + "name": "Foo", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 25, + "name": "bar", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "115:7:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + }, + "typeName": { + "contractScope": null, + "id": 24, + "name": "Bar", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 23, + "src": "115:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 27, + "name": "isOne", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "125:10:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 26, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "125:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 42, + "nodeType": "Block", + "src": "172:57:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 36, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 32, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "176:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 34, + "name": "_bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 29, + "src": "186:4:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 33, + "name": "Bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "182:3:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Bar_$23_$", + "typeString": "type(contract Bar)" + } + }, + "id": 35, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "182:9:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "src": "176:15:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 37, + "nodeType": "ExpressionStatement", + "src": "176:15:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 38, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "216:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "hexValue": "30", + "id": 39, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "224:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "216:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 41, + "nodeType": "ExpressionStatement", + "src": "216:9:1" + } + ] + }, + "documentation": null, + "id": 43, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 30, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 29, + "name": "_bar", + "nodeType": "VariableDeclaration", + "scope": 43, + "src": "151:12:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 28, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "151:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:14:1" + }, + "payable": false, + "returnParameters": { + "id": 31, + "nodeType": "ParameterList", + "parameters": [], + "src": "172:0:1" + }, + "scope": 69, + "src": "139:90:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 52, + "nodeType": "Block", + "src": "258:26:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 46, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "262:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 47, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "270:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 48, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "270:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "270:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "262:18:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 51, + "nodeType": "ExpressionStatement", + "src": "262:18:1" + } + ] + }, + "documentation": null, + "id": 53, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "callBar", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 44, + "nodeType": "ParameterList", + "parameters": [], + "src": "248:2:1" + }, + "payable": false, + "returnParameters": { + "id": 45, + "nodeType": "ParameterList", + "parameters": [], + "src": "258:0:1" + }, + "scope": 69, + "src": "232:52:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 67, + "nodeType": "Block", + "src": "338:41:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 58, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "344:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 60, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "344:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 61, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "344:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 62, + "nodeType": "ExpressionStatement", + "src": "344:10:1" + }, + { + "expression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 65, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 63, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "365:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 64, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "374:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "365:10:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "functionReturnParameters": 57, + "id": 66, + "nodeType": "Return", + "src": "358:17:1" + } + ] + }, + "documentation": null, + "id": 68, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "echidna_test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 54, + "nodeType": "ParameterList", + "parameters": [], + "src": "308:2:1" + }, + "payable": false, + "returnParameters": { + "id": 57, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 56, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 68, + "src": "332:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 55, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "332:4:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "331:6:1" + }, + "scope": 69, + "src": "287:92:1", + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "99:282:1" + } + ], + "src": "0:382:1" + }, + "legacyAST": { + "absolutePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Foo.sol", + "exportedSymbols": { + "Bar": [ + 23 + ], + "Foo": [ + 69 + ] + }, + "id": 70, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 16, + "literals": [ + "solidity", + ">=", + "0.4", + ".25", + "<", + "0.6", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 23, + "linearizedBaseContracts": [ + 23 + ], + "name": "Bar", + "nodeType": "ContractDefinition", + "nodes": [ + { + "body": { + "id": 21, + "nodeType": "Block", + "src": "93:2:1", + "statements": [] + }, + "documentation": null, + "id": 22, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 17, + "nodeType": "ParameterList", + "parameters": [], + "src": "63:2:1" + }, + "payable": false, + "returnParameters": { + "id": 20, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 19, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 22, + "src": "87:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 18, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "87:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "86:6:1" + }, + "scope": 23, + "src": "50:45:1", + "stateMutability": "pure", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "34:63:1" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 69, + "linearizedBaseContracts": [ + 69 + ], + "name": "Foo", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 25, + "name": "bar", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "115:7:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + }, + "typeName": { + "contractScope": null, + "id": 24, + "name": "Bar", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 23, + "src": "115:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "value": null, + "visibility": "internal" + }, + { + "constant": false, + "id": 27, + "name": "isOne", + "nodeType": "VariableDeclaration", + "scope": 69, + "src": "125:10:1", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 26, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "125:4:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + }, + { + "body": { + "id": 42, + "nodeType": "Block", + "src": "172:57:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 36, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 32, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "176:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 34, + "name": "_bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 29, + "src": "186:4:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 33, + "name": "Bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 23, + "src": "182:3:1", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Bar_$23_$", + "typeString": "type(contract Bar)" + } + }, + "id": 35, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "182:9:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "src": "176:15:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 37, + "nodeType": "ExpressionStatement", + "src": "176:15:1" + }, + { + "expression": { + "argumentTypes": null, + "id": 40, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 38, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "216:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "hexValue": "30", + "id": 39, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "224:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "216:9:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 41, + "nodeType": "ExpressionStatement", + "src": "216:9:1" + } + ] + }, + "documentation": null, + "id": 43, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 30, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 29, + "name": "_bar", + "nodeType": "VariableDeclaration", + "scope": 43, + "src": "151:12:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 28, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "151:7:1", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "150:14:1" + }, + "payable": false, + "returnParameters": { + "id": 31, + "nodeType": "ParameterList", + "parameters": [], + "src": "172:0:1" + }, + "scope": 69, + "src": "139:90:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 52, + "nodeType": "Block", + "src": "258:26:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 50, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 46, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "262:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 47, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "270:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 48, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "270:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 49, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "270:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "262:18:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 51, + "nodeType": "ExpressionStatement", + "src": "262:18:1" + } + ] + }, + "documentation": null, + "id": 53, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [], + "name": "callBar", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 44, + "nodeType": "ParameterList", + "parameters": [], + "src": "248:2:1" + }, + "payable": false, + "returnParameters": { + "id": 45, + "nodeType": "ParameterList", + "parameters": [], + "src": "258:0:1" + }, + "scope": 69, + "src": "232:52:1", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 67, + "nodeType": "Block", + "src": "338:41:1", + "statements": [ + { + "expression": { + "argumentTypes": null, + "arguments": [], + "expression": { + "argumentTypes": [], + "expression": { + "argumentTypes": null, + "id": 58, + "name": "bar", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 25, + "src": "344:3:1", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Bar_$23", + "typeString": "contract Bar" + } + }, + "id": 60, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "test", + "nodeType": "MemberAccess", + "referencedDeclaration": 22, + "src": "344:8:1", + "typeDescriptions": { + "typeIdentifier": "t_function_external_pure$__$returns$_t_uint256_$", + "typeString": "function () pure external returns (uint256)" + } + }, + "id": 61, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "344:10:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 62, + "nodeType": "ExpressionStatement", + "src": "344:10:1" + }, + { + "expression": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "id": 65, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "id": 63, + "name": "isOne", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 27, + "src": "365:5:1", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "hexValue": "30", + "id": 64, + "isConstant": false, + "isLValue": false, + "isPure": true, + "kind": "number", + "lValueRequested": false, + "nodeType": "Literal", + "src": "374:1:1", + "subdenomination": null, + "typeDescriptions": { + "typeIdentifier": "t_rational_0_by_1", + "typeString": "int_const 0" + }, + "value": "0" + }, + "src": "365:10:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "functionReturnParameters": 57, + "id": 66, + "nodeType": "Return", + "src": "358:17:1" + } + ] + }, + "documentation": null, + "id": 68, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": true, + "modifiers": [], + "name": "echidna_test", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 54, + "nodeType": "ParameterList", + "parameters": [], + "src": "308:2:1" + }, + "payable": false, + "returnParameters": { + "id": 57, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 56, + "name": "", + "nodeType": "VariableDeclaration", + "scope": 68, + "src": "332:4:1", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + }, + "typeName": { + "id": 55, + "name": "bool", + "nodeType": "ElementaryTypeName", + "src": "332:4:1", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "331:6:1" + }, + "scope": 69, + "src": "287:92:1", + "stateMutability": "view", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 70, + "src": "99:282:1" + } + ], + "src": "0:382:1" + }, + "compiler": { + "name": "solc", + "version": "0.4.25+commit.59dbf8f1.Emscripten.clang" + }, + "networks": { + "5777": { + "events": {}, + "links": {}, + "address": "0xC7a351e329E286f3B46Dc8aB9AD82Db6Dc27DaA1", + "transactionHash": "0x7aa76596d32d4b79ba417c71053f8653d4a7f39d4136dece6cf6e9cdbacc1249" + } + }, + "schemaVersion": "3.0.11", + "updatedAt": "2019-07-02T22:09:01.450Z", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/examples/basic_multicontract/build/contracts/Migrations.json b/examples/basic_multicontract/build/contracts/Migrations.json new file mode 100644 index 00000000..e93a9c8c --- /dev/null +++ b/examples/basic_multicontract/build/contracts/Migrations.json @@ -0,0 +1,1400 @@ +{ + "contractName": "Migrations", + "abi": [ + { + "constant": true, + "inputs": [], + "name": "last_completed_migration", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "constant": false, + "inputs": [ + { + "name": "completed", + "type": "uint256" + } + ], + "name": "setCompleted", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "new_address", + "type": "address" + } + ], + "name": "upgrade", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } + ], + "metadata": "{\"compiler\":{\"version\":\"0.4.25+commit.59dbf8f1\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"inputs\":[{\"name\":\"new_address\",\"type\":\"address\"}],\"name\":\"upgrade\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"last_completed_migration\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"completed\",\"type\":\"uint256\"}],\"name\":\"setCompleted\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Migrations.sol\":\"Migrations\"},\"evmVersion\":\"byzantium\",\"libraries\":{},\"optimizer\":{\"enabled\":false,\"runs\":200},\"remappings\":[]},\"sources\":{\"/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Migrations.sol\":{\"keccak256\":\"0xb6af40b801a24d4a45d83e10ff128d636e7d008426c8a2f473e3f0a517443439\",\"urls\":[\"bzzr://81a9ffb399fe5bd7cc3213837d9121f2cfb4942e0a3d0c6c7a80a0e1c4dcd81e\"]}},\"version\":1}", + "bytecode": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a72305820b27f3ee844fe76b108178ff61c03c5e1962752f695e0f1a3d1dc51c983c241310029", + "deployedBytecode": "0x608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a72305820b27f3ee844fe76b108178ff61c03c5e1962752f695e0f1a3d1dc51c983c241310029", + "sourceMap": "34:480:2:-;;;186:50;8:9:-1;5:2;;;30:1;27;20:12;5:2;186:50:2;221:10;213:5;;:18;;;;;;;;;;;;;;;;;;34:480;;;;;;", + "deployedSourceMap": "34:480:2:-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;;8:9:-1;5:2;;;30:1;27;20:12;5:2;347:165:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;82:36;;8:9:-1;5:2;;;30:1;27;20:12;5:2;82:36:2;;;;;;;;;;;;;;;;;;;;;;;58:20;;8:9:-1;5:2;;;30:1;27;20:12;5:2;58:20:2;;;;;;;;;;;;;;;;;;;;;;;;;;;240:103;;8:9:-1;5:2;;;30:1;27;20:12;5:2;240:103:2;;;;;;;;;;;;;;;;;;;;;;;;;;347:165;409:19;169:5;;;;;;;;;;;155:19;;:10;:19;;;151:26;;;442:11;409:45;;460:8;:21;;;482:24;;460:47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;460:47:2;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;460:47:2;;;;151:26;347:165;;:::o;82:36::-;;;;:::o;58:20::-;;;;;;;;;;;;;:::o;240:103::-;169:5;;;;;;;;;;;155:19;;:10;:19;;;151:26;;;329:9;302:24;:36;;;;151:26;240:103;:::o", + "source": "pragma solidity >=0.4.25 <0.6.0;\n\ncontract Migrations {\n address public owner;\n uint public last_completed_migration;\n\n modifier restricted() {\n if (msg.sender == owner) _;\n }\n\n constructor() public {\n owner = msg.sender;\n }\n\n function setCompleted(uint completed) public restricted {\n last_completed_migration = completed;\n }\n\n function upgrade(address new_address) public restricted {\n Migrations upgraded = Migrations(new_address);\n upgraded.setCompleted(last_completed_migration);\n }\n}\n", + "sourcePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Migrations.sol", + "ast": { + "absolutePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 126 + ] + }, + "id": 127, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 71, + "literals": [ + "solidity", + ">=", + "0.4", + ".25", + "<", + "0.6", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 126, + "linearizedBaseContracts": [ + 126 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 73, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 126, + "src": "58:20:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 72, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "58:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 75, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 126, + "src": "82:36:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 74, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "82:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 83, + "nodeType": "Block", + "src": "145:37:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 80, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 77, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 141, + "src": "155:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 78, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "155:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 79, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 73, + "src": "169:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "155:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 82, + "nodeType": "IfStatement", + "src": "151:26:2", + "trueBody": { + "id": 81, + "nodeType": "PlaceholderStatement", + "src": "176:1:2" + } + } + ] + }, + "documentation": null, + "id": 84, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 76, + "nodeType": "ParameterList", + "parameters": [], + "src": "142:2:2" + }, + "src": "123:59:2", + "visibility": "internal" + }, + { + "body": { + "id": 92, + "nodeType": "Block", + "src": "207:29:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 90, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 87, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 73, + "src": "213:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 88, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 141, + "src": "221:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 89, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "221:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "213:18:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 91, + "nodeType": "ExpressionStatement", + "src": "213:18:2" + } + ] + }, + "documentation": null, + "id": 93, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 85, + "nodeType": "ParameterList", + "parameters": [], + "src": "197:2:2" + }, + "payable": false, + "returnParameters": { + "id": 86, + "nodeType": "ParameterList", + "parameters": [], + "src": "207:0:2" + }, + "scope": 126, + "src": "186:50:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 104, + "nodeType": "Block", + "src": "296:47:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 102, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 100, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 75, + "src": "302:24:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 101, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 95, + "src": "329:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "302:36:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 103, + "nodeType": "ExpressionStatement", + "src": "302:36:2" + } + ] + }, + "documentation": null, + "id": 105, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 98, + "modifierName": { + "argumentTypes": null, + "id": 97, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 84, + "src": "285:10:2", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "285:10:2" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 96, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 95, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 105, + "src": "262:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 94, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "262:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "261:16:2" + }, + "payable": false, + "returnParameters": { + "id": 99, + "nodeType": "ParameterList", + "parameters": [], + "src": "296:0:2" + }, + "scope": 126, + "src": "240:103:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 124, + "nodeType": "Block", + "src": "403:109:2", + "statements": [ + { + "assignments": [ + 113 + ], + "declarations": [ + { + "constant": false, + "id": 113, + "name": "upgraded", + "nodeType": "VariableDeclaration", + "scope": 125, + "src": "409:19:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + }, + "typeName": { + "contractScope": null, + "id": 112, + "name": "Migrations", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 126, + "src": "409:10:2", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 117, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 115, + "name": "new_address", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 107, + "src": "442:11:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 114, + "name": "Migrations", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 126, + "src": "431:10:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Migrations_$126_$", + "typeString": "type(contract Migrations)" + } + }, + "id": 116, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "431:23:2", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "409:45:2" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 121, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 75, + "src": "482:24:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 118, + "name": "upgraded", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 113, + "src": "460:8:2", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + } + }, + "id": 120, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "setCompleted", + "nodeType": "MemberAccess", + "referencedDeclaration": 105, + "src": "460:21:2", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256) external" + } + }, + "id": 122, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "460:47:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 123, + "nodeType": "ExpressionStatement", + "src": "460:47:2" + } + ] + }, + "documentation": null, + "id": 125, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 110, + "modifierName": { + "argumentTypes": null, + "id": 109, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 84, + "src": "392:10:2", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "392:10:2" + } + ], + "name": "upgrade", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 108, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 107, + "name": "new_address", + "nodeType": "VariableDeclaration", + "scope": 125, + "src": "364:19:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 106, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "364:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "363:21:2" + }, + "payable": false, + "returnParameters": { + "id": 111, + "nodeType": "ParameterList", + "parameters": [], + "src": "403:0:2" + }, + "scope": 126, + "src": "347:165:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 127, + "src": "34:480:2" + } + ], + "src": "0:515:2" + }, + "legacyAST": { + "absolutePath": "/Users/incertia/dev/git/echidna/examples/basic_multicontract/contracts/Migrations.sol", + "exportedSymbols": { + "Migrations": [ + 126 + ] + }, + "id": 127, + "nodeType": "SourceUnit", + "nodes": [ + { + "id": 71, + "literals": [ + "solidity", + ">=", + "0.4", + ".25", + "<", + "0.6", + ".0" + ], + "nodeType": "PragmaDirective", + "src": "0:32:2" + }, + { + "baseContracts": [], + "contractDependencies": [], + "contractKind": "contract", + "documentation": null, + "fullyImplemented": true, + "id": 126, + "linearizedBaseContracts": [ + 126 + ], + "name": "Migrations", + "nodeType": "ContractDefinition", + "nodes": [ + { + "constant": false, + "id": 73, + "name": "owner", + "nodeType": "VariableDeclaration", + "scope": 126, + "src": "58:20:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 72, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "58:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "public" + }, + { + "constant": false, + "id": 75, + "name": "last_completed_migration", + "nodeType": "VariableDeclaration", + "scope": 126, + "src": "82:36:2", + "stateVariable": true, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 74, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "82:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "public" + }, + { + "body": { + "id": 83, + "nodeType": "Block", + "src": "145:37:2", + "statements": [ + { + "condition": { + "argumentTypes": null, + "commonType": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "id": 80, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftExpression": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 77, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 141, + "src": "155:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 78, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "155:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "BinaryOperation", + "operator": "==", + "rightExpression": { + "argumentTypes": null, + "id": 79, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 73, + "src": "169:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "155:19:2", + "typeDescriptions": { + "typeIdentifier": "t_bool", + "typeString": "bool" + } + }, + "falseBody": null, + "id": 82, + "nodeType": "IfStatement", + "src": "151:26:2", + "trueBody": { + "id": 81, + "nodeType": "PlaceholderStatement", + "src": "176:1:2" + } + } + ] + }, + "documentation": null, + "id": 84, + "name": "restricted", + "nodeType": "ModifierDefinition", + "parameters": { + "id": 76, + "nodeType": "ParameterList", + "parameters": [], + "src": "142:2:2" + }, + "src": "123:59:2", + "visibility": "internal" + }, + { + "body": { + "id": 92, + "nodeType": "Block", + "src": "207:29:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 90, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 87, + "name": "owner", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 73, + "src": "213:5:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "expression": { + "argumentTypes": null, + "id": 88, + "name": "msg", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 141, + "src": "221:3:2", + "typeDescriptions": { + "typeIdentifier": "t_magic_message", + "typeString": "msg" + } + }, + "id": 89, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "sender", + "nodeType": "MemberAccess", + "referencedDeclaration": null, + "src": "221:10:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "src": "213:18:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "id": 91, + "nodeType": "ExpressionStatement", + "src": "213:18:2" + } + ] + }, + "documentation": null, + "id": 93, + "implemented": true, + "isConstructor": true, + "isDeclaredConst": false, + "modifiers": [], + "name": "", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 85, + "nodeType": "ParameterList", + "parameters": [], + "src": "197:2:2" + }, + "payable": false, + "returnParameters": { + "id": 86, + "nodeType": "ParameterList", + "parameters": [], + "src": "207:0:2" + }, + "scope": 126, + "src": "186:50:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 104, + "nodeType": "Block", + "src": "296:47:2", + "statements": [ + { + "expression": { + "argumentTypes": null, + "id": 102, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "leftHandSide": { + "argumentTypes": null, + "id": 100, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 75, + "src": "302:24:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "nodeType": "Assignment", + "operator": "=", + "rightHandSide": { + "argumentTypes": null, + "id": 101, + "name": "completed", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 95, + "src": "329:9:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "src": "302:36:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "id": 103, + "nodeType": "ExpressionStatement", + "src": "302:36:2" + } + ] + }, + "documentation": null, + "id": 105, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 98, + "modifierName": { + "argumentTypes": null, + "id": 97, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 84, + "src": "285:10:2", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "285:10:2" + } + ], + "name": "setCompleted", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 96, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 95, + "name": "completed", + "nodeType": "VariableDeclaration", + "scope": 105, + "src": "262:14:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + }, + "typeName": { + "id": 94, + "name": "uint", + "nodeType": "ElementaryTypeName", + "src": "262:4:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "261:16:2" + }, + "payable": false, + "returnParameters": { + "id": 99, + "nodeType": "ParameterList", + "parameters": [], + "src": "296:0:2" + }, + "scope": 126, + "src": "240:103:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + }, + { + "body": { + "id": 124, + "nodeType": "Block", + "src": "403:109:2", + "statements": [ + { + "assignments": [ + 113 + ], + "declarations": [ + { + "constant": false, + "id": 113, + "name": "upgraded", + "nodeType": "VariableDeclaration", + "scope": 125, + "src": "409:19:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + }, + "typeName": { + "contractScope": null, + "id": 112, + "name": "Migrations", + "nodeType": "UserDefinedTypeName", + "referencedDeclaration": 126, + "src": "409:10:2", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + } + }, + "value": null, + "visibility": "internal" + } + ], + "id": 117, + "initialValue": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 115, + "name": "new_address", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 107, + "src": "442:11:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_address", + "typeString": "address" + } + ], + "id": 114, + "name": "Migrations", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 126, + "src": "431:10:2", + "typeDescriptions": { + "typeIdentifier": "t_type$_t_contract$_Migrations_$126_$", + "typeString": "type(contract Migrations)" + } + }, + "id": 116, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "typeConversion", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "431:23:2", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + } + }, + "nodeType": "VariableDeclarationStatement", + "src": "409:45:2" + }, + { + "expression": { + "argumentTypes": null, + "arguments": [ + { + "argumentTypes": null, + "id": 121, + "name": "last_completed_migration", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 75, + "src": "482:24:2", + "typeDescriptions": { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + } + ], + "expression": { + "argumentTypes": [ + { + "typeIdentifier": "t_uint256", + "typeString": "uint256" + } + ], + "expression": { + "argumentTypes": null, + "id": 118, + "name": "upgraded", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 113, + "src": "460:8:2", + "typeDescriptions": { + "typeIdentifier": "t_contract$_Migrations_$126", + "typeString": "contract Migrations" + } + }, + "id": 120, + "isConstant": false, + "isLValue": false, + "isPure": false, + "lValueRequested": false, + "memberName": "setCompleted", + "nodeType": "MemberAccess", + "referencedDeclaration": 105, + "src": "460:21:2", + "typeDescriptions": { + "typeIdentifier": "t_function_external_nonpayable$_t_uint256_$returns$__$", + "typeString": "function (uint256) external" + } + }, + "id": 122, + "isConstant": false, + "isLValue": false, + "isPure": false, + "kind": "functionCall", + "lValueRequested": false, + "names": [], + "nodeType": "FunctionCall", + "src": "460:47:2", + "typeDescriptions": { + "typeIdentifier": "t_tuple$__$", + "typeString": "tuple()" + } + }, + "id": 123, + "nodeType": "ExpressionStatement", + "src": "460:47:2" + } + ] + }, + "documentation": null, + "id": 125, + "implemented": true, + "isConstructor": false, + "isDeclaredConst": false, + "modifiers": [ + { + "arguments": null, + "id": 110, + "modifierName": { + "argumentTypes": null, + "id": 109, + "name": "restricted", + "nodeType": "Identifier", + "overloadedDeclarations": [], + "referencedDeclaration": 84, + "src": "392:10:2", + "typeDescriptions": { + "typeIdentifier": "t_modifier$__$", + "typeString": "modifier ()" + } + }, + "nodeType": "ModifierInvocation", + "src": "392:10:2" + } + ], + "name": "upgrade", + "nodeType": "FunctionDefinition", + "parameters": { + "id": 108, + "nodeType": "ParameterList", + "parameters": [ + { + "constant": false, + "id": 107, + "name": "new_address", + "nodeType": "VariableDeclaration", + "scope": 125, + "src": "364:19:2", + "stateVariable": false, + "storageLocation": "default", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + }, + "typeName": { + "id": 106, + "name": "address", + "nodeType": "ElementaryTypeName", + "src": "364:7:2", + "typeDescriptions": { + "typeIdentifier": "t_address", + "typeString": "address" + } + }, + "value": null, + "visibility": "internal" + } + ], + "src": "363:21:2" + }, + "payable": false, + "returnParameters": { + "id": 111, + "nodeType": "ParameterList", + "parameters": [], + "src": "403:0:2" + }, + "scope": 126, + "src": "347:165:2", + "stateMutability": "nonpayable", + "superFunction": null, + "visibility": "public" + } + ], + "scope": 127, + "src": "34:480:2" + } + ], + "src": "0:515:2" + }, + "compiler": { + "name": "solc", + "version": "0.4.25+commit.59dbf8f1.Emscripten.clang" + }, + "networks": { + "5777": { + "events": {}, + "links": {}, + "address": "0xf02e7BC30FdcC89826547B09303A253C85A68784", + "transactionHash": "0xc5ae5c5cfba800941c1eb5064ba64c9eea7d0db436bc0561a2ec3c2de7ccccfb" + } + }, + "schemaVersion": "3.0.11", + "updatedAt": "2019-07-02T22:09:01.453Z", + "devdoc": { + "methods": {} + }, + "userdoc": { + "methods": {} + } +} \ No newline at end of file diff --git a/examples/basic_multicontract/contracts/.placeholder b/examples/basic_multicontract/contracts/.placeholder new file mode 100644 index 00000000..3ed31e18 --- /dev/null +++ b/examples/basic_multicontract/contracts/.placeholder @@ -0,0 +1 @@ +This is a placeholder file to ensure the parent directory in the git repository. Feel free to remove. diff --git a/examples/basic_multicontract/contracts/Bar.sol b/examples/basic_multicontract/contracts/Bar.sol new file mode 100644 index 00000000..679331bd --- /dev/null +++ b/examples/basic_multicontract/contracts/Bar.sol @@ -0,0 +1,10 @@ +pragma solidity >=0.4.25 <0.6.0; + +contract Bar { + + constructor() public {} + + function test() public pure returns (uint) { + return 1; + } +} \ No newline at end of file diff --git a/examples/basic_multicontract/contracts/Foo.sol b/examples/basic_multicontract/contracts/Foo.sol new file mode 100644 index 00000000..d1be5639 --- /dev/null +++ b/examples/basic_multicontract/contracts/Foo.sol @@ -0,0 +1,25 @@ +pragma solidity >=0.4.25 <0.6.0; + +contract Bar { + function test() public pure returns (uint) {} +} + +contract Foo { + Bar bar; + uint isOne; + + constructor(address _bar) public { + bar = Bar(_bar); + //bar = new Bar(); + isOne = 0; + } + + function callBar() public { + isOne = bar.test(); + } + + function echidna_test() public view returns (bool) { + bar.test(); + return isOne == 0; + } +} diff --git a/examples/basic_multicontract/contracts/Migrations.sol b/examples/basic_multicontract/contracts/Migrations.sol new file mode 100644 index 00000000..7d659145 --- /dev/null +++ b/examples/basic_multicontract/contracts/Migrations.sol @@ -0,0 +1,23 @@ +pragma solidity >=0.4.25 <0.6.0; + +contract Migrations { + address public owner; + uint public last_completed_migration; + + modifier restricted() { + if (msg.sender == owner) _; + } + + constructor() public { + owner = msg.sender; + } + + function setCompleted(uint completed) public restricted { + last_completed_migration = completed; + } + + function upgrade(address new_address) public restricted { + Migrations upgraded = Migrations(new_address); + upgraded.setCompleted(last_completed_migration); + } +} diff --git a/examples/basic_multicontract/echidna_config.yaml b/examples/basic_multicontract/echidna_config.yaml new file mode 100644 index 00000000..030192c6 --- /dev/null +++ b/examples/basic_multicontract/echidna_config.yaml @@ -0,0 +1,2 @@ +contractAddr: "0x12342" +initialize: "./examples/basic_multicontract/export.json" diff --git a/examples/basic_multicontract/export.json b/examples/basic_multicontract/export.json new file mode 100644 index 00000000..5f34634c --- /dev/null +++ b/examples/basic_multicontract/export.json @@ -0,0 +1,17 @@ +[ +{"event": "AccountCreated", "address": "9bc0895dc163e5dc83f9654186c9ee60b7736f1a"}, +{"event": "AccountCreated", "address": "b4a07ad03011e7afa37e80890cfbab65960988b6"}, +{"event": "AccountCreated", "address": "b0d71bcbcca8d1c4c2cb0ab4bae6d951f035e577"}, +{"event": "AccountCreated", "address": "e498baf98383a8c0cb2a3ff8002cf4ca6c5295b8"}, +{"event": "AccountCreated", "address": "907128412912321ea7a01ef1d1196588b01cb98b"}, +{"event": "AccountCreated", "address": "93a3cda86dbb1b5dccd6f6719e5030dd65b267b4"}, +{"event": "AccountCreated", "address": "7a3a17fbebbaa1a9576845f31a07ef5be353f71d"}, +{"event": "AccountCreated", "address": "7fae60090e87dd649074938432e1d0af3f8fbcf9"}, +{"event": "AccountCreated", "address": "45d33bed8871017e7b1fbd22a1dd47faeb1d914a"}, +{"event": "AccountCreated", "address": "57da5aaf5de3ff574ffbd8cb3a4885238a926616"}, +{"event": "ContractCreated", "from": "0x9bc0895dc163e5dc83f9654186c9ee60b7736f1a", "contract_address": "0xf02e7bc30fdcc89826547b09303a253c85a68784", "gas_used": "0x43bd6", "gas_price": "0x4a817c800", "data": "0x608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102f8806100606000396000f300608060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100aa5780638da5cb5b146100d5578063fdacd5761461012c575b600080fd5b34801561007357600080fd5b506100a8600480360381019080803573ffffffffffffffffffffffffffffffffffffffff169060200190929190505050610159565b005b3480156100b657600080fd5b506100bf610241565b6040518082815260200191505060405180910390f35b3480156100e157600080fd5b506100ea610247565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b34801561013857600080fd5b506101576004803603810190808035906020019092919050505061026c565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16141561023d578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b15801561022457600080fd5b505af1158015610238573d6000803e3d6000fd5b505050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102c957806001819055505b505600a165627a7a72305820b27f3ee844fe76b108178ff61c03c5e1962752f695e0f1a3d1dc51c983c241310029", "value": "0x0"}, +{"event": "FunctionCall", "from": "0x9bc0895dc163e5dc83f9654186c9ee60b7736f1a", "to": "0xf02e7bc30fdcc89826547b09303a253c85a68784", "gas_used": "0xa418", "gas_price": "0x4a817c800", "data": "0xfdacd5760000000000000000000000000000000000000000000000000000000000000001", "value": "0x0"}, +{"event": "ContractCreated", "from": "0x9bc0895dc163e5dc83f9654186c9ee60b7736f1a", "contract_address": "0x2b1a87cac755d503e968296e19ccbd21da46462f", "gas_used": "0x171ed", "gas_price": "0x4a817c800", "data": "0x6080604052348015600f57600080fd5b50609d8061001e6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f8a8fd6d146044575b600080fd5b348015604f57600080fd5b506056606c565b6040518082815260200191505060405180910390f35b6000905600a165627a7a72305820fc76e4cc480ddc19670a05f11d40cca4bc0d260e9defbadaca10785b81cd16b60029", "value": "0x0"}, +{"event": "ContractCreated", "from": "0x9bc0895dc163e5dc83f9654186c9ee60b7736f1a", "contract_address": "0xc7a351e329e286f3b46dc8ab9ad82db6dc27daa1", "gas_used": "0x3b31c", "gas_price": "0x4a817c800", "data": "0x608060405234801561001057600080fd5b506040516020806102e483398101806040528101908080519060200190929190505050806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506000600181905550506102598061008b6000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806317bf8bac14610051578063acffee6b14610080575b600080fd5b34801561005d57600080fd5b50610066610097565b604051808215151515815260200191505060405180910390f35b34801561008c57600080fd5b50610095610165565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b15801561011e57600080fd5b505af1158015610132573d6000803e3d6000fd5b505050506040513d602081101561014857600080fd5b810190808051906020019092919050505050600060015414905090565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663f8a8fd6d6040518163ffffffff167c0100000000000000000000000000000000000000000000000000000000028152600401602060405180830381600087803b1580156101ea57600080fd5b505af11580156101fe573d6000803e3d6000fd5b505050506040513d602081101561021457600080fd5b81019080805190602001909291905050506001819055505600a165627a7a7230582064bd2903f96a9a349e15dd6aad759df3d037ca5f5f2eb800af9a5467a935fa0900290000000000000000000000002b1a87cac755d503e968296e19ccbd21da46462f", "value": "0x0"}, +{"event": "FunctionCall", "from": "0x9bc0895dc163e5dc83f9654186c9ee60b7736f1a", "to": "0xf02e7bc30fdcc89826547b09303a253c85a68784", "gas_used": "0x6980", "gas_price": "0x4a817c800", "data": "0xfdacd5760000000000000000000000000000000000000000000000000000000000000002", "value": "0x0"} +] diff --git a/examples/basic_multicontract/migrations/1_initial_migration.js b/examples/basic_multicontract/migrations/1_initial_migration.js new file mode 100644 index 00000000..ee2135d2 --- /dev/null +++ b/examples/basic_multicontract/migrations/1_initial_migration.js @@ -0,0 +1,5 @@ +const Migrations = artifacts.require("Migrations"); + +module.exports = function(deployer) { + deployer.deploy(Migrations); +}; diff --git a/examples/basic_multicontract/migrations/2_deploy_contracts.js b/examples/basic_multicontract/migrations/2_deploy_contracts.js new file mode 100644 index 00000000..3a7b3417 --- /dev/null +++ b/examples/basic_multicontract/migrations/2_deploy_contracts.js @@ -0,0 +1,8 @@ +const Foo = artifacts.require("Foo"); +const Bar = artifacts.require("Bar"); + +module.exports = function(deployer) { + deployer.deploy(Bar).then(function() { + return deployer.deploy(Foo, Bar.address); + }); +}; diff --git a/examples/basic_multicontract/test/.placeholder b/examples/basic_multicontract/test/.placeholder new file mode 100644 index 00000000..3ed31e18 --- /dev/null +++ b/examples/basic_multicontract/test/.placeholder @@ -0,0 +1 @@ +This is a placeholder file to ensure the parent directory in the git repository. Feel free to remove. diff --git a/examples/basic_multicontract/truffle-config.js b/examples/basic_multicontract/truffle-config.js new file mode 100644 index 00000000..00b8e33a --- /dev/null +++ b/examples/basic_multicontract/truffle-config.js @@ -0,0 +1,26 @@ +module.exports = { + // Uncommenting the defaults below + // provides for an easier quick-start with Ganache. + // You can also follow this format for other networks; + // see + // for more details on how to specify configuration options! + /* + networks: { + development: { + host: "127.0.0.1", + port: 7545, + network_id: "*" + }, + test: { + host: "127.0.0.1", + port: 7545, + network_id: "*" + } + } + */ + compilers: { + solc: { + version: "0.4.25" + }, + }, +}; diff --git a/lib/Echidna/RPC.hs b/lib/Echidna/RPC.hs index 5be75b7e..4c09e2b5 100644 --- a/lib/Echidna/RPC.hs +++ b/lib/Echidna/RPC.hs @@ -1,117 +1,181 @@ {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE LambdaCase #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} module Echidna.RPC where - import Prelude hiding (Word) - - import Control.Exception (Exception) - import Control.Lens - import Control.Monad (foldM) - import Control.Monad.Catch (MonadThrow, throwM) - import Control.Monad.IO.Class (MonadIO(..)) - import Control.Monad.State.Strict (MonadState, execState, execStateT, get, put, runState) - import Data.Aeson (FromJSON(..), defaultOptions, eitherDecodeFileStrict, genericParseJSON, omitNothingFields) - import Data.ByteString (ByteString, empty) - import Data.Has (Has(..)) - import Data.List (partition) - import Data.Text.Encoding (encodeUtf8) - import EVM - import EVM.Concrete (w256) - import EVM.Exec (exec, vmForEthrunCreation) - import EVM.Types (Addr, W256) - import GHC.Generics - - import qualified Control.Monad.State.Strict as S (state) - import qualified Data.Text as T - - import Echidna.Exec - import Echidna.Transaction - - - -- | During initialization we can either call a function or create an account or contract - data EthenoEvent = AccountCreated | ContractCreated | FunctionCall deriving(Eq, Show, Generic) - - instance FromJSON EthenoEvent - - -- | A single initialization event - data Etheno = Etheno { _event :: !EthenoEvent - , _address :: !Addr - , _from :: !Addr - , _to :: !Addr - , _contractAddr :: !Addr - , _gasUsed :: !Integer - , _gasPrice :: !Integer - , _initCode :: !T.Text - , _value :: !W256 - } deriving (Eq, Show, Generic) - - makeLenses ''Etheno - - instance FromJSON Etheno where - parseJSON = genericParseJSON $ defaultOptions{omitNothingFields = True} - - - -- | Handler for parsing errors - data EthenoException = EthenoException String - - instance Show EthenoException where - show (EthenoException e) = "Error parsing Etheno initialization file: " ++ e - - instance Exception EthenoException - - - -- | Main function: takes a filepath where the initialization sequence lives and returns - -- | the initialized VM along with a list of Addr's to put in GenConf - loadEthenoBatch :: (MonadThrow m, MonadIO m) => ByteString -> FilePath -> m (VM, [Addr]) - loadEthenoBatch echidnaInit fp = do - bs <- liftIO $ eitherDecodeFileStrict fp - - case bs of - (Left e) -> throwM $ EthenoException e - (Right ethenoInit) -> do - -- | Separate out account creation txns to use later for config - let (accounts, txs) = partition (\t -> t ^. event == AccountCreated) ethenoInit - knownAddrs = map (\e -> e ^. address) accounts - - -- | Execute contract creations and initial transactions, - let blank = vmForEthrunCreation empty - initVM = foldM (execEthenoTxs echidnaInit) 0x0 txs >>= liftSH . loadContract - - vm <- execStateT initVM blank - +import Prelude hiding (Word) + +import Debug.Trace (traceShow, trace) + +import Control.Exception (Exception) +import Control.Lens +import Control.Monad (foldM) +import Control.Monad.Catch (MonadThrow, throwM) +import Control.Monad.IO.Class (MonadIO(..)) +import Control.Monad.State.Strict (MonadState, execState, execStateT, runStateT, get, put, runState) +import Data.Aeson (FromJSON(..), (.:), withObject, eitherDecodeFileStrict) +import Data.ByteString.Char8 (ByteString, empty, unpack) +import Data.Has (Has(..)) +import Data.List (partition) +import Data.Map (fromList) +import Data.Text.Encoding (encodeUtf8) +import EVM +import EVM.Concrete (w256) +import EVM.Exec (exec, vmForEthrunCreation) +import EVM.Types (Addr, W256) + +import qualified Control.Monad.Fail as M (MonadFail(..)) +import qualified Control.Monad.State.Strict as S (state) +import qualified Data.ByteString.Base16 as BS16 (decode, encode) +import qualified Data.Text as T (Text, drop) + +import Echidna.Exec +import Echidna.Transaction + +-- | During initialization we can either call a function or create an account or contract +--data EthenoEvent = AccountCreated | ContractCreated | FunctionCall deriving(Eq, Show, Generic) + +--instance FromJSON EthenoEvent + +-- | A single initialization event +--data Etheno = Etheno { _event :: !EthenoEvent +-- , _address :: Maybe Addr +-- , _from :: Maybe Addr +-- , _to :: Maybe Addr +-- , _contractAddr :: Maybe Addr +-- , _gasUsed :: Maybe Integer +-- , _gasPrice :: Maybe Integer +-- , _initCode :: Maybe T.Text +-- , _value :: Maybe W256 +-- } deriving (Eq, Show, Generic) + +data Etheno = AccountCreated Addr + | ContractCreated Addr Addr Integer Integer ByteString W256 + | FunctionCall Addr Addr Integer Integer ByteString W256 + deriving (Eq, Show) + +--makeLenses ''Etheno + +instance FromJSON Etheno where + -- parseJSON = genericParseJSON $ defaultOptions {fieldLabelModifier = tail, omitNothingFields = True} + parseJSON = withObject "Etheno" $ \v -> do + (ev :: String) <- v .: "event" + case ev of + "AccountCreated" -> AccountCreated <$> v .: "address" + "ContractCreated" -> ContractCreated <$> v .: "from" + <*> v .: "contract_address" + <*> (read <$> (v .: "gas_used")) + <*> (read <$> (v .: "gas_price")) + <*> (decode <$> (v .: "data")) + <*> v .: "value" + "FunctionCall" -> FunctionCall <$> v .: "from" + <*> v .: "to" + <*> (read <$> (v .: "gas_used")) + <*> (read <$> (v .: "gas_price")) + <*> (decode <$> (v .: "data")) + <*> v .: "value" + _ -> M.fail "event should be one of \"AccountCreated\", \"ContractCreated\", or \"FunctionCall\"" + where decode :: T.Text -> ByteString + decode = decodeHex . encodeUtf8 . T.drop 2 + decodeHex = fst . BS16.decode + + +-- | Handler for parsing errors +data EthenoException = EthenoException String + +instance Show EthenoException where + show (EthenoException e) = "Error parsing Etheno initialization file: " ++ e + +instance Exception EthenoException + + +-- | Main function: takes a filepath where the initialization sequence lives and returns +-- | the initialized VM along with a list of Addr's to put in GenConf +loadEthenoBatch :: (MonadThrow m, MonadIO m) => [T.Text] -> FilePath -> m (VM, [Addr]) +loadEthenoBatch ts fp = do + bs <- liftIO $ eitherDecodeFileStrict fp + + case bs of + (Left e) -> throwM $ EthenoException e + (Right ethenoInit) -> do + -- | Separate out account creation txns to use later for config + let (accounts, txs) = partition (\case { AccountCreated{} -> True; _ -> False; }) ethenoInit + knownAddrs = map (\(AccountCreated a) -> a) accounts + + -- | Execute contract creations and initial transactions, + let blank = vmForEthrunCreation empty & env . contracts .~ fromList [] + cs = blank ^. env . contracts + initVM = foldM (execEthenoTxs ts) Nothing txs + + liftIO $ print (length cs) + -- liftIO $ print $ view contractcode <$> cs + liftIO $ putStrLn "---" + (addr, vm') <- runStateT initVM blank + let cs' = vm' ^. env . contracts + liftIO $ print (length cs') + -- liftIO $ print $ view contractcode <$> cs' + liftIO $ putStrLn "done loading" + liftIO $ print ts + case addr of + Nothing -> throwM $ EthenoException "Could not find contract with echidna tests" + Just a -> do + liftIO $ putStrLn $ "found echidna at " ++ show addr + vm <- execStateT (liftSH . loadContract $ a) vm' return (vm, knownAddrs) - - -- | Takes a list of Etheno transactions and loads them into the VM, returning the - -- | address containing echidna tests - execEthenoTxs :: (MonadState x m, Has VM x, MonadThrow m) => ByteString -> Addr -> Etheno -> m Addr - execEthenoTxs bs addr t = do - og <- get - setupEthenoTx t - res <- liftSH exec - case (res, t ^. event == ContractCreated) of - (Reversion, _) -> put og - (VMFailure x, _) -> vmExcept x - (VMSuccess bc, True) -> hasLens %= execState ( replaceCodeOfSelf (RuntimeCode bc) - >> loadContract (t ^. contractAddr)) - _ -> pure () - - -- See if current contract is the same as echidna test - if t ^. event == ContractCreated && encodeUtf8 (t ^. initCode) == bs - then return (t ^. contractAddr) - else return addr - - - -- | For an etheno txn, set up VM to execute txn - setupEthenoTx :: (MonadState x m, Has VM x) => Etheno -> m () - setupEthenoTx (Etheno e _ f t c _ _ d v) = S.state . runState . zoom hasLens . sequence_ $ - [ result .= Nothing, state . pc .= 0, state . stack .= mempty, state . gas .= 0xffffffff - , tx . origin .= f, state . caller .= f, state . callvalue .= w256 v, setup] where - bc = encodeUtf8 d - setup = case e of - AccountCreated -> pure () - ContractCreated -> assign (env . contracts . at c) (Just . initialContract . RuntimeCode $ bc) >> loadContract c - FunctionCall -> loadContract t >> state . calldata .= bc +-- | Takes a list of Etheno transactions and loads them into the VM, returning the +-- | address containing echidna tests +execEthenoTxs :: (MonadState x m, Has VM x, MonadThrow m) => [T.Text] -> Maybe Addr -> Etheno -> m (Maybe Addr) +execEthenoTxs ts addr t = do + og <- get + setupEthenoTx t + res <- liftSH exec + case (res, t) of + (Reversion, _) -> throwM $ EthenoException "Encountered reversion while setting up Etheno transactions" + (VMFailure x, _) -> vmExcept x >> return addr + (VMSuccess bc, + ContractCreated _ ca _ _ _ _) -> + -- See if current contract is the same as echidna test + case addr of + Just m -> return $ Just m + Nothing -> let txs = ts <&> \t -> Tx (Left (t, [])) ca ca 0 + go [] = return $ Just ca + go (x:xs) = execTx x >>= \case + Reversion -> return Nothing + _ -> go xs in + go txs + -- hasLens %= execState (replaceCodeOfSelf (RuntimeCode bc) >> loadContract ca) + _ -> return addr + --if t ^. event == ContractCreated && encodeUtf8 (fromJustt (t ^. initCode)) == bs + -- then return (fromJust (t ^. contractAddr)) + -- else return addr + + +-- | For an etheno txn, set up VM to execute txn +setupEthenoTx :: (MonadState x m, Has VM x) => Etheno -> m () +setupEthenoTx (AccountCreated _) = pure () +setupEthenoTx (ContractCreated f c _ _ d v) = S.state . runState . zoom hasLens . sequence_ $ + [ result .= Nothing, state . pc .= 0, state . stack .= mempty, state . gas .= 0xffffffff + , tx . origin .= f, state . caller .= f, state . callvalue .= w256 v, setup] + where setup = assign (env . contracts . at (traceShow c c)) (Just . initialContract . RuntimeCode $ trace ("bc: " ++ (unpack $ BS16.encode d)) d) + --setup = do + -- env . contracts . at c .= Just . initialContract . RuntimeCode . encodeUtf8 $ d + -- loadContract c + +setupEthenoTx (FunctionCall f t _ _ d v) = S.state . runState . zoom hasLens . sequence_ $ + [ result .= Nothing, state . pc .= 0, state . stack .= mempty, state . gas .= 0xffffffff + , tx . origin .= f, state . caller .= f, state . callvalue .= w256 v, setup] + where setup = loadContract (traceShow t t) >> state . calldata .= d +--setupEthenoTx FunctionCall{} = pure () +--setupEthenoTx (Etheno e _ f t c _ _ d v) = S.state . runState . zoom hasLens . sequence_ $ +-- [ result .= Nothing, state . pc .= 0, state . stack .= mempty, state . gas .= 0xffffffff +-- , tx . origin .= fromJust f, state . caller .= fromJust f, state . callvalue .= w256 v, setup] where +-- bc = encodeUtf8 (fromJust d) +-- setup = case e of +-- AccountCreated -> pure () +-- ContractCreated -> assign (env . contracts . at c) (Just . initialContract . RuntimeCode $ bc) >> loadContract (fromJust c) +-- FunctionCall -> loadContract (fromJust t) >> state . calldata .= bc diff --git a/lib/Echidna/Solidity.hs b/lib/Echidna/Solidity.hs index d5a1690d..37773f9a 100644 --- a/lib/Echidna/Solidity.hs +++ b/lib/Echidna/Solidity.hs @@ -45,6 +45,7 @@ import EVM.Concrete (w256) import qualified Data.ByteString as BS import qualified Data.HashMap.Strict as M import qualified Data.Text as T +import qualified EVM as E (contracts) -- | Things that can go wrong trying to load a Solidity file for Echidna testing. Read the 'Show' -- instance for more detailed explanations. @@ -142,12 +143,13 @@ loadSpecified name cs = let ensure l e = if l == mempty then throwM e else pure -- Local variables (SolConf ca d ads bala balc pref _ libs _ fp) <- view hasLens let bc = c ^. creationCode + abi = liftM2 (,) (view methodName) (fmap snd . view methodInputs) <$> toList (c ^. abiMap) + (tests, funs) = partition (isPrefixOf pref . fst) abi -- Set up initial VM, either with chosen contract or Etheno initialization file -- need to use snd to add to ABI dict - (blank', _) <- maybe (pure (vmForEthrunCreation bc, [])) (loadEthenoBatch bc) fp + (blank', _) <- maybe (pure (vmForEthrunCreation bc, [])) (loadEthenoBatch (fst <$> tests)) fp + liftIO . print $ blank' ^. env . E.contracts . to length let blank = populateAddresses (ads |> d) bala blank' - abi = liftM2 (,) (view methodName) (fmap snd . view methodInputs) <$> toList (c ^. abiMap) - (tests, funs) = partition (isPrefixOf pref . fst) abi -- Select libraries ls <- mapM (choose cs . Just . pack) libs diff --git a/package.yaml b/package.yaml index b13dfc7b..27d57e30 100644 --- a/package.yaml +++ b/package.yaml @@ -11,6 +11,7 @@ dependencies: - base - ansi-terminal - brick + - base16-bytestring - bytestring >= 0.10.8 && < 0.11 - containers >= 0.5.7 && < 0.6 - data-dword >= 0.3.1 && < 0.4 @@ -26,6 +27,7 @@ dependencies: - mtl >= 2.2.1 && < 2.3 - optparse-applicative >= 0.13.0 && < 0.15 - process >= 1.4.3 && < 1.7 + - split - stm - temporary >= 1.2.1 && < 1.4 - text >= 1.2.2 && < 1.3