@aztec/aztec 0.0.1-commit.fff30aa → 0.0.1-dev

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.
Files changed (58) hide show
  1. package/dest/bin/index.js +1 -1
  2. package/dest/cli/aztec_start_action.js +1 -1
  3. package/dest/cli/aztec_start_options.d.ts +1 -1
  4. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  5. package/dest/cli/aztec_start_options.js +1 -7
  6. package/dest/cli/cmds/compile.d.ts +1 -1
  7. package/dest/cli/cmds/compile.d.ts.map +1 -1
  8. package/dest/cli/cmds/compile.js +6 -8
  9. package/dest/cli/cmds/profile.d.ts +1 -1
  10. package/dest/cli/cmds/profile.d.ts.map +1 -1
  11. package/dest/cli/cmds/profile.js +1 -1
  12. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  13. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  14. package/dest/cli/cmds/profile_gates.js +21 -3
  15. package/dest/cli/cmds/standby.d.ts +28 -2
  16. package/dest/cli/cmds/standby.d.ts.map +1 -1
  17. package/dest/cli/cmds/standby.js +44 -1
  18. package/dest/cli/cmds/start_node.d.ts +1 -1
  19. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  20. package/dest/cli/cmds/start_node.js +8 -6
  21. package/dest/cli/cmds/start_prover_agent.js +2 -2
  22. package/dest/cli/cmds/start_prover_broker.js +2 -2
  23. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +1 -1
  24. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -1
  25. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +2 -3
  26. package/dest/cli/util.d.ts +10 -5
  27. package/dest/cli/util.d.ts.map +1 -1
  28. package/dest/cli/util.js +19 -48
  29. package/dest/local-network/banana_fpc.d.ts +1 -1
  30. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  31. package/dest/local-network/banana_fpc.js +8 -6
  32. package/package.json +34 -34
  33. package/scripts/add_crate.sh +11 -60
  34. package/scripts/aztec.sh +0 -1
  35. package/scripts/init.sh +5 -5
  36. package/scripts/new.sh +2 -2
  37. package/scripts/setup_workspace.sh +3 -2
  38. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  39. package/scripts/templates/blank/contract/src/main.nr +10 -0
  40. package/scripts/templates/blank/test/Nargo.toml +7 -0
  41. package/scripts/templates/blank/test/src/lib.nr +11 -0
  42. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  43. package/scripts/templates/counter/contract/src/main.nr +48 -0
  44. package/scripts/templates/counter/test/Nargo.toml +7 -0
  45. package/scripts/templates/counter/test/src/lib.nr +32 -0
  46. package/src/bin/index.ts +1 -1
  47. package/src/cli/aztec_start_action.ts +1 -1
  48. package/src/cli/aztec_start_options.ts +2 -10
  49. package/src/cli/cmds/compile.ts +7 -9
  50. package/src/cli/cmds/profile.ts +2 -1
  51. package/src/cli/cmds/profile_gates.ts +20 -4
  52. package/src/cli/cmds/standby.ts +54 -2
  53. package/src/cli/cmds/start_node.ts +8 -15
  54. package/src/cli/cmds/start_prover_agent.ts +2 -2
  55. package/src/cli/cmds/start_prover_broker.ts +2 -2
  56. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +2 -3
  57. package/src/cli/util.ts +20 -61
  58. package/src/local-network/banana_fpc.ts +4 -7
@@ -1,7 +1,6 @@
1
1
  import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
2
2
  import { Fr } from '@aztec/aztec.js/fields';
3
3
  import { getL1Config } from '@aztec/cli/config';
4
- import { getPublicClient } from '@aztec/ethereum/client';
5
4
  import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
6
5
  import { type NetworkNames, SecretValue } from '@aztec/foundation/config';
7
6
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
@@ -26,14 +25,9 @@ import {
26
25
  import { EmbeddedWallet } from '@aztec/wallets/embedded';
27
26
 
28
27
  import { createAztecNode } from '../../local-network/index.js';
29
- import {
30
- extractNamespacedOptions,
31
- extractRelevantOptions,
32
- preloadCrsDataForVerifying,
33
- setupVersionChecker,
34
- } from '../util.js';
28
+ import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying } from '../util.js';
35
29
  import { getVersions } from '../versioning.js';
36
- import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
30
+ import { computeExpectedGenesisRoot, setupAutoShutdown, waitForCompatibleRollup } from './standby.js';
37
31
  import { startProverBroker } from './start_prover_broker.js';
38
32
 
39
33
  export async function startNode(
@@ -187,15 +181,14 @@ export async function startNode(
187
181
  await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
188
182
  }
189
183
 
190
- if (nodeConfig.enableVersionCheck && networkName !== 'local') {
191
- const cacheDir = process.env.DATA_DIRECTORY ? `${process.env.DATA_DIRECTORY}/cache` : undefined;
184
+ if (nodeConfig.enableAutoShutdown && networkName !== 'local' && followsCanonicalRollup) {
192
185
  try {
193
- await setupVersionChecker(
194
- networkName,
195
- followsCanonicalRollup,
196
- getPublicClient(nodeConfig!),
186
+ await setupAutoShutdown(
187
+ nodeConfig,
188
+ nodeConfig.l1Contracts.registryAddress,
189
+ (nodeConfig.rollupVersion as number | 'canonical') ?? 'canonical',
190
+ { genesisArchiveRoot, vkTreeRoot: getVKTreeRoot(), protocolContractsHash },
197
191
  signalHandlers,
198
- cacheDir,
199
192
  );
200
193
  } catch {
201
194
  /* no-op */
@@ -24,8 +24,8 @@ export async function startProverAgent(
24
24
  services: NamespacedApiHandlers,
25
25
  userLog: LogFn,
26
26
  ) {
27
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
28
- userLog(`Starting a prover agent with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
27
+ if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
28
+ userLog(`Starting a prover agent with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
29
29
  process.exit(1);
30
30
  }
31
31
 
@@ -24,8 +24,8 @@ export async function startProverBroker(
24
24
  services: NamespacedApiHandlers,
25
25
  userLog: LogFn,
26
26
  ): Promise<{ broker: ProvingJobBroker; config: ProverBrokerConfig }> {
27
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
28
- userLog(`Starting a prover broker with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
27
+ if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
28
+ userLog(`Starting a prover broker with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
29
29
  process.exit(1);
30
30
  }
31
31
 
@@ -1,5 +1,5 @@
1
1
  import type { LogFn } from '@aztec/foundation/log';
2
- import { getPackageVersion } from '@aztec/stdlib/update-checker';
2
+ import { DEV_VERSION, getPackageVersion } from '@aztec/stdlib/update-checker';
3
3
 
4
4
  import TOML from '@iarna/toml';
5
5
  import { readFile } from 'fs/promises';
@@ -28,8 +28,7 @@ function isAztecNrGitUrl(gitUrl: string): boolean {
28
28
  /** Warns if any aztec-nr git dependency in a crate's Nargo.toml has a tag that doesn't match the CLI version. */
29
29
  export async function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void> {
30
30
  const version = cliVersion ?? getPackageVersion();
31
- if (!version) {
32
- log(`WARNING: aztec CLI version not found. Skipping dependency compatibility check.`);
31
+ if (version === DEV_VERSION) {
33
32
  return;
34
33
  }
35
34
 
package/src/cli/util.ts CHANGED
@@ -1,18 +1,13 @@
1
1
  import type { AztecNodeConfig } from '@aztec/aztec-node';
2
2
  import type { AccountManager } from '@aztec/aztec.js/wallet';
3
- import { getNetworkConfig } from '@aztec/cli/config';
4
- import { RegistryContract } from '@aztec/ethereum/contracts';
5
- import type { ViemClient } from '@aztec/ethereum/types';
6
- import type { ConfigMappingsType, NetworkNames } from '@aztec/foundation/config';
3
+ import type { ConfigMappingsType } from '@aztec/foundation/config';
7
4
  import { jsonStringify } from '@aztec/foundation/json-rpc';
8
- import { type LogFn, createLogger } from '@aztec/foundation/log';
5
+ import type { LogFn } from '@aztec/foundation/log';
9
6
  import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
10
- import { type VersionCheck, getPackageVersion } from '@aztec/stdlib/update-checker';
11
7
  import type { EmbeddedWallet } from '@aztec/wallets/embedded';
12
8
 
13
9
  import chalk from 'chalk';
14
10
  import type { Command } from 'commander';
15
- import type { Hex } from 'viem';
16
11
 
17
12
  import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';
18
13
 
@@ -51,6 +46,24 @@ export function isShuttingDown(): boolean {
51
46
  return shutdownPromise !== undefined;
52
47
  }
53
48
 
49
+ /**
50
+ * Stops the node's subsystems (via the registered signal handlers) without exiting the process, leaving
51
+ * the HTTP health server listening so K8s liveness/readiness probes keep passing. Unlike {@link shutdown}
52
+ * this deliberately does not latch `shutdownPromise` or call `process.exit`; instead it re-arms
53
+ * SIGTERM/SIGINT so a later K8s pod deletion still terminates the wound-down pod with a clean exit.
54
+ */
55
+ export async function softShutdown(logFn: LogFn, signalHandlers: Array<() => Promise<void>>): Promise<void> {
56
+ logFn('Canonical rollup upgrade detected: stopping subsystems, health server stays up.', {
57
+ exitCode: ExitCode.ROLLUP_UPGRADE,
58
+ });
59
+ await Promise.allSettled(signalHandlers.map(fn => fn()));
60
+ for (const sig of ['SIGTERM', 'SIGINT'] as const) {
61
+ process.removeAllListeners(sig);
62
+ process.once(sig, () => process.exit(ExitCode.ROLLUP_UPGRADE));
63
+ }
64
+ logFn('Subsystems stopped due to rollup upgrade. Health server remains active.');
65
+ }
66
+
54
67
  export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<void>>) => {
55
68
  const signals = [
56
69
  ['SIGINT', ExitCode.SIGINT],
@@ -291,60 +304,6 @@ export async function preloadCrsDataForServerSideProving(
291
304
  }
292
305
  }
293
306
 
294
- export async function setupVersionChecker(
295
- network: NetworkNames,
296
- followsCanonicalRollup: boolean,
297
- publicClient: ViemClient,
298
- signalHandlers: Array<() => Promise<void>>,
299
- cacheDir?: string,
300
- ): Promise<void> {
301
- const networkConfig = await getNetworkConfig(network, cacheDir);
302
- if (!networkConfig) {
303
- return;
304
- }
305
-
306
- const { VersionChecker } = await import('@aztec/stdlib/update-checker');
307
-
308
- const logger = createLogger('version_check');
309
- const registry = new RegistryContract(publicClient, networkConfig.registryAddress as Hex);
310
-
311
- const checks: Array<VersionCheck> = [];
312
- checks.push({
313
- name: 'node',
314
- currentVersion: getPackageVersion() ?? 'unknown',
315
- getLatestVersion: async () => {
316
- const cfg = await getNetworkConfig(network, cacheDir);
317
- return cfg?.nodeVersion;
318
- },
319
- });
320
-
321
- if (followsCanonicalRollup) {
322
- const getLatestVersion = async () => {
323
- const version = (await registry.getRollupVersions()).at(-1);
324
- return version !== undefined ? String(version) : undefined;
325
- };
326
- const currentVersion = await getLatestVersion();
327
- if (currentVersion !== undefined) {
328
- checks.push({
329
- name: 'rollup',
330
- currentVersion,
331
- getLatestVersion,
332
- });
333
- }
334
- }
335
-
336
- const checker = new VersionChecker(checks, 600_000, logger);
337
- checker.on('newVersion', ({ name, latestVersion, currentVersion }) => {
338
- if (isShuttingDown()) {
339
- return;
340
- }
341
-
342
- logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
343
- });
344
- checker.start();
345
- signalHandlers.push(() => checker.stop());
346
- }
347
-
348
307
  export function stringifyConfig(config: object): string {
349
308
  return Object.entries(config)
350
309
  .map(([key, value]) => `${key}=${jsonStringify(value)}`)
@@ -49,15 +49,12 @@ export async function setupBananaFPC(initialAccounts: InitialAccountData[], wall
49
49
  const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
50
50
  const admin = getBananaAdmin(initialAccounts);
51
51
  const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
52
- TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
53
- from: admin,
54
- contractAddressSalt: BANANA_COIN_SALT,
52
+ TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
53
+ salt: BANANA_COIN_SALT,
55
54
  universalDeploy: true,
56
- }),
57
- FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
55
+ }).send({ from: admin }),
56
+ FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
58
57
  from: admin,
59
- contractAddressSalt: BANANA_FPC_SALT,
60
- universalDeploy: true,
61
58
  }),
62
59
  ]);
63
60