Skip to content

Commit

Permalink
feat: devnet docker compose (#6761)
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
alexghr authored May 30, 2024
1 parent 2d69253 commit c62dfee
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 22 deletions.
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions yarn-project/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand All @@ -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"]
8 changes: 6 additions & 2 deletions yarn-project/aztec/Dockerfile
Original file line number Diff line number Diff line change
@@ -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=""
ARG COMMIT_TAG=""
23 changes: 3 additions & 20 deletions yarn-project/cli/src/client.ts
Original file line number Diff line number Diff line change
@@ -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<PXE> {
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. */
Expand Down

0 comments on commit c62dfee

Please sign in to comment.