-
Notifications
You must be signed in to change notification settings - Fork 48
318 lines (275 loc) · 12 KB
/
nix_build_linux.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
name: Run tests
on:
# Triggers the workflow on pull request events but only for the master branch
pull_request:
branches: [ master ]
push:
branches: [ master ]
jobs:
handle-syncwith:
if: github.event_name == 'pull_request'
name: Call Reusable SyncWith Handler
uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1
with:
ci-cd-ref: 'v1'
secrets: inherit
build-and-test-with-nix:
needs: [ handle-syncwith ]
runs-on: ["self-hosted", "aws_autoscaling"]
outputs:
transpiler-artifact-name: ${{ steps.artifact-names.outputs.transpiler }}
examples-artifact-name: ${{ steps.artifact-names.outputs.examples }}
evm-targets: ${{ steps.get-targets.outputs.evm-targets }}
prover-targets: ${{ steps.get-targets.outputs.prover-targets }}
env:
INTEGRATION_TESTING_TARGETS: |
arithmetics_cpp_example
polynomial_cpp_example
poseidon_cpp_example
merkle_tree_poseidon_cpp_example
uint_remainder_cpp
compare_eq_cpp
private_input_cpp
# uint_shift_left # TODO fix and re-enable tests
# uint_bit_decomposition # TODO fix and re-enable tests
# uint_bit_composition # TODO fix and re-enable tests
strategy:
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: recursive
- name: Checkout submodules to specified refs
if: inputs.submodules-refs != ''
uses: NilFoundation/ci-cd/actions/recursive-checkout@master
with:
refs: ${{ inputs.submodules-refs }}
paths: |
${{ github.workspace }}/**
!${{ github.workspace }}/
!${{ github.workspace }}/**/.git/**
# nix is taken from the cloud-init template, no need to install it.
- name: Setup build
run: |
nix develop .?submodules=1# -c cmake -G Ninja -B build -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_ENABLE_TESTS=TRUE -DGENERATE_EVM_VERIFIER=TRUE -DZKLLVM_VERSION=0.1.18
- name: Build zkllvm
run: |
nix develop -c ninja -C build assigner clang transpiler
- name: Build IR of the C++ examples
run: |
nix develop -c ninja -C build -k 0 compile_cpp_examples
ls -al ./examples/cpp
- name: Build circuits(.crct) of the C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_generate_crct
ls -al ./examples/cpp
- name: Build assignment tables(.tbl) of the C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_generate_tbl_no_check
ls -al ./examples/cpp
- name: Copy assigner output from separate generation mode
run: |
bash ./tests/copy_assigner_outputs.sh ./build/examples/cpp/ build/separate_generatuon
- name: Run simultaneous .tbl and .crct generation of the C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_generate_both
ls -al ./examples/cpp
- name: Copy assigner output from simultaneous generation mode
run: |
bash ./tests/copy_assigner_outputs.sh ./build/examples/cpp/ build/simultaneous_generation
- name: Compare different assigner modes output
run: |
bash ./tests/compare_folders_content.sh build/separate_generatuon build/simultaneous_generation
- name: Run size estimation for C++ examples
run: |
nix develop -c ninja -C build -k 0 cpp_examples_estimate_size
- name: Copy examples' circuits and assignments for uploading
run: |
chmod +x ./examples/copy_artifacts.sh
./examples/copy_artifacts.sh build/examples/cpp examples_output
ls -al examples_output/
- name: Set aritfacts' names
id: artifact-names
run: |
echo "transpiler=transpiler-output" >> $GITHUB_OUTPUT
echo "examples=circuits-and-assignments" >> $GITHUB_OUTPUT
- name: Upload examples' circuits and assignments artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact-names.outputs.examples }}
path: |
examples_output
- name: Compile tests as cpp code
run: |
nix develop -c ninja -C build -k 0 all_tests_compile_as_cpp_code
- name: Compile tests as circuits
run: |
nix develop -c ninja -C build -k 0 all_tests_compile_as_circuits
- name: Run tests as cpp code (expected res calculation)
run: |
nix develop -c ninja -C build -k 0 all_tests_run_expected_res_calculation
- name: Get transpiler output for integration testing
run: |
targets_str=$(echo "${{ env.INTEGRATION_TESTING_TARGETS }}" | awk 'NF {printf " %s_evm_verifier ", $0}' | sed 's/[[:space:]]*$//')
echo "targets: ${targets_str}"
nix develop -c ninja -C build -k 0 ${targets_str}
ls -al build/examples/cpp/
- name: Upload examples' circuits and assignments artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact-names.outputs.transpiler }}
path: |
build/examples/cpp/transpiler_output_*
- name: Run tests as circuits (real res calculation)
run: |
nix develop -c ninja -C build -k 0 all_tests_assign_circuits
- name: Compare expected and real test results
run: |
chmod +x ./tests/run_test_results_comparison.sh
bash ./tests/run_test_results_comparison.sh
- name: Run tests on faulty inputs
run: |
chmod +x ./tests/run_tests_faulty_input.sh
bash ./tests/run_tests_faulty_input.sh pallas
- name: Run assigner unit tests
run: |
nix develop -c ninja -C build -k 0 check-crypto3-assigner
- name: Build proof for the circuit of the C++ examples
run: |
nix develop -c ninja -C build -k 0 prove_cpp_examples
- name: Build recursive gen
run: |
nix develop -c ninja -C build -k 0 recursive_gen
- name: Build and run transpiler test
run: |
nix develop -c ninja -C build -k 0 compile_and_run_transpiler_tests
- name: Run recursive verifier tests
run: |
nix develop -c ninja -C build -k 0 recursion
- name: Set targets for integration testing
id: get-targets
run: |
targets_str=$(echo "${{ env.INTEGRATION_TESTING_TARGETS }}" | awk 'NF {print "transpiler_output_" $1}')
echo "evm-targets<<EOF" >> $GITHUB_OUTPUT
echo "${targets_str}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "prover-targets<<EOF" >> $GITHUB_OUTPUT
echo "${{ env.INTEGRATION_TESTING_TARGETS }}" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
verify-zkllvm-proofs:
name: Verify built-it proofs with EVM-placeholder
needs:
- build-and-test-with-nix
- handle-syncwith
if: |
always() && !cancelled() &&
(needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped') &&
needs.build-and-test-with-nix.result == 'success'
uses: NilFoundation/evm-placeholder-verification/.github/workflows/reusable-verify-proofs.yml@2a0ef5fc67e97be8e3c7b59338cf9eecd030c57d
with:
artifact-name: ${{ needs.build-and-test-with-nix.outputs.transpiler-artifact-name }}
evm-placeholder-verification-ref: 2a0ef5fc67e97be8e3c7b59338cf9eecd030c57d
refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
test-names: ${{ needs.build-and-test-with-nix.outputs.evm-targets }}
generate-proofs:
name: Generate proofs for cpp examples
needs:
- build-and-test-with-nix
- handle-syncwith
if: |
always() && !cancelled() &&
(needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped') &&
needs.build-and-test-with-nix.result == 'success'
uses: NilFoundation/proof-producer/.github/workflows/reusable-generate-proofs-linux.yml@ef8cd9152b4bec871e7efdc1d6b606e445bad274
with:
artifact-name: ${{ needs.build-and-test-with-nix.outputs.examples-artifact-name }}
# Update next line if you need new version of proof producer
proof-producer-ref: ef8cd9152b4bec871e7efdc1d6b606e445bad274
refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
targets: ${{ needs.build-and-test-with-nix.outputs.prover-targets }}
merge-proofs-to-transpiler-output:
runs-on: ubuntu-22.04
needs:
- generate-proofs
- build-and-test-with-nix
if: |
always() && !cancelled() &&
needs.generate-proofs.result == 'success' &&
needs.build-and-test-with-nix.result == 'success'
outputs:
merged-artifact-name: ${{ steps.artifact-name.outputs.merged }}
steps:
- name: Download artifact with proofs
uses: actions/download-artifact@v3
with:
name: ${{ needs.generate-proofs.outputs.artifact-name }}
- name: Download artifact with transpiler output
uses: actions/download-artifact@v3
with:
name: ${{ needs.build-and-test-with-nix.outputs.transpiler-artifact-name }}
- name: Merge proofs into transpiler output
run: |
copy_failed=0
while read dir; do
base_name=${dir#./transpiler_output_}
if [[ -d "$base_name" ]]; then
if ! cp "${base_name}/proof.bin" "${dir}/"; then
echo "Failed to copy proof.bin to ${dir}" >&2
copy_failed=1
else
echo "proof.bin added to ${dir}"
fi
else
echo "Error: No matching directory found for ${dir}" >&2
fi
done < <(find . -type d -name "transpiler_output_*")
if [ $copy_failed -eq 1 ]; then
echo "One or more copy operations failed."
exit 1
fi
- name: Set aritfact name
id: artifact-name
run: |
echo "merged=transpiler-output-merged-proofs" >> $GITHUB_OUTPUT
- name: Upload merged artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.artifact-name.outputs.merged }}
path: |
transpiler_output_*
verify-proof-producer-proofs:
name: Verify proof-producer proofs with EVM-placeholder
needs:
- handle-syncwith
- merge-proofs-to-transpiler-output
- build-and-test-with-nix
if: |
always() && !cancelled() &&
(needs.handle-syncwith.result == 'success' || needs.handle-syncwith.result == 'skipped') &&
needs.build-and-test-with-nix.result == 'success' &&
needs.merge-proofs-to-transpiler-output.result == 'success'
uses: NilFoundation/evm-placeholder-verification/.github/workflows/reusable-verify-proofs.yml@2a0ef5fc67e97be8e3c7b59338cf9eecd030c57d
with:
artifact-name: ${{ needs.merge-proofs-to-transpiler-output.outputs.merged-artifact-name }}
evm-placeholder-verification-ref: 2a0ef5fc67e97be8e3c7b59338cf9eecd030c57d
refs: ${{ needs.handle-syncwith.outputs.prs-refs }}
test-names: ${{ needs.build-and-test-with-nix.outputs.evm-targets }}
cleanup-integration-testing:
# For now each artifact is 12 GB. Better clean it up to keep the space
name: Clean up after integration testing
needs:
- verify-proof-producer-proofs
- verify-zkllvm-proofs
- merge-proofs-to-transpiler-output
- build-and-test-with-nix
- generate-proofs
if: always()
runs-on: ubuntu-22.04
steps:
- uses: geekyeggo/delete-artifact@v2
with:
name: |
${{ needs.merge-proofs-to-transpiler-output.outputs.merged-artifact-name }}
${{ needs.generate-proofs.outputs.artifact-name }}