-
Notifications
You must be signed in to change notification settings - Fork 9
240 lines (214 loc) · 9.03 KB
/
check-proof-producer.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
name: Check Proof producer
on:
workflow_call:
env:
CAA_ARTIFACT_NAME: circuits-and-assignments
TO_ARTIFACT_NAME: transpiler-output
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
# uint_bit_decomposition
# uint_bit_composition
jobs:
prepare-targets:
name: Prepare targets strings
runs-on: ubuntu-22.04
if: |
always() && !cancelled()
outputs:
evm-targets: ${{ steps.get-targets.outputs.evm-targets }}
prover-targets: ${{ steps.get-targets.outputs.prover-targets }}
steps:
- 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
get-zkllvm-run:
name: Get zkLLVM run to use artifacts from
if: |
always() && !cancelled()
runs-on: ubuntu-22.04
outputs:
run-id: ${{ steps.get-run-id.outputs.run-id }}
steps:
- name: Get run ID of zkLLVM
id: get-run-id
env:
GH_TOKEN: ${{ github.token }}
run: |
zkllvm_ref="master"
zkllvm_repo="NilFoundation/zkLLVM"
while read -r line; do
echo "$line"
if [[ $line == "${zkllvm_repo}:"* ]]; then
zkllvm_ref=$(echo "$line" | cut -d ' ' -f 2)
break
fi
done <<< "$prs_refs"
if [[ $zkllvm_ref == refs/pull/* ]]; then
echo "Considering reference ${zkllvm_ref} a pr ref"
pr_number=${zkllvm_ref#refs/pull/}
pr_number=${pr_number%/merge}
sha=$(gh api repos/${zkllvm_repo}/pulls/$pr_number --jq '.head.sha')
elif [[ $zkllvm_ref == refs/tags/* ]]; then
echo "Considering reference ${zkllvm_ref} a tag"
tag=${zkllvm_ref#refs/tags/}
sha=$(gh api repos/${zkllvm_repo}/git/ref/tags/$tag --jq '.object.sha')
else
echo "Considering reference ${zkllvm_ref} a branch"
branch=${zkllvm_ref#refs/heads/}
# We can already fetch run_id here, but better fit to common approach with extra query by sha
sha=$(gh api "repos/${zkllvm_repo}/actions/workflows/nix_build_linux.yml/runs?branch=${branch}&status=completed&per_page=1" \
--jq '.workflow_runs[0].head_sha')
fi
echo "Using head sha: ${sha}"
run_id=$(gh api "repos/${zkllvm_repo}/actions/workflows/nix_build_linux.yml/runs?head_sha=${sha}&status=completed&per_page=1" \
--jq '.workflow_runs[0].id')
if [ -z "${run_id}" ]; then
echo no run ID fetched
exit 1
fi
echo "Run ID: ${run_id}"
for artifact in "${{ env.CAA_ARTIFACT_NAME }}" "${{ env.TO_ARTIFACT_NAME }}"; do
# Check if the artifact exists in the run
if ! gh run view ${run_id} --repo ${zkllvm_repo} | grep "$artifact"; then
echo "Artifact '$artifact' not found in run ${run_id}"
exit 1
fi
done
echo "run-id=${run_id}" >> $GITHUB_OUTPUT
build-and-generate-proofs:
name: Build prover, generate proofs for circuits
runs-on: [self-hosted, Linux, X64, aws_autoscaling]
needs:
- get-zkllvm-run
- prepare-targets
if: |
always() && !cancelled() &&
(needs.get-zkllvm-run.result == 'success' || needs.get-zkllvm-run.result == 'skipped') &&
(needs.prepare-targets.result == 'success' || needs.prepare-targets.result == 'skipped')
outputs:
artifact-name: ${{ steps.artifact-name.outputs.merged }}
steps:
# https://github.com/actions/checkout/issues/1552
- name: Clean up after previous checkout
run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*;
- name: Checkout Proof Producer
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Checkout submodules to specified refs
if: inputs.submodules-refs != ''
uses: NilFoundation/ci-cd/actions/[email protected]
with:
paths: |
${{ github.workspace }}/**
!${{ github.workspace }}/
!${{ github.workspace }}/**/.git/**
- name: Run checks
run: nix build -L .?#packages.x86_64-linux.proof-producer
- name: Set usefull strings
id: strings
run: |
echo "artifact-dir=$(realpath ${{ github.workspace }}/../artifacts)" >> $GITHUB_OUTPUT
echo "artifact-dir=$(realpath ${{ github.workspace }}/../artifacts)"
- name: Cleanup artifacts after previous runs
continue-on-error: true
run: |
echo "before:"
ls -l -a ${{ steps.strings.outputs.artifact-dir }}
rm -rf -v ${{ steps.strings.outputs.artifact-dir }}
echo "after:"
ls -l -a ${{ steps.strings.outputs.artifact-dir }}
- name: Download circuits and assignments artifact
uses: dawidd6/action-download-artifact@v6
with:
repo: NilFoundation/zkLLVM
name: ${{ env.CAA_ARTIFACT_NAME }}
path: ${{ steps.strings.outputs.artifact-dir }}
run_id: ${{ needs.get-zkllvm-run.outputs.run-id }}
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_unpack: true # It can't unpack such large files (>2Gb for some circuits)
- name: Extract circuits and assignments artifact
working-directory: ${{ steps.strings.outputs.artifact-dir }}
run: |
ls -l -a
unzip -o ${{ env.CAA_ARTIFACT_NAME }}.zip
- name: List artifacts
working-directory: ${{ steps.strings.outputs.artifact-dir }}
run: |
echo "all artifacts after unzip:"
find . -printf '%t %p\n'
echo "all artifacts end"
- name: Make proofs for pairs
working-directory: ${{ steps.strings.outputs.artifact-dir }}
run: |
extra_args=""
if [[ "true" == "true" ]]; then
extra_args="--multithreaded "
fi
targets_str=$(echo "${{ needs.prepare-targets.outputs.prover-targets }}" | awk '{$1=$1};1' | sed '/^$/d' | tr '\n' ' ' | sed 's/ $//')
echo "targets from input: ${targets_str}"
targets_arr=($targets_str)
new_targets_str=""
for artifact in "${targets_arr[@]}"; do
new_artifact_name=transpiler_output_"$artifact"
mv "$artifact" "$new_artifact_name"
new_targets_str="$new_targets_str $new_artifact_name"
done
echo "targets for output: ${new_targets_str}"
${{ github.workspace }}/proof-producer/tests/make_proof_for_pairs.sh --use-nix ${extra_args} ${new_targets_str}
# Leave only relevant transpiler_output_* folders
rm -rf ${RUNNER_TEMP}/transpiler_output/
mkdir -p ${RUNNER_TEMP}/transpiler_output/
mv transpiler_output_* ${RUNNER_TEMP}/transpiler_output/
rm -rf *
mv ${RUNNER_TEMP}/transpiler_output/* .
- name: List artifacts
working-directory: ${{ steps.strings.outputs.artifact-dir }}
run: find . -printf '%t %p\n'
- 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: |
${{ steps.strings.outputs.artifact-dir }}
# TODO: add package derivation to nix, upload its result
# - name: Upload .deb package
# if: matrix.cpp-compiler == 'clang++' && matrix.build-type == 'Release'
# uses: actions/upload-artifact@v4
# with:
# name: proof-producer.deb
# path: |
# ${{ steps.strings.outputs.build-dir }}/proof-producer*.deb
verify-proof-producer-proofs:
name: Verify proof-producer proofs with EVM-placeholder
needs:
- build-and-generate-proofs
- prepare-targets
if: |
always() && !cancelled() &&
(needs.build-and-generate-proofs.result == 'success' || needs.build-and-generate-proofs.result == 'skipped') &&
(needs.prepare-targets.result == 'success' || needs.prepare-targets.result == 'skipped')
uses: NilFoundation/evm-placeholder-verification/.github/workflows/reusable-verify-proofs.yml@a68465f641680eccc43ebdae02810eeab0537954
with:
artifact-name: ${{ needs.build-and-generate-proofs.outputs.artifact-name }}
evm-placeholder-verification-ref: a68465f641680eccc43ebdae02810eeab0537954
test-names: ${{ needs.prepare-targets.outputs.evm-targets }}