trailofbits / manticore

Symbolic execution tool
https://blog.trailofbits.com/2017/04/27/manticore-symbolic-execution-for-humans/
GNU Affero General Public License v3.0
3.68k stars 472 forks source link

Had to downgrade protobuf (v4 -> v3) to run Manticore #2600

Open ChmielewskiKamil opened 1 year ago

ChmielewskiKamil commented 1 year ago

Summary of the problem

This is my first-ever use of Manticore so please take it with a grain of salt.

I've installed Manticore in a virtual environment with Python 3.9.13 and run Manticore on a contract with manticore token.sol. After that I get the following error: TypeError: Descriptors cannot not be created directly.. The actual log is in the any relevant logs section below.

I've managed to fix the issue by downgrading the protobuf package to version 3.20.1 (as mentioned in #2558) by running pip install protobuf==3.20.1

I've noticed that during the installation of Manticore (pip install manticore) it is using the cached version of protobuff:

Collecting protobuf
  Using cached protobuf-4.21.9-cp37-abi3-macosx_10_9_universal2.whl (483 kB)

I've deleted the virtual environment and repeated the installation process 2 times with the same result.

I am aware of the fact that the protobuf v4 package is not supported yet (as there is #2559) but for a beginner user like me, this was a little headache to fix. I was not aware of the existence of the protobuf in the first place 😅

I am not sure if this is the expected behavior or not.

Thanks!

Manticore version

Version: 0.3.7

Python version

Python 3.9.13

OS / Environment

macOS Monterey Version 12.6 Apple M1 chip

Dependencies

crytic-compile==0.2.2 cytoolz==0.12.0 eth-hash==0.5.1 eth-typing==3.2.0 eth-utils==2.1.0 future==0.18.2 intervaltree==3.1.0 manticore==0.3.7 ply==3.11 prettytable==3.5.0 protobuf==3.20.1 pyevmasm==0.2.3 pysha3==1.0.2 PyYAML==6.0 rlp==3.0.0 sortedcontainers==2.4.0 toolz==0.12.0 wasm==1.2 wcwidth==0.2.5 z3-solver==4.11.2.0

Step to reproduce the behavior

  1. Create virtual environment python3.9 -m venv manticore-env
  2. Activate the environment source manticore-env/bin/activate
  3. cd into the contracts folder
  4. Run Manticore on a target contract (in my case manticore token.sol)

Expected behavior

Start the analysis

Actual behavior

Type error

Any relevant logs


  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/bin/manticore", line 5, in <module>
    from manticore.__main__ import main
  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/lib/python3.9/site-packages/manticore/__init__.py", line 10, in <module>
    from .ethereum.manticore import ManticoreEVM
  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/lib/python3.9/site-packages/manticore/ethereum/__init__.py", line 3, in <module>
    from .manticore import ManticoreEVM, config
  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/lib/python3.9/site-packages/manticore/ethereum/manticore.py", line 15, in <module>
    from ..core.manticore import ManticoreBase, ManticoreError
  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/lib/python3.9/site-packages/manticore/core/manticore.py", line 29, in <module>
    from .worker import (
  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/lib/python3.9/site-packages/manticore/core/worker.py", line 4, in <module>
    from .state_pb2 import StateList, MessageList, State, LogMessage
  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/lib/python3.9/site-packages/manticore/core/state_pb2.py", line 32, in <module>
    _descriptor.EnumValueDescriptor(
  File "/Users/kamilchmielewski/Projects/echidna-streaming-series/manticore-env/lib/python3.9/site-packages/google/protobuf/descriptor.py", line 755, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 5. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates ```
ekilmer commented 1 year ago

Are you installing Manticore from PyPI or the latest commit on this repo? I tried to reproduce your results using the latest commit of Manticore, and it correctly removes the newer protobuf:

$ python3.9 -m venv manticore-env
$ source manticore-venv/bin/activate
$ pip install protobuf
Collecting protobuf
  Downloading protobuf-4.21.9-cp37-abi3-macosx_10_9_universal2.whl (483 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 483.8/483.8 kB 4.2 MB/s eta 0:00:00
Installing collected packages: protobuf
Successfully installed protobuf-4.21.9
$ pip install .
[...]
Collecting protobuf~=3.20
  Downloading protobuf-3.20.3-cp39-cp39-macosx_10_9_x86_64.whl (982 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 982.8/982.8 kB 4.0 MB/s eta 0:00:00
[...]
  Attempting uninstall: protobuf
    Found existing installation: protobuf 4.21.9
    Uninstalling protobuf-4.21.9:
      Successfully uninstalled protobuf-4.21.9
Successfully installed crytic-compile-0.2.4 cytoolz-0.12.0 eth-hash-0.5.1 eth-typing-3.2.0 eth-utils-2.1.0 future-0.18.2 intervaltree-3.1.0 manticore-0.3.7 ply-3.11 prettytable-3.5.0 protobuf-3.20.3 pyevmasm-0.2.3 pysha3-1.0.2 pyyaml-6.0 rlp-3.0.0 sortedcontainers-2.4.0 toolz-0.12.0 wasm-1.2 wcwidth-0.2.5 z3-solver-4.11.2.0

If you're using Manticore from PyPI, then I can reproduce your issue, and we'll need to create a new release of Manticore to fix it. Thank you for the report!

ChmielewskiKamil commented 1 year ago

I am installing the PyPi version.

ChmielewskiKamil commented 1 year ago

I am glad that I could be of some help!

0x62797465 commented 8 months ago

Now I get AttributeError: module 'collections' has no attribute 'Callable'