-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'abi-wasm' of github.com:noir-lang/noir into abi-wasm
- Loading branch information
Showing
22 changed files
with
6,395 additions
and
13 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,26 @@ | ||
name: Setup | ||
|
||
inputs: | ||
working-directory: | ||
default: ./ | ||
required: false | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Install node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.15 | ||
- name: Cache | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: "**/node_modules" | ||
key: yarn-v1-${{ hashFiles('**/yarn.lock') }} | ||
- name: Install | ||
run: | | ||
cd ${{ inputs.working-directory }} | ||
yarn --immutable | ||
shell: bash | ||
if: steps.cache.outputs.cache-hit != 'true' |
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,95 @@ | ||
name: ABI Wasm test | ||
|
||
on: | ||
pull_request: | ||
merge_group: | ||
|
||
# This will cancel previous runs when a branch or PR is updated | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-noirc-abi-wasm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- uses: cachix/install-nix-action@v20 | ||
with: | ||
nix_path: nixpkgs=channel:nixos-22.11 | ||
github_access_token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- uses: cachix/cachix-action@v12 | ||
with: | ||
name: barretenberg | ||
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" | ||
|
||
- name: Build noirc_abi_wasm | ||
run: | | ||
nix build .#noirc_abi_wasm | ||
- name: Dereference symlink | ||
run: echo "UPLOAD_PATH=$(readlink -f result)" >> $GITHUB_ENV | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: noirc_abi_wasm | ||
path: ${{ env.UPLOAD_PATH }} | ||
retention-days: 3 | ||
|
||
test-node: | ||
needs: [build-noirc-abi-wasm] | ||
name: Node.js Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: noirc_abi_wasm | ||
path: ./result | ||
|
||
- name: Set up test environment | ||
uses: ./.github/actions/setup | ||
with: | ||
working-directory: ./crates/noirc_abi_wasm | ||
|
||
- name: Run node tests | ||
working-directory: ./crates/noirc_abi_wasm | ||
run: yarn test | ||
|
||
test-browser: | ||
needs: [build-noirc-abi-wasm] | ||
name: Browser Tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v3 | ||
|
||
- name: Download artifact | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: noirc_abi_wasm | ||
path: ./result | ||
|
||
- name: Set up test environment | ||
uses: ./.github/actions/setup | ||
with: | ||
working-directory: ./crates/noirc_abi_wasm | ||
|
||
- name: Install playwright deps | ||
working-directory: ./crates/noirc_abi_wasm | ||
run: | | ||
npx playwright install | ||
npx playwright install-deps | ||
- name: Run browser tests | ||
working-directory: ./crates/noirc_abi_wasm | ||
run: yarn test:browser |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,2 @@ | ||
node_modules | ||
pkg |
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,19 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint", "prettier"], | ||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
rules: { | ||
"comma-spacing": ["error", { before: false, after: true }], | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": [ | ||
"warn", // or "error" | ||
{ | ||
argsIgnorePattern: "^_", | ||
varsIgnorePattern: "^_", | ||
caughtErrorsIgnorePattern: "^_", | ||
}, | ||
], | ||
"prettier/prettier": "error", | ||
}, | ||
}; |
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,8 @@ | ||
# Yarn | ||
.pnp.* | ||
.yarn/* | ||
!.yarn/patches | ||
!.yarn/plugins | ||
!.yarn/releases | ||
!.yarn/sdks | ||
!.yarn/versions |
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,5 @@ | ||
{ | ||
"extension": ["ts"], | ||
"spec": "test/node/**/*.test.ts", | ||
"require": "ts-node/register" | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
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,3 @@ | ||
yarnPath: .yarn/releases/yarn-3.5.1.cjs | ||
|
||
nodeLinker: node-modules |
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
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
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
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
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
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,24 @@ | ||
import { expect } from "@esm-bundle/chai"; | ||
import initACVM, { abiEncode, abiDecode, WitnessMap } from "../../../../result/"; | ||
import { DecodedInputs } from "../types"; | ||
|
||
beforeEach(async () => { | ||
await initACVM(); | ||
}); | ||
|
||
it("recovers original inputs when abi encoding and decoding", async () => { | ||
const { abi, inputs } = await import("../shared/abi_encode"); | ||
|
||
const initial_witness: WitnessMap = abiEncode(abi, inputs, null); | ||
const decoded_inputs: DecodedInputs = abiDecode(abi, initial_witness); | ||
|
||
|
||
expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); | ||
expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( | ||
BigInt(inputs.bar[0]) | ||
); | ||
expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( | ||
BigInt(inputs.bar[1]) | ||
); | ||
expect(decoded_inputs.return_value).to.be.null; | ||
}); |
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,19 @@ | ||
import { expect } from "chai"; | ||
import { abiEncode, abiDecode, WitnessMap } from "../../../../result/"; | ||
import { DecodedInputs } from "../types"; | ||
|
||
it("recovers original inputs when abi encoding and decoding", async () => { | ||
const { abi, inputs } = await import("../shared/abi_encode"); | ||
|
||
const initial_witness: WitnessMap = abiEncode(abi, inputs, null); | ||
const decoded_inputs: DecodedInputs = abiDecode(abi, initial_witness); | ||
|
||
expect(BigInt(decoded_inputs.inputs.foo)).to.be.equal(BigInt(inputs.foo)); | ||
expect(BigInt(decoded_inputs.inputs.bar[0])).to.be.equal( | ||
BigInt(inputs.bar[0]) | ||
); | ||
expect(BigInt(decoded_inputs.inputs.bar[1])).to.be.equal( | ||
BigInt(inputs.bar[1]) | ||
); | ||
expect(decoded_inputs.return_value).to.be.null; | ||
}); |
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,20 @@ | ||
// TODO: Add type definitions for these | ||
|
||
export const abi = { | ||
parameters: [ | ||
{ name: "foo", type: { kind: "field" }, visibility: "private" }, | ||
{ | ||
name: "bar", | ||
type: { kind: "array", length: 2, type: { kind: "field" } }, | ||
visibility: "private", | ||
}, | ||
], | ||
param_witnesses: { foo: [1], bar: [2, 3] }, | ||
return_type: null, | ||
return_witnesses: [], | ||
}; | ||
|
||
export const inputs = { | ||
foo: "1", | ||
bar: ["1", "2"], | ||
}; |
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,2 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
export type DecodedInputs = { inputs: Record<string, any>; return_value: any }; |
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,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"outDir": "lib", | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"strict": true, | ||
"experimentalDecorators": true, | ||
"esModuleInterop": true, | ||
"noImplicitAny": true, | ||
"removeComments": false, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
"resolveJsonModule": true, | ||
"importHelpers": true | ||
} | ||
} |
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,25 @@ | ||
import { esbuildPlugin } from "@web/dev-server-esbuild"; | ||
import { playwrightLauncher } from "@web/test-runner-playwright"; | ||
|
||
export default { | ||
browsers: [ | ||
playwrightLauncher({ product: "chromium" }), | ||
playwrightLauncher({ product: "webkit" }), | ||
// Firefox requires 40s to perform a Pedersen hash so we recommend using either | ||
// a Chromium- or Webkit-based browser | ||
// playwrightLauncher({ product: "firefox" }), | ||
], | ||
plugins: [ | ||
esbuildPlugin({ | ||
ts: true, | ||
}), | ||
], | ||
files: ["test/browser/**/*.test.ts"], | ||
nodeResolve: true, | ||
testFramework: { | ||
config: { | ||
ui: "bdd", | ||
timeout: 40000, | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.