-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: making testnet script write a docker compose file (#10333)
Some QoL stuff for our S&P friends. The tutorial can be simplified by using docker compose. Assuming UNIX distros and node installed, this should work out of the box: ```bash npx aztec-spartan install # creates the docker-compose config npx aztec-spartan start/stop/logs/update/etc ```
- Loading branch information
1 parent
20b88ba
commit be54cc3
Showing
10 changed files
with
644 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
|
||
# Logs | ||
|
||
logs | ||
_.log | ||
npm-debug.log_ | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Caches | ||
|
||
.cache | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
|
||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
||
# Runtime data | ||
|
||
pids | ||
_.pid | ||
_.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
|
||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
|
||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
|
||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
|
||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
|
||
bower_components | ||
|
||
# node-waf configuration | ||
|
||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
|
||
build/Release | ||
|
||
# Dependency directories | ||
|
||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
|
||
web_modules/ | ||
|
||
# TypeScript cache | ||
|
||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
|
||
.npm | ||
|
||
# Optional eslint cache | ||
|
||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
|
||
.stylelintcache | ||
|
||
# Microbundle cache | ||
|
||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
|
||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
|
||
*.tgz | ||
|
||
# Yarn Integrity file | ||
|
||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
|
||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
|
||
.parcel-cache | ||
|
||
# Next.js build output | ||
|
||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
|
||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
|
||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
|
||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
|
||
# public | ||
|
||
# vuepress build output | ||
|
||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
|
||
.temp | ||
|
||
# Docusaurus cache and generated files | ||
|
||
.docusaurus | ||
|
||
# Serverless directories | ||
|
||
.serverless/ | ||
|
||
# FuseBox cache | ||
|
||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
|
||
.dynamodb/ | ||
|
||
# TernJS port file | ||
|
||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
|
||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# IntelliJ based IDEs | ||
.idea | ||
|
||
# Finder (MacOS) folder config | ||
.DS_Store | ||
docker-compose.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
VERSION 0.7 | ||
|
||
FROM ubuntu:22.04 | ||
WORKDIR /app | ||
|
||
deps: | ||
RUN apt-get update && apt-get install -y \ | ||
curl \ | ||
git \ | ||
make \ | ||
nodejs \ | ||
npm \ | ||
unzip | ||
|
||
test-setup: | ||
FROM +deps | ||
COPY aztec-spartan.sh . | ||
RUN chmod +x aztec-spartan.sh | ||
# Mock docker and docker compose commands for testing | ||
RUN mkdir -p /usr/local/bin && \ | ||
echo '#!/bin/bash\necho "Docker command: $@"' > /usr/local/bin/docker && \ | ||
echo '#!/bin/bash\necho "Docker compose command: $@"' > /usr/local/bin/docker-compose && \ | ||
chmod +x /usr/local/bin/docker /usr/local/bin/docker-compose | ||
|
||
test-help: | ||
FROM +test-setup | ||
RUN ./aztec-spartan.sh | grep -q "Commands:" && \ | ||
echo "✅ Help command test passed" || \ | ||
(echo "❌ Help command test failed" && exit 1) | ||
|
||
test-no-config: | ||
FROM +test-setup | ||
RUN if ./aztec-spartan.sh start 2>&1 | grep -q "Configuration not found"; then \ | ||
echo "✅ No config test passed"; \ | ||
else \ | ||
echo "❌ No config test failed" && exit 1; \ | ||
fi | ||
|
||
test-install: | ||
FROM +test-setup | ||
# Test installation with CLI arguments | ||
RUN echo -e "\n\n" | ./aztec-spartan.sh config \ | ||
-p 8080 \ | ||
-p2p 40400 \ | ||
-ip 1.2.3.4 \ | ||
-k 0x00 \ | ||
-n test-validator | ||
# Verify docker-compose.yml was created and contains correct values | ||
RUN test -f docker-compose.yml && \ | ||
grep -q "name: test-validator" docker-compose.yml && \ | ||
grep -q "P2P_UDP_ANNOUNCE_ADDR=1.2.3.4:40400" docker-compose.yml && \ | ||
grep -q "AZTEC_PORT=8080" docker-compose.yml && \ | ||
grep -q "VALIDATOR_PRIVATE_KEY=0x00" docker-compose.yml && \ | ||
echo "✅ Config test passed" || \ | ||
(echo "❌ Config test failed" && exit 1) | ||
|
||
test-docker-check: | ||
FROM +deps | ||
COPY aztec-spartan.sh . | ||
RUN chmod +x aztec-spartan.sh | ||
# Remove docker to test docker installation check | ||
RUN rm -f /usr/local/bin/docker /usr/local/bin/docker-compose | ||
# Test docker check (should fail since docker is not installed) | ||
RUN if ./aztec-spartan.sh config 2>&1 | grep -q "Docker or Docker Compose not found"; then \ | ||
echo "✅ Docker check test passed"; \ | ||
else \ | ||
echo "❌ Docker check test failed" && exit 1; \ | ||
fi | ||
|
||
test-start-stop: | ||
FROM +test-setup | ||
# First install with test configuration | ||
RUN echo -e "\n\n" | ./aztec-spartan.sh config \ | ||
-p 8080 \ | ||
-p2p 40400 \ | ||
-ip 1.2.3.4 \ | ||
-k 0x00 \ | ||
-n test-validator | ||
# Test start command | ||
RUN ./aztec-spartan.sh start 2>&1 | grep -q "Starting containers" && \ | ||
echo "✅ Start command test passed" || \ | ||
(echo "❌ Start command test failed" && exit 1) | ||
# Test stop command | ||
RUN ./aztec-spartan.sh stop 2>&1 | grep -q "Stopping containers" && \ | ||
echo "✅ Stop command test passed" || \ | ||
(echo "❌ Stop command test failed" && exit 1) | ||
|
||
test-update: | ||
FROM +test-setup | ||
RUN ./aztec-spartan.sh update 2>&1 | grep -q "Pulling latest images" && \ | ||
echo "✅ Update command test passed" || \ | ||
(echo "❌ Update command test failed" && exit 1) | ||
|
||
test-all: | ||
BUILD +test-help | ||
BUILD +test-no-config | ||
BUILD +test-install | ||
BUILD +test-docker-check | ||
BUILD +test-start-stop | ||
BUILD +test-update | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Aztec Spartan | ||
|
||
This tool helps easing the entry barrier to boot an Aztec Sequencer and Prover (S&P) Testnet. | ||
|
||
![Aztec Sparta Meme](./assets/banner.jpeg) | ||
|
||
For once, there's no rocket science here. This script does the following: | ||
|
||
- Checks for the presence of Docker in your machine | ||
- Prompts you for some environment variables | ||
- Outputs a templated docker-compose file with your variables | ||
- Runs the docker compose file | ||
|
||
It should work in most UNIX-based machines. | ||
|
||
## Installation | ||
|
||
To configure a new node, create a new directory and run the install script: | ||
|
||
```bash | ||
cd val1 | ||
curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/refs/heads/master/spartan/releases/rough-rhino/create-spartan.sh | bash | ||
``` | ||
|
||
This will install `aztec-spartan.sh` in the current directory. You can now run it: | ||
|
||
```bash | ||
./aztec-spartan.sh config | ||
``` | ||
|
||
If you don't have Docker installed, the script will do it for you. It will then prompt for any required environment variables and output a `docker-compose.yml` file. | ||
|
||
You can run the command without any command to see all available options, and pass them as flags, i.e. `npx aztec-spartan config -p 8080 -p2p 40400 -n nameme`. | ||
|
||
## Running | ||
|
||
To spare you a few keystrokes, you can use `npx aztec-spartan [start/stop/logs/update]` to start, stop, output logs or pull the latest docker images. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.