-
Notifications
You must be signed in to change notification settings - Fork 25
416 lines (363 loc) · 16.2 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
name: Build
on:
release:
types: [published]
push:
branches:
- main
pull_request:
jobs:
build-linux-2:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- uses: docker/build-push-action@v6
with:
push: false
outputs: type=docker
platforms: linux/amd64
file: .github/images/Dockerfile.build
context: ./.github/images/context.build
cache-from: type=gha,scope=buildkit-amd64
cache-to: type=gha,mode=max,scope=buildkit-amd64
tags: builder:amd64
- uses: docker/build-push-action@v6
with:
push: false
outputs: type=docker
platforms: linux/arm64
file: .github/images/Dockerfile.build
context: ./.github/images/context.build
cache-from: type=gha,scope=buildkit-arm64
cache-to: type=gha,mode=max,scope=buildkit-arm64
tags: builder:arm64
- name: Cache gmp build
uses: actions/cache@v4
with:
path: |
depends/gmp
depends/gmp-6.2.1.tar.xz
key: ${{ runner.os }}-gmp-${{ hashFiles('build_gmp.sh') }}-3
- name: Build gmp for Linux arm64
run: |
set -x
set -e
if [[ ! -d "depends/gmp/package_aarch64" ]]; then
docker run --rm --platform=linux/arm64 -i -v $PWD:/work --workdir=/work builder:arm64 ./build_gmp.sh aarch64
fi
- name: Build prover Linux arm64
run: |
docker run --rm --platform=linux/arm64 -i -v $PWD:/work --workdir=/work builder:arm64 bash -c "$(cat << 'EOF'
set -x
set -e
mkdir -p build_prover_arm64 && cd build_prover_arm64
cmake .. -DTARGET_PLATFORM=aarch64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_arm64
make -j4 && make install
ctest --rerun-failed --output-on-failure
EOF
)"
- name: Upload Linux arm64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-linux-arm64
path: |
package_arm64
if-no-files-found: error
- run: docker run --platform=linux/arm64 builder:arm64 uname -a
- run: docker run --platform=linux/amd64 builder:amd64 uname -a
build-linux:
runs-on: ubuntu-22.04
if: false
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: install requirements
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: build-essential cmake m4 nasm
version: 1.0
- name: Cache gmp build
uses: actions/cache@v4
with:
path: |
depends/gmp
depends/gmp-6.2.1.tar.xz
key: ${{ runner.os }}-gmp-${{ hashFiles('build_gmp.sh') }}-2
- name: Build gmp for Android arm64
run: if [[ ! -d "depends/gmp/package_android_arm64" ]]; then ./build_gmp.sh android; fi
- name: Build gmp for Android x86_64
run: if [[ ! -d "depends/gmp/package_android_x86_64" ]]; then ./build_gmp.sh android_x86_64; fi
- name: Build gmp for Linux x86_64
run: if [[ ! -d "depends/gmp/package" ]]; then ./build_gmp.sh host; fi
- name: Build prover Android ARM64
run: |
mkdir -p build_prover_android && cd build_prover_android
cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android -DBUILD_TESTS=OFF -DUSE_OPENMP=OFF
make -j4 && make install
- name: Build prover Android ARM64 with OpenMP
run: |
mkdir -p build_prover_android_openmp && cd build_prover_android_openmp
cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_openmp -DBUILD_TESTS=OFF -DUSE_OPENMP=ON
make -j4 && make install
- name: Build prover Android x86_64
run: |
mkdir -p build_prover_android_x86_64 && cd build_prover_android_x86_64
cmake .. -DTARGET_PLATFORM=ANDROID_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_x86_64 -DBUILD_TESTS=OFF -DUSE_OPENMP=OFF
make -j4 && make install
- name: Build prover Android x86_64 with OpenMP
run: |
mkdir -p build_prover_android_openmp_x86_64 && cd build_prover_android_openmp_x86_64
cmake .. -DTARGET_PLATFORM=ANDROID_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_openmp_x86_64 -DBUILD_TESTS=OFF -DUSE_OPENMP=ON
make -j4 && make install
- name: Build prover Linux
run: |
mkdir -p build_prover && cd build_prover
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
make -j4 && make install
ctest --rerun-failed --output-on-failure
- name: test rapidsnark
run: |
set -x
set -e
time package/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
time package/bin/verifier testdata/verification_key.json public.json proof.json
# make a wrong public.json by decrementing the first element by 1
(value_0=$(jq '.[0]' public.json | tr -d '"') && value_0=$(echo "$value_0 - 1" | BC_LINE_LENGTH=100 bc) && jq --arg value_0 "$value_0" '.[0] = $value_0' public.json) > public_bad.json
set +e
time package/bin/verifier testdata/verification_key.json public_bad.json proof.json
exit_code=$?
set -e
[ $exit_code -ne 0 ]
- name: upload Linux amd64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-linux-amd64
path: |
package
if-no-files-found: error
- name: upload Android dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-Android
path: |
package_android
if-no-files-found: error
- name: upload Android dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-Android-OpenMP
path: |
package_android_openmp
if-no-files-found: error
- name: upload Android x86_64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-Android-x86_64
path: |
package_android_x86_64
if-no-files-found: error
- name: upload Android x86_64 dev artifacts (with OpenMP)
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-Android-OpenMP-x86_64
path: |
package_android_openmp_x86_64
if-no-files-found: error
- name: upload Android ARM64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir -p rapidsnark-android-arm64-${{ github.ref_name }}
cp -r package_android/* rapidsnark-android-arm64-${{ github.ref_name }}/
zip -r rapidsnark-android-arm64-${{ github.ref_name }}.zip rapidsnark-android-arm64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-android-arm64-${{ github.ref_name }}.zip
- name: upload Android x86_64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir -p rapidsnark-android-x86_64-${{ github.ref_name }}
cp -r package_android_x86_64/* rapidsnark-android-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-android-x86_64-${{ github.ref_name }}.zip rapidsnark-android-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-android-x86_64-${{ github.ref_name }}.zip
- name: upload Linux x86_64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir -p rapidsnark-linux-x86_64-${{ github.ref_name }}
cp -r package/* rapidsnark-linux-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-linux-x86_64-${{ github.ref_name }}.zip rapidsnark-linux-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-linux-x86_64-${{ github.ref_name }}.zip
build-apple-arm64:
runs-on: macos-14
if: false
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Cache gmp build
uses: actions/cache@v4
with:
path: |
depends/gmp
depends/gmp-6.2.1.tar.xz
key: ${{ runner.os }}-gmp-arm64-${{ hashFiles('build_gmp.sh') }}
- name: build
run: |
if [[ ! -d "depends/gmp/package_ios_arm64" ]]; then ./build_gmp.sh ios; fi
if [[ ! -d "depends/gmp/package_iphone_simulator" ]]; then ./build_gmp.sh ios_simulator; fi
if [[ ! -d "depends/gmp/package_macos_arm64" ]]; then ./build_gmp.sh macos_arm64; fi
mkdir -p build_prover_ios && cd build_prover_ios
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios -DBUILD_TESTS=OFF
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release
cp ../depends/gmp/package_ios_arm64/lib/libgmp.a src/Release-iphoneos
cd ../
mkdir -p build_prover_ios_simulator && cd build_prover_ios_simulator
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO -DBUILD_TESTS=OFF
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj
cp ../depends/gmp/package_iphone_simulator/lib/libgmp.a src/Debug-iphonesimulator
cd ../
mkdir -p build_prover_macos_arm64 && cd build_prover_macos_arm64
cmake .. -DTARGET_PLATFORM=macos_arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_arm64
make -j4 && make install
ctest --rerun-failed --output-on-failure
- name: test rapidsnark
run: |
set -x
set -e
time package_macos_arm64/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
time package_macos_arm64/bin/verifier testdata/verification_key.json public.json proof.json
# make a wrong public.json by decrementing the first element by 1
(value_0=$(jq '.[0]' public.json | tr -d '"') && value_0=$(echo "$value_0 - 1" | BC_LINE_LENGTH=100 bc) && jq --arg value_0 "$value_0" '.[0] = $value_0' public.json) > public_bad.json
set +e
time package_macos_arm64/bin/verifier testdata/verification_key.json public_bad.json proof.json
exit_code=$?
set -e
[ $exit_code -ne 0 ]
- name: upload macOS arm64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-macOS-arm64
path: |
package_macos_arm64
if-no-files-found: error
- name: upload iOS dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-iOS
path: |
build_prover_ios/src/Release-iphoneos
if-no-files-found: error
- name: upload iOS Simulator dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-iOS-Simulator
path: |
build_prover_ios_simulator/src/Debug-iphonesimulator
if-no-files-found: error
- name: upload iOS release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir -p rapidsnark-iOS-${{ github.ref_name }}
cp -r build_prover_ios/src/Release-iphoneos/* rapidsnark-iOS-${{ github.ref_name }}/
zip -r rapidsnark-iOS-${{ github.ref_name }}.zip rapidsnark-iOS-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-iOS-${{ github.ref_name }}.zip
- name: upload iOS Simulator release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir -p rapidsnark-iOS-Simulator-${{ github.ref_name }}
cp -r build_prover_ios_simulator/src/Debug-iphonesimulator/* rapidsnark-iOS-Simulator-${{ github.ref_name }}/
zip -r rapidsnark-iOS-Simulator-${{ github.ref_name }}.zip rapidsnark-iOS-Simulator-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-iOS-Simulator-${{ github.ref_name }}.zip
- name: upload macOS arm64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir -p rapidsnark-macOS-arm64-${{ github.ref_name }}
cp -r package_macos_arm64/* rapidsnark-macOS-arm64-${{ github.ref_name }}/
zip -r rapidsnark-macOS-arm64-${{ github.ref_name }}.zip rapidsnark-macOS-arm64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-arm64-${{ github.ref_name }}.zip
build-apple-x86_64:
runs-on: macos-13
if: false
steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Cache gmp build
uses: actions/cache@v4
with:
path: |
depends/gmp
depends/gmp-6.2.1.tar.xz
key: ${{ runner.os }}-gmp-x86_64-${{ hashFiles('build_gmp.sh') }}-2
- name: install dependencies
run: |
brew install nasm
- name: build
run: |
if [[ ! -d "depends/gmp/package_macos_x86_64" ]]; then ./build_gmp.sh macos_x86_64; fi
mkdir -p build_prover_macos_x86_64 && cd build_prover_macos_x86_64
cmake .. -DTARGET_PLATFORM=macos_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_x86_64
make -j4 && make install
ctest --rerun-failed --output-on-failure
- name: test rapidsnark
run: |
set -x
set -e
time package_macos_x86_64/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
time package_macos_x86_64/bin/verifier testdata/verification_key.json public.json proof.json
# make a wrong public.json by decrementing the first element by 1
(value_0=$(jq '.[0]' public.json | tr -d '"') && value_0=$(echo "$value_0 - 1" | BC_LINE_LENGTH=100 bc) && jq --arg value_0 "$value_0" '.[0] = $value_0' public.json) > public_bad.json
set +e
time package_macos_x86_64/bin/verifier testdata/verification_key.json public_bad.json proof.json
exit_code=$?
set -e
[ $exit_code -ne 0 ]
- name: upload macOS x86_64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v4
with:
name: rapidsnark-macOS-x86_64
path: |
package_macos_x86_64
if-no-files-found: error
- name: upload macOS x86_64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir -p rapidsnark-macOS-x86_64-${{ github.ref_name }}
cp -r package_macos_x86_64/* rapidsnark-macOS-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip rapidsnark-macOS-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip