Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multiple pixies 1 Sandbox #2492

Merged
merged 34 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f1ac5b1
WIP
benesjan Sep 25, 2023
4d5ffa3
docs fix
benesjan Sep 25, 2023
74e52cf
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 2, 2023
96d2c0b
fixes after merge
benesjan Oct 2, 2023
0c41bf9
renaming env vars
benesjan Oct 2, 2023
3f42e5b
updated sandbox configuration
benesjan Oct 2, 2023
73584fa
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 2, 2023
7f1085d
chore: exposing aztec node port in dockerfile
benesjan Oct 2, 2023
e8d68fb
Merge branch 'janb/multiple-rpc-servers-1-node' of https://github.com…
benesjan Oct 2, 2023
9dc1588
updated tests
benesjan Oct 2, 2023
b60cde0
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 2, 2023
5ab8488
fix
benesjan Oct 2, 2023
73cacfd
pxe dockerhub deploy
benesjan Oct 2, 2023
8ee3b62
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 3, 2023
2a60ab4
linter fix
benesjan Oct 3, 2023
8256e62
equality fix
benesjan Oct 3, 2023
5f953fc
feat: exposing 'getDataTreePath', 'getL1ToL2MessageAndIndex', 'getL1T…
benesjan Oct 3, 2023
b581220
test: making e2e_2_pxes compatible with sandbox
benesjan Oct 3, 2023
853af1d
renaming SANDBOX_URL as PXE_URL
benesjan Oct 3, 2023
bbed19f
removed unused file
benesjan Oct 3, 2023
a501a90
dockerfile cleanup
benesjan Oct 3, 2023
7eafdec
formatting
benesjan Oct 3, 2023
c10f7f8
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 3, 2023
ce0478f
fixes
benesjan Oct 3, 2023
04d06ae
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 3, 2023
9325719
fix
benesjan Oct 3, 2023
463df43
better env name
benesjan Oct 3, 2023
22debdc
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 3, 2023
26660eb
test fix
benesjan Oct 3, 2023
26b6e8e
fixes
benesjan Oct 3, 2023
8c9a37b
Update yarn-project/aztec-sandbox/src/bin/index.ts
benesjan Oct 3, 2023
5aed56c
docs fix
benesjan Oct 4, 2023
552150a
Merge branch 'master' into janb/multiple-rpc-servers-1-node
benesjan Oct 4, 2023
a828c76
Merge branch 'janb/multiple-rpc-servers-1-node' of https://github.com…
benesjan Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 78 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure you'll need the -base step, you may want to take a look at #2645


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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is abot to be removed. You will need to check the above PR to see the new pattern of arch specific builds


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
Expand All @@ -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:
Expand Down Expand Up @@ -993,7 +1032,7 @@ jobs:
name: "yarn-project"
command: yarn-project/deploy_npm.sh

deploy-dockerhub:
deploy-dockerhub-sandbox:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have a look at the deploy_npm step, it recently changed to call a single script in yarn-project which deploys all of the relevant packages.. Could we make the deploy_dockerhub step similar to that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will send a new PR.

machine:
image: ubuntu-2204:2023.07.2
resource_class: medium
Expand All @@ -1008,6 +1047,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
Expand Down Expand Up @@ -1201,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

Expand All @@ -1213,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:
Expand All @@ -1237,7 +1303,7 @@ workflows:
- e2e-join:
requires:
- end-to-end
- aztec-sandbox-ecr-manifest
- ecr-manifest
- canary
<<: *defaults

Expand Down Expand Up @@ -1322,7 +1388,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
Expand All @@ -1333,7 +1403,8 @@ workflows:

- deploy-end:
requires:
- deploy-dockerhub
- deploy-dockerhub-sandbox
- deploy-dockerhub-pxe
- deploy-npm
<<: *deploy_defaults

Expand Down
14 changes: 14 additions & 0 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ aztec-sandbox:
dependencies:
- aztec-sandbox-base

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
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/cli/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
6 changes: 5 additions & 1 deletion docs/docs/dev_docs/getting_started/sandbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
29 changes: 26 additions & 3 deletions yarn-project/aztec-node/src/aztec-node/http_rpc_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'],
benesjan marked this conversation as resolved.
Show resolved Hide resolved
['start', 'stop'],
);
return rpc;
}
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,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));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/aztec-node/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ resource "aws_ecs_task_definition" "aztec-node-1" {
"value": "production"
},
{
"name": "SERVER_PORT",
"name": "AZTEC_NODE_PORT",
"value": "80"
},
{
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-sandbox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion yarn-project/aztec-sandbox/Dockerfile.final
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ WORKDIR /usr/src/yarn-project/aztec-sandbox

ENTRYPOINT ["yarn"]
CMD [ "start" ]
EXPOSE 8080
EXPOSE 8079 8080
5 changes: 3 additions & 2 deletions yarn-project/aztec-sandbox/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,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
17 changes: 11 additions & 6 deletions yarn-project/aztec-sandbox/src/bin/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
#!/usr/bin/env -S node --no-warnings
import { createAztecNodeRpcServer } from '@aztec/aztec-node';
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 { startPXEHttpServer } 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 { startHttpRpcServer } from '../server.js';
import { github, splash } from '../splash.js';

const { SERVER_PORT = 8080 } = process.env;
const { AZTEC_NODE_PORT = 8079, PXE_PORT = 8080 } = process.env;

const logger = createDebugLogger('aztec:sandbox');

/**
* Creates the sandbox from provided config and deploys any initial L1 and L2 contracts
*/
async function createAndInitialiseSandbox() {
const { l1Contracts, pxe, stop } = await createSandbox();
const { l1Contracts, node, pxe, stop } = await createSandbox();
logger.info('Setting up test accounts...');
const accounts = await deployInitialSandboxAccounts(pxe);
return {
l1Contracts,
pxe,
node,
stop,
accounts,
};
Expand All @@ -41,7 +44,7 @@ async function main() {

logger.info(`Setting up Aztec Sandbox v${version} (nargo ${NoirVersion.tag}), please stand by...`);

const { pxe, stop, accounts } = await createAndInitialiseSandbox();
const { pxe, node, stop, accounts } = await createAndInitialiseSandbox();

const shutdown = async () => {
logger.info('Shutting down...');
Expand All @@ -52,8 +55,10 @@ async function main() {
process.once('SIGINT', shutdown);
process.once('SIGTERM', shutdown);

startPXEHttpServer(pxe, SERVER_PORT);
logger.info(`Aztec Sandbox JSON-RPC Server listening on port ${SERVER_PORT}`);
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}`);
logger.info(`Debug logs will be written to ${logPath}`);
const accountStrings = [`Initial Accounts:\n\n`];

Expand Down
17 changes: 0 additions & 17 deletions yarn-project/aztec-sandbox/src/routes.ts

This file was deleted.

Loading