-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add integration testing with zkLLVM artifacts
- Loading branch information
Showing
1 changed file
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ (github.ref == 'refs/heads/master' && github.workflow) || (github.workflow, github.ref) }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
CONTAINER_TMP: circuits-and-assignments | ||
INTEGRATION_TESTING_TARGETS: | | ||
arithmetics_cpp_example | ||
polynomial_cpp_example | ||
poseidon_cpp_example | ||
merkle_tree_poseidon_cpp_example | ||
strlen_cpp_example | ||
uint_remainder_cpp | ||
uint_shift_left | ||
uint_bit_decomposition | ||
uint_bit_composition | ||
compare_eq_cpp | ||
private_input_cpp | ||
jobs: | ||
handle-syncwith: | ||
if: github.event_name == 'pull_request' | ||
name: Call Reusable SyncWith Handler | ||
uses: NilFoundation/ci-cd/.github/workflows/[email protected] | ||
with: | ||
ci-cd-ref: 'v1.1.2' | ||
secrets: inherit | ||
|
||
download-zkllvm-artifact: | ||
needs: | ||
- handle-syncwith | ||
outputs: | ||
evm-targets: ${{ steps.get-targets.outputs.evm-targets }} | ||
prover-targets: ${{ steps.get-targets.outputs.prover-targets }} | ||
steps: | ||
- name: Get run ID of zkLLVM | ||
id: get-run-id | ||
run: | | ||
prs_refs="${{ needs.handle-syncwith.outputs.prs-refs }}" | ||
zkllvm_ref="master" | ||
zkllvm_repo="NilFoundation/zkLLVM" | ||
echo "$prs_refs" | while read line; do | ||
if [[ $line == "${zkllvm_repo}:"* ]]; then | ||
zkllvm_ref=$(echo $line | cut -d ' ' -f 2) | ||
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/} | ||
sha=$(gh api repos/${zkllvm_repo}/branches/$branch --jq '.commit.sha') | ||
fi | ||
break | ||
fi | ||
done | ||
echo "Using head sha ${sha}" | ||
run_id=$(gh api "repos/${zkllvm_repo}/actions/runs?head_sha=${sha}&status=completed&event=pull_request&per_page=1" \ | ||
--jq '.workflow_runs[0].id') | ||
echo "run-id=${run_id}" >> $GITHUB_OUTPUT | ||
- name: Download circuits and assignments from zkLLVM | ||
run: | | ||
run_id=${{ steps.get-run-id.outputs.run-id }} | ||
if [ -z "${run_id}" ]; then | ||
echo no run ID provided | ||
fi | ||
gh run download $run_id --repo 'NilFoundation/zkLLVM' --name 'circuits-and-assignments' | ||
gh run download $run_id --repo 'NilFoundation/zkLLVM' --name 'transpiler-output' | ||
- name: Upload circuits and assignments | ||
# Make it a local artifact, so reusable generate proofs would access it | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: circuits-and-assignments | ||
path: circuits-and-assignments | ||
|
||
- name: Upload circuits and assignments | ||
# Make it a local artifact, so reusable generate proofs would access it | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: transpiler-output | ||
path: transpiler-output | ||
|
||
- 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 | ||
generate-proofs: | ||
name: Generate proofs for cpp examples | ||
needs: | ||
- download-zkllvm-artifact | ||
- handle-syncwith | ||
uses: NilFoundation/proof-producer/.github/workflows/reusable-generate-proofs-linux.yml@af67299b6f1ae991c3295b9eb062601f401a6f86 | ||
with: | ||
artifact-name: circuits-and-assignments | ||
# Update next line if you need new version of proof producer | ||
proof-producer-ref: ${{ github.sha }} | ||
refs: ${{ needs.handle-syncwith.outputs.prs-refs }} | ||
targets: ${{ needs.download-zkllvm-artifact.outputs.evm-targets }} | ||
|
||
|
||
merge-proofs-to-transpiler-output: | ||
runs-on: ubuntu-22.04 | ||
needs: | ||
- download-zkllvm-artifact | ||
- build-and-test-linux | ||
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: transpiler-output | ||
|
||
- 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 | ||
- download-zkllvm-artifact | ||
- merge-proofs-to-transpiler-output | ||
uses: NilFoundation/evm-placeholder-verification/.github/workflows/reusable-verify-proofs.yml@5bb7c4b0790f56b3a339e33ba442816fac17ab88 | ||
with: | ||
artifact-name: ${{ needs.merge-proofs-to-transpiler-output.outputs.merged-artifact-name }} | ||
evm-placeholder-verification-ref: 5bb7c4b0790f56b3a339e33ba442816fac17ab88 | ||
refs: ${{ needs.handle-syncwith.outputs.prs-refs }} | ||
test-names: ${{ needs.download-zkllvm-artifact.outputs.evm-targets }} |