Skip to content

Commit

Permalink
feat: making testnet script write a docker compose file (#10333)
Browse files Browse the repository at this point in the history
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
signorecello authored Dec 4, 2024
1 parent 20b88ba commit be54cc3
Show file tree
Hide file tree
Showing 10 changed files with 644 additions and 81 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,19 @@ jobs:
timeout-minutes: 40
run: earthly-ci -P --no-output +test --box=${{ matrix.box }} --browser=${{ matrix.browser }} --mode=cache

rough-rhino-installer:
needs: [configure]
runs-on: ${{ needs.configure.outputs.username }}-x86
steps:
- uses: actions/checkout@v4
with: { ref: "${{ github.event.pull_request.head.sha }}" }
- uses: ./.github/ci-setup-action
with:
concurrency_key: rough-rhino-installer
- name: Rough Rhino Installer Helper Script
working-directory: ./spartan/releases/rough-rhino
run: earthly-ci +test-all

protocol-circuits-gates-report:
needs: [build, configure]
if: needs.configure.outputs.non-docs == 'true' && needs.configure.outputs.non-barretenberg-cpp == 'true'
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/publish-aztec-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ jobs:
--VERSION=$VERSION \
--DRY_RUN=${{ (github.event.inputs.publish == 'false') && '1' || '0' }}
- name: Publish spartan NPM package
run: |
DEPLOY_TAG=${{ env.DEPLOY_TAG }}
VERSION=${DEPLOY_TAG#aztec-packages-v}
earthly-ci \
--no-output \
--secret NPM_TOKEN=${{ env.NPM_TOKEN }} \
./spartan/releases/rough-rhino+publish-npm \
--DIST_TAG=latest \
--VERSION=$VERSION \
--DRY_RUN=${{ (github.event.inputs.publish == 'false') && '1' || '0' }}
publish-aztec-up:
needs: [configure, publish-manifests]
runs-on: ubuntu-latest
Expand Down
176 changes: 176 additions & 0 deletions spartan/releases/rough-rhino/.gitignore
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
101 changes: 101 additions & 0 deletions spartan/releases/rough-rhino/Earthfile
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

37 changes: 37 additions & 0 deletions spartan/releases/rough-rhino/README.md
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.
Binary file added spartan/releases/rough-rhino/assets/banner.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit be54cc3

Please sign in to comment.