Closed thanhtoantnt closed 1 year ago
SolcAST depends on solcx
package, which supports solidity>=0.4.11.
In our SolcAST, if version is not specified, given this line, we will treat pragma solidity ^0.4.2;
as 0.4.2, thus causing the failure.
@YoungHS-NUS Do you have any suggestions for dealing with solidity < 0.4.11? We may get these contracts in some old benchmarks.
For the moment, I don't have any good suggestions. Maybe Chan Li has some insight on this issue.
Arguments passed to the lib print(" SolidityAst: Received args ", contract_source_path, version, retry_num, solc_options)
pragma solidity ^0.4.2;
contract SimpleDAO {
....
}
0.4.11 None {}
Traceback (most recent call last):
ast = SolidityAst(flatten_source, solc_version, solc_options=solc_options)
File "/home/minh/Documents/github/solc-json-parser/solc_json_parser/parser.py", line 260, in __init__
self.contracts_dict: Dict = self._parse()
File "/home/minh/Documents/github/solc-json-parser/solc_json_parser/parser.py", line 502, in _parse
self.exported_symbols = symbols_to_ids_from_ast_v7(self.solc_json_ast)
File "/home/minh/Documents/github/solc-json-parser/solc_json_parser/parser.py", line 157, in symbols_to_ids_from_ast_v7
syms = [c['ast']['attributes']['exportedSymbols'] for c in ast.values()]
File "/home/minh/Documents/github/solc-json-parser/solc_json_parser/parser.py", line 157, in <listcomp>
syms = [c['ast']['attributes']['exportedSymbols'] for c in ast.values()]
KeyError: 'attributes'
The bugs is in other parts of solc_json_parser
not the unsupported version . The correct solc version is already passed to this library. @thanhtoantnt When you post an issue, it's better to post the call stacks and error message so people know what is wrong, you post it's too general Fail to parse the program
nobody can guess what is the exact problem .
@YoungHS-NUS can you test with SolidityAst version=0.4.11
to see if the bug can be reproduced ?
No problem, will test it later in afternoon
I have reproduced the error. On the first look, it might come from the compatibility problem from different versions. This part of the code is not written by me, but I will see what I can do to fix it.
For this issue, compiler 0.4.11 output can't support our functionality, 0.4.12 will work in this case. In my experience, I suggest using 0.4.23 to avoid some problems.
We can force the compiling function from our side to start from 0.4.12 @cl2089
to be handled by updating the compiler version selection strategy in smart-fuzz (https://github.com/sbip-sg/smart-fuzz/issues/182), closing this here.
Program
pragma solidity ^0.4.2;
contract SimpleDAO { mapping (address => uint) public credit;
function donate(address to) payable { credit[to] += msg.value; }
function withdraw(uint amount) { if (credit[msg.sender]>= amount) { // REENTRANCY
bool res = msg.sender.call.value(amount)();
credit[msg.sender]-=amount;
}
}
function queryCredit(address to) returns (uint){ return credit[to]; } }