Skip to content

Commit be54cc3

Browse files
authored
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 ```
1 parent 20b88ba commit be54cc3

File tree

10 files changed

+644
-81
lines changed

10 files changed

+644
-81
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,19 @@ jobs:
875875
timeout-minutes: 40
876876
run: earthly-ci -P --no-output +test --box=${{ matrix.box }} --browser=${{ matrix.browser }} --mode=cache
877877

878+
rough-rhino-installer:
879+
needs: [configure]
880+
runs-on: ${{ needs.configure.outputs.username }}-x86
881+
steps:
882+
- uses: actions/checkout@v4
883+
with: { ref: "${{ github.event.pull_request.head.sha }}" }
884+
- uses: ./.github/ci-setup-action
885+
with:
886+
concurrency_key: rough-rhino-installer
887+
- name: Rough Rhino Installer Helper Script
888+
working-directory: ./spartan/releases/rough-rhino
889+
run: earthly-ci +test-all
890+
878891
protocol-circuits-gates-report:
879892
needs: [build, configure]
880893
if: needs.configure.outputs.non-docs == 'true' && needs.configure.outputs.non-barretenberg-cpp == 'true'

.github/workflows/publish-aztec-packages.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,18 @@ jobs:
312312
--VERSION=$VERSION \
313313
--DRY_RUN=${{ (github.event.inputs.publish == 'false') && '1' || '0' }}
314314
315+
- name: Publish spartan NPM package
316+
run: |
317+
DEPLOY_TAG=${{ env.DEPLOY_TAG }}
318+
VERSION=${DEPLOY_TAG#aztec-packages-v}
319+
earthly-ci \
320+
--no-output \
321+
--secret NPM_TOKEN=${{ env.NPM_TOKEN }} \
322+
./spartan/releases/rough-rhino+publish-npm \
323+
--DIST_TAG=latest \
324+
--VERSION=$VERSION \
325+
--DRY_RUN=${{ (github.event.inputs.publish == 'false') && '1' || '0' }}
326+
315327
publish-aztec-up:
316328
needs: [configure, publish-manifests]
317329
runs-on: ubuntu-latest
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Caches
14+
15+
.cache
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
59+
node_modules/
60+
jspm_packages/
61+
62+
# Snowpack dependency directory (https://snowpack.dev/)
63+
64+
web_modules/
65+
66+
# TypeScript cache
67+
68+
*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
72+
.npm
73+
74+
# Optional eslint cache
75+
76+
.eslintcache
77+
78+
# Optional stylelint cache
79+
80+
.stylelintcache
81+
82+
# Microbundle cache
83+
84+
.rpt2_cache/
85+
.rts2_cache_cjs/
86+
.rts2_cache_es/
87+
.rts2_cache_umd/
88+
89+
# Optional REPL history
90+
91+
.node_repl_history
92+
93+
# Output of 'npm pack'
94+
95+
*.tgz
96+
97+
# Yarn Integrity file
98+
99+
.yarn-integrity
100+
101+
# dotenv environment variable files
102+
103+
.env
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
111+
.parcel-cache
112+
113+
# Next.js build output
114+
115+
.next
116+
out
117+
118+
# Nuxt.js build / generate output
119+
120+
.nuxt
121+
dist
122+
123+
# Gatsby files
124+
125+
# Comment in the public line in if your project uses Gatsby and not Next.js
126+
127+
# https://nextjs.org/blog/next-9-1#public-directory-support
128+
129+
# public
130+
131+
# vuepress build output
132+
133+
.vuepress/dist
134+
135+
# vuepress v2.x temp and cache directory
136+
137+
.temp
138+
139+
# Docusaurus cache and generated files
140+
141+
.docusaurus
142+
143+
# Serverless directories
144+
145+
.serverless/
146+
147+
# FuseBox cache
148+
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
153+
.dynamodb/
154+
155+
# TernJS port file
156+
157+
.tern-port
158+
159+
# Stores VSCode versions used for testing VSCode extensions
160+
161+
.vscode-test
162+
163+
# yarn v2
164+
165+
.yarn/cache
166+
.yarn/unplugged
167+
.yarn/build-state.yml
168+
.yarn/install-state.gz
169+
.pnp.*
170+
171+
# IntelliJ based IDEs
172+
.idea
173+
174+
# Finder (MacOS) folder config
175+
.DS_Store
176+
docker-compose.yml
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
VERSION 0.7
2+
3+
FROM ubuntu:22.04
4+
WORKDIR /app
5+
6+
deps:
7+
RUN apt-get update && apt-get install -y \
8+
curl \
9+
git \
10+
make \
11+
nodejs \
12+
npm \
13+
unzip
14+
15+
test-setup:
16+
FROM +deps
17+
COPY aztec-spartan.sh .
18+
RUN chmod +x aztec-spartan.sh
19+
# Mock docker and docker compose commands for testing
20+
RUN mkdir -p /usr/local/bin && \
21+
echo '#!/bin/bash\necho "Docker command: $@"' > /usr/local/bin/docker && \
22+
echo '#!/bin/bash\necho "Docker compose command: $@"' > /usr/local/bin/docker-compose && \
23+
chmod +x /usr/local/bin/docker /usr/local/bin/docker-compose
24+
25+
test-help:
26+
FROM +test-setup
27+
RUN ./aztec-spartan.sh | grep -q "Commands:" && \
28+
echo "✅ Help command test passed" || \
29+
(echo "❌ Help command test failed" && exit 1)
30+
31+
test-no-config:
32+
FROM +test-setup
33+
RUN if ./aztec-spartan.sh start 2>&1 | grep -q "Configuration not found"; then \
34+
echo "✅ No config test passed"; \
35+
else \
36+
echo "❌ No config test failed" && exit 1; \
37+
fi
38+
39+
test-install:
40+
FROM +test-setup
41+
# Test installation with CLI arguments
42+
RUN echo -e "\n\n" | ./aztec-spartan.sh config \
43+
-p 8080 \
44+
-p2p 40400 \
45+
-ip 1.2.3.4 \
46+
-k 0x00 \
47+
-n test-validator
48+
# Verify docker-compose.yml was created and contains correct values
49+
RUN test -f docker-compose.yml && \
50+
grep -q "name: test-validator" docker-compose.yml && \
51+
grep -q "P2P_UDP_ANNOUNCE_ADDR=1.2.3.4:40400" docker-compose.yml && \
52+
grep -q "AZTEC_PORT=8080" docker-compose.yml && \
53+
grep -q "VALIDATOR_PRIVATE_KEY=0x00" docker-compose.yml && \
54+
echo "✅ Config test passed" || \
55+
(echo "❌ Config test failed" && exit 1)
56+
57+
test-docker-check:
58+
FROM +deps
59+
COPY aztec-spartan.sh .
60+
RUN chmod +x aztec-spartan.sh
61+
# Remove docker to test docker installation check
62+
RUN rm -f /usr/local/bin/docker /usr/local/bin/docker-compose
63+
# Test docker check (should fail since docker is not installed)
64+
RUN if ./aztec-spartan.sh config 2>&1 | grep -q "Docker or Docker Compose not found"; then \
65+
echo "✅ Docker check test passed"; \
66+
else \
67+
echo "❌ Docker check test failed" && exit 1; \
68+
fi
69+
70+
test-start-stop:
71+
FROM +test-setup
72+
# First install with test configuration
73+
RUN echo -e "\n\n" | ./aztec-spartan.sh config \
74+
-p 8080 \
75+
-p2p 40400 \
76+
-ip 1.2.3.4 \
77+
-k 0x00 \
78+
-n test-validator
79+
# Test start command
80+
RUN ./aztec-spartan.sh start 2>&1 | grep -q "Starting containers" && \
81+
echo "✅ Start command test passed" || \
82+
(echo "❌ Start command test failed" && exit 1)
83+
# Test stop command
84+
RUN ./aztec-spartan.sh stop 2>&1 | grep -q "Stopping containers" && \
85+
echo "✅ Stop command test passed" || \
86+
(echo "❌ Stop command test failed" && exit 1)
87+
88+
test-update:
89+
FROM +test-setup
90+
RUN ./aztec-spartan.sh update 2>&1 | grep -q "Pulling latest images" && \
91+
echo "✅ Update command test passed" || \
92+
(echo "❌ Update command test failed" && exit 1)
93+
94+
test-all:
95+
BUILD +test-help
96+
BUILD +test-no-config
97+
BUILD +test-install
98+
BUILD +test-docker-check
99+
BUILD +test-start-stop
100+
BUILD +test-update
101+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Aztec Spartan
2+
3+
This tool helps easing the entry barrier to boot an Aztec Sequencer and Prover (S&P) Testnet.
4+
5+
![Aztec Sparta Meme](./assets/banner.jpeg)
6+
7+
For once, there's no rocket science here. This script does the following:
8+
9+
- Checks for the presence of Docker in your machine
10+
- Prompts you for some environment variables
11+
- Outputs a templated docker-compose file with your variables
12+
- Runs the docker compose file
13+
14+
It should work in most UNIX-based machines.
15+
16+
## Installation
17+
18+
To configure a new node, create a new directory and run the install script:
19+
20+
```bash
21+
cd val1
22+
curl -L https://raw.githubusercontent.com/AztecProtocol/aztec-packages/refs/heads/master/spartan/releases/rough-rhino/create-spartan.sh | bash
23+
```
24+
25+
This will install `aztec-spartan.sh` in the current directory. You can now run it:
26+
27+
```bash
28+
./aztec-spartan.sh config
29+
```
30+
31+
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.
32+
33+
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`.
34+
35+
## Running
36+
37+
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.
66.8 KB
Loading

0 commit comments

Comments
 (0)