@aztec/aztec 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2

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 (50) hide show
  1. package/README.md +57 -0
  2. package/dest/bin/index.js +46 -0
  3. package/dest/cli/aztec_start_action.js +110 -0
  4. package/dest/cli/aztec_start_options.js +341 -0
  5. package/dest/cli/cli.js +33 -0
  6. package/dest/cli/cmds/start_archiver.js +35 -0
  7. package/dest/cli/cmds/start_bot.js +31 -0
  8. package/dest/cli/cmds/start_faucet.js +20 -0
  9. package/dest/cli/cmds/start_node.js +109 -0
  10. package/dest/cli/cmds/start_p2p_bootstrap.js +20 -0
  11. package/dest/cli/cmds/start_proof_verifier.js +12 -0
  12. package/dest/cli/cmds/start_prover_agent.js +32 -0
  13. package/dest/cli/cmds/start_prover_broker.js +22 -0
  14. package/dest/cli/cmds/start_prover_node.js +81 -0
  15. package/dest/cli/cmds/start_pxe.js +90 -0
  16. package/dest/cli/cmds/start_txe.js +11 -0
  17. package/dest/cli/index.js +1 -0
  18. package/dest/cli/util.js +154 -0
  19. package/dest/cli/validation.js +25 -0
  20. package/dest/examples/token.js +53 -0
  21. package/dest/examples/util.js +31 -0
  22. package/dest/index.js +1 -0
  23. package/dest/mnemonic.js +1 -0
  24. package/dest/sandbox.js +116 -0
  25. package/dest/splash.js +2 -0
  26. package/package.json +119 -0
  27. package/src/bin/index.ts +54 -0
  28. package/src/cli/aztec_start_action.ts +115 -0
  29. package/src/cli/aztec_start_options.ts +366 -0
  30. package/src/cli/cli.ts +48 -0
  31. package/src/cli/cmds/start_archiver.ts +47 -0
  32. package/src/cli/cmds/start_bot.ts +49 -0
  33. package/src/cli/cmds/start_faucet.ts +34 -0
  34. package/src/cli/cmds/start_node.ts +123 -0
  35. package/src/cli/cmds/start_p2p_bootstrap.ts +25 -0
  36. package/src/cli/cmds/start_proof_verifier.ts +18 -0
  37. package/src/cli/cmds/start_prover_agent.ts +65 -0
  38. package/src/cli/cmds/start_prover_broker.ts +37 -0
  39. package/src/cli/cmds/start_prover_node.ts +100 -0
  40. package/src/cli/cmds/start_pxe.ts +124 -0
  41. package/src/cli/cmds/start_txe.ts +15 -0
  42. package/src/cli/index.ts +1 -0
  43. package/src/cli/util.ts +216 -0
  44. package/src/cli/validation.ts +38 -0
  45. package/src/examples/token.ts +74 -0
  46. package/src/examples/util.ts +44 -0
  47. package/src/index.ts +1 -0
  48. package/src/mnemonic.ts +1 -0
  49. package/src/sandbox.ts +165 -0
  50. package/src/splash.ts +10 -0
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # aztec
2
+
3
+ Aztec is a package that allows for a simple development environment on Aztec stack. It creates a Private eXecution Environment (PXE) that listens for HTTP requests on `localhost:8080` by default. When started, it deploys all necessary L1 Aztec contracts and then starts listening for RPC requests.
4
+
5
+ ## How to run:
6
+
7
+ ### Docker Compose
8
+
9
+ The easiest way to run is by using `docker compose up`. This will create two containers:
10
+
11
+ 1. The sandbox listening on port `8080`
12
+ 2. An anvil instance listening on port `8545`
13
+
14
+ ### Node Server
15
+
16
+ You can also run it as a standalone node server with:
17
+
18
+ ```sh
19
+ yarn start
20
+ ```
21
+
22
+ It will look for a local Ethereum RPC to talk to but you can change this with the `ETHEREUM_HOST` environment variable.
23
+
24
+ ## Examples
25
+
26
+ The package also includes 2 examples. There are some system prerequisites that you will need to run these locally:
27
+
28
+ - [nvm](https://github.com/nvm-sh/nvm)
29
+ - Node version > 18
30
+ - [yarn](https://yarnpkg.com/)
31
+ - [jq](https://jqlang.github.io/jq/download/)
32
+
33
+ Before running locally you'll need to:
34
+
35
+ - Head to `l1-contracts` directory and run `./bootstrap.sh`
36
+ - Then go to `yarn-project and run:
37
+ - `yarn install`
38
+ - `yarn build`
39
+ And you should be good to go!
40
+
41
+ From the `aztec` directory, you can run the two existing examples:
42
+
43
+ - Deployment, mint and transfer on an Aztec Private Token
44
+ - `yarn run:example:token`
45
+ - An L1 / L2 uniswap token trade.
46
+ - `yarn run:example:uniswap`
47
+ - To run this example, you need to set the following vars:
48
+
49
+ ```
50
+ export FORK_BLOCK_NUMBER=17514288
51
+ export FORK_URL=<YOUR_RPC_URL e.g. https://mainnet.infura.io/v3/API_KEY>
52
+ ```
53
+
54
+ ## Publishing
55
+
56
+ This package is set-up to be published on dockerhub by CI whenever there's a tagged release on `master` branch.
57
+ It's published under the tags `aztecprotocol/aztec:latest` & `aztecprotocol/aztec:<version-tag>`.
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ //
3
+ import { injectCommands as injectBuilderCommands } from '@aztec/builder';
4
+ import { injectCommands as injectWalletCommands } from '@aztec/cli-wallet';
5
+ import { injectCommands as injectContractCommands } from '@aztec/cli/contracts';
6
+ import { injectCommands as injectDevnetCommands } from '@aztec/cli/devnet';
7
+ import { injectCommands as injectInfrastructureCommands } from '@aztec/cli/infrastructure';
8
+ import { injectCommands as injectL1Commands } from '@aztec/cli/l1';
9
+ import { injectCommands as injectMiscCommands } from '@aztec/cli/misc';
10
+ import { injectCommands as injectPXECommands } from '@aztec/cli/pxe';
11
+ import { createConsoleLogger, createLogger } from '@aztec/foundation/log';
12
+ import { fileURLToPath } from '@aztec/foundation/url';
13
+ import { Command } from 'commander';
14
+ import { readFileSync } from 'fs';
15
+ import { dirname, resolve } from 'path';
16
+ import { injectAztecCommands } from '../cli/index.js';
17
+ const userLog = createConsoleLogger();
18
+ const debugLogger = createLogger('cli');
19
+ /** CLI & full node main entrypoint */ async function main() {
20
+ const shutdown = ()=>{
21
+ process.exit(0);
22
+ };
23
+ process.once('SIGINT', shutdown);
24
+ process.once('SIGTERM', shutdown);
25
+ const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
26
+ const cliVersion = JSON.parse(readFileSync(packageJsonPath).toString()).version;
27
+ let program = new Command('aztec');
28
+ program.description('Aztec command line interface').version(cliVersion);
29
+ program = injectAztecCommands(program, userLog, debugLogger);
30
+ program = injectBuilderCommands(program);
31
+ program = injectContractCommands(program, userLog, debugLogger);
32
+ program = injectInfrastructureCommands(program, userLog, debugLogger);
33
+ program = injectL1Commands(program, userLog, debugLogger);
34
+ program = injectPXECommands(program, userLog, debugLogger);
35
+ program = injectMiscCommands(program, userLog);
36
+ program = injectDevnetCommands(program, userLog, debugLogger);
37
+ program = injectWalletCommands(program, userLog, debugLogger);
38
+ await program.parseAsync(process.argv);
39
+ }
40
+ main().catch((err)=>{
41
+ debugLogger.error(`Error in command execution`);
42
+ debugLogger.error(err + '\n' + err.stack);
43
+ // See https://nodejs.org/api/process.html#processexitcode
44
+ process.exitCode = 1;
45
+ throw err;
46
+ });
@@ -0,0 +1,110 @@
1
+ import { deployInitialTestAccounts } from '@aztec/accounts/testing';
2
+ import { AztecNodeApiSchema, PXESchema } from '@aztec/circuit-types';
3
+ import { createNamespacedSafeJsonRpcServer, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
4
+ import { fileURLToPath } from '@aztec/foundation/url';
5
+ import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
6
+ import { readFileSync } from 'fs';
7
+ import { dirname, resolve } from 'path';
8
+ import { createSandbox } from '../sandbox.js';
9
+ import { github, splash } from '../splash.js';
10
+ import { createAccountLogs, extractNamespacedOptions, installSignalHandlers } from './util.js';
11
+ const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
12
+ const cliVersion = JSON.parse(readFileSync(packageJsonPath).toString()).version;
13
+ export async function aztecStart(options, userLog, debugLogger) {
14
+ // list of 'stop' functions to call when process ends
15
+ const signalHandlers = [];
16
+ const services = {};
17
+ if (options.sandbox) {
18
+ const sandboxOptions = extractNamespacedOptions(options, 'sandbox');
19
+ const nodeOptions = extractNamespacedOptions(options, 'node');
20
+ userLog(`${splash}\n${github}\n\n`);
21
+ userLog(`Setting up Aztec Sandbox ${cliVersion}, please stand by...`);
22
+ const { aztecNodeConfig, node, pxe, stop } = await createSandbox({
23
+ l1Mnemonic: options.l1Mnemonic,
24
+ l1RpcUrl: options.l1RpcUrl,
25
+ l1Salt: nodeOptions.deployAztecContractsSalt
26
+ });
27
+ // Deploy test accounts by default
28
+ if (sandboxOptions.testAccounts) {
29
+ if (aztecNodeConfig.p2pEnabled) {
30
+ userLog(`Not setting up test accounts as we are connecting to a network`);
31
+ } else if (sandboxOptions.noPXE) {
32
+ userLog(`Not setting up test accounts as we are not exposing a PXE`);
33
+ } else {
34
+ userLog('Setting up test accounts...');
35
+ const accounts = await deployInitialTestAccounts(pxe);
36
+ const accLogs = await createAccountLogs(accounts, pxe);
37
+ userLog(accLogs.join(''));
38
+ }
39
+ }
40
+ // Start Node and PXE JSON-RPC server
41
+ signalHandlers.push(stop);
42
+ services.node = [
43
+ node,
44
+ AztecNodeApiSchema
45
+ ];
46
+ if (!sandboxOptions.noPXE) {
47
+ services.pxe = [
48
+ pxe,
49
+ PXESchema
50
+ ];
51
+ } else {
52
+ userLog(`Not exposing PXE API through JSON-RPC server`);
53
+ }
54
+ } else {
55
+ if (options.node) {
56
+ const { startNode } = await import('./cmds/start_node.js');
57
+ await startNode(options, signalHandlers, services, userLog);
58
+ } else if (options.proofVerifier) {
59
+ const { startProofVerifier } = await import('./cmds/start_proof_verifier.js');
60
+ await startProofVerifier(options, signalHandlers, userLog);
61
+ } else if (options.bot) {
62
+ const { startBot } = await import('./cmds/start_bot.js');
63
+ await startBot(options, signalHandlers, services, userLog);
64
+ } else if (options.proverNode) {
65
+ const { startProverNode } = await import('./cmds/start_prover_node.js');
66
+ await startProverNode(options, signalHandlers, services, userLog);
67
+ } else if (options.pxe) {
68
+ const { startPXE } = await import('./cmds/start_pxe.js');
69
+ await startPXE(options, signalHandlers, services, userLog);
70
+ } else if (options.archiver) {
71
+ const { startArchiver } = await import('./cmds/start_archiver.js');
72
+ await startArchiver(options, signalHandlers, services);
73
+ } else if (options.p2pBootstrap) {
74
+ const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
75
+ await startP2PBootstrap(options, signalHandlers, services, userLog);
76
+ } else if (options.proverAgent) {
77
+ const { startProverAgent } = await import('./cmds/start_prover_agent.js');
78
+ await startProverAgent(options, signalHandlers, services, userLog);
79
+ } else if (options.proverBroker) {
80
+ const { startProverBroker } = await import('./cmds/start_prover_broker.js');
81
+ await startProverBroker(options, signalHandlers, services, userLog);
82
+ } else if (options.txe) {
83
+ const { startTXE } = await import('./cmds/start_txe.js');
84
+ await startTXE(options, debugLogger);
85
+ } else if (options.sequencer) {
86
+ userLog(`Cannot run a standalone sequencer without a node`);
87
+ process.exit(1);
88
+ } else if (options.faucet) {
89
+ const { startFaucet } = await import('./cmds/start_faucet.js');
90
+ await startFaucet(options, signalHandlers, services, userLog);
91
+ } else {
92
+ userLog(`No module specified to start`);
93
+ process.exit(1);
94
+ }
95
+ }
96
+ installSignalHandlers(debugLogger.info, signalHandlers);
97
+ if (Object.entries(services).length > 0) {
98
+ const rpcServer = createNamespacedSafeJsonRpcServer(services, {
99
+ http200OnError: false,
100
+ log: debugLogger,
101
+ middlewares: [
102
+ getOtelJsonRpcPropagationMiddleware()
103
+ ]
104
+ });
105
+ const { port } = await startHttpRpcServer(rpcServer, {
106
+ port: options.port
107
+ });
108
+ debugLogger.info(`Aztec Server listening on port ${port}`);
109
+ }
110
+ }
@@ -0,0 +1,341 @@
1
+ import { archiverConfigMappings } from '@aztec/archiver/config';
2
+ import { faucetConfigMapping } from '@aztec/aztec-faucet/config';
3
+ import { sequencerClientConfigMappings } from '@aztec/aztec-node/config';
4
+ import { blobSinkConfigMapping } from '@aztec/blob-sink/client';
5
+ import { botConfigMappings } from '@aztec/bot/config';
6
+ import { booleanConfigHelper, isBooleanConfigValue, omitConfigMappings } from '@aztec/foundation/config';
7
+ import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config';
8
+ import { proofVerifierConfigMappings } from '@aztec/proof-verifier/config';
9
+ import { proverAgentConfigMappings, proverBrokerConfigMappings } from '@aztec/prover-client/broker';
10
+ import { proverNodeConfigMappings } from '@aztec/prover-node/config';
11
+ import { allPxeConfigMappings } from '@aztec/pxe/config';
12
+ import { telemetryClientConfigMappings } from '@aztec/telemetry-client';
13
+ import { DefaultMnemonic } from '../mnemonic.js';
14
+ export const getOptions = (namespace, configMappings)=>{
15
+ const options = [];
16
+ for (const [key, { env, defaultValue: def, parseEnv, description, printDefault }] of Object.entries(configMappings)){
17
+ if (universalOptions.includes(key)) {
18
+ continue;
19
+ }
20
+ const isBoolean = isBooleanConfigValue(configMappings, key);
21
+ options.push({
22
+ flag: `--${namespace}.${key}${isBoolean ? '' : ' <value>'}`,
23
+ description,
24
+ defaultValue: def,
25
+ printDefault,
26
+ envVar: env,
27
+ parseVal: parseEnv
28
+ });
29
+ }
30
+ return options;
31
+ };
32
+ // These are options used by multiple modules so should be inputted once
33
+ export const universalOptions = [
34
+ 'l1RpcUrl',
35
+ 'l1ChainId',
36
+ 'l1Contracts',
37
+ 'p2pEnabled',
38
+ 'dataDirectory'
39
+ ];
40
+ // Define categories and options
41
+ export const aztecStartOptions = {
42
+ SANDBOX: [
43
+ {
44
+ flag: '--sandbox',
45
+ description: 'Starts Aztec Sandbox',
46
+ defaultValue: undefined,
47
+ envVar: undefined
48
+ },
49
+ {
50
+ flag: '--sandbox.testAccounts',
51
+ description: 'Deploy test accounts on sandbox start',
52
+ envVar: 'TEST_ACCOUNTS',
53
+ ...booleanConfigHelper(true)
54
+ },
55
+ {
56
+ flag: '--sandbox.noPXE',
57
+ description: 'Do not expose PXE service on sandbox start',
58
+ envVar: 'NO_PXE',
59
+ ...booleanConfigHelper()
60
+ }
61
+ ],
62
+ API: [
63
+ {
64
+ flag: '--port <value>',
65
+ description: 'Port to run the Aztec Services on on',
66
+ defaultValue: 8080,
67
+ envVar: 'AZTEC_PORT',
68
+ parseVal: (val)=>parseInt(val, 10)
69
+ },
70
+ {
71
+ flag: '--api-prefix <value>',
72
+ description: 'Prefix for API routes on any service that is started',
73
+ defaultValue: '',
74
+ envVar: 'API_PREFIX'
75
+ }
76
+ ],
77
+ ETHEREUM: [
78
+ {
79
+ flag: '--l1-rpc-url <value>',
80
+ description: 'URL of the Ethereum RPC node that services will connect to',
81
+ defaultValue: 'http://localhost:8545',
82
+ envVar: 'ETHEREUM_HOST'
83
+ },
84
+ {
85
+ flag: '--l1-chain-id <value>',
86
+ description: 'The L1 chain ID',
87
+ defaultValue: 31337,
88
+ envVar: 'L1_CHAIN_ID',
89
+ parseVal: (val)=>parseInt(val, 10)
90
+ },
91
+ {
92
+ flag: '--l1-mnemonic <value>',
93
+ description: 'Mnemonic for L1 accounts. Will be used if no publisher private keys are provided',
94
+ defaultValue: DefaultMnemonic,
95
+ envVar: 'MNEMONIC'
96
+ }
97
+ ],
98
+ 'L1 CONTRACT ADDRESSES': [
99
+ {
100
+ flag: '--rollup-address <value>',
101
+ description: 'The deployed L1 rollup contract address',
102
+ defaultValue: undefined,
103
+ envVar: 'ROLLUP_CONTRACT_ADDRESS'
104
+ },
105
+ {
106
+ flag: '--registry-address <value>',
107
+ description: 'The deployed L1 registry contract address',
108
+ defaultValue: undefined,
109
+ envVar: 'REGISTRY_CONTRACT_ADDRESS'
110
+ },
111
+ {
112
+ flag: '--inbox-address <value>',
113
+ description: 'The deployed L1 -> L2 inbox contract address',
114
+ defaultValue: undefined,
115
+ envVar: 'INBOX_CONTRACT_ADDRESS'
116
+ },
117
+ {
118
+ flag: '--outbox-address <value>',
119
+ description: 'The deployed L2 -> L1 outbox contract address',
120
+ defaultValue: undefined,
121
+ envVar: 'OUTBOX_CONTRACT_ADDRESS'
122
+ },
123
+ {
124
+ flag: '--fee-juice-address <value>',
125
+ description: 'The deployed L1 Fee Juice contract address',
126
+ defaultValue: undefined,
127
+ envVar: 'FEE_JUICE_CONTRACT_ADDRESS'
128
+ },
129
+ {
130
+ flag: '--staking-asset-address <value>',
131
+ description: 'The deployed L1 Staking Asset contract address',
132
+ defaultValue: undefined,
133
+ envVar: 'STAKING_ASSET_CONTRACT_ADDRESS'
134
+ },
135
+ {
136
+ flag: '--fee-juice-portal-address <value>',
137
+ description: 'The deployed L1 Fee Juice portal contract address',
138
+ defaultValue: undefined,
139
+ envVar: 'FEE_JUICE_PORTAL_CONTRACT_ADDRESS'
140
+ }
141
+ ],
142
+ // We can't easily auto-generate node options as they're parts of modules defined below
143
+ 'AZTEC NODE': [
144
+ {
145
+ flag: '--node',
146
+ description: 'Starts Aztec Node with options',
147
+ defaultValue: undefined,
148
+ envVar: undefined
149
+ },
150
+ {
151
+ flag: '--data-directory <value>',
152
+ description: 'Where to store data. If not set, will store temporarily',
153
+ defaultValue: undefined,
154
+ envVar: 'DATA_DIRECTORY'
155
+ },
156
+ {
157
+ flag: '--node.archiverUrl <value>',
158
+ description: 'URL for an archiver service',
159
+ defaultValue: undefined,
160
+ envVar: 'ARCHIVER_URL'
161
+ },
162
+ {
163
+ flag: '--node.deployAztecContracts',
164
+ description: 'Deploys L1 Aztec contracts before starting the node. Needs mnemonic or private key to be set.',
165
+ envVar: 'DEPLOY_AZTEC_CONTRACTS',
166
+ ...booleanConfigHelper()
167
+ },
168
+ {
169
+ flag: '--node.deployAztecContractsSalt',
170
+ description: 'Numeric salt for deploying L1 Aztec contracts before starting the node. Needs mnemonic or private key to be set. Implies --node.deployAztecContracts.',
171
+ envVar: 'DEPLOY_AZTEC_CONTRACTS_SALT',
172
+ defaultValue: undefined,
173
+ parseVal: (val)=>val ? parseInt(val) : undefined
174
+ },
175
+ {
176
+ flag: '--node.assumeProvenThroughBlockNumber',
177
+ description: 'Cheats the rollup contract into assuming every block until this one is proven. Useful for speeding up bootstraps.',
178
+ envVar: 'ASSUME_PROVEN_THROUGH_BLOCK_NUMBER',
179
+ parseVal: (val)=>parseInt(val, 10),
180
+ defaultValue: 0
181
+ },
182
+ {
183
+ flag: '--node.publisherPrivateKey <value>',
184
+ description: 'Private key of account for publishing L1 contracts',
185
+ defaultValue: undefined,
186
+ envVar: 'L1_PRIVATE_KEY'
187
+ },
188
+ {
189
+ flag: '--node.worldStateBlockCheckIntervalMS <value>',
190
+ description: 'Frequency in which to check for blocks in ms',
191
+ defaultValue: 100,
192
+ envVar: 'WS_BLOCK_CHECK_INTERVAL_MS',
193
+ parseVal: (val)=>parseInt(val, 10)
194
+ }
195
+ ],
196
+ 'P2P SUBSYSTEM': [
197
+ {
198
+ flag: '--p2p-enabled',
199
+ description: 'Enable P2P subsystem',
200
+ envVar: 'P2P_ENABLED',
201
+ ...booleanConfigHelper()
202
+ },
203
+ ...getOptions('p2p', p2pConfigMappings)
204
+ ],
205
+ TELEMETRY: [
206
+ ...getOptions('tel', telemetryClientConfigMappings)
207
+ ],
208
+ PXE: [
209
+ {
210
+ flag: '--pxe',
211
+ description: 'Starts Aztec PXE with options',
212
+ defaultValue: undefined,
213
+ envVar: undefined
214
+ },
215
+ ...getOptions('pxe', allPxeConfigMappings)
216
+ ],
217
+ ARCHIVER: [
218
+ {
219
+ flag: '--archiver',
220
+ description: 'Starts Aztec Archiver with options',
221
+ defaultValue: undefined,
222
+ envVar: undefined
223
+ },
224
+ // filter out archiverUrl as it's passed separately in --node & --prover-node
225
+ ...getOptions('archiver', archiverConfigMappings).filter((opt)=>!opt.flag.includes('archiverUrl'))
226
+ ],
227
+ SEQUENCER: [
228
+ {
229
+ flag: '--sequencer',
230
+ description: 'Starts Aztec Sequencer with options',
231
+ defaultValue: undefined,
232
+ envVar: undefined
233
+ },
234
+ ...getOptions('sequencer', sequencerClientConfigMappings)
235
+ ],
236
+ BLOB_SINK: [
237
+ {
238
+ flag: '--blob-sink',
239
+ description: 'Starts Aztec Blob Sink with options',
240
+ defaultValue: undefined,
241
+ envVar: undefined
242
+ },
243
+ ...getOptions('blobSink', blobSinkConfigMapping)
244
+ ],
245
+ 'PROVER NODE': [
246
+ {
247
+ flag: '--prover-node',
248
+ description: 'Starts Aztec Prover Node with options',
249
+ defaultValue: undefined,
250
+ envVar: undefined
251
+ },
252
+ {
253
+ flag: '--proverNode.archiverUrl <value>',
254
+ description: 'URL for an archiver service',
255
+ defaultValue: undefined,
256
+ envVar: 'ARCHIVER_URL'
257
+ },
258
+ ...getOptions('proverNode', omitConfigMappings(proverNodeConfigMappings, [
259
+ // filter out options passed separately
260
+ ...Object.keys(archiverConfigMappings),
261
+ ...Object.keys(proverBrokerConfigMappings),
262
+ ...Object.keys(proverAgentConfigMappings)
263
+ ]))
264
+ ],
265
+ 'PROVER BROKER': [
266
+ {
267
+ flag: '--prover-broker',
268
+ description: 'Starts Aztec proving job broker',
269
+ defaultValue: undefined,
270
+ envVar: undefined
271
+ },
272
+ ...getOptions('proverBroker', // filter out archiver options from prover node options as they're passed separately in --archiver
273
+ proverBrokerConfigMappings)
274
+ ],
275
+ 'PROVER AGENT': [
276
+ {
277
+ flag: '--prover-agent',
278
+ description: 'Starts Aztec Prover Agent with options',
279
+ defaultValue: undefined,
280
+ envVar: undefined
281
+ },
282
+ ...getOptions('proverAgent', proverAgentConfigMappings)
283
+ ],
284
+ 'P2P BOOTSTRAP': [
285
+ {
286
+ flag: '--p2p-bootstrap',
287
+ description: 'Starts Aztec P2P Bootstrap with options',
288
+ defaultValue: undefined,
289
+ envVar: undefined
290
+ },
291
+ ...getOptions('p2pBootstrap', bootnodeConfigMappings)
292
+ ],
293
+ BOT: [
294
+ {
295
+ flag: '--bot',
296
+ description: 'Starts Aztec Bot with options',
297
+ defaultValue: undefined,
298
+ envVar: undefined
299
+ },
300
+ ...getOptions('bot', botConfigMappings)
301
+ ],
302
+ 'PROOF VERIFIER': [
303
+ {
304
+ flag: '--proof-verifier',
305
+ description: 'Starts Aztec Proof Verifier with options',
306
+ defaultValue: undefined,
307
+ envVar: undefined
308
+ },
309
+ ...getOptions('proofVerifier', proofVerifierConfigMappings)
310
+ ],
311
+ TXE: [
312
+ {
313
+ flag: '--txe',
314
+ description: 'Starts Aztec TXE with options',
315
+ defaultValue: undefined,
316
+ envVar: undefined
317
+ }
318
+ ],
319
+ FAUCET: [
320
+ {
321
+ flag: '--faucet',
322
+ description: 'Starts the Aztec faucet',
323
+ defaultValue: undefined,
324
+ envVar: undefined
325
+ },
326
+ {
327
+ flag: '--faucet.apiServer',
328
+ description: 'Starts a simple HTTP server to access the faucet',
329
+ defaultValue: true,
330
+ envVar: undefined
331
+ },
332
+ {
333
+ flag: '--faucet.apiServerPort <value>',
334
+ description: 'The port on which to start the api server on',
335
+ defaultValue: 8080,
336
+ envVar: undefined,
337
+ parseVal: (val)=>parseInt(val, 10)
338
+ },
339
+ ...getOptions('faucet', faucetConfigMapping)
340
+ ]
341
+ };
@@ -0,0 +1,33 @@
1
+ import { Command } from 'commander';
2
+ import { aztecStartOptions } from './aztec_start_options.js';
3
+ import { addOptions, printAztecStartHelpText } from './util.js';
4
+ /**
5
+ * Returns commander program that defines the 'aztec' command line interface.
6
+ * @param userLog - log function for logging user output.
7
+ * @param debugLogger - logger for logging debug messages.
8
+ */ export function injectAztecCommands(program, userLog, debugLogger) {
9
+ const startCmd = new Command('start').description('Starts Aztec modules. Options for each module can be set as key-value pairs (e.g. "option1=value1,option2=value2") or as environment variables.');
10
+ // Assuming commands are added elsewhere, here we just add options to the main program
11
+ Object.keys(aztecStartOptions).forEach((category)=>{
12
+ addOptions(startCmd, aztecStartOptions[category]);
13
+ });
14
+ startCmd.helpInformation = printAztecStartHelpText;
15
+ startCmd.action(async (options)=>{
16
+ const { aztecStart } = await import('./aztec_start_action.js');
17
+ return await aztecStart(options, userLog, debugLogger);
18
+ });
19
+ program.addCommand(startCmd);
20
+ program.configureHelp({
21
+ sortSubcommands: true
22
+ });
23
+ program.addHelpText('after', `
24
+
25
+ Additional commands:
26
+
27
+ test [options]: starts a dockerized TXE node via
28
+ $ aztec start --txe
29
+ then runs
30
+ $ aztec-nargo test --silence-warnings --oracle-resolver=<TXE_ADDRESS> [options]
31
+ `);
32
+ return program;
33
+ }
@@ -0,0 +1,35 @@
1
+ import { Archiver, KVArchiverDataStore, archiverConfigMappings, getArchiverConfigFromEnv } from '@aztec/archiver';
2
+ import { createLogger } from '@aztec/aztec.js';
3
+ import { createBlobSinkClient } from '@aztec/blob-sink/client';
4
+ import { ArchiverApiSchema } from '@aztec/circuit-types';
5
+ import { dataConfigMappings } from '@aztec/kv-store/config';
6
+ import { createStore } from '@aztec/kv-store/lmdb-v2';
7
+ import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
8
+ import { extractRelevantOptions } from '../util.js';
9
+ import { validateL1Config } from '../validation.js';
10
+ /** Starts a standalone archiver. */ export async function startArchiver(options, signalHandlers, services) {
11
+ const archiverConfig = extractRelevantOptions(options, {
12
+ ...archiverConfigMappings,
13
+ ...dataConfigMappings
14
+ }, 'archiver');
15
+ await validateL1Config({
16
+ ...getArchiverConfigFromEnv(),
17
+ ...archiverConfig
18
+ });
19
+ const storeLog = createLogger('archiver:lmdb');
20
+ const store = await createStore('archiver', archiverConfig, storeLog);
21
+ const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
22
+ const telemetry = initTelemetryClient(getTelemetryClientConfig());
23
+ // TODO(https://github.com/AztecProtocol/aztec-packages/issues/10056): place CL url in config here
24
+ const blobSinkClient = createBlobSinkClient();
25
+ const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, {
26
+ telemetry,
27
+ blobSinkClient
28
+ }, true);
29
+ services.archiver = [
30
+ archiver,
31
+ ArchiverApiSchema
32
+ ];
33
+ signalHandlers.push(archiver.stop);
34
+ return services;
35
+ }
@@ -0,0 +1,31 @@
1
+ import { BotRunner, botConfigMappings, getBotRunnerApiHandler } from '@aztec/bot';
2
+ import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
3
+ import { extractRelevantOptions } from '../util.js';
4
+ export async function startBot(options, signalHandlers, services, userLog) {
5
+ const { proverNode, archiver, sequencer, p2pBootstrap, txe, prover } = options;
6
+ if (proverNode || archiver || sequencer || p2pBootstrap || txe || prover) {
7
+ userLog(`Starting a bot with --prover-node, --prover, --archiver, --sequencer, --p2p-bootstrap, or --txe is not supported.`);
8
+ process.exit(1);
9
+ }
10
+ // Start a PXE client that is used by the bot if required
11
+ let pxe;
12
+ if (options.pxe) {
13
+ const { addPXE } = await import('./start_pxe.js');
14
+ pxe = await addPXE(options, signalHandlers, services, userLog);
15
+ }
16
+ const telemetry = initTelemetryClient(getTelemetryClientConfig());
17
+ await addBot(options, signalHandlers, services, {
18
+ pxe,
19
+ telemetry
20
+ });
21
+ }
22
+ export function addBot(options, signalHandlers, services, deps) {
23
+ const config = extractRelevantOptions(options, botConfigMappings, 'bot');
24
+ const botRunner = new BotRunner(config, deps);
25
+ if (!config.noStart) {
26
+ void botRunner.start(); // Do not block since bot setup takes time
27
+ }
28
+ services.bot = getBotRunnerApiHandler(botRunner);
29
+ signalHandlers.push(botRunner.stop);
30
+ return Promise.resolve();
31
+ }
@@ -0,0 +1,20 @@
1
+ import { Faucet, FaucetSchema, createFaucetHttpServer, faucetConfigMapping, getFaucetConfigFromEnv } from '@aztec/aztec-faucet';
2
+ import { extractNamespacedOptions, extractRelevantOptions } from '../util.js';
3
+ export async function startFaucet(options, signalHandlers, services, log) {
4
+ const faucetOptions = extractNamespacedOptions(options, 'faucet');
5
+ const config = {
6
+ ...getFaucetConfigFromEnv(),
7
+ ...extractRelevantOptions(options, faucetConfigMapping, 'faucet')
8
+ };
9
+ const faucet = await Faucet.create(config);
10
+ if (faucetOptions.apiServer) {
11
+ const httpServer = createFaucetHttpServer(faucet);
12
+ httpServer.listen(faucetOptions.apiServerPort);
13
+ signalHandlers.push(()=>new Promise((res)=>httpServer.close(()=>res())));
14
+ log(`Faucet now running on port: ${faucetOptions.apiServerPort}`);
15
+ }
16
+ services.faucet = [
17
+ faucet,
18
+ FaucetSchema
19
+ ];
20
+ }