-
Notifications
You must be signed in to change notification settings - Fork 979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug-Candidate]: Invalid signature returned by _extract_function_relations()
#1331
Comments
_extract_function_relations()
_extract_function_relations()
This is used in the echidna printer and relies on the slither/slither/printers/guidance/echidna.py Lines 35 to 41 in db703d8
def _get_name(f: Union[Function, Variable]) -> str:
# Return the name of the function or variable
if isinstance(f, Function):
if f.is_fallback or f.is_receive:
return "()"
return f.solidity_signature
return f.function_name Can be adjusted to: def _get_name(f: Union[Function, Variable]) -> str:
# Return the name of the function or variable
if isinstance(f, Function):
if f.is_fallback:
return "fallback()"
elif f.is_receive:
return "receive()"
return f.solidity_signature Now provides output:
|
Hi @plotchy, that's a great point :) We actually already changed slither/slither/printers/guidance/echidna.py Lines 35 to 40 in 5a6b630
However I am a bit unsure about returning contract C{
function fallback() public{
}
fallback() external{
}
} So it would create collision/confusion. However maybe we could use a special placeholder for the impact/is_impacted_by list, to indicate if the destination is the receiver/fallback. |
Ah, @montyly youre totally right. I like the idea of using placeholders. I briefly tested with Assuming the list is getting deduplicated on names or something. contract Fallback {
function fallback() public payable {}
function receive() public payable {}
receive() external payable {}
fallback() external payable {}
} {
"payable": {
"Fallback": [
"*fallback()",
"*receive()" < -- "fallback()" and "receive()" Not recognized here
]
},
"functions_relations": {
"Fallback": {
"*fallback()": {
"impacts": [],
"is_impacted_by": []
},
"*receive()": {
"impacts": [],
"is_impacted_by": []
}
}
},
"constructors": {},
"have_external_calls": {},
"call_a_parameter": {},
"use_balance": {},
"solc_versions": [
"0.8.13"
],
"with_fallback": [ <-- Are recognized here
"Fallback"
],
"with_receive": [ <-- Are recognized here
"Fallback"
]
} Even if the functions impact each other and should all be in the impact_list, only the |
@0xalpharush Hmm after looking at that line it seems ambiguous how Below is a minimal way to test contract Fallback {
mapping(address => uint) public contributions;
address payable public owner;
constructor() public {
owner = payable(msg.sender);
contributions[msg.sender] = 1000 * (1 ether);
}
function fallback() public payable {
contributions[msg.sender] += msg.value;
}
function receive() public payable {
contributions[msg.sender] += msg.value;
}
receive() external payable {
contributions[msg.sender] += msg.value;
}
fallback() external payable {
contributions[msg.sender] += msg.value;
}
} |
You're right that it's not the source of the issue. At a glance, I suspect the |
Describe the issue:
Trying to get function relations on the contract of the Fallback ethernaut challenge returns a result that contains an invalid function signature:
()
I think slither returns
()
instead ofreceive()
for thereceive
function prototypeCode example to reproduce the issue:
Version:
0.8.3
Relevant log output:
No response
The text was updated successfully, but these errors were encountered: