crytic / solc-select

Manage and switch between Solidity compiler versions
GNU Affero General Public License v3.0
758 stars 103 forks source link

Creating Local Contexts With Solc-select #171

Closed Akshat-Mishra101 closed 1 year ago

Akshat-Mishra101 commented 1 year ago

solc-select and slither multithreaded parallel execution

Is there a way to create a local solc version context for slither?

I've made a small tool which takes a smart contract, and passes it through slither to execute a few tests. Now i want to scale this app, and want it to be able to handle multiple requests per second. For this, I've been using threads but the solc-select changes the globl context, which is now shared across all threads.

is there any workaround?

elopez commented 1 year ago

Hi! An option would be to set the SOLC_VERSION environment variable. This variable takes precedence over the global solc-select context. This way you can avoid calling solc-select use ...

% solc --version
solc, the solidity compiler commandline interface
Version: 0.8.19+commit.7dd6d404.Darwin.appleclang
% export SOLC_VERSION=0.8.0
% solc --version           
solc, the solidity compiler commandline interface
Version: 0.8.0+commit.c7dfd78e.Darwin.appleclang
Akshat-Mishra101 commented 1 year ago

Hey @elopez, thanks for the swift reply :). I'm wondering if it would work with a command like "export SOLC_VERSION=0.8.0; slither ."

elopez commented 1 year ago

on most shells you can do SOLC_VERSION=0.8.0 slither foo.sol and it should work 👍 If you are doing it programmaticaly, most languages also offer a way to add or update an environment variable for a command execution, like on Go or Python

Akshat-Mishra101 commented 1 year ago

Thank you so much for the help @elopez, I'm using nodejs with child processes to achieve this.

elopez commented 1 year ago

Something like this should work for node, see how FOO is added.

Akshat-Mishra101 commented 1 year ago

amazing, this works. Thanks for the help man, Ill close this thread.