From f1ac5b1206a084c06352e3c95404e99a9279d55d Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 25 Sep 2023 08:27:22 +0000 Subject: [PATCH 01/24] WIP --- yarn-project/aztec-sandbox/src/bin/index.ts | 10 +++++++--- yarn-project/aztec-sandbox/src/routes.ts | 7 +++---- yarn-project/aztec-sandbox/src/server.ts | 22 ++++++++++----------- yarn-project/end-to-end/src/e2e_cli.test.ts | 4 ++-- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index 8f906cf874d..65cfd4b1cc3 100644 --- a/yarn-project/aztec-sandbox/src/bin/index.ts +++ b/yarn-project/aztec-sandbox/src/bin/index.ts @@ -1,4 +1,6 @@ #!/usr/bin/env -S node --no-warnings +import { createAztecNodeRpcServer } from '@aztec/aztec-node'; +import { getHttpRpcServer } from '@aztec/aztec-rpc'; import { deployInitialSandboxAccounts } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; @@ -12,7 +14,7 @@ import { createSandbox } from '../sandbox.js'; import { startHttpRpcServer } from '../server.js'; import { github, splash } from '../splash.js'; -const { SERVER_PORT = 8080 } = process.env; +const { NODE_PORT = 8079, SERVER_PORT = 8080 } = process.env; const logger = createDebugLogger('aztec:sandbox'); @@ -26,7 +28,7 @@ async function main() { logger.info(`Setting up Aztec Sandbox v${version} (nargo ${NoirVersion.tag}), please stand by...`); - const { l1Contracts, rpcServer, stop } = await createSandbox(); + const { node, rpcServer, l1Contracts, stop } = await createSandbox(); logger.info('Setting up test accounts...'); const accounts = await deployInitialSandboxAccounts(rpcServer); @@ -40,7 +42,9 @@ async function main() { process.once('SIGINT', shutdown); process.once('SIGTERM', shutdown); - startHttpRpcServer(rpcServer, l1Contracts, SERVER_PORT); + startHttpRpcServer(node, createAztecNodeRpcServer, l1Contracts, 8079); + logger.info(`Aztec Node JSON-RPC Server listening on port ${NODE_PORT}`); + startHttpRpcServer(rpcServer, getHttpRpcServer, l1Contracts, SERVER_PORT); logger.info(`Aztec Sandbox JSON-RPC Server listening on port ${SERVER_PORT}`); logger.info(`Debug logs will be written to ${logPath}`); const accountStrings = [`Initial Accounts:\n\n`]; diff --git a/yarn-project/aztec-sandbox/src/routes.ts b/yarn-project/aztec-sandbox/src/routes.ts index 43967f3bd82..205bab8d3ab 100644 --- a/yarn-project/aztec-sandbox/src/routes.ts +++ b/yarn-project/aztec-sandbox/src/routes.ts @@ -4,11 +4,10 @@ import Koa from 'koa'; import Router from 'koa-router'; /** - * Creates a router for helper API endpoints of the Aztec RPC Server. - * @param aztecNode - An instance of the aztec node. - * @param config - The aztec node's configuration variables. + * Creates a router for helper API endpoints. + * @param l1Contracts - Object containing L1 contract addresses. */ -export function createApiRouter(l1Contracts: DeployL1Contracts) { +export function createHelperRouter(l1Contracts: DeployL1Contracts) { const router = new Router({ prefix: '/api' }); router.get('/status', (ctx: Koa.Context) => { // TODO: add `status` to Aztec node. diff --git a/yarn-project/aztec-sandbox/src/server.ts b/yarn-project/aztec-sandbox/src/server.ts index e749c4cc79c..a54788d78ec 100644 --- a/yarn-project/aztec-sandbox/src/server.ts +++ b/yarn-project/aztec-sandbox/src/server.ts @@ -1,29 +1,29 @@ -import { getHttpRpcServer } from '@aztec/aztec-rpc'; import { DeployL1Contracts } from '@aztec/ethereum'; -import { AztecRPC } from '@aztec/types'; +import { JsonRpcServer } from '@aztec/foundation/json-rpc/server'; import http from 'http'; -import { createApiRouter } from './routes.js'; +import { createHelperRouter } from './routes.js'; /** - * Creates an http server that forwards calls to the rpc server and starts it on the given port. - * @param aztecRpcServer - RPC server that answers queries to the created HTTP server. + * Creates an http server that forwards calls to the underlying instance and starts it on the given port. + * @param instance - RPC server that answers queries to the created HTTP server. * @param deployedL1Contracts - Info on L1 deployed contracts. * @param port - Port to listen in. * @returns A running http server. */ -export function startHttpRpcServer( - aztecRpcServer: AztecRPC, +export function startHttpRpcServer( + instance: T, + jsonRpcFactoryFunc: (instance: T) => JsonRpcServer, deployedL1Contracts: DeployL1Contracts, port: string | number, ): http.Server { - const rpcServer = getHttpRpcServer(aztecRpcServer); + const rpcServer = jsonRpcFactoryFunc(instance); const app = rpcServer.getApp(); - const apiRouter = createApiRouter(deployedL1Contracts); - app.use(apiRouter.routes()); - app.use(apiRouter.allowedMethods()); + const helperRouter = createHelperRouter(deployedL1Contracts); + app.use(helperRouter.routes()); + app.use(helperRouter.allowedMethods()); const httpServer = http.createServer(app.callback()); httpServer.listen(port); diff --git a/yarn-project/end-to-end/src/e2e_cli.test.ts b/yarn-project/end-to-end/src/e2e_cli.test.ts index 112748fe75b..9f3ba081ba5 100644 --- a/yarn-project/end-to-end/src/e2e_cli.test.ts +++ b/yarn-project/end-to-end/src/e2e_cli.test.ts @@ -1,5 +1,5 @@ import { AztecNodeService } from '@aztec/aztec-node'; -import { AztecRPCServer } from '@aztec/aztec-rpc'; +import { AztecRPCServer, getHttpRpcServer } from '@aztec/aztec-rpc'; import { startHttpRpcServer } from '@aztec/aztec-sandbox'; import { AztecRPC, createDebugLogger } from '@aztec/aztec.js'; @@ -19,7 +19,7 @@ const testSetup = async () => { debug(`Environment set up`); const { deployL1ContractsValues } = context; ({ aztecNode, aztecRpcServer } = context); - http = startHttpRpcServer(aztecRpcServer, deployL1ContractsValues, HTTP_PORT); + http = startHttpRpcServer(aztecRpcServer, getHttpRpcServer, deployL1ContractsValues, HTTP_PORT); debug(`HTTP RPC server started in port ${HTTP_PORT}`); return aztecRpcServer; }; From 4d5ffa378bc6206db95f7ff906ac7c555dcba511 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 25 Sep 2023 11:44:27 +0000 Subject: [PATCH 02/24] docs fix --- yarn-project/aztec-sandbox/src/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/aztec-sandbox/src/server.ts b/yarn-project/aztec-sandbox/src/server.ts index a54788d78ec..b0576aa0edf 100644 --- a/yarn-project/aztec-sandbox/src/server.ts +++ b/yarn-project/aztec-sandbox/src/server.ts @@ -7,7 +7,7 @@ import { createHelperRouter } from './routes.js'; /** * Creates an http server that forwards calls to the underlying instance and starts it on the given port. - * @param instance - RPC server that answers queries to the created HTTP server. + * @param instance - Instance to wrap in a JSON-RPC server. * @param deployedL1Contracts - Info on L1 deployed contracts. * @param port - Port to listen in. * @returns A running http server. From 96d2c0baba7fa5046b3bd8a7c15ddb94d6ab304c Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 2 Oct 2023 07:37:23 +0000 Subject: [PATCH 03/24] fixes after merge --- yarn-project/aztec-sandbox/src/bin/index.ts | 4 ++-- yarn-project/canary/package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index b3ababf43bd..58b4285a466 100644 --- a/yarn-project/aztec-sandbox/src/bin/index.ts +++ b/yarn-project/aztec-sandbox/src/bin/index.ts @@ -4,15 +4,15 @@ import { deployInitialSandboxAccounts } from '@aztec/aztec.js'; import { createDebugLogger } from '@aztec/foundation/log'; import { fileURLToPath } from '@aztec/foundation/url'; import NoirVersion from '@aztec/noir-compiler/noir-version'; -import {createPXERpcServer} from '@aztec/pxe'; +import { createPXERpcServer } from '@aztec/pxe'; import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; import { setupFileDebugLog } from '../logging.js'; import { createSandbox } from '../sandbox.js'; -import { github, splash } from '../splash.js'; import { startHttpRpcServer } from '../server.js'; +import { github, splash } from '../splash.js'; const { NODE_PORT = 8079, SERVER_PORT = 8080 } = process.env; diff --git a/yarn-project/canary/package.json b/yarn-project/canary/package.json index 138d9b5b098..d621c6008e8 100644 --- a/yarn-project/canary/package.json +++ b/yarn-project/canary/package.json @@ -21,8 +21,8 @@ "rootDir": "./src" }, "dependencies": { - "@aztec/circuits.js": "workspace:^", "@aztec/aztec.js": "workspace:^", + "@aztec/circuits.js": "workspace:^", "@aztec/cli": "workspace:^", "@aztec/end-to-end": "workspace:^", "@aztec/l1-artifacts": "workspace:^", From 0c41bf9034183266733d968012c019577d556be0 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 2 Oct 2023 08:24:48 +0000 Subject: [PATCH 04/24] renaming env vars --- yarn-project/aztec-node/src/bin/index.ts | 6 +++--- yarn-project/aztec-node/terraform/main.tf | 2 +- yarn-project/aztec-sandbox/src/bin/index.ts | 8 ++++---- yarn-project/pxe/src/bin/index.ts | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/yarn-project/aztec-node/src/bin/index.ts b/yarn-project/aztec-node/src/bin/index.ts index 41ec5382c82..fee7f7808dc 100644 --- a/yarn-project/aztec-node/src/bin/index.ts +++ b/yarn-project/aztec-node/src/bin/index.ts @@ -7,7 +7,7 @@ import Router from 'koa-router'; import { AztecNodeConfig, AztecNodeService, createAztecNodeRpcServer, getConfigEnvVars } from '../index.js'; -const { SERVER_PORT = 8081, API_PREFIX = '' } = process.env; +const { AZTEC_NODE_PORT = 8081, API_PREFIX = '' } = process.env; const logger = createDebugLogger('aztec:node'); @@ -57,8 +57,8 @@ async function main() { app.use(apiRouter.allowedMethods()); const httpServer = http.createServer(app.callback()); - httpServer.listen(+SERVER_PORT); - logger.info(`Aztec Node JSON-RPC Server listening on port ${SERVER_PORT}`); + httpServer.listen(+AZTEC_NODE_PORT); + logger.info(`Aztec Node JSON-RPC Server listening on port ${AZTEC_NODE_PORT}`); } main().catch(err => { diff --git a/yarn-project/aztec-node/terraform/main.tf b/yarn-project/aztec-node/terraform/main.tf index c2518571d3b..38fff0a2d9e 100644 --- a/yarn-project/aztec-node/terraform/main.tf +++ b/yarn-project/aztec-node/terraform/main.tf @@ -98,7 +98,7 @@ resource "aws_ecs_task_definition" "aztec-node-1" { "value": "production" }, { - "name": "SERVER_PORT", + "name": "AZTEC_NODE_PORT", "value": "80" }, { diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index 58b4285a466..e6013daf1de 100644 --- a/yarn-project/aztec-sandbox/src/bin/index.ts +++ b/yarn-project/aztec-sandbox/src/bin/index.ts @@ -14,7 +14,7 @@ import { createSandbox } from '../sandbox.js'; import { startHttpRpcServer } from '../server.js'; import { github, splash } from '../splash.js'; -const { NODE_PORT = 8079, SERVER_PORT = 8080 } = process.env; +const { AZTEC_NODE_PORT = 8079, PXE_PORT = 8080 } = process.env; const logger = createDebugLogger('aztec:sandbox'); @@ -56,9 +56,9 @@ async function main() { process.once('SIGTERM', shutdown); startHttpRpcServer(node, createAztecNodeRpcServer, 8079); - logger.info(`Aztec Node JSON-RPC Server listening on port ${NODE_PORT}`); - startHttpRpcServer(pxe, createPXERpcServer, SERVER_PORT); - logger.info(`Aztec Sandbox JSON-RPC Server listening on port ${SERVER_PORT}`); + logger.info(`Aztec Node JSON-RPC Server listening on port ${AZTEC_NODE_PORT}`); + startHttpRpcServer(pxe, createPXERpcServer, PXE_PORT); + logger.info(`PXE JSON-RPC Server listening on port ${PXE_PORT}`); logger.info(`Debug logs will be written to ${logPath}`); const accountStrings = [`Initial Accounts:\n\n`]; diff --git a/yarn-project/pxe/src/bin/index.ts b/yarn-project/pxe/src/bin/index.ts index 2cfb5794c51..a06d27a3f36 100644 --- a/yarn-project/pxe/src/bin/index.ts +++ b/yarn-project/pxe/src/bin/index.ts @@ -6,7 +6,7 @@ import { getPXEServiceConfig } from '../config/index.js'; import { startPXEHttpServer } from '../pxe_http/index.js'; import { createPXEService } from '../pxe_service/index.js'; -const { SERVER_PORT = 8080, AZTEC_NODE_RPC_URL = '' } = process.env; +const { PXE_PORT = 8081, AZTEC_NODE_RPC_URL = 'http://localhost:8079' } = process.env; const logger = createDebugLogger('aztec:pxe_service'); @@ -29,8 +29,8 @@ async function main() { process.once('SIGINT', shutdown); process.once('SIGTERM', shutdown); - startPXEHttpServer(pxeService, SERVER_PORT); - logger.info(`PXE listening on port ${SERVER_PORT}`); + startPXEHttpServer(pxeService, PXE_PORT); + logger.info(`PXE listening on port ${PXE_PORT}`); } main().catch(err => { From 3f42e5b222b3be346f5a0f8a30a2a72c46298be4 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 2 Oct 2023 08:36:26 +0000 Subject: [PATCH 05/24] updated sandbox configuration --- docs/docs/dev_docs/getting_started/sandbox.md | 6 +++++- l1-contracts/scripts/install_foundry.sh | 2 +- yarn-project/aztec-sandbox/docker-compose.yml | 3 ++- yarn-project/boxes/blank-react/docker-compose.yml | 3 ++- yarn-project/boxes/blank/docker-compose.yml | 3 ++- yarn-project/boxes/private-token/docker-compose.yml | 3 ++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/docs/dev_docs/getting_started/sandbox.md b/docs/docs/dev_docs/getting_started/sandbox.md index 7c15428d9c0..3cc74267891 100644 --- a/docs/docs/dev_docs/getting_started/sandbox.md +++ b/docs/docs/dev_docs/getting_started/sandbox.md @@ -36,7 +36,11 @@ It will download and execute a script invoking docker compose with 2 containers: - Anvil - Aztec Sandbox -2 ports will need to be opened on your system in order for you to interact with the sandbox. The first port is for Anvil, it defaults to 8545 and can be overridden by specifying a value in the environment variable `SANDBOX_ANVIL_PORT`. The second is the sandbox RPC host port. It defaults to value 8080 but can be overridden with environment variable `SANDBOX_RPC_PORT`. +3 ports will need to be opened on your system in order for you to interact with the sandbox. +The first port is for Anvil, it defaults to 8545 and can be overridden by specifying a value in the environment variable `SANDBOX_ANVIL_PORT`. +The second one is sandbox Aztec Node port, it defaults to 8079 and can be overridden by specifying a value in the environment variable `SANDBOX_AZTEC_NODE_PORT`. +The third is the sandbox PXE port. +It defaults to value 8080 but can be overridden with environment variable `SANDBOX_PXE_PORT`. Within a few seconds the Sandbox should be up and running! diff --git a/l1-contracts/scripts/install_foundry.sh b/l1-contracts/scripts/install_foundry.sh index e669ab2a01f..e085beb76d5 100755 --- a/l1-contracts/scripts/install_foundry.sh +++ b/l1-contracts/scripts/install_foundry.sh @@ -18,4 +18,4 @@ chmod +x $BIN_PATH export PATH=$FOUNDRY_BIN_DIR:$PATH # Use version. -foundryup --version nightly-bdea91c79055e8adcf33e714984edba9a3e33d2a +foundryup diff --git a/yarn-project/aztec-sandbox/docker-compose.yml b/yarn-project/aztec-sandbox/docker-compose.yml index 935d0da224e..143c8f779ef 100644 --- a/yarn-project/aztec-sandbox/docker-compose.yml +++ b/yarn-project/aztec-sandbox/docker-compose.yml @@ -9,7 +9,8 @@ services: aztec: image: 'aztecprotocol/aztec-sandbox:${SANDBOX_VERSION:-latest}' ports: - - '${SANDBOX_RPC_PORT:-8080}:8080' + - '${SANDBOX_AZTEC_NODE_PORT:-8079}:8079' + - '${SANDBOX_PXE_PORT:-8080}:8080' environment: DEBUG: # Loaded from the user shell if explicitly set HOST_WORKDIR: '${PWD}' # Loaded from the user shell to show log files absolute path in host diff --git a/yarn-project/boxes/blank-react/docker-compose.yml b/yarn-project/boxes/blank-react/docker-compose.yml index 2417ca77775..328d0c8f366 100644 --- a/yarn-project/boxes/blank-react/docker-compose.yml +++ b/yarn-project/boxes/blank-react/docker-compose.yml @@ -9,7 +9,8 @@ services: aztec: image: 'aztecprotocol/aztec-sandbox:${SANDBOX_VERSION:-latest}' ports: - - '${SANDBOX_RPC_PORT:-8080}:8080' + - '${SANDBOX_AZTEC_NODE_PORT:-8079}:8079' + - '${SANDBOX_PXE_PORT:-8080}:8080' environment: DEBUG: # Loaded from the user shell if explicitly set HOST_WORKDIR: '${PWD}' # Loaded from the user shell to show log files absolute path in host diff --git a/yarn-project/boxes/blank/docker-compose.yml b/yarn-project/boxes/blank/docker-compose.yml index 923aed602d3..8ecb7ac09cc 100644 --- a/yarn-project/boxes/blank/docker-compose.yml +++ b/yarn-project/boxes/blank/docker-compose.yml @@ -9,7 +9,8 @@ services: aztec: image: 'aztecprotocol/aztec-sandbox:${SANDBOX_VERSION:-latest}' ports: - - '${SANDBOX_RPC_PORT:-8080}:8080' + - '${SANDBOX_AZTEC_NODE_PORT:-8079}:8079' + - '${SANDBOX_PXE_PORT:-8080}:8080' environment: DEBUG: # Loaded from the user shell if explicitly set HOST_WORKDIR: '${PWD}' # Loaded from the user shell to show log files absolute path in host diff --git a/yarn-project/boxes/private-token/docker-compose.yml b/yarn-project/boxes/private-token/docker-compose.yml index 997eed0992b..536fae2c3fd 100644 --- a/yarn-project/boxes/private-token/docker-compose.yml +++ b/yarn-project/boxes/private-token/docker-compose.yml @@ -9,7 +9,8 @@ services: aztec: image: 'aztecprotocol/aztec-sandbox:${SANDBOX_VERSION:-latest}' ports: - - '${SANDBOX_RPC_PORT:-8080}:8080' + - '${SANDBOX_AZTEC_NODE_PORT:-8079}:8079' + - '${SANDBOX_PXE_PORT:-8080}:8080' environment: DEBUG: # Loaded from the user shell if explicitly set HOST_WORKDIR: '${PWD}' # Loaded from the user shell to show log files absolute path in host From 7f1085d587f9b35d9e4fad01ee96bfab88ba42cb Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 2 Oct 2023 11:07:27 +0000 Subject: [PATCH 06/24] chore: exposing aztec node port in dockerfile --- yarn-project/aztec-sandbox/Dockerfile | 2 +- yarn-project/aztec-sandbox/Dockerfile.final | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/yarn-project/aztec-sandbox/Dockerfile b/yarn-project/aztec-sandbox/Dockerfile index 3f3a2e6cb3d..3b669677b80 100644 --- a/yarn-project/aztec-sandbox/Dockerfile +++ b/yarn-project/aztec-sandbox/Dockerfile @@ -22,4 +22,4 @@ COPY --from=builder /usr/src/ /usr/src/ WORKDIR /usr/src/yarn-project/aztec-sandbox ENTRYPOINT ["yarn"] CMD [ "start" ] -EXPOSE 8080 +EXPOSE 8079 8080 diff --git a/yarn-project/aztec-sandbox/Dockerfile.final b/yarn-project/aztec-sandbox/Dockerfile.final index a9cc84909f1..5ef50e268e4 100644 --- a/yarn-project/aztec-sandbox/Dockerfile.final +++ b/yarn-project/aztec-sandbox/Dockerfile.final @@ -7,4 +7,4 @@ WORKDIR /usr/src/yarn-project/aztec-sandbox ENTRYPOINT ["yarn"] CMD [ "start" ] -EXPOSE 8080 \ No newline at end of file +EXPOSE 8079 8080 \ No newline at end of file From 9dc15888600fe6065e2e1e8670700ea02a030054 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 2 Oct 2023 14:29:10 +0000 Subject: [PATCH 07/24] updated tests --- yarn-project/canary/tsconfig.json | 4 +- yarn-project/end-to-end/src/e2e_cli.test.ts | 10 ++--- .../end-to-end/src/e2e_multi_transfer.test.ts | 5 +-- .../e2e_multiple_accounts_1_enc_key.test.ts | 5 +-- .../src/e2e_non_contract_account.test.ts | 5 +-- .../e2e_pending_commitments_contract.test.ts | 5 +-- .../src/e2e_private_token_contract.test.ts | 5 +-- .../src/fixtures/cross_chain_test_harness.ts | 8 ++-- yarn-project/end-to-end/src/fixtures/utils.ts | 39 +++++++++---------- .../src/uniswap_trade_on_l1_from_l2.test.ts | 4 +- 10 files changed, 41 insertions(+), 49 deletions(-) diff --git a/yarn-project/canary/tsconfig.json b/yarn-project/canary/tsconfig.json index 837b3f136a5..d02659b19cd 100644 --- a/yarn-project/canary/tsconfig.json +++ b/yarn-project/canary/tsconfig.json @@ -20,10 +20,10 @@ }, "references": [ { - "path": "../circuits.js" + "path": "../aztec.js" }, { - "path": "../aztec.js" + "path": "../circuits.js" }, { "path": "../cli" diff --git a/yarn-project/end-to-end/src/e2e_cli.test.ts b/yarn-project/end-to-end/src/e2e_cli.test.ts index 21709f65a3a..1f24698ce1e 100644 --- a/yarn-project/end-to-end/src/e2e_cli.test.ts +++ b/yarn-project/end-to-end/src/e2e_cli.test.ts @@ -1,7 +1,6 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { startHttpRpcServer } from '@aztec/aztec-sandbox'; import { PXE, createDebugLogger } from '@aztec/aztec.js'; -import { PXEService, createPXERpcServer } from '@aztec/pxe'; +import { createPXERpcServer } from '@aztec/pxe'; import { cliTestSuite } from './canary/cli.js'; import { setup as e2eSetup } from './fixtures/utils.js'; @@ -11,13 +10,13 @@ const RPC_URL = `http://localhost:${HTTP_PORT}`; const debug = createDebugLogger('aztec:e2e_cli'); let http: ReturnType; -let aztecNode: AztecNodeService | undefined; let pxe: PXE; +let teardown: () => Promise; const testSetup = async () => { const context = await e2eSetup(2); debug(`Environment set up`); - ({ aztecNode, pxe } = context); + ({ pxe, teardown } = context); http = startHttpRpcServer(pxe, createPXERpcServer, HTTP_PORT); debug(`HTTP RPC server started in port ${HTTP_PORT}`); return pxe; @@ -25,8 +24,7 @@ const testSetup = async () => { const testCleanup = async () => { http.close(); - await aztecNode?.stop(); - await (pxe as PXEService).stop(); + await teardown(); }; cliTestSuite('E2E CLI Test', testSetup, testCleanup, createDebugLogger('aztec:e2e_cli'), RPC_URL); diff --git a/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts b/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts index 65c593fbfc0..81aa130aba0 100644 --- a/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts +++ b/yarn-project/end-to-end/src/e2e_multi_transfer.test.ts @@ -1,8 +1,7 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Contract, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { MultiTransferContract, PrivateTokenAirdropContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress } from '@aztec/types'; +import { AztecNode, CompleteAddress } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; @@ -14,7 +13,7 @@ import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/u describe('multi-transfer payments', () => { const numberOfAccounts = 12; - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let wallet: Wallet; let logger: DebugLogger; let teardown: () => Promise; diff --git a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts index 651552a7d2a..e463e48ea5a 100644 --- a/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts +++ b/yarn-project/end-to-end/src/e2e_multiple_accounts_1_enc_key.test.ts @@ -1,14 +1,13 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Wallet, computeMessageSecretHash, generatePublicKey, getSchnorrAccount } from '@aztec/aztec.js'; import { Fr, GrumpkinScalar } from '@aztec/circuits.js'; import { DebugLogger } from '@aztec/foundation/log'; import { TokenContract } from '@aztec/noir-contracts/types'; -import { PXE, TxStatus } from '@aztec/types'; +import { AztecNode, PXE, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_multiple_accounts_1_enc_key', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let pxe: PXE; const wallets: Wallet[] = []; const accounts: AztecAddress[] = []; diff --git a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts index 6f4da87a779..9a40f277243 100644 --- a/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts +++ b/yarn-project/end-to-end/src/e2e_non_contract_account.test.ts @@ -1,13 +1,12 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, SignerlessWallet, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PokeableTokenContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress, PXE, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, PXE, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_non_contract_account', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let pxe: PXE; let wallet: Wallet; let sender: AztecAddress; diff --git a/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts b/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts index 81070e19577..abe745c4688 100644 --- a/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_pending_commitments_contract.test.ts @@ -1,13 +1,12 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Fr, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PendingCommitmentsContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, TxStatus } from '@aztec/types'; import { setup } from './fixtures/utils.js'; describe('e2e_pending_commitments_contract', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let wallet: Wallet; let logger: DebugLogger; let owner: AztecAddress; diff --git a/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts b/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts index 3d13f15fa02..1cc13f97e78 100644 --- a/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_private_token_contract.test.ts @@ -1,13 +1,12 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, Wallet } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { PrivateTokenContract } from '@aztec/noir-contracts/types'; -import { CompleteAddress, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, TxStatus } from '@aztec/types'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup } from './fixtures/utils.js'; describe('e2e_private_token_contract', () => { - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let wallet: Wallet; let logger: DebugLogger; let owner: AztecAddress; diff --git a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts index 4eba012fa93..5d2f2c18a81 100644 --- a/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts +++ b/yarn-project/end-to-end/src/fixtures/cross_chain_test_harness.ts @@ -8,7 +8,7 @@ import { DebugLogger } from '@aztec/foundation/log'; import { OutboxAbi } from '@aztec/l1-artifacts'; import { TokenBridgeContract, TokenContract } from '@aztec/noir-contracts/types'; import { PXEService } from '@aztec/pxe'; -import { PXE, TxStatus } from '@aztec/types'; +import { AztecNode, PXE, TxStatus } from '@aztec/types'; import { Chain, HttpTransport, PublicClient, getContract } from 'viem'; @@ -20,7 +20,7 @@ import { deployAndInitializeTokenAndBridgeContracts } from './utils.js'; */ export class CrossChainTestHarness { static async new( - aztecNode: AztecNodeService | undefined, + aztecNode: AztecNode | undefined, pxeService: PXE, deployL1ContractsValues: DeployL1Contracts, accounts: CompleteAddress[], @@ -89,7 +89,7 @@ export class CrossChainTestHarness { } constructor( /** AztecNode. */ - public aztecNode: AztecNodeService | undefined, + public aztecNode: AztecNode | undefined, /** Private eXecution Environment (PXE). */ public pxeService: PXE, /** CheatCodes. */ @@ -338,7 +338,7 @@ export class CrossChainTestHarness { } async stop() { - await this.aztecNode?.stop(); + if (this.aztecNode instanceof AztecNodeService) await this.aztecNode?.stop(); if (this.pxeService instanceof PXEService) { await this.pxeService?.stop(); } diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 7b8e3c18e07..e371f36489a 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -8,7 +8,7 @@ import { EthCheatCodes, Wallet, createAccounts, - createPXEClient as createJsonRpcClient, + createPXEClient, getSandboxAccountsWallets, } from '@aztec/aztec.js'; import { CircuitsWasm, GeneratorIndex } from '@aztec/circuits.js'; @@ -42,7 +42,7 @@ import { } from '@aztec/l1-artifacts'; import { NonNativeTokenContract, TokenBridgeContract, TokenContract } from '@aztec/noir-contracts/types'; import { PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe'; -import { L2BlockL2Logs, LogType, PXE, TxStatus } from '@aztec/types'; +import { AztecNode, L2BlockL2Logs, LogType, PXE, TxStatus, createAztecNodeRpcClient } from '@aztec/types'; import { Account, @@ -76,10 +76,7 @@ export const waitForPXE = async (pxe: PXE, logger: DebugLogger) => { }, 'RPC Get Node Info'); }; -const createAztecNode = async ( - nodeConfig: AztecNodeConfig, - logger: DebugLogger, -): Promise => { +const createAztecNode = async (nodeConfig: AztecNodeConfig, logger: DebugLogger): Promise => { if (SANDBOX_URL) { logger(`Not creating Aztec Node as we are running against a sandbox at ${SANDBOX_URL}`); return undefined; @@ -136,7 +133,7 @@ export const setupL1Contracts = async ( */ export async function setupPXEService( numberOfAccounts: number, - aztecNode: AztecNodeService, + aztecNode: AztecNode, logger = getLogger(), useLogSuffix = false, ): Promise<{ @@ -175,18 +172,20 @@ export async function setupPXEService( * @param account - The account for use in create viem wallets. * @param config - The aztec Node Configuration * @param logger - The logger to be used - * @returns Private eXecution Environment (PXE) client, viem wallets, contract addreses etc. + * @returns Private eXecution Environment (PXE) client, viem wallets, contract addresses etc. */ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logger: DebugLogger) { // we are setting up against the sandbox, l1 contracts are already deployed - logger(`Creating JSON RPC client to remote host ${SANDBOX_URL}`); - const jsonClient = createJsonRpcClient(SANDBOX_URL); - await waitForPXE(jsonClient, logger); + logger(`Creating Aztec Node client to remote host ${SANDBOX_URL}`); + const aztecNode = createAztecNodeRpcClient('http://localhost:8079'); + logger(`Creating PXE client to remote host ${SANDBOX_URL}`); + const pxeClient = createPXEClient(SANDBOX_URL); + await waitForPXE(pxeClient, logger); logger('JSON RPC client connected to PXE'); logger(`Retrieving contract addresses from ${SANDBOX_URL}`); - const l1Contracts = (await jsonClient.getNodeInfo()).l1ContractAddresses; + const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses; logger('PXE created, constructing wallets from initial sandbox accounts...'); - const wallets = await getSandboxAccountsWallets(jsonClient); + const wallets = await getSandboxAccountsWallets(pxeClient); const walletClient = createWalletClient({ account, @@ -202,13 +201,13 @@ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logge walletClient, publicClient, }; - const cheatCodes = await CheatCodes.create(config.rpcUrl, jsonClient!); + const cheatCodes = await CheatCodes.create(config.rpcUrl, pxeClient!); const teardown = () => Promise.resolve(); return { - aztecNode: undefined, - pxe: jsonClient, + aztecNode, + pxe: pxeClient, deployL1ContractsValues, - accounts: await jsonClient!.getRegisteredAccounts(), + accounts: await pxeClient!.getRegisteredAccounts(), config, wallet: wallets[0], wallets, @@ -229,7 +228,7 @@ export async function setup( /** * The Aztec Node service. */ - aztecNode: AztecNodeService | undefined; + aztecNode: AztecNode | undefined; /** * The Private eXecution Environment (PXE). */ @@ -300,7 +299,7 @@ export async function setup( const cheatCodes = await CheatCodes.create(config.rpcUrl, pxe!); const teardown = async () => { - await aztecNode?.stop(); + if (aztecNode instanceof AztecNodeService) await aztecNode?.stop(); if (pxe instanceof PXEService) await pxe?.stop(); }; @@ -528,7 +527,7 @@ export function delay(ms: number): Promise { * @param numEncryptedLogs - The number of expected logs. */ export const expectsNumOfEncryptedLogsInTheLastBlockToBe = async ( - aztecNode: AztecNodeService | undefined, + aztecNode: AztecNode | undefined, numEncryptedLogs: number, ) => { if (!aztecNode) { diff --git a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts index 4f25b6bbbc9..dbbd6d9779e 100644 --- a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts @@ -6,7 +6,7 @@ import { EthAddress } from '@aztec/foundation/eth-address'; import { DebugLogger } from '@aztec/foundation/log'; import { UniswapPortalAbi, UniswapPortalBytecode } from '@aztec/l1-artifacts'; import { UniswapContract } from '@aztec/noir-contracts/types'; -import { PXE, TxStatus } from '@aztec/types'; +import { AztecNode, PXE, TxStatus } from '@aztec/types'; import { getContract, parseEther } from 'viem'; @@ -31,7 +31,7 @@ describe('uniswap_trade_on_l1_from_l2', () => { const WETH9_ADDRESS: EthAddress = EthAddress.fromString('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'); const DAI_ADDRESS: EthAddress = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC495271d0F'); - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let pxe: PXE; let logger: DebugLogger; let teardown: () => Promise; From 5ab8488a11c191df056276ec612c1750ae44c284 Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 2 Oct 2023 14:35:23 +0000 Subject: [PATCH 08/24] fix --- yarn-project/end-to-end/src/e2e_2_pxes.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index f19ee8aebca..4497ada8e47 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -1,11 +1,10 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress, NotePreimage, Wallet, computeMessageSecretHash } from '@aztec/aztec.js'; import { DebugLogger } from '@aztec/foundation/log'; import { retryUntil } from '@aztec/foundation/retry'; import { toBigInt } from '@aztec/foundation/serialize'; import { ChildContract, TokenContract } from '@aztec/noir-contracts/types'; import { EthAddress, Fr, PXEService } from '@aztec/pxe'; -import { CompleteAddress, PXE, TxStatus } from '@aztec/types'; +import { AztecNode, CompleteAddress, PXE, TxStatus } from '@aztec/types'; import { jest } from '@jest/globals'; @@ -18,7 +17,7 @@ const TIMEOUT = 60_000; describe('e2e_2_pxes', () => { jest.setTimeout(TIMEOUT); - let aztecNode: AztecNodeService | undefined; + let aztecNode: AztecNode | undefined; let pxeA: PXE; let pxeB: PXE; let walletA: Wallet; From 73cacfd3f610521475e693f2c4881b2d5567124a Mon Sep 17 00:00:00 2001 From: benesjan Date: Mon, 2 Oct 2023 14:44:44 +0000 Subject: [PATCH 09/24] pxe dockerhub deploy --- .circleci/config.yml | 26 +++++++++++++++++++++++--- build_manifest.yml | 7 +++++++ yarn-project/pxe/Dockerfile | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 yarn-project/pxe/Dockerfile diff --git a/.circleci/config.yml b/.circleci/config.yml index b05b90cf172..a199e2dc8ec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -938,7 +938,7 @@ jobs: name: "yarn-project" command: yarn-project/deploy_npm.sh - deploy-dockerhub: + deploy-dockerhub-sandbox: machine: image: ubuntu-2204:2023.07.2 resource_class: medium @@ -953,6 +953,21 @@ jobs: deploy_dockerhub aztec-sandbox arm64 create_dockerhub_manifest aztec-sandbox x86_64,arm64 + deploy-dockerhub-pxe: + machine: + image: ubuntu-2204:2023.07.2 + resource_class: medium + steps: + - *checkout + - *setup_env + - run: + name: "deploy-pxe" + working_directory: pxe + command: | + deploy_dockerhub pxe x86_64 + deploy_dockerhub pxe arm64 + create_dockerhub_manifest pxe x86_64,arm64 + deploy-end: docker: - image: cimg/base:2023.09 @@ -1260,7 +1275,11 @@ workflows: <<: *defaults # Deployment and Canary tests - - deploy-dockerhub: + - deploy-dockerhub-sandbox: + requires: + - e2e-end + <<: *deploy_defaults + - deploy-dockerhub-pxe: requires: - e2e-end <<: *deploy_defaults @@ -1271,7 +1290,8 @@ workflows: - deploy-end: requires: - - deploy-dockerhub + - deploy-dockerhub-sandbox + - deploy-dockerhub-pxe - deploy-npm <<: *deploy_defaults diff --git a/build_manifest.yml b/build_manifest.yml index bdb1f1361e9..f7840384a24 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -120,6 +120,13 @@ aztec-sandbox: dependencies: - aztec-sandbox-base +pxe: + buildDir: yarn-project + projectDir: yarn-project/pxe + dockerfile: Dockerfile + dependencies: + - yarn-project + boxes-blank-react: buildDir: yarn-project projectDir: yarn-project/boxes/blank-react diff --git a/yarn-project/pxe/Dockerfile b/yarn-project/pxe/Dockerfile new file mode 100644 index 00000000000..a7f6a1c7c74 --- /dev/null +++ b/yarn-project/pxe/Dockerfile @@ -0,0 +1,25 @@ +FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project AS builder + +ARG COMMIT_TAG="" + +# Update pxe version if COMMIT_TAG has been used +WORKDIR /usr/src/yarn-project/pxe +RUN if [[ -n "${COMMIT_TAG}" ]]; then \ + jq --arg v ${COMMIT_TAG} '.version = $v' package.json > _temp && mv _temp package.json; \ + fi + +WORKDIR /usr/src/yarn-project/pxe +RUN if [[ -n "${COMMIT_TAG}" ]]; then \ + jq --arg v ${COMMIT_TAG} '.version = $v' package.json > _temp && mv _temp package.json; \ + fi + +# Productionify. See comment in yarn-project-base/Dockerfile. +RUN yarn cache clean && yarn workspaces focus --production + +# Create final, minimal size image. +FROM node:18-alpine +COPY --from=builder /usr/src/ /usr/src/ +WORKDIR /usr/src/yarn-project/pxe +ENTRYPOINT ["yarn"] +CMD [ "start" ] +EXPOSE 8081 From 2a60ab474e72e41dc70e89644a7bcf4f2bdf5f07 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 07:26:20 +0000 Subject: [PATCH 10/24] linter fix --- yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts index a25ad6c74a1..f73ec6dddd4 100644 --- a/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/end-to-end/src/uniswap_trade_on_l1_from_l2.test.ts @@ -1,4 +1,3 @@ -import { AztecNodeService } from '@aztec/aztec-node'; import { AccountWallet, AztecAddress } from '@aztec/aztec.js'; import { Fr, FunctionSelector } from '@aztec/circuits.js'; import { deployL1Contract } from '@aztec/ethereum'; From 8256e628c0b7ef35703b833edfbf072c0b88ca36 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 08:10:11 +0000 Subject: [PATCH 11/24] equality fix --- yarn-project/types/package.json | 2 ++ yarn-project/types/src/l2_block.ts | 4 +--- yarn-project/types/src/logs/l2_block_l2_logs.ts | 11 +++++++++++ yarn-project/yarn.lock | 13 ++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/yarn-project/types/package.json b/yarn-project/types/package.json index 78fa4e4fda9..ff64626d7ac 100644 --- a/yarn-project/types/package.json +++ b/yarn-project/types/package.json @@ -35,6 +35,7 @@ "@aztec/foundation": "workspace:^", "browserify-cipher": "^1.0.1", "lodash.clonedeep": "^4.5.0", + "lodash.isequal": "^4.5.0", "lodash.times": "^4.3.2", "tslib": "^2.5.0" }, @@ -43,6 +44,7 @@ "@rushstack/eslint-patch": "^1.1.4", "@types/jest": "^29.5.0", "@types/lodash.clonedeep": "^4.5.7", + "@types/lodash.isequal": "^4.5.6", "@types/lodash.times": "^4.3.7", "@types/node": "^18.7.23", "jest": "^29.5.0", diff --git a/yarn-project/types/src/l2_block.ts b/yarn-project/types/src/l2_block.ts index d2ea30a99fd..6b23a0b52d7 100644 --- a/yarn-project/types/src/l2_block.ts +++ b/yarn-project/types/src/l2_block.ts @@ -558,9 +558,7 @@ export class L2Block { const logFieldName = logType === LogType.ENCRYPTED ? 'newEncryptedLogs' : 'newUnencryptedLogs'; if (this[logFieldName]) { - if (this[logFieldName] === logs) { - // Comparing objects only by references is enough in this case since this should occur only when exactly - // the same object is passed in and not a copy. + if (this[logFieldName]?.equals(logs)) { L2Block.logger(`${logFieldName} logs already attached`); return; } diff --git a/yarn-project/types/src/logs/l2_block_l2_logs.ts b/yarn-project/types/src/logs/l2_block_l2_logs.ts index c37e61178ad..a3d1ae3cf3f 100644 --- a/yarn-project/types/src/logs/l2_block_l2_logs.ts +++ b/yarn-project/types/src/logs/l2_block_l2_logs.ts @@ -1,5 +1,7 @@ import { BufferReader, serializeBufferToVector } from '@aztec/foundation/serialize'; +import isEqual from 'lodash.isequal'; + import { TxL2Logs } from './tx_l2_logs.js'; /** @@ -89,6 +91,15 @@ export class L2BlockL2Logs { }; } + /** + * Checks if two L2BlockL2Logs objects are equal. + * @param other - Another L2BlockL2Logs object to compare with. + * @returns True if the two objects are equal, false otherwise. + */ + public equals(other: L2BlockL2Logs): boolean { + return isEqual(this, other); + } + /** * Convert a plain JSON object to a L2BlockL2Logs class object. * @param obj - A plain L2BlockL2Logs JSON object. diff --git a/yarn-project/yarn.lock b/yarn-project/yarn.lock index ebc867c97db..03feaa0573e 100644 --- a/yarn-project/yarn.lock +++ b/yarn-project/yarn.lock @@ -761,12 +761,14 @@ __metadata: "@rushstack/eslint-patch": ^1.1.4 "@types/jest": ^29.5.0 "@types/lodash.clonedeep": ^4.5.7 + "@types/lodash.isequal": ^4.5.6 "@types/lodash.times": ^4.3.7 "@types/node": ^18.7.23 browserify-cipher: ^1.0.1 jest: ^29.5.0 jest-mock-extended: ^3.0.3 lodash.clonedeep: ^4.5.0 + lodash.isequal: ^4.5.0 lodash.times: ^4.3.2 ts-jest: ^29.1.0 ts-node: ^10.9.1 @@ -4597,6 +4599,15 @@ __metadata: languageName: node linkType: hard +"@types/lodash.isequal@npm:^4.5.6": + version: 4.5.6 + resolution: "@types/lodash.isequal@npm:4.5.6" + dependencies: + "@types/lodash": "*" + checksum: 0f065989408a9e0584e6c27495be2cd4602e62650f55266aa195812582444463c0c8570c674ae84f947c11748f49ab43fd5b482fa120e08eeee4c23b162edc38 + languageName: node + linkType: hard + "@types/lodash.mapvalues@npm:^4.6.7": version: 4.6.7 resolution: "@types/lodash.mapvalues@npm:4.6.7" @@ -13546,7 +13557,7 @@ __metadata: languageName: node linkType: hard -"lodash.isequal@npm:4.5.0": +"lodash.isequal@npm:4.5.0, lodash.isequal@npm:^4.5.0": version: 4.5.0 resolution: "lodash.isequal@npm:4.5.0" checksum: da27515dc5230eb1140ba65ff8de3613649620e8656b19a6270afe4866b7bd461d9ba2ac8a48dcc57f7adac4ee80e1de9f965d89d4d81a0ad52bb3eec2609644 From 5f953fc45ef953a45486bdb688baec55ea0ffe16 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 09:22:34 +0000 Subject: [PATCH 12/24] feat: exposing 'getDataTreePath', 'getL1ToL2MessageAndIndex', 'getL1ToL2MessagesTreePath' via RPC --- .../src/aztec-node/http_rpc_server.ts | 29 ++++++++++++-- .../aztec-node/src/aztec-node/server.ts | 2 +- .../src/aztec_node/rpc/http_rpc_client.ts | 27 ++++++++++++- .../types/src/l1_to_l2_message.test.ts | 24 +++++++++++- yarn-project/types/src/l1_to_l2_message.ts | 39 ++++++++++++++----- 5 files changed, 104 insertions(+), 17 deletions(-) diff --git a/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts b/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts index cd740d9c44f..51205c979af 100644 --- a/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts +++ b/yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts @@ -3,7 +3,18 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { JsonRpcServer } from '@aztec/foundation/json-rpc/server'; -import { AztecNode, ContractData, ExtendedContractData, L2Block, L2BlockL2Logs, L2Tx, Tx, TxHash } from '@aztec/types'; +import { + AztecNode, + ContractData, + ExtendedContractData, + L1ToL2MessageAndIndex, + L2Block, + L2BlockL2Logs, + L2Tx, + SiblingPath, + Tx, + TxHash, +} from '@aztec/types'; /** * Wrap an AztecNode instance with a JSON RPC HTTP server. @@ -13,11 +24,23 @@ import { AztecNode, ContractData, ExtendedContractData, L2Block, L2BlockL2Logs, export function createAztecNodeRpcServer(node: AztecNode) { const rpc = new JsonRpcServer( node, - { AztecAddress, EthAddress, ExtendedContractData, ContractData, Fr, HistoricBlockData, L2Block, L2Tx, TxHash }, + { + AztecAddress, + EthAddress, + ExtendedContractData, + ContractData, + Fr, + HistoricBlockData, + L2Block, + L2Tx, + TxHash, + SiblingPath, + L1ToL2MessageAndIndex, + }, { Tx, L2BlockL2Logs }, false, // disable methods not part of the AztecNode interface - ['start', 'stop', 'getDataTreePath', 'getL1ToL2MessageAndIndex', 'getL1ToL2MessagesTreePath'], + ['start', 'stop'], ); return rpc; } diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index f1e3f3ad607..cf92a60650a 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -294,7 +294,7 @@ export class AztecNodeService implements AztecNode { // todo: #697 - make this one lookup. const index = (await this.findLeafIndex(MerkleTreeId.L1_TO_L2_MESSAGES_TREE, messageKey.toBuffer()))!; const message = await this.l1ToL2MessageSource.getConfirmedL1ToL2Message(messageKey); - return Promise.resolve({ message, index }); + return Promise.resolve(new L1ToL2MessageAndIndex(index, message)); } /** diff --git a/yarn-project/types/src/aztec_node/rpc/http_rpc_client.ts b/yarn-project/types/src/aztec_node/rpc/http_rpc_client.ts index c19c787a35d..96cdfb6676e 100644 --- a/yarn-project/types/src/aztec_node/rpc/http_rpc_client.ts +++ b/yarn-project/types/src/aztec_node/rpc/http_rpc_client.ts @@ -3,7 +3,18 @@ import { AztecAddress } from '@aztec/foundation/aztec-address'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; import { createJsonRpcClient, defaultFetch } from '@aztec/foundation/json-rpc/client'; -import { AztecNode, ContractData, ExtendedContractData, L2Block, L2BlockL2Logs, L2Tx, Tx, TxHash } from '@aztec/types'; +import { + AztecNode, + ContractData, + ExtendedContractData, + L1ToL2MessageAndIndex, + L2Block, + L2BlockL2Logs, + L2Tx, + SiblingPath, + Tx, + TxHash, +} from '@aztec/types'; /** * Creates a JSON-RPC client to remotely talk to an AztecNode. @@ -14,7 +25,19 @@ import { AztecNode, ContractData, ExtendedContractData, L2Block, L2BlockL2Logs, export function createAztecNodeRpcClient(url: string, fetch = defaultFetch): AztecNode { const rpcClient = createJsonRpcClient( url, - { AztecAddress, EthAddress, ExtendedContractData, ContractData, Fr, HistoricBlockData, L2Block, L2Tx, TxHash }, + { + AztecAddress, + EthAddress, + ExtendedContractData, + ContractData, + Fr, + HistoricBlockData, + L2Block, + L2Tx, + TxHash, + SiblingPath, + L1ToL2MessageAndIndex, + }, { Tx, L2BlockL2Logs }, false, fetch, diff --git a/yarn-project/types/src/l1_to_l2_message.test.ts b/yarn-project/types/src/l1_to_l2_message.test.ts index 842d0b5428f..35dc7e83e05 100644 --- a/yarn-project/types/src/l1_to_l2_message.test.ts +++ b/yarn-project/types/src/l1_to_l2_message.test.ts @@ -1,4 +1,4 @@ -import { L1ToL2Message } from './l1_to_l2_message.js'; +import { L1ToL2Message, L1ToL2MessageAndIndex } from './l1_to_l2_message.js'; describe('L1 to L2 message', () => { it('can encode an L1 to L2 message to buffer and back', () => { @@ -7,4 +7,26 @@ describe('L1 to L2 message', () => { const recovered = L1ToL2Message.fromBuffer(buffer); expect(recovered).toEqual(msg); }); + + it('can encode an L1ToL2MessageAndIndex to buffer and back', () => { + const index = BigInt(Math.floor(Math.random() * 1000)); // Generate a random BigInt + const msg = L1ToL2Message.random(); + const l1ToL2MsgAndIndex = new L1ToL2MessageAndIndex(index, msg); + + const buffer = l1ToL2MsgAndIndex.toBuffer(); + const recovered = L1ToL2MessageAndIndex.fromBuffer(buffer); + + expect(recovered).toEqual(l1ToL2MsgAndIndex); + }); + + it('can encode an L1ToL2MessageAndIndex to string and back', () => { + const index = BigInt(Math.floor(Math.random() * 1000)); // Generate a random BigInt + const msg = L1ToL2Message.random(); + const l1ToL2MsgAndIndex = new L1ToL2MessageAndIndex(index, msg); + + const stringData = l1ToL2MsgAndIndex.toString(); + const recovered = L1ToL2MessageAndIndex.fromString(stringData); + + expect(recovered).toEqual(l1ToL2MsgAndIndex); + }); }); diff --git a/yarn-project/types/src/l1_to_l2_message.ts b/yarn-project/types/src/l1_to_l2_message.ts index 03493c09d29..d56652fd6ae 100644 --- a/yarn-project/types/src/l1_to_l2_message.ts +++ b/yarn-project/types/src/l1_to_l2_message.ts @@ -1,5 +1,6 @@ import { BufferReader, serializeToBuffer } from '@aztec/circuits.js/utils'; import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { toBigIntBE, toBufferBE } from '@aztec/foundation/bigint-buffer'; import { EthAddress } from '@aztec/foundation/eth-address'; import { Fr } from '@aztec/foundation/fields'; @@ -32,16 +33,34 @@ export interface L1ToL2MessageSource { /** * L1AndL2Message and Index (in the merkle tree) as one type */ -export type L1ToL2MessageAndIndex = { - /** - * The message. - */ - message: L1ToL2Message; - /** - * the index in the L1 to L2 Message tree. - */ - index: bigint; -}; +export class L1ToL2MessageAndIndex { + constructor( + /** the index in the L1 to L2 Message tree. */ + public readonly index: bigint, + /** The message. */ + public readonly message: L1ToL2Message, + ) {} + + toBuffer(): Buffer { + return Buffer.concat([toBufferBE(this.index, 32), this.message.toBuffer()]); + } + + toString(): string { + return this.toBuffer().toString('hex'); + } + + static fromString(data: string): L1ToL2MessageAndIndex { + const buffer = Buffer.from(data, 'hex'); + return L1ToL2MessageAndIndex.fromBuffer(buffer); + } + + static fromBuffer(buffer: Buffer | BufferReader) { + const reader = BufferReader.asReader(buffer); + const index = toBigIntBE(reader.readBytes(32)); + const message = L1ToL2Message.fromBuffer(reader); + return new L1ToL2MessageAndIndex(index, message); + } +} /** * The format of an L1 to L2 Message. From b5812209219a31a6f7a175f40c53be76d99dfbe0 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 09:23:25 +0000 Subject: [PATCH 13/24] test: making e2e_2_pxes compatible with sandbox --- yarn-project/end-to-end/src/e2e_2_pxes.test.ts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index 4497ada8e47..bbdda6c8e15 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -10,8 +10,6 @@ import { jest } from '@jest/globals'; import { expectsNumOfEncryptedLogsInTheLastBlockToBe, setup, setupPXEService } from './fixtures/utils.js'; -const { SANDBOX_URL = '' } = process.env; - const TIMEOUT = 60_000; describe('e2e_2_pxes', () => { @@ -28,10 +26,6 @@ describe('e2e_2_pxes', () => { let teardownA: () => Promise; beforeEach(async () => { - // this test can't be run against the sandbox as it requires 2 PXEs - if (SANDBOX_URL) { - throw new Error(`Test can't be run against the sandbox as 2 PXEs are required`); - } let accounts: CompleteAddress[] = []; ({ aztecNode, From 853af1d690c38e187bf9bd29571fc0ac47d15e7f Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 09:50:13 +0000 Subject: [PATCH 14/24] renaming SANDBOX_URL as PXE_URL --- .../boxes/blank-react/docker-compose.yml | 2 +- .../boxes/blank-react/src/app/home.tsx | 4 +-- yarn-project/boxes/blank-react/src/config.ts | 4 +-- .../src/tests/blank.contract.test.ts | 4 +-- yarn-project/boxes/blank/docker-compose.yml | 2 +- yarn-project/boxes/blank/src/index.ts | 4 +-- .../blank/src/tests/blank.contract.test.ts | 4 +-- .../boxes/private-token/docker-compose.yml | 2 +- .../boxes/private-token/src/app/home.tsx | 4 +-- .../boxes/private-token/src/config.ts | 4 +-- .../src/tests/privatetoken.sandbox.test.ts | 4 +-- .../canary/scripts/docker-compose-browser.yml | 2 +- .../scripts/docker-compose-e2e-sandbox.yml | 2 +- .../canary/scripts/docker-compose.yml | 2 +- yarn-project/canary/src/cli.test.ts | 6 ++-- .../src/uniswap_trade_on_l1_from_l2.test.ts | 4 +-- .../docker-compose-e2e-sandbox-browser.yml | 2 +- .../scripts/docker-compose-e2e-sandbox.yml | 2 +- yarn-project/end-to-end/src/canary/browser.ts | 14 ++++---- .../end-to-end/src/cli_docs_sandbox.test.ts | 4 +-- .../src/e2e_aztec_js_browser.test.ts | 2 +- .../src/e2e_sandbox_example.test.ts | 6 ++-- yarn-project/end-to-end/src/fixtures/utils.ts | 36 ++++++++++--------- .../src/guides/dapp_testing.test.ts | 12 +++---- .../src/guides/up_quick_start.test.ts | 2 +- .../end-to-end/src/pxe_sandbox.test.ts | 4 +-- .../end-to-end/src/sample-dapp/connect.mjs | 4 +-- .../end-to-end/src/sample-dapp/deploy.mjs | 4 +-- .../end-to-end/src/sample-dapp/index.mjs | 4 +-- yarn-project/pxe/src/bin/index.ts | 4 +-- 30 files changed, 78 insertions(+), 76 deletions(-) diff --git a/yarn-project/boxes/blank-react/docker-compose.yml b/yarn-project/boxes/blank-react/docker-compose.yml index 328d0c8f366..e125024c37b 100644 --- a/yarn-project/boxes/blank-react/docker-compose.yml +++ b/yarn-project/boxes/blank-react/docker-compose.yml @@ -32,4 +32,4 @@ services: environment: ETHEREUM_HOST: http://ethereum:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://aztec:8080 \ No newline at end of file + PXE_URL: http://aztec:8080 \ No newline at end of file diff --git a/yarn-project/boxes/blank-react/src/app/home.tsx b/yarn-project/boxes/blank-react/src/app/home.tsx index f6d7186fcb1..b1535b94d4f 100644 --- a/yarn-project/boxes/blank-react/src/app/home.tsx +++ b/yarn-project/boxes/blank-react/src/app/home.tsx @@ -1,7 +1,7 @@ import { Loader } from '@aztec/aztec-ui'; import { CompleteAddress } from '@aztec/aztec.js'; import { useEffect, useRef, useState } from 'react'; -import { SANDBOX_URL } from '../config.js'; +import { PXE_URL } from '../config.js'; import { WalletDropdown } from './components/wallet_dropdown.js'; import { Contract } from './contract.js'; import styles from './home.module.scss'; @@ -73,7 +73,7 @@ export function Home() { <> {`Failed to load accounts. Error: ${selectWalletError}`}
- {`Make sure the Aztec Sandbox is running at: ${SANDBOX_URL}`} + {`Make sure PXE from Aztec Sandbox is running at: ${PXE_URL}`} )} {!selectWalletError && !selectedWallet && `No accounts.`} diff --git a/yarn-project/boxes/blank-react/src/config.ts b/yarn-project/boxes/blank-react/src/config.ts index bf8bbb85b3b..b2405997b7d 100644 --- a/yarn-project/boxes/blank-react/src/config.ts +++ b/yarn-project/boxes/blank-react/src/config.ts @@ -6,7 +6,7 @@ import { BlankContractAbi } from './artifacts/blank.js'; export const contractAbi: ContractAbi = BlankContractAbi; -export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:8080'; -export const pxe: PXE = createPXEClient(SANDBOX_URL); +export const PXE_URL: string = process.env.PXE_URL || 'http://localhost:8080'; +export const pxe: PXE = createPXEClient(PXE_URL); export const CONTRACT_ADDRESS_PARAM_NAMES = ['address']; diff --git a/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts b/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts index 7f1eed6e2c8..035deced39c 100644 --- a/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts +++ b/yarn-project/boxes/blank-react/src/tests/blank.contract.test.ts @@ -19,8 +19,8 @@ const logger = createDebugLogger('aztec:http-pxe-client'); // assumes sandbox is running locally, which this script does not trigger // as well as anvil. anvil can be started with yarn test:integration const setupSandbox = async () => { - const { SANDBOX_URL = 'http://localhost:8080' } = process.env; - const pxe = createPXEClient(SANDBOX_URL); + const { PXE_URL = 'http://localhost:8080' } = process.env; + const pxe = createPXEClient(PXE_URL); await waitForSandbox(pxe); return pxe; diff --git a/yarn-project/boxes/blank/docker-compose.yml b/yarn-project/boxes/blank/docker-compose.yml index 8ecb7ac09cc..313e5faddef 100644 --- a/yarn-project/boxes/blank/docker-compose.yml +++ b/yarn-project/boxes/blank/docker-compose.yml @@ -32,4 +32,4 @@ services: environment: ETHEREUM_HOST: http://ethereum:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://aztec:8080 \ No newline at end of file + PXE_URL: http://aztec:8080 \ No newline at end of file diff --git a/yarn-project/boxes/blank/src/index.ts b/yarn-project/boxes/blank/src/index.ts index 6d35b8190fc..a273bcabf70 100644 --- a/yarn-project/boxes/blank/src/index.ts +++ b/yarn-project/boxes/blank/src/index.ts @@ -15,8 +15,8 @@ import { FieldsOf } from '@aztec/foundation/types'; import { BlankContractAbi } from './artifacts/blank.js'; export const contractAbi: ContractAbi = BlankContractAbi; -export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:8080'; -export const pxe: PXE = createPXEClient(SANDBOX_URL); +export const PXE_URL: string = process.env.PXE_URL || 'http://localhost:8080'; +export const pxe: PXE = createPXEClient(PXE_URL); let contractAddress: string = ''; diff --git a/yarn-project/boxes/blank/src/tests/blank.contract.test.ts b/yarn-project/boxes/blank/src/tests/blank.contract.test.ts index 883ef265369..ac9cff71b87 100644 --- a/yarn-project/boxes/blank/src/tests/blank.contract.test.ts +++ b/yarn-project/boxes/blank/src/tests/blank.contract.test.ts @@ -18,8 +18,8 @@ const logger = createDebugLogger('aztec:blank-box-test'); // assumes sandbox is running locally, which this script does not trigger // as well as anvil. anvil can be started with yarn test:integration const setupSandbox = async () => { - const { SANDBOX_URL = 'http://localhost:8080' } = process.env; - const pxe = createPXEClient(SANDBOX_URL); + const { PXE_URL = 'http://localhost:8080' } = process.env; + const pxe = createPXEClient(PXE_URL); await waitForSandbox(pxe); return pxe; }; diff --git a/yarn-project/boxes/private-token/docker-compose.yml b/yarn-project/boxes/private-token/docker-compose.yml index 536fae2c3fd..458571a4cdc 100644 --- a/yarn-project/boxes/private-token/docker-compose.yml +++ b/yarn-project/boxes/private-token/docker-compose.yml @@ -32,4 +32,4 @@ services: environment: ETHEREUM_HOST: http://ethereum:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://aztec:8080 \ No newline at end of file + PXE_URL: http://aztec:8080 \ No newline at end of file diff --git a/yarn-project/boxes/private-token/src/app/home.tsx b/yarn-project/boxes/private-token/src/app/home.tsx index 64e73a44d12..8475b2afe55 100644 --- a/yarn-project/boxes/private-token/src/app/home.tsx +++ b/yarn-project/boxes/private-token/src/app/home.tsx @@ -1,4 +1,4 @@ -import { SANDBOX_URL } from '../config.js'; +import { PXE_URL } from '../config.js'; import { WalletDropdown } from './components/wallet_dropdown.js'; import { Contract } from './contract.js'; import styles from './home.module.scss'; @@ -73,7 +73,7 @@ export function Home() { <> {`Failed to load accounts. Error: ${selectWalletError}`}
- {`Make sure the Aztec Sandbox is running at: ${SANDBOX_URL}`} + {`Make sure PXE from Aztec Sandbox is running at: ${PXE_URL}`} )} {!selectWalletError && !selectedWallet && `No accounts.`} diff --git a/yarn-project/boxes/private-token/src/config.ts b/yarn-project/boxes/private-token/src/config.ts index 074f5eea5fa..14449eac122 100644 --- a/yarn-project/boxes/private-token/src/config.ts +++ b/yarn-project/boxes/private-token/src/config.ts @@ -6,8 +6,8 @@ import { ContractAbi } from '@aztec/foundation/abi'; export const contractAbi: ContractAbi = PrivateTokenContractAbi; -export const SANDBOX_URL: string = process.env.SANDBOX_URL || 'http://localhost:8080'; -export const pxe: PXE = createPXEClient(SANDBOX_URL); +export const PXE_URL: string = process.env.PXE_URL || 'http://localhost:8080'; +export const pxe: PXE = createPXEClient(PXE_URL); export const CONTRACT_ADDRESS_PARAM_NAMES = ['owner', 'contract_address', 'recipient']; export const FILTERED_FUNCTION_NAMES = ['compute_note_hash_and_nullifier']; diff --git a/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts b/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts index bfbe139e133..367e0fb60f4 100644 --- a/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts +++ b/yarn-project/boxes/private-token/src/tests/privatetoken.sandbox.test.ts @@ -23,8 +23,8 @@ const MINT_AMOUNT = 11n; // assumes sandbox is running locally, which this script does not trigger // as well as anvil. anvil can be started with yarn test:integration const setupSandbox = async () => { - const { SANDBOX_URL = 'http://localhost:8080' } = process.env; - const pxe = createPXEClient(SANDBOX_URL); + const { PXE_URL = 'http://localhost:8080' } = process.env; + const pxe = createPXEClient(PXE_URL); await waitForSandbox(pxe); return pxe; }; diff --git a/yarn-project/canary/scripts/docker-compose-browser.yml b/yarn-project/canary/scripts/docker-compose-browser.yml index e7db3336acc..325fefec48f 100644 --- a/yarn-project/canary/scripts/docker-compose-browser.yml +++ b/yarn-project/canary/scripts/docker-compose-browser.yml @@ -33,5 +33,5 @@ services: environment: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://sandbox:8080 + PXE_URL: http://sandbox:8080 command: ['./scripts/start_e2e_ci_browser.sh', './src/aztec_js_browser.test.ts'] diff --git a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml index 7f3d8162382..99ba4ef692a 100644 --- a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml @@ -33,6 +33,6 @@ services: environment: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://sandbox:8080 + PXE_URL: http://sandbox:8080 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/e2e_deploy_contract.test.ts} diff --git a/yarn-project/canary/scripts/docker-compose.yml b/yarn-project/canary/scripts/docker-compose.yml index ccba483c3ac..cb05203150c 100644 --- a/yarn-project/canary/scripts/docker-compose.yml +++ b/yarn-project/canary/scripts/docker-compose.yml @@ -33,5 +33,5 @@ services: environment: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://sandbox:8080 + PXE_URL: http://sandbox:8080 command: ${TEST:-./src/uniswap_trade_on_l1_from_l2.test.ts} diff --git a/yarn-project/canary/src/cli.test.ts b/yarn-project/canary/src/cli.test.ts index a7fef24cc07..ef5e9184789 100644 --- a/yarn-project/canary/src/cli.test.ts +++ b/yarn-project/canary/src/cli.test.ts @@ -1,14 +1,14 @@ import { createDebugLogger, createPXEClient, makeFetch, waitForSandbox } from '@aztec/aztec.js'; import { cliTestSuite } from '@aztec/end-to-end'; -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +const { PXE_URL = 'http://localhost:8080' } = process.env; const debug = createDebugLogger('aztec:canary_cli'); const setupRPC = async () => { - const pxe = createPXEClient(SANDBOX_URL, makeFetch([1, 2, 3, 4, 5], true)); + const pxe = createPXEClient(PXE_URL, makeFetch([1, 2, 3, 4, 5], true)); await waitForSandbox(pxe); return pxe; }; -cliTestSuite('CLI Canary', setupRPC, () => Promise.resolve(), debug, SANDBOX_URL); +cliTestSuite('CLI Canary', setupRPC, () => Promise.resolve(), debug, PXE_URL); diff --git a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts index 8ae683ebfee..12af58ee3cf 100644 --- a/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts +++ b/yarn-project/canary/src/uniswap_trade_on_l1_from_l2.test.ts @@ -36,7 +36,7 @@ import { deployAndInitializeTokenAndBridgeContracts, deployL1Contract, hashPaylo const logger = createDebugLogger('aztec:canary'); -const { SANDBOX_URL = 'http://localhost:8080', ETHEREUM_HOST = 'http://localhost:8545' } = process.env; +const { PXE_URL = 'http://localhost:8080', ETHEREUM_HOST = 'http://localhost:8545' } = process.env; export const MNEMONIC = 'test test test test test test test test test test test junk'; @@ -45,7 +45,7 @@ const DAI_ADDRESS = EthAddress.fromString('0x6B175474E89094C44Da98b954EedeAC4952 const EXPECTED_FORKED_BLOCK = 17514288; -const pxeRpcUrl = SANDBOX_URL; +const pxeRpcUrl = PXE_URL; const ethRpcUrl = ETHEREUM_HOST; const hdAccount = mnemonicToAccount(MNEMONIC); diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml index 54424e6c93e..36fdf0067c4 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml @@ -33,6 +33,6 @@ services: environment: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://sandbox:8080 + PXE_URL: http://sandbox:8080 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} entrypoint: ['./scripts/start_e2e_ci_browser.sh', './src/e2e_aztec_js_browser.test.ts'] diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml index 53eb4fde6d2..063dd304f20 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml @@ -33,6 +33,6 @@ services: environment: ETHEREUM_HOST: http://fork:8545 CHAIN_ID: 31337 - SANDBOX_URL: http://sandbox:8080 + PXE_URL: http://sandbox:8080 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/e2e_deploy_contract.test.ts} diff --git a/yarn-project/end-to-end/src/canary/browser.ts b/yarn-project/end-to-end/src/canary/browser.ts index bf145149e99..ef2e1cddc26 100644 --- a/yarn-project/end-to-end/src/canary/browser.ts +++ b/yarn-project/end-to-end/src/canary/browser.ts @@ -25,9 +25,9 @@ const __dirname = dirname(__filename); const PORT = 3000; -const { SANDBOX_URL } = process.env; +const { PXE_URL } = process.env; -const conditionalDescribe = () => (SANDBOX_URL ? describe : describe.skip); +const conditionalDescribe = () => (PXE_URL ? describe : describe.skip); const privKey = AztecJs.GrumpkinScalar.random(); export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugLogger) => @@ -46,7 +46,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL beforeAll(async () => { server = setup(); - testClient = AztecJs.createPXEClient(SANDBOX_URL!); + testClient = AztecJs.createPXEClient(PXE_URL!); await AztecJs.waitForSandbox(testClient); app = new Koa(); @@ -100,7 +100,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL console.log(`Created Account: ${addressString}`); return addressString; }, - SANDBOX_URL, + PXE_URL, privKey.toString(), ); const accounts = await testClient.getRegisteredAccounts(); @@ -123,7 +123,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL const balance = await contract.methods.balance_of_private(owner).view({ from: owner }); return balance; }, - SANDBOX_URL, + PXE_URL, (await getTokenAddress()).toString(), TokenContractAbi, ); @@ -144,7 +144,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL console.log(`Transferred ${transferAmount} tokens to new Account`); return await contract.methods.balance_of_private(receiver).view({ from: receiver }); }, - SANDBOX_URL, + PXE_URL, (await getTokenAddress()).toString(), transferAmount, TokenContractAbi, @@ -195,7 +195,7 @@ export const browserTestSuite = (setup: () => Server, pageLogger: AztecJs.DebugL return receipt.txHash.toString(); }, - SANDBOX_URL, + PXE_URL, privKey.toString(), initialBalance, TokenContractAbi, diff --git a/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts b/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts index bedab689aef..f7885a1ecdf 100644 --- a/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts +++ b/yarn-project/end-to-end/src/cli_docs_sandbox.test.ts @@ -7,7 +7,7 @@ import { format } from 'util'; const debug = createDebugLogger('aztec:e2e_cli'); -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +const { PXE_URL = 'http://localhost:8080' } = process.env; describe('CLI docs sandbox', () => { let cli: ReturnType; @@ -65,7 +65,7 @@ Rollup Address: 0x0dcd1bf9a1b36ce34237eeafef220932846bcd82 const run = (cmd: string, addRpcUrl = true) => { const args = stringArgv(cmd, 'node', 'dest/bin/index.js'); if (addRpcUrl) { - args.push('--rpc-url', SANDBOX_URL); + args.push('--rpc-url', PXE_URL); } return cli.parseAsync(args); }; diff --git a/yarn-project/end-to-end/src/e2e_aztec_js_browser.test.ts b/yarn-project/end-to-end/src/e2e_aztec_js_browser.test.ts index bb4a246251e..aa88cdbbe18 100644 --- a/yarn-project/end-to-end/src/e2e_aztec_js_browser.test.ts +++ b/yarn-project/end-to-end/src/e2e_aztec_js_browser.test.ts @@ -20,7 +20,7 @@ const pageLogger = createDebugLogger('aztec:canary_aztec.js:web:page'); * 3) start anvil: `anvil`, * 4) open new terminal and optionally set the more verbose debug level: `DEBUG=aztec:*`, * 5) go to the sandbox dir `yarn-project/aztec-sandbox` and run `yarn start`, - * 6) open new terminal and export the sandbox URL: `export SANDBOX_URL='http://localhost:8080'`, + * 6) open new terminal and export the URL of PXE from Sandbox: `export PXE_URL='http://localhost:8080'`, * 7) go to `yarn-project/end-to-end` and run the test: `yarn test aztec_js_browser` * * NOTE: If you see aztec-sandbox logs spammed with unexpected logs there is probably a chrome process with a webpage diff --git a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts index c3ddec3f42a..006eee63584 100644 --- a/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts +++ b/yarn-project/end-to-end/src/e2e_sandbox_example.test.ts @@ -13,7 +13,7 @@ import { import { GrumpkinScalar } from '@aztec/circuits.js'; import { TokenContract } from '@aztec/noir-contracts/types'; -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +const { PXE_URL = 'http://localhost:8080' } = process.env; // docs:end:imports describe('e2e_sandbox_example', () => { @@ -23,7 +23,7 @@ describe('e2e_sandbox_example', () => { const logger = createDebugLogger('token'); // We create PXE client connected to the sandbox URL - const pxe = createPXEClient(SANDBOX_URL); + const pxe = createPXEClient(PXE_URL); // Wait for sandbox to be ready await waitForSandbox(pxe); @@ -148,7 +148,7 @@ describe('e2e_sandbox_example', () => { it('can create accounts on the sandbox', async () => { const logger = createDebugLogger('token'); // We create PXE client connected to the sandbox URL - const pxe = createPXEClient(SANDBOX_URL); + const pxe = createPXEClient(PXE_URL); // Wait for sandbox to be ready await waitForSandbox(pxe); diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index e371f36489a..4d9a7d74cf4 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -61,7 +61,16 @@ import { mnemonicToAccount } from 'viem/accounts'; import { MNEMONIC, localAnvil } from './fixtures.js'; -const { SANDBOX_URL = '' } = process.env; +const { PXE_URL = '', AZTEC_NODE_URL = '' } = process.env; + +const getAztecNodeUrl = () => { + if (AZTEC_NODE_URL) return AZTEC_NODE_URL; + + // If AZTEC_NODE_URL is not set, we assume that the PXE is running on the same host as the Aztec Node and use the default port + const url = new URL(PXE_URL); + url.port = '8079'; + return url.toString(); +} export const waitForPXE = async (pxe: PXE, logger: DebugLogger) => { await retryUntil(async () => { @@ -76,15 +85,6 @@ export const waitForPXE = async (pxe: PXE, logger: DebugLogger) => { }, 'RPC Get Node Info'); }; -const createAztecNode = async (nodeConfig: AztecNodeConfig, logger: DebugLogger): Promise => { - if (SANDBOX_URL) { - logger(`Not creating Aztec Node as we are running against a sandbox at ${SANDBOX_URL}`); - return undefined; - } - logger('Creating and synching an aztec node...'); - return await AztecNodeService.createAndSync(nodeConfig); -}; - export const setupL1Contracts = async ( l1RpcUrl: string, account: HDAccount | PrivateKeyAccount, @@ -176,13 +176,14 @@ export async function setupPXEService( */ async function setupWithSandbox(account: Account, config: AztecNodeConfig, logger: DebugLogger) { // we are setting up against the sandbox, l1 contracts are already deployed - logger(`Creating Aztec Node client to remote host ${SANDBOX_URL}`); - const aztecNode = createAztecNodeRpcClient('http://localhost:8079'); - logger(`Creating PXE client to remote host ${SANDBOX_URL}`); - const pxeClient = createPXEClient(SANDBOX_URL); + const aztecNodeUrl = getAztecNodeUrl(); + logger(`Creating Aztec Node client to remote host ${aztecNodeUrl}`); + const aztecNode = createAztecNodeRpcClient(aztecNodeUrl); + logger(`Creating PXE client to remote host ${PXE_URL}`); + const pxeClient = createPXEClient(PXE_URL); await waitForPXE(pxeClient, logger); logger('JSON RPC client connected to PXE'); - logger(`Retrieving contract addresses from ${SANDBOX_URL}`); + logger(`Retrieving contract addresses from ${PXE_URL}`); const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses; logger('PXE created, constructing wallets from initial sandbox accounts...'); const wallets = await getSandboxAccountsWallets(pxeClient); @@ -276,7 +277,7 @@ export async function setup( const logger = getLogger(); const hdAccount = mnemonicToAccount(MNEMONIC); - if (SANDBOX_URL) { + if (PXE_URL) { // we are setting up against the sandbox, l1 contracts are already deployed return await setupWithSandbox(hdAccount, config, logger); } @@ -292,7 +293,8 @@ export async function setup( deployL1ContractsValues.l1ContractAddresses.contractDeploymentEmitterAddress; config.l1Contracts.inboxAddress = deployL1ContractsValues.l1ContractAddresses.inboxAddress; - const aztecNode = await createAztecNode(config, logger); + logger('Creating and synching an aztec node...'); + const aztecNode = await AztecNodeService.createAndSync(config); const { pxe, accounts, wallets } = await setupPXEService(numberOfAccounts, aztecNode!, logger); diff --git a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts index 710cea3bf33..d3253bd218f 100644 --- a/yarn-project/end-to-end/src/guides/dapp_testing.test.ts +++ b/yarn-project/end-to-end/src/guides/dapp_testing.test.ts @@ -15,7 +15,7 @@ import { import { toBigIntBE } from '@aztec/foundation/bigint-buffer'; import { TestContract, TokenContract } from '@aztec/noir-contracts/types'; -const { SANDBOX_URL = 'http://localhost:8080', ETHEREUM_HOST = 'http://localhost:8545' } = process.env; +const { PXE_URL = 'http://localhost:8080', ETHEREUM_HOST = 'http://localhost:8545' } = process.env; describe('guides/dapp/testing', () => { describe('on in-proc sandbox', () => { @@ -61,7 +61,7 @@ describe('guides/dapp/testing', () => { describe('on local sandbox', () => { beforeAll(async () => { - const pxe = createPXEClient(SANDBOX_URL); + const pxe = createPXEClient(PXE_URL); await waitForSandbox(pxe); }); @@ -73,7 +73,7 @@ describe('guides/dapp/testing', () => { let token: TokenContract; beforeEach(async () => { - pxe = createPXEClient(SANDBOX_URL); + pxe = createPXEClient(PXE_URL); owner = await createAccount(pxe); recipient = await createAccount(pxe); token = await TokenContract.deploy(owner).send().deployed(); @@ -107,7 +107,7 @@ describe('guides/dapp/testing', () => { beforeEach(async () => { // docs:start:use-existing-wallets - pxe = createPXEClient(SANDBOX_URL); + pxe = createPXEClient(PXE_URL); [owner, recipient] = await getSandboxAccountsWallets(pxe); token = await TokenContract.deploy(owner).send().deployed(); await token.methods._initialize(owner.getAddress()).send().wait(); @@ -138,7 +138,7 @@ describe('guides/dapp/testing', () => { let cheats: CheatCodes; beforeAll(async () => { - pxe = createPXEClient(SANDBOX_URL); + pxe = createPXEClient(PXE_URL); owner = await createAccount(pxe); testContract = await TestContract.deploy(owner).send().deployed(); cheats = await CheatCodes.create(ETHEREUM_HOST, pxe); @@ -163,7 +163,7 @@ describe('guides/dapp/testing', () => { let ownerSlot: Fr; beforeAll(async () => { - pxe = createPXEClient(SANDBOX_URL); + pxe = createPXEClient(PXE_URL); owner = await createAccount(pxe); recipient = await createAccount(pxe); testContract = await TestContract.deploy(owner).send().deployed(); diff --git a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts index 855dbcaf4ff..1969e1cfd3d 100644 --- a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts +++ b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts @@ -7,7 +7,7 @@ describe('guides/up_quick_start', () => { it('works', async () => { await waitForSandbox(); execSync( - `DEBUG="aztec:*" PXE_HOST=\${SANDBOX_URL:-http://localhost:8080} PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh`, + `DEBUG="aztec:*" PXE_HOST=\${PXE_URL:-http://localhost:8080} PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh`, { shell: '/bin/bash', stdio: 'pipe', diff --git a/yarn-project/end-to-end/src/pxe_sandbox.test.ts b/yarn-project/end-to-end/src/pxe_sandbox.test.ts index cfdee86086e..c39f0edfd14 100644 --- a/yarn-project/end-to-end/src/pxe_sandbox.test.ts +++ b/yarn-project/end-to-end/src/pxe_sandbox.test.ts @@ -1,10 +1,10 @@ import { createPXEClient, waitForSandbox } from '@aztec/aztec.js'; import { pxeTestSuite } from '@aztec/pxe'; -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +const { PXE_URL = 'http://localhost:8080' } = process.env; const setup = async () => { - const pxe = createPXEClient(SANDBOX_URL); + const pxe = createPXEClient(PXE_URL); await waitForSandbox(pxe); return pxe; }; diff --git a/yarn-project/end-to-end/src/sample-dapp/connect.mjs b/yarn-project/end-to-end/src/sample-dapp/connect.mjs index 0785fb1ca3a..6486f7447a1 100644 --- a/yarn-project/end-to-end/src/sample-dapp/connect.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/connect.mjs @@ -1,10 +1,10 @@ // docs:start:all import { createPXEClient } from '@aztec/aztec.js'; -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +const { PXE_URL = 'http://localhost:8080' } = process.env; async function main() { - const pxe = createPXEClient(SANDBOX_URL); + const pxe = createPXEClient(PXE_URL); const { chainId } = await pxe.getNodeInfo(); console.log(`Connected to chain ${chainId}`); } diff --git a/yarn-project/end-to-end/src/sample-dapp/deploy.mjs b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs index 7d9c655ac19..a200a05934d 100644 --- a/yarn-project/end-to-end/src/sample-dapp/deploy.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/deploy.mjs @@ -5,10 +5,10 @@ import { writeFileSync } from 'fs'; import { fileURLToPath } from 'url'; // docs:start:dapp-deploy -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +const { PXE_URL = 'http://localhost:8080' } = process.env; async function main() { - const pxe = createPXEClient(SANDBOX_URL); + const pxe = createPXEClient(PXE_URL); const [owner] = await getSandboxAccountsWallets(pxe); const token = await Contract.deploy(pxe, TokenContractAbi, []).send().deployed(); diff --git a/yarn-project/end-to-end/src/sample-dapp/index.mjs b/yarn-project/end-to-end/src/sample-dapp/index.mjs index db69c2b26af..449eedace47 100644 --- a/yarn-project/end-to-end/src/sample-dapp/index.mjs +++ b/yarn-project/end-to-end/src/sample-dapp/index.mjs @@ -10,7 +10,7 @@ import { fileURLToPath } from '@aztec/foundation/url'; import { getToken } from './contracts.mjs'; -const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +const { PXE_URL = 'http://localhost:8080' } = process.env; async function showAccounts(pxe) { // docs:start:showAccounts @@ -105,7 +105,7 @@ async function mintPublicFunds(pxe) { } async function main() { - const pxe = createPXEClient(SANDBOX_URL); + const pxe = createPXEClient(PXE_URL); const { chainId } = await pxe.getNodeInfo(); console.log(`Connected to chain ${chainId}`); diff --git a/yarn-project/pxe/src/bin/index.ts b/yarn-project/pxe/src/bin/index.ts index a06d27a3f36..012742ca34d 100644 --- a/yarn-project/pxe/src/bin/index.ts +++ b/yarn-project/pxe/src/bin/index.ts @@ -6,7 +6,7 @@ import { getPXEServiceConfig } from '../config/index.js'; import { startPXEHttpServer } from '../pxe_http/index.js'; import { createPXEService } from '../pxe_service/index.js'; -const { PXE_PORT = 8081, AZTEC_NODE_RPC_URL = 'http://localhost:8079' } = process.env; +const { PXE_PORT = 8081, AZTEC_NODE_URL = 'http://localhost:8079' } = process.env; const logger = createDebugLogger('aztec:pxe_service'); @@ -17,7 +17,7 @@ async function main() { logger.info(`Setting up PXE...`); const pxeConfig = getPXEServiceConfig(); - const nodeRpcClient = createAztecNodeRpcClient(AZTEC_NODE_RPC_URL); + const nodeRpcClient = createAztecNodeRpcClient(AZTEC_NODE_URL); const pxeService = await createPXEService(nodeRpcClient, pxeConfig); const shutdown = async () => { From bbed19f77ea25a43cc5891dddc1ed6c1928a010a Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 09:55:51 +0000 Subject: [PATCH 15/24] removed unused file --- yarn-project/aztec-sandbox/src/routes.ts | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 yarn-project/aztec-sandbox/src/routes.ts diff --git a/yarn-project/aztec-sandbox/src/routes.ts b/yarn-project/aztec-sandbox/src/routes.ts deleted file mode 100644 index 0b6c67f22be..00000000000 --- a/yarn-project/aztec-sandbox/src/routes.ts +++ /dev/null @@ -1,17 +0,0 @@ -import Koa from 'koa'; -import Router from 'koa-router'; - -/** - * Creates a router for helper API endpoints of the Private eXecution Environment (PXE). - * @param aztecNode - An instance of the aztec node. - * @param config - The aztec node's configuration variables. - */ -export function createApiRouter() { - const router = new Router({ prefix: '/api' }); - router.get('/status', (ctx: Koa.Context) => { - // TODO: add `status` to Aztec node. - ctx.status = 200; - }); - - return router; -} From a501a903eefb0753d36a68803044fb0b81dcf135 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 10:01:33 +0000 Subject: [PATCH 16/24] dockerfile cleanup --- yarn-project/pxe/Dockerfile | 5 ----- 1 file changed, 5 deletions(-) diff --git a/yarn-project/pxe/Dockerfile b/yarn-project/pxe/Dockerfile index a7f6a1c7c74..49503a0d0d3 100644 --- a/yarn-project/pxe/Dockerfile +++ b/yarn-project/pxe/Dockerfile @@ -8,11 +8,6 @@ RUN if [[ -n "${COMMIT_TAG}" ]]; then \ jq --arg v ${COMMIT_TAG} '.version = $v' package.json > _temp && mv _temp package.json; \ fi -WORKDIR /usr/src/yarn-project/pxe -RUN if [[ -n "${COMMIT_TAG}" ]]; then \ - jq --arg v ${COMMIT_TAG} '.version = $v' package.json > _temp && mv _temp package.json; \ - fi - # Productionify. See comment in yarn-project-base/Dockerfile. RUN yarn cache clean && yarn workspaces focus --production From 7eafdeca0cdd6f5e5a6db2c183eb2ddf41696385 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 10:02:57 +0000 Subject: [PATCH 17/24] formatting --- yarn-project/end-to-end/src/fixtures/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/end-to-end/src/fixtures/utils.ts b/yarn-project/end-to-end/src/fixtures/utils.ts index 4d9a7d74cf4..76e89187371 100644 --- a/yarn-project/end-to-end/src/fixtures/utils.ts +++ b/yarn-project/end-to-end/src/fixtures/utils.ts @@ -70,7 +70,7 @@ const getAztecNodeUrl = () => { const url = new URL(PXE_URL); url.port = '8079'; return url.toString(); -} +}; export const waitForPXE = async (pxe: PXE, logger: DebugLogger) => { await retryUntil(async () => { From ce0478f1347daa34ede5687b808d81040f44f4f7 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 11:23:24 +0000 Subject: [PATCH 18/24] fixes --- yarn-project/aztec.js/src/sandbox/index.ts | 4 ++-- yarn-project/end-to-end/src/guides/up_quick_start.test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn-project/aztec.js/src/sandbox/index.ts b/yarn-project/aztec.js/src/sandbox/index.ts index e94cbca275c..73623f82798 100644 --- a/yarn-project/aztec.js/src/sandbox/index.ts +++ b/yarn-project/aztec.js/src/sandbox/index.ts @@ -18,7 +18,7 @@ export const INITIAL_SANDBOX_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO]; export const INITIAL_SANDBOX_ACCOUNT_CONTRACT_ABI = SchnorrAccountContractAbi; -export const { SANDBOX_URL = 'http://localhost:8080' } = process.env; +export const { PXE_URL = 'http://localhost:8080' } = process.env; /** * Gets a collection of wallets for the Aztec accounts that are initially stored in the sandbox. @@ -73,7 +73,7 @@ export async function deployInitialSandboxAccounts(pxe: PXE) { * @param pxe - The pxe client connected to the sandbox. */ export async function waitForSandbox(pxe?: PXE) { - pxe = pxe ?? createPXEClient(SANDBOX_URL); + pxe = pxe ?? createPXEClient(PXE_URL); while (true) { try { await pxe.getNodeInfo(); diff --git a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts index 1969e1cfd3d..0b28900865e 100644 --- a/yarn-project/end-to-end/src/guides/up_quick_start.test.ts +++ b/yarn-project/end-to-end/src/guides/up_quick_start.test.ts @@ -7,7 +7,7 @@ describe('guides/up_quick_start', () => { it('works', async () => { await waitForSandbox(); execSync( - `DEBUG="aztec:*" PXE_HOST=\${PXE_URL:-http://localhost:8080} PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh`, + `DEBUG="aztec:*" PXE_URL=\${PXE_URL:-http://localhost:8080} PATH=$PATH:../node_modules/.bin ./src/guides/up_quick_start.sh`, { shell: '/bin/bash', stdio: 'pipe', From 9325719c97fb61acb45b4000545b74ec835d23d7 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 13:15:28 +0000 Subject: [PATCH 19/24] fix --- docs/docs/dev_docs/cli/main.md | 2 +- yarn-project/cli/README.md | 4 ++-- yarn-project/cli/src/index.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/docs/dev_docs/cli/main.md b/docs/docs/dev_docs/cli/main.md index 4836fad27a3..8f6d0a584ce 100644 --- a/docs/docs/dev_docs/cli/main.md +++ b/docs/docs/dev_docs/cli/main.md @@ -36,7 +36,7 @@ Once installed it is invoked via: ## I have the Sandbox running, now what? -Lets first establish that we are able to communicate with the Sandbox. Most commands will require the url to the Sandbox, which defaults in the CLI to `http://localhost:8080`. You can override this as an option with each command or by setting `PXE_HOST` environment variable. +Lets first establish that we are able to communicate with the Sandbox. Most commands will require the url to the Sandbox, which defaults in the CLI to `http://localhost:8080`. You can override this as an option with each command or by setting `PXE_URL` environment variable. To test communication with the Sandbox, let's run the command: diff --git a/yarn-project/cli/README.md b/yarn-project/cli/README.md index ae1d8fd4812..fffc25a7a4b 100644 --- a/yarn-project/cli/README.md +++ b/yarn-project/cli/README.md @@ -43,14 +43,14 @@ These options are: - `PRIVATE_KEY` -> `-k, --private-key` for all commands that require a private key. - `PUBLIC_KEY` -> `-k, --public-key` for all commands that require a public key. -- `PXE_HOST` -> `-u, --rpc-url` for commands that require a PXE +- `PXE_URL` -> `-u, --rpc-url` for commands that require a PXE - `API_KEY` -> `a, --api-key` for `deploy-l1-contracts`. - `ETHEREUM_RPC_HOST` -> `-u, --rpc-url` for `deploy-l1-contracts`. So if for example you are running your Private eXecution Environment (PXE) remotely you can do: ```shell -export PXE_HOST=http://external.site/rpc:8080 +export PXE_URL=http://external.site/rpc:8080 aztec-cli deploy my_contract.json ``` diff --git a/yarn-project/cli/src/index.ts b/yarn-project/cli/src/index.ts index 962acb0aa61..cfd37b534e2 100644 --- a/yarn-project/cli/src/index.ts +++ b/yarn-project/cli/src/index.ts @@ -60,7 +60,7 @@ export function getProgram(log: LogFn, debugLogger: DebugLogger): Command { program.name('aztec-cli').description('CLI for interacting with Aztec.').version(version); const pxeOption = new Option('-u, --rpc-url ', 'URL of the PXE') - .env('PXE_HOST') + .env('PXE_URL') .default('http://localhost:8080') .makeOptionMandatory(true); From 463df4397068d5cc5eebfaceedc5e1abf9360ad0 Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 13:18:58 +0000 Subject: [PATCH 20/24] better env name --- yarn-project/aztec-sandbox/docker-compose.yml | 2 +- yarn-project/boxes/blank-react/docker-compose.yml | 2 +- yarn-project/boxes/blank/docker-compose.yml | 2 +- yarn-project/boxes/private-token/docker-compose.yml | 2 +- yarn-project/canary/scripts/docker-compose-browser.yml | 2 +- yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml | 2 +- yarn-project/canary/scripts/docker-compose.yml | 2 +- .../end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml | 2 +- .../end-to-end/scripts/docker-compose-e2e-sandbox.yml | 2 +- yarn-project/end-to-end/scripts/docker-compose.yml | 2 +- yarn-project/pxe/src/config/index.ts | 4 ++-- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/yarn-project/aztec-sandbox/docker-compose.yml b/yarn-project/aztec-sandbox/docker-compose.yml index 143c8f779ef..da0939bd062 100644 --- a/yarn-project/aztec-sandbox/docker-compose.yml +++ b/yarn-project/aztec-sandbox/docker-compose.yml @@ -20,7 +20,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/boxes/blank-react/docker-compose.yml b/yarn-project/boxes/blank-react/docker-compose.yml index e125024c37b..37a653c0fdc 100644 --- a/yarn-project/boxes/blank-react/docker-compose.yml +++ b/yarn-project/boxes/blank-react/docker-compose.yml @@ -20,7 +20,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/boxes/blank/docker-compose.yml b/yarn-project/boxes/blank/docker-compose.yml index 313e5faddef..2d8d5c5dc18 100644 --- a/yarn-project/boxes/blank/docker-compose.yml +++ b/yarn-project/boxes/blank/docker-compose.yml @@ -20,7 +20,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/boxes/private-token/docker-compose.yml b/yarn-project/boxes/private-token/docker-compose.yml index 458571a4cdc..9ad3d4e954c 100644 --- a/yarn-project/boxes/private-token/docker-compose.yml +++ b/yarn-project/boxes/private-token/docker-compose.yml @@ -20,7 +20,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 volumes: - ./log:/usr/src/yarn-project/aztec-sandbox/log:rw diff --git a/yarn-project/canary/scripts/docker-compose-browser.yml b/yarn-project/canary/scripts/docker-compose-browser.yml index 325fefec48f..bb8c3b1ecc5 100644 --- a/yarn-project/canary/scripts/docker-compose-browser.yml +++ b/yarn-project/canary/scripts/docker-compose-browser.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml index 99ba4ef692a..9fcde2a195a 100644 --- a/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/canary/scripts/docker-compose-e2e-sandbox.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/canary/scripts/docker-compose.yml b/yarn-project/canary/scripts/docker-compose.yml index cb05203150c..9dba10f56cd 100644 --- a/yarn-project/canary/scripts/docker-compose.yml +++ b/yarn-project/canary/scripts/docker-compose.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml index 36fdf0067c4..dd294ff12b1 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox-browser.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml index 063dd304f20..068ca43a231 100644 --- a/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml +++ b/yarn-project/end-to-end/scripts/docker-compose-e2e-sandbox.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} ports: diff --git a/yarn-project/end-to-end/scripts/docker-compose.yml b/yarn-project/end-to-end/scripts/docker-compose.yml index a20f4ffb02f..c9ca227d1bf 100644 --- a/yarn-project/end-to-end/scripts/docker-compose.yml +++ b/yarn-project/end-to-end/scripts/docker-compose.yml @@ -22,7 +22,7 @@ services: P2P_BLOCK_CHECK_INTERVAL_MS: 50 SEQ_TX_POLLING_INTERVAL_MS: 50 WS_BLOCK_CHECK_INTERVAL_MS: 50 - PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS: 50 + PXE_BLOCK_POLLING_INTERVAL_MS: 50 ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500 SEARCH_START_BLOCK: ${FORK_BLOCK_NUMBER:-0} command: ${TEST:-./src/e2e_deploy_contract.test.ts} diff --git a/yarn-project/pxe/src/config/index.ts b/yarn-project/pxe/src/config/index.ts index 81dab01b2ab..cf07799dab6 100644 --- a/yarn-project/pxe/src/config/index.ts +++ b/yarn-project/pxe/src/config/index.ts @@ -16,10 +16,10 @@ export interface PXEServiceConfig { * Creates an instance of PXEServiceConfig out of environment variables using sensible defaults for integration testing if not set. */ export function getPXEServiceConfig(): PXEServiceConfig { - const { PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS } = process.env; + const { PXE_BLOCK_POLLING_INTERVAL_MS } = process.env; return { - l2BlockPollingIntervalMS: PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS ? +PXE_SERVICE_BLOCK_POLLING_INTERVAL_MS : 1000, + l2BlockPollingIntervalMS: PXE_BLOCK_POLLING_INTERVAL_MS ? +PXE_BLOCK_POLLING_INTERVAL_MS : 1000, }; } From 26660eb82ef8bbee608957a382ac96c3d397831c Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 13:59:31 +0000 Subject: [PATCH 21/24] test fix --- .../src/benchmarks/bench_publish_rollup.test.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts b/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts index 8c42bafb577..dcc30279429 100644 --- a/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts +++ b/yarn-project/end-to-end/src/benchmarks/bench_publish_rollup.test.ts @@ -1,7 +1,9 @@ /* eslint-disable camelcase */ +import { AztecNodeService } from '@aztec/aztec-node'; import { AztecAddress } from '@aztec/aztec.js'; import { sleep } from '@aztec/foundation/sleep'; import { TokenContract } from '@aztec/noir-contracts/types'; +import { SequencerClient } from '@aztec/sequencer-client'; import times from 'lodash.times'; @@ -14,13 +16,18 @@ describe('benchmarks/publish_rollup', () => { let token: TokenContract; let owner: AztecAddress; let recipient: AztecAddress; + let sequencer: SequencerClient; beforeEach(async () => { context = await setup(2, { maxTxsPerBlock: 1024 }); + + if (!(context.aztecNode instanceof AztecNodeService)) throw new Error('Aztec node is not a service'); + sequencer = context.aztecNode!.getSequencer(); + [owner, recipient] = context.accounts.map(a => a.address); token = await TokenContract.deploy(context.wallet, owner).send().deployed(); await token.methods.mint_public(owner, 10000n).send().wait(); - await context.aztecNode?.getSequencer().stop(); + await sequencer.stop(); }, 60_000); it.each(ROLLUP_SIZES)( @@ -36,7 +43,7 @@ describe('benchmarks/publish_rollup', () => { // And then wait a bit more just in case await sleep(100); // Restart sequencer to process all txs together - context.aztecNode?.getSequencer().restart(); + sequencer.restart(); // Wait for the last tx to be processed await sentTxs[sentTxs.length - 1].wait({ timeout: 600_00 }); }, From 26b6e8e5271dfb4c506e6199050bf3d6802ed23e Mon Sep 17 00:00:00 2001 From: benesjan Date: Tue, 3 Oct 2023 15:35:40 +0000 Subject: [PATCH 22/24] fixes --- .circleci/config.yml | 59 ++++++++++++++++++++++++++++--- build_manifest.yml | 9 ++++- yarn-project/pxe/Dockerfile.final | 10 ++++++ 3 files changed, 73 insertions(+), 5 deletions(-) create mode 100644 yarn-project/pxe/Dockerfile.final diff --git a/.circleci/config.yml b/.circleci/config.yml index 85f8b643e8f..eefe6be22db 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -454,7 +454,44 @@ jobs: echo "export DOCKER_BUILDKIT=" > $BASH_ENV force_deploy_build aztec-sandbox false arm64 - aztec-sandbox-ecr-manifest: + pxe-base: + machine: + image: ubuntu-2204:2023.07.2 + resource_class: large + steps: + - *checkout + - *setup_env + - run: + name: "Build and test" + command: force_deploy_build pxe-base false + + pxe-x86_64: + machine: + image: ubuntu-2204:2023.07.2 + resource_class: large + steps: + - *checkout + - *setup_env + - run: + name: "Build and test" + command: force_deploy_build pxe false x86_64 + + pxe-arm64: + machine: + image: ubuntu-2204:2023.07.2 + resource_class: arm.large + steps: + - *checkout + - *setup_env + - run: + name: "Build and test" + # We need to force not to use docker buildkit because for some reason on arm only, it ends up making a call + # out to eu-west2 despite the image being locally tagged, resulting in unauthorised 401. Weird docker bug? + command: | + echo "export DOCKER_BUILDKIT=" > $BASH_ENV + force_deploy_build pxe false arm64 + + ecr-manifest: machine: image: ubuntu-2204:2023.07.2 resource_class: large @@ -463,7 +500,9 @@ jobs: - *setup_env - run: name: "Create ECR manifest" - command: create_ecr_manifest aztec-sandbox-base aztec-sandbox x86_64,arm64 + command: | + create_ecr_manifest aztec-sandbox-base aztec-sandbox x86_64,arm64 + create_ecr_manifest pxe-base pxe x86_64,arm64 boxes-blank-react: machine: @@ -1216,6 +1255,7 @@ workflows: - end-to-end: *yarn_project - aztec-sandbox-base: *yarn_project + - pxe-base: *yarn_project - canary: *yarn_project - build-docs: *yarn_project @@ -1228,10 +1268,21 @@ workflows: - aztec-sandbox-base <<: *defaults - - aztec-sandbox-ecr-manifest: + - pxe-x86_64: + requires: + - pxe-base + <<: *defaults + - pxe-arm64: + requires: + - pxe-base + <<: *defaults + + - ecr-manifest: requires: - aztec-sandbox-x86_64 - aztec-sandbox-arm64 + - pxe-x86_64 + - pxe-arm64 <<: *defaults - boxes-blank-react: @@ -1252,7 +1303,7 @@ workflows: - e2e-join: requires: - end-to-end - - aztec-sandbox-ecr-manifest + - ecr-manifest - canary <<: *defaults diff --git a/build_manifest.yml b/build_manifest.yml index f7840384a24..e62123a6888 100644 --- a/build_manifest.yml +++ b/build_manifest.yml @@ -120,13 +120,20 @@ aztec-sandbox: dependencies: - aztec-sandbox-base -pxe: +pxe-base: buildDir: yarn-project projectDir: yarn-project/pxe dockerfile: Dockerfile dependencies: - yarn-project +pxe: + buildDir: yarn-project + projectDir: yarn-project/pxe + dockerfile: Dockerfile.final + dependencies: + - pxe-base + boxes-blank-react: buildDir: yarn-project projectDir: yarn-project/boxes/blank-react diff --git a/yarn-project/pxe/Dockerfile.final b/yarn-project/pxe/Dockerfile.final new file mode 100644 index 00000000000..5f2ac5b817e --- /dev/null +++ b/yarn-project/pxe/Dockerfile.final @@ -0,0 +1,10 @@ +FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/pxe-base AS builder + +FROM node:18-alpine + +COPY --from=builder /usr/src/ /usr/src/ +WORKDIR /usr/src/yarn-project/pxe + +ENTRYPOINT ["yarn"] +CMD [ "start" ] +EXPOSE 8081 From 8c9a37b7a00ebad4bdb2d2c1a7de6ff950db3929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bene=C5=A1?= Date: Tue, 3 Oct 2023 19:05:56 +0200 Subject: [PATCH 23/24] Update yarn-project/aztec-sandbox/src/bin/index.ts Co-authored-by: spypsy --- yarn-project/aztec-sandbox/src/bin/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn-project/aztec-sandbox/src/bin/index.ts b/yarn-project/aztec-sandbox/src/bin/index.ts index e6013daf1de..184ca5ad707 100644 --- a/yarn-project/aztec-sandbox/src/bin/index.ts +++ b/yarn-project/aztec-sandbox/src/bin/index.ts @@ -55,7 +55,7 @@ async function main() { process.once('SIGINT', shutdown); process.once('SIGTERM', shutdown); - startHttpRpcServer(node, createAztecNodeRpcServer, 8079); + startHttpRpcServer(node, createAztecNodeRpcServer, AZTEC_NODE_PORT); logger.info(`Aztec Node JSON-RPC Server listening on port ${AZTEC_NODE_PORT}`); startHttpRpcServer(pxe, createPXERpcServer, PXE_PORT); logger.info(`PXE JSON-RPC Server listening on port ${PXE_PORT}`); From 5aed56c6badbda440fcde2815df63f0e366f58ea Mon Sep 17 00:00:00 2001 From: benesjan Date: Wed, 4 Oct 2023 06:53:02 +0000 Subject: [PATCH 24/24] docs fix --- yarn-project/aztec-sandbox/src/server.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/yarn-project/aztec-sandbox/src/server.ts b/yarn-project/aztec-sandbox/src/server.ts index ff7ad0be8b4..f8cc66f2198 100644 --- a/yarn-project/aztec-sandbox/src/server.ts +++ b/yarn-project/aztec-sandbox/src/server.ts @@ -5,6 +5,7 @@ import http from 'http'; /** * Creates an http server that forwards calls to the underlying instance and starts it on the given port. * @param instance - Instance to wrap in a JSON-RPC server. + * @param jsonRpcFactoryFunc - Function that wraps the instance in a JSON-RPC server. * @param port - Port to listen in. * @returns A running http server. */