Skip to content

Commit f955b49

Browse files
wei3erHasexorsal
andauthored
chore: 3.0.0 devnet.20251212 (#75)
Co-authored-by: zorzal <zorzal@wonderland.xyz>
1 parent 2e33d0f commit f955b49

13 files changed

Lines changed: 1805 additions & 1342 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818

1919
jobs:
2020
check-changes:
21+
if: false # Temporary disable benchmarking cross-version comparison
2122
name: Check for relevant changes
2223
runs-on: ubuntu-latest
2324
outputs:
@@ -64,6 +65,7 @@ jobs:
6465
core.setOutput('should-benchmark', shouldBenchmark);
6566
6667
benchmark:
68+
if: false # Temporary disable benchmarking cross-version comparison
6769
name: Run comparison
6870
needs: check-changes
6971
if: needs.check-changes.outputs.should-benchmark == 'true'
@@ -108,7 +110,7 @@ jobs:
108110
109111
- name: Switch CLI to BASE version
110112
run: |
111-
VERSION=${{ steps.basever.outputs.ver }} aztec-up
113+
aztec-up ${{ steps.basever.outputs.ver }}
112114
113115
- name: Manually tag the aztec version as `latest`
114116
run: |

.github/workflows/lint.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ jobs:
5858
- name: Install Aztec CLI
5959
run: |
6060
curl -s https://install.aztec.network > tmp.sh
61-
VERSION=${{ steps.aztec-version.outputs.version }} bash tmp.sh <<< yes "yes"
61+
bash tmp.sh <<< yes "yes"
6262
6363
- name: Update path
6464
run: echo "/home/runner/.aztec/bin" >> $GITHUB_PATH
65+
66+
- name: Update Aztec
67+
run: |
68+
aztec-up ${{ steps.aztec-version.outputs.version }}
6569
6670
- name: Setup Node.js
6771
uses: actions/setup-node@v5
@@ -73,7 +77,7 @@ jobs:
7377
run: yarn install --frozen-lockfile
7478

7579
- name: Check Noir formatting
76-
run: aztec-nargo fmt --check
80+
run: aztec fmt --check
7781

7882
- name: Check Javascript & Typescript formatting
7983
run: yarn prettier '**/*.{js,ts}' --check

.github/workflows/tests.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,15 @@ jobs:
4545
- name: Install Aztec CLI
4646
run: |
4747
curl -s https://install.aztec.network > tmp.sh
48-
VERSION=${{ steps.aztec-version.outputs.version }} bash tmp.sh <<< yes "yes"
48+
bash tmp.sh <<< yes "yes"
4949
5050
- name: Update path
5151
run: echo "/home/runner/.aztec/bin" >> $GITHUB_PATH
5252

53+
- name: Update Aztec
54+
run: |
55+
aztec-up ${{ steps.aztec-version.outputs.version }}
56+
5357
- name: Cache Noir compilation artifacts
5458
id: cache-noir
5559
uses: actions/cache@v4
@@ -67,9 +71,6 @@ jobs:
6771
if: steps.cache-noir.outputs.cache-hit != 'true'
6872
run: yarn codegen -f
6973

70-
- name: Postprocess contracts
71-
run: aztec-postprocess-contract
72-
7374
- name: Run nr tests
7475
run: yarn test:nr
7576

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ log/
77
codegenCache.json
88
.env
99
.cursor
10+
pxe-test/

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
aztec-nargo fmt
1+
aztec fmt
22
yarn lint-staged

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ yarn ccc
4343

4444
This runs:
4545
- `yarn clean` - Removes all build artifacts
46-
- `yarn compile` - Compiles Noir contracts using aztec-nargo
46+
- `yarn compile` - Compiles Noir contracts using aztec
4747
- `yarn codegen` - Generates TypeScript bindings from compiled contracts
4848

4949
## Running tests

benchmarks/counter.benchmark.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AztecAddress } from "@aztec/aztec.js/addresses";
33
import { createAztecNodeClient, waitForNode } from "@aztec/aztec.js/node";
44
import { type ContractFunctionInteractionCallIntent } from "@aztec/aztec.js/authorization";
55
import {
6-
registerInitialSandboxAccountsInWallet,
6+
registerInitialLocalNetworkAccountsInWallet,
77
TestWallet,
88
} from "@aztec/test-wallet/server";
99
import {
@@ -28,13 +28,12 @@ export default class CounterContractBenchmark extends Benchmark {
2828
* Creates PXE client, gets accounts, and deploys the contract.
2929
*/
3030
async setup(): Promise<CounterBenchmarkContext> {
31-
const { NODE_URL = "http://localhost:8080" } = process.env;
32-
const aztecNode = createAztecNodeClient(NODE_URL);
31+
const aztecNode = createAztecNodeClient("http://localhost:8080");
3332
await waitForNode(aztecNode);
3433

3534
const wallet: TestWallet = await TestWallet.create(aztecNode);
3635
const accounts: AztecAddress[] =
37-
await registerInitialSandboxAccountsInWallet(wallet);
36+
await registerInitialLocalNetworkAccountsInWallet(wallet);
3837

3938
const [deployer] = accounts;
4039

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "aztec-boilerplate",
3-
"version": "3.0.0-devnet.2",
3+
"version": "3.0.0-devnet.20251212",
44
"repository": "https://github.com/defi-wonderland/aztec-boilerplate.git",
55
"author": "Wonderland",
66
"license": "MIT",
77
"type": "module",
88
"scripts": {
99
"clean": "rm -rf ./src/artifacts ./target codegenCache.json",
1010
"codegen": "aztec codegen target --outdir src/artifacts -f",
11-
"compile": "aztec-nargo compile && aztec-postprocess-contract",
11+
"compile": "aztec compile",
1212
"test": "yarn test:nr && yarn test:js",
1313
"test:js": "vitest run",
1414
"test:nr": "aztec test",
@@ -21,13 +21,13 @@
2121
"*.{js,ts}": "prettier --write -u"
2222
},
2323
"dependencies": {
24-
"@aztec/accounts": "3.0.0-devnet.2",
25-
"@aztec/aztec.js": "3.0.0-devnet.2",
26-
"@aztec/entrypoints": "3.0.0-devnet.2",
27-
"@aztec/noir-contracts.js": "3.0.0-devnet.2",
28-
"@aztec/pxe": "3.0.0-devnet.2",
29-
"@aztec/stdlib": "3.0.0-devnet.2",
30-
"@aztec/test-wallet": "3.0.0-devnet.2",
24+
"@aztec/accounts": "3.0.0-devnet.20251212",
25+
"@aztec/aztec.js": "3.0.0-devnet.20251212",
26+
"@aztec/entrypoints": "3.0.0-devnet.20251212",
27+
"@aztec/noir-contracts.js": "3.0.0-devnet.20251212",
28+
"@aztec/pxe": "3.0.0-devnet.20251212",
29+
"@aztec/stdlib": "3.0.0-devnet.20251212",
30+
"@aztec/test-wallet": "3.0.0-devnet.20251212",
3131
"@defi-wonderland/aztec-benchmark": "3.0.0-devnet.2",
3232
"@types/node": "22.5.1"
3333
},
@@ -45,7 +45,7 @@
4545
"vitest": "3.2.4"
4646
},
4747
"config": {
48-
"aztecVersion": "3.0.0-devnet.2"
48+
"aztecVersion": "3.0.0-devnet.20251212"
4949
},
5050
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
5151
"engines": {

scripts/start-sandbox.ts

Lines changed: 108 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
import { spawn, ChildProcess } from "child_process";
1+
import { spawn, ChildProcess, execSync } from "child_process";
22
import { EventEmitter } from "events";
33
import { createAztecNodeClient } from "@aztec/aztec.js/node";
4+
import net from "node:net";
5+
import { readFileSync } from "node:fs";
6+
import { fileURLToPath } from "node:url";
7+
import { dirname, join } from "node:path";
48

59
// Global reference for the active sandbox manager
610
let activeSandboxManager: SandboxManager | null = null;
@@ -54,6 +58,8 @@ class SandboxManager extends EventEmitter {
5458
public forceKillTimeout = 5000;
5559
public maxRetries = 3;
5660
public verbose: boolean;
61+
public port: number;
62+
public url: string;
5763

5864
// Timer/interval tracking for centralized cleanup
5965
private timers: Record<string, NodeJS.Timeout> = {};
@@ -65,12 +71,69 @@ class SandboxManager extends EventEmitter {
6571
super();
6672
// Enable verbose mode in CI environments by default
6773
this.verbose = options.verbose ?? Boolean(process.env.CI);
74+
this.port = 8080;
75+
this.url = "http://localhost:8080";
6876

6977
// Register this manager for signal handling
7078
activeSandboxManager = this;
7179
setupSignalHandlers();
7280
}
7381

82+
/**
83+
* Returns true if a local TCP port is available for binding.
84+
*/
85+
private async isPortAvailable(port: number): Promise<boolean> {
86+
try {
87+
await new Promise<void>((resolve, reject) => {
88+
const server = net.createServer();
89+
server.unref();
90+
server.on("error", reject);
91+
server.listen({ port, host: "::", ipv6Only: false }, () => {
92+
server.close(() => resolve());
93+
});
94+
});
95+
return true;
96+
} catch {
97+
return false;
98+
}
99+
}
100+
101+
private getExpectedAztecVersion(): string {
102+
const __filename = fileURLToPath(import.meta.url);
103+
const __dirname = dirname(__filename);
104+
const packageJsonPath = join(__dirname, "..", "package.json");
105+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
106+
config?: { aztecVersion?: string };
107+
};
108+
const expected = packageJson.config?.aztecVersion;
109+
if (!expected) {
110+
throw new Error("No aztecVersion found in package.json config");
111+
}
112+
return expected;
113+
}
114+
115+
private async tryConnectAndValidateRunningSandbox(): Promise<boolean> {
116+
try {
117+
const aztecNode = await createAztecNodeClient(this.url, {});
118+
const nodeInfo = await aztecNode.getNodeInfo();
119+
const expected = this.getExpectedAztecVersion();
120+
if (nodeInfo.nodeVersion !== expected) {
121+
throw new Error(
122+
`Aztec sandbox already running but version mismatch.\n` +
123+
`Expected: ${expected}\n` +
124+
`Running: ${nodeInfo.nodeVersion}`,
125+
);
126+
}
127+
128+
console.log(`🔧 Node version: ${nodeInfo.nodeVersion}`);
129+
this.isExternalSandbox = true;
130+
this.isReady = true;
131+
return true;
132+
} catch {
133+
return false;
134+
}
135+
}
136+
74137
/**
75138
* Create a managed timer that will be automatically cleaned up
76139
*/
@@ -165,11 +228,23 @@ class SandboxManager extends EventEmitter {
165228
* Spawn the Aztec sandbox process
166229
*/
167230
spawnSandboxProcess(): ChildProcess {
168-
// In devnet.2, an L1 RPC URL is required
169-
// The sandbox will start its own Anvil instance on the default port
170-
const l1RpcUrl = process.env.L1_RPC_URL || "http://127.0.0.1:8545";
231+
// Prefer `--sandbox` if supported by the installed Aztec CLI; otherwise fall back to `--local-network`.
232+
// This keeps compatibility across Aztec CLI versions.
233+
let modeFlag: "--sandbox" | "--local-network" = "--sandbox";
234+
try {
235+
const help = execSync("aztec start --help", {
236+
encoding: "utf8",
237+
stdio: ["ignore", "pipe", "pipe"],
238+
});
239+
if (!help.includes("--sandbox")) {
240+
modeFlag = "--local-network";
241+
}
242+
} catch {
243+
// If help fails for any reason, fall back to local-network since it's supported in current releases.
244+
modeFlag = "--local-network";
245+
}
171246

172-
return spawn("aztec", ["start", "--sandbox", "--l1-rpc-urls", l1RpcUrl], {
247+
return spawn("aztec", ["start", modeFlag, "--port", String(this.port)], {
173248
stdio: "pipe",
174249
});
175250
}
@@ -221,29 +296,36 @@ class SandboxManager extends EventEmitter {
221296
console.log(`🚨 Sandbox error: ${output}`);
222297
}
223298

224-
// Check for port already in use
225-
if (output.includes("port is already")) {
226-
this.clearManagedTimer("startupTimeout"); // Clear startup timeout since we're switching to external
227-
console.log(
228-
"ℹ️ Port is already in use, checking if existing sandbox is responsive",
229-
);
299+
// If the process couldn't bind because something is already running, attach to it and validate version.
300+
if (
301+
output.includes("port is already") ||
302+
output.includes("address already in use") ||
303+
output.includes("EADDRINUSE")
304+
) {
305+
this.clearManagedTimer("startupTimeout");
230306

231307
// Clean up our failed spawn process since we'll use external sandbox
232308
if (this.process) {
233309
this.process.kill("SIGTERM");
234310
}
235311
this.process = null;
236312

237-
this.checkSandboxConnectivity()
238-
.then(() => {
239-
this.isExternalSandbox = true; // Mark that we're using external sandbox
240-
this.isReady = true;
241-
console.log("✅ Connected to existing external sandbox");
242-
safeResolve(this);
313+
this.tryConnectAndValidateRunningSandbox()
314+
.then((ok) => {
315+
if (ok) {
316+
console.log("✅ Connected to existing sandbox");
317+
safeResolve(this);
318+
} else {
319+
this.handleError(
320+
"Port is in use but sandbox is not responsive",
321+
"external-sandbox-check",
322+
safeReject,
323+
);
324+
}
243325
})
244-
.catch(() => {
326+
.catch((err: any) => {
245327
this.handleError(
246-
"Port 8080 is in use but sandbox is not responsive",
328+
err?.message ?? String(err),
247329
"external-sandbox-check",
248330
safeReject,
249331
);
@@ -289,10 +371,7 @@ class SandboxManager extends EventEmitter {
289371
for (let attempt = 1; attempt <= maxRetries; attempt++) {
290372
try {
291373
// Try to connect to the Aztec node
292-
const aztecNode = await createAztecNodeClient(
293-
"http://localhost:8080",
294-
{},
295-
);
374+
const aztecNode = await createAztecNodeClient(this.url, {});
296375

297376
// Try to get node info to verify it's responsive
298377
const nodeInfo = await aztecNode.getNodeInfo();
@@ -326,6 +405,11 @@ class SandboxManager extends EventEmitter {
326405
throw new Error("Cannot start sandbox - already running or starting");
327406
}
328407

408+
// If something is already running on the default URL, validate version and reuse it.
409+
if (await this.tryConnectAndValidateRunningSandbox()) {
410+
return this;
411+
}
412+
329413
return new Promise((resolve, reject) => {
330414
console.log("🚀 Starting Aztec sandbox");
331415
let resolved = false; // Prevent double resolution
@@ -434,8 +518,7 @@ class SandboxManager extends EventEmitter {
434518
}
435519

436520
cleanup(): void {
437-
// Only kill process if we own it, not if using external sandbox
438-
if (!this.isExternalSandbox && this.process) {
521+
if (this.process) {
439522
this.process.kill("SIGTERM");
440523
}
441524

src/nr/counter_contract/Nargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ compiler_version = ">=1.0.0"
55
authors = [""]
66

77
[dependencies]
8-
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.2", directory = "noir-projects/aztec-nr/aztec" }
8+
aztec = { git = "https://github.com/AztecProtocol/aztec-packages/", tag = "v3.0.0-devnet.20251212", directory = "noir-projects/aztec-nr/aztec" }

0 commit comments

Comments
 (0)