Skip to content

Commit

Permalink
chore: clean up (#74)
Browse files Browse the repository at this point in the history
* chore: clean up

- [x] Add checks for ci actions
- [x] Run prettier, clippy, fmt commands for all the files
- [x] Move circom circuits to a circom folder
- [x] Get rid of js var statements

* chore: add resolver version for cargo.toml

* chore: add circom tests

* chore: optimize check triggers

* chore: remove `check` command

* chore: use only `pnpm`

* chore: update readme

---------

Co-authored-by: 0xmad <[email protected]>
  • Loading branch information
0xmad and 0xmad authored Nov 18, 2023
1 parent 51b030d commit 79c6026
Show file tree
Hide file tree
Showing 70 changed files with 7,047 additions and 6,505 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/circom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Circom checks
on:
workflow_dispatch:

push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
checks:
strategy:
fail-fast: false
matrix:
node-version: [18]
command: ["prettier", "types", "test:coverage"]

runs-on: ubuntu-latest

timeout-minutes: 240

steps:
- uses: actions/checkout@v4

- name: Clone circom repository
uses: actions/checkout@v4
with:
repository: iden3/circom
path: ./circom

- uses: pnpm/action-setup@v2
with:
version: latest

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- uses: dtolnay/rust-toolchain@nightly
with:
components: "clippy, rustfmt"

- name: Cache circom
uses: actions/cache@v3
id: circom-cache
continue-on-error: true
with:
path: |
~/.cargo/bin/circom
key: ${{ runner.os }}-circom-${{ hashFiles('./circom/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-circom-
- name: Install circom
if: steps.circom-cache.outputs.cache-hit != 'true'
run: |
cargo build --release
cargo install --path circom
working-directory: ./circom


- name: Build javascript
run: |
pnpm install --no-frozen-lockfile --prefer-offline
pnpm run build
working-directory: "./javascript"

- name: Check circom
run: |
pnpm install --no-frozen-lockfile --prefer-offline
pnpm run ${{ matrix.command }}
working-directory: "./circuits/circom"
41 changes: 41 additions & 0 deletions .github/workflows/javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Javascript checks
on:
workflow_dispatch:

push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
checks:
strategy:
fail-fast: false
matrix:
node-version: [18]
command: ["prettier", "types", "test:coverage"]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: latest

- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Check javascript
run: |
pnpm install --no-frozen-lockfile --prefer-offline
pnpm run build
pnpm run ${{ matrix.command }}
working-directory: "./javascript"
18 changes: 0 additions & 18 deletions .github/workflows/npm.yml

This file was deleted.

38 changes: 30 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
name: Rust test suite
on: [push, pull_request]
name: Rust checks
on:
workflow_dispatch:

push:
branches: [main]

pull_request:
branches: [main]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: cargo test
checks:
strategy:
fail-fast: false
matrix:
directory: ["./rust-arkworks", "./rust-k256"]
command: ["clippy", "test"]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@nightly
- run: cargo test --all-features
working-directory: ./rust-k256
- run: cargo test --all-features
working-directory: ./rust-arkworks
with:
components: "clippy, rustfmt"

- name: ${{ matrix.command }}
run: |
cargo build
cargo ${{ matrix.command }} --all-features
working-directory: ${{ matrix.directory }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
debug/
target/

coverage/

# Remove Cargo.lock from gitignore if creating an executable, leave it for
# libraries. More information at
# <https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html>
Expand Down
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dist/
node_modules/
coverage/
target
**/target/
**/dist/
**/node_modules/
**/coverage/
pnpm-lock.yaml
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"endOfLine": "auto",
"singleQuote": false,
"semi": true,
"tabWidth": 2,
"useTabs": false,
"trailingComma": "all"
}
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
[workspace]
resolver = "2"

members = [
"rust-arkworks",
"rust-k256"
]
members = ["rust-arkworks", "rust-k256"]

[patch.crates-io]
ark-ec = { git = "https://github.com/FindoraNetwork/ark-algebra" }
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ First, clone this repository and navigate to the `javascript/` directory.
Install dependencies:

```bash
npm i
pnpm i
```

If you encounter an error `No prebuilt binaries found`, try switching to node ` v18.17.0` (using [`n`](https://github.com/tj/n), for example) to work around our dependency's [build issue](https://github.com/WiseLibs/better-sqlite3/issues/1027).

Then, navigate to the `circuits/` directory and install the dependencies there:

```bash
npm i
pnpm i
```

Run the tests:
```bash
npm run flatten-deps && \
npm run test
pnpm run flatten-deps && \
pnpm run test
```

Be prepared to wait around 20-40 minutes for the tests to complete.
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion circuits/jest.config.js → circuits/circom/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ module.exports = {
"^.+\\.ts?$": "ts-jest",
},
transformIgnorePatterns: [
"<rootDir>/node_modules/(?!(secp256k1_hash_to_curve_circom)/)",
"<rootdir>/node_modules/.pnpm/(?!(secp256k1_hash_to_curve_circom)@)",
],
};
20 changes: 17 additions & 3 deletions circuits/package.json → circuits/circom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,35 @@
"version": "1.0.0",
"description": "Circom circuit to verify the construction of a nullifier signature in zero knowledge.",
"main": "",
"pnpm": {
"overrides": {
"@noble/secp256k1": "$@noble/secp256k1",
"circomlib": "$circomlib"
}
},
"scripts": {
"test": "NODE_OPTIONS=--max_old_space_size=8192 jest --runInBand",
"flatten-deps": "bash flatten-nested-dependencies.sh"
"preinstall": "npx only-allow pnpm",
"prettier": "prettier -c . --config ../../.prettierrc --ignore-path ../../.prettierignore",
"prettier:fix": "prettier -w . --config ../../.prettierrc --ignore-path ../../.prettierignore",
"types": "tsc -p tsconfig.json --noEmit",
"postinstall": "bash flatten-nested-dependencies.sh",
"test": "NODE_OPTIONS=--max_old_space_size=8192 jest",
"test:coverage": "pnpm run test"
},
"license": "ISC",
"dependencies": {
"circom_tester": "^0.0.19",
"@noble/secp256k1": "^1.7.1",
"circom-ecdsa": "github:0xPARC/circom-ecdsa",
"circom_tester": "^0.0.19",
"circomlib": "^2.0.5",
"ffjavascript": "^0.2.57",
"secp256k1_hash_to_curve_circom": "https://gitpkg.now.sh/geometryresearch/secp256k1_hash_to_curve/circuits?main"
},
"devDependencies": {
"@types/jest": "^29.4.0",
"@types/node": "^20.9.0",
"jest": "^29.4.1",
"prettier": "^3.0.3",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
},
Expand Down
Loading

0 comments on commit 79c6026

Please sign in to comment.