Skip to content

Commit aa627f6

Browse files
Merge pull request #23 from lisa-analyzer/truth-ground
Ground Truth and Dockerfile
2 parents 32ffc94 + 2d0ce5c commit aa627f6

File tree

302 files changed

+171525
-1865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+171525
-1865
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
# Ignore output directories that contain generated results
1111
evm-outputs/
12+
test-ground-truth-stats/
13+
evm-testcases/ground-truth/test/logs.txt
14+
evm-testcases/ground-truth/test/statistics.csv
1215

1316
# Ignore downloaded bytecode
1417
evm-testcases/benchmark/

Dockerfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Use a base image with JDK 11
2+
FROM openjdk:11-jdk-slim
3+
4+
# Specify the version of Gradle to install
5+
ARG GRADLE_VERSION=6.6
6+
7+
# Install Gradle
8+
RUN apt-get update && apt-get install -y wget unzip git && \
9+
wget https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip && \
10+
mkdir /opt/gradle && \
11+
unzip -d /opt/gradle gradle-${GRADLE_VERSION}-bin.zip && \
12+
rm gradle-${GRADLE_VERSION}-bin.zip && \
13+
ln -s /opt/gradle/gradle-${GRADLE_VERSION}/bin/gradle /usr/bin/gradle && \
14+
apt-get clean && rm -rf /var/lib/apt/lists/*
15+
16+
# Set working directory
17+
WORKDIR /app
18+
19+
# Clone the EVMLiSA repository (latest stable version)
20+
# RUN git clone https://github.com/lisa-analyzer/evm-lisa.git .
21+
22+
# Copy the entire EVMLiSA project into the container (latest version)
23+
COPY . .
24+
25+
# Build the project with Gradle
26+
RUN gradle build
27+
28+
# Extract the project ZIP file for distribution
29+
RUN gradle distZip && \
30+
unzip -o build/distributions/evm-lisa.zip -d /app/execution
31+
32+
# Create results directory
33+
RUN mkdir -p /app/execution/results
34+
35+
# Set the entry point of the container
36+
ENTRYPOINT ["/app/execution/evm-lisa/bin/evm-lisa"]

README.md

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,22 @@
99

1010
EVMLiSA is a static analyzer based on abstract interpretation for [EVM bytecode](https://www.ethervm.io/) of smart contracts deployed on Ethereum blockchain and built upon [LiSA](https://unive-ssv.github.io/lisa/). Given a EVM bytecode smart contract, EVMLiSA builds a sound and precise control-flow graph of the smart contract.
1111

12-
1312
EVMLiSA is based on the peer-reviewed publication
1413
> Vincenzo Arceri, Saverio Mattia Merenda, Greta Dolcetti, Luca Negrini, Luca Olivieri, Enea Zaffanella. _**"Towards a Sound Construction of EVM Bytecode Control-Flow Graphs"**_. In Proceedings of the 26th ACM International Workshop on Formal Techniques for Java-like Programs (FTfJP 2024), co-located with ECOOP 2024.
1514
16-
1715
# 🛠 Building EVMLiSA
1816
Compiling EVMLiSA requires:
1917
- JDK >= 11
2018
- [Gradle](https://gradle.org/releases/) >= 6.6
2119
- [Etherscan API key](https://etherscan.io/myapikey)
2220

23-
Development is done in [Eclipse](https://www.eclipse.org/downloads/).
2421
You need to:
2522
- Clone the repository:
2623
```bash
2724
git clone https://github.com/lisa-analyzer/evm-lisa.git
2825
cd evm-lisa
2926
```
30-
- Install the Gradle IDE Pack plugin through the Eclipse Marketplace; from the eclipse menu bar:
31-
- *Help*
32-
- *Eclipse Marketplace...*
33-
- *Search* for *Gradle IDE Pack 3.8*
34-
- *Install Gradle IDE Pack 3.8*
35-
- Import the project into the eclipse workspace as a Gradle project.
27+
- Import the project into the Eclipse/IntelliJ workspace as a Gradle project (optional).
3628

3729
# ⚙️ Running EVMLiSA
3830
Before running EVMLiSA, ensure you have set up an Environment Variable with your Etherscan API Key. Follow the steps below to set up the environment variable:
@@ -46,8 +38,30 @@ ETHERSCAN_API_KEY=<your_etherscan_api_key>
4638

4739
> Here you can find how to generate an [Etherscan API key](https://etherscan.io/myapikey).
4840
49-
Once you have set up the environment variable, follow these steps to run EVMLiSA:
41+
Once you have set up the environment variable, you can run EVMLiSA via Docker or via Bash.
42+
43+
## Via Docker
44+
Build the container:
45+
```
46+
mkdir -p execution/docker &&
47+
docker build -t evm-lisa:latest .
48+
```
49+
50+
Then you can run EVMLiSA with:
51+
```
52+
docker run --rm -it \
53+
-v $(pwd)/.env:/app/.env \
54+
-v $(pwd)/execution/docker:/app/execution/results \
55+
evm-lisa:latest \
56+
-a <smart_contract_address> [options]
57+
```
58+
59+
- `-v $(pwd)/.env:/app/.env`: mount the `.env` file.
60+
- `-v $(pwd)/execution/docker:/app/execution/results`: share the results' folder.
5061

62+
> Replace `<smart_contract_address>` with the address of the Ethereum smart contract you want to analyze.
63+
64+
## Via Bash
5165
Build the Project:
5266
```bash
5367
./gradlew build
@@ -63,11 +77,12 @@ Unzip the Distribution:
6377
unzip build/distributions/evm-lisa.zip -d execution
6478
```
6579

66-
Run EVMLiSA:
80+
Then you can run EVMLiSA with:
6781
```bash
68-
./execution/evm-lisa/bin/evm-lisa -a <smart_contract_address> [options]
82+
./execution/evm-lisa/bin/evm-lisa \
83+
-a <smart_contract_address> [options]
6984
```
70-
Replace `<smart_contract_address>` with the address of the Ethereum smart contract you want to analyze.
85+
> Replace `<smart_contract_address>` with the address of the Ethereum smart contract you want to analyze.
7186
7287
This command will initiate the analysis process for the specified smart contract, providing insights and results based on the EVM bytecode of the contract.
7388

@@ -94,15 +109,32 @@ EVMLiSA introduces the abstract stack powerset domain $\texttt{SetSt}_{k,h,l}$ w
94109

95110
# 📋 Running example
96111
Here is an example of how to run EVMLiSA. In this example, we will analyze a smart contract at the address `0x7c21C4Bbd63D05Fa9F788e38d14e18FC52E9557B` with specific options for stack size, stack-set size, live storage usage and the dump of the CFG:
112+
113+
- Bash:
114+
```bash
115+
./execution/evm-lisa/bin/evm-lisa \
116+
-a 0x7c21C4Bbd63D05Fa9F788e38d14e18FC52E9557B \
117+
--stack-size 64 \
118+
--stack-set-size 10 \
119+
--dump-stats \
120+
--use-live-storage
97121
```
98-
./execution/evm-lisa/bin/evm-lisa
99-
-a 0x7c21C4Bbd63D05Fa9F788e38d14e18FC52E9557B
100-
--stack-size 64
101-
--stack-set-size 10
122+
123+
- Docker:
124+
```bash
125+
docker run --rm -it \
126+
-v $(pwd)/.env:/app/.env \
127+
-v $(pwd)/execution/docker:/app/execution/results \
128+
evm-lisa:latest \
129+
-a 0x7c21C4Bbd63D05Fa9F788e38d14e18FC52E9557B \
130+
--stack-size 64 \
131+
--stack-set-size 10 \
132+
--dump-stats \
102133
--use-live-storage
103-
--dump-analysis dot
104134
```
105135

136+
> Use `docker run -a stderr` to dump only the json report as standard output.
137+
106138
The expected output is as follows:
107139
```yaml
108140
##############
@@ -123,3 +155,10 @@ Maybe unsound jumps: 0
123155
- _Unsound_: the jump node is reached at least with a stack with an unknown numerical value that may correspond to a
124156
valid jump destination as the top element;
125157
- _Maybe unsound_: the stack set exceeded the maximal stack size.
158+
159+
---
160+
161+
## Contributors
162+
<a href="https://github.com/lisa-analyzer/evm-lisa/graphs/contributors">
163+
<img src="https://contrib.rocks/image?repo=lisa-analyzer/evm-lisa" />
164+
</a>

benchmark/50-ground-truth.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
0xDcfCcaf54CB8c7c30bb7959929AbA24bF136FF57
2+
0x5b348ec54c290683697f6a812ca1bfbb0e74c70d
3+
0x9a1ba1687c2759fe96bfacbfb5300458b7d726f0
4+
0x4582b79844e753ed53928d8b8761e9f27eb22735
5+
0x60f19fd1f15fc08a1ea27d407dae25c4e7937547
6+
0x1370e65e0228b27566a5cb7328160794001f8651
7+
0x0dcd1b77ef4459c37551b3a3fa4a8e1f2485ad08
8+
0x16eA5Db6A7C2A72749a7f7600CAA64c97468D50E
9+
0x5a67e970cc210d6b5fb6512d8142e3eb648c1d32
10+
0xb04862d030a38c351e8ecae09508cd30f80d88e3
11+
0x6ea4f5bcd17185c5958677569340e39ac6364e9f
12+
0xced519a9e7555dee0399f8da3019d8d557a88f81
13+
0x2fa57c80249b0683c443043aB01b894125876AfC
14+
0x0c6b8078d27c9729fad5db98c331291bf57ec879
15+
0x2cfC31b4e1E838453c22675F46bB248AC9DDD439
16+
0x33f9704b980a21b776eac1d9d4111db33ab6dfda
17+
0x9960012D71d2085516646B411925AD1d115ED01F
18+
0x7Afa3d0E44046C7ce8094dC429305A7ff3706D10
19+
0xcbe2cb2511e4fc2ca3552a65cf95324a5786c64f
20+
0xc4772Be15F0483672CD5f16CA06456c46908B61c
21+
0xfdf37696ba7b6f96efda6109fab72a1351c2e33a
22+
0x37c1f2469d510449a847e4e5c48607a2fc9aa223
23+
0xce85d05d57c4b16a09de0133c2abedf1bfeea57c
24+
0xd5a14d1846de1ad342853b79d1b5ef344c4973ef
25+
0xcc0eab15b35cf04b57db2bb1f9237cd782115bdc
26+
0x7699B9ACb26b9d05bd9091e14B28Ba57C1F0F5E8
27+
0x3f121b9a6bc33b6c9f711ccbcaac67459c875641
28+
0xb663945fc96656ad9f5b7ad1561182aca7071592
29+
0x9248679610d7a502a069948278160c88239f123b
30+
0x7f212c237699f3244da5ac025e12bcbf00d09357
31+
0x5b7279055048d435d70e86be71764de0a09e5b7f
32+
0x13b385a0cbc3296f14b342bad0e4fdf91ee08100
33+
0x0a442ac10830f98e6f0485c6193490c5260e94b8
34+
0xfa0460097248642d69bfb223bab5999507a8c23d
35+
0xc053308c25597ac6447ccfbf25bb08bfdf03b596
36+
0x3b7c618156f8cef53e123a66166aaf915b30ba3e
37+
0x75b884711094aa9f407251892d28653d049fafbd
38+
0xb0990e799314c516060b67a030fa5f5318baab69
39+
0xe536920e8256d58Ca9356899bcc36C4F14E76a2c
40+
0x306c0b64c39fb8924b026f6b9418d38278fc3c3f
41+
0x7c6ECf809bc86518458fcC87CdC73B9a4289Cc40
42+
0xcaa7f414906138a05051ecb759163dcc20514510
43+
0xf7783e451fcbf7ccc2e15b7fee4f534b41ecd6e4
44+
0x75272b96b7685834ef49b406e6a333ea28b10860
45+
0x3932f366886d2b981485503a182173da80d15c97
46+
0xa25150b69733D6834628613E712934C279BEadF7
47+
0xb30aef19a72d235090100795dacfaf529813f1f3
48+
0x78791ee453093a33486a7a5c5e425f998f63a785
49+
0x62fb2cdaf98b4851920548e991e14445721ad952
50+
0xa151e7a30b805d399106bef9ee6b4a463232b643

evm-testcases/cfs/add/report.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"files" : [ "report.json", "untyped_program.evm-testcases_cfs_add_add_eth.sol().json" ],
44
"info" : {
55
"cfgs" : "1",
6-
"duration" : "121ms",
7-
"end" : "2024-07-02T10:39:01.518+02:00",
6+
"duration" : "142ms",
7+
"end" : "2024-10-03T17:31:51.377+02:00",
88
"expressions" : "6",
99
"files" : "1",
1010
"globals" : "0",
1111
"members" : "1",
1212
"programs" : "1",
13-
"start" : "2024-07-02T10:39:01.397+02:00",
13+
"start" : "2024-10-03T17:31:51.235+02:00",
1414
"statements" : "11",
1515
"units" : "0",
1616
"version" : "0.1b8",

0 commit comments

Comments
 (0)