@aztec/aztec 0.0.1-commit.733c4a3 → 0.0.1-commit.7689c7f

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 (124) hide show
  1. package/dest/bin/index.js +2 -2
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +31 -14
  5. package/dest/cli/aztec_start_options.d.ts +2 -2
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +16 -17
  8. package/dest/cli/cli.js +3 -3
  9. package/dest/cli/cmds/compile.d.ts +1 -1
  10. package/dest/cli/cmds/compile.d.ts.map +1 -1
  11. package/dest/cli/cmds/compile.js +15 -9
  12. package/dest/cli/cmds/profile.d.ts +1 -1
  13. package/dest/cli/cmds/profile.d.ts.map +1 -1
  14. package/dest/cli/cmds/profile.js +1 -1
  15. package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
  16. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
  17. package/dest/cli/cmds/profile_flamegraph.js +2 -1
  18. package/dest/cli/cmds/profile_gates.d.ts +2 -2
  19. package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
  20. package/dest/cli/cmds/profile_gates.js +23 -4
  21. package/dest/cli/cmds/standby.d.ts +30 -0
  22. package/dest/cli/cmds/standby.d.ts.map +1 -0
  23. package/dest/cli/cmds/standby.js +97 -0
  24. package/dest/cli/cmds/start_bot.d.ts +1 -1
  25. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  26. package/dest/cli/cmds/start_bot.js +3 -3
  27. package/dest/cli/cmds/start_node.d.ts +3 -2
  28. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  29. package/dest/cli/cmds/start_node.js +28 -40
  30. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  31. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  32. package/dest/cli/cmds/start_prover_agent.js +5 -17
  33. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  34. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  35. package/dest/cli/cmds/start_prover_broker.js +22 -13
  36. package/dest/cli/cmds/start_txe.d.ts +2 -2
  37. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  38. package/dest/cli/cmds/start_txe.js +6 -5
  39. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  40. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  41. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  42. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  43. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  44. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  45. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  46. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  47. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  48. package/dest/cli/util.d.ts +3 -5
  49. package/dest/cli/util.d.ts.map +1 -1
  50. package/dest/cli/util.js +46 -85
  51. package/dest/examples/token.js +4 -4
  52. package/dest/local-network/auth_registry.d.ts +4 -0
  53. package/dest/local-network/auth_registry.d.ts.map +1 -0
  54. package/dest/local-network/auth_registry.js +15 -0
  55. package/dest/local-network/banana_fpc.d.ts +1 -1
  56. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  57. package/dest/local-network/banana_fpc.js +9 -7
  58. package/dest/local-network/local-network.d.ts +5 -28
  59. package/dest/local-network/local-network.d.ts.map +1 -1
  60. package/dest/local-network/local-network.js +44 -17
  61. package/dest/testing/anvil_test_watcher.d.ts +15 -3
  62. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  63. package/dest/testing/anvil_test_watcher.js +68 -14
  64. package/dest/testing/cheat_codes.d.ts +18 -17
  65. package/dest/testing/cheat_codes.d.ts.map +1 -1
  66. package/dest/testing/cheat_codes.js +72 -36
  67. package/dest/testing/epoch_test_settler.d.ts +1 -1
  68. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  69. package/dest/testing/epoch_test_settler.js +9 -8
  70. package/dest/testing/index.d.ts +3 -2
  71. package/dest/testing/index.d.ts.map +1 -1
  72. package/dest/testing/index.js +1 -0
  73. package/dest/testing/token_allowed_setup.d.ts +7 -0
  74. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  75. package/dest/testing/token_allowed_setup.js +20 -0
  76. package/package.json +35 -34
  77. package/scripts/add_crate.sh +53 -0
  78. package/scripts/aztec.sh +10 -3
  79. package/scripts/init.sh +18 -24
  80. package/scripts/new.sh +45 -22
  81. package/scripts/setup_workspace.sh +12 -67
  82. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  83. package/scripts/templates/blank/contract/src/main.nr +10 -0
  84. package/scripts/templates/blank/test/Nargo.toml +7 -0
  85. package/scripts/templates/blank/test/src/lib.nr +11 -0
  86. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  87. package/scripts/templates/counter/contract/src/main.nr +48 -0
  88. package/scripts/templates/counter/test/Nargo.toml +7 -0
  89. package/scripts/templates/counter/test/src/lib.nr +32 -0
  90. package/src/bin/index.ts +2 -2
  91. package/src/cli/aztec_start_action.ts +20 -14
  92. package/src/cli/aztec_start_options.ts +23 -25
  93. package/src/cli/cli.ts +3 -3
  94. package/src/cli/cmds/compile.ts +18 -10
  95. package/src/cli/cmds/profile.ts +2 -1
  96. package/src/cli/cmds/profile_flamegraph.ts +2 -1
  97. package/src/cli/cmds/profile_gates.ts +22 -5
  98. package/src/cli/cmds/standby.ts +132 -0
  99. package/src/cli/cmds/start_bot.ts +3 -5
  100. package/src/cli/cmds/start_node.ts +43 -39
  101. package/src/cli/cmds/start_prover_agent.ts +5 -8
  102. package/src/cli/cmds/start_prover_broker.ts +23 -24
  103. package/src/cli/cmds/start_txe.ts +7 -5
  104. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  105. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  106. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  107. package/src/cli/util.ts +49 -82
  108. package/src/examples/token.ts +6 -4
  109. package/src/local-network/auth_registry.ts +14 -0
  110. package/src/local-network/banana_fpc.ts +5 -8
  111. package/src/local-network/local-network.ts +43 -14
  112. package/src/testing/anvil_test_watcher.ts +76 -13
  113. package/src/testing/cheat_codes.ts +92 -39
  114. package/src/testing/epoch_test_settler.ts +6 -8
  115. package/src/testing/index.ts +2 -1
  116. package/src/testing/token_allowed_setup.ts +19 -0
  117. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  118. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  119. package/dest/cli/cmds/start_archiver.js +0 -48
  120. package/dest/cli/release_version.d.ts +0 -2
  121. package/dest/cli/release_version.d.ts.map +0 -1
  122. package/dest/cli/release_version.js +0 -14
  123. package/src/cli/cmds/start_archiver.ts +0 -50
  124. package/src/cli/release_version.ts +0 -21
@@ -7,9 +7,9 @@ import { EmbeddedWallet } from '@aztec/wallets/embedded';
7
7
  import { extractRelevantOptions, stringifyConfig } from '../util.js';
8
8
  import { getVersions } from '../versioning.js';
9
9
  export async function startBot(options, signalHandlers, services, userLog) {
10
- const { proverNode, archiver, sequencer, p2pBootstrap, txe, prover } = options;
11
- if (proverNode || archiver || sequencer || p2pBootstrap || txe || prover) {
12
- userLog(`Starting a bot with --prover-node, --prover, --archiver, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
10
+ const { proverNode, sequencer, p2pBootstrap, txe, prover } = options;
11
+ if (proverNode || sequencer || p2pBootstrap || txe || prover) {
12
+ userLog(`Starting a bot with --prover-node, --prover, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
13
13
  process.exit(1);
14
14
  }
15
15
  const fetch = makeTracedFetch([
@@ -1,7 +1,8 @@
1
1
  import { type AztecNodeConfig } from '@aztec/aztec-node';
2
+ import { type NetworkNames } from '@aztec/foundation/config';
2
3
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
3
4
  import type { LogFn } from '@aztec/foundation/log';
4
- export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn): Promise<{
5
+ export declare function startNode(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, adminServices: NamespacedApiHandlers, userLog: LogFn, networkName: NetworkNames): Promise<{
5
6
  config: AztecNodeConfig;
6
7
  }>;
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUE2QyxNQUFNLG1CQUFtQixDQUFDO0FBTXBHLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUF3Qm5ELHdCQUFzQixTQUFTLENBQzdCLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLGFBQWEsRUFBRSxxQkFBcUIsRUFDcEMsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZUFBZSxDQUFBO0NBQUUsQ0FBQyxDQThKdEMifQ==
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfbm9kZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X25vZGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLEtBQUssZUFBZSxFQUE2QyxNQUFNLG1CQUFtQixDQUFDO0FBS3BHLE9BQU8sRUFBRSxLQUFLLFlBQVksRUFBZSxNQUFNLDBCQUEwQixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUE4Qm5ELHdCQUFzQixTQUFTLENBQzdCLE9BQU8sRUFBRSxHQUFHLEVBQ1osY0FBYyxFQUFFLENBQUMsTUFBTSxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsRUFBRSxFQUN2QyxRQUFRLEVBQUUscUJBQXFCLEVBQy9CLGFBQWEsRUFBRSxxQkFBcUIsRUFDcEMsT0FBTyxFQUFFLEtBQUssRUFDZCxXQUFXLEVBQUUsWUFBWSxHQUN4QixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZUFBZSxDQUFBO0NBQUUsQ0FBQyxDQTRKdEMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"start_node.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAA6C,MAAM,mBAAmB,CAAC;AAMpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAwBnD,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,GACb,OAAO,CAAC;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,CAAC,CA8JtC"}
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;AA8BnD,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,CA4JtC"}
@@ -1,23 +1,24 @@
1
- import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
1
  import { aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
3
2
  import { Fr } from '@aztec/aztec.js/fields';
4
- import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
5
3
  import { getL1Config } from '@aztec/cli/config';
6
4
  import { getPublicClient } from '@aztec/ethereum/client';
5
+ import { getGenesisStateConfigEnvVars } from '@aztec/ethereum/config';
7
6
  import { SecretValue } from '@aztec/foundation/config';
8
7
  import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
9
- import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
8
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
9
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
10
+ import { ProvingJobConsumerSchema, createProvingJobBrokerClient, proverBrokerBackoff } from '@aztec/prover-client/broker';
10
11
  import { allPxeConfigMappings } from '@aztec/pxe/config';
11
12
  import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
12
13
  import { P2PApiSchema, ProverNodeApiSchema } from '@aztec/stdlib/interfaces/server';
13
14
  import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
14
15
  import { EmbeddedWallet } from '@aztec/wallets/embedded';
15
- import { getGenesisValues } from '@aztec/world-state/testing';
16
16
  import { createAztecNode } from '../../local-network/index.js';
17
- import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying, setupUpdateMonitor } from '../util.js';
17
+ import { extractNamespacedOptions, extractRelevantOptions, preloadCrsDataForVerifying, setupVersionChecker } from '../util.js';
18
18
  import { getVersions } from '../versioning.js';
19
+ import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
19
20
  import { startProverBroker } from './start_prover_broker.js';
20
- export async function startNode(options, signalHandlers, services, adminServices, userLog) {
21
+ export async function startNode(options, signalHandlers, services, adminServices, userLog, networkName) {
21
22
  // All options set from environment variables
22
23
  const configFromEnvVars = getConfigEnvVars();
23
24
  // Extract relevant options from command line arguments
@@ -38,20 +39,8 @@ export async function startNode(options, signalHandlers, services, adminServices
38
39
  if (nodeConfig.proverBrokerUrl) {
39
40
  // at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
40
41
  // set a lower connection limit such that we don't overload the server
41
- // Keep retrying up to 30s
42
- const fetch = makeTracedFetch([
43
- 1,
44
- 2,
45
- 3,
46
- 3,
47
- 3,
48
- 3,
49
- 3,
50
- 3,
51
- 3,
52
- 3,
53
- 3
54
- ], false, makeUndiciFetch(new Agent({
42
+ // Retry indefinitely until the epoch proving times out and the chain reorgs
43
+ const fetch = makeTracedFetch(proverBrokerBackoff, false, makeUndiciFetch(new Agent({
55
44
  connections: 100
56
45
  })));
57
46
  broker = createProvingJobBrokerClient(nodeConfig.proverBrokerUrl, getVersions(nodeConfig), fetch);
@@ -63,30 +52,27 @@ export async function startNode(options, signalHandlers, services, adminServices
63
52
  }
64
53
  }
65
54
  await preloadCrsDataForVerifying(nodeConfig, userLog);
66
- const testAccounts = nodeConfig.testAccounts ? (await getInitialTestAccountsData()).map((a)=>a.address) : [];
67
- const sponsoredFPCAccounts = nodeConfig.sponsoredFPC ? [
68
- await getSponsoredFPCAddress()
69
- ] : [];
70
- const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
71
- userLog(`Initial funded accounts: ${initialFundedAccounts.map((a)=>a.toString()).join(', ')}`);
72
- const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
73
- userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
55
+ const genesisConfig = getGenesisStateConfigEnvVars();
56
+ const { genesisArchiveRoot, genesis } = await computeExpectedGenesisRoot(genesisConfig, userLog);
74
57
  const followsCanonicalRollup = typeof nodeConfig.rollupVersion !== 'number' || nodeConfig.rollupVersion === 'canonical';
75
- if (!nodeConfig.l1Contracts.registryAddress || nodeConfig.l1Contracts.registryAddress.isZero()) {
58
+ if (!nodeConfig.registryAddress || nodeConfig.registryAddress.isZero()) {
76
59
  throw new Error('L1 registry address is required to start Aztec Node');
77
60
  }
78
- const { addresses, config } = await getL1Config(nodeConfig.l1Contracts.registryAddress, nodeConfig.l1RpcUrls, nodeConfig.l1ChainId, nodeConfig.rollupVersion);
61
+ // Wait for a compatible rollup before proceeding with full L1 config fetch.
62
+ // This prevents crashes when the canonical rollup hasn't been upgraded yet.
63
+ await waitForCompatibleRollup(nodeConfig, {
64
+ genesisArchiveRoot,
65
+ vkTreeRoot: getVKTreeRoot(),
66
+ protocolContractsHash
67
+ }, options.port, userLog);
68
+ const { addresses, config } = await getL1Config(nodeConfig.registryAddress, nodeConfig.l1RpcUrls, nodeConfig.l1ChainId, nodeConfig.rollupVersion);
79
69
  process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
80
70
  if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
81
71
  throw new Error(`The computed genesis archive tree root ${genesisArchiveRoot} does not match the expected genesis archive tree root ${config.genesisArchiveTreeRoot} for the rollup deployed at ${addresses.rollupAddress}`);
82
72
  }
83
- // TODO(#12272): will clean this up.
84
73
  nodeConfig = {
85
74
  ...nodeConfig,
86
- l1Contracts: {
87
- ...addresses,
88
- slashFactoryAddress: nodeConfig.l1Contracts.slashFactoryAddress
89
- },
75
+ ...addresses,
90
76
  ...config
91
77
  };
92
78
  if (!options.sequencer && !nodeConfig.fishermanMode) {
@@ -119,7 +105,7 @@ export async function startNode(options, signalHandlers, services, adminServices
119
105
  telemetry,
120
106
  proverBroker: broker
121
107
  }, {
122
- prefilledPublicData
108
+ genesis
123
109
  });
124
110
  // Add node and p2p to services list
125
111
  services.node = [
@@ -159,10 +145,12 @@ export async function startNode(options, signalHandlers, services, adminServices
159
145
  });
160
146
  await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
161
147
  }
162
- if (nodeConfig.autoUpdate !== 'disabled' && nodeConfig.autoUpdateUrl) {
163
- await setupUpdateMonitor(nodeConfig.autoUpdate, new URL(nodeConfig.autoUpdateUrl), followsCanonicalRollup, getPublicClient(nodeConfig), nodeConfig.l1Contracts.registryAddress, signalHandlers, async (config)=>node.setConfig((await AztecNodeAdminApiSchema.setConfig.parameters().parseAsync([
164
- config
165
- ]))[0]));
148
+ if (nodeConfig.enableVersionCheck && networkName !== 'local') {
149
+ const cacheDir = process.env.DATA_DIRECTORY ? `${process.env.DATA_DIRECTORY}/cache` : undefined;
150
+ try {
151
+ await setupVersionChecker(networkName, followsCanonicalRollup, getPublicClient(nodeConfig), signalHandlers, cacheDir);
152
+ } catch {
153
+ /* no-op */ }
166
154
  }
167
155
  return {
168
156
  config: nodeConfig
@@ -1,4 +1,4 @@
1
1
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
2
2
  import type { LogFn } from '@aztec/foundation/log';
3
3
  export declare function startProverAgent(options: any, signalHandlers: (() => Promise<void>)[], services: NamespacedApiHandlers, userLog: LogFn): Promise<void>;
4
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX2FnZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfcHJvdmVyX2FnZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFnQm5ELHdCQUFzQixnQkFBZ0IsQ0FDcEMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsT0FBTyxFQUFFLEtBQUssaUJBd0RmIn0=
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX2FnZW50LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfcHJvdmVyX2FnZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0sbUNBQW1DLENBQUM7QUFFL0UsT0FBTyxLQUFLLEVBQUUsS0FBSyxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFpQm5ELHdCQUFzQixnQkFBZ0IsQ0FDcEMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsT0FBTyxFQUFFLEtBQUssaUJBb0RmIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"start_prover_agent.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAgBnD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,iBAwDf"}
1
+ {"version":3,"file":"start_prover_agent.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_prover_agent.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAiBnD,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,GAAG,EACZ,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EACvC,QAAQ,EAAE,qBAAqB,EAC/B,OAAO,EAAE,KAAK,iBAoDf"}
@@ -1,15 +1,15 @@
1
1
  import { times } from '@aztec/foundation/collection';
2
2
  import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
3
3
  import { buildServerCircuitProver } from '@aztec/prover-client';
4
- import { ProvingAgent, createProofStore, createProvingJobBrokerClient, proverAgentConfigMappings } from '@aztec/prover-client/broker';
4
+ import { ProvingAgent, createProofStore, createProvingJobBrokerClient, proverAgentConfigMappings, proverBrokerBackoff } from '@aztec/prover-client/broker';
5
5
  import { getProverNodeAgentConfigFromEnv } from '@aztec/prover-node';
6
6
  import { ProverAgentApiSchema } from '@aztec/stdlib/interfaces/server';
7
7
  import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
8
8
  import { extractRelevantOptions, preloadCrsDataForServerSideProving } from '../util.js';
9
9
  import { getVersions } from '../versioning.js';
10
10
  export async function startProverAgent(options, signalHandlers, services, userLog) {
11
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
12
- userLog(`Starting a prover agent with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
11
+ if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
12
+ userLog(`Starting a prover agent with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
13
13
  process.exit(1);
14
14
  }
15
15
  const config = {
@@ -25,20 +25,8 @@ export async function startProverAgent(options, signalHandlers, services, userLo
25
25
  process.exit(1);
26
26
  }
27
27
  await preloadCrsDataForServerSideProving(config, userLog);
28
- const fetch = makeTracedFetch(// retry connections every 3s, up to 30s before giving up
29
- [
30
- 1,
31
- 2,
32
- 3,
33
- 3,
34
- 3,
35
- 3,
36
- 3,
37
- 3,
38
- 3,
39
- 3,
40
- 3
41
- ], false, makeUndiciFetch(new Agent({
28
+ // Retry indefinitely until the epoch proving times out and the chain reorgs
29
+ const fetch = makeTracedFetch(proverBrokerBackoff, false, makeUndiciFetch(new Agent({
42
30
  connections: 10
43
31
  })));
44
32
  const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX2Jyb2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X3Byb3Zlcl9icm9rZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUNuRCxPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFLeEIsTUFBTSw2QkFBNkIsQ0FBQztBQUVyQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBS3hFLHdCQUFzQixpQkFBaUIsQ0FDckMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZ0JBQWdCLENBQUM7SUFBQyxNQUFNLEVBQUUsa0JBQWtCLENBQUE7Q0FBRSxDQUFDLENBK0NuRSJ9
9
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfcHJvdmVyX2Jyb2tlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NsaS9jbWRzL3N0YXJ0X3Byb3Zlcl9icm9rZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxLQUFLLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxtQ0FBbUMsQ0FBQztBQUMvRSxPQUFPLEtBQUssRUFBRSxLQUFLLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQUduRCxPQUFPLEVBQ0wsS0FBSyxrQkFBa0IsRUFLeEIsTUFBTSw2QkFBNkIsQ0FBQztBQUVyQyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBTXhFLHdCQUFzQixpQkFBaUIsQ0FDckMsT0FBTyxFQUFFLEdBQUcsRUFDWixjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQ3ZDLFFBQVEsRUFBRSxxQkFBcUIsRUFDL0IsT0FBTyxFQUFFLEtBQUssR0FDYixPQUFPLENBQUM7SUFBRSxNQUFNLEVBQUUsZ0JBQWdCLENBQUM7SUFBQyxNQUFNLEVBQUUsa0JBQWtCLENBQUE7Q0FBRSxDQUFDLENBMkNuRSJ9
@@ -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;AACnD,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAKxE,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,CA+CnE"}
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,CA2CnE"}
@@ -1,30 +1,39 @@
1
1
  import { getL1Config } from '@aztec/cli/config';
2
- import { getPublicClient } from '@aztec/ethereum/client';
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';
6
- import { extractRelevantOptions, setupUpdateMonitor } from '../util.js';
8
+ import { extractRelevantOptions } from '../util.js';
9
+ import { computeExpectedGenesisRoot, waitForCompatibleRollup } from './standby.js';
7
10
  export async function startProverBroker(options, signalHandlers, services, userLog) {
8
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
9
- userLog(`Starting a prover broker with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
11
+ if (options.node || options.sequencer || options.p2pBootstrap || options.txe) {
12
+ userLog(`Starting a prover broker with --node, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
10
13
  process.exit(1);
11
14
  }
12
- const config = {
15
+ const baseConfig = {
13
16
  ...getProverNodeBrokerConfigFromEnv(),
14
17
  ...extractRelevantOptions(options, proverBrokerConfigMappings, 'proverBroker')
15
18
  };
16
- if (!config.l1Contracts.registryAddress || config.l1Contracts.registryAddress.isZero()) {
19
+ if (!baseConfig.registryAddress || baseConfig.registryAddress.isZero()) {
17
20
  throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
18
21
  }
19
- const followsCanonicalRollup = typeof config.rollupVersion !== 'number';
20
- const { addresses, config: rollupConfig } = await getL1Config(config.l1Contracts.registryAddress, config.l1RpcUrls, config.l1ChainId, config.rollupVersion);
21
- config.l1Contracts = addresses;
22
- config.rollupVersion = rollupConfig.rollupVersion;
22
+ const genesisConfig = getGenesisStateConfigEnvVars();
23
+ const { genesisArchiveRoot } = await computeExpectedGenesisRoot(genesisConfig, userLog);
24
+ await waitForCompatibleRollup(baseConfig, {
25
+ genesisArchiveRoot,
26
+ vkTreeRoot: getVKTreeRoot(),
27
+ protocolContractsHash
28
+ }, options.port, userLog);
29
+ const { addresses, config: rollupConfig } = await getL1Config(baseConfig.registryAddress, baseConfig.l1RpcUrls, baseConfig.l1ChainId, baseConfig.rollupVersion);
30
+ const config = {
31
+ ...baseConfig,
32
+ ...addresses,
33
+ rollupVersion: rollupConfig.rollupVersion
34
+ };
23
35
  const client = await initTelemetryClient(getTelemetryClientConfig());
24
36
  const broker = await createAndStartProvingBroker(config, client);
25
- if (options.autoUpdate !== 'disabled' && options.autoUpdateUrl) {
26
- await setupUpdateMonitor(options.autoUpdate, new URL(options.autoUpdateUrl), followsCanonicalRollup, getPublicClient(config), config.l1Contracts.registryAddress, signalHandlers);
27
- }
28
37
  services.proverBroker = [
29
38
  broker,
30
39
  config.proverBrokerDebugReplayEnabled ? ProvingJobBrokerSchemaWithDebug : ProvingJobBrokerSchema
@@ -1,3 +1,3 @@
1
1
  import type { Logger } from '@aztec/foundation/log';
2
- export declare function startTXE(options: any, debugLogger: Logger): Promise<void>;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfdHhlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfdHhlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBR3BELHdCQUFzQixRQUFRLENBQUMsT0FBTyxFQUFFLEdBQUcsRUFBRSxXQUFXLEVBQUUsTUFBTSxpQkFVL0QifQ==
2
+ export declare function startTXE(options: any, signalHandlers: Array<() => Promise<void>>, debugLogger: Logger): Promise<void>;
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfdHhlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfdHhlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBR3BELHdCQUFzQixRQUFRLENBQUMsT0FBTyxFQUFFLEdBQUcsRUFBRSxjQUFjLEVBQUUsS0FBSyxDQUFDLE1BQU0sT0FBTyxDQUFDLElBQUksQ0FBQyxDQUFDLEVBQUUsV0FBVyxFQUFFLE1BQU0saUJBWTNHIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"start_txe.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_txe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,iBAU/D"}
1
+ {"version":3,"file":"start_txe.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_txe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,KAAK,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,iBAY3G"}
@@ -1,11 +1,12 @@
1
1
  import { startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
2
- import { createTXERpcServer } from '@aztec/txe';
3
- export async function startTXE(options, debugLogger) {
2
+ import { createTXERpcServer } from '@aztec/txe/server';
3
+ export async function startTXE(options, signalHandlers, debugLogger) {
4
4
  debugLogger.info(`Setting up TXE...`);
5
- const txeServer = createTXERpcServer(debugLogger);
6
- const { port } = await startHttpRpcServer(txeServer, {
5
+ const txeServer = await createTXERpcServer(debugLogger);
6
+ const httpServer = await startHttpRpcServer(txeServer, {
7
7
  port: options.port,
8
8
  timeoutMs: 1e3 * 60 * 5
9
9
  });
10
- debugLogger.info(`TXE listening on port ${port}`);
10
+ signalHandlers.push(()=>new Promise((resolve)=>httpServer.close(()=>resolve())));
11
+ debugLogger.info(`TXE listening on port ${httpServer.port}`);
11
12
  }
@@ -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 any aztec-nr git dependency in a crate's Nargo.toml has a tag that doesn't match the CLI version. */
3
+ export declare function warnIfAztecVersionMismatch(log: LogFn, cliVersion?: string): Promise<void>;
4
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2Fybl9pZl9henRlY192ZXJzaW9uX21pc21hdGNoLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvY2xpL2NtZHMvdXRpbHMvd2Fybl9pZl9henRlY192ZXJzaW9uX21pc21hdGNoLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBMkJuRCxpSEFBaUg7QUFDakgsd0JBQXNCLDBCQUEwQixDQUFDLEdBQUcsRUFBRSxLQUFLLEVBQUUsVUFBVSxDQUFDLEVBQUUsTUFBTSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0ErQy9GIn0=
@@ -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;AA2BnD,iHAAiH;AACjH,wBAAsB,0BAA0B,CAAC,GAAG,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+C/F"}