Closed PaulRBerg closed 3 years ago
Your contract is compiled inside Docker so solc is installed inside it.
Thanks for the quick reply! So is there no way to override that? Am I bound to solc@0.5.17 with this Docker package?
Update: I know that I can switch the compiler version with the eth-security-box image, but I was looking to use the bespoke Echidna package.
Yes, you can go inside the docker container (running bash
for instance), install anything you need (or use solc-select
as I think it is already installed) and then run your fuzzing campaign from the shell.
Oh, makes sense! Sorry, I am not a Docker expert.
That's fine. Please feel free to comment on this closed issue what worked better for you so we can update the README and clarify this.
I figured it out eventually, but it was quite a detour. I tried to run the commands listed under the Linux packages section in the Solidity docs, but I got this error:
Error sudo: add-apt-repository: command not found
I then found this thread on StackExchange, and realised I have to install software-properties-common
:
$ apt install software-properties-common
Only then I was able to run the commands from the Solidity documentation (without sudo):
$ add-apt-repository ppa:ethereum/ethereum
$ apt-get update
$ apt-get install solc
I then tried to compile my contract, but unfortunately that didn't work. From within the Docker container, I ran this:
$ echidna-test /src/contracts/invariants/MulDivInvariant.sol
But I got this error back:
echidna-test: Couldn't compile given file
stdout:
stderr:
Traceback (most recent call last):
File "/root/.local/bin/crytic-compile", line 11, in <module>
sys.exit(main())
File "/root/.local/lib/python3.6/site-packages/crytic_compile/__main__.py", line 157, in main
compilations = compile_all(**vars(args))
File "/root/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 1076, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/root/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 137, in __init__
self._compile(**kwargs)
File "/root/.local/lib/python3.6/site-packages/crytic_compile/crytic_compile.py", line 987, in _compile
self._platform.compile(self, **kwargs)
File "/root/.local/lib/python3.6/site-packages/crytic_compile/platform/solc.py", line 180, in compile
crytic_compile.abis[contract_name] = json.loads(info["abi"])
File "/usr/lib/python3.6/json/__init__.py", line 348, in loads
'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'list'
Not sure how to fix this. For the record, I am using Hardhat. In the meantime, I will switch back to the eth-security-toolbox.
Update: After providing the path to the Echidna config (via the --config
argument) and the name of the contract (via the --contract
argument), running echidna-test
worked, but the compilation didn't succeed. It seems like Solidity v0.8 is not supported by crytic-compile?
Also solc-select
is not installed, by default.
You can just install the solc version you need as it does inside the Dockerfile
docker run -it -v `pwd`:/src trailofbits/echidna bash
Inside the bash run the following command, but replacing v0.X.X
for the version you want.
wget https://github.com/ethereum/solidity/releases/download/v0.X.X/solc-static-linux && chmod +x solc-static-linux && mv solc-static-linux /usr/bin/solc
I followed the instructions in the README listed under Docker container and executed the following comand:
But I encountered this error:
Now, I am not quite sure whence this v0.5.7 of Solidity is picked up from. Is it the default used by Echidna (which I can override)? Is it the one I have locally installed on my Mac? If yes, which installation option takes priority: node.js, docker, homebrew, etc.?
It would be helpful if there was an explanation in the README about how to set the compiler version when running Echidna via the Docker package.