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: add boxes to CI #2456

Merged
merged 65 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
09421ab
readd circleci, add a dockerfile
dan-aztec Sep 21, 2023
04747af
whitespace
dan-aztec Sep 21, 2023
683c54e
try a wildcard in build_manifest
dan-aztec Sep 21, 2023
684289e
just try building blank-react
dan-aztec Sep 21, 2023
04dd89f
update the projectDir
dan-aztec Sep 21, 2023
e3512b7
[debug ci] blank liens
dan-aztec Sep 21, 2023
e13e4cd
fix circleci job name
dan-aztec Sep 21, 2023
da694eb
[debug ci]
dan-aztec Sep 21, 2023
656afe3
re-add yarn build
dan-aztec Sep 21, 2023
452d036
copy for circuits.js, add dep
dan-aztec Sep 21, 2023
788f94d
move from
dan-aztec Sep 21, 2023
c81e1a3
yarn first
dan-aztec Sep 21, 2023
929a541
revert bad
dan-aztec Sep 21, 2023
9b3e1e2
tsc -b first
dan-aztec Sep 21, 2023
2499ff5
formatting
dan-aztec Sep 21, 2023
7920a3a
add aztec/types
dan-aztec Sep 21, 2023
9c88e82
revert wasm direct copy
dan-aztec Sep 21, 2023
9dd1052
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 21, 2023
ffc25bc
add yarn test to the dockerfile
dan-aztec Sep 21, 2023
bc4eda7
just build, no test
dan-aztec Sep 22, 2023
ab3352a
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 22, 2023
a114d09
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 22, 2023
d02457b
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 22, 2023
26cf2be
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 25, 2023
0876733
try to copy e2e to run tests on sandbox
dan-aztec Sep 25, 2023
851cadc
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 25, 2023
998af17
revert bad merge
dan-aztec Sep 25, 2023
14471be
one more revert
dan-aztec Sep 25, 2023
183cfe8
add script
dan-aztec Sep 25, 2023
60e059b
use run_script
dan-aztec Sep 25, 2023
3bc69a0
try -
dan-aztec Sep 25, 2023
b3db1e4
use updated ecr command
dan-aztec Sep 25, 2023
5dc0aee
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 25, 2023
3169d85
somehow file was uncomitted
dan-aztec Sep 25, 2023
38a4cea
fix the envvar
dan-aztec Sep 25, 2023
ae2fe2e
ugh
dan-aztec Sep 25, 2023
01525cf
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 25, 2023
d130c52
adam fixes everything
dan-aztec Sep 25, 2023
edc5479
bad copy
dan-aztec Sep 25, 2023
47aa06e
just use entrypoint
dan-aztec Sep 25, 2023
3854364
dont prune dev deps
dan-aztec Sep 25, 2023
81d9e63
Merge remote-tracking branch 'origin/master' into dan/2455-add-boxes-…
dan-aztec Sep 25, 2023
397f9e7
merge
dan-aztec Sep 25, 2023
11cba28
Revert "merge"
dan-aztec Sep 25, 2023
eed1c75
re-add job
dan-aztec Sep 25, 2023
67b9c1c
bad line
dan-aztec Sep 25, 2023
14be304
depend on yarn megajob
dan-aztec Sep 25, 2023
33775f9
use updated image
dan-aztec Sep 25, 2023
38ee7f5
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 25, 2023
c2f78d8
try to use universal image
dan-aztec Sep 25, 2023
a39b447
depend on aztec-sandbox job so image is ready
dan-aztec Sep 25, 2023
f41746a
fix docker compose
dan-aztec Sep 25, 2023
f92e6a1
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 25, 2023
070ccb9
add docker-pose files and update package.json
dan-aztec Sep 26, 2023
3b62679
also run noirup
dan-aztec Sep 26, 2023
914e94f
update test command
dan-aztec Sep 26, 2023
b3a3910
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 26, 2023
b51b813
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 26, 2023
cdfeb81
add other boxes to jobz
dan-aztec Sep 26, 2023
c478808
conditional usage of dom to allow node test to import
dan-aztec Sep 26, 2023
94cfced
Merge branch 'master' into dan/2455-add-boxes-to-ci
dan-aztec Sep 26, 2023
cd3bc40
small readme fix
dan-aztec Sep 26, 2023
74682b9
switch to local link for contractABI
dan-aztec Sep 26, 2023
f54af0c
revert noir-contracts
dan-aztec Sep 26, 2023
bf4e75a
revert more noir-contracts
dan-aztec Sep 26, 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
48 changes: 48 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,39 @@ jobs:
name: "Create ECR manifest"
command: create_ecr_manifest aztec-sandbox-base aztec-sandbox x86_64,arm64

boxes-blank-react:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Test via adhoc script"
command: ./yarn-project/boxes/blank-react/run_tests

boxes-blank:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Test via adhoc script"
command: ./yarn-project/boxes/blank/run_tests

boxes-private-token:
machine:
image: ubuntu-2204:2023.07.2
resource_class: large
steps:
- *checkout
- *setup_env
- run:
name: "Test via adhoc script"
command: ./yarn-project/boxes/private-token/run_tests

canary:
machine:
image: ubuntu-2204:2023.07.2
Expand Down Expand Up @@ -1131,6 +1164,21 @@ workflows:
- aztec-sandbox-arm64
<<: *defaults

- boxes-blank-react:
requires:
- aztec-sandbox-x86_64
<<: *defaults

- boxes-blank:
requires:
- aztec-sandbox-x86_64
<<: *defaults

- boxes-private-token:
requires:
- aztec-sandbox-x86_64
<<: *defaults

- e2e-join:
requires:
- end-to-end
Expand Down
18 changes: 18 additions & 0 deletions build_manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ aztec-sandbox:
dependencies:
- aztec-sandbox-base

boxes-blank-react:
buildDir: yarn-project
projectDir: yarn-project/boxes/blank-react
dependencies:
- aztec-sandbox

boxes-blank:
buildDir: yarn-project
projectDir: yarn-project/boxes/blank
dependencies:
- aztec-sandbox

boxes-private-token:
buildDir: yarn-project
projectDir: yarn-project/boxes/private-token
dependencies:
- aztec-sandbox

canary-build:
buildDir: yarn-project
projectDir: yarn-project/canary
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/boxes/blank-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn install:sandbox

This sandbox requires [Docker](https://www.docker.com/) to be installed _and running_ locally. In the event the image needs updating, you can run `yarn install:sandbox` (see [sandbox docs](https://aztec-docs-dev.netlify.app/dev_docs/getting_started/sandbox) for more information.)

In addition to the usual javascript dependencies, this project requires `nargo` (package manager) and `noir` (Aztec ZK smart contract language) in addition to `@aztec/aztec-cli`. The former are installed within `yarn install:noir`
In addition to the usual javascript dependencies, this project requires `nargo` (package manager) and `noir` (Aztec ZK smart contract language) in addition to `@aztec/aztec-cli`. The former two are installed by `yarn install:noir`.

## Getting started

Expand Down Expand Up @@ -44,7 +44,8 @@ This folder should have the following directory structure:
|— blank.ts
|— tests
| A simple end2end test deploying and testing the Blank contract deploys on a local sandbox
| The test requires the sandbox and anvil to be running (yarn start:sandbox).
| The test requires the sandbox and anvil to be running (`yarn start:sandbox`).
| You can run the tests with `yarn test:integration`
|- blank.contract.test.ts
```

Expand Down
34 changes: 34 additions & 0 deletions yarn-project/boxes/blank-react/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3'
services:
ethereum:
image: ghcr.io/foundry-rs/foundry:v1.0.0
command: '"anvil --silent -p 8545 --host 0.0.0.0 --chain-id 31337"'
ports:
- '${SANDBOX_ANVIL_PORT:-8545}:8545'

aztec:
image: 'aztecprotocol/aztec-sandbox:${SANDBOX_VERSION:-latest}'
ports:
- '${SANDBOX_RPC_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
ETHEREUM_HOST: http://ethereum:8545
CHAIN_ID: 31337
ARCHIVER_POLLING_INTERVAL_MS: 50
P2P_BLOCK_CHECK_INTERVAL_MS: 50
SEQ_TX_POLLING_INTERVAL_MS: 50
WS_BLOCK_CHECK_INTERVAL_MS: 50
RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50
ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500
volumes:
- ./log:/usr/src/yarn-project/aztec-sandbox/log:rw

boxes-blank-react:
image: aztecprotocol/yarn-project:latest
entrypoint: sh
command: -c "cd boxes/blank-react && yarn test:integration"
environment:
ETHEREUM_HOST: http://ethereum:8545
CHAIN_ID: 31337
SANDBOX_URL: http://aztec:8080
5 changes: 2 additions & 3 deletions yarn-project/boxes/blank-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"main": "./dest/index.js",
"scripts": {
"build": "yarn clean && webpack",
"build": "yarn clean && tsc -b && webpack",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v aztec",
"install:sandbox": "docker pull aztecprotocol/aztec-sandbox:latest",
"clean": "rm -rf ./dest .tsbuildinfo",
Expand All @@ -15,8 +15,7 @@
"formatting": "prettier --check ./src && eslint ./src",
"formatting:fix": "prettier -w ./src",
"compile": "aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts",
"test": "true #FIX THIS #NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test\" \"anvil\""
"test:integration": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand"
},
"jest": {
"preset": "ts-jest/presets/default-esm",
Expand Down
21 changes: 21 additions & 0 deletions yarn-project/boxes/blank-react/run_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This script is used to run an e2e test in CI (see .circleci/config.yml).
# It pulls images and runs docker-compose, which has the test as the entrypoint.
[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -eu

# Run in script path.
cd `dirname $0`

export COMPOSE_FILE=${1:-docker-compose.yml}

ecr_login

for REPO in aztec-sandbox yarn-project; do
echo "pulling docker image for $REPO $(calculate_image_uri $REPO)"
retry docker pull $(calculate_image_uri $REPO)
retry docker tag $(calculate_image_uri $REPO) aztecprotocol/$REPO:latest
done

docker-compose rm -f
docker-compose -f $COMPOSE_FILE up --exit-code-from boxes-blank-react
2 changes: 1 addition & 1 deletion yarn-project/boxes/blank/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ yarn install:sandbox

This sandbox requires [Docker](https://www.docker.com/) to be installed _and running_ locally. In the event the image needs updating, you can run `yarn install:sandbox` (see [sandbox docs](https://aztec-docs-dev.netlify.app/dev_docs/getting_started/sandbox) for more information.)

In addition to the usual javascript dependencies, this project requires `nargo` (package manager) and `noir` (a Domain Specific Language for SNARK proving systems) in addition to `@aztec/aztec-cli`. The former are installed within `yarn install:noir`
In addition to the usual javascript dependencies, this project requires `nargo` (package manager) and `noir` (a Domain Specific Language for SNARK proving systems) in addition to `@aztec/aztec-cli`. The former are installed within `yarn install:noir`.

## Getting started

Expand Down
34 changes: 34 additions & 0 deletions yarn-project/boxes/blank/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3'
services:
ethereum:
image: ghcr.io/foundry-rs/foundry:v1.0.0
command: '"anvil --silent -p 8545 --host 0.0.0.0 --chain-id 31337"'
ports:
- '${SANDBOX_ANVIL_PORT:-8545}:8545'

aztec:
image: 'aztecprotocol/aztec-sandbox:${SANDBOX_VERSION:-latest}'
ports:
- '${SANDBOX_RPC_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
ETHEREUM_HOST: http://ethereum:8545
CHAIN_ID: 31337
ARCHIVER_POLLING_INTERVAL_MS: 50
P2P_BLOCK_CHECK_INTERVAL_MS: 50
SEQ_TX_POLLING_INTERVAL_MS: 50
WS_BLOCK_CHECK_INTERVAL_MS: 50
RPC_SERVER_BLOCK_POLLING_INTERVAL_MS: 50
ARCHIVER_VIEM_POLLING_INTERVAL_MS: 500
volumes:
- ./log:/usr/src/yarn-project/aztec-sandbox/log:rw

boxes-blank:
image: aztecprotocol/yarn-project:latest
entrypoint: sh
command: -c "cd boxes/blank && yarn test:integration"
environment:
ETHEREUM_HOST: http://ethereum:8545
CHAIN_ID: 31337
SANDBOX_URL: http://aztec:8080
17 changes: 8 additions & 9 deletions yarn-project/boxes/blank/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"main": "./dest/index.js",
"scripts": {
"build": "yarn clean && webpack",
"build": "yarn clean && tsc -b && webpack",
"install:noir": "curl -L https://raw.githubusercontent.com/noir-lang/noirup/main/install | bash noirup -v aztec",
"install:sandbox": "docker pull aztecprotocol/aztec-sandbox:latest",
"clean": "rm -rf ./dest .tsbuildinfo",
Expand All @@ -15,18 +15,17 @@
"formatting": "prettier --check ./src && eslint ./src",
"formatting:fix": "prettier -w ./src",
"compile": "aztec-cli compile src/contracts --outdir ../artifacts --typescript ../artifacts",
"test": "true #NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test\" \"anvil\""
"test:integration": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand"
},
"jest": {
"preset": "ts-jest/presets/default-esm",
"globals": {
"ts-jest": {
"useESM": true
}
},
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"useESM": true
}
]
},
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
Expand Down
21 changes: 21 additions & 0 deletions yarn-project/boxes/blank/run_tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# This script is used to run an e2e type test in CI (see .circleci/config.yml).
# It pulls images and runs docker-compose, which has the test as the entrypoint.
[ -n "${BUILD_SYSTEM_DEBUG:-}" ] && set -x # conditionally trace
set -eu

# Run in script path.
cd `dirname $0`

export COMPOSE_FILE=${1:-docker-compose.yml}

ecr_login

for REPO in aztec-sandbox yarn-project; do
echo "pulling docker image for $REPO $(calculate_image_uri $REPO)"
retry docker pull $(calculate_image_uri $REPO)
retry docker tag $(calculate_image_uri $REPO) aztecprotocol/$REPO:latest
done

docker-compose rm -f
docker-compose -f $COMPOSE_FILE up --exit-code-from boxes-blank
33 changes: 23 additions & 10 deletions yarn-project/boxes/blank/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import {
Contract,
DeployMethod,
Fr,
TxReceipt,
createAztecRpcClient,
getSandboxAccountsWallets,
} from '@aztec/aztec.js';
import { ContractAbi, FunctionAbi, encodeArguments } from '@aztec/foundation/abi';
import { FieldsOf } from '@aztec/foundation/types';
import { BlankContractAbi } from './artifacts/blank.js';
export const contractAbi: ContractAbi = BlankContractAbi;

Expand All @@ -23,8 +25,20 @@ export const DEFAULT_PUBLIC_ADDRESS: string = '0x25048e8c1b7dea68053d597ac2d9206

let contractAddress: string = '';

// interaction with the buttons
document.getElementById('deploy')?.addEventListener('click', async () => {
// interaction with the buttons, but conditional check so node env can also import from this file
if (typeof document !== 'undefined') {
document.getElementById('deploy')?.addEventListener('click', async () => {
contractAddress = await handleDeployClick();
console.log('Deploy Succeeded, contract deployed at', contractAddress);
});

document.getElementById('interact')?.addEventListener('click', async () => {
const interactionResult = await handleInteractClick(contractAddress);
console.log('Interaction transaction succeeded', interactionResult);
});
}

export async function handleDeployClick(): Promise<string> {
console.log('Deploying Contract');
const [wallet, ..._rest] = await getSandboxAccountsWallets(rpcClient);

Expand All @@ -35,28 +49,27 @@ document.getElementById('deploy')?.addEventListener('click', async () => {
Fr.random(),
rpcClient,
);
contractAddress = contractAztecAddress.toString();
console.log('Deploy Succeeded, contract deployed at', contractAddress);
});

document.getElementById('interact')?.addEventListener('click', async () => {
return contractAztecAddress.toString();
}

export async function handleInteractClick(contractAddress: string) {
const [wallet, ..._rest] = await getSandboxAccountsWallets(rpcClient);
const callArgs = { address: wallet.getCompleteAddress().address };
const getPkAbi = getFunctionAbi(BlankContractAbi, 'getPublicKey');
const typedArgs = convertArgs(getPkAbi, callArgs);
console.log('Interacting with Contract');

const call = await callContractFunction(
return await callContractFunction(
AztecAddress.fromString(contractAddress),
contractAbi,
'getPublicKey',
typedArgs,
rpcClient,
wallet.getCompleteAddress(),
);
}

console.log('transaction outcome:', call);
});

export const getFunctionAbi = (contractAbi: any, functionName: string) => {
const functionAbi = contractAbi.functions.find((f: FunctionAbi) => f.name === functionName);
Expand All @@ -71,7 +84,7 @@ export async function callContractFunction(
typedArgs: any[], // for the exposed functions, this is an array of field elements Fr[]
rpc: AztecRPC,
wallet: CompleteAddress,
) {
): Promise<FieldsOf<TxReceipt>> {
// selectedWallet is how we specify the "sender" of the transaction
const selectedWallet = await getWallet(wallet, rpc);

Expand Down
15 changes: 0 additions & 15 deletions yarn-project/boxes/private-token/Dockerfile

This file was deleted.

Loading