You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
doc: add build instructions for auto_build.sh and Docker
Added documentation to README.md detailing the usage of auto_build.sh for automated module compilation and cleaning.
Included instructions for building and running the application using Docker and Docker Compose, with examples for environment variables and volume mounts.
@@ -43,98 +43,219 @@ Or install the complete boost library with
43
43
sudo apt install libboost-all-dev
44
44
```
45
45
46
+
# Build Options
47
+
48
+
You can build the modules in two ways: **manual** or **automatic**. The automatic method is provided by the `auto_build.sh` script, which simplifies the build and clean processes. Additionally, you can use **Docker** or **Docker Compose** to run the application without installing dependencies directly on your machine.
49
+
50
+
## Automatic Method: `auto_build.sh`
51
+
52
+
The `auto_build.sh` script allows you to automatically build the modules based on the flags defined in `CXXFLAGS`. It also provides options to clean the builds before compiling.
53
+
54
+
### How to use:
55
+
56
+
1. **Automatic Build**:
57
+
- To automatically build the modules, define the flags in `CXXFLAGS` and run the script:
58
+
```bash
59
+
CXXFLAGS="-DLDK -DLND" ./auto_build.sh
60
+
```
61
+
This will automatically build the `LDK` and `LND` modules.
62
+
63
+
2. **Automatic Clean**:
64
+
- The script supports three cleaning modes before building:
65
+
- **Full Clean**: Cleans all modules before building the selected ones.
In this case, the script will run `make clean` for `LDK` and `BTCD`, but will only build the modules defined in `CXXFLAGS` (`LDK` and `LND`).
78
+
79
+
## Docker Method
80
+
81
+
If you prefer not to install dependencies directly on your machine, you can use Docker to run the application. This method simplifies deployment and ensures a consistent environment.
82
+
83
+
### Using the Dockerfile
84
+
85
+
1. **Build the Docker Image**:
86
+
- Build the Docker image using the provided `docker`:
87
+
```bash
88
+
docker build -t bitcoinfuzz .
89
+
```
90
+
91
+
2. **Run the Container**:
92
+
- Run the container with the required `FUZZ` and `CXXFLAGS` environment variables:
93
+
```bash
94
+
docker run -e FUZZ=target_name -e CXXFLAGS="-DLDK -DLND ..." bitcoinfuzz
95
+
```
96
+
97
+
3. **Optional Parameters**:
98
+
- You can also pass optional parameters:
99
+
- **`FUZZ_RUNS`**: Specify the number of fuzzing runs (e.g., 50):
The `docker-compose.yml` file simplifies running multiple fuzzing scenarios. Each scenario is preconfigured with the required modules and environment variables.
117
+
118
+
1. **Run All Scenarios**:
119
+
- To run all scenarios, simply execute:
120
+
```bash
121
+
docker-compose up
122
+
```
123
+
124
+
2. **Run a Specific Scenario**:
125
+
- To run a specific scenario (e.g., `script`), use:
126
+
```bash
127
+
docker-compose up script
128
+
```
129
+
130
+
3. **Optional Parameters**:
131
+
- You can pass optional parameters like `FUZZ_RUNS` or `FUZZ_INPUT`:
132
+
- Run with a specific number of fuzzing runs:
133
+
```bash
134
+
FUZZ_RUNS=50 docker-compose up script
135
+
```
136
+
- Run with a specific input file:
137
+
```bash
138
+
FUZZ_INPUT=/path/to/input docker-compose up script
139
+
```
140
+
141
+
4. **Accessing Generated Corpus**:
142
+
- The generated corpus for each scenario is saved in the `docker` directory at the same level as the `docker-compose.yml` file. Each scenario has its own subdirectory:
143
+
```
144
+
docker/
145
+
├── script/
146
+
├── deserialize_block/
147
+
├── script_eval/
148
+
├── deserialize_offer/
149
+
├── descriptor_parse/
150
+
├── miniscript_parse/
151
+
├── script_asm/
152
+
├── deserialize_invoice/
153
+
├── address_parse/
154
+
└── psbt_parse/
155
+
```
156
+
- To ensure the corpus is saved locally, the `docker-compose.yml` file maps the `/app/data` directory inside the container to the corresponding subdirectory in `docker`.
157
+
158
+
## Manual Method
159
+
160
+
If you prefer, you can still build the modules manually. Below are the steps for each module:
161
+
162
+
### Bitcoin modules:
163
+
164
+
- ### rust-bitcoin
165
+
166
+
```bash
167
+
cd modules/rustbitcoin
168
+
make cargo && make
169
+
export CXXFLAGS="$CXXFLAGS -DRUST_BITCOIN"
170
+
```
46
171
47
-
## Bitcoin modules:
48
-
49
-
### rust-bitcoin
50
-
51
-
```bash
52
-
cd modules/rustbitcoin
53
-
make cargo && make
54
-
export CXXFLAGS="$CXXFLAGS -DRUST_BITCOIN"
55
-
```
56
-
57
-
### rust-miniscript
58
-
59
-
```bash
60
-
cd modules/rustminiscript
61
-
make cargo && make
62
-
export CXXFLAGS="$CXXFLAGS -DRUST_MINISCRIPT"
63
-
```
64
-
65
-
### btcd
172
+
- ### rust-miniscript
66
173
67
-
```bash
68
-
cd modules/btcd
69
-
make
70
-
export CXXFLAGS="$CXXFLAGS -DBTCD"
71
-
```
174
+
```bash
175
+
cd modules/rustminiscript
176
+
make cargo && make
177
+
export CXXFLAGS="$CXXFLAGS -DRUST_MINISCRIPT"
178
+
```
72
179
73
-
### embit
180
+
- ### btcd
74
181
75
-
To run the fuzzer with `embit` module, you need to install the `embit` library.
182
+
```bash
183
+
cd modules/btcd
184
+
make
185
+
export CXXFLAGS="$CXXFLAGS -DBTCD"
186
+
```
76
187
77
-
To install the `embit` library, you can use the following command:
78
-
```bash
79
-
cd modules/embit
80
-
pip install -r embit_lib/requirements.txt
81
-
```
188
+
- ### embit
82
189
83
-
```bash
84
-
cd modules/embit
85
-
make
86
-
export CXXFLAGS="$CXXFLAGS -DEMBIT"
87
-
```
190
+
To run the fuzzer with `embit` module, you need to install the `embit` library.
88
191
89
-
### Bitcoin Core
192
+
To install the `embit` library, you can use the following command:
0 commit comments