Skip to content
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

Catch AssertionError and log context and raise again while parsing #1873

Merged

Conversation

duelinggalois
Copy link
Contributor

partial fix of #1853
Opened PR per request in #1854

AssertionError with stack trace can occur while parsing contracts that provides no context to what was parsed that threw the error as described in #1853. This change catches this error, logs additional context, and then throws the error again.

An example of the logging from code I am working on:

$ slither .
...
Compiler run successful

ERROR:SlitherSolcParsing:
Failed to parse MyERC20Controller.constructor (contracts/MyERC20Controller.sol#19-25):
 	(tokenX,tokenY) = IMyFactoryCallback(msg.sender).tokens()
	(success,data) = msg.sender.delegatecall(abi.encodeWithSelector(IMyFactoryCallback.newTokens.selector,tokenX,tokenY))
	require(bool,string)(success,Factory new tokens failed)
	_tokens = abi.decode(data,(IMyERC20[6]))
Traceback (most recent call last):
  File "~/slither/slither/__main__.py", line 810, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "~/slither/slither/__main__.py", line 101, in process_all
...

Logging should make it easier for further issues from users to be easily understood and if necessary included in a bug report.

partial fix of crytic#1853
Opened PR per request in crytic#1854

AssertionError with stack trace can occur while parsing contracts that
provides no context to what was parsed that threw the error as described
in crytic#1853. This change catches this error, logs additional context, and
then throws the error again.

An example of the logging from code I am working on:

```
$ slither .
...
Compiler run successful

ERROR:SlitherSolcParsing:
Failed to parse MyERC20Controller.constructor (contracts/MyERC20Controller.sol#19-25):
 	(tokenX,tokenY) = IMyFactoryCallback(msg.sender).tokens()
	(success,data) = msg.sender.delegatecall(abi.encodeWithSelector(IMyFactoryCallback.newTokens.selector,tokenX,tokenY))
	require(bool,string)(success,Factory new tokens failed)
	_tokens = abi.decode(data,(IMyERC20[6]))
Traceback (most recent call last):
  File "~/slither/slither/__main__.py", line 810, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "~/slither/slither/__main__.py", line 101, in process_all
...
```
Logging should make it easier for further issues from users to be easily
understood and if necessary included in a bug report.
@duelinggalois
Copy link
Contributor Author

@montyly, @0xalpharush, @smonicas Anything needed from me to merge, rebase or fix-up?

@montyly
Copy link
Member

montyly commented May 22, 2023

This is great, thanks @duelinggalois and @smonicas

@montyly montyly merged commit 9896771 into crytic:dev May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants