Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Port changes from main #48

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 7 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,57 +1,15 @@
name: Run tests
name: Run unit tests

on:
push:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
merge_group:
workflow_dispatch:

jobs:
integration-tests-e2e:
name: E2E verification
# Run on merge_group and workflow_dispatch only
if: (github.event_name != 'push' && github.event_name != 'pull_request') || github.event.action == 'enqueued'
runs-on: [self-hosted]
env:
ANVIL_PRIVATE_KEY: ${{secrets.ANVIL_PRIVATE_KEY}}
ANVIL_URL: ${{secrets.ANVIL_RPC_URL}}
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: Deploy main contract
run: |
echo "CONTRACT_ADDRESS=$(forge script script/Deployment.s.sol:NovaVerifierDeployer --fork-url $ANVIL_URL --private-key $ANVIL_PRIVATE_KEY --broadcast --non-interactive | sed -n 's/.*Contract Address: //p' | tail -1)" >> $GITHUB_OUTPUT
id: deployment

- name: Load proof and public parameters
run: |
python loader.py pp-verifier-key.json pp-compressed-snark.json ${{steps.deployment.outputs.CONTRACT_ADDRESS}} $ANVIL_URL $ANVIL_PRIVATE_KEY
- name: Check proof verification status
run: |
[[ $(cast call ${{steps.deployment.outputs.CONTRACT_ADDRESS}} "verify(uint32,uint256[],uint256[],bool)(bool)" "3" "[1]" "[0]" "true" --private-key $ANVIL_PRIVATE_KEY --rpc-url $ANVIL_URL) == true ]] && exit 0 || exit 1
unit-tests:
strategy:
fail-fast: true

name: Unit Tests
runs-on: [self-hosted]
runs-on: buildjet-16vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -62,6 +20,11 @@ jobs:
with:
python-version: 3.8

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Check formatting
run: |
forge fmt --check
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/end2end.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Run integration tests when a maintainer comments `!test` on a PR
# Run integration tests when a maintainer comments `!test` on a PR to feature branch
# Fails when base branch is `main`, as it doesn't support e2e tests
name: End to end integration tests

on:
Expand All @@ -11,17 +12,24 @@ env:

jobs:
integration-tests-e2e:
strategy:
fail-fast: true

name: E2E verification
runs-on: [self-hosted]
runs-on: buildjet-16vcpu-ubuntu-2204
if:
github.event.issue.pull_request
&& github.event.issue.state == 'open'
&& contains(github.event.comment.body, '!test')
&& (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER')
steps:
- uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch

- name: Exit if base branch is `main`
if: ${{ steps.comment-branch.outputs.base_ref == 'main' }}
run: |
echo "Cannot run end2end integration tests on PR targeting `main`"
exit 1
continue-on-error: false

- uses: actions/checkout@v4
with:
submodules: recursive
Expand Down
4 changes: 1 addition & 3 deletions src/Utilities.sol
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ library PolyLib {
}

uint256 coeff_index = 0;
uint256[] memory coeffs = new uint256[](
poly.coeffs_except_linear_term.length + 1
);
uint256[] memory coeffs = new uint256[](poly.coeffs_except_linear_term.length + 1);
coeffs[coeff_index] = poly.coeffs_except_linear_term[0];
coeff_index++;
coeffs[coeff_index] = linear_term;
Expand Down
7 changes: 4 additions & 3 deletions test/pp-spartan-step5-tests.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,10 @@ contract PpSpartanStep5Computations is Test {
uint256[] memory eval_output_arr
) private pure returns (uint256[] memory) {
uint256 index = 0;
uint256[] memory eval_vec =
new uint256[](eval_left_arr.length + eval_right_arr.length + eval_output_arr.length + eval_A_B_C_z.length + evals_E.length + evals_val.length);

uint256[] memory eval_vec = new uint256[](
eval_left_arr.length + eval_right_arr.length + eval_output_arr.length + eval_A_B_C_z.length + evals_E.length
+ evals_val.length
);
for (uint256 i = 0; i < eval_A_B_C_z.length; i++) {
eval_vec[index] = eval_A_B_C_z[i];
index++;
Expand Down