@aztec/aztec 4.0.0-rc.1 → 4.0.0-rc.10
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/dest/bin/index.js +5 -1
- package/dest/cli/admin_api_key_store.d.ts +3 -3
- package/dest/cli/admin_api_key_store.d.ts.map +1 -1
- package/dest/cli/admin_api_key_store.js +3 -3
- package/dest/cli/aztec_start_action.js +4 -4
- package/dest/cli/aztec_start_options.d.ts +1 -1
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +4 -3
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +0 -1
- package/dest/cli/cmds/compile.d.ts +4 -0
- package/dest/cli/cmds/compile.d.ts.map +1 -0
- package/dest/cli/cmds/compile.js +68 -0
- package/dest/cli/cmds/profile.d.ts +4 -0
- package/dest/cli/cmds/profile.d.ts.map +1 -0
- package/dest/cli/cmds/profile.js +8 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
- package/dest/cli/cmds/profile_flamegraph.js +51 -0
- package/dest/cli/cmds/profile_gates.d.ts +4 -0
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
- package/dest/cli/cmds/profile_gates.js +57 -0
- package/dest/cli/cmds/profile_utils.d.ts +18 -0
- package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
- package/dest/cli/cmds/profile_utils.js +50 -0
- package/dest/cli/cmds/utils/artifacts.d.ts +21 -0
- package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
- package/dest/cli/cmds/utils/artifacts.js +24 -0
- package/dest/cli/cmds/utils/spawn.d.ts +3 -0
- package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
- package/dest/cli/cmds/utils/spawn.js +16 -0
- package/dest/local-network/local-network.d.ts +1 -1
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +15 -0
- package/dest/testing/anvil_test_watcher.d.ts +9 -1
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +52 -15
- package/package.json +34 -34
- package/scripts/aztec.sh +7 -3
- package/src/bin/index.ts +5 -1
- package/src/cli/admin_api_key_store.ts +4 -4
- package/src/cli/aztec_start_action.ts +4 -4
- package/src/cli/aztec_start_options.ts +4 -3
- package/src/cli/cli.ts +0 -1
- package/src/cli/cmds/compile.ts +80 -0
- package/src/cli/cmds/profile.ts +25 -0
- package/src/cli/cmds/profile_flamegraph.ts +63 -0
- package/src/cli/cmds/profile_gates.ts +67 -0
- package/src/cli/cmds/profile_utils.ts +58 -0
- package/src/cli/cmds/utils/artifacts.ts +44 -0
- package/src/cli/cmds/utils/spawn.ts +16 -0
- package/src/local-network/local-network.ts +16 -0
- package/src/testing/anvil_test_watcher.ts +59 -15
- package/scripts/compile.sh +0 -44
- package/scripts/extract_function.js +0 -47
- package/scripts/flamegraph.sh +0 -59
|
@@ -21,14 +21,22 @@ export declare class AnvilTestWatcher {
|
|
|
21
21
|
private markingAsProvenRunningPromise?;
|
|
22
22
|
private logger;
|
|
23
23
|
private isMarkingAsProven;
|
|
24
|
+
private getPendingTxCount?;
|
|
25
|
+
private isSequencerBuilding?;
|
|
26
|
+
private unfilledSlotFirstSeen?;
|
|
24
27
|
constructor(cheatcodes: EthCheatCodes, rollupAddress: EthAddress, l1Client: ViemClient, dateProvider?: TestDateProvider | undefined);
|
|
25
28
|
setIsMarkingAsProven(isMarkingAsProven: boolean): void;
|
|
26
29
|
setisLocalNetwork(isLocalNetwork: boolean): void;
|
|
30
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */
|
|
31
|
+
setGetPendingTxCount(fn: () => Promise<number>): void;
|
|
32
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */
|
|
33
|
+
setIsSequencerBuilding(fn: () => boolean): void;
|
|
27
34
|
start(): Promise<void>;
|
|
28
35
|
stop(): Promise<void>;
|
|
29
36
|
trigger(): Promise<void>;
|
|
30
37
|
markAsProven(): Promise<void>;
|
|
31
38
|
syncDateProviderToL1IfBehind(): Promise<void>;
|
|
32
39
|
warpTimeIfNeeded(): Promise<void>;
|
|
40
|
+
private warpToTimestamp;
|
|
33
41
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW52aWxfdGVzdF93YXRjaGVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdGluZy9hbnZpbF90ZXN0X3dhdGNoZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGFBQWEsRUFBb0IsTUFBTSxzQkFBc0IsQ0FBQztBQUN2RSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUV4RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUdoRSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBS2hFOzs7Ozs7R0FNRztBQUNILHFCQUFhLGdCQUFnQjtJQXlCekIsT0FBTyxDQUFDLFVBQVU7SUFHbEIsT0FBTyxDQUFDLFlBQVksQ0FBQztJQTNCdkIsT0FBTyxDQUFDLGNBQWMsQ0FBa0I7SUFFeEMsT0FBTyxDQUFDLE1BQU0sQ0FBc0Q7SUFDcEUsT0FBTyxDQUFDLGdCQUFnQixDQUFtQjtJQUMzQyxPQUFPLENBQUMsY0FBYyxDQUFVO0lBRWhDLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQUFpQjtJQUM5QyxPQUFPLENBQUMsdUJBQXVCLENBQUMsQ0FBaUI7SUFDakQsT0FB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,CAAC,MAAM,CAAC,QAE7C;IAED,uGAAuG;IACvG,sBAAsB,CAAC,EAAE,EAAE,MAAM,OAAO,QAEvC;IAEK,KAAK,kBAyBV;IAEK,IAAI,kBAIT;IAEK,OAAO,kBAIZ;IAEK,YAAY,kBAKjB;IAEK,4BAA4B,kBAejC;IAEK,gBAAgB,kBAyDrB;YAEa,eAAe;CAO9B"}
|
|
@@ -22,6 +22,12 @@ import { getAddress, getContract } from 'viem';
|
|
|
22
22
|
markingAsProvenRunningPromise;
|
|
23
23
|
logger;
|
|
24
24
|
isMarkingAsProven;
|
|
25
|
+
// Optional callback to check if there are pending txs in the mempool.
|
|
26
|
+
getPendingTxCount;
|
|
27
|
+
// Optional callback to check if the sequencer is actively building a block.
|
|
28
|
+
isSequencerBuilding;
|
|
29
|
+
// Tracks when we first observed the current unfilled slot with pending txs (real wall time).
|
|
30
|
+
unfilledSlotFirstSeen;
|
|
25
31
|
constructor(cheatcodes, rollupAddress, l1Client, dateProvider){
|
|
26
32
|
this.cheatcodes = cheatcodes;
|
|
27
33
|
this.dateProvider = dateProvider;
|
|
@@ -45,6 +51,12 @@ import { getAddress, getContract } from 'viem';
|
|
|
45
51
|
setisLocalNetwork(isLocalNetwork) {
|
|
46
52
|
this.isLocalNetwork = isLocalNetwork;
|
|
47
53
|
}
|
|
54
|
+
/** Sets a callback to check for pending txs, used to skip unfilled slots faster when txs are waiting. */ setGetPendingTxCount(fn) {
|
|
55
|
+
this.getPendingTxCount = fn;
|
|
56
|
+
}
|
|
57
|
+
/** Sets a callback to check if the sequencer is actively building, to avoid warping while it works. */ setIsSequencerBuilding(fn) {
|
|
58
|
+
this.isSequencerBuilding = fn;
|
|
59
|
+
}
|
|
48
60
|
async start() {
|
|
49
61
|
if (this.filledRunningPromise) {
|
|
50
62
|
throw new Error('Watcher already watching for filled slot');
|
|
@@ -111,14 +123,8 @@ import { getAddress, getContract } from 'viem';
|
|
|
111
123
|
BigInt(nextSlot)
|
|
112
124
|
]));
|
|
113
125
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
114
|
-
//
|
|
115
|
-
|
|
116
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
117
|
-
resetBlockInterval: true
|
|
118
|
-
});
|
|
119
|
-
} catch (e) {
|
|
120
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
121
|
-
}
|
|
126
|
+
// The current slot has been filled, we should jump to the next slot.
|
|
127
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
122
128
|
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
123
129
|
return;
|
|
124
130
|
}
|
|
@@ -126,19 +132,50 @@ import { getAddress, getContract } from 'viem';
|
|
|
126
132
|
if (!this.isLocalNetwork) {
|
|
127
133
|
return;
|
|
128
134
|
}
|
|
135
|
+
// If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
|
|
136
|
+
// sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
|
|
137
|
+
// the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
|
|
138
|
+
// to avoid invalidating its in-progress work.
|
|
139
|
+
if (this.getPendingTxCount) {
|
|
140
|
+
const pendingTxs = await this.getPendingTxCount();
|
|
141
|
+
if (pendingTxs > 0) {
|
|
142
|
+
if (this.isSequencerBuilding?.()) {
|
|
143
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const realNow = Date.now();
|
|
147
|
+
if (!this.unfilledSlotFirstSeen || this.unfilledSlotFirstSeen.slot !== currentSlot) {
|
|
148
|
+
this.unfilledSlotFirstSeen = {
|
|
149
|
+
slot: currentSlot,
|
|
150
|
+
realTime: realNow
|
|
151
|
+
};
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
155
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
156
|
+
this.unfilledSlotFirstSeen = undefined;
|
|
157
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
158
|
+
}
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
129
163
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
130
164
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
131
|
-
|
|
132
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
133
|
-
resetBlockInterval: true
|
|
134
|
-
});
|
|
135
|
-
} catch (e) {
|
|
136
|
-
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
137
|
-
}
|
|
165
|
+
await this.warpToTimestamp(nextSlotTimestamp);
|
|
138
166
|
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
139
167
|
}
|
|
140
168
|
} catch {
|
|
141
169
|
this.logger.error('mineIfSlotFilled failed');
|
|
142
170
|
}
|
|
143
171
|
}
|
|
172
|
+
async warpToTimestamp(timestamp) {
|
|
173
|
+
try {
|
|
174
|
+
await this.cheatcodes.warp(timestamp, {
|
|
175
|
+
resetBlockInterval: true
|
|
176
|
+
});
|
|
177
|
+
} catch (e) {
|
|
178
|
+
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
144
181
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -28,39 +28,39 @@
|
|
|
28
28
|
"../package.common.json"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@aztec/accounts": "4.0.0-rc.
|
|
32
|
-
"@aztec/archiver": "4.0.0-rc.
|
|
33
|
-
"@aztec/aztec-faucet": "4.0.0-rc.
|
|
34
|
-
"@aztec/aztec-node": "4.0.0-rc.
|
|
35
|
-
"@aztec/aztec.js": "4.0.0-rc.
|
|
36
|
-
"@aztec/bb-prover": "4.0.0-rc.
|
|
37
|
-
"@aztec/bb.js": "4.0.0-rc.
|
|
38
|
-
"@aztec/blob-client": "4.0.0-rc.
|
|
39
|
-
"@aztec/bot": "4.0.0-rc.
|
|
40
|
-
"@aztec/builder": "4.0.0-rc.
|
|
41
|
-
"@aztec/cli": "4.0.0-rc.
|
|
42
|
-
"@aztec/constants": "4.0.0-rc.
|
|
43
|
-
"@aztec/entrypoints": "4.0.0-rc.
|
|
44
|
-
"@aztec/ethereum": "4.0.0-rc.
|
|
45
|
-
"@aztec/foundation": "4.0.0-rc.
|
|
46
|
-
"@aztec/kv-store": "4.0.0-rc.
|
|
47
|
-
"@aztec/l1-artifacts": "4.0.0-rc.
|
|
48
|
-
"@aztec/node-lib": "4.0.0-rc.
|
|
49
|
-
"@aztec/noir-contracts.js": "4.0.0-rc.
|
|
50
|
-
"@aztec/noir-protocol-circuits-types": "4.0.0-rc.
|
|
51
|
-
"@aztec/p2p": "4.0.0-rc.
|
|
52
|
-
"@aztec/p2p-bootstrap": "4.0.0-rc.
|
|
53
|
-
"@aztec/protocol-contracts": "4.0.0-rc.
|
|
54
|
-
"@aztec/prover-client": "4.0.0-rc.
|
|
55
|
-
"@aztec/prover-node": "4.0.0-rc.
|
|
56
|
-
"@aztec/pxe": "4.0.0-rc.
|
|
57
|
-
"@aztec/sequencer-client": "4.0.0-rc.
|
|
58
|
-
"@aztec/stdlib": "4.0.0-rc.
|
|
59
|
-
"@aztec/telemetry-client": "4.0.0-rc.
|
|
60
|
-
"@aztec/txe": "4.0.0-rc.
|
|
61
|
-
"@aztec/validator-ha-signer": "4.0.0-rc.
|
|
62
|
-
"@aztec/wallets": "4.0.0-rc.
|
|
63
|
-
"@aztec/world-state": "4.0.0-rc.
|
|
31
|
+
"@aztec/accounts": "4.0.0-rc.10",
|
|
32
|
+
"@aztec/archiver": "4.0.0-rc.10",
|
|
33
|
+
"@aztec/aztec-faucet": "4.0.0-rc.10",
|
|
34
|
+
"@aztec/aztec-node": "4.0.0-rc.10",
|
|
35
|
+
"@aztec/aztec.js": "4.0.0-rc.10",
|
|
36
|
+
"@aztec/bb-prover": "4.0.0-rc.10",
|
|
37
|
+
"@aztec/bb.js": "4.0.0-rc.10",
|
|
38
|
+
"@aztec/blob-client": "4.0.0-rc.10",
|
|
39
|
+
"@aztec/bot": "4.0.0-rc.10",
|
|
40
|
+
"@aztec/builder": "4.0.0-rc.10",
|
|
41
|
+
"@aztec/cli": "4.0.0-rc.10",
|
|
42
|
+
"@aztec/constants": "4.0.0-rc.10",
|
|
43
|
+
"@aztec/entrypoints": "4.0.0-rc.10",
|
|
44
|
+
"@aztec/ethereum": "4.0.0-rc.10",
|
|
45
|
+
"@aztec/foundation": "4.0.0-rc.10",
|
|
46
|
+
"@aztec/kv-store": "4.0.0-rc.10",
|
|
47
|
+
"@aztec/l1-artifacts": "4.0.0-rc.10",
|
|
48
|
+
"@aztec/node-lib": "4.0.0-rc.10",
|
|
49
|
+
"@aztec/noir-contracts.js": "4.0.0-rc.10",
|
|
50
|
+
"@aztec/noir-protocol-circuits-types": "4.0.0-rc.10",
|
|
51
|
+
"@aztec/p2p": "4.0.0-rc.10",
|
|
52
|
+
"@aztec/p2p-bootstrap": "4.0.0-rc.10",
|
|
53
|
+
"@aztec/protocol-contracts": "4.0.0-rc.10",
|
|
54
|
+
"@aztec/prover-client": "4.0.0-rc.10",
|
|
55
|
+
"@aztec/prover-node": "4.0.0-rc.10",
|
|
56
|
+
"@aztec/pxe": "4.0.0-rc.10",
|
|
57
|
+
"@aztec/sequencer-client": "4.0.0-rc.10",
|
|
58
|
+
"@aztec/stdlib": "4.0.0-rc.10",
|
|
59
|
+
"@aztec/telemetry-client": "4.0.0-rc.10",
|
|
60
|
+
"@aztec/txe": "4.0.0-rc.10",
|
|
61
|
+
"@aztec/validator-ha-signer": "4.0.0-rc.10",
|
|
62
|
+
"@aztec/wallets": "4.0.0-rc.10",
|
|
63
|
+
"@aztec/world-state": "4.0.0-rc.10",
|
|
64
64
|
"@types/chalk": "^2.2.0",
|
|
65
65
|
"abitype": "^0.8.11",
|
|
66
66
|
"chalk": "^5.3.0",
|
package/scripts/aztec.sh
CHANGED
|
@@ -21,13 +21,13 @@ function aztec {
|
|
|
21
21
|
|
|
22
22
|
case $cmd in
|
|
23
23
|
test)
|
|
24
|
-
export LOG_LEVEL="${LOG_LEVEL:-error}"
|
|
24
|
+
export LOG_LEVEL="${LOG_LEVEL:-"error;trace:contract_log"}"
|
|
25
25
|
aztec start --txe --port 8081 &
|
|
26
26
|
server_pid=$!
|
|
27
27
|
trap 'kill $server_pid &>/dev/null || true' EXIT
|
|
28
28
|
while ! nc -z 127.0.0.1 8081 &>/dev/null; do sleep 0.2; done
|
|
29
29
|
export NARGO_FOREIGN_CALL_TIMEOUT=300000
|
|
30
|
-
nargo test --silence-warnings
|
|
30
|
+
nargo test --silence-warnings --oracle-resolver http://127.0.0.1:8081 --test-threads 16 "$@"
|
|
31
31
|
;;
|
|
32
32
|
start)
|
|
33
33
|
if [ "${1:-}" == "--local-network" ]; then
|
|
@@ -54,9 +54,13 @@ case $cmd in
|
|
|
54
54
|
|
|
55
55
|
aztec start "$@"
|
|
56
56
|
;;
|
|
57
|
-
|
|
57
|
+
new|init)
|
|
58
58
|
$script_dir/${cmd}.sh "$@"
|
|
59
59
|
;;
|
|
60
|
+
flamegraph)
|
|
61
|
+
echo "Warning: 'aztec flamegraph' is deprecated. Use 'aztec profile flamegraph' instead." >&2
|
|
62
|
+
aztec profile flamegraph "$@"
|
|
63
|
+
;;
|
|
60
64
|
*)
|
|
61
65
|
aztec $cmd "$@"
|
|
62
66
|
;;
|
package/src/bin/index.ts
CHANGED
|
@@ -14,7 +14,9 @@ import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
|
|
|
14
14
|
|
|
15
15
|
import { Command } from 'commander';
|
|
16
16
|
|
|
17
|
+
import { injectCompileCommand } from '../cli/cmds/compile.js';
|
|
17
18
|
import { injectMigrateCommand } from '../cli/cmds/migrate_ha_db.js';
|
|
19
|
+
import { injectProfileCommand } from '../cli/cmds/profile.js';
|
|
18
20
|
import { injectAztecCommands } from '../cli/index.js';
|
|
19
21
|
import { getCliVersion } from '../cli/release_version.js';
|
|
20
22
|
|
|
@@ -47,7 +49,7 @@ async function main() {
|
|
|
47
49
|
|
|
48
50
|
const cliVersion = getCliVersion();
|
|
49
51
|
let program = new Command('aztec');
|
|
50
|
-
program.description('Aztec command line interface').version(cliVersion);
|
|
52
|
+
program.description('Aztec command line interface').version(cliVersion).enablePositionalOptions();
|
|
51
53
|
program = injectAztecCommands(program, userLog, debugLogger);
|
|
52
54
|
program = injectBuilderCommands(program);
|
|
53
55
|
program = injectContractCommands(program, userLog, debugLogger);
|
|
@@ -56,6 +58,8 @@ async function main() {
|
|
|
56
58
|
program = injectAztecNodeCommands(program, userLog, debugLogger);
|
|
57
59
|
program = injectMiscCommands(program, userLog);
|
|
58
60
|
program = injectValidatorKeysCommands(program, userLog);
|
|
61
|
+
program = injectCompileCommand(program, userLog);
|
|
62
|
+
program = injectProfileCommand(program, userLog);
|
|
59
63
|
program = injectMigrateCommand(program, userLog);
|
|
60
64
|
|
|
61
65
|
await program.parseAsync(process.argv);
|
|
@@ -28,7 +28,7 @@ export interface ResolveAdminApiKeyOptions {
|
|
|
28
28
|
/** SHA-256 hex hash of a pre-generated API key. When set, the node uses this hash directly. */
|
|
29
29
|
adminApiKeyHash?: string;
|
|
30
30
|
/** If true, disable admin API key auth entirely. */
|
|
31
|
-
|
|
31
|
+
disableAdminApiKey?: boolean;
|
|
32
32
|
/** If true, force-generate a new key even if one is already persisted. */
|
|
33
33
|
resetAdminApiKey?: boolean;
|
|
34
34
|
/** Root data directory for persistent storage. */
|
|
@@ -39,7 +39,7 @@ export interface ResolveAdminApiKeyOptions {
|
|
|
39
39
|
* Resolves the admin API key for the admin RPC endpoint.
|
|
40
40
|
*
|
|
41
41
|
* Strategy:
|
|
42
|
-
* 1. If opt-out flag is set (`
|
|
42
|
+
* 1. If opt-out flag is set (`disableAdminApiKey`), return undefined (no auth).
|
|
43
43
|
* 2. If a pre-generated hash is provided (`adminApiKeyHash`), use it directly.
|
|
44
44
|
* 3. If a data directory exists, look for a persisted hash file
|
|
45
45
|
* at `<dataDirectory>/admin/api_key_hash`:
|
|
@@ -58,8 +58,8 @@ export async function resolveAdminApiKey(
|
|
|
58
58
|
log: Logger,
|
|
59
59
|
): Promise<AdminApiKeyResolution | undefined> {
|
|
60
60
|
// Operator explicitly opted out of admin auth
|
|
61
|
-
if (options.
|
|
62
|
-
log.warn('Admin API key authentication is DISABLED (--
|
|
61
|
+
if (options.disableAdminApiKey) {
|
|
62
|
+
log.warn('Admin API key authentication is DISABLED (--disable-admin-api-key / AZTEC_DISABLE_ADMIN_API_KEY)');
|
|
63
63
|
return undefined;
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -37,11 +37,11 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
37
37
|
l1RpcUrls: options.l1RpcUrls,
|
|
38
38
|
testAccounts: localNetwork.testAccounts,
|
|
39
39
|
realProofs: false,
|
|
40
|
-
// Setting the epoch duration to
|
|
40
|
+
// Setting the epoch duration to 2 by default for local network. This allows the epoch to be "proven" faster, so
|
|
41
41
|
// the users can consume out hash without having to wait for a long time.
|
|
42
42
|
// Note: We are not proving anything in the local network (realProofs == false). But in `createLocalNetwork`,
|
|
43
43
|
// the EpochTestSettler will set the out hash to the outbox when an epoch is complete.
|
|
44
|
-
aztecEpochDuration:
|
|
44
|
+
aztecEpochDuration: 2,
|
|
45
45
|
},
|
|
46
46
|
userLog,
|
|
47
47
|
);
|
|
@@ -109,7 +109,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
109
109
|
const apiKeyResolution = await resolveAdminApiKey(
|
|
110
110
|
{
|
|
111
111
|
adminApiKeyHash: options.adminApiKeyHash,
|
|
112
|
-
|
|
112
|
+
disableAdminApiKey: options.disableAdminApiKey,
|
|
113
113
|
resetAdminApiKey: options.resetAdminApiKey,
|
|
114
114
|
dataDirectory: options.dataDirectory,
|
|
115
115
|
},
|
|
@@ -148,7 +148,7 @@ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logg
|
|
|
148
148
|
userLog(' The key hash has been persisted — on next restart, the same key will be used.');
|
|
149
149
|
}
|
|
150
150
|
userLog('');
|
|
151
|
-
userLog(' To disable admin auth: --
|
|
151
|
+
userLog(' To disable admin auth: --disable-admin-api-key or AZTEC_DISABLE_ADMIN_API_KEY=true');
|
|
152
152
|
userLog(separator);
|
|
153
153
|
userLog('');
|
|
154
154
|
}
|
|
@@ -150,12 +150,13 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = {
|
|
|
150
150
|
env: 'AZTEC_ADMIN_API_KEY_HASH',
|
|
151
151
|
},
|
|
152
152
|
{
|
|
153
|
-
flag: '--
|
|
153
|
+
flag: '--disable-admin-api-key',
|
|
154
154
|
description:
|
|
155
155
|
'Disable API key authentication on the admin RPC endpoint. By default, a key is auto-generated, displayed once, and its hash is persisted.',
|
|
156
156
|
defaultValue: false,
|
|
157
|
-
env: '
|
|
158
|
-
|
|
157
|
+
env: 'AZTEC_DISABLE_ADMIN_API_KEY',
|
|
158
|
+
// undefined means the flag was passed without a value (boolean toggle), treat as true.
|
|
159
|
+
parseVal: val => val === undefined || val === 'true' || val === '1',
|
|
159
160
|
},
|
|
160
161
|
{
|
|
161
162
|
flag: '--reset-admin-api-key',
|
package/src/cli/cli.ts
CHANGED
|
@@ -39,7 +39,6 @@ Additional commands:
|
|
|
39
39
|
|
|
40
40
|
init [folder] [options] creates a new Aztec Noir project.
|
|
41
41
|
new <path> [options] creates a new Aztec Noir project in a new directory.
|
|
42
|
-
compile [options] compiles Aztec Noir contracts.
|
|
43
42
|
test [options] starts a TXE and runs "nargo test" using it as the oracle resolver.
|
|
44
43
|
`,
|
|
45
44
|
);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { execFileSync } from 'child_process';
|
|
4
|
+
import type { Command } from 'commander';
|
|
5
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
6
|
+
|
|
7
|
+
import { readArtifactFiles } from './utils/artifacts.js';
|
|
8
|
+
import { run } from './utils/spawn.js';
|
|
9
|
+
|
|
10
|
+
/** Returns paths to contract artifacts in the target directory. */
|
|
11
|
+
async function collectContractArtifacts(): Promise<string[]> {
|
|
12
|
+
let files;
|
|
13
|
+
try {
|
|
14
|
+
files = await readArtifactFiles('target');
|
|
15
|
+
} catch (err: any) {
|
|
16
|
+
if (err?.message?.includes('does not exist')) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
throw err;
|
|
20
|
+
}
|
|
21
|
+
return files.filter(f => Array.isArray(f.content.functions)).map(f => f.filePath);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Strips the `__aztec_nr_internals__` prefix from function names in contract artifacts. */
|
|
25
|
+
async function stripInternalPrefixes(artifactPaths: string[]): Promise<void> {
|
|
26
|
+
for (const path of artifactPaths) {
|
|
27
|
+
const artifact = JSON.parse(await readFile(path, 'utf-8'));
|
|
28
|
+
for (const fn of artifact.functions) {
|
|
29
|
+
if (typeof fn.name === 'string') {
|
|
30
|
+
fn.name = fn.name.replace(/^__aztec_nr_internals__/, '');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
await writeFile(path, JSON.stringify(artifact, null, 2) + '\n');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Compiles Aztec Noir contracts and postprocesses artifacts. */
|
|
38
|
+
async function compileAztecContract(nargoArgs: string[], log: LogFn): Promise<void> {
|
|
39
|
+
const nargo = process.env.NARGO ?? 'nargo';
|
|
40
|
+
const bb = process.env.BB ?? 'bb';
|
|
41
|
+
|
|
42
|
+
await run(nargo, ['compile', ...nargoArgs]);
|
|
43
|
+
|
|
44
|
+
const artifacts = await collectContractArtifacts();
|
|
45
|
+
|
|
46
|
+
if (artifacts.length > 0) {
|
|
47
|
+
log('Postprocessing contracts...');
|
|
48
|
+
const bbArgs = artifacts.flatMap(a => ['-i', a]);
|
|
49
|
+
await run(bb, ['aztec_process', ...bbArgs]);
|
|
50
|
+
|
|
51
|
+
// TODO: This should be part of bb aztec_process!
|
|
52
|
+
await stripInternalPrefixes(artifacts);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
log('Compilation complete!');
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function injectCompileCommand(program: Command, log: LogFn): Command {
|
|
59
|
+
program
|
|
60
|
+
.command('compile')
|
|
61
|
+
.argument('[nargo-args...]')
|
|
62
|
+
.passThroughOptions()
|
|
63
|
+
.allowUnknownOption()
|
|
64
|
+
.description(
|
|
65
|
+
'Compile Aztec Noir contracts using nargo and postprocess them to generate transpiled artifacts and verification keys. All options are forwarded to nargo compile.',
|
|
66
|
+
)
|
|
67
|
+
.addHelpText('after', () => {
|
|
68
|
+
// Show nargo's own compile options so users see all available flags in one place.
|
|
69
|
+
const nargo = process.env.NARGO ?? 'nargo';
|
|
70
|
+
try {
|
|
71
|
+
const output = execFileSync(nargo, ['compile', '--help'], { encoding: 'utf-8' });
|
|
72
|
+
return `\nUnderlying nargo compile options:\n\n${output}`;
|
|
73
|
+
} catch {
|
|
74
|
+
return '\n(Run "nargo compile --help" to see available nargo options)';
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
.action((nargoArgs: string[]) => compileAztecContract(nargoArgs, log));
|
|
78
|
+
|
|
79
|
+
return program;
|
|
80
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import type { Command } from 'commander';
|
|
4
|
+
|
|
5
|
+
import { profileFlamegraph } from './profile_flamegraph.js';
|
|
6
|
+
import { profileGates } from './profile_gates.js';
|
|
7
|
+
|
|
8
|
+
export function injectProfileCommand(program: Command, log: LogFn): Command {
|
|
9
|
+
const profile = program.command('profile').description('Profile compiled Aztec artifacts.');
|
|
10
|
+
|
|
11
|
+
profile
|
|
12
|
+
.command('gates')
|
|
13
|
+
.argument('[target-dir]', 'Path to the compiled artifacts directory', './target')
|
|
14
|
+
.description('Display gate counts for all compiled Aztec artifacts in a target directory.')
|
|
15
|
+
.action((targetDir: string) => profileGates(targetDir, log));
|
|
16
|
+
|
|
17
|
+
profile
|
|
18
|
+
.command('flamegraph')
|
|
19
|
+
.argument('<contract-artifact>', 'Path to the compiled contract artifact JSON')
|
|
20
|
+
.argument('<function>', 'Name of the contract function to profile')
|
|
21
|
+
.description('Generate a gate count flamegraph SVG for a contract function.')
|
|
22
|
+
.action((artifactPath: string, functionName: string) => profileFlamegraph(artifactPath, functionName, log));
|
|
23
|
+
|
|
24
|
+
return program;
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
|
|
3
|
+
import { readFile, rename, rm, writeFile } from 'fs/promises';
|
|
4
|
+
import { basename, dirname, join } from 'path';
|
|
5
|
+
|
|
6
|
+
import { makeFunctionArtifact } from './profile_utils.js';
|
|
7
|
+
import type { CompiledArtifact } from './utils/artifacts.js';
|
|
8
|
+
import { run } from './utils/spawn.js';
|
|
9
|
+
|
|
10
|
+
/** Generates a gate count flamegraph SVG for a single contract function. */
|
|
11
|
+
export async function profileFlamegraph(artifactPath: string, functionName: string, log: LogFn): Promise<void> {
|
|
12
|
+
const raw = await readFile(artifactPath, 'utf-8');
|
|
13
|
+
const artifact: CompiledArtifact = JSON.parse(raw);
|
|
14
|
+
|
|
15
|
+
if (!Array.isArray(artifact.functions)) {
|
|
16
|
+
throw new Error(`${artifactPath} does not appear to be a contract artifact (no functions array)`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const func = artifact.functions.find(f => f.name === functionName);
|
|
20
|
+
if (!func) {
|
|
21
|
+
const available = artifact.functions.map(f => f.name).join(', ');
|
|
22
|
+
throw new Error(`Function "${functionName}" not found in artifact. Available: ${available}`);
|
|
23
|
+
}
|
|
24
|
+
if (func.is_unconstrained) {
|
|
25
|
+
throw new Error(`Function "${functionName}" is unconstrained and cannot be profiled`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const outputDir = dirname(artifactPath);
|
|
29
|
+
const contractName = basename(artifactPath, '.json');
|
|
30
|
+
const functionArtifact = join(outputDir, `${contractName}-${functionName}.json`);
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
await writeFile(functionArtifact, makeFunctionArtifact(artifact, func));
|
|
34
|
+
|
|
35
|
+
const profiler = process.env.PROFILER_PATH ?? 'noir-profiler';
|
|
36
|
+
const bb = process.env.BB ?? 'bb';
|
|
37
|
+
|
|
38
|
+
await run(profiler, [
|
|
39
|
+
'gates',
|
|
40
|
+
'--artifact-path',
|
|
41
|
+
functionArtifact,
|
|
42
|
+
'--backend-path',
|
|
43
|
+
bb,
|
|
44
|
+
'--backend-gates-command',
|
|
45
|
+
'gates',
|
|
46
|
+
'--output',
|
|
47
|
+
outputDir,
|
|
48
|
+
'--scheme',
|
|
49
|
+
'chonk',
|
|
50
|
+
'--include_gates_per_opcode',
|
|
51
|
+
]);
|
|
52
|
+
|
|
53
|
+
// noir-profiler names the SVG using the internal function name which
|
|
54
|
+
// retains the __aztec_nr_internals__ prefix in the bytecode metadata.
|
|
55
|
+
const srcSvg = join(outputDir, `__aztec_nr_internals__${functionName}_gates.svg`);
|
|
56
|
+
const destSvg = join(outputDir, `${contractName}-${functionName}-flamegraph.svg`);
|
|
57
|
+
await rename(srcSvg, destSvg);
|
|
58
|
+
|
|
59
|
+
log(`Flamegraph written to ${destSvg}`);
|
|
60
|
+
} finally {
|
|
61
|
+
await rm(functionArtifact, { force: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
2
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
3
|
+
|
|
4
|
+
import { execFile as execFileCb } from 'child_process';
|
|
5
|
+
import { rm } from 'fs/promises';
|
|
6
|
+
import { promisify } from 'util';
|
|
7
|
+
|
|
8
|
+
import { MAX_CONCURRENT, discoverArtifacts } from './profile_utils.js';
|
|
9
|
+
|
|
10
|
+
const execFile = promisify(execFileCb);
|
|
11
|
+
|
|
12
|
+
interface GateCountResult {
|
|
13
|
+
name: string;
|
|
14
|
+
gateCount: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Parses circuit_size from bb gates JSON output: { "functions": [{ "circuit_size": N }] } */
|
|
18
|
+
function parseGateCount(stdout: string): number {
|
|
19
|
+
const parsed = JSON.parse(stdout);
|
|
20
|
+
const size = parsed?.functions?.[0]?.circuit_size;
|
|
21
|
+
if (typeof size !== 'number') {
|
|
22
|
+
throw new Error('Failed to parse circuit_size from bb gates output');
|
|
23
|
+
}
|
|
24
|
+
return size;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Runs bb gates on a single artifact file and returns the gate count. */
|
|
28
|
+
async function getGateCount(bb: string, artifactPath: string): Promise<number> {
|
|
29
|
+
const { stdout } = await execFile(bb, ['gates', '--scheme', 'chonk', '-b', artifactPath]);
|
|
30
|
+
return parseGateCount(stdout);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Profiles all compiled artifacts in a target directory and prints gate counts. */
|
|
34
|
+
export async function profileGates(targetDir: string, log: LogFn): Promise<void> {
|
|
35
|
+
const bb = process.env.BB ?? 'bb';
|
|
36
|
+
const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
|
|
37
|
+
|
|
38
|
+
if (artifacts.length === 0) {
|
|
39
|
+
log('No artifacts found in target directory.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const results: GateCountResult[] = await asyncPool(MAX_CONCURRENT, artifacts, async artifact => ({
|
|
45
|
+
name: artifact.name,
|
|
46
|
+
gateCount: await getGateCount(bb, artifact.filePath),
|
|
47
|
+
}));
|
|
48
|
+
results.sort((a, b) => a.name.localeCompare(b.name));
|
|
49
|
+
|
|
50
|
+
if (results.length === 0) {
|
|
51
|
+
log('No constrained circuits found.');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const maxNameLen = Math.max(...results.map(r => r.name.length));
|
|
56
|
+
log('');
|
|
57
|
+
log('Gate counts:');
|
|
58
|
+
log('-'.repeat(maxNameLen + 16));
|
|
59
|
+
for (const { name, gateCount } of results) {
|
|
60
|
+
log(`${name.padEnd(maxNameLen)} ${gateCount.toLocaleString().padStart(12)}`);
|
|
61
|
+
}
|
|
62
|
+
log('-'.repeat(maxNameLen + 16));
|
|
63
|
+
log(`Total: ${results.length} circuit(s)`);
|
|
64
|
+
} finally {
|
|
65
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
66
|
+
}
|
|
67
|
+
}
|