Skip to content

Commit

Permalink
ci: Add Solidity compatibility check (#363)
Browse files Browse the repository at this point in the history
* ci: Add Solidity compatibility check

* Fix CI

* Test breaking change comment

* Test breaking change issue

* Prep for review

* Address feedback & clean up

* Address feedback

* Test breaking change issue creation

* Prep for final review
  • Loading branch information
samuelburnham authored Mar 14, 2024
1 parent 6133454 commit 7ba1739
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/SOLIDITY_COMPAT_ISSUE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Compatibility with the [Arecibo](https://github.com/lurk-lab/arecibo) dependency has been broken by commit [`__COMMIT__`](__COMMIT_URL__) from __PR_URL__.

Check the [Solidity compatibility workflow run](__WORKFLOW_URL__) for details.

This issue was raised by the workflow at __WORKFLOW_FILE__.
172 changes: 172 additions & 0 deletions .github/workflows/solidity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# TODO: Reusify and combine with the `check-lurk-compiles` action and/or make a reusable open-issue action
#
# This workflow runs autogenerated `solidity-verifier` compatibility tests on Arecibo PRs and notifies if compatibility is broken
# The workflow is intended to be a required status check only to make sure the Rust test & basic job steps work
# It is NOT intended to block breaking changes from merging, only to noisily surface them for review
#
# If the Rust template fails to generate the Solidity test or the job errors for another reason, the workflow fails immediately
# If the Solidity test fails on `pull_request`, it writes a PR comment to ensure the author/reviewer are notified
# If the Solidity test fails on `merge_group`, it opens an issue in `solidity-verifier` downstream that compatibility has been broken
# `merge_group` failures should only happen intentionally when breaking changes need to be merged in Arecibo
#
# Implementation note:
# `falnyr/replace-env-vars-action`, `micalevisk/last-issue-action` and `peter-evans/create-issue-from-file` replace
# equivalent functionality in `JasonEtco/create-an-issue`. We can't use the latter because it doesn't allow creating
# the issue in another repo. See https://github.com/JasonEtco/create-an-issue/issues/40
name: Test `solidity-verifier` compatibility

on:
merge_group:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- dev
- 'feat/**'
- release-candidate

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
solidity-compat:
runs-on: buildjet-16vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
with:
repository: lurk-lab/ci-workflows
- uses: ./.github/actions/ci-env
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@nextest
- uses: Swatinem/rust-cache@v2
- name: Run Solidity test generator
run: |
# Runs all tests with the `test_solidity_compatibility` prefix, e.g. `test_solidity_compatibility_ipa`
cargo nextest run -E 'test(test_solidity_compatibility)' --release --run-ignored all --nocapture > test-output
working-directory: ${{ github.workspace }}
- name: Check out `solidity-verifier` for tests
uses: actions/checkout@v4
with:
repository: lurk-lab/solidity-verifier
path: solidity-verifier
submodules: recursive
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Prep Solidity test files
run: |
# Get test names from output, extracting the final word after the final `_` in the test output
# E.g. `test provider::tests::ipa_pc::test::test_solidity_compatibility_ipa ... ok` returns `ipa`
# Expects all tests to live in the `provider` module, but can be changed/strengthened in future
TEST_NAMES=$(grep 'test provider::*' test-output | awk -F'[_(.*?)\b...]' '{ print $(NF-3) }')
echo "$TEST_NAMES"
# Print output of each test to `<test_name>.t.sol` file
awk -v names="$TEST_NAMES" 'BEGIN {
file_counter = 0
buffer = ""
# Convert test names to array
split(names, elements, " ")
for (i in elements) {
print "Element:", elements[i]
}
}
/running 1 test/ {
between = 1
buffer = ""
}
between {
buffer = buffer $0 ORS
}
/^test provider.*$/ {
between = 0
if (buffer != "") {
++file_counter
print buffer > elements[file_counter]".t.sol"
buffer = ""
}
}' test-output
# Clean up
shopt -s nullglob
for file in *.t.sol; do
cat $file | sed '1d' | head -n -2 > tmp.file && mv tmp.file solidity-verifier/test/$file
done
shopt -u nullglob
working-directory: ${{ github.workspace }}
- name: Run Forge tests
id: solidity-test
run: forge test -vvv
working-directory: ${{ github.workspace }}/solidity-verifier
continue-on-error: true
# Prepares env vars for use in a PR comment or issue in `solidity-verifier`
- name: Set env vars
if: steps.solidity-test.outcome != 'success'
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
COMMIT=$(echo ${{ github.event.pull_request.head.sha }} | cut -c -7)
PR_NUMBER=${{ github.event.pull_request.number }}
else
COMMIT=$(echo ${{ github.event.merge_group.head_sha }} | cut -c -7)
PR_NUMBER=$(echo ${{ github.event.merge_group.head_ref }} | sed -e 's/.*pr-\(.*\)-.*/\1/')
fi
GITHUB_URL=https://github.com/${{ github.repository }}
WORKFLOW_URL=$GITHUB_URL/actions/runs/${{ github.run_id }}
echo "WORKFLOW_FILE=$WORKFLOW_URL/workflow" | tee -a $GITHUB_ENV
echo "WORKFLOW_URL=$WORKFLOW_URL" | tee -a $GITHUB_ENV
echo "COMMIT_URL=$GITHUB_URL/commit/$COMMIT" | tee -a $GITHUB_ENV
echo "PR_URL=$GITHUB_URL/pull/$PR_NUMBER" | tee -a $GITHUB_ENV
echo "COMMIT=$COMMIT" | tee -a $GITHUB_ENV
# Comment on PR when test fails on `pull_request`
- name: Comment on failing run
if: steps.solidity-test.outcome != 'success' && github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
`solidity-verifier` compatibility test failed :x:
${{ env.WORKFLOW_URL }}
# Substitutes env vars for their values in `SOLIDITY_COMPAT_ISSUE.md`
- uses: falnyr/replace-env-vars-action@master
if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued')
env:
WORKFLOW_URL: ${{ env.WORKFLOW_URL }}
WORKFLOW_FILE: ${{ env.WORKFLOW_FILE }}
COMMIT: ${{ env.COMMIT }}
COMMIT_URL: ${{ env.COMMIT_URL }}
PR_URL: ${{ env.PR_URL }}
with:
filename: .github/SOLIDITY_COMPAT_ISSUE.md
# Finds the last open issue matching given labels
- name: Find the last open compatibility issue
id: last-issue
if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued')
uses: micalevisk/last-issue-action@v2
with:
repository: lurk-lab/solidity-verifier
state: open
# Find the last updated open issue that has these labels:
labels: |
compatibility
debt
automated issue
# Update existing issue in `solidity-verifier` or create new one
- uses: peter-evans/create-issue-from-file@v5
if: steps.solidity-test.outcome != 'success' && (github.event_name != 'pull_request' || github.event.action == 'enqueued')
with:
token: ${{ secrets.REPO_TOKEN }}
repository: lurk-lab/solidity-verifier
issue-number: ${{ steps.last-issue.outputs.issue-number }}
title: ":rotating_light: Arecibo compatibility is broken"
content-filepath: .github/SOLIDITY_COMPAT_ISSUE.md
labels: |
compatibility
debt
automated issue
2 changes: 2 additions & 0 deletions .lycheeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__COMMIT_URL__
__WORKFLOW_URL__

1 comment on commit 7ba1739

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks

Table of Contents

Overview

This benchmark report shows the Arecibo GPU benchmarks.
NVIDIA L4
Intel(R) Xeon(R) CPU @ 2.20GHz
32 vCPUs
125 GB RAM
Workflow run: https://github.com/lurk-lab/arecibo/actions/runs/8286817864

Benchmark Results

RecursiveSNARK-NIVC-2

ref=6133454 ref=7ba1739
Prove-NumCons-6540 45.20 ms (✅ 1.00x) 44.97 ms (✅ 1.01x faster)
Verify-NumCons-6540 35.28 ms (✅ 1.00x) 35.90 ms (✅ 1.02x slower)
Prove-NumCons-1028888 322.71 ms (✅ 1.00x) 323.06 ms (✅ 1.00x slower)
Verify-NumCons-1028888 247.99 ms (✅ 1.00x) 254.31 ms (✅ 1.03x slower)

CompressedSNARK-NIVC-Commitments-2

ref=6133454 ref=7ba1739
Prove-NumCons-6540 10.84 s (✅ 1.00x) 10.84 s (✅ 1.00x slower)
Verify-NumCons-6540 51.92 ms (✅ 1.00x) 52.13 ms (✅ 1.00x slower)
Prove-NumCons-1028888 53.08 s (✅ 1.00x) 54.21 s (✅ 1.02x slower)
Verify-NumCons-1028888 52.00 ms (✅ 1.00x) 52.24 ms (✅ 1.00x slower)

Made with criterion-table

Please sign in to comment.