From 26a37a3542d613ae799060174af70aa8bffd5679 Mon Sep 17 00:00:00 2001 From: spalladino Date: Tue, 28 Mar 2023 21:06:38 +0000 Subject: [PATCH 1/7] Try run circuits.js tests on CI --- .circleci/config.yml | 14 ++++++++++++++ build_manifest.json | 7 +++++++ yarn-project/circuits.js/Dockerfile | 13 +++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 yarn-project/circuits.js/Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index de09cb162f08..804bab1ac38c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -125,6 +125,18 @@ jobs: name: "Build and test" command: build world-state + circuits-js: + machine: + image: ubuntu-2004:202010-01 + resource_class: large + steps: + - *checkout + - *setup_env + - run: + name: "Build and test" + command: build circuits.js + + end-to-end: machine: image: ubuntu-2004:202010-01 @@ -184,6 +196,7 @@ workflows: - aztec-js: *yarn_project - end-to-end: *yarn_project - foundation: *yarn_project + - circuits-js: *yarn_project - e2e-join: requires: - ethereum-js @@ -191,6 +204,7 @@ workflows: - end-to-end - noir-contracts - foundation + - circuits-js <<: *defaults - e2e-deploy-contract: *e2e_test - world-state: *yarn_project diff --git a/build_manifest.json b/build_manifest.json index e0fb9579ac2d..87ff6a37bf85 100644 --- a/build_manifest.json +++ b/build_manifest.json @@ -73,6 +73,13 @@ "rebuildPatterns": ["^yarn-project/aztec.js/"], "dependencies": ["aztec-rpc"] }, + "circuits.js": { + "buildDir": "yarn-project", + "projectDir": "yarn-project/circuits.js", + "dockerfile": "circuits.js/Dockerfile", + "rebuildPatterns": ["^yarn-project/circuits.js/"], + "dependencies": ["aztec-rpc"] + }, "end-to-end": { "buildDir": "yarn-project", "projectDir": "yarn-project/end-to-end", diff --git a/yarn-project/circuits.js/Dockerfile b/yarn-project/circuits.js/Dockerfile new file mode 100644 index 000000000000..df448782ad62 --- /dev/null +++ b/yarn-project/circuits.js/Dockerfile @@ -0,0 +1,13 @@ +FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder + +COPY circuits.js circuits.js +COPY foundation foundation +WORKDIR /usr/src/yarn-project/circuits.js +RUN yarn build && yarn formatting && yarn test + +# Prune dev dependencies. See comment in base image. +RUN yarn cache clean +RUN yarn workspaces focus --production > /dev/null + +FROM alpine:latest +COPY --from=builder /usr/src/yarn-project/circuits.js /usr/src/yarn-project/circuits.js From 616bec45a7c42043134e4499e310944162ad69c2 Mon Sep 17 00:00:00 2001 From: spalladino Date: Thu, 30 Mar 2023 08:33:58 +0000 Subject: [PATCH 2/7] Add wasm to circuits dockerfile --- yarn-project/circuits.js/Dockerfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/yarn-project/circuits.js/Dockerfile b/yarn-project/circuits.js/Dockerfile index df448782ad62..c1b1d249652a 100644 --- a/yarn-project/circuits.js/Dockerfile +++ b/yarn-project/circuits.js/Dockerfile @@ -1,7 +1,13 @@ FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder -COPY circuits.js circuits.js COPY foundation foundation +COPY circuits.js circuits.js + +WORKDIR /usr/src/yarn-project/foundation +RUN yarn build + +RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm dest/wasm/barretenberg.wasm + WORKDIR /usr/src/yarn-project/circuits.js RUN yarn build && yarn formatting && yarn test @@ -11,3 +17,5 @@ RUN yarn workspaces focus --production > /dev/null FROM alpine:latest COPY --from=builder /usr/src/yarn-project/circuits.js /usr/src/yarn-project/circuits.js +WORKDIR /usr/src/yarn-project/merkle-tree +ENTRYPOINT ["yarn", "test"] \ No newline at end of file From 2ebc022442b138d84ad860f7aa337e20ce3786c4 Mon Sep 17 00:00:00 2001 From: spalladino Date: Thu, 30 Mar 2023 08:38:54 +0000 Subject: [PATCH 3/7] Formatting --- .../circuits.js/src/structs/merge_rollup.ts | 3 +-- yarn-project/circuits.js/src/tests/factories.ts | 16 +++++++++++----- yarn-project/circuits.js/src/utils/serialize.ts | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/yarn-project/circuits.js/src/structs/merge_rollup.ts b/yarn-project/circuits.js/src/structs/merge_rollup.ts index 405e7b5cca33..fd562badb894 100644 --- a/yarn-project/circuits.js/src/structs/merge_rollup.ts +++ b/yarn-project/circuits.js/src/structs/merge_rollup.ts @@ -16,8 +16,7 @@ export class PreviousRollupData { */ public vkIndex: UInt32, public vkSiblingPath: MembershipWitness, - ) { - } + ) {} toBuffer() { return serializeToBuffer(this.publicInputs, this.proof, this.vk, this.vkIndex, this.vkSiblingPath); diff --git a/yarn-project/circuits.js/src/tests/factories.ts b/yarn-project/circuits.js/src/tests/factories.ts index 7ca3e5698d34..f00c6c580afc 100644 --- a/yarn-project/circuits.js/src/tests/factories.ts +++ b/yarn-project/circuits.js/src/tests/factories.ts @@ -1,5 +1,11 @@ import { AztecAddress, EthAddress, Fq, Fr } from '@aztec/foundation'; -import { CallContext, PreviousRollupData, PrivateCircuitPublicInputs, RootRollupInputs, RootRollupPublicInputs } from '../index.js'; +import { + CallContext, + PreviousRollupData, + PrivateCircuitPublicInputs, + RootRollupInputs, + RootRollupPublicInputs, +} from '../index.js'; import { AppendOnlyTreeSnapshot, BaseRollupPublicInputs, ConstantBaseRollupData } from '../structs/base_rollup.js'; import { ARGS_LENGTH, @@ -22,7 +28,7 @@ import { PUBLIC_CALL_STACK_LENGTH, RETURN_VALUES_LENGTH, ROLLUP_VK_TREE_HEIGHT, - VK_TREE_HEIGHT + VK_TREE_HEIGHT, } from '../structs/constants.js'; import { FunctionData } from '../structs/function_data.js'; import { @@ -34,7 +40,7 @@ import { PreviousKernelData, PrivateCallData, PrivateKernelInputs, - PrivateKernelPublicInputs + PrivateKernelPublicInputs, } from '../structs/kernel.js'; import { PrivateCallStackItem } from '../structs/private_call_stack_item.js'; import { @@ -43,7 +49,7 @@ import { ComposerType, EcdsaSignature, MembershipWitness, - UInt8Vector + UInt8Vector, } from '../structs/shared.js'; import { ContractDeploymentData, SignedTxRequest, TxContext, TxRequest } from '../structs/tx.js'; import { CommitmentMap, G1AffineElement, VerificationKey } from '../structs/verification_key.js'; @@ -260,7 +266,7 @@ export function makePreviousBaseRollupData(seed = 0) { makeVerificationKey(), seed + 0x110, makeMembershipWitness(ROLLUP_VK_TREE_HEIGHT, seed + 0x120), - ) + ); } export function makeRootRollupInputs(seed = 0) { diff --git a/yarn-project/circuits.js/src/utils/serialize.ts b/yarn-project/circuits.js/src/utils/serialize.ts index 834f8c643955..527a45cfbaa0 100644 --- a/yarn-project/circuits.js/src/utils/serialize.ts +++ b/yarn-project/circuits.js/src/utils/serialize.ts @@ -119,7 +119,7 @@ export type Bufferable = } | Bufferable[]; -function isSerializableToBuffer32(obj: Object): obj is { toBuffer32: () => Buffer } { +function isSerializableToBuffer32(obj: object): obj is { toBuffer32: () => Buffer } { return !!(obj as { toBuffer32: () => Buffer }).toBuffer32; } From 9c5523ece467b4577da73dc83a9912353fff6c61 Mon Sep 17 00:00:00 2001 From: spalladino Date: Thu, 30 Mar 2023 08:45:17 +0000 Subject: [PATCH 4/7] Fix dest name of circuits wasm in dockerfile --- yarn-project/circuits.js/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/circuits.js/Dockerfile b/yarn-project/circuits.js/Dockerfile index c1b1d249652a..37085737aa6a 100644 --- a/yarn-project/circuits.js/Dockerfile +++ b/yarn-project/circuits.js/Dockerfile @@ -6,7 +6,7 @@ COPY circuits.js circuits.js WORKDIR /usr/src/yarn-project/foundation RUN yarn build -RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm dest/wasm/barretenberg.wasm +RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm dest/wasm/aztec3-circuits.wasm WORKDIR /usr/src/yarn-project/circuits.js RUN yarn build && yarn formatting && yarn test From 36853b1beacb0812c499ec261f776ab65b71149f Mon Sep 17 00:00:00 2001 From: spalladino Date: Thu, 30 Mar 2023 08:54:33 +0000 Subject: [PATCH 5/7] Get the wasm to circuits at any cost --- yarn-project/circuits.js/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/yarn-project/circuits.js/Dockerfile b/yarn-project/circuits.js/Dockerfile index 37085737aa6a..3e24acb710b4 100644 --- a/yarn-project/circuits.js/Dockerfile +++ b/yarn-project/circuits.js/Dockerfile @@ -6,7 +6,11 @@ COPY circuits.js circuits.js WORKDIR /usr/src/yarn-project/foundation RUN yarn build +# TODO: It seems we're loading the wasm from dest and from src, depending on how we run, +# so we copy the wasm to both locations just in case, but we should set up a proper pipeline +# and location for the wasm. RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm dest/wasm/aztec3-circuits.wasm +RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm src/wasm/aztec3-circuits.wasm WORKDIR /usr/src/yarn-project/circuits.js RUN yarn build && yarn formatting && yarn test From 189a3c37efab0640d6a9d846b960a451181a4d84 Mon Sep 17 00:00:00 2001 From: spalladino Date: Thu, 30 Mar 2023 09:22:46 +0000 Subject: [PATCH 6/7] Another shot at the dockerfile for circuits.js --- yarn-project/circuits.js/Dockerfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/yarn-project/circuits.js/Dockerfile b/yarn-project/circuits.js/Dockerfile index 3e24acb710b4..1f7c5b4c5d34 100644 --- a/yarn-project/circuits.js/Dockerfile +++ b/yarn-project/circuits.js/Dockerfile @@ -6,13 +6,8 @@ COPY circuits.js circuits.js WORKDIR /usr/src/yarn-project/foundation RUN yarn build -# TODO: It seems we're loading the wasm from dest and from src, depending on how we run, -# so we copy the wasm to both locations just in case, but we should set up a proper pipeline -# and location for the wasm. -RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm dest/wasm/aztec3-circuits.wasm -RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm src/wasm/aztec3-circuits.wasm - WORKDIR /usr/src/yarn-project/circuits.js +RUN cp /usr/src/aztec3-circuits/cpp/build-wasm/bin/aztec3-circuits.wasm src/wasm/aztec3-circuits.wasm RUN yarn build && yarn formatting && yarn test # Prune dev dependencies. See comment in base image. From cc7f4e05127109a04b7e5dccb9bc56cebad24b32 Mon Sep 17 00:00:00 2001 From: spalladino Date: Thu, 30 Mar 2023 09:35:45 +0000 Subject: [PATCH 7/7] Try to avoid timeout in tests on CI --- yarn-project/circuits.js/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/circuits.js/package.json b/yarn-project/circuits.js/package.json index 806b14990498..a2f1a6216b1d 100644 --- a/yarn-project/circuits.js/package.json +++ b/yarn-project/circuits.js/package.json @@ -18,7 +18,7 @@ "clean": "rm -rf ./dest .tsbuildinfo", "formatting": "prettier --check ./src && eslint --max-warnings 278 ./src", "formatting:fix": "prettier -w ./src", - "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --passWithNoTests", + "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --passWithNoTests --maxWorkers=2", "test-debug": "NODE_NO_WARNINGS=1 node --inspect-brk --experimental-vm-modules $(yarn bin jest) --no-cache --passWithNoTests --runInBand" }, "jest": {