Skip to content

Commit 948a4be

Browse files
authored
Merge pull request #181 from AztecProtocol/chore/upgrade-aztec-2.0.2
same code works on sandbox and testnet + tests + ci workflow
2 parents 8c6db75 + 5c315b1 commit 948a4be

20 files changed

+467
-165
lines changed

.env-example

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
L1_URL=https://ethereum-sepolia-rpc.publicnode.com
2-
NODE_URL="https://aztec-alpha-testnet-fullnode.zkv.xyz" # testnet
31
VOTING_CONTRACT_ADDRESS="0x2320c9938b3e87feb4e475413456d028572f3367e18d61e7d198d342b557f297"
42
SECRET="0x29aa7f43021f964fe46527ff4df0e9211de94274f54eff12ec81070ee3e16300"
5-
SALT="0x23c46f2dd4450fb881f0b0e70c3974f84dfa9d199493001b3fe8eb136dc612cd"
6-
7-
L1_CHAIN_ID="11155111" # Sepolia
3+
SALT="0x23c46f2dd4450fb881f0b0e70c3974f84dfa9d199493001b3fe8eb136dc612cd"
Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
name: Run Tests and Scripts
1+
name: Sandbox Tests
22

33
on:
44
push:
55
branches:
66
- main
7+
- dev
78
pull_request:
89
branches:
910
- main
1011
- dev
12+
workflow_dispatch:
1113

1214
jobs:
13-
setup-and-run:
15+
sandbox-tests:
16+
name: Sandbox Tests
1417
runs-on: ubuntu-latest
18+
env:
19+
AZTEC_ENV: sandbox
1520

1621
steps:
1722
- name: Checkout repository
@@ -21,10 +26,10 @@ jobs:
2126
uses: actions/setup-node@v4
2227
with:
2328
node-version: "22"
24-
cache: "yarn" # Optional: cache dependencies for faster builds
29+
cache: "yarn"
2530

2631
- name: Set up Docker
27-
uses: docker/setup-buildx-action@v2
32+
uses: docker/setup-buildx-action@v3
2833

2934
- name: Install Aztec CLI
3035
run: |
@@ -39,28 +44,43 @@ jobs:
3944
VERSION=2.0.2 aztec-up
4045
aztec start --sandbox &
4146
47+
- name: Wait for sandbox to be ready
48+
run: |
49+
echo "Waiting for sandbox to start..."
50+
for i in {1..30}; do
51+
if curl -s http://localhost:8080/status >/dev/null 2>&1; then
52+
echo "✅ Sandbox is ready!"
53+
break
54+
fi
55+
echo "Waiting... ($i/30)"
56+
sleep 5
57+
done
58+
4259
- name: Install project dependencies
4360
run: yarn
4461

45-
- name: Compile, generate code, and run tests
62+
- name: Compile contracts
4663
run: script -e -c "${AZTEC_NARGO:-aztec-nargo} compile"
4764

48-
- name: Codegen
65+
- name: Generate contract artifacts
4966
run: script -e -c "aztec codegen target --outdir src/artifacts && aztec-postprocess-contract"
5067

51-
- name: Change ownership # to get around Docker issues
68+
- name: Change ownership for nargo files
5269
run: sudo chown -R $(whoami) ~/nargo && sudo chown -R $(whoami) ~/nargo/github.com
5370

54-
- name: Run tests
55-
run: script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json && aztec test"
71+
- name: Run JavaScript tests
72+
run: |
73+
script -e -c "rm -rf store/pxe"
74+
script -e -c "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json"
75+
76+
- name: Run Aztec tests
77+
run: script -e -c "aztec test"
5678

57-
- name: Deploy account and capture SECRET/SIGNING_KEY/SALT
79+
- name: Deploy account and capture credentials
5880
run: |
5981
script -e -c "yarn clear-store"
60-
# Create a temporary file to store the output
6182
TEMP_OUTPUT=$(mktemp)
6283
63-
# Run deploy-account script and capture both stdout and stderr
6484
if script -e -c "yarn deploy-account" > "$TEMP_OUTPUT" 2>&1; then
6585
echo "✅ Deploy account script completed successfully"
6686
else
@@ -70,40 +90,28 @@ jobs:
7090
exit 1
7191
fi
7292
73-
# Show the full output for debugging
7493
cat "$TEMP_OUTPUT"
7594
76-
# Extract SECRET, SIGNING_KEY, and SALT from the output
7795
SECRET_KEY=$(grep -o "🔑 Secret key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🔑 Secret key generated: //' || echo "")
7896
SIGNING_KEY=$(grep -o "🖊️ Signing key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🖊️ Signing key generated: //' || echo "")
7997
SALT_VALUE=$(grep -o "🧂 Salt generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🧂 Salt generated: //' || echo "")
8098
81-
# Clean up temp file
8299
rm "$TEMP_OUTPUT"
83100
84-
# Validate and create .env file
85101
if [ -n "$SECRET_KEY" ] && [ -n "$SIGNING_KEY" ] && [ -n "$SALT_VALUE" ]; then
86-
87-
# Create .env file with all necessary values
88102
echo "SECRET=\"$SECRET_KEY\"" >> .env
89103
echo "SIGNING_KEY=\"$SIGNING_KEY\"" >> .env
90104
echo "SALT=\"$SALT_VALUE\"" >> .env
91-
echo "📋 Current .env file contents:"
92-
cat .env
105+
echo "📋 Saved credentials to .env file"
93106
else
94-
echo "❌ Failed to extract SECRET, SIGNING_KEY and/or SALT from deploy output"
95-
echo "🔍 SECRET_KEY: '$SECRET_KEY'"
96-
echo "🔍 SIGNING_KEY: '$SIGNING_KEY'"
97-
echo "🔍 SALT_VALUE: '$SALT_VALUE'"
107+
echo "❌ Failed to extract SECRET, SIGNING_KEY, and/or SALT from deploy output"
98108
exit 1
99109
fi
100110
101111
- name: Deploy contract and capture address
102112
run: |
103-
# Create a temporary file to store the output
104113
TEMP_OUTPUT=$(mktemp)
105114
106-
# Run deploy script and capture both stdout and stderr
107115
if script -e -c "yarn deploy" > "$TEMP_OUTPUT" 2>&1; then
108116
echo "✅ Deploy script completed successfully"
109117
else
@@ -112,28 +120,23 @@ jobs:
112120
exit 1
113121
fi
114122
115-
# Show the full output for debugging
116123
cat "$TEMP_OUTPUT"
117124
118-
# Try multiple extraction patterns in order of preference
119125
VOTING_CONTRACT_ADDRESS=""
120-
121-
# Look for "Contract address:" pattern
122126
if [ -z "$VOTING_CONTRACT_ADDRESS" ]; then
123127
VOTING_CONTRACT_ADDRESS=$(grep -o "Contract address: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/Contract address: //' || echo "")
124128
fi
125129
126-
# Clean up temp file
127130
rm "$TEMP_OUTPUT"
128131
129-
# Validate and save the address
130132
if [ -n "$VOTING_CONTRACT_ADDRESS" ]; then
131133
echo "VOTING_CONTRACT_ADDRESS=\"$VOTING_CONTRACT_ADDRESS\"" >> .env
134+
echo "📋 Saved contract address to .env file"
132135
fi
133136
134-
- name: Run other scripts
137+
- name: Run sandbox scripts
135138
run: |
136139
script -e -c "yarn fees"
137140
script -e -c "yarn multiple-pxe"
138141
script -e -c "yarn profile"
139-
script -e -c "yarn interaction-existing-contract"
142+
script -e -c "yarn interaction-existing-contract"

.github/workflows/testnet.yaml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Testnet Tests
2+
3+
on:
4+
schedule:
5+
- cron: '0 2 * * *'
6+
workflow_dispatch:
7+
inputs:
8+
skip_deployment:
9+
description: "Skip deployment and use existing contracts"
10+
required: false
11+
type: boolean
12+
default: false
13+
14+
jobs:
15+
testnet-tests:
16+
name: Testnet Tests
17+
runs-on: ubuntu-latest
18+
env:
19+
AZTEC_ENV: testnet
20+
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v5
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "22"
29+
cache: "yarn"
30+
31+
- name: Install Aztec CLI
32+
run: |
33+
curl -s https://install.aztec.network > tmp.sh
34+
bash tmp.sh <<< yes "yes"
35+
36+
- name: Update path
37+
run: echo "/home/runner/.aztec/bin" >> $GITHUB_PATH
38+
39+
- name: Install project dependencies
40+
run: yarn
41+
42+
- name: Compile contracts
43+
run: script -e -c "${AZTEC_NARGO:-aztec-nargo} compile"
44+
45+
- name: Generate contract artifacts
46+
run: script -e -c "aztec codegen target --outdir src/artifacts && aztec-postprocess-contract"
47+
48+
- name: Setup testnet environment
49+
run: |
50+
echo "📋 Using testnet configuration from config/testnet.json"
51+
cat config/testnet.json
52+
53+
- name: Test testnet connectivity
54+
run: |
55+
echo "Testing testnet connectivity..."
56+
curl -s https://aztec-testnet-fullnode.zkv.xyz/status || echo "Warning: Could not connect to testnet"
57+
58+
- name: Deploy account to testnet
59+
if: ${{ !inputs.skip_deployment }}
60+
run: |
61+
TEMP_OUTPUT=$(mktemp)
62+
63+
if script -e -c "yarn deploy-account::testnet" > "$TEMP_OUTPUT" 2>&1; then
64+
echo "✅ Deploy account to testnet completed successfully"
65+
else
66+
echo "❌ Deploy account script failed"
67+
cat "$TEMP_OUTPUT"
68+
rm "$TEMP_OUTPUT"
69+
exit 1
70+
fi
71+
72+
cat "$TEMP_OUTPUT"
73+
74+
SECRET_KEY=$(grep -o "🔑 Secret key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🔑 Secret key generated: //' || echo "")
75+
SIGNING_KEY=$(grep -o "🖊️ Signing key generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🖊️ Signing key generated: //' || echo "")
76+
SALT_VALUE=$(grep -o "🧂 Salt generated: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/🧂 Salt generated: //' || echo "")
77+
78+
rm "$TEMP_OUTPUT"
79+
80+
if [ -n "$SECRET_KEY" ] && [ -n "$SIGNING_KEY" ] && [ -n "$SALT_VALUE" ]; then
81+
echo "SECRET=\"$SECRET_KEY\"" >> .env
82+
echo "SIGNING_KEY=\"$SIGNING_KEY\"" >> .env
83+
echo "SALT=\"$SALT_VALUE\"" >> .env
84+
echo "📋 Saved credentials to .env file"
85+
else
86+
echo "❌ Failed to extract SECRET, SIGNING_KEY, and/or SALT from deploy output"
87+
exit 1
88+
fi
89+
90+
- name: Deploy contract to testnet
91+
if: ${{ !inputs.skip_deployment }}
92+
run: |
93+
TEMP_OUTPUT=$(mktemp)
94+
95+
if script -e -c "yarn deploy::testnet" > "$TEMP_OUTPUT" 2>&1; then
96+
echo "✅ Deploy contract to testnet completed successfully"
97+
else
98+
echo "❌ Deploy contract script failed"
99+
cat "$TEMP_OUTPUT"
100+
rm "$TEMP_OUTPUT"
101+
exit 1
102+
fi
103+
104+
cat "$TEMP_OUTPUT"
105+
106+
VOTING_CONTRACT_ADDRESS=$(grep -o "Contract address: 0x[a-fA-F0-9]*" "$TEMP_OUTPUT" | head -1 | sed 's/Contract address: //' || echo "")
107+
108+
rm "$TEMP_OUTPUT"
109+
110+
if [ -n "$VOTING_CONTRACT_ADDRESS" ]; then
111+
echo "VOTING_CONTRACT_ADDRESS=\"$VOTING_CONTRACT_ADDRESS\"" >> .env
112+
echo "📋 Saved contract address to .env file"
113+
else
114+
echo "⚠️ Warning: Could not extract contract address"
115+
fi
116+
117+
- name: Run testnet scripts
118+
run: |
119+
echo "Running testnet scripts..."
120+
script -e -c "yarn get-block::testnet"
121+
122+
- name: Run interaction test with existing contract
123+
if: ${{ inputs.skip_deployment }}
124+
run: |
125+
echo "Running interaction with existing contract on testnet..."
126+
script -e -c "yarn interaction-existing-contract::testnet"
127+
128+
- name: Run JavaScript tests on testnet
129+
run: |
130+
echo "Running JavaScript tests against testnet..."
131+
script -e -c "rm -rf store/pxe"
132+
script -e -c "ENV=testnet NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json"
133+
134+
- name: Profile deployment on testnet
135+
if: ${{ !inputs.skip_deployment }}
136+
run: |
137+
script -e -c "yarn profile::testnet"

.github/workflows/testnet_scripts.yaml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ log/
66
.DS_Store
77
codegenCache.json
88
store/
9+
.tsbuildinfo

.tsbuildinfo

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)