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: modular CLI + aztec test #7426

Merged
merged 33 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
56c3c7e
wip
Thunkar Jul 8, 2024
b15c7af
wip
Thunkar Jul 9, 2024
9fadc9e
separate txe in bin and exports
Thunkar Jul 9, 2024
29a9bdf
dirty solution
Thunkar Jul 9, 2024
c329587
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Jul 10, 2024
f63e062
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Jul 10, 2024
188b7fe
wip
Thunkar Jul 10, 2024
235cbe7
moved to start --txe model
Thunkar Jul 10, 2024
3259d0b
fixed ports and other nits
Thunkar Jul 10, 2024
89b3587
cleanup
Thunkar Jul 10, 2024
1eac6dd
better wording
Thunkar Jul 10, 2024
a182396
wip
Thunkar Jul 11, 2024
5e70043
started using modules
Thunkar Jul 11, 2024
537c238
version fixes
Thunkar Jul 11, 2024
0a250ad
restored tsconfig
Thunkar Jul 11, 2024
fc7e610
Merge branch 'master' into gj/builder-to-cli
Thunkar Jul 11, 2024
7e7dd61
naming bins
Thunkar Jul 11, 2024
af88013
Merge branch 'gj/builder-to-cli' of github.com:AztecProtocol/aztec-pa…
Thunkar Jul 11, 2024
c844515
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Jul 12, 2024
7969d1e
trying to cleanup circular deps
Thunkar Jul 12, 2024
554bf5b
removed duplicated command and cli from earthly
Thunkar Jul 12, 2024
c60715d
fixed e2e
Thunkar Jul 12, 2024
fbfbf50
updated lock
Thunkar Jul 12, 2024
b3810c6
formatting
Thunkar Jul 12, 2024
4b6c4f3
yarn prepare
Thunkar Jul 12, 2024
34c74bf
fixes
Thunkar Jul 12, 2024
0290479
fixed formatting errors
Thunkar Jul 12, 2024
13ac1ad
added missing command injectors
Thunkar Jul 12, 2024
eeb5add
more fixes
Thunkar Jul 12, 2024
d814984
updated devnet deploy flow
Thunkar Jul 12, 2024
ca4999c
Merge branch 'master' of github.com:AztecProtocol/aztec-packages into…
Thunkar Jul 15, 2024
f832862
updated docs
Thunkar Jul 15, 2024
dcd3bff
minor doc fixes
Thunkar Jul 15, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/devnet-deploys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ jobs:
- name: Deploy L1 Contracts
if: steps.check_changes_release.outputs.result == 'true'
run: |
docker pull aztecprotocol/cli:${{ env.DEPLOY_TAG }}
docker run aztecprotocol/cli:${{ env.DEPLOY_TAG }} \
docker pull aztecprotocol/aztec:${{ env.DEPLOY_TAG }}
Thunkar marked this conversation as resolved.
Show resolved Hide resolved
docker run aztecprotocol/aztec:${{ env.DEPLOY_TAG }} \
deploy-l1-contracts -p ${{ secrets.SEQ_1_PUBLISHER_PRIVATE_KEY }} \
-u https://${{ env.DEPLOY_TAG }}-mainnet-fork.aztec.network:8545/${{ secrets.FORK_API_KEY }} \
| tee ${{ env.FILE_PATH }}
Expand Down
52 changes: 35 additions & 17 deletions aztec-up/bin/aztec
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail

# Call cli image if used with `aztec cli ...args`
if [ -n "${1-}" ] && [ "$1" != "--help" ]; then
if [ "$1" == "cli" ]; then
shift
SKIP_PORT_ASSIGNMENT=1 $(dirname $0)/.aztec-run aztecprotocol/cli "$@"
elif [ "$1" == "sandbox" ]; then
$(dirname $0)/aztec-sandbox
else
$(dirname $0)/.aztec-run aztecprotocol/aztec "$@"
fi
else
# TODO - display help message
echo
echo "Using 'aztec' CLI:"
echo " aztec start <args> - Start aztec infrastructure components. See 'aztec start --help' for detailed command info."
echo " aztec sandbox - Run a local sandbox network (same as aztec-sandbox)."
echo " aztec cli <args> - Run the aztec client CLI. See 'aztec cli --help' for detailed command info."
function get_compose {
# Favour 'docker compose', falling back on docker-compose.
CMD="docker compose"
$CMD &>/dev/null || CMD="docker-compose"
$CMD $@
}

CALLED_FROM=$PWD

if [ "${1:-}" == "test" ]; then
# Change working dir, so relative volume mounts are in the right place.
cd $(dirname $0)/..
# Compose file to use
FILE_ARG="-f $HOME/.aztec/docker-compose.test.yml"
Thunkar marked this conversation as resolved.
Show resolved Hide resolved
# Aztec contract test args for nargo
TEST_ARGS="$@ --silence-warnings --use-legacy --oracle-resolver http://aztec:8081"
get_compose -p aztec-test $FILE_ARG run -e NARGO_FOREIGN_CALL_TIMEOUT=300000 --workdir $CALLED_FROM --rm -it aztec-nargo $TEST_ARGS
elif [ $# == 2 ] && [ "$1" == "start" ] && [ "$2" == "--sandbox" ]; then
# Change working dir, so relative volume mounts are in the right place.
cd $(dirname $0)/..
# Compose file to use
FILE_ARG="-f $HOME/.aztec/docker-compose.sandbox.yml"

# Function to be executed when SIGINT is received.
cleanup() {
get_compose $FILE_ARG down
}

# Set trap to catch SIGINT and call the cleanup function.
trap cleanup SIGINT

get_compose -p sandbox $FILE_ARG up --force-recreate --remove-orphans
else
$(dirname $0)/.aztec-run aztecprotocol/aztec "$@"
fi

9 changes: 0 additions & 9 deletions aztec-up/bin/aztec-builder
Thunkar marked this conversation as resolved.
Show resolved Hide resolved

This file was deleted.

10 changes: 3 additions & 7 deletions aztec-up/bin/aztec-install
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ function title() {
echo -e "${r}"
fi
echo -e "This will install the following scripts and update your PATH if necessary:"
echo -e " ${bold}${g}aztec${r} - launches various infrastructure subsystems (node, sequencer, prover, pxe, etc)."
echo -e " ${bold}${g}aztec${r} - a collection of tools to launch subsystems and interact with the aztec network."
echo -e " ${bold}${g}aztec-nargo${r} - aztec's build of nargo, the noir compiler toolchain."
echo -e " ${bold}${g}aztec-sandbox${r} - a wrapper around docker-compose that launches services needed for sandbox testing."
echo -e " ${bold}${g}aztec-up${r} - a tool to upgrade the aztec toolchain to the latest, or specific versions."
echo -e " ${bold}${g}aztec-builder${r} - a tool to generate typescript interfaces of Noir contracts"
echo
read -p "Do you wish to continue? (y/n)" -n 1 -r
echo
Expand Down Expand Up @@ -107,11 +105,11 @@ if [ -z "${SKIP_PULL:-}" ]; then
info "Pulling aztec version $VERSION..."
pull_container aztec-nargo
pull_container aztec
pull_container aztec-builder
fi

# Download the Docker Compose file. Used by aztec.
curl -fsSL http://$INSTALL_HOST/docker-compose.yml -o $AZTEC_PATH/docker-compose.yml
curl -fsSL http://$INSTALL_HOST/docker-compose.sandbox.yml -o $AZTEC_PATH/docker-compose.sandbox.yml
curl -fsSL http://$INSTALL_HOST/docker-compose.test.yml -o $AZTEC_PATH/docker-compose.test.yml

function install_bin {
curl -fsSL http://$INSTALL_HOST/$1 -o $BIN_PATH/$1
Expand All @@ -123,10 +121,8 @@ info "Installing scripts in $BIN_PATH..."
rm -f $BIN_PATH/aztec*
install_bin .aztec-run
install_bin aztec
install_bin aztec-sandbox
install_bin aztec-up
install_bin aztec-nargo
install_bin aztec-builder

function update_path_env_var {
TARGET_DIR="${1}"
Expand Down
21 changes: 0 additions & 21 deletions aztec-up/bin/aztec-sandbox

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3"
services:
ethereum:
image: ghcr.io/foundry-rs/foundry@sha256:29ba6e34379e79c342ec02d437beb7929c9e254261e8032b17e187be71a2609f
Expand Down Expand Up @@ -36,3 +35,6 @@ services:
TEST_ACCOUNTS: ${TEST_ACCOUNTS:-true}
volumes:
- ./log:/usr/src/yarn-project/aztec/log:rw
depends_on:
- ethereum
command: "start --sandbox"
19 changes: 19 additions & 0 deletions aztec-up/bin/docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
services:
aztec:
image: "aztecprotocol/aztec"
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
volumes:
- ./log:/usr/src/yarn-project/aztec/log:rw
command: start --txe

aztec-nargo:
image: "aztecprotocol/aztec-nargo"
environment:
HOME: # Loaded from the user shell
NARGO_FOREIGN_CALL_TIMEOUT: 300000 # To avoid timeouts when many tests run at once
volumes:
- ${HOME}:${HOME}
depends_on:
- aztec
2 changes: 1 addition & 1 deletion barretenberg/acir_tests/headless-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"chalk": "^5.3.0",
"commander": "^12.0.0",
"commander": "^12.1.0",
"playwright": "^1.42.1",
"puppeteer": "^22.4.1"
},
Expand Down
14 changes: 8 additions & 6 deletions barretenberg/acir_tests/headless-test/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ function formatAndPrintLog(message: string): void {
}

const readBytecodeFile = (path: string): Uint8Array => {
const extension = path.substring(path.lastIndexOf('.') + 1);
const extension = path.substring(path.lastIndexOf(".") + 1);

if (extension == 'json') {
const encodedCircuit = JSON.parse(fs.readFileSync(path, 'utf8'));
const decompressed = gunzipSync(Uint8Array.from(atob(encodedCircuit.bytecode), c => c.charCodeAt(0)));
if (extension == "json") {
const encodedCircuit = JSON.parse(fs.readFileSync(path, "utf8"));
const decompressed = gunzipSync(
Uint8Array.from(atob(encodedCircuit.bytecode), (c) => c.charCodeAt(0))
);
return decompressed;
}

Expand All @@ -57,7 +59,7 @@ const readWitnessFile = (path: string): Uint8Array => {
};

// Set up the command-line interface
const program = new Command();
const program = new Command("headless_test");
program.option("-v, --verbose", "verbose logging");
program.option("-c, --crs-path <path>", "ignored (here for compatibility)");

Expand All @@ -84,7 +86,7 @@ program
const browsers = { chrome: chromium, firefox: firefox, webkit: webkit };

for (const [name, browserType] of Object.entries(browsers)) {
if (BROWSER && !BROWSER.split(',').includes(name)) {
if (BROWSER && !BROWSER.split(",").includes(name)) {
continue;
}
console.log(chalk.blue(`Testing ${bytecodePath} in ${name}...`));
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/ts/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ export async function vkAsFieldsUltraHonk(vkPath: string, vkeyOutputPath: string
}
}

const program = new Command();
const program = new Command('bb');

program.option('-v, --verbose', 'enable verbose logging', false);
program.option('-c, --crs-path <path>', 'set crs path', './crs');
Expand Down
5 changes: 5 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
# clean: Force a complete clean of the repo. Erases untracked files, be careful!
set -eu

if [ "$(uname)" == "Darwin" ]; then
shopt -s expand_aliases
alias clang++-16="clang++"
fi

cd "$(dirname "$0")"

CMD=${1:-}
Expand Down
1 change: 1 addition & 0 deletions boxes/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ services:

aztec:
image: aztecprotocol/aztec:${AZTEC_DOCKER_TAG:-latest}
command: 'start --sandbox'
environment:
ETHEREUM_HOST: http://ethereum:8545
CHAIN_ID: 31337
Expand Down
2 changes: 1 addition & 1 deletion boxes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@inquirer/input": "^2.0.0",
"@inquirer/select": "^2.0.0",
"axios": "^1.6.7",
"commander": "^12.0.0",
"commander": "^12.1.0",
"ora": "^8.0.1",
"pino": "^8.19.0",
"pino-pretty": "^10.3.1",
Expand Down
10 changes: 5 additions & 5 deletions boxes/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@ __metadata:
"@inquirer/select": "npm:^2.0.0"
"@playwright/test": "npm:1.42.0"
axios: "npm:^1.6.7"
commander: "npm:^12.0.0"
commander: "npm:^12.1.0"
ora: "npm:^8.0.1"
pino: "npm:^8.19.0"
pino-pretty: "npm:^10.3.1"
Expand Down Expand Up @@ -2966,10 +2966,10 @@ __metadata:
languageName: node
linkType: hard

"commander@npm:^12.0.0":
version: 12.0.0
resolution: "commander@npm:12.0.0"
checksum: e51cac1d1d0aa1f76581981d2256a9249497e08f5a370bf63b0dfc7e76a647fc8cbc3ddd507928f2bdca6c514c83834e87e2687ace2fe2fc7cc7e631bf80f83d
"commander@npm:^12.1.0":
version: 12.1.0
resolution: "commander@npm:12.1.0"
checksum: 6e1996680c083b3b897bfc1cfe1c58dfbcd9842fd43e1aaf8a795fbc237f65efcc860a3ef457b318e73f29a4f4a28f6403c3d653d021d960e4632dd45bde54a9
languageName: node
linkType: hard

Expand Down
31 changes: 0 additions & 31 deletions yarn-project/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,37 +185,6 @@ export-aztec-faucet:
ARG ARCH
SAVE IMAGE --push aztecprotocol/aztec-faucet:${DIST_TAG}${ARCH:+-$ARCH}

cli-build:
FROM +build
RUN yarn workspaces focus @aztec/cli --production && yarn cache clean
RUN rm -rf \
../noir-projects \
../l1-contracts \
../barretenberg/ts/src \
../barretenberg/ts/dest/node-cjs \
../barretenberg/ts/dest/browser \
aztec.js/dest/main.js \
end-to-end \
**/src \
**/artifacts
SAVE ARTIFACT /usr/src /usr/src

cli:
FROM ubuntu:noble
RUN apt update && apt install nodejs curl -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
COPY +cli-build/usr/src /usr/src

RUN mkdir /cache && chmod 777 /cache
ENV XDG_CACHE_HOME /cache
VOLUME "/cache"
ENTRYPOINT ["node", "--no-warnings", "/usr/src/yarn-project/cli/dest/bin/index.js"]

export-cli:
FROM +cli
ARG DIST_TAG="latest"
ARG ARCH
SAVE IMAGE --push aztecprotocol/cli:${DIST_TAG}${ARCH:+-$ARCH}

# We care about creating a slimmed down e2e image because we have to serialize it from earthly to docker for running.
end-to-end-prod:
FROM +build
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/aztec/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@aztec/builder": "workspace:^",
"@aztec/circuit-types": "workspace:^",
"@aztec/circuits.js": "workspace:^",
"@aztec/cli": "workspace:^",
"@aztec/entrypoints": "workspace:^",
"@aztec/ethereum": "workspace:^",
"@aztec/foundation": "workspace:^",
Expand All @@ -48,8 +49,9 @@
"@aztec/prover-client": "workspace:^",
"@aztec/pxe": "workspace:^",
"@aztec/telemetry-client": "workspace:^",
"@aztec/txe": "workspace:^",
"abitype": "^0.8.11",
"commander": "^11.1.0",
"commander": "^12.1.0",
"koa": "^2.14.2",
"koa-router": "^12.0.0",
"viem": "^2.7.15",
Expand Down
Empty file.
Loading
Loading