Skip to content

Added support for solidity 0.5.x #1219

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

Merged
merged 10 commits into from
Sep 27, 2019
Merged

Added support for solidity 0.5.x #1219

merged 10 commits into from
Sep 27, 2019

Conversation

mderka
Copy link
Contributor

@mderka mderka commented Sep 26, 2019

Mythril relies on py-solc to install versions specified by the --solv parameter. Unfortunately, py-solc does not seem maintained and cannot install solc with versions 0.5.x. Thus, Mythril currently supports only the system solc installation for 0.5.x.

This PR adds py-solc-x dependency which is used for versions other than 0.4.x. For 0.4.x, handling by py-solc is preserved, because py-solc-x declares incompatibility of 0.4.x installations with OSX.

This should solve Mythril's dynamic support for 0.5.x that is reference e.g. in ethereum/py-solc#63, andindirectly also in #1217.

Tested with Docker as follows:

docker build .
docker run -v /tmp:/tmp 3ff13f1e1c8b analyze /tmp/contract.sol --solv 0.5.10 -o jsonv2
docker run -v /tmp:/tmp 3ff13f1e1c8b analyze /tmp/contract.sol --solv 0.4.24 -o jsonv2

@@ -1,4 +1,4 @@
pragma solidity 0.5.0;
pragma solidity 0.5.3;
Copy link
Collaborator

@norhh norhh Sep 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pragma solidity 0.5.3;
pragma solidity ^0.5.0;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@norhh
Copy link
Collaborator

norhh commented Sep 27, 2019

Hi @mderka thanks for the PR. Just a small change is required for the native_tests.sol, as using a ^ would be simpler there at the moment.

Copy link

@banescusebi banescusebi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Collaborator

@norhh norhh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 👍

@norhh norhh merged commit 75838e3 into ConsenSysDiligence:develop Sep 27, 2019
norhh added a commit that referenced this pull request Oct 19, 2019
* Refactor cli

* enhance cli

* Re-Refactor the cli structure for more flexibility

* Add cli tests for error

* Move the cmd_line_test to the previous directory

* Add documentation

* Add more tests and change docs

* Add more tests for storage slots and execution

* support a for analyze and add more tests

* Improve cli interface

* Fix previous errors

* Refactor with black

* Add help command

* Add new tests, fix an edge case and improve code and help messages

* Turn mythril into a MythX client

* Fix merge mistake

* Convert --solc-args parameter to --solc-json

* Set solver timeout and loop bound for analysis modules

* Set only for non None values

* Load contracts from the blockchain by default.

Renames --no-on-chain-storage-access to --no-onchain-access. This
control both storage and contract code loading.

* Remove solc version check in tests

* Change defaults

* Change loopbound default in symbolic.py

*  Fix bug #1168 by checking eth is not None in the loader. Refactor the loader. (#1169)

* Fix bug #1168 by checking eth is not None in the loader.

Also refactor the loader quite a bit:
 - remove the cache dictionary, and use functools.lru_cache instead
 - also use lru_cache for caching contract code
 - add type annotations, now mypy would be complaining if we didn't
   "self.eth" for None.
 - use log.debug() with %s, it's good pratice and allow advanced logging
   to group by log messages / parameters if needed.

* Fix type annotation.

* Exception -> ValueError in loader.py

* Remove unused import.

* Nested bitvec func  (#1163)

* add test to reproduce nested function bug

* add test for other level of bitvecfunc

* add appropriate handling for nested bitvecfuncs

* add return character

* ignore hybrid functions for condition permeation

* add tests to check if correct inputs are found

* copy bitvecfunc logic to generic handlers

* clean up & move logic to separate module

Removes cyclic dependency and redundant code

* style

* fix imports

* do uniq & iff application

* implement initial If for bvf

* style

* add return

* only deal with eq comparison

* fix type issues

* Fix a crash

* Fix the issue in statechange module

* Fix for mypy

* Use correct operator

* Update README.md

* Update README.md

* Update README.md

* WIP uselsess commit

* Enable coverage based search strategy through CLI (#1171)

* Enable coverage based search strategy through CLI

* Ran black on files changed

* Refactored code

* Removed redundant code

* First draft of ether balance modeling

* Clean up leftover code

* Fix missing argument to function

* Updated jinja templates to report initial state of the transaction sequences. (#1173)

* Inject missing env variables (#1174)

* Only add constraint to symbolic Ether balances

* Refactored interfaces to run custom modules

* Various small fixes.

* Fix incorrect values in some suicide evm tests

* Reformat with black.

* Add a logger in account.py

* Fix #1176: retrieve map items.

* Fix #1176: load map items

* Remove logging messages, and a "pass"

* Revert commit that should not have been here (other PR)

* Refactored code

* Fixed some logic

* Fix wrongly named constructor arg

* Update old_cli.py

* Revert "Fixed some logic"

This reverts commit 80c21a3.

* Revert "Refactored code"

This reverts commit a8dc3aa.

* Removed unnecessary comments and cleaned up code

* Added ProgramCounterException to display a clearer message when pc is out of bounds. (#1180)

* Fix dependency conflict for issue (#1181)

* Fix dependency conflict for issue

* Fix dependency conflict for issue

* Minor grammar improvements

* Bump version number

* Fix error preventing contract name from being set

* Fix compilation error handling

* Document MythX analysis

* Update wiki links to Read the Docs links

* Fix bug compiling contracts without solc warnings

* Constrain all transaction callers to have <= 1000 ETH

* Remove unneeded import

* Implemented extcodehash

* Refactored instructions for extcodehash and its test

* Ran black

* Fixed linting errors

* Ran black

* Fixed errors in asserts in extcodehash tests

* Ran black...

* "true" to True (#1188)

* Version update

* Fix a bug: correctly copy printable storage over (#1191)

* Fix a bug: the key for the accounts is an integer.

* Fix a bug: correctly copy printable storage.

Also fix another serialization bug that appears now that the printable
storage is not empty.

* Revert "Fix a bug: the key for the accounts is an integer."

Should not have been included in that PR.

* Fix a bug: the key for the accounts is an integer. (#1190)

* Track what storage has been initialized, and load non-initialized storage.

* Check if item is symbolic first.

* Check that key is not symbolic in __setitem__

* Add type annotation.

* Fix pruning of calls

* Fix invalid function names

* Add logic for CREATE opcode, still need to add unit test for CREATE. Refactored extcodehash unit tests into separate test units.

* Small cleanups (no semantic changes) (#1196)

* Small cleanups.

* Run black.

* Fix onsite storage by using proper variables (#1194)

* Fix some ether problems and fix minimise (#1198)

* Version update

* Update the execution timeout for calls.sol test

* Refactored create_ opcode

* Fix support for calls forwarding the entire calldata. (#1195)

* Fix support for calls forwarding the entire calldata.

* Reformat with black.

* uses_entire_calldata is always a Bool

* Revert "uses_entire_calldata is always a Bool"

This reverts commit 629cb53.

* Revert "Revert "uses_entire_calldata is always a Bool""

Didn't help, it passed before. Strange. Will need to find a way to
investigate locally.

* Change actor addresses in line with MythX test case conventions

* Reduce number of actors

* Fix standard actors list

* Added new calculation to codesize.

* Starting implementation of creationdata.

* Add the rest of the precompiles (#990)

* Support modular exponentiation for concrete data

* Add elliptic curve operations

* Fix type hints and refactor code

* Support usage of the rest of the native contracts

* Remove unused imports

* Add tests for elliptic curve functions

* Use a constant for native functions count

* Update py_ecc version

* Use PRECOMPILE_COUNT over hardcoded value

* Use shortened list comprehensives

* Clean up imports

* Use precompile count in checking precompile calls

* Refactor code

* Add checks for creation transaction in codesize/codecopy/calldatasize/calldatacopy

* Removed creationdata as is unnecessary for now.

* Remove confusing comment

* Added CREATE

* Updated create implementation. TODO: finish log, create2, and staticcall

* Fix bug and comment code. Adding tests.

* Add create_post logic

* Add logic for create and create2.

* Refactor the cli and add help for the contract selection (#1203)

* Add a descriptive comment to codecopy_

* Fix typo

* Test issue constraints at the end of each transaction

* Update external calls to report issues at the end of a transaction

* Refactored delegatecall to ignore post conditions.

* Fix mypy

* Removed DelegateCallAnnotation

* Concretize and display calldata transaction data

* Fixes for latest pythx version

* Fix up some missed bugs

* Implement static call (#991)

* Implement static call

* Refactor static call tests

* Reuse call's post for staticcall

* Change variable names and add docstring comments

* Rename variable name

* change the comment

* Fix the tests based on the merge

* Fix the tests

* Remove extra declaration of WriteProtection

* Fix static call test

* Add the missing condition in callcode

* Propagate annotations to the parent call, when a call succeeds. (#1197)

* Propagate annotations to the parent call, when a call succeeds.

This makes the MutationPruner behave correctly.

* Add a copy_annotations_from method.

* Run black.

* WIP

* Use persist_to_world_state and the world state instead.

* Fix issue reporting for trial analysis

* Cleaned up stupid logic. Add gas calculation to create2.

* Syntax errors

* Mythril version 0.21.16 release

* Refactored code.

* Add trial mode messaging

* Add variables for trial credentials

* Make _cache and _issues public

* Fix missed _cache and _issue names

* Fixing CCT logic. Fixes CREATE with symbolic constructor arguments, but not Concrete.

* Modified codecopy. Debugging issue with contract function calls.

* Cleaned up code. Add create test.

* Only propagate code based call annotations (#1211)

* Only propagate code based call annotations

* Move the if condition to a better place

* Implement user supplied assertion module

* Add user supplied assertions module to documentation

* Cleaned up some logic. Fixed issue with VMException and freezing on staticcall.

* Ran black. TODO: Fix issue with storage.

* Fixed issue with staticcall.

* Refactor code

* Fixed mypy.

* Minor improvements to user_assertions.py

* Remove unused variables

* Remove unused import

* Remove unused variables

* Check delegatecall after execution finishes (#1215)

* Minor improvements to user_assertions.py

* Add the return condition (#1216)

* Mythril v0.21.17

* Fix typehints for latest mypy release (#1221)

* Added support for solidity 0.5.x (#1219)

* Added support for solidity 0.5.x

* Formatting using black

* Added missing requirement for tests to pass

* Fixed py-solc-x version

* Added packages to setup

* Removed py35 from tox

* Synced the solc version for the test

* Updated the test smart contract to floating pragma

* Changed instructions out-of-bounds behavior to return halt instruction. (#1223)

* Inject env variable into Edelweiss

* immediately return value

* Enable optimizer when compiling Soldity files (#1226)

* Added returning global state to SIGNEXTEND opcode. (#1227)

* Added returning global state to SIGNEXTEND opcode.

* Add TODO statement.

* added new symbol instead

* hash s0

* Added 'context' to loop annotations.

* Fixed mypy

* Use padded operation over operation (#1229)

* Use padded operation over operation

* Add missing operation

* Make keys unique

* Display instruction profiler results on ctrl+c or error

* Improve function signatures

* Fix propagation of JumpdestCountAnnotation (#1237)

* Fix propagation of JumpdestCountAnnotation

* Update mythril/laser/ethereum/strategy/extensions/bounded_loops.py

Co-Authored-By: Nikhil Parasaram <[email protected]>

* Remove truffle support (#1218)

* Remove truffle

* Fix black

* Remove truffle.py

* Py35 support (#1233)

* Add py35 into tox

* Use solcx for python3.6+

* Fix tests

* Add tests for extcodecopy (#1240)

* Add tests for extcodecopy

* Don't use mock

* Catch stackunderflow exception before hitting analysis modules (#1234)

* Add a instruction stack usage table

* catch stackunderflow exception before the pre analysis

* Fix type hints

* Fix black

* fix tests

* Fix mypy issues (#1246)

* Do not display creation input in markdown or text reports (#1242)

* Fix symbolic calldata size when create (#1244)

* Fix symbolic calldata size when create

* Consider the integer case

* Refactor code by removing usused and repeated code (#1249)

* Mythril v0.21.18
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