@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.
- package/README.md +57 -0
- package/dest/bin/index.js +46 -0
- package/dest/cli/aztec_start_action.js +110 -0
- package/dest/cli/aztec_start_options.js +341 -0
- package/dest/cli/cli.js +33 -0
- package/dest/cli/cmds/start_archiver.js +35 -0
- package/dest/cli/cmds/start_bot.js +31 -0
- package/dest/cli/cmds/start_faucet.js +20 -0
- package/dest/cli/cmds/start_node.js +109 -0
- package/dest/cli/cmds/start_p2p_bootstrap.js +20 -0
- package/dest/cli/cmds/start_proof_verifier.js +12 -0
- package/dest/cli/cmds/start_prover_agent.js +32 -0
- package/dest/cli/cmds/start_prover_broker.js +22 -0
- package/dest/cli/cmds/start_prover_node.js +81 -0
- package/dest/cli/cmds/start_pxe.js +90 -0
- package/dest/cli/cmds/start_txe.js +11 -0
- package/dest/cli/index.js +1 -0
- package/dest/cli/util.js +154 -0
- package/dest/cli/validation.js +25 -0
- package/dest/examples/token.js +53 -0
- package/dest/examples/util.js +31 -0
- package/dest/index.js +1 -0
- package/dest/mnemonic.js +1 -0
- package/dest/sandbox.js +116 -0
- package/dest/splash.js +2 -0
- package/package.json +119 -0
- package/src/bin/index.ts +54 -0
- package/src/cli/aztec_start_action.ts +115 -0
- package/src/cli/aztec_start_options.ts +366 -0
- package/src/cli/cli.ts +48 -0
- package/src/cli/cmds/start_archiver.ts +47 -0
- package/src/cli/cmds/start_bot.ts +49 -0
- package/src/cli/cmds/start_faucet.ts +34 -0
- package/src/cli/cmds/start_node.ts +123 -0
- package/src/cli/cmds/start_p2p_bootstrap.ts +25 -0
- package/src/cli/cmds/start_proof_verifier.ts +18 -0
- package/src/cli/cmds/start_prover_agent.ts +65 -0
- package/src/cli/cmds/start_prover_broker.ts +37 -0
- package/src/cli/cmds/start_prover_node.ts +100 -0
- package/src/cli/cmds/start_pxe.ts +124 -0
- package/src/cli/cmds/start_txe.ts +15 -0
- package/src/cli/index.ts +1 -0
- package/src/cli/util.ts +216 -0
- package/src/cli/validation.ts +38 -0
- package/src/examples/token.ts +74 -0
- package/src/examples/util.ts +44 -0
- package/src/index.ts +1 -0
- package/src/mnemonic.ts +1 -0
- package/src/sandbox.ts +165 -0
- package/src/splash.ts +10 -0
package/dest/sandbox.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
#!/usr/bin/env -S node --no-warnings
|
|
2
|
+
import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
3
|
+
import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet } from '@aztec/aztec.js';
|
|
4
|
+
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
|
|
5
|
+
import { createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
6
|
+
import { setupCanonicalL2FeeJuice } from '@aztec/cli/setup-contracts';
|
|
7
|
+
import { NULL_KEY, createEthereumChain, deployL1Contracts, getL1ContractsConfigEnvVars, waitForPublicClient } from '@aztec/ethereum';
|
|
8
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
9
|
+
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
|
|
10
|
+
import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
11
|
+
import { createPXEService, getPXEServiceConfig } from '@aztec/pxe';
|
|
12
|
+
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
13
|
+
import { createPublicClient, http as httpViemTransport } from 'viem';
|
|
14
|
+
import { mnemonicToAccount } from 'viem/accounts';
|
|
15
|
+
import { foundry } from 'viem/chains';
|
|
16
|
+
import { DefaultMnemonic } from './mnemonic.js';
|
|
17
|
+
const logger = createLogger('sandbox');
|
|
18
|
+
const localAnvil = foundry;
|
|
19
|
+
/**
|
|
20
|
+
* Function to deploy our L1 contracts to the sandbox L1
|
|
21
|
+
* @param aztecNodeConfig - The Aztec Node Config
|
|
22
|
+
* @param hdAccount - Account for publishing L1 contracts
|
|
23
|
+
*/ export async function deployContractsToL1(aztecNodeConfig, hdAccount, contractDeployLogger = logger, opts = {}) {
|
|
24
|
+
const chain = aztecNodeConfig.l1RpcUrl ? createEthereumChain(aztecNodeConfig.l1RpcUrl, aztecNodeConfig.l1ChainId) : {
|
|
25
|
+
chainInfo: localAnvil
|
|
26
|
+
};
|
|
27
|
+
await waitForPublicClient(aztecNodeConfig);
|
|
28
|
+
const l1Contracts = await deployL1Contracts(aztecNodeConfig.l1RpcUrl, hdAccount, chain.chainInfo, contractDeployLogger, {
|
|
29
|
+
...getL1ContractsConfigEnvVars(),
|
|
30
|
+
...aztecNodeConfig,
|
|
31
|
+
l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice,
|
|
32
|
+
vkTreeRoot: await getVKTreeRoot(),
|
|
33
|
+
protocolContractTreeRoot,
|
|
34
|
+
assumeProvenThrough: opts.assumeProvenThroughBlockNumber,
|
|
35
|
+
salt: opts.salt
|
|
36
|
+
});
|
|
37
|
+
aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
|
|
38
|
+
return aztecNodeConfig.l1Contracts;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
42
|
+
* Does not start any HTTP services nor populate any initial accounts.
|
|
43
|
+
* @param config - Optional Sandbox settings.
|
|
44
|
+
*/ export async function createSandbox(config = {}) {
|
|
45
|
+
const aztecNodeConfig = {
|
|
46
|
+
...getConfigEnvVars(),
|
|
47
|
+
...config
|
|
48
|
+
};
|
|
49
|
+
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
50
|
+
if (!aztecNodeConfig.publisherPrivateKey || aztecNodeConfig.publisherPrivateKey === NULL_KEY) {
|
|
51
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
52
|
+
aztecNodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey).toString('hex')}`;
|
|
53
|
+
}
|
|
54
|
+
if (!aztecNodeConfig.validatorPrivateKey || aztecNodeConfig.validatorPrivateKey === NULL_KEY) {
|
|
55
|
+
const privKey = hdAccount.getHdKey().privateKey;
|
|
56
|
+
aztecNodeConfig.validatorPrivateKey = `0x${Buffer.from(privKey).toString('hex')}`;
|
|
57
|
+
}
|
|
58
|
+
let watcher = undefined;
|
|
59
|
+
if (!aztecNodeConfig.p2pEnabled) {
|
|
60
|
+
const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
|
|
61
|
+
assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
|
|
62
|
+
salt: config.l1Salt ? parseInt(config.l1Salt) : undefined
|
|
63
|
+
});
|
|
64
|
+
const chain = aztecNodeConfig.l1RpcUrl ? createEthereumChain(aztecNodeConfig.l1RpcUrl, aztecNodeConfig.l1ChainId) : {
|
|
65
|
+
chainInfo: localAnvil
|
|
66
|
+
};
|
|
67
|
+
const publicClient = createPublicClient({
|
|
68
|
+
chain: chain.chainInfo,
|
|
69
|
+
transport: httpViemTransport(aztecNodeConfig.l1RpcUrl)
|
|
70
|
+
});
|
|
71
|
+
watcher = new AnvilTestWatcher(new EthCheatCodes(aztecNodeConfig.l1RpcUrl), l1ContractAddresses.rollupAddress, publicClient);
|
|
72
|
+
watcher.setIsSandbox(true);
|
|
73
|
+
await watcher.start();
|
|
74
|
+
}
|
|
75
|
+
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
76
|
+
// Create a local blob sink client inside the sandbox, no http connectivity
|
|
77
|
+
const blobSinkClient = createBlobSinkClient();
|
|
78
|
+
const node = await createAztecNode(aztecNodeConfig, {
|
|
79
|
+
telemetry,
|
|
80
|
+
blobSinkClient
|
|
81
|
+
});
|
|
82
|
+
const pxe = await createAztecPXE(node);
|
|
83
|
+
await setupCanonicalL2FeeJuice(new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(aztecNodeConfig.l1ChainId, aztecNodeConfig.version)), aztecNodeConfig.l1Contracts.feeJuicePortalAddress, undefined, logger.info);
|
|
84
|
+
const stop = async ()=>{
|
|
85
|
+
await node.stop();
|
|
86
|
+
await watcher?.stop();
|
|
87
|
+
};
|
|
88
|
+
return {
|
|
89
|
+
node,
|
|
90
|
+
pxe,
|
|
91
|
+
aztecNodeConfig,
|
|
92
|
+
stop
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Create and start a new Aztec RPC HTTP Server
|
|
97
|
+
* @param config - Optional Aztec node settings.
|
|
98
|
+
*/ export async function createAztecNode(config = {}, deps = {}) {
|
|
99
|
+
const aztecNodeConfig = {
|
|
100
|
+
...getConfigEnvVars(),
|
|
101
|
+
...config
|
|
102
|
+
};
|
|
103
|
+
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps);
|
|
104
|
+
return node;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create and start a new Aztec PXE HTTP Server
|
|
108
|
+
* @param config - Optional PXE settings.
|
|
109
|
+
*/ export async function createAztecPXE(node, config = {}) {
|
|
110
|
+
const pxeServiceConfig = {
|
|
111
|
+
...getPXEServiceConfig(),
|
|
112
|
+
...config
|
|
113
|
+
};
|
|
114
|
+
const pxe = await createPXEService(node, pxeServiceConfig);
|
|
115
|
+
return pxe;
|
|
116
|
+
}
|
package/dest/splash.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aztec/aztec",
|
|
3
|
+
"version": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./dest/index.js"
|
|
7
|
+
},
|
|
8
|
+
"bin": "./dest/bin/index.js",
|
|
9
|
+
"typedocOptions": {
|
|
10
|
+
"entryPoints": [
|
|
11
|
+
"./src/index.ts"
|
|
12
|
+
],
|
|
13
|
+
"name": "Aztec Packages",
|
|
14
|
+
"tsconfig": "./tsconfig.json"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "yarn clean && tsc -b",
|
|
18
|
+
"start": "node --no-warnings ./dest/bin",
|
|
19
|
+
"start:debug": "node --inspect=0.0.0.0:9221 --no-warnings ./dest/bin",
|
|
20
|
+
"start:sandbox": "ETHEREUM_HOST=http://0.0.0.0:8545/ && yarn start start --sandbox",
|
|
21
|
+
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
22
|
+
"formatting": "run -T prettier --check ./src && run -T eslint ./src",
|
|
23
|
+
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
|
|
24
|
+
"build:dev": "tsc -b --watch",
|
|
25
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}",
|
|
26
|
+
"run:example:token": "LOG_LEVEL='verbose' node ./dest/examples/token.js"
|
|
27
|
+
},
|
|
28
|
+
"inherits": [
|
|
29
|
+
"../package.common.json"
|
|
30
|
+
],
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@aztec/accounts": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
33
|
+
"@aztec/archiver": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
34
|
+
"@aztec/aztec-faucet": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
35
|
+
"@aztec/aztec-node": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
36
|
+
"@aztec/aztec.js": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
37
|
+
"@aztec/bb-prover": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
38
|
+
"@aztec/blob-sink": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
39
|
+
"@aztec/bot": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
40
|
+
"@aztec/builder": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
41
|
+
"@aztec/circuit-types": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
42
|
+
"@aztec/circuits.js": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
43
|
+
"@aztec/cli": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
44
|
+
"@aztec/cli-wallet": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
45
|
+
"@aztec/entrypoints": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
46
|
+
"@aztec/ethereum": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
47
|
+
"@aztec/foundation": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
48
|
+
"@aztec/kv-store": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
49
|
+
"@aztec/noir-contracts.js": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
50
|
+
"@aztec/noir-protocol-circuits-types": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
51
|
+
"@aztec/p2p": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
52
|
+
"@aztec/p2p-bootstrap": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
53
|
+
"@aztec/proof-verifier": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
54
|
+
"@aztec/protocol-contracts": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
55
|
+
"@aztec/prover-client": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
56
|
+
"@aztec/prover-node": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
57
|
+
"@aztec/pxe": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
58
|
+
"@aztec/telemetry-client": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
59
|
+
"@aztec/txe": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
60
|
+
"@aztec/types": "0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2",
|
|
61
|
+
"@types/chalk": "^2.2.0",
|
|
62
|
+
"abitype": "^0.8.11",
|
|
63
|
+
"chalk": "^5.3.0",
|
|
64
|
+
"commander": "^12.1.0",
|
|
65
|
+
"koa": "^2.14.2",
|
|
66
|
+
"koa-router": "^12.0.0",
|
|
67
|
+
"viem": "2.22.8"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"dest",
|
|
71
|
+
"src",
|
|
72
|
+
"!*.test.*"
|
|
73
|
+
],
|
|
74
|
+
"types": "./dest/index.d.ts",
|
|
75
|
+
"devDependencies": {
|
|
76
|
+
"@jest/globals": "^29.5.0",
|
|
77
|
+
"@types/jest": "^29.5.0",
|
|
78
|
+
"@types/koa": "^2.13.6",
|
|
79
|
+
"jest": "^29.5.0",
|
|
80
|
+
"ts-node": "^10.9.1",
|
|
81
|
+
"typescript": "^5.0.4"
|
|
82
|
+
},
|
|
83
|
+
"jest": {
|
|
84
|
+
"moduleNameMapper": {
|
|
85
|
+
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
|
|
86
|
+
},
|
|
87
|
+
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
|
|
88
|
+
"rootDir": "./src",
|
|
89
|
+
"transform": {
|
|
90
|
+
"^.+\\.tsx?$": [
|
|
91
|
+
"@swc/jest",
|
|
92
|
+
{
|
|
93
|
+
"jsc": {
|
|
94
|
+
"parser": {
|
|
95
|
+
"syntax": "typescript",
|
|
96
|
+
"decorators": true
|
|
97
|
+
},
|
|
98
|
+
"transform": {
|
|
99
|
+
"decoratorVersion": "2022-03"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
"extensionsToTreatAsEsm": [
|
|
106
|
+
".ts"
|
|
107
|
+
],
|
|
108
|
+
"reporters": [
|
|
109
|
+
"default"
|
|
110
|
+
],
|
|
111
|
+
"testTimeout": 30000,
|
|
112
|
+
"setupFiles": [
|
|
113
|
+
"../../foundation/src/jest/setup.mjs"
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"engines": {
|
|
117
|
+
"node": ">=18"
|
|
118
|
+
}
|
|
119
|
+
}
|
package/src/bin/index.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
|
|
14
|
+
import { Command } from 'commander';
|
|
15
|
+
import { readFileSync } from 'fs';
|
|
16
|
+
import { dirname, resolve } from 'path';
|
|
17
|
+
|
|
18
|
+
import { injectAztecCommands } from '../cli/index.js';
|
|
19
|
+
|
|
20
|
+
const userLog = createConsoleLogger();
|
|
21
|
+
const debugLogger = createLogger('cli');
|
|
22
|
+
|
|
23
|
+
/** CLI & full node main entrypoint */
|
|
24
|
+
async function main() {
|
|
25
|
+
const shutdown = () => {
|
|
26
|
+
process.exit(0);
|
|
27
|
+
};
|
|
28
|
+
process.once('SIGINT', shutdown);
|
|
29
|
+
process.once('SIGTERM', shutdown);
|
|
30
|
+
|
|
31
|
+
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
|
|
32
|
+
const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
33
|
+
let program = new Command('aztec');
|
|
34
|
+
program.description('Aztec command line interface').version(cliVersion);
|
|
35
|
+
program = injectAztecCommands(program, userLog, debugLogger);
|
|
36
|
+
program = injectBuilderCommands(program);
|
|
37
|
+
program = injectContractCommands(program, userLog, debugLogger);
|
|
38
|
+
program = injectInfrastructureCommands(program, userLog, debugLogger);
|
|
39
|
+
program = injectL1Commands(program, userLog, debugLogger);
|
|
40
|
+
program = injectPXECommands(program, userLog, debugLogger);
|
|
41
|
+
program = injectMiscCommands(program, userLog);
|
|
42
|
+
program = injectDevnetCommands(program, userLog, debugLogger);
|
|
43
|
+
program = injectWalletCommands(program, userLog, debugLogger);
|
|
44
|
+
|
|
45
|
+
await program.parseAsync(process.argv);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
main().catch(err => {
|
|
49
|
+
debugLogger.error(`Error in command execution`);
|
|
50
|
+
debugLogger.error(err + '\n' + err.stack);
|
|
51
|
+
// See https://nodejs.org/api/process.html#processexitcode
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
throw err;
|
|
54
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { deployInitialTestAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { AztecNodeApiSchema, PXESchema } from '@aztec/circuit-types';
|
|
3
|
+
import {
|
|
4
|
+
type NamespacedApiHandlers,
|
|
5
|
+
createNamespacedSafeJsonRpcServer,
|
|
6
|
+
startHttpRpcServer,
|
|
7
|
+
} from '@aztec/foundation/json-rpc/server';
|
|
8
|
+
import { type LogFn, type Logger } from '@aztec/foundation/log';
|
|
9
|
+
import { fileURLToPath } from '@aztec/foundation/url';
|
|
10
|
+
import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
|
|
11
|
+
|
|
12
|
+
import { readFileSync } from 'fs';
|
|
13
|
+
import { dirname, resolve } from 'path';
|
|
14
|
+
|
|
15
|
+
import { createSandbox } from '../sandbox.js';
|
|
16
|
+
import { github, splash } from '../splash.js';
|
|
17
|
+
import { createAccountLogs, extractNamespacedOptions, installSignalHandlers } from './util.js';
|
|
18
|
+
|
|
19
|
+
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
|
|
20
|
+
const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
21
|
+
|
|
22
|
+
export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logger) {
|
|
23
|
+
// list of 'stop' functions to call when process ends
|
|
24
|
+
const signalHandlers: Array<() => Promise<void>> = [];
|
|
25
|
+
const services: NamespacedApiHandlers = {};
|
|
26
|
+
|
|
27
|
+
if (options.sandbox) {
|
|
28
|
+
const sandboxOptions = extractNamespacedOptions(options, 'sandbox');
|
|
29
|
+
const nodeOptions = extractNamespacedOptions(options, 'node');
|
|
30
|
+
userLog(`${splash}\n${github}\n\n`);
|
|
31
|
+
userLog(`Setting up Aztec Sandbox ${cliVersion}, please stand by...`);
|
|
32
|
+
|
|
33
|
+
const { aztecNodeConfig, node, pxe, stop } = await createSandbox({
|
|
34
|
+
l1Mnemonic: options.l1Mnemonic,
|
|
35
|
+
l1RpcUrl: options.l1RpcUrl,
|
|
36
|
+
l1Salt: nodeOptions.deployAztecContractsSalt,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Deploy test accounts by default
|
|
40
|
+
if (sandboxOptions.testAccounts) {
|
|
41
|
+
if (aztecNodeConfig.p2pEnabled) {
|
|
42
|
+
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
43
|
+
} else if (sandboxOptions.noPXE) {
|
|
44
|
+
userLog(`Not setting up test accounts as we are not exposing a PXE`);
|
|
45
|
+
} else {
|
|
46
|
+
userLog('Setting up test accounts...');
|
|
47
|
+
const accounts = await deployInitialTestAccounts(pxe);
|
|
48
|
+
const accLogs = await createAccountLogs(accounts, pxe);
|
|
49
|
+
userLog(accLogs.join(''));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Start Node and PXE JSON-RPC server
|
|
54
|
+
signalHandlers.push(stop);
|
|
55
|
+
services.node = [node, AztecNodeApiSchema];
|
|
56
|
+
if (!sandboxOptions.noPXE) {
|
|
57
|
+
services.pxe = [pxe, PXESchema];
|
|
58
|
+
} else {
|
|
59
|
+
userLog(`Not exposing PXE API through JSON-RPC server`);
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
if (options.node) {
|
|
63
|
+
const { startNode } = await import('./cmds/start_node.js');
|
|
64
|
+
await startNode(options, signalHandlers, services, userLog);
|
|
65
|
+
} else if (options.proofVerifier) {
|
|
66
|
+
const { startProofVerifier } = await import('./cmds/start_proof_verifier.js');
|
|
67
|
+
await startProofVerifier(options, signalHandlers, userLog);
|
|
68
|
+
} else if (options.bot) {
|
|
69
|
+
const { startBot } = await import('./cmds/start_bot.js');
|
|
70
|
+
await startBot(options, signalHandlers, services, userLog);
|
|
71
|
+
} else if (options.proverNode) {
|
|
72
|
+
const { startProverNode } = await import('./cmds/start_prover_node.js');
|
|
73
|
+
await startProverNode(options, signalHandlers, services, userLog);
|
|
74
|
+
} else if (options.pxe) {
|
|
75
|
+
const { startPXE } = await import('./cmds/start_pxe.js');
|
|
76
|
+
await startPXE(options, signalHandlers, services, userLog);
|
|
77
|
+
} else if (options.archiver) {
|
|
78
|
+
const { startArchiver } = await import('./cmds/start_archiver.js');
|
|
79
|
+
await startArchiver(options, signalHandlers, services);
|
|
80
|
+
} else if (options.p2pBootstrap) {
|
|
81
|
+
const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
|
|
82
|
+
await startP2PBootstrap(options, signalHandlers, services, userLog);
|
|
83
|
+
} else if (options.proverAgent) {
|
|
84
|
+
const { startProverAgent } = await import('./cmds/start_prover_agent.js');
|
|
85
|
+
await startProverAgent(options, signalHandlers, services, userLog);
|
|
86
|
+
} else if (options.proverBroker) {
|
|
87
|
+
const { startProverBroker } = await import('./cmds/start_prover_broker.js');
|
|
88
|
+
await startProverBroker(options, signalHandlers, services, userLog);
|
|
89
|
+
} else if (options.txe) {
|
|
90
|
+
const { startTXE } = await import('./cmds/start_txe.js');
|
|
91
|
+
await startTXE(options, debugLogger);
|
|
92
|
+
} else if (options.sequencer) {
|
|
93
|
+
userLog(`Cannot run a standalone sequencer without a node`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
} else if (options.faucet) {
|
|
96
|
+
const { startFaucet } = await import('./cmds/start_faucet.js');
|
|
97
|
+
await startFaucet(options, signalHandlers, services, userLog);
|
|
98
|
+
} else {
|
|
99
|
+
userLog(`No module specified to start`);
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
installSignalHandlers(debugLogger.info, signalHandlers);
|
|
105
|
+
|
|
106
|
+
if (Object.entries(services).length > 0) {
|
|
107
|
+
const rpcServer = createNamespacedSafeJsonRpcServer(services, {
|
|
108
|
+
http200OnError: false,
|
|
109
|
+
log: debugLogger,
|
|
110
|
+
middlewares: [getOtelJsonRpcPropagationMiddleware()],
|
|
111
|
+
});
|
|
112
|
+
const { port } = await startHttpRpcServer(rpcServer, { port: options.port });
|
|
113
|
+
debugLogger.info(`Aztec Server listening on port ${port}`);
|
|
114
|
+
}
|
|
115
|
+
}
|