@aztec/aztec 0.0.1-commit.ef17749e1 → 0.0.1-commit.f1b29a41e
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/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +12 -5
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +9 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
- package/dest/cli/cmds/profile_flamegraph.js +2 -1
- package/dest/cli/cmds/profile_gates.d.ts +1 -1
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +2 -1
- package/dest/cli/cmds/standby.d.ts +10 -5
- package/dest/cli/cmds/standby.d.ts.map +1 -1
- package/dest/cli/cmds/standby.js +33 -14
- package/dest/cli/cmds/start_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +7 -1
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +7 -1
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +90 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +41 -0
- package/dest/testing/anvil_test_watcher.js +1 -1
- package/dest/testing/cheat_codes.js +1 -1
- package/dest/testing/epoch_test_settler.d.ts +1 -1
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +3 -4
- package/package.json +34 -34
- package/scripts/aztec.sh +4 -1
- package/src/cli/aztec_start_action.ts +7 -5
- package/src/cli/cmds/compile.ts +11 -1
- package/src/cli/cmds/profile_flamegraph.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +2 -1
- package/src/cli/cmds/standby.ts +37 -16
- package/src/cli/cmds/start_node.ts +8 -1
- package/src/cli/cmds/start_prover_broker.ts +8 -1
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +54 -0
- package/src/testing/anvil_test_watcher.ts +1 -1
- package/src/testing/cheat_codes.ts +1 -1
- package/src/testing/epoch_test_settler.ts +3 -4
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
2
2
|
export declare function aztecStart(options: any, userLog: LogFn, debugLogger: Logger): Promise<void>;
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXp0ZWNfc3RhcnRfYWN0aW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL2F6dGVjX3N0YXJ0X2FjdGlvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFPQSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFhM0Qsd0JBQXNCLFVBQVUsQ0FBQyxPQUFPLEVBQUUsR0FBRyxFQUFFLE9BQU8sRUFBRSxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0saUJBMklqRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aztec_start_action.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_action.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAa3D,wBAAsB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"aztec_start_action.d.ts","sourceRoot":"","sources":["../../src/cli/aztec_start_action.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAa3D,wBAAsB,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,iBA2IjF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getActiveNetworkName } from '@aztec/foundation/config';
|
|
2
2
|
import { createNamespacedSafeJsonRpcServer, getApiKeyAuthMiddleware, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
3
|
-
import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
3
|
+
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
4
4
|
import { getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
5
5
|
import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
|
|
6
6
|
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
@@ -14,13 +14,13 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
14
14
|
const signalHandlers = [];
|
|
15
15
|
const services = {};
|
|
16
16
|
const adminServices = {};
|
|
17
|
+
const packageVersion = getPackageVersion();
|
|
17
18
|
let config = undefined;
|
|
18
19
|
if (options.localNetwork) {
|
|
19
|
-
const cliVersion = getPackageVersion() ?? 'unknown';
|
|
20
20
|
const localNetwork = extractNamespacedOptions(options, 'local-network');
|
|
21
21
|
localNetwork.testAccounts = true;
|
|
22
22
|
userLog(`${splash}\n${github}\n\n`);
|
|
23
|
-
userLog(`Setting up Aztec local network ${
|
|
23
|
+
userLog(`Setting up Aztec local network ${packageVersion ?? 'unknown'}, please stand by...`);
|
|
24
24
|
const { node, stop } = await createLocalNetwork({
|
|
25
25
|
l1Mnemonic: localNetwork.l1Mnemonic,
|
|
26
26
|
l1RpcUrls: options.l1RpcUrls,
|
|
@@ -38,6 +38,10 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
38
38
|
node,
|
|
39
39
|
AztecNodeApiSchema
|
|
40
40
|
];
|
|
41
|
+
adminServices.node = [
|
|
42
|
+
node,
|
|
43
|
+
AztecNodeAdminApiSchema
|
|
44
|
+
];
|
|
41
45
|
} else {
|
|
42
46
|
// Route --prover-node through startNode
|
|
43
47
|
if (options.proverNode && !options.node) {
|
|
@@ -75,6 +79,9 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
75
79
|
}
|
|
76
80
|
installSignalHandlers(debugLogger.info, signalHandlers);
|
|
77
81
|
const versions = getVersions(config);
|
|
82
|
+
const versioningOpts = {
|
|
83
|
+
packageVersion
|
|
84
|
+
};
|
|
78
85
|
// Start the main JSON-RPC server
|
|
79
86
|
if (Object.entries(services).length > 0) {
|
|
80
87
|
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
|
|
@@ -82,7 +89,7 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
82
89
|
log: debugLogger,
|
|
83
90
|
middlewares: [
|
|
84
91
|
getOtelJsonRpcPropagationMiddleware(),
|
|
85
|
-
getVersioningMiddleware(versions)
|
|
92
|
+
getVersioningMiddleware(versions, versioningOpts)
|
|
86
93
|
],
|
|
87
94
|
maxBatchSize: options.rpcMaxBatchSize,
|
|
88
95
|
maxBodySizeBytes: options.rpcMaxBodySize
|
|
@@ -96,7 +103,7 @@ export async function aztecStart(options, userLog, debugLogger) {
|
|
|
96
103
|
if (Object.entries(adminServices).length > 0) {
|
|
97
104
|
const adminMiddlewares = [
|
|
98
105
|
getOtelJsonRpcPropagationMiddleware(),
|
|
99
|
-
getVersioningMiddleware(versions)
|
|
106
|
+
getVersioningMiddleware(versions, versioningOpts)
|
|
100
107
|
];
|
|
101
108
|
// Resolve the admin API key (auto-generated and persisted, or opt-out)
|
|
102
109
|
const apiKeyResolution = await resolveAdminApiKey({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
2
|
import type { Command } from 'commander';
|
|
3
3
|
export declare function injectCompileCommand(program: Command, log: LogFn): Command;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcGlsZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL2NvbXBpbGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFHbkQsT0FBTyxLQUFLLEVBQUUsT0FBTyxFQUFFLE1BQU0sV0FBVyxDQUFDO0FBdUt6Qyx3QkFBZ0Isb0JBQW9CLENBQUMsT0FBTyxFQUFFLE9BQU8sRUFBRSxHQUFHLEVBQUUsS0FBSyxHQUFHLE9BQU8sQ0FzQjFFIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/compile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/compile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuKzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAsB1E"}
|
package/dest/cli/cmds/compile.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { findBbBinary } from '@aztec/bb.js';
|
|
1
2
|
import { execFileSync } from 'child_process';
|
|
2
3
|
import { readFile, writeFile } from 'fs/promises';
|
|
3
4
|
import { join } from 'path';
|
|
4
5
|
import { readArtifactFiles } from './utils/artifacts.js';
|
|
6
|
+
import { needsRecompile } from './utils/needs_recompile.js';
|
|
5
7
|
import { run } from './utils/spawn.js';
|
|
8
|
+
import { warnIfAztecVersionMismatch } from './utils/warn_if_aztec_version_mismatch.js';
|
|
6
9
|
/** Returns paths to contract artifacts in the target directory. */ async function collectContractArtifacts() {
|
|
7
10
|
let files;
|
|
8
11
|
try {
|
|
@@ -116,8 +119,13 @@ import { run } from './utils/spawn.js';
|
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
/** Compiles Aztec Noir contracts and postprocesses artifacts. */ async function compileAztecContract(nargoArgs, log) {
|
|
122
|
+
await warnIfAztecVersionMismatch(log);
|
|
123
|
+
if (!await needsRecompile()) {
|
|
124
|
+
log('No source changes detected, skipping compilation.');
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
119
127
|
const nargo = process.env.NARGO ?? 'nargo';
|
|
120
|
-
const bb = process.env.BB ?? 'bb';
|
|
128
|
+
const bb = process.env.BB ?? findBbBinary() ?? 'bb';
|
|
121
129
|
await run(nargo, [
|
|
122
130
|
'compile',
|
|
123
131
|
...nargoArgs
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
2
|
/** Generates a gate count flamegraph SVG for a single contract function. */
|
|
3
3
|
export declare function profileFlamegraph(artifactPath: string, functionName: string, log: LogFn): Promise<void>;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV9mbGFtZWdyYXBoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvcHJvZmlsZV9mbGFtZWdyYXBoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBU25ELDRFQUE0RTtBQUM1RSx3QkFBc0IsaUJBQWlCLENBQUMsWUFBWSxFQUFFLE1BQU0sRUFBRSxZQUFZLEVBQUUsTUFBTSxFQUFFLEdBQUcsRUFBRSxLQUFLLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQW9EN0cifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_flamegraph.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_flamegraph.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profile_flamegraph.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_flamegraph.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD,4EAA4E;AAC5E,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAoD7G"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findBbBinary } from '@aztec/bb.js';
|
|
1
2
|
import { readFile, rename, rm, writeFile } from 'fs/promises';
|
|
2
3
|
import { basename, dirname, join } from 'path';
|
|
3
4
|
import { makeFunctionArtifact } from './profile_utils.js';
|
|
@@ -22,7 +23,7 @@ import { run } from './utils/spawn.js';
|
|
|
22
23
|
try {
|
|
23
24
|
await writeFile(functionArtifact, makeFunctionArtifact(artifact, func));
|
|
24
25
|
const profiler = process.env.PROFILER_PATH ?? 'noir-profiler';
|
|
25
|
-
const bb = process.env.BB ?? 'bb';
|
|
26
|
+
const bb = process.env.BB ?? findBbBinary() ?? 'bb';
|
|
26
27
|
await run(profiler, [
|
|
27
28
|
'gates',
|
|
28
29
|
'--artifact-path',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { LogFn } from '@aztec/foundation/log';
|
|
2
2
|
/** Profiles all compiled artifacts in a target directory and prints gate counts. */
|
|
3
3
|
export declare function profileGates(targetDir: string, log: LogFn): Promise<void>;
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvZmlsZV9nYXRlcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3Byb2ZpbGVfZ2F0ZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUErQm5ELG9GQUFvRjtBQUNwRix3QkFBc0IsWUFBWSxDQUFDLFNBQVMsRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLEtBQUssR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLENBaUMvRSJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_gates.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_gates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profile_gates.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/profile_gates.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AA+BnD,oFAAoF;AACpF,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAiC/E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findBbBinary } from '@aztec/bb.js';
|
|
1
2
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
2
3
|
import { execFile as execFileCb } from 'child_process';
|
|
3
4
|
import { rm } from 'fs/promises';
|
|
@@ -23,7 +24,7 @@ const execFile = promisify(execFileCb);
|
|
|
23
24
|
return parseGateCount(stdout);
|
|
24
25
|
}
|
|
25
26
|
/** Profiles all compiled artifacts in a target directory and prints gate counts. */ export async function profileGates(targetDir, log) {
|
|
26
|
-
const bb = process.env.BB ?? 'bb';
|
|
27
|
+
const bb = process.env.BB ?? findBbBinary() ?? 'bb';
|
|
27
28
|
const { artifacts, tmpDir } = await discoverArtifacts(targetDir);
|
|
28
29
|
if (artifacts.length === 0) {
|
|
29
30
|
log('No artifacts found in target directory.');
|
|
@@ -12,9 +12,10 @@ export declare function computeExpectedGenesisRoot(config: GenesisStateConfig, u
|
|
|
12
12
|
prefilledPublicData: import("@aztec/stdlib/trees").PublicDataTreeLeaf[];
|
|
13
13
|
}>;
|
|
14
14
|
/**
|
|
15
|
-
* Waits until the canonical rollup's genesis archive root
|
|
16
|
-
* If the rollup is not yet compatible (e.g. during L1 contract upgrades),
|
|
17
|
-
* starts a lightweight HTTP server for K8s liveness probes and polls every 60s
|
|
15
|
+
* Waits until the canonical rollup's genesis archive root, VK tree root, and protocol contracts hash
|
|
16
|
+
* all match the expected local values. If the rollup is not yet compatible (e.g. during L1 contract upgrades),
|
|
17
|
+
* enters standby mode: starts a lightweight HTTP server for K8s liveness probes and polls every 60s
|
|
18
|
+
* until a compatible rollup appears.
|
|
18
19
|
*/
|
|
19
20
|
export declare function waitForCompatibleRollup(config: {
|
|
20
21
|
l1RpcUrls: string[];
|
|
@@ -23,5 +24,9 @@ export declare function waitForCompatibleRollup(config: {
|
|
|
23
24
|
registryAddress: EthAddress;
|
|
24
25
|
};
|
|
25
26
|
rollupVersion?: number;
|
|
26
|
-
},
|
|
27
|
-
|
|
27
|
+
}, expected: {
|
|
28
|
+
genesisArchiveRoot: Fr;
|
|
29
|
+
vkTreeRoot: Fr;
|
|
30
|
+
protocolContractsHash: Fr;
|
|
31
|
+
}, port: number | undefined, userLog: LogFn): Promise<void>;
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhbmRieS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YW5kYnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFHakQsT0FBTyxLQUFLLEVBQUUsa0JBQWtCLEVBQUUsTUFBTSx3QkFBd0IsQ0FBQztBQUVqRSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUVoRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQVNuRDs7OztHQUlHO0FBQ0gsd0JBQXNCLDBCQUEwQixDQUFDLE1BQU0sRUFBRSxrQkFBa0IsRUFBRSxPQUFPLEVBQUUsS0FBSzs7O0dBYTFGO0FBd0JEOzs7OztHQUtHO0FBQ0gsd0JBQXNCLHVCQUF1QixDQUMzQyxNQUFNLEVBQUU7SUFDTixTQUFTLEVBQUUsTUFBTSxFQUFFLENBQUM7SUFDcEIsU0FBUyxFQUFFLE1BQU0sQ0FBQztJQUNsQixXQUFXLEVBQUU7UUFBRSxlQUFlLEVBQUUsVUFBVSxDQUFBO0tBQUUsQ0FBQztJQUM3QyxhQUFhLENBQUMsRUFBRSxNQUFNLENBQUM7Q0FDeEIsRUFDRCxRQUFRLEVBQUU7SUFBRSxrQkFBa0IsRUFBRSxFQUFFLENBQUM7SUFBQyxVQUFVLEVBQUUsRUFBRSxDQUFDO0lBQUMscUJBQXFCLEVBQUUsRUFBRSxDQUFBO0NBQUUsRUFDL0UsSUFBSSxFQUFFLE1BQU0sR0FBRyxTQUFTLEVBQ3hCLE9BQU8sRUFBRSxLQUFLLEdBQ2IsT0FBTyxDQUFDLElBQUksQ0FBQyxDQXdEZiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standby.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/standby.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK;;;GAa1F;
|
|
1
|
+
{"version":3,"file":"standby.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/standby.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD;;;;GAIG;AACH,wBAAsB,0BAA0B,CAAC,MAAM,EAAE,kBAAkB,EAAE,OAAO,EAAE,KAAK;;;GAa1F;AAwBD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,MAAM,EAAE;IACN,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE;QAAE,eAAe,EAAE,UAAU,CAAA;KAAE,CAAC;IAC7C,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,EACD,QAAQ,EAAE;IAAE,kBAAkB,EAAE,EAAE,CAAC;IAAC,UAAU,EAAE,EAAE,CAAC;IAAC,qBAAqB,EAAE,EAAE,CAAA;CAAE,EAC/E,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,OAAO,EAAE,KAAK,GACb,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
package/dest/cli/cmds/standby.js
CHANGED
|
@@ -27,26 +27,45 @@ const ROLLUP_POLL_INTERVAL_S = 60;
|
|
|
27
27
|
prefilledPublicData
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
+
async function checkRollupCompatibility(rollup, expected) {
|
|
31
|
+
const mismatches = [];
|
|
32
|
+
const [l1Genesis, l1Vk, l1Protocol] = await Promise.all([
|
|
33
|
+
rollup.getGenesisArchiveTreeRoot(),
|
|
34
|
+
rollup.getVkTreeRoot(),
|
|
35
|
+
rollup.getProtocolContractsHash()
|
|
36
|
+
]);
|
|
37
|
+
if (!l1Genesis.equals(expected.genesisArchiveRoot)) {
|
|
38
|
+
mismatches.push(`genesis archive root (expected ${expected.genesisArchiveRoot}, got ${l1Genesis})`);
|
|
39
|
+
}
|
|
40
|
+
if (!l1Vk.equals(expected.vkTreeRoot)) {
|
|
41
|
+
mismatches.push(`VK tree root (expected ${expected.vkTreeRoot}, got ${l1Vk})`);
|
|
42
|
+
}
|
|
43
|
+
if (!l1Protocol.equals(expected.protocolContractsHash)) {
|
|
44
|
+
mismatches.push(`protocol contracts hash (expected ${expected.protocolContractsHash}, got ${l1Protocol})`);
|
|
45
|
+
}
|
|
46
|
+
return mismatches;
|
|
47
|
+
}
|
|
30
48
|
/**
|
|
31
|
-
* Waits until the canonical rollup's genesis archive root
|
|
32
|
-
* If the rollup is not yet compatible (e.g. during L1 contract upgrades),
|
|
33
|
-
* starts a lightweight HTTP server for K8s liveness probes and polls every 60s
|
|
34
|
-
|
|
49
|
+
* Waits until the canonical rollup's genesis archive root, VK tree root, and protocol contracts hash
|
|
50
|
+
* all match the expected local values. If the rollup is not yet compatible (e.g. during L1 contract upgrades),
|
|
51
|
+
* enters standby mode: starts a lightweight HTTP server for K8s liveness probes and polls every 60s
|
|
52
|
+
* until a compatible rollup appears.
|
|
53
|
+
*/ export async function waitForCompatibleRollup(config, expected, port, userLog) {
|
|
35
54
|
const publicClient = getPublicClient(config);
|
|
36
55
|
const rollupVersion = config.rollupVersion ?? 'canonical';
|
|
37
56
|
const registry = new RegistryContract(publicClient, config.l1Contracts.registryAddress);
|
|
38
57
|
const rollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
39
58
|
const rollup = new RollupContract(publicClient, rollupAddress.toString());
|
|
40
|
-
let
|
|
59
|
+
let mismatches;
|
|
41
60
|
try {
|
|
42
|
-
|
|
61
|
+
mismatches = await checkRollupCompatibility(rollup, expected);
|
|
43
62
|
} catch (err) {
|
|
44
|
-
throw new Error(`Could not retrieve
|
|
63
|
+
throw new Error(`Could not retrieve rollup config from canonical rollup at ${rollupAddress}: ${err.message}`);
|
|
45
64
|
}
|
|
46
|
-
if (
|
|
65
|
+
if (mismatches.length === 0) {
|
|
47
66
|
return;
|
|
48
67
|
}
|
|
49
|
-
userLog(`
|
|
68
|
+
userLog(`Rollup at ${rollupAddress} is incompatible: ${mismatches.join('; ')}. ` + `Entering standby mode. Will poll every ${ROLLUP_POLL_INTERVAL_S}s for a compatible rollup...`);
|
|
50
69
|
const standbyServer = await startHttpRpcServer({
|
|
51
70
|
getApp: ()=>new Koa(),
|
|
52
71
|
isHealthy: ()=>true
|
|
@@ -58,18 +77,18 @@ const ROLLUP_POLL_INTERVAL_S = 60;
|
|
|
58
77
|
await retryUntil(async ()=>{
|
|
59
78
|
const currentRollupAddress = await registry.getRollupAddress(rollupVersion);
|
|
60
79
|
const currentRollup = new RollupContract(publicClient, currentRollupAddress.toString());
|
|
61
|
-
let
|
|
80
|
+
let currentMismatches;
|
|
62
81
|
try {
|
|
63
|
-
|
|
82
|
+
currentMismatches = await checkRollupCompatibility(currentRollup, expected);
|
|
64
83
|
} catch {
|
|
65
|
-
userLog(`Failed to fetch
|
|
84
|
+
userLog(`Failed to fetch rollup config from rollup at ${currentRollupAddress}. Retrying...`);
|
|
66
85
|
return undefined;
|
|
67
86
|
}
|
|
68
|
-
if (
|
|
87
|
+
if (currentMismatches.length === 0) {
|
|
69
88
|
userLog(`Compatible rollup found at ${currentRollupAddress}. Exiting standby mode.`);
|
|
70
89
|
return true;
|
|
71
90
|
}
|
|
72
|
-
userLog(`Still waiting. Rollup at ${currentRollupAddress}
|
|
91
|
+
userLog(`Still waiting. Rollup at ${currentRollupAddress}: ${currentMismatches.join('; ')}.`);
|
|
73
92
|
return undefined;
|
|
74
93
|
}, 'compatible rollup', 0, ROLLUP_POLL_INTERVAL_S);
|
|
75
94
|
} finally{
|
|
@@ -5,4 +5,4 @@ import type { LogFn } from '@aztec/foundation/log';
|
|
|
5
5
|
export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn, networkName: NetworkNames): Promise<{
|
|
6
6
|
config: AztecNodeConfig;
|
|
7
7
|
}>;
|
|
8
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
8
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUE2QyxNQUFNLG1CQUFtQixDQUFDO0FBS3BHLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBZSxNQUFNLDBCQUEwQixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUEwQm5ELHdCQUFzQixTQUFTLENBQzdCLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLGFBQWEsRUFBRSxxQkFBcUIsRUFDcEMsT0FBTyxFQUFFLEtBQUssRUFDZCxXQUFXLEVBQUUsWUFBWSxHQUN4QixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZUFBZSxDQUFBO0NBQUUsQ0FBQyxDQW9LdEMifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAKpG,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAKpG,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AA0BnD,wBAAsB,SAAS,CAC7B,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,qBAAqB,EACpC,OAAO,EAAE,KAAK,EACd,WAAW,EAAE,YAAY,GACxB,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CAoKtC"}
|
|
@@ -5,6 +5,8 @@ import { getPublicClient } from '@aztec/ethereum/client';
|
|
|
5
5
|
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
6
6
|
import { SecretValue } from '@aztec/foundation/config';
|
|
7
7
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
8
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
9
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
8
10
|
import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
|
|
9
11
|
import { allPxeConfigMappings } from '@aztec/pxe/config';
|
|
10
12
|
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
@@ -70,7 +72,11 @@ export async function startNode(options, signalHandlers, services, adminServices
|
|
|
70
72
|
}
|
|
71
73
|
// Wait for a compatible rollup before proceeding with full L1 config fetch.
|
|
72
74
|
// This prevents crashes when the canonical rollup hasn't been upgraded yet.
|
|
73
|
-
await waitForCompatibleRollup(nodeConfig,
|
|
75
|
+
await waitForCompatibleRollup(nodeConfig, {
|
|
76
|
+
genesisArchiveRoot,
|
|
77
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
78
|
+
protocolContractsHash
|
|
79
|
+
}, options.port, userLog);
|
|
74
80
|
const { addresses, config } = await getL1Config(nodeConfig.l1Contracts.registryAddress, nodeConfig.l1RpcUrls, nodeConfig.l1ChainId, nodeConfig.rollupVersion);
|
|
75
81
|
process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
|
|
76
82
|
if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
|
|
@@ -6,4 +6,4 @@ export declare function startProverBroker(options: any, signalHandlers: (() => P
|
|
|
6
6
|
broker: ProvingJobBroker;
|
|
7
7
|
config: ProverBrokerConfig;
|
|
8
8
|
}>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX2Jyb2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X3Byb3Zlcl9icm9rZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUduRCxPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFLeEIsTUFBTSw2QkFBNkIsQ0FBQztBQUVyQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBTXhFLHdCQUFzQixpQkFBaUIsQ0FDckMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZ0JBQWdCLENBQUM7SUFBQyxNQUFNLEVBQUUsa0JBQWtCLENBQUE7Q0FBRSxDQUFDLENBNENuRSJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start_prover_broker.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_broker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"start_prover_broker.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_broker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAMxE,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,CAAC,CA4CnE"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { getL1Config } from '@aztec/cli/config';
|
|
2
2
|
import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
|
|
3
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
3
5
|
import { ProvingJobBrokerSchema, ProvingJobBrokerSchemaWithDebug, createAndStartProvingBroker, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
|
|
4
6
|
import { getProverNodeBrokerConfigFromEnv } from '@aztec/prover-node';
|
|
5
7
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
@@ -19,7 +21,11 @@ export async function startProverBroker(options, signalHandlers, services, userL
|
|
|
19
21
|
}
|
|
20
22
|
const genesisConfig = getGenesisStateConfigEnvVars();
|
|
21
23
|
const { genesisArchiveRoot } = await computeExpectedGenesisRoot(genesisConfig, userLog);
|
|
22
|
-
await waitForCompatibleRollup(config,
|
|
24
|
+
await waitForCompatibleRollup(config, {
|
|
25
|
+
genesisArchiveRoot,
|
|
26
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
27
|
+
protocolContractsHash
|
|
28
|
+
}, options.port, userLog);
|
|
23
29
|
const { addresses, config: rollupConfig } = await getL1Config(config.l1Contracts.registryAddress, config.l1RpcUrls, config.l1ChainId, config.rollupVersion);
|
|
24
30
|
config.l1Contracts = addresses;
|
|
25
31
|
config.rollupVersion = rollupConfig.rollupVersion;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively collects crate directories starting from startCrateDir by following dependencies declared in Nargo.toml
|
|
3
|
+
* files.
|
|
4
|
+
*
|
|
5
|
+
* When `skipGitDeps` is false (default), git-based deps are followed and fetched into the nargo cache
|
|
6
|
+
* (`$HOME/nargo/<domain>/<repo-path>/<tag>`) if not already present.
|
|
7
|
+
*
|
|
8
|
+
* When `skipGitDeps` is true, git-based deps are ignored entirely.
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectCrateDirs(startCrateDir: string, opts?: {
|
|
11
|
+
skipGitDeps?: boolean;
|
|
12
|
+
}): Promise<string[]>;
|
|
13
|
+
/**
|
|
14
|
+
* Computes the local nargo cache path for a git dependency, mirroring nargo's own `git_dep_location` function.
|
|
15
|
+
* Path format: `$HOME/nargo/<domain>/<repo-path>/<tag>`
|
|
16
|
+
* e.g. `~/nargo/github.com/AztecProtocol/aztec-packages/v0.82.0`
|
|
17
|
+
*
|
|
18
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
19
|
+
*/
|
|
20
|
+
export declare function nargoGitDepPath(gitUrl: string, tag: string): string;
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sbGVjdF9jcmF0ZV9kaXJzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvY29sbGVjdF9jcmF0ZV9kaXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVFBOzs7Ozs7OztHQVFHO0FBQ0gsd0JBQXNCLGdCQUFnQixDQUFDLGFBQWEsRUFBRSxNQUFNLEVBQUUsSUFBSSxDQUFDLEVBQUU7SUFBRSxXQUFXLENBQUMsRUFBRSxPQUFPLENBQUE7Q0FBRSxHQUFHLE9BQU8sQ0FBQyxNQUFNLEVBQUUsQ0FBQyxDQWlFakg7QUFFRDs7Ozs7O0dBTUc7QUFDSCx3QkFBZ0IsZUFBZSxDQUFDLE1BQU0sRUFBRSxNQUFNLEVBQUUsR0FBRyxFQUFFLE1BQU0sR0FBRyxNQUFNLENBS25FIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collect_crate_dirs.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/collect_crate_dirs.ts"],"names":[],"mappings":"AAQA;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAiEjH;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAKnE"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import TOML from '@iarna/toml';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
3
|
+
import { mkdir, readFile, stat } from 'fs/promises';
|
|
4
|
+
import { homedir } from 'os';
|
|
5
|
+
import { dirname, join, resolve } from 'path';
|
|
6
|
+
import { run } from './spawn.js';
|
|
7
|
+
/**
|
|
8
|
+
* Recursively collects crate directories starting from startCrateDir by following dependencies declared in Nargo.toml
|
|
9
|
+
* files.
|
|
10
|
+
*
|
|
11
|
+
* When `skipGitDeps` is false (default), git-based deps are followed and fetched into the nargo cache
|
|
12
|
+
* (`$HOME/nargo/<domain>/<repo-path>/<tag>`) if not already present.
|
|
13
|
+
*
|
|
14
|
+
* When `skipGitDeps` is true, git-based deps are ignored entirely.
|
|
15
|
+
*/ export async function collectCrateDirs(startCrateDir, opts) {
|
|
16
|
+
const { skipGitDeps = false } = opts ?? {};
|
|
17
|
+
const visited = new Set();
|
|
18
|
+
async function visit(crateDir) {
|
|
19
|
+
const absDir = resolve(crateDir);
|
|
20
|
+
if (visited.has(absDir)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
visited.add(absDir);
|
|
24
|
+
const tomlPath = join(absDir, 'Nargo.toml');
|
|
25
|
+
const content = await readFile(tomlPath, 'utf-8').catch(()=>{
|
|
26
|
+
throw new Error(`Incorrectly defined dependency. Nargo.toml not found in ${absDir}`);
|
|
27
|
+
});
|
|
28
|
+
const parsed = TOML.parse(content);
|
|
29
|
+
const members = parsed.workspace?.members;
|
|
30
|
+
// A Nargo.toml is either a workspace root (has workspace.members) or a single crate (has dependencies).
|
|
31
|
+
if (Array.isArray(members)) {
|
|
32
|
+
// The crate is a workspace root and has members defined so we visit the members
|
|
33
|
+
for (const member of members){
|
|
34
|
+
await visit(resolve(absDir, member));
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
// Single crate — follow its deps
|
|
38
|
+
const deps = parsed.dependencies ?? {};
|
|
39
|
+
for (const dep of Object.values(deps)){
|
|
40
|
+
if (!dep || typeof dep !== 'object') {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (typeof dep.path === 'string') {
|
|
44
|
+
// Dependency contains "path" hence it's a local dependency. We just check it's a real directory and then we
|
|
45
|
+
// recursively search through it
|
|
46
|
+
const depPath = resolve(absDir, dep.path);
|
|
47
|
+
const s = await stat(depPath);
|
|
48
|
+
if (!s.isDirectory()) {
|
|
49
|
+
throw new Error(`Dependency path "${dep.path}" in ${tomlPath} resolves to ${depPath} which is not a directory`);
|
|
50
|
+
}
|
|
51
|
+
await visit(depPath);
|
|
52
|
+
} else if (!skipGitDeps && typeof dep.git === 'string' && typeof dep.tag === 'string') {
|
|
53
|
+
// Dependency contains "git" hence it's a git dependency. We ensure it has been fetched and fetch it if
|
|
54
|
+
// it's not the case and then we recursively search through it.
|
|
55
|
+
await fetchAndVisit(dep.git, dep.tag, dep.directory);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function fetchAndVisit(gitUrl, tag, directory) {
|
|
61
|
+
// `directory` is set when the dep lives in a subdirectory of a repository, e.g.:
|
|
62
|
+
// aztec = { git = "https://github.com/AztecProtocol/aztec-packages", tag = "v0.82.0",
|
|
63
|
+
// directory = "noir-projects/aztec-nr/aztec" }
|
|
64
|
+
// In that case nargo clones the whole repo and the crate root is <cachePath>/<directory>.
|
|
65
|
+
const cachePath = nargoGitDepPath(gitUrl, tag);
|
|
66
|
+
const crateDir = directory ? join(cachePath, directory) : cachePath;
|
|
67
|
+
await ensureGitDepCached(gitUrl, tag, cachePath);
|
|
68
|
+
await visit(crateDir);
|
|
69
|
+
}
|
|
70
|
+
await visit(startCrateDir);
|
|
71
|
+
return [
|
|
72
|
+
...visited
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Computes the local nargo cache path for a git dependency, mirroring nargo's own `git_dep_location` function.
|
|
77
|
+
* Path format: `$HOME/nargo/<domain>/<repo-path>/<tag>`
|
|
78
|
+
* e.g. `~/nargo/github.com/AztecProtocol/aztec-packages/v0.82.0`
|
|
79
|
+
*
|
|
80
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
81
|
+
*/ export function nargoGitDepPath(gitUrl, tag) {
|
|
82
|
+
const url = new URL(gitUrl);
|
|
83
|
+
const domain = url.hostname;
|
|
84
|
+
const repoPath = url.pathname.replace(/^\//, '');
|
|
85
|
+
return join(process.env.HOME ?? homedir(), 'nargo', domain, repoPath, tag);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Ensures a git dep is present in the nargo cache, cloning it if it isn't. Mirrors nargo's `clone_git_repo`.
|
|
89
|
+
* If cloning fails (e.g. no network), throws with a message suggesting `nargo check` to prime the cache.
|
|
90
|
+
*
|
|
91
|
+
* Source: noir/noir-repo/tooling/nargo_toml/src/git.rs
|
|
92
|
+
*/ async function ensureGitDepCached(gitUrl, tag, cachePath) {
|
|
93
|
+
if (existsSync(cachePath)) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
await mkdir(dirname(cachePath), {
|
|
97
|
+
recursive: true
|
|
98
|
+
});
|
|
99
|
+
try {
|
|
100
|
+
await run('git', [
|
|
101
|
+
'-c',
|
|
102
|
+
'advice.detachedHead=false',
|
|
103
|
+
'clone',
|
|
104
|
+
'--depth',
|
|
105
|
+
'1',
|
|
106
|
+
'--branch',
|
|
107
|
+
tag,
|
|
108
|
+
gitUrl,
|
|
109
|
+
cachePath
|
|
110
|
+
]);
|
|
111
|
+
} catch (err) {
|
|
112
|
+
throw new Error(`Failed to fetch git dependency ${gitUrl}@${tag}: ${err?.message ?? err}.\n` + `Try running \`nargo check\` first to prime the dependency cache.`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if recompilation is needed: either no artifacts exist in target/ or any .nr or Nargo.toml source file
|
|
3
|
+
* (including path-based dependencies) is newer than the oldest artifact. We compare against the oldest artifact so
|
|
4
|
+
* that a source change between the oldest and newest compilation (e.g. in a multi-contract workspace) still triggers
|
|
5
|
+
* a recompile.
|
|
6
|
+
*
|
|
7
|
+
* Note: The above implies that if there is a random json file in the target dir we would be always recompiling.
|
|
8
|
+
*/
|
|
9
|
+
export declare function needsRecompile(): Promise<boolean>;
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmVlZHNfcmVjb21waWxlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvbmVlZHNfcmVjb21waWxlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBOzs7Ozs7O0dBT0c7QUFDSCx3QkFBc0IsY0FBYyxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsQ0FXdkQifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"needs_recompile.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/needs_recompile.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAWvD"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { readdir, stat } from 'fs/promises';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { collectCrateDirs } from './collect_crate_dirs.js';
|
|
4
|
+
/**
|
|
5
|
+
* Returns true if recompilation is needed: either no artifacts exist in target/ or any .nr or Nargo.toml source file
|
|
6
|
+
* (including path-based dependencies) is newer than the oldest artifact. We compare against the oldest artifact so
|
|
7
|
+
* that a source change between the oldest and newest compilation (e.g. in a multi-contract workspace) still triggers
|
|
8
|
+
* a recompile.
|
|
9
|
+
*
|
|
10
|
+
* Note: The above implies that if there is a random json file in the target dir we would be always recompiling.
|
|
11
|
+
*/ export async function needsRecompile() {
|
|
12
|
+
const oldestArtifactMs = await getOldestArtifactModificationTime('target');
|
|
13
|
+
if (oldestArtifactMs === undefined) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
// Git deps are pinned to a specific tag in Nargo.toml and nargo always fetches an exact tag, so their contents never
|
|
17
|
+
// change without Nargo.toml itself changing — and Nargo.toml is already tracked as a source file. Hence we can
|
|
18
|
+
// safely ignore checking source files of git deps.
|
|
19
|
+
const crateDirs = await collectCrateDirs('.', {
|
|
20
|
+
skipGitDeps: true
|
|
21
|
+
});
|
|
22
|
+
return hasNewerSourceFile(crateDirs, oldestArtifactMs);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns the last modification time (timestamp in ms) of the oldest .json artifact in targetDir, or undefined if
|
|
26
|
+
* none exist.
|
|
27
|
+
*/ async function getOldestArtifactModificationTime(targetDir) {
|
|
28
|
+
let entries;
|
|
29
|
+
try {
|
|
30
|
+
entries = (await readdir(targetDir)).filter((f)=>f.endsWith('.json'));
|
|
31
|
+
} catch (err) {
|
|
32
|
+
if (err?.code === 'ENOENT') {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
throw err;
|
|
36
|
+
}
|
|
37
|
+
if (entries.length === 0) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
let oldest = Infinity;
|
|
41
|
+
for (const entry of entries){
|
|
42
|
+
const s = await stat(join(targetDir, entry));
|
|
43
|
+
if (s.mtimeMs < oldest) {
|
|
44
|
+
oldest = s.mtimeMs;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return oldest;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Walks crate dirs looking for .nr and Nargo.toml files newer than thresholdMs. Short-circuits on the first match.
|
|
51
|
+
*/ async function hasNewerSourceFile(crateDirs, thresholdMs) {
|
|
52
|
+
// Returns true if it find a new file than thresholdMs, false otherwise
|
|
53
|
+
async function walkForNewer(dir) {
|
|
54
|
+
let entries;
|
|
55
|
+
try {
|
|
56
|
+
entries = await readdir(dir, {
|
|
57
|
+
withFileTypes: true
|
|
58
|
+
});
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
// We iterate over the entries in the dir
|
|
63
|
+
for (const entry of entries){
|
|
64
|
+
const fullPath = join(dir, entry.name);
|
|
65
|
+
if (entry.isDirectory()) {
|
|
66
|
+
// If the entry is a dir and it's not called `target` we recursively enter it
|
|
67
|
+
if (entry.name === 'target') {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (await walkForNewer(fullPath)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
} else if (entry.name === 'Nargo.toml' || entry.name.endsWith('.nr')) {
|
|
74
|
+
// The entry is a Nargo.toml file or *.nr file so we check the timestamp
|
|
75
|
+
const s = await stat(fullPath);
|
|
76
|
+
if (s.mtimeMs > thresholdMs) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
// We search through the crate dirs
|
|
84
|
+
for (const dir of crateDirs){
|
|
85
|
+
if (await walkForNewer(dir)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
2
|
+
/** Warns if the `aztec` dependency tag in any crate's Nargo.toml doesn't match the CLI version. */
|
|
3
|
+
export declare function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2Fybl9pZl9henRlY192ZXJzaW9uX21pc21hdGNoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvd2Fybl9pZl9henRlY192ZXJzaW9uX21pc21hdGNoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBU25ELG1HQUFtRztBQUNuRyx3QkFBc0IsMEJBQTBCLENBQUMsR0FBRyxFQUFFLEtBQUssRUFBRSxVQUFVLENBQUMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxDQTJDL0YifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"warn_if_aztec_version_mismatch.d.ts","sourceRoot":"","sources":["../../../../src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AASnD,mGAAmG;AACnG,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2C/F"}
|