@aztec/aztec 0.0.1-commit.a072138 → 0.0.1-commit.a4600f49

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 (154) hide show
  1. package/dest/bin/index.js +9 -3
  2. package/dest/cli/admin_api_key_store.d.ts +45 -0
  3. package/dest/cli/admin_api_key_store.d.ts.map +1 -0
  4. package/dest/cli/admin_api_key_store.js +98 -0
  5. package/dest/cli/aztec_start_action.d.ts +1 -1
  6. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_action.js +69 -32
  8. package/dest/cli/aztec_start_options.d.ts +2 -2
  9. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  10. package/dest/cli/aztec_start_options.js +39 -23
  11. package/dest/cli/cli.d.ts +1 -1
  12. package/dest/cli/cli.d.ts.map +1 -1
  13. package/dest/cli/cli.js +3 -4
  14. package/dest/cli/cmds/compile.d.ts +4 -0
  15. package/dest/cli/cmds/compile.d.ts.map +1 -0
  16. package/dest/cli/cmds/compile.js +174 -0
  17. package/dest/cli/cmds/profile.d.ts +4 -0
  18. package/dest/cli/cmds/profile.d.ts.map +1 -0
  19. package/dest/cli/cmds/profile.js +8 -0
  20. package/dest/cli/cmds/profile_flamegraph.d.ts +4 -0
  21. package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -0
  22. package/dest/cli/cmds/profile_flamegraph.js +52 -0
  23. package/dest/cli/cmds/profile_gates.d.ts +4 -0
  24. package/dest/cli/cmds/profile_gates.d.ts.map +1 -0
  25. package/dest/cli/cmds/profile_gates.js +76 -0
  26. package/dest/cli/cmds/profile_utils.d.ts +18 -0
  27. package/dest/cli/cmds/profile_utils.d.ts.map +1 -0
  28. package/dest/cli/cmds/profile_utils.js +50 -0
  29. package/dest/cli/cmds/prover.d.ts +4 -0
  30. package/dest/cli/cmds/prover.d.ts.map +1 -0
  31. package/dest/cli/cmds/prover.js +24 -0
  32. package/dest/cli/cmds/standby.d.ts +56 -0
  33. package/dest/cli/cmds/standby.d.ts.map +1 -0
  34. package/dest/cli/cmds/standby.js +140 -0
  35. package/dest/cli/cmds/start_bot.d.ts +3 -3
  36. package/dest/cli/cmds/start_bot.d.ts.map +1 -1
  37. package/dest/cli/cmds/start_bot.js +17 -9
  38. package/dest/cli/cmds/start_node.d.ts +3 -2
  39. package/dest/cli/cmds/start_node.d.ts.map +1 -1
  40. package/dest/cli/cmds/start_node.js +82 -51
  41. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  42. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  43. package/dest/cli/cmds/start_prover_agent.js +6 -18
  44. package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
  45. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
  46. package/dest/cli/cmds/start_prover_broker.js +24 -15
  47. package/dest/cli/cmds/start_txe.d.ts +2 -2
  48. package/dest/cli/cmds/start_txe.d.ts.map +1 -1
  49. package/dest/cli/cmds/start_txe.js +6 -5
  50. package/dest/cli/cmds/utils/artifacts.d.ts +26 -0
  51. package/dest/cli/cmds/utils/artifacts.d.ts.map +1 -0
  52. package/dest/cli/cmds/utils/artifacts.js +24 -0
  53. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
  54. package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
  55. package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
  56. package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
  57. package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
  58. package/dest/cli/cmds/utils/needs_recompile.js +90 -0
  59. package/dest/cli/cmds/utils/spawn.d.ts +3 -0
  60. package/dest/cli/cmds/utils/spawn.d.ts.map +1 -0
  61. package/dest/cli/cmds/utils/spawn.js +16 -0
  62. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
  63. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
  64. package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +61 -0
  65. package/dest/cli/util.d.ts +13 -19
  66. package/dest/cli/util.d.ts.map +1 -1
  67. package/dest/cli/util.js +37 -100
  68. package/dest/examples/token.js +9 -9
  69. package/dest/local-network/auth_registry.d.ts +5 -0
  70. package/dest/local-network/auth_registry.d.ts.map +1 -0
  71. package/dest/local-network/auth_registry.js +17 -0
  72. package/dest/local-network/banana_fpc.d.ts +3 -2
  73. package/dest/local-network/banana_fpc.d.ts.map +1 -1
  74. package/dest/local-network/banana_fpc.js +12 -8
  75. package/dest/local-network/local-network.d.ts +10 -32
  76. package/dest/local-network/local-network.d.ts.map +1 -1
  77. package/dest/local-network/local-network.js +83 -72
  78. package/dest/testing/cheat_codes.d.ts +17 -23
  79. package/dest/testing/cheat_codes.d.ts.map +1 -1
  80. package/dest/testing/cheat_codes.js +17 -43
  81. package/dest/testing/epoch_test_settler.d.ts +2 -2
  82. package/dest/testing/epoch_test_settler.d.ts.map +1 -1
  83. package/dest/testing/epoch_test_settler.js +6 -26
  84. package/dest/testing/index.d.ts +2 -2
  85. package/dest/testing/index.d.ts.map +1 -1
  86. package/dest/testing/index.js +1 -1
  87. package/dest/testing/token_allowed_setup.d.ts +12 -0
  88. package/dest/testing/token_allowed_setup.d.ts.map +1 -0
  89. package/dest/testing/token_allowed_setup.js +24 -0
  90. package/package.json +35 -34
  91. package/scripts/add_crate.sh +53 -0
  92. package/scripts/aztec.sh +15 -5
  93. package/scripts/init.sh +23 -19
  94. package/scripts/new.sh +48 -24
  95. package/scripts/setup_workspace.sh +69 -0
  96. package/scripts/templates/blank/contract/Nargo.toml +6 -0
  97. package/scripts/templates/blank/contract/src/main.nr +10 -0
  98. package/scripts/templates/blank/test/Nargo.toml +7 -0
  99. package/scripts/templates/blank/test/src/lib.nr +11 -0
  100. package/scripts/templates/counter/contract/Nargo.toml +7 -0
  101. package/scripts/templates/counter/contract/src/main.nr +48 -0
  102. package/scripts/templates/counter/test/Nargo.toml +7 -0
  103. package/scripts/templates/counter/test/src/lib.nr +32 -0
  104. package/src/bin/index.ts +9 -3
  105. package/src/cli/admin_api_key_store.ts +128 -0
  106. package/src/cli/aztec_start_action.ts +69 -24
  107. package/src/cli/aztec_start_options.ts +48 -30
  108. package/src/cli/cli.ts +3 -4
  109. package/src/cli/cmds/compile.ts +205 -0
  110. package/src/cli/cmds/profile.ts +26 -0
  111. package/src/cli/cmds/profile_flamegraph.ts +64 -0
  112. package/src/cli/cmds/profile_gates.ts +84 -0
  113. package/src/cli/cmds/profile_utils.ts +58 -0
  114. package/src/cli/cmds/prover.ts +42 -0
  115. package/src/cli/cmds/standby.ts +184 -0
  116. package/src/cli/cmds/start_bot.ts +17 -11
  117. package/src/cli/cmds/start_node.ts +92 -52
  118. package/src/cli/cmds/start_prover_agent.ts +7 -10
  119. package/src/cli/cmds/start_prover_broker.ts +28 -25
  120. package/src/cli/cmds/start_txe.ts +7 -5
  121. package/src/cli/cmds/utils/artifacts.ts +49 -0
  122. package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
  123. package/src/cli/cmds/utils/needs_recompile.ts +98 -0
  124. package/src/cli/cmds/utils/spawn.ts +16 -0
  125. package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +76 -0
  126. package/src/cli/util.ts +39 -118
  127. package/src/examples/token.ts +11 -9
  128. package/src/local-network/auth_registry.ts +19 -0
  129. package/src/local-network/banana_fpc.ts +13 -9
  130. package/src/local-network/local-network.ts +91 -81
  131. package/src/testing/cheat_codes.ts +18 -49
  132. package/src/testing/epoch_test_settler.ts +8 -32
  133. package/src/testing/index.ts +1 -1
  134. package/src/testing/token_allowed_setup.ts +26 -0
  135. package/dest/cli/cmds/start_archiver.d.ts +0 -9
  136. package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
  137. package/dest/cli/cmds/start_archiver.js +0 -48
  138. package/dest/cli/cmds/start_prover_node.d.ts +0 -7
  139. package/dest/cli/cmds/start_prover_node.d.ts.map +0 -1
  140. package/dest/cli/cmds/start_prover_node.js +0 -108
  141. package/dest/cli/release_version.d.ts +0 -2
  142. package/dest/cli/release_version.d.ts.map +0 -1
  143. package/dest/cli/release_version.js +0 -14
  144. package/dest/testing/anvil_test_watcher.d.ts +0 -34
  145. package/dest/testing/anvil_test_watcher.d.ts.map +0 -1
  146. package/dest/testing/anvil_test_watcher.js +0 -144
  147. package/scripts/compile.sh +0 -44
  148. package/scripts/extract_function.js +0 -47
  149. package/scripts/flamegraph.sh +0 -59
  150. package/scripts/setup_project.sh +0 -31
  151. package/src/cli/cmds/start_archiver.ts +0 -50
  152. package/src/cli/cmds/start_prover_node.ts +0 -124
  153. package/src/cli/release_version.ts +0 -21
  154. package/src/testing/anvil_test_watcher.ts +0 -166
@@ -1,47 +0,0 @@
1
- #!/usr/bin/env node
2
- import fs from 'fs/promises';
3
- import path from 'path';
4
-
5
- // Simple script to extract a contract function as a separate Noir artifact.
6
- // We need to use this since the transpiling that we do on public functions make the contract artifacts
7
- // unreadable by noir tooling, since they are no longer following the noir artifact format.
8
- async function main() {
9
- let [contractArtifactPath, functionName] = process.argv.slice(2);
10
- if (!contractArtifactPath || !functionName) {
11
- console.log('Usage: node extractFunctionAsNoirArtifact.js <contractArtifactPath> <functionName>');
12
- return;
13
- }
14
-
15
- const contractArtifact = JSON.parse(await fs.readFile(contractArtifactPath, 'utf8'));
16
- const func = contractArtifact.functions.find(f => f.name === functionName);
17
- if (!func) {
18
- console.error(`Function ${functionName} not found in ${contractArtifactPath}`);
19
- return;
20
- }
21
-
22
- const artifact = {
23
- noir_version: contractArtifact.noir_version,
24
- hash: 0,
25
- abi: func.abi,
26
- bytecode: func.bytecode,
27
- debug_symbols: func.debug_symbols,
28
- file_map: contractArtifact.file_map,
29
- expression_width: {
30
- Bounded: {
31
- width: 4,
32
- },
33
- },
34
- };
35
-
36
- const outputDir = path.dirname(contractArtifactPath);
37
- const outputName = path.basename(contractArtifactPath, '.json') + `-${functionName}.json`;
38
-
39
- const outPath = path.join(outputDir, outputName);
40
-
41
- await fs.writeFile(outPath, JSON.stringify(artifact, null, 2));
42
- }
43
-
44
- main().catch(err => {
45
- console.error(err);
46
- process.exit(1);
47
- });
@@ -1,59 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -eu
3
-
4
- # If first arg is -h or --help, print usage.
5
- if [ $# -lt 2 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
6
- cat << 'EOF'
7
- Aztec Flamegraph - Generate a gate count flamegraph for an aztec contract function.
8
-
9
- Usage: aztec flamegraph <contract_artifact> <function>
10
-
11
- Options:
12
- -h, --help Print help
13
-
14
- Will output an svg at <artifact_path>/<contract>-<function>-flamegraph.svg.
15
- You can open it in your browser to view it.
16
-
17
- EOF
18
- exit 0
19
- fi
20
-
21
- cleanup() {
22
- set +e
23
- if [ -f "$function_artifact" ]; then
24
- rm -f "$function_artifact"
25
- fi
26
- }
27
-
28
- trap cleanup EXIT
29
-
30
- # Get the directory of the script
31
- script_dir=$(realpath $(dirname $0))
32
-
33
- PROFILER=${PROFILER_PATH:-noir-profiler}
34
- BB=${BB:-bb}
35
-
36
- # first console arg is contract name in camel case or path to contract artifact
37
- contract=$1
38
-
39
- # second console arg is the contract function
40
- function=$2
41
-
42
- if [ ! -f "$contract" ]; then
43
- echo "Error: Contract artifact not found at: $contract"
44
- exit 1
45
- fi
46
- artifact_path=$contract
47
- function_artifact="${artifact_path%%.json}-${function}.json"
48
- output_dir=$(dirname "$artifact_path")
49
-
50
- # Extract artifact for the specific function.
51
- node $script_dir/extract_function.js "$artifact_path" $function
52
-
53
- # Generate the flamegraph
54
- $PROFILER gates --artifact-path "$function_artifact" --backend-path "$BB" --backend-gates-command "gates" --output "$output_dir" --scheme chonk --include_gates_per_opcode
55
-
56
- # Save as $artifact_name-$function-flamegraph.svg
57
- output_file="${function_artifact%%.json}-flamegraph.svg"
58
- mv "$output_dir/__aztec_nr_internals__${function}_gates.svg" "$output_file"
59
- echo "Flamegraph generated at: $output_file"
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- # Get the actual aztec version for the git tag.
5
- AZTEC_VERSION=$(jq -r '.version' $(dirname $0)/../package.json)
6
- NARGO_TOML_PATH="Nargo.toml"
7
- MAIN_NR_PATH="src/main.nr"
8
-
9
- if [ ! -f "$NARGO_TOML_PATH" ]; then
10
- >&2 echo "Warning: Could not find Nargo.toml at $NARGO_TOML_PATH to add aztec dependency"
11
- exit 1
12
- fi
13
-
14
- if [ ! -f "$MAIN_NR_PATH" ]; then
15
- >&2 echo "Warning: Could not find main.nr at $MAIN_NR_PATH"
16
- exit 1
17
- fi
18
-
19
- # Add aztec dependency to Nargo.toml
20
- echo "" >> "$NARGO_TOML_PATH"
21
- echo "aztec = { git=\"https://github.com/AztecProtocol/aztec-nr\", tag=\"v${AZTEC_VERSION}\", directory=\"aztec\" }" >> "$NARGO_TOML_PATH"
22
- echo "Added aztec dependency (v${AZTEC_VERSION}) to Nargo.toml"
23
-
24
- # Replace the contents of main.nr with the Aztec contract template
25
- cat > "$MAIN_NR_PATH" << 'EOF'
26
- use aztec::macros::aztec;
27
-
28
- #[aztec]
29
- contract Main {}
30
- EOF
31
- echo "Created main.nr with Aztec contract template"
@@ -1,50 +0,0 @@
1
- import { type ArchiverConfig, archiverConfigMappings, createArchiver, getArchiverConfigFromEnv } from '@aztec/archiver';
2
- import { createLogger } from '@aztec/aztec.js/log';
3
- import { type BlobClientConfig, blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
4
- import { getL1Config } from '@aztec/cli/config';
5
- import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
6
- import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
7
- import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
8
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
9
-
10
- import { extractRelevantOptions } from '../util.js';
11
-
12
- export type { ArchiverConfig, DataStoreConfig };
13
-
14
- /** Starts a standalone archiver. */
15
- export async function startArchiver(
16
- options: any,
17
- signalHandlers: (() => Promise<void>)[],
18
- services: NamespacedApiHandlers,
19
- ): Promise<{ config: ArchiverConfig & DataStoreConfig }> {
20
- const envConfig = getArchiverConfigFromEnv();
21
- const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
22
- options,
23
- { ...archiverConfigMappings, ...dataConfigMappings, ...blobClientConfigMapping },
24
- 'archiver',
25
- );
26
-
27
- let archiverConfig = { ...envConfig, ...cliOptions };
28
- archiverConfig.dataStoreMapSizeKb = archiverConfig.archiverStoreMapSizeKb ?? archiverConfig.dataStoreMapSizeKb;
29
-
30
- if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) {
31
- throw new Error('L1 registry address is required to start an Archiver');
32
- }
33
-
34
- const { addresses, config: l1Config } = await getL1Config(
35
- archiverConfig.l1Contracts.registryAddress,
36
- archiverConfig.l1RpcUrls,
37
- archiverConfig.l1ChainId,
38
- );
39
-
40
- archiverConfig.l1Contracts = addresses;
41
- archiverConfig = { ...archiverConfig, ...l1Config };
42
-
43
- const telemetry = await initTelemetryClient(getTelemetryClientConfig());
44
- const blobClient = createBlobClient(archiverConfig, { logger: createLogger('archiver:blob-client:client') });
45
- const archiver = await createArchiver(archiverConfig, { telemetry, blobClient }, { blockUntilSync: true });
46
- services.archiver = [archiver, ArchiverApiSchema];
47
- signalHandlers.push(archiver.stop);
48
-
49
- return { config: archiverConfig };
50
- }
@@ -1,124 +0,0 @@
1
- import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
- import { Fr } from '@aztec/aztec.js/fields';
3
- import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
4
- import { getL1Config } from '@aztec/cli/config';
5
- import { getPublicClient } from '@aztec/ethereum/client';
6
- import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
7
- import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
8
- import type { LogFn } from '@aztec/foundation/log';
9
- import { ProvingJobConsumerSchema, createProvingJobBrokerClient } from '@aztec/prover-client/broker';
10
- import {
11
- type ProverNodeConfig,
12
- createProverNode,
13
- getProverNodeConfigFromEnv,
14
- proverNodeConfigMappings,
15
- } from '@aztec/prover-node';
16
- import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
17
- import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
18
- import { getGenesisValues } from '@aztec/world-state/testing';
19
-
20
- import { extractRelevantOptions, preloadCrsDataForVerifying, setupUpdateMonitor } from '../util.js';
21
- import { getVersions } from '../versioning.js';
22
- import { startProverBroker } from './start_prover_broker.js';
23
-
24
- export async function startProverNode(
25
- options: any,
26
- signalHandlers: (() => Promise<void>)[],
27
- services: NamespacedApiHandlers,
28
- userLog: LogFn,
29
- ): Promise<{ config: ProverNodeConfig }> {
30
- if (options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
31
- userLog(`Starting a prover-node with --node, --sequencer, --pxe, --p2p-bootstrap, or --txe is not supported.`);
32
- process.exit(1);
33
- }
34
-
35
- let proverConfig = {
36
- ...getProverNodeConfigFromEnv(), // get default config from env
37
- ...extractRelevantOptions<ProverNodeConfig>(options, proverNodeConfigMappings, 'proverNode'), // override with command line options
38
- };
39
-
40
- if (!proverConfig.l1Contracts.registryAddress || proverConfig.l1Contracts.registryAddress.isZero()) {
41
- throw new Error('L1 registry address is required to start a Prover Node');
42
- }
43
-
44
- const followsCanonicalRollup = typeof proverConfig.rollupVersion !== 'number';
45
- const { addresses, config } = await getL1Config(
46
- proverConfig.l1Contracts.registryAddress,
47
- proverConfig.l1RpcUrls,
48
- proverConfig.l1ChainId,
49
- proverConfig.rollupVersion,
50
- );
51
- process.env.ROLLUP_CONTRACT_ADDRESS ??= addresses.rollupAddress.toString();
52
- proverConfig.l1Contracts = addresses;
53
- proverConfig = { ...proverConfig, ...config };
54
-
55
- const testAccounts = proverConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
56
- const sponsoredFPCAccounts = proverConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
57
- const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
58
-
59
- userLog(`Initial funded accounts: ${initialFundedAccounts.map(a => a.toString()).join(', ')}`);
60
- const { genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
61
-
62
- userLog(`Genesis archive root: ${genesisArchiveRoot.toString()}`);
63
-
64
- if (!Fr.fromHexString(config.genesisArchiveTreeRoot).equals(genesisArchiveRoot)) {
65
- throw new Error(
66
- `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}`,
67
- );
68
- }
69
-
70
- const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
71
-
72
- let broker: ProvingJobBroker;
73
- if (proverConfig.proverBrokerUrl) {
74
- // at 1TPS we'd enqueue ~1k chonk verifier proofs and ~1k AVM proofs immediately
75
- // set a lower connection limit such that we don't overload the server
76
- // Keep retrying up to 30s
77
- const fetch = makeTracedFetch(
78
- [1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
79
- false,
80
- makeUndiciFetch(new Agent({ connections: 100 })),
81
- );
82
- broker = createProvingJobBrokerClient(proverConfig.proverBrokerUrl, getVersions(proverConfig), fetch);
83
- } else if (options.proverBroker) {
84
- ({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
85
- } else {
86
- userLog(`--prover-broker-url or --prover-broker is required to start a Prover Node`);
87
- process.exit(1);
88
- }
89
-
90
- if (proverConfig.proverAgentCount === 0) {
91
- userLog(
92
- `Running prover node without local prover agent. Connect one or more prover agents to this node or pass --proverAgent.proverAgentCount`,
93
- );
94
- }
95
-
96
- await preloadCrsDataForVerifying(proverConfig, userLog);
97
-
98
- const proverNode = await createProverNode(proverConfig, { telemetry, broker }, { prefilledPublicData });
99
- services.proverNode = [proverNode, ProverNodeApiSchema];
100
-
101
- if (proverNode.getP2P()) {
102
- services.p2p = [proverNode.getP2P(), P2PApiSchema];
103
- }
104
-
105
- if (!proverConfig.proverBrokerUrl) {
106
- services.provingJobSource = [proverNode.getProver().getProvingJobSource(), ProvingJobConsumerSchema];
107
- }
108
-
109
- signalHandlers.push(proverNode.stop.bind(proverNode));
110
-
111
- await proverNode.start();
112
-
113
- if (proverConfig.autoUpdate !== 'disabled' && proverConfig.autoUpdateUrl) {
114
- await setupUpdateMonitor(
115
- proverConfig.autoUpdate,
116
- new URL(proverConfig.autoUpdateUrl),
117
- followsCanonicalRollup,
118
- getPublicClient(proverConfig),
119
- proverConfig.l1Contracts.registryAddress,
120
- signalHandlers,
121
- );
122
- }
123
- return { config: proverConfig };
124
- }
@@ -1,21 +0,0 @@
1
- import { fileURLToPath } from '@aztec/foundation/url';
2
-
3
- import { readFileSync } from 'fs';
4
- import { dirname, resolve } from 'path';
5
-
6
- export const getCliVersion = () => {
7
- const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
8
- const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
9
-
10
- // If the version is 0.1.0, this is a placeholder version and we are in a docker container; query release please for the latest version
11
- if (cliVersion === '0.1.0') {
12
- const releasePleasePath = resolve(
13
- dirname(fileURLToPath(import.meta.url)),
14
- '../../../../.release-please-manifest.json',
15
- );
16
- const releaseVersion = JSON.parse(readFileSync(releasePleasePath).toString())['.'];
17
- return releaseVersion;
18
- }
19
-
20
- return cliVersion;
21
- };
@@ -1,166 +0,0 @@
1
- import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
- import type { ViemClient } from '@aztec/ethereum/types';
3
- import { SlotNumber } from '@aztec/foundation/branded-types';
4
- import type { EthAddress } from '@aztec/foundation/eth-address';
5
- import { type Logger, createLogger } from '@aztec/foundation/log';
6
- import { RunningPromise } from '@aztec/foundation/running-promise';
7
- import type { TestDateProvider } from '@aztec/foundation/timer';
8
- import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
9
-
10
- import { type GetContractReturnType, getAddress, getContract } from 'viem';
11
-
12
- /**
13
- * Represents a watcher for a rollup contract.
14
- *
15
- * It started on a network like anvil where time traveling is allowed, and auto-mine is turned on
16
- * it will periodically check if the current slot have already been filled, e.g., there was an L2
17
- * block within the slot. And if so, it will time travel into the next slot.
18
- */
19
- export class AnvilTestWatcher {
20
- private isLocalNetwork: boolean = false;
21
-
22
- private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
23
- private rollupCheatCodes: RollupCheatCodes;
24
- private l2SlotDuration!: number;
25
-
26
- private filledRunningPromise?: RunningPromise;
27
- private syncDateProviderPromise?: RunningPromise;
28
- private markingAsProvenRunningPromise?: RunningPromise;
29
-
30
- private logger: Logger = createLogger(`aztecjs:utils:watcher`);
31
-
32
- private isMarkingAsProven = true;
33
-
34
- constructor(
35
- private cheatcodes: EthCheatCodes,
36
- rollupAddress: EthAddress,
37
- l1Client: ViemClient,
38
- private dateProvider?: TestDateProvider,
39
- ) {
40
- this.rollup = getContract({
41
- address: getAddress(rollupAddress.toString()),
42
- abi: RollupAbi,
43
- client: l1Client,
44
- });
45
-
46
- this.rollupCheatCodes = new RollupCheatCodes(this.cheatcodes, {
47
- rollupAddress,
48
- });
49
-
50
- this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
51
- }
52
-
53
- setIsMarkingAsProven(isMarkingAsProven: boolean) {
54
- this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
55
- this.isMarkingAsProven = isMarkingAsProven;
56
- }
57
-
58
- setisLocalNetwork(isLocalNetwork: boolean) {
59
- this.isLocalNetwork = isLocalNetwork;
60
- }
61
-
62
- async start() {
63
- if (this.filledRunningPromise) {
64
- throw new Error('Watcher already watching for filled slot');
65
- }
66
-
67
- const config = await this.rollupCheatCodes.getConfig();
68
- this.l2SlotDuration = config.slotDuration;
69
-
70
- // If auto mining is not supported (e.g., we are on a real network), then we
71
- // will simple do nothing. But if on an anvil or the like, this make sure that
72
- // the local network and tests don't break because time is frozen and we never get to
73
- // the next slot.
74
- const isAutoMining = await this.cheatcodes.isAutoMining();
75
-
76
- if (isAutoMining) {
77
- this.filledRunningPromise = new RunningPromise(() => this.warpTimeIfNeeded(), this.logger, 200);
78
- this.filledRunningPromise.start();
79
- this.syncDateProviderPromise = new RunningPromise(() => this.syncDateProviderToL1IfBehind(), this.logger, 200);
80
- this.syncDateProviderPromise.start();
81
- this.markingAsProvenRunningPromise = new RunningPromise(() => this.markAsProven(), this.logger, 200);
82
- this.markingAsProvenRunningPromise.start();
83
- this.logger.info(`Watcher started for rollup at ${this.rollup.address}`);
84
- } else {
85
- this.logger.info(`Watcher not started because not auto mining`);
86
- }
87
- }
88
-
89
- async stop() {
90
- await this.filledRunningPromise?.stop();
91
- await this.syncDateProviderPromise?.stop();
92
- await this.markingAsProvenRunningPromise?.stop();
93
- }
94
-
95
- async trigger() {
96
- await this.filledRunningPromise?.trigger();
97
- await this.syncDateProviderPromise?.trigger();
98
- await this.markingAsProvenRunningPromise?.trigger();
99
- }
100
-
101
- async markAsProven() {
102
- if (!this.isMarkingAsProven) {
103
- return;
104
- }
105
- await this.rollupCheatCodes.markAsProven();
106
- }
107
-
108
- async syncDateProviderToL1IfBehind() {
109
- // this doesn't apply to the local network, because we don't have a date provider in the local network
110
- if (!this.dateProvider) {
111
- return;
112
- }
113
-
114
- const l1Time = (await this.cheatcodes.timestamp()) * 1000;
115
- const wallTime = this.dateProvider.now();
116
- if (l1Time > wallTime) {
117
- this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
118
- this.dateProvider.setTime(l1Time);
119
- } else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
120
- this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to wall time`);
121
- await this.cheatcodes.warp(Math.ceil(wallTime / 1000));
122
- }
123
- }
124
-
125
- async warpTimeIfNeeded() {
126
- try {
127
- const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
128
- const pendingCheckpointNumber = await this.rollup.read.getPendingCheckpointNumber();
129
- const checkpointLog = await this.rollup.read.getCheckpoint([pendingCheckpointNumber]);
130
- const nextSlot = SlotNumber(currentSlot + 1);
131
- const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]));
132
-
133
- if (BigInt(currentSlot) === checkpointLog.slotNumber) {
134
- // We should jump to the next slot
135
- try {
136
- await this.cheatcodes.warp(nextSlotTimestamp, {
137
- resetBlockInterval: true,
138
- });
139
- } catch (e) {
140
- this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
141
- }
142
-
143
- this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
144
- return;
145
- }
146
-
147
- // If we are not in local network, we don't need to warp time
148
- if (!this.isLocalNetwork) {
149
- return;
150
- }
151
-
152
- const currentTimestamp = this.dateProvider?.now() ?? Date.now();
153
- if (currentTimestamp > nextSlotTimestamp * 1000) {
154
- try {
155
- await this.cheatcodes.warp(nextSlotTimestamp, { resetBlockInterval: true });
156
- } catch (e) {
157
- this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
158
- }
159
-
160
- this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
161
- }
162
- } catch {
163
- this.logger.error('mineIfSlotFilled failed');
164
- }
165
- }
166
- }