@alejoamiras/aztec-benchmark 0.0.0-canary.gb8d1485 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -105
- package/dist/cli.js +3 -1
- package/dist/profiler.d.ts +2 -2
- package/dist/types.d.ts +4 -2
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Aztec Benchmark
|
|
2
|
-
[](https://www.npmjs.com/package/@alejoamiras/aztec-benchmark)
|
|
3
3
|
|
|
4
4
|
**CLI tool and reusable CI workflows for running Aztec contract benchmarks.**
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ Use the CLI to execute benchmark files written in TypeScript. For CI integration
|
|
|
27
27
|
## Installation
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
|
-
|
|
30
|
+
bun add -D @alejoamiras/aztec-benchmark
|
|
31
31
|
# or
|
|
32
32
|
npm install --save-dev @alejoamiras/aztec-benchmark
|
|
33
33
|
```
|
|
@@ -134,6 +134,9 @@ export default class MyContractBenchmark extends Benchmark {
|
|
|
134
134
|
const fullConfig = { ...config, l1Contracts };
|
|
135
135
|
// IMPORTANT: true enables proof generation for the benchmark, set it to false when using --skip-proving
|
|
136
136
|
fullConfig.proverEnabled = true;
|
|
137
|
+
// PXE wipes any store whose schema version differs from the running PXE's (Aztec 5.0.0+
|
|
138
|
+
// resets on upgrade) — a hardcoded version can resurrect or mask a stale store, so use a
|
|
139
|
+
// fresh dataDirectory per toolchain version when in doubt.
|
|
137
140
|
const pxeVersion = 2;
|
|
138
141
|
const store = await createStore('pxe', pxeVersion, {
|
|
139
142
|
dataDirectory: 'store',
|
|
@@ -214,9 +217,9 @@ If you provide a `NamedBenchmarkedInteraction` object, its `name` field will be
|
|
|
214
217
|
If you provide a plain `ContractFunctionInteractionCallIntent`, the tool will attempt to derive a name from the interaction (e.g., the method name).
|
|
215
218
|
If you return a `feePaymentMethod` in the `BenchmarkContext`, it is automatically passed to every transaction the profiler sends — no changes to `getMethods` are needed.
|
|
216
219
|
|
|
217
|
-
###
|
|
220
|
+
### Usage Example
|
|
218
221
|
|
|
219
|
-
|
|
222
|
+
See how this monorepo benchmarks its own contracts in [`packages/aztec-standards/benchmarks`](https://github.com/alejoamiras/ecosystem-tooling/tree/main/packages/aztec-standards/benchmarks).
|
|
220
223
|
|
|
221
224
|
---
|
|
222
225
|
|
|
@@ -227,114 +230,35 @@ Each entry in the output will be identified by the custom `name` you provided (i
|
|
|
227
230
|
|
|
228
231
|
---
|
|
229
232
|
|
|
230
|
-
##
|
|
233
|
+
## CI Integration
|
|
231
234
|
|
|
232
|
-
|
|
235
|
+
### Inside this monorepo
|
|
233
236
|
|
|
234
|
-
|
|
237
|
+
The per-package gates (`aztec-standards.yml`, `aztec-fee-payment.yml`) call the repo's reusable workflows:
|
|
235
238
|
|
|
236
|
-
|
|
239
|
+
- **`_pr-benchmark.yml`** — on every PR: runs the suites on the PR head (`--skip-proving`), downloads the `main` baseline artifact, generates a comparison report (regressions beyond 2.5% highlighted), and posts it as a PR comment. Security split: the job executing PR code is read-only; a separate write-permission job posts the comment without executing anything from the PR.
|
|
240
|
+
- **`_update-baseline.yml`** — on pushes to `main` (+ monthly cron via `update-baselines.yml`): refreshes the baseline artifacts (`benchmark-baseline-<package>-main`).
|
|
237
241
|
|
|
238
|
-
|
|
242
|
+
Wiring a new package: add a `benchmark` job to its gate workflow:
|
|
239
243
|
|
|
240
244
|
```yaml
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
benchmark
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
issues: write
|
|
254
|
-
actions: read
|
|
245
|
+
benchmark:
|
|
246
|
+
needs: changes
|
|
247
|
+
if: needs.changes.outputs.relevant == 'true' && github.event_name == 'pull_request'
|
|
248
|
+
permissions:
|
|
249
|
+
contents: read
|
|
250
|
+
pull-requests: write
|
|
251
|
+
issues: write
|
|
252
|
+
actions: read
|
|
253
|
+
uses: ./.github/workflows/_pr-benchmark.yml
|
|
254
|
+
with:
|
|
255
|
+
package-dir: packages/<your-package>
|
|
256
|
+
pr-workflow: <your-package>.yml
|
|
255
257
|
```
|
|
256
258
|
|
|
257
|
-
|
|
259
|
+
### From other repositories
|
|
258
260
|
|
|
259
|
-
|
|
260
|
-
|---|---|---|---|
|
|
261
|
-
| `runner` | `string` | `ubuntu-latest-m` | GitHub runner label |
|
|
262
|
-
| `timeout` | `number` | `120` | Job timeout in minutes |
|
|
263
|
-
| `bench-dir` | `string` | `./benchmarks` | Directory for benchmark files |
|
|
261
|
+
The reusable workflows reference this repo's local `setup-aztec` action, so they are not directly callable cross-repo. External projects have two options:
|
|
264
262
|
|
|
265
|
-
**
|
|
266
|
-
|
|
267
|
-
```yaml
|
|
268
|
-
jobs:
|
|
269
|
-
benchmark:
|
|
270
|
-
uses: defi-wonderland/aztec-benchmark/.github/workflows/pr-benchmark.yml@v0
|
|
271
|
-
permissions:
|
|
272
|
-
pull-requests: write
|
|
273
|
-
issues: write
|
|
274
|
-
actions: read
|
|
275
|
-
with:
|
|
276
|
-
runner: ubuntu-latest-l
|
|
277
|
-
timeout: 180
|
|
278
|
-
bench-dir: ./my-benchmarks
|
|
279
|
-
```
|
|
280
|
-
|
|
281
|
-
### Update Baseline (`update-baseline.yml`)
|
|
282
|
-
|
|
283
|
-
Runs benchmarks on the current branch and uploads the results as a baseline artifact. This should be triggered on pushes to your default branches so that PR benchmarks have a baseline to compare against.
|
|
284
|
-
|
|
285
|
-
**Usage:**
|
|
286
|
-
|
|
287
|
-
```yaml
|
|
288
|
-
# .github/workflows/update-baseline.yml
|
|
289
|
-
name: Update Baseline
|
|
290
|
-
|
|
291
|
-
on:
|
|
292
|
-
push:
|
|
293
|
-
branches: [dev, main]
|
|
294
|
-
|
|
295
|
-
jobs:
|
|
296
|
-
update-baseline:
|
|
297
|
-
uses: defi-wonderland/aztec-benchmark/.github/workflows/update-baseline.yml@v0
|
|
298
|
-
permissions:
|
|
299
|
-
contents: read
|
|
300
|
-
actions: write
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
**Inputs:**
|
|
304
|
-
|
|
305
|
-
| Input | Type | Default | Description |
|
|
306
|
-
|---|---|---|---|
|
|
307
|
-
| `runner` | `string` | `ubuntu-latest-m` | GitHub runner label |
|
|
308
|
-
| `timeout` | `number` | `120` | Job timeout in minutes |
|
|
309
|
-
| `bench-dir` | `string` | `./benchmarks` | Directory for benchmark files |
|
|
310
|
-
|
|
311
|
-
### How Baselines Work
|
|
312
|
-
|
|
313
|
-
The workflows use GitHub Actions artifacts to store and retrieve baseline benchmark results:
|
|
314
|
-
|
|
315
|
-
1. **`update-baseline.yml`** runs benchmarks with the `_latest` suffix and uploads the results as `benchmark-baseline-<branch>`.
|
|
316
|
-
2. **`pr-benchmark.yml`** runs benchmarks with the `_new` suffix on the PR head, then downloads the `benchmark-baseline-<base-branch>` artifact to get the `_latest` files. It compares `_latest` (baseline) vs `_new` (PR) and comments a Markdown diff table on the PR.
|
|
317
|
-
3. Before posting the new comment, the workflow finds all previous benchmark comments on the PR (identified by a unique marker in the comment body) and hides them as **Outdated** via the GitHub GraphQL API, so the PR timeline stays clean.
|
|
318
|
-
4. After comparison, the PR workflow renames `_new` files to `_latest` and uploads them as `benchmark-baseline-<head-branch>`, so stacked PRs can also compare against each other.
|
|
319
|
-
|
|
320
|
-
Artifacts are retained for **90 days** by default.
|
|
321
|
-
|
|
322
|
-
---
|
|
323
|
-
|
|
324
|
-
## Action Usage (Advanced)
|
|
325
|
-
|
|
326
|
-
> **Note:** For most projects, the [reusable workflows](#reusable-workflows) above are the recommended approach. The action below is a lower-level building block for projects that need a custom CI setup.
|
|
327
|
-
|
|
328
|
-
This repository also includes a GitHub Action (defined in `action/action.yml`) that runs `aztec-benchmark` and compares results. It automatically finds benchmark reports (named with `_base` and `_latest` suffixes) and produces a Markdown comparison report.
|
|
329
|
-
|
|
330
|
-
### Inputs
|
|
331
|
-
|
|
332
|
-
- `threshold`: Regression threshold percentage (default: `2.5`).
|
|
333
|
-
- `output_markdown_path`: Path to save the generated Markdown comparison report (default: `benchmark-comparison.md`).
|
|
334
|
-
|
|
335
|
-
### Outputs
|
|
336
|
-
|
|
337
|
-
- `comparison_markdown`: The generated Markdown report content.
|
|
338
|
-
- `markdown_file_path`: Path to the saved Markdown file.
|
|
339
|
-
|
|
340
|
-
Refer to the `action/action.yml` file for the definitive inputs and description.
|
|
263
|
+
1. **Use the CLI directly** (recommended): install `@alejoamiras/aztec-benchmark` as a devDependency, add a `[benchmark]` table to your `Nargo.toml`, and run `aztec-benchmark --suffix _base` in a job that has an Aztec local network running. The comparison helper is importable as `require('@alejoamiras/aztec-benchmark/action/comparison.cjs')` — see `_pr-benchmark.yml` in this repo as a reference implementation for baselines, comparison and PR comments.
|
|
264
|
+
2. **Vendor the workflows**: copy `_pr-benchmark.yml`, `_update-baseline.yml` and `.github/actions/setup-aztec/` into your repo and adjust `package-dir`.
|
package/dist/cli.js
CHANGED
|
@@ -126,7 +126,9 @@ program
|
|
|
126
126
|
await pxe.blockStateSynchronizer.blockStream?.stop();
|
|
127
127
|
await pxe.blockStateSynchronizer.store?.close();
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
// stop() is EmbeddedWallet lifecycle, not part of the Wallet interface —
|
|
130
|
+
// narrow structurally so any wallet implementation remains accepted.
|
|
131
|
+
await runContext.wallet.stop?.();
|
|
130
132
|
// Close leftover HTTP keep-alive sockets
|
|
131
133
|
for (const h of process._getActiveHandles()) {
|
|
132
134
|
if (h?.constructor?.name === 'Socket' && !h.destroyed)
|
package/dist/profiler.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractFunctionInteractionCallIntent } from '@aztec/aztec.js/authorization';
|
|
2
2
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
4
4
|
import type { NamedBenchmarkedInteraction, ProfileResult } from './types.js';
|
|
5
5
|
interface ProfilerOptions {
|
|
6
6
|
skipProving?: boolean;
|
|
@@ -13,7 +13,7 @@ interface ProfilerOptions {
|
|
|
13
13
|
export declare class Profiler {
|
|
14
14
|
#private;
|
|
15
15
|
/** @param _wallet - Unused, kept for backward compatibility with existing callers. */
|
|
16
|
-
constructor(_wallet?:
|
|
16
|
+
constructor(_wallet?: Wallet, options?: ProfilerOptions);
|
|
17
17
|
/**
|
|
18
18
|
* Profiles a list of contract function interactions.
|
|
19
19
|
* Items can be plain interactions or objects with an interaction and a custom name.
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
2
|
import type { ContractFunctionInteractionCallIntent } from '@aztec/aztec.js/authorization';
|
|
3
3
|
import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
5
5
|
import type { SystemInfo } from './systemInfo.js';
|
|
6
6
|
export type { SystemInfo } from './systemInfo.js';
|
|
7
7
|
/** Simplified Gas type (contains actual gas values) */
|
|
@@ -18,7 +18,9 @@ export type GasLimits = {
|
|
|
18
18
|
};
|
|
19
19
|
/** Benchmark specific setup/teardown context */
|
|
20
20
|
export interface BenchmarkContext {
|
|
21
|
-
wallet
|
|
21
|
+
/** Typed as the Wallet interface so suite contexts can extend with any wallet
|
|
22
|
+
* implementation; the CLI narrows structurally for lifecycle calls (stop). */
|
|
23
|
+
wallet?: Wallet;
|
|
22
24
|
/** Optional fee payment method used when sending profiled transactions.
|
|
23
25
|
* When set, the profiler passes this to every send/prove call.
|
|
24
26
|
* When unset, the sender must have pre-existing Fee Juice. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alejoamiras/aztec-benchmark",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "CLI tool and GitHub Action for Aztec contract benchmarking",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
],
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsc && ncc build action/index.cjs -o action/dist -m -C",
|
|
26
|
-
"start": "tsx cli/cli.ts"
|
|
26
|
+
"start": "tsx cli/cli.ts",
|
|
27
|
+
"typecheck": "tsc --noEmit -p tsconfig.check.json"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
|
29
30
|
"@actions/core": "1.10.1",
|
|
@@ -35,15 +36,15 @@
|
|
|
35
36
|
"typescript": "5.8.3"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@aztec/aztec.js": "5.0.0
|
|
39
|
-
"@aztec/stdlib": "5.0.0
|
|
40
|
-
"@aztec/wallets": "5.0.0
|
|
39
|
+
"@aztec/aztec.js": "5.0.0",
|
|
40
|
+
"@aztec/stdlib": "5.0.0",
|
|
41
|
+
"@aztec/wallets": "5.0.0",
|
|
41
42
|
"@types/node": "22.15.3",
|
|
42
43
|
"@vercel/ncc": "0.38.3"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"@aztec/aztec.js": "5.0.0
|
|
46
|
-
"@aztec/wallets": "5.0.0
|
|
46
|
+
"@aztec/aztec.js": "5.0.0",
|
|
47
|
+
"@aztec/wallets": "5.0.0"
|
|
47
48
|
},
|
|
48
49
|
"engines": {
|
|
49
50
|
"node": ">=22"
|