@aztec/aztec 0.0.0-test.0

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 (122) hide show
  1. package/README.md +57 -0
  2. package/dest/bin/index.d.ts +3 -0
  3. package/dest/bin/index.d.ts.map +1 -0
  4. package/dest/bin/index.js +46 -0
  5. package/dest/cli/aztec_start_action.d.ts +3 -0
  6. package/dest/cli/aztec_start_action.d.ts.map +1 -0
  7. package/dest/cli/aztec_start_action.js +108 -0
  8. package/dest/cli/aztec_start_options.d.ts +15 -0
  9. package/dest/cli/aztec_start_options.d.ts.map +1 -0
  10. package/dest/cli/aztec_start_options.js +348 -0
  11. package/dest/cli/chain_l2_config.d.ts +19 -0
  12. package/dest/cli/chain_l2_config.d.ts.map +1 -0
  13. package/dest/cli/chain_l2_config.js +56 -0
  14. package/dest/cli/cli.d.ts +9 -0
  15. package/dest/cli/cli.d.ts.map +1 -0
  16. package/dest/cli/cli.js +33 -0
  17. package/dest/cli/cmds/start_archiver.d.ts +9 -0
  18. package/dest/cli/cmds/start_archiver.d.ts.map +1 -0
  19. package/dest/cli/cmds/start_archiver.js +42 -0
  20. package/dest/cli/cmds/start_blob_sink.d.ts +3 -0
  21. package/dest/cli/cmds/start_blob_sink.d.ts.map +1 -0
  22. package/dest/cli/cmds/start_blob_sink.js +17 -0
  23. package/dest/cli/cmds/start_bot.d.ts +11 -0
  24. package/dest/cli/cmds/start_bot.d.ts.map +1 -0
  25. package/dest/cli/cmds/start_bot.js +31 -0
  26. package/dest/cli/cmds/start_faucet.d.ts +4 -0
  27. package/dest/cli/cmds/start_faucet.d.ts.map +1 -0
  28. package/dest/cli/cmds/start_faucet.js +20 -0
  29. package/dest/cli/cmds/start_node.d.ts +7 -0
  30. package/dest/cli/cmds/start_node.d.ts.map +1 -0
  31. package/dest/cli/cmds/start_node.js +131 -0
  32. package/dest/cli/cmds/start_p2p_bootstrap.d.ts +6 -0
  33. package/dest/cli/cmds/start_p2p_bootstrap.d.ts.map +1 -0
  34. package/dest/cli/cmds/start_p2p_bootstrap.js +26 -0
  35. package/dest/cli/cmds/start_prover_agent.d.ts +4 -0
  36. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -0
  37. package/dest/cli/cmds/start_prover_agent.js +41 -0
  38. package/dest/cli/cmds/start_prover_broker.d.ts +9 -0
  39. package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -0
  40. package/dest/cli/cmds/start_prover_broker.js +31 -0
  41. package/dest/cli/cmds/start_prover_node.d.ts +7 -0
  42. package/dest/cli/cmds/start_prover_node.d.ts.map +1 -0
  43. package/dest/cli/cmds/start_prover_node.js +110 -0
  44. package/dest/cli/cmds/start_pxe.d.ts +16 -0
  45. package/dest/cli/cmds/start_pxe.d.ts.map +1 -0
  46. package/dest/cli/cmds/start_pxe.js +95 -0
  47. package/dest/cli/cmds/start_txe.d.ts +3 -0
  48. package/dest/cli/cmds/start_txe.d.ts.map +1 -0
  49. package/dest/cli/cmds/start_txe.js +11 -0
  50. package/dest/cli/get_l1_config.d.ts +7 -0
  51. package/dest/cli/get_l1_config.d.ts.map +1 -0
  52. package/dest/cli/get_l1_config.js +13 -0
  53. package/dest/cli/index.d.ts +2 -0
  54. package/dest/cli/index.d.ts.map +1 -0
  55. package/dest/cli/index.js +1 -0
  56. package/dest/cli/util.d.ts +46 -0
  57. package/dest/cli/util.d.ts.map +1 -0
  58. package/dest/cli/util.js +154 -0
  59. package/dest/cli/versioning.d.ts +4 -0
  60. package/dest/cli/versioning.d.ts.map +1 -0
  61. package/dest/cli/versioning.js +9 -0
  62. package/dest/examples/token.d.ts +2 -0
  63. package/dest/examples/token.d.ts.map +1 -0
  64. package/dest/examples/token.js +46 -0
  65. package/dest/examples/util.d.ts +20 -0
  66. package/dest/examples/util.d.ts.map +1 -0
  67. package/dest/examples/util.js +31 -0
  68. package/dest/index.d.ts +2 -0
  69. package/dest/index.d.ts.map +1 -0
  70. package/dest/index.js +1 -0
  71. package/dest/mnemonic.d.ts +2 -0
  72. package/dest/mnemonic.d.ts.map +1 -0
  73. package/dest/mnemonic.js +1 -0
  74. package/dest/sandbox/banana_fpc.d.ts +11 -0
  75. package/dest/sandbox/banana_fpc.d.ts.map +1 -0
  76. package/dest/sandbox/banana_fpc.js +79 -0
  77. package/dest/sandbox/index.d.ts +5 -0
  78. package/dest/sandbox/index.d.ts.map +1 -0
  79. package/dest/sandbox/index.js +4 -0
  80. package/dest/sandbox/sandbox.d.ts +76 -0
  81. package/dest/sandbox/sandbox.d.ts.map +1 -0
  82. package/dest/sandbox/sandbox.js +181 -0
  83. package/dest/sandbox/sponsored_fee_payment_method.d.ts +23 -0
  84. package/dest/sandbox/sponsored_fee_payment_method.d.ts.map +1 -0
  85. package/dest/sandbox/sponsored_fee_payment_method.js +36 -0
  86. package/dest/sandbox/sponsored_fpc.d.ts +6 -0
  87. package/dest/sandbox/sponsored_fpc.d.ts.map +1 -0
  88. package/dest/sandbox/sponsored_fpc.js +26 -0
  89. package/dest/splash.d.ts +3 -0
  90. package/dest/splash.d.ts.map +1 -0
  91. package/dest/splash.js +2 -0
  92. package/package.json +118 -0
  93. package/src/bin/index.ts +54 -0
  94. package/src/cli/aztec_start_action.ts +114 -0
  95. package/src/cli/aztec_start_options.ts +371 -0
  96. package/src/cli/chain_l2_config.ts +74 -0
  97. package/src/cli/cli.ts +48 -0
  98. package/src/cli/cmds/start_archiver.ts +55 -0
  99. package/src/cli/cmds/start_blob_sink.ts +31 -0
  100. package/src/cli/cmds/start_bot.ts +49 -0
  101. package/src/cli/cmds/start_faucet.ts +34 -0
  102. package/src/cli/cmds/start_node.ts +151 -0
  103. package/src/cli/cmds/start_p2p_bootstrap.ts +29 -0
  104. package/src/cli/cmds/start_prover_agent.ts +68 -0
  105. package/src/cli/cmds/start_prover_broker.ts +46 -0
  106. package/src/cli/cmds/start_prover_node.ts +121 -0
  107. package/src/cli/cmds/start_pxe.ts +129 -0
  108. package/src/cli/cmds/start_txe.ts +15 -0
  109. package/src/cli/get_l1_config.ts +18 -0
  110. package/src/cli/index.ts +1 -0
  111. package/src/cli/util.ts +216 -0
  112. package/src/cli/versioning.ts +13 -0
  113. package/src/examples/token.ts +65 -0
  114. package/src/examples/util.ts +45 -0
  115. package/src/index.ts +7 -0
  116. package/src/mnemonic.ts +1 -0
  117. package/src/sandbox/banana_fpc.ts +83 -0
  118. package/src/sandbox/index.ts +5 -0
  119. package/src/sandbox/sandbox.ts +229 -0
  120. package/src/sandbox/sponsored_fee_payment_method.ts +46 -0
  121. package/src/sandbox/sponsored_fpc.ts +38 -0
  122. package/src/splash.ts +10 -0
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env -S node --no-warnings
2
+ import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
3
+ import { type BlobSinkClientInterface } from '@aztec/blob-sink/client';
4
+ import { Fr } from '@aztec/foundation/fields';
5
+ import { type LogFn } from '@aztec/foundation/log';
6
+ import { type PXEServiceConfig } from '@aztec/pxe/server';
7
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
8
+ import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
9
+ import { type TelemetryClient } from '@aztec/telemetry-client';
10
+ import { type HDAccount, type PrivateKeyAccount } from 'viem';
11
+ /**
12
+ * Function to deploy our L1 contracts to the sandbox L1
13
+ * @param aztecNodeConfig - The Aztec Node Config
14
+ * @param hdAccount - Account for publishing L1 contracts
15
+ */
16
+ export declare function deployContractsToL1(aztecNodeConfig: AztecNodeConfig, hdAccount: HDAccount | PrivateKeyAccount, contractDeployLogger?: import("@aztec/aztec.js").Logger, opts?: {
17
+ assumeProvenThroughBlockNumber?: number;
18
+ salt?: number;
19
+ genesisArchiveRoot?: Fr;
20
+ genesisBlockHash?: Fr;
21
+ }): Promise<{
22
+ rollupAddress: import("@aztec/aztec.js").EthAddress;
23
+ registryAddress: import("@aztec/aztec.js").EthAddress;
24
+ inboxAddress: import("@aztec/aztec.js").EthAddress;
25
+ outboxAddress: import("@aztec/aztec.js").EthAddress;
26
+ feeJuiceAddress: import("@aztec/aztec.js").EthAddress;
27
+ feeJuicePortalAddress: import("@aztec/aztec.js").EthAddress;
28
+ coinIssuerAddress: import("@aztec/aztec.js").EthAddress;
29
+ rewardDistributorAddress: import("@aztec/aztec.js").EthAddress;
30
+ governanceProposerAddress: import("@aztec/aztec.js").EthAddress;
31
+ governanceAddress: import("@aztec/aztec.js").EthAddress;
32
+ stakingAssetAddress: import("@aztec/aztec.js").EthAddress;
33
+ } & {
34
+ slashFactoryAddress?: import("@aztec/aztec.js").EthAddress | undefined;
35
+ } & {
36
+ rollupAddress: import("@aztec/aztec.js").EthAddress;
37
+ } & {
38
+ rollupAddress: import("@aztec/aztec.js").EthAddress;
39
+ }>;
40
+ /** Sandbox settings. */
41
+ export type SandboxConfig = AztecNodeConfig & {
42
+ /** Mnemonic used to derive the L1 deployer private key.*/
43
+ l1Mnemonic: string;
44
+ /** Salt used to deploy L1 contracts.*/
45
+ l1Salt: string;
46
+ /** Whether to expose PXE service on sandbox start.*/
47
+ noPXE: boolean;
48
+ /** Whether to deploy test accounts on sandbox start.*/
49
+ testAccounts: boolean;
50
+ };
51
+ /**
52
+ * Create and start a new Aztec Node and PXE. Deploys L1 contracts.
53
+ * Does not start any HTTP services nor populate any initial accounts.
54
+ * @param config - Optional Sandbox settings.
55
+ */
56
+ export declare function createSandbox(config: Partial<SandboxConfig> | undefined, userLog: LogFn): Promise<{
57
+ node: AztecNodeService;
58
+ pxe: import("@aztec/pxe/server").PXEService;
59
+ stop: () => Promise<void>;
60
+ }>;
61
+ /**
62
+ * Create and start a new Aztec RPC HTTP Server
63
+ * @param config - Optional Aztec node settings.
64
+ */
65
+ export declare function createAztecNode(config?: Partial<AztecNodeConfig>, deps?: {
66
+ telemetry?: TelemetryClient;
67
+ blobSinkClient?: BlobSinkClientInterface;
68
+ }, options?: {
69
+ prefilledPublicData?: PublicDataTreeLeaf[];
70
+ }): Promise<AztecNodeService>;
71
+ /**
72
+ * Create and start a new Aztec PXE HTTP Server
73
+ * @param config - Optional PXE settings.
74
+ */
75
+ export declare function createAztecPXE(node: AztecNode, config?: Partial<PXEServiceConfig>): Promise<import("@aztec/pxe/server").PXEService>;
76
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../../src/sandbox/sandbox.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,KAAK,eAAe,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AAE7F,OAAO,EAAE,KAAK,uBAAuB,EAAwB,MAAM,yBAAyB,CAAC;AAU7F,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,KAAK,EAAgB,MAAM,uBAAuB,CAAC;AAGjE,OAAO,EAAE,KAAK,gBAAgB,EAAyC,MAAM,mBAAmB,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EACL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAA2D,MAAM,MAAM,CAAC;AAavH;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,SAAS,GAAG,iBAAiB,EACxC,oBAAoB,mCAAS,EAC7B,IAAI,GAAE;IAAE,8BAA8B,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,EAAE,CAAC;IAAC,gBAAgB,CAAC,EAAE,EAAE,CAAA;CAAO;;;;;;;;;;;;;;;;;;GA6BtH;AAED,wBAAwB;AACxB,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG;IAC5C,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,uDAAuD;IACvD,YAAY,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,MAAM,oCAA6B,EAAE,OAAO,EAAE,KAAK;;;;GAkGtF;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACnC,MAAM,GAAE,OAAO,CAAC,eAAe,CAAM,EACrC,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,eAAe,CAAC;IAAC,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAO,EACpF,OAAO,GAAE;IAAE,mBAAmB,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAAO,6BAY7D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,GAAE,OAAO,CAAC,gBAAgB,CAAM,mDAI3F"}
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env -S node --no-warnings
2
+ import { getSchnorrWallet } from '@aztec/accounts/schnorr';
3
+ import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
4
+ import { AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
+ import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet } from '@aztec/aztec.js';
6
+ import { createBlobSinkClient } from '@aztec/blob-sink/client';
7
+ import { setupCanonicalL2FeeJuice } from '@aztec/cli/setup-contracts';
8
+ import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
9
+ import { NULL_KEY, createEthereumChain, deployL1Contracts, getL1ContractsConfigEnvVars, waitForPublicClient } from '@aztec/ethereum';
10
+ import { Fr } from '@aztec/foundation/fields';
11
+ import { createLogger } from '@aztec/foundation/log';
12
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
13
+ import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
14
+ import { createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
15
+ import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
16
+ import { getGenesisValues } from '@aztec/world-state/testing';
17
+ import { createPublicClient, fallback, http as httpViemTransport } from 'viem';
18
+ import { mnemonicToAccount } from 'viem/accounts';
19
+ import { foundry } from 'viem/chains';
20
+ import { createAccountLogs } from '../cli/util.js';
21
+ import { DefaultMnemonic } from '../mnemonic.js';
22
+ import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
23
+ import { getSponsoredFPCAddress, setupSponsoredFPC } from './sponsored_fpc.js';
24
+ const logger = createLogger('sandbox');
25
+ const localAnvil = foundry;
26
+ /**
27
+ * Function to deploy our L1 contracts to the sandbox L1
28
+ * @param aztecNodeConfig - The Aztec Node Config
29
+ * @param hdAccount - Account for publishing L1 contracts
30
+ */ export async function deployContractsToL1(aztecNodeConfig, hdAccount, contractDeployLogger = logger, opts = {}) {
31
+ const chain = aztecNodeConfig.l1RpcUrls.length > 0 ? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId) : {
32
+ chainInfo: localAnvil
33
+ };
34
+ await waitForPublicClient(aztecNodeConfig);
35
+ const l1Contracts = await deployL1Contracts(aztecNodeConfig.l1RpcUrls, hdAccount, chain.chainInfo, contractDeployLogger, {
36
+ ...getL1ContractsConfigEnvVars(),
37
+ ...aztecNodeConfig,
38
+ l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
39
+ vkTreeRoot: getVKTreeRoot(),
40
+ protocolContractTreeRoot,
41
+ genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
42
+ genesisBlockHash: opts.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
43
+ salt: opts.salt
44
+ });
45
+ aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
46
+ return aztecNodeConfig.l1Contracts;
47
+ }
48
+ /**
49
+ * Create and start a new Aztec Node and PXE. Deploys L1 contracts.
50
+ * Does not start any HTTP services nor populate any initial accounts.
51
+ * @param config - Optional Sandbox settings.
52
+ */ export async function createSandbox(config = {}, userLog) {
53
+ // sandbox is meant for test envs. We should only need one l1RpcUrl
54
+ const l1RpcUrl = config.l1RpcUrls?.[0];
55
+ if (!l1RpcUrl) {
56
+ throw new Error('An L1 RPC URL is required');
57
+ }
58
+ if ((config.l1RpcUrls?.length || 0) > 1) {
59
+ logger.warn(`Multiple L1 RPC URLs provided. Sandbox will only use the first one: ${l1RpcUrl}`);
60
+ }
61
+ const aztecNodeConfig = {
62
+ ...getConfigEnvVars(),
63
+ ...config
64
+ };
65
+ const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
66
+ if (!aztecNodeConfig.publisherPrivateKey || aztecNodeConfig.publisherPrivateKey === NULL_KEY) {
67
+ const privKey = hdAccount.getHdKey().privateKey;
68
+ aztecNodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey).toString('hex')}`;
69
+ }
70
+ if (!aztecNodeConfig.validatorPrivateKey || aztecNodeConfig.validatorPrivateKey === NULL_KEY) {
71
+ const privKey = hdAccount.getHdKey().privateKey;
72
+ aztecNodeConfig.validatorPrivateKey = `0x${Buffer.from(privKey).toString('hex')}`;
73
+ }
74
+ const initialAccounts = await (async ()=>{
75
+ if (config.testAccounts) {
76
+ if (aztecNodeConfig.p2pEnabled) {
77
+ userLog(`Not setting up test accounts as we are connecting to a network`);
78
+ } else if (config.noPXE) {
79
+ userLog(`Not setting up test accounts as we are not exposing a PXE`);
80
+ } else {
81
+ return await getInitialTestAccounts();
82
+ }
83
+ }
84
+ return [];
85
+ })();
86
+ const bananaFPC = await getBananaFPCAddress(initialAccounts);
87
+ const sponsoredFPC = await getSponsoredFPCAddress();
88
+ const fundedAddresses = initialAccounts.length ? [
89
+ ...initialAccounts.map((a)=>a.address),
90
+ bananaFPC,
91
+ sponsoredFPC
92
+ ] : [];
93
+ const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(fundedAddresses);
94
+ let watcher = undefined;
95
+ if (!aztecNodeConfig.p2pEnabled) {
96
+ const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
97
+ assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
98
+ genesisArchiveRoot,
99
+ genesisBlockHash,
100
+ salt: config.l1Salt ? parseInt(config.l1Salt) : undefined
101
+ });
102
+ const chain = aztecNodeConfig.l1RpcUrls.length > 0 ? createEthereumChain([
103
+ l1RpcUrl
104
+ ], aztecNodeConfig.l1ChainId) : {
105
+ chainInfo: localAnvil
106
+ };
107
+ const publicClient = createPublicClient({
108
+ chain: chain.chainInfo,
109
+ transport: fallback([
110
+ httpViemTransport(l1RpcUrl)
111
+ ])
112
+ });
113
+ watcher = new AnvilTestWatcher(new EthCheatCodes([
114
+ l1RpcUrl
115
+ ]), l1ContractAddresses.rollupAddress, publicClient);
116
+ watcher.setIsSandbox(true);
117
+ await watcher.start();
118
+ }
119
+ const telemetry = initTelemetryClient(getTelemetryClientConfig());
120
+ // Create a local blob sink client inside the sandbox, no http connectivity
121
+ const blobSinkClient = createBlobSinkClient();
122
+ const node = await createAztecNode(aztecNodeConfig, {
123
+ telemetry,
124
+ blobSinkClient
125
+ }, {
126
+ prefilledPublicData
127
+ });
128
+ const pxe = await createAztecPXE(node);
129
+ await setupCanonicalL2FeeJuice(new SignerlessWallet(pxe), aztecNodeConfig.l1Contracts.feeJuicePortalAddress, undefined, logger.info);
130
+ if (initialAccounts.length) {
131
+ userLog('Setting up funded test accounts...');
132
+ const accounts = await deployFundedSchnorrAccounts(pxe, initialAccounts);
133
+ const accountsWithSecrets = accounts.map((account, i)=>({
134
+ account,
135
+ secretKey: initialAccounts[i].secret
136
+ }));
137
+ const accLogs = await createAccountLogs(accountsWithSecrets, pxe);
138
+ userLog(accLogs.join(''));
139
+ const deployer = await getSchnorrWallet(pxe, initialAccounts[0].address, initialAccounts[0].signingKey);
140
+ await setupBananaFPC(initialAccounts, deployer, userLog);
141
+ await setupSponsoredFPC(deployer, userLog);
142
+ }
143
+ const stop = async ()=>{
144
+ await node.stop();
145
+ await watcher?.stop();
146
+ };
147
+ return {
148
+ node,
149
+ pxe,
150
+ stop
151
+ };
152
+ }
153
+ /**
154
+ * Create and start a new Aztec RPC HTTP Server
155
+ * @param config - Optional Aztec node settings.
156
+ */ export async function createAztecNode(config = {}, deps = {}, options = {}) {
157
+ // TODO(#12272): will clean this up. This is criminal.
158
+ const { l1Contracts, ...rest } = getConfigEnvVars();
159
+ const aztecNodeConfig = {
160
+ ...rest,
161
+ ...config,
162
+ l1Contracts: {
163
+ ...l1Contracts,
164
+ ...config.l1Contracts
165
+ }
166
+ };
167
+ logger.info('createAztecNode', aztecNodeConfig);
168
+ const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
169
+ return node;
170
+ }
171
+ /**
172
+ * Create and start a new Aztec PXE HTTP Server
173
+ * @param config - Optional PXE settings.
174
+ */ export async function createAztecPXE(node, config = {}) {
175
+ const pxeServiceConfig = {
176
+ ...getPXEServiceConfig(),
177
+ ...config
178
+ };
179
+ const pxe = await createPXEService(node, pxeServiceConfig);
180
+ return pxe;
181
+ }
@@ -0,0 +1,23 @@
1
+ import type { FeePaymentMethod } from '@aztec/aztec.js';
2
+ import { type FunctionCall } from '@aztec/stdlib/abi';
3
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import type { PXE } from '@aztec/stdlib/interfaces/client';
5
+ /**
6
+ * A payment method that uses the SponsoredFPCContract to pay the fee unconditionally.
7
+ */
8
+ export declare class SponsoredFeePaymentMethod implements FeePaymentMethod {
9
+ /**
10
+ * Contract which will pay the fee.
11
+ */
12
+ private paymentContract;
13
+ constructor(
14
+ /**
15
+ * Contract which will pay the fee.
16
+ */
17
+ paymentContract: AztecAddress);
18
+ static new(pxe: PXE): Promise<SponsoredFeePaymentMethod>;
19
+ getAsset(): Promise<AztecAddress>;
20
+ getFeePayer(): Promise<AztecAddress>;
21
+ getFunctionCalls(): Promise<FunctionCall[]>;
22
+ }
23
+ //# sourceMappingURL=sponsored_fee_payment_method.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sponsored_fee_payment_method.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fee_payment_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,KAAK,YAAY,EAAkC,MAAM,mBAAmB,CAAC;AACtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAI3D;;GAEG;AACH,qBAAa,yBAA0B,YAAW,gBAAgB;IAE9D;;OAEG;IACH,OAAO,CAAC,eAAe;;IAHvB;;OAEG;IACK,eAAe,EAAE,YAAY;WAG1B,GAAG,CAAC,GAAG,EAAE,GAAG;IAKzB,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC;IAIjC,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;IAI9B,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;CAalD"}
@@ -0,0 +1,36 @@
1
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
3
+ import { getDeployedSponsoredFPCAddress } from './sponsored_fpc.js';
4
+ /**
5
+ * A payment method that uses the SponsoredFPCContract to pay the fee unconditionally.
6
+ */ export class SponsoredFeePaymentMethod {
7
+ paymentContract;
8
+ constructor(/**
9
+ * Contract which will pay the fee.
10
+ */ paymentContract){
11
+ this.paymentContract = paymentContract;
12
+ }
13
+ static async new(pxe) {
14
+ const sponsoredFPC = await getDeployedSponsoredFPCAddress(pxe);
15
+ return new SponsoredFeePaymentMethod(sponsoredFPC);
16
+ }
17
+ getAsset() {
18
+ return Promise.resolve(ProtocolContractAddress.FeeJuice);
19
+ }
20
+ getFeePayer() {
21
+ return Promise.resolve(this.paymentContract);
22
+ }
23
+ async getFunctionCalls() {
24
+ return [
25
+ {
26
+ name: 'sponsor_unconditionally',
27
+ to: this.paymentContract,
28
+ selector: await FunctionSelector.fromSignature('sponsor_unconditionally()'),
29
+ type: FunctionType.PRIVATE,
30
+ isStatic: false,
31
+ args: [],
32
+ returnTypes: []
33
+ }
34
+ ];
35
+ }
36
+ }
@@ -0,0 +1,6 @@
1
+ import { type PXE, type Wallet } from '@aztec/aztec.js';
2
+ import type { LogFn } from '@aztec/foundation/log';
3
+ export declare function getSponsoredFPCAddress(): Promise<import("@aztec/aztec.js").AztecAddress>;
4
+ export declare function setupSponsoredFPC(deployer: Wallet, log: LogFn): Promise<void>;
5
+ export declare function getDeployedSponsoredFPCAddress(pxe: PXE): Promise<import("@aztec/aztec.js").AztecAddress>;
6
+ //# sourceMappingURL=sponsored_fpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sponsored_fpc.d.ts","sourceRoot":"","sources":["../../src/sandbox/sponsored_fpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,MAAM,EAEZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAWnD,wBAAsB,sBAAsB,oDAE3C;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,iBAMnE;AAED,wBAAsB,8BAA8B,CAAC,GAAG,EAAE,GAAG,mDAO5D"}
@@ -0,0 +1,26 @@
1
+ import { Fr, getContractInstanceFromDeployParams } from '@aztec/aztec.js';
2
+ import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
3
+ const SPONSORED_FPC_SALT = new Fr(0);
4
+ async function getSponsoredFPCInstance() {
5
+ return await getContractInstanceFromDeployParams(SponsoredFPCContract.artifact, {
6
+ salt: SPONSORED_FPC_SALT
7
+ });
8
+ }
9
+ export async function getSponsoredFPCAddress() {
10
+ return (await getSponsoredFPCInstance()).address;
11
+ }
12
+ export async function setupSponsoredFPC(deployer, log) {
13
+ const deployed = await SponsoredFPCContract.deploy(deployer).send({
14
+ contractAddressSalt: SPONSORED_FPC_SALT,
15
+ universalDeploy: true
16
+ }).deployed();
17
+ log(`SponsoredFPC: ${deployed.address}`);
18
+ }
19
+ export async function getDeployedSponsoredFPCAddress(pxe) {
20
+ const fpc = await getSponsoredFPCAddress();
21
+ const contracts = await pxe.getContracts();
22
+ if (!contracts.find((c)=>c.equals(fpc))) {
23
+ throw new Error('SponsoredFPC not deployed.');
24
+ }
25
+ return fpc;
26
+ }
@@ -0,0 +1,3 @@
1
+ export declare const splash: string;
2
+ export declare const github = "https://github.com/AztecProtocol";
3
+ //# sourceMappingURL=splash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splash.d.ts","sourceRoot":"","sources":["../src/splash.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM,EAAE,MAOkB,CAAC;AAExC,eAAO,MAAM,MAAM,qCAAqC,CAAC"}
package/dest/splash.js ADDED
@@ -0,0 +1,2 @@
1
+ export const splash = '\n' + ' _\n' + ' /\\ | |\n' + ' / \\ ___| |_ ___ ___ \n' + ' / /\\ \\ |_ / __/ _ \\/ __|\n' + ' / ____ \\ / /| || __/ (__ \n' + '/_/___ \\_\\/___|\\__\\___|\\___|\n';
2
+ export const github = 'https://github.com/AztecProtocol';
package/package.json ADDED
@@ -0,0 +1,118 @@
1
+ {
2
+ "name": "@aztec/aztec",
3
+ "version": "0.0.0-test.0",
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_HOSTS=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.0.0-test.0",
33
+ "@aztec/archiver": "0.0.0-test.0",
34
+ "@aztec/aztec-faucet": "0.0.0-test.0",
35
+ "@aztec/aztec-node": "0.0.0-test.0",
36
+ "@aztec/aztec.js": "0.0.0-test.0",
37
+ "@aztec/bb-prover": "0.0.0-test.0",
38
+ "@aztec/blob-sink": "0.0.0-test.0",
39
+ "@aztec/bot": "0.0.0-test.0",
40
+ "@aztec/builder": "0.0.0-test.0",
41
+ "@aztec/cli": "0.0.0-test.0",
42
+ "@aztec/cli-wallet": "0.0.0-test.0",
43
+ "@aztec/constants": "0.0.0-test.0",
44
+ "@aztec/entrypoints": "0.0.0-test.0",
45
+ "@aztec/ethereum": "0.0.0-test.0",
46
+ "@aztec/foundation": "0.0.0-test.0",
47
+ "@aztec/kv-store": "0.0.0-test.0",
48
+ "@aztec/noir-contracts.js": "0.0.0-test.0",
49
+ "@aztec/noir-protocol-circuits-types": "0.0.0-test.0",
50
+ "@aztec/p2p": "0.0.0-test.0",
51
+ "@aztec/p2p-bootstrap": "0.0.0-test.0",
52
+ "@aztec/protocol-contracts": "0.0.0-test.0",
53
+ "@aztec/prover-client": "0.0.0-test.0",
54
+ "@aztec/prover-node": "0.0.0-test.0",
55
+ "@aztec/pxe": "0.0.0-test.0",
56
+ "@aztec/stdlib": "0.0.0-test.0",
57
+ "@aztec/telemetry-client": "0.0.0-test.0",
58
+ "@aztec/txe": "0.0.0-test.0",
59
+ "@aztec/world-state": "0.0.0-test.0",
60
+ "@types/chalk": "^2.2.0",
61
+ "abitype": "^0.8.11",
62
+ "chalk": "^5.3.0",
63
+ "commander": "^12.1.0",
64
+ "koa": "^2.14.2",
65
+ "koa-router": "^12.0.0",
66
+ "viem": "2.22.8"
67
+ },
68
+ "files": [
69
+ "dest",
70
+ "src",
71
+ "!*.test.*"
72
+ ],
73
+ "types": "./dest/index.d.ts",
74
+ "devDependencies": {
75
+ "@jest/globals": "^29.5.0",
76
+ "@types/jest": "^29.5.0",
77
+ "@types/koa": "^2.13.6",
78
+ "jest": "^29.5.0",
79
+ "ts-node": "^10.9.1",
80
+ "typescript": "^5.0.4"
81
+ },
82
+ "jest": {
83
+ "moduleNameMapper": {
84
+ "^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
85
+ },
86
+ "testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
87
+ "rootDir": "./src",
88
+ "transform": {
89
+ "^.+\\.tsx?$": [
90
+ "@swc/jest",
91
+ {
92
+ "jsc": {
93
+ "parser": {
94
+ "syntax": "typescript",
95
+ "decorators": true
96
+ },
97
+ "transform": {
98
+ "decoratorVersion": "2022-03"
99
+ }
100
+ }
101
+ }
102
+ ]
103
+ },
104
+ "extensionsToTreatAsEsm": [
105
+ ".ts"
106
+ ],
107
+ "reporters": [
108
+ "default"
109
+ ],
110
+ "testTimeout": 120000,
111
+ "setupFiles": [
112
+ "../../foundation/src/jest/setup.mjs"
113
+ ]
114
+ },
115
+ "engines": {
116
+ "node": ">=18"
117
+ }
118
+ }
@@ -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,114 @@
1
+ import {
2
+ type NamespacedApiHandlers,
3
+ createNamespacedSafeJsonRpcServer,
4
+ startHttpRpcServer,
5
+ } from '@aztec/foundation/json-rpc/server';
6
+ import type { LogFn, Logger } from '@aztec/foundation/log';
7
+ import { fileURLToPath } from '@aztec/foundation/url';
8
+ import type { ChainConfig } from '@aztec/stdlib/config';
9
+ import { AztecNodeApiSchema, PXESchema } from '@aztec/stdlib/interfaces/client';
10
+ import { getVersioningMiddleware } from '@aztec/stdlib/versioning';
11
+ import { getOtelJsonRpcPropagationMiddleware } from '@aztec/telemetry-client';
12
+
13
+ import { readFileSync } from 'fs';
14
+ import { dirname, resolve } from 'path';
15
+
16
+ import { createSandbox } from '../sandbox/index.js';
17
+ import { github, splash } from '../splash.js';
18
+ import { enrichEnvironmentWithChainConfig } from './chain_l2_config.js';
19
+ import { extractNamespacedOptions, installSignalHandlers } from './util.js';
20
+ import { getVersions } from './versioning.js';
21
+
22
+ const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
23
+ const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
24
+
25
+ export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logger) {
26
+ // list of 'stop' functions to call when process ends
27
+ const signalHandlers: Array<() => Promise<void>> = [];
28
+ const services: NamespacedApiHandlers = {};
29
+ let config: ChainConfig | undefined = undefined;
30
+
31
+ if (options.sandbox) {
32
+ const sandboxOptions = extractNamespacedOptions(options, 'sandbox');
33
+ const nodeOptions = extractNamespacedOptions(options, 'node');
34
+ userLog(`${splash}\n${github}\n\n`);
35
+ userLog(`Setting up Aztec Sandbox ${cliVersion}, please stand by...`);
36
+
37
+ const { node, pxe, stop } = await createSandbox(
38
+ {
39
+ l1Mnemonic: options.l1Mnemonic,
40
+ l1RpcUrls: options.l1RpcUrls,
41
+ l1Salt: nodeOptions.deployAztecContractsSalt,
42
+ noPXE: sandboxOptions.noPXE,
43
+ testAccounts: sandboxOptions.testAccounts,
44
+ },
45
+ userLog,
46
+ );
47
+
48
+ // Start Node and PXE JSON-RPC server
49
+ signalHandlers.push(stop);
50
+ services.node = [node, AztecNodeApiSchema];
51
+ if (!sandboxOptions.noPXE) {
52
+ services.pxe = [pxe, PXESchema];
53
+ } else {
54
+ userLog(`Not exposing PXE API through JSON-RPC server`);
55
+ }
56
+ } else {
57
+ // If a network is specified, enrich the environment with the chain config
58
+ if (options.network) {
59
+ await enrichEnvironmentWithChainConfig(options.network);
60
+ }
61
+ if (options.node) {
62
+ const { startNode } = await import('./cmds/start_node.js');
63
+ ({ config } = await startNode(options, signalHandlers, services, userLog));
64
+ } else if (options.bot) {
65
+ const { startBot } = await import('./cmds/start_bot.js');
66
+ await startBot(options, signalHandlers, services, userLog);
67
+ } else if (options.proverNode) {
68
+ const { startProverNode } = await import('./cmds/start_prover_node.js');
69
+ ({ config } = await startProverNode(options, signalHandlers, services, userLog));
70
+ } else if (options.blobSink) {
71
+ const { startBlobSink } = await import('./cmds/start_blob_sink.js');
72
+ await startBlobSink(options, signalHandlers, userLog);
73
+ } else if (options.pxe) {
74
+ const { startPXE } = await import('./cmds/start_pxe.js');
75
+ ({ config } = await startPXE(options, signalHandlers, services, userLog));
76
+ } else if (options.archiver) {
77
+ const { startArchiver } = await import('./cmds/start_archiver.js');
78
+ ({ config } = await startArchiver(options, signalHandlers, services));
79
+ } else if (options.p2pBootstrap) {
80
+ const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js');
81
+ ({ config } = await startP2PBootstrap(options, signalHandlers, services, userLog));
82
+ } else if (options.proverAgent) {
83
+ const { startProverAgent } = await import('./cmds/start_prover_agent.js');
84
+ await startProverAgent(options, signalHandlers, services, userLog);
85
+ } else if (options.proverBroker) {
86
+ const { startProverBroker } = await import('./cmds/start_prover_broker.js');
87
+ await startProverBroker(options, signalHandlers, services, userLog);
88
+ } else if (options.txe) {
89
+ const { startTXE } = await import('./cmds/start_txe.js');
90
+ await startTXE(options, debugLogger);
91
+ } else if (options.sequencer) {
92
+ userLog(`Cannot run a standalone sequencer without a node`);
93
+ process.exit(1);
94
+ } else if (options.faucet) {
95
+ const { startFaucet } = await import('./cmds/start_faucet.js');
96
+ await startFaucet(options, signalHandlers, services, userLog);
97
+ } else {
98
+ userLog(`No module specified to start`);
99
+ process.exit(1);
100
+ }
101
+ }
102
+
103
+ installSignalHandlers(debugLogger.info, signalHandlers);
104
+ const versions = getVersions(config);
105
+ if (Object.entries(services).length > 0) {
106
+ const rpcServer = createNamespacedSafeJsonRpcServer(services, {
107
+ http200OnError: false,
108
+ log: debugLogger,
109
+ middlewares: [getOtelJsonRpcPropagationMiddleware(), getVersioningMiddleware(versions)],
110
+ });
111
+ const { port } = await startHttpRpcServer(rpcServer, { port: options.port });
112
+ debugLogger.info(`Aztec Server listening on port ${port}`, versions);
113
+ }
114
+ }