From c62dfeecfb81a0eb82794c31ff6aa30f0366d5c9 Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Thu, 30 May 2024 13:58:02 +0100 Subject: [PATCH] feat: devnet docker compose (#6761) Adds a docker compose running a PXE against a node ``` $ export AZTEC_NODE_URL=... $ docker compose up -d # starts the pxe in the background $ docker compose run cli create-account ``` --- docker-compose.yml | 35 ++++++++++++++++++++++++++++++++++ yarn-project/Dockerfile | 12 ++++++++++++ yarn-project/aztec/Dockerfile | 8 ++++++-- yarn-project/cli/src/client.ts | 23 +++------------------- 4 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000000..ecde918d46d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +name: aztec-devnet +services: + pxe: + image: aztecprotocol/aztec:${AZTEC_DOCKER_TAG:-latest} + environment: + LOG_LEVEL: info + DEBUG: aztec:* + DEBUG_COLORS: 1 + CHAIN_ID: 31337 + VERSION: 1 + PXE_PROVER_ENABLED: ${PXE_PROVER_ENABLED:-1} + NODE_NO_WARNINGS: 1 + entrypoint: + [ + "/bin/sh", + "-c", + "export AZTEC_NODE_URL=$$(cat /var/run/secrets/aztec-node-url); node /usr/src/yarn-project/aztec/dest/bin/index.js start --pxe", + ] + secrets: + - aztec-node-url + extra_hosts: + - "host.docker.internal:host-gateway" + cli: + image: aztecprotocol/aztec:${AZTEC_DOCKER_TAG:-latest} + environment: + PXE_URL: http://pxe:8080 + NODE_NO_WARNINGS: 1 + PRIVATE_KEY: + entrypoint: ["node", "/usr/src/yarn-project/cli/dest/bin/index.js"] + profiles: + - cli + +secrets: + aztec-node-url: + environment: AZTEC_NODE_URL diff --git a/yarn-project/Dockerfile b/yarn-project/Dockerfile index b8b94d6ab22..da3f0a09b88 100644 --- a/yarn-project/Dockerfile +++ b/yarn-project/Dockerfile @@ -32,6 +32,16 @@ RUN ln -s /usr/src/yarn-project/node_modules /usr/src/node_modules ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true RUN ./bootstrap.sh + +ENV BB_BINARY_PATH=/usr/src/barretenberg/cpp/build/bin/bb +ENV BB_WORKING_DIRECTORY=/usr/src/yarn-project/bb +ENV ACVM_BINARY_PATH=/usr/src/noir/noir-repo/target/release/acvm +ENV ACVM_WORKING_DIRECTORY=/usr/src/yarn-project/acvm + +RUN mkdir -p $BB_WORKING_DIRECTORY $ACVM_WORKING_DIRECTORY && \ + echo -n RootRollupArtifact PrivateKernelTailArtifact PrivateKernelTailToPublicArtifact | xargs -d ' ' -P 3 -I {} node bb-prover/dest/bb/index.js write-vk -c {} && \ + node bb-prover/dest/bb/index.js write-contract -c RootRollupArtifact -n UltraVerifier.sol + RUN yarn workspaces focus @aztec/aztec @aztec/builder @aztec/cli --production && yarn cache clean # TODO: Use release-please to update package.json directly, and remove this! @@ -48,4 +58,6 @@ ARG COMMIT_TAG="" ENV COMMIT_TAG=$COMMIT_TAG COPY --from=builder /usr/src /usr/src WORKDIR /usr/src/yarn-project +# add curl to be able to download CRS file +RUN apt update && apt install -y curl ENTRYPOINT ["yarn"] diff --git a/yarn-project/aztec/Dockerfile b/yarn-project/aztec/Dockerfile index a78851eab10..0eaaaac2040 100644 --- a/yarn-project/aztec/Dockerfile +++ b/yarn-project/aztec/Dockerfile @@ -1,9 +1,13 @@ FROM aztecprotocol/yarn-project AS yarn-project # ENV vars for using native ACVM simulation -ENV ACVM_BINARY_PATH="/usr/src/noir/noir-repo/target/release/acvm" ACVM_WORKING_DIRECTORY="/tmp/acvm" +ENV BB_BINARY_PATH=/usr/src/barretenberg/cpp/build/bin/bb +ENV BB_WORKING_DIRECTORY=/usr/src/yarn-project/bb +ENV ACVM_BINARY_PATH=/usr/src/noir/noir-repo/target/release/acvm +ENV ACVM_WORKING_DIRECTORY=/usr/src/yarn-project/acvm +RUN mkdir -p $BB_WORKING_DIRECTORY $ACVM_WORKING_DIRECTORY ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/aztec/dest/bin/index.js"] EXPOSE 8080 # The version has been updated in yarn-project. # Adding COMMIT_TAG here to rebuild versioned image. -ARG COMMIT_TAG="" \ No newline at end of file +ARG COMMIT_TAG="" diff --git a/yarn-project/cli/src/client.ts b/yarn-project/cli/src/client.ts index 8b3d55c37d9..ed4e1d24459 100644 --- a/yarn-project/cli/src/client.ts +++ b/yarn-project/cli/src/client.ts @@ -1,35 +1,18 @@ import { type PXE, createPXEClient } from '@aztec/aztec.js'; import { type DebugLogger } from '@aztec/foundation/log'; -import { fileURLToPath } from '@aztec/foundation/url'; -import { readFileSync } from 'fs'; -import { dirname, resolve } from 'path'; import { gtr, ltr, satisfies, valid } from 'semver'; /** * Creates a PXE client with a given set of retries on non-server errors. * Checks that PXE matches the expected version, and warns if not. * @param rpcUrl - URL of the RPC server wrapping the PXE. - * @param logger - Debug logger to warn version incompatibilities. + * @param _logger - Debug logger to warn version incompatibilities. * @returns A PXE client. */ -export async function createCompatibleClient(rpcUrl: string, logger: DebugLogger) { +export function createCompatibleClient(rpcUrl: string, _logger: DebugLogger): Promise { const pxe = createPXEClient(rpcUrl); - const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../package.json'); - const packageJsonContents = JSON.parse(readFileSync(packageJsonPath).toString()); - const expectedVersionRange = packageJsonContents.version; - - try { - await checkServerVersion(pxe, expectedVersionRange); - } catch (err) { - if (err instanceof VersionMismatchError) { - logger.warn(err.message); - } else { - throw err; - } - } - - return pxe; + return Promise.resolve(pxe); } /** Mismatch between server and client versions. */