smartbugs / smartbugs-wild

This repository contains 47,398 smart contracts extracted from the Ethereum network.
Apache License 2.0
147 stars 38 forks source link

Encountered `no pragma` errors #7

Open Stamp9 opened 1 year ago

Stamp9 commented 1 year ago

Hey,

I was trying to run smartbug with smartbugs-wild dataset but encountered many no pragma errors. Given that the paper utilized SmartBugs to analyze the same dataset, I'm wondering why it's not functioning as expected now and how this issue can be resolved. Any information would be appreciated, thanks in advance!

cat /Users/rr/my-repo/cloned/smartbugs-wild/sb_wild.txt | xargs -n 200 ./smartbugs -t smartcheck -f

Welcome to SmartBugs 2.0.7!
Collecting files ...
200 files to analyse
Assembling tasks ...
Error(s) while collecting tasks:
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x0710714a1e30c70aea2dc1254e24292bea7943f4.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x0b8d56c26d8cf16fe1bddf4967753503d974de06.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x41f2d5040726c5328f8366f17041ec012ac8f338.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x44afd8995b70f37c90c2c6a484218f79df86d74a.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x77562e7c5cedf35d3264fd13469b9e9d9fee90cc.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x7fd022cc8b6e019260627fafa1d9c3afece18cef.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xc0c2809aa2a6c38ff1eeac13cff6c0e5cf637e27.sol: no pragma, cannot determine solc version
Welcome to SmartBugs 2.0.7!
Collecting files ...
200 files to analyse
Assembling tasks ...
Error(s) while collecting tasks:
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x9497043f4cd9450867479f3fd873d80d9321094c.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xbc053e4bc868f40beea7d571c808f01ade8dae12.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xe2ff99d71555b62271f74b062d1e2928c4d27b1e.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xe7e01babb53c98f8d84d05dfff64ebb63ed37bf5.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xf01b26626550448606de2b6e7eeda1216d9cd239.sol: no pragma, cannot determine solc version
Welcome to SmartBugs 2.0.7!
Collecting files ...
200 files to analyse
Assembling tasks ...
Error(s) while collecting tasks:
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x073e957bc883693f15ecb14bfced3e8ffc8654c5.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x43bbc7fafb860d974037b8f7dd06b6f6fe799b3e.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xb1d58bad78f33892719cdeba218f8641a71a3f05.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xd5a3a5f35e8db7740ff644752bce389fc958d5c1.sol: no pragma, cannot determine solc version
Welcome to SmartBugs 2.0.7!
Collecting files ...
200 files to analyse
Assembling tasks ...
Error(s) while collecting tasks:
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x0948cc023fa99f12f93dc6dd88d958faac3e07d2.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x11d02e7119cdf769bf887b7c35548ab7f67b3fe0.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x2b84b61394511aba931500e974cb243a852f134b.sol: no compiler found that matches pragma solidity ;
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0x954de93d9f1cd1e2e3ae5964f614cdcc821fac64.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xbacd554538c8037545098a36361f54c4e1d0f94e.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xcf377dfd654676940e2b5a87cf2673def25aeaed.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xd0f51907e541e63ec338e0e210dc33a6c7871096.sol: no pragma, cannot determine solc version
/Users/rr/my-repo/cloned/smartbugs-wild/contracts/0xd494938d0524edadfc239adc2c233e50550fa152.sol: no pragma, cannot determine solc version
tdurieux commented 1 year ago

You executed a different version of SmartBugs that we initially used for that study. SmartBugs v2 tries to determine the version of the required compiler automatically by identifying the pragma in the solidity file.

In those cases, no pragma is present in the file, and therefore no compiler could be identified.

Stamp9 commented 1 year ago

Hi, @tdurieux

Thanks for your quick reply. So, if we intend to analyze the dataset using SmartBugs v2 with some tools, is manually adding the compiler version and pragma the sole approach available? Is there any alternative or more efficient method in your opinion?

tdurieux commented 1 year ago

You could modify smartbugs to use a default pragma, I expect that the contracts are really old when no pragma is provided.

@gsalzer WDYT?

Stamp9 commented 1 year ago

You could modify smartbugs to use a default pragma, I expect that the contracts are really old when no pragma is provided.

Yes, they are old. According to the source code, Is it correct that that the minimal version supported by SmartBugs v2 is 0.4.11? If so, does it mean that utilizing a default pragma specifying a Solidity version earlier than 0.4.11 would not align with the compatibility requirements v2? There are also s
ome contract files have earlier version(e.g. pragma solidity 0.4.4), do you have any suggestions for these situations?

gsalzer commented 1 year ago

@Stamp9 I will look at it in a few days. It should be possible to support solc >= 0.4.0. One might also add a command line switch to supply a default solc version.

MartinY9 commented 11 months ago

I have also encountered the same problem when running smartbug with smartbugs-wild dataset, may I ask how to solve this?

MartinY9 commented 11 months ago

I have also encountered the same problem when running smartbug with smartbugs-wild dataset, may I ask how to solve this?

This is a version formatting issue in the dataset, which has been resolved by automatically formatting it through a script.

gsalzer commented 11 months ago

@MartinY9 Thanks for clarification. Can you elaborate the issue a bit? What exactly did you reformat, to which format? Maybe we should apply the reformatting to the original dataset.

MartinY9 commented 11 months ago

@MartinY9 Thanks for clarification. Can you elaborate the issue a bit? What exactly did you reformat, to which format? Maybe we should apply the reformatting to the original dataset.

There are several incorrect formats for writing contract definition versions, such as: "pragma solidity ^ 0.4.18;","pragma solidity 0.4.18;", and "pragma solidity 0.4. 18" and so on. These wrong formats make the program unable to run normally. I wrote a script to address this issue, which was manually checked and proved to be effective.

gsalzer commented 11 months ago

Thanks for the analysis. We will fix it for future users.