@aztec/aztec 3.0.0-canary.a9708bd → 3.0.0-devnet.3
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/dest/bin/index.js +7 -9
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +2 -17
- package/dest/cli/aztec_start_options.d.ts +1 -1
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +105 -225
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +3 -3
- package/dest/cli/cmds/start_blob_sink.d.ts.map +1 -1
- package/dest/cli/cmds/start_blob_sink.js +1 -1
- package/dest/cli/cmds/start_bot.d.ts +3 -6
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +24 -13
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +9 -26
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +10 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +7 -2
- package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_node.js +14 -9
- package/dest/cli/util.d.ts +6 -4
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +10 -10
- package/dest/cli/versioning.js +3 -3
- package/dest/examples/token.js +18 -16
- package/dest/examples/util.d.ts +1 -1
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +1 -1
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/sandbox/banana_fpc.d.ts +4 -5
- package/dest/sandbox/banana_fpc.d.ts.map +1 -1
- package/dest/sandbox/banana_fpc.js +14 -18
- package/dest/sandbox/index.d.ts +2 -2
- package/dest/sandbox/index.d.ts.map +1 -1
- package/dest/sandbox/index.js +2 -2
- package/dest/sandbox/sandbox.d.ts +3 -12
- package/dest/sandbox/sandbox.d.ts.map +1 -1
- package/dest/sandbox/sandbox.js +19 -32
- package/dest/sandbox/sponsored_fpc.d.ts +3 -3
- package/dest/sandbox/sponsored_fpc.d.ts.map +1 -1
- package/dest/sandbox/sponsored_fpc.js +7 -8
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +3 -4
- package/dest/testing/cheat_codes.d.ts +6 -7
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +9 -10
- package/dest/testing/index.d.ts +0 -1
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +0 -1
- package/package.json +34 -33
- package/src/bin/index.ts +7 -9
- package/src/cli/aztec_start_action.ts +2 -14
- package/src/cli/aztec_start_options.ts +113 -232
- package/src/cli/cmds/start_archiver.ts +3 -3
- package/src/cli/cmds/start_blob_sink.ts +1 -1
- package/src/cli/cmds/start_bot.ts +35 -12
- package/src/cli/cmds/start_node.ts +12 -23
- package/src/cli/cmds/start_prover_agent.ts +6 -1
- package/src/cli/cmds/start_prover_broker.ts +16 -2
- package/src/cli/cmds/start_prover_node.ts +11 -11
- package/src/cli/util.ts +17 -14
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +20 -17
- package/src/examples/util.ts +1 -1
- package/src/index.ts +3 -3
- package/src/sandbox/banana_fpc.ts +15 -20
- package/src/sandbox/index.ts +5 -2
- package/src/sandbox/sandbox.ts +21 -32
- package/src/sandbox/sponsored_fpc.ts +8 -10
- package/src/testing/anvil_test_watcher.ts +2 -5
- package/src/testing/cheat_codes.ts +10 -11
- package/src/testing/index.ts +0 -1
- package/dest/cli/chain_l2_config.d.ts +0 -31
- package/dest/cli/chain_l2_config.d.ts.map +0 -1
- package/dest/cli/chain_l2_config.js +0 -261
- package/dest/cli/cmds/start_faucet.d.ts +0 -4
- package/dest/cli/cmds/start_faucet.d.ts.map +0 -1
- package/dest/cli/cmds/start_faucet.js +0 -20
- package/dest/cli/cmds/start_pxe.d.ts +0 -16
- package/dest/cli/cmds/start_pxe.d.ts.map +0 -1
- package/dest/cli/cmds/start_pxe.js +0 -31
- package/dest/cli/get_l1_config.d.ts +0 -7
- package/dest/cli/get_l1_config.d.ts.map +0 -1
- package/dest/cli/get_l1_config.js +0 -13
- package/dest/testing/aztec_cheat_codes.d.ts +0 -59
- package/dest/testing/aztec_cheat_codes.d.ts.map +0 -1
- package/dest/testing/aztec_cheat_codes.js +0 -62
- package/src/cli/chain_l2_config.ts +0 -341
- package/src/cli/cmds/start_faucet.ts +0 -34
- package/src/cli/cmds/start_pxe.ts +0 -49
- package/src/cli/get_l1_config.ts +0 -19
- package/src/testing/aztec_cheat_codes.ts +0 -77
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
2
|
import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node';
|
|
3
|
-
import { Fr } from '@aztec/aztec.js';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
4
|
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
5
|
+
import { getL1Config } from '@aztec/cli/config';
|
|
5
6
|
import { getPublicClient } from '@aztec/ethereum';
|
|
6
7
|
import { SecretValue } from '@aztec/foundation/config';
|
|
7
8
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
8
9
|
import type { LogFn } from '@aztec/foundation/log';
|
|
9
|
-
import {
|
|
10
|
+
import { type CliPXEOptions, type PXEConfig, allPxeConfigMappings } from '@aztec/pxe/config';
|
|
11
|
+
import { AztecNodeAdminApiSchema, AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
|
|
10
12
|
import { P2PApiSchema } from '@aztec/stdlib/interfaces/server';
|
|
11
13
|
import {
|
|
12
14
|
type TelemetryClientConfig,
|
|
13
15
|
initTelemetryClient,
|
|
14
16
|
telemetryClientConfigMappings,
|
|
15
17
|
} from '@aztec/telemetry-client';
|
|
18
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
16
19
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
17
20
|
|
|
18
21
|
import { createAztecNode } from '../../sandbox/index.js';
|
|
19
|
-
import { getL1Config } from '../get_l1_config.js';
|
|
20
22
|
import {
|
|
21
23
|
extractNamespacedOptions,
|
|
22
24
|
extractRelevantOptions,
|
|
@@ -50,7 +52,7 @@ export async function startNode(
|
|
|
50
52
|
|
|
51
53
|
await preloadCrsDataForVerifying(nodeConfig, userLog);
|
|
52
54
|
|
|
53
|
-
const testAccounts = nodeConfig.testAccounts ? (await
|
|
55
|
+
const testAccounts = nodeConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
|
|
54
56
|
const sponsoredFPCAccounts = nodeConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
|
|
55
57
|
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
|
|
56
58
|
|
|
@@ -91,16 +93,6 @@ export async function startNode(
|
|
|
91
93
|
...config,
|
|
92
94
|
};
|
|
93
95
|
|
|
94
|
-
if (!options.archiver) {
|
|
95
|
-
// expect archiver url in node config
|
|
96
|
-
const archiverUrl = nodeConfig.archiverUrl;
|
|
97
|
-
if (!archiverUrl) {
|
|
98
|
-
userLog('Archiver Service URL is required to start Aztec Node without --archiver option');
|
|
99
|
-
throw new Error('Archiver Service URL is required to start Aztec Node without --archiver option');
|
|
100
|
-
}
|
|
101
|
-
nodeConfig.archiverUrl = archiverUrl;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
96
|
if (!options.sequencer) {
|
|
105
97
|
nodeConfig.disableValidator = true;
|
|
106
98
|
} else {
|
|
@@ -138,17 +130,14 @@ export async function startNode(
|
|
|
138
130
|
// Add node stop function to signal handlers
|
|
139
131
|
signalHandlers.push(node.stop.bind(node));
|
|
140
132
|
|
|
141
|
-
// Add a PXE client that connects to this node if requested
|
|
142
|
-
let pxe: PXE | undefined;
|
|
143
|
-
if (options.pxe) {
|
|
144
|
-
const { addPXE } = await import('./start_pxe.js');
|
|
145
|
-
({ pxe } = await addPXE(options, signalHandlers, services, userLog, { node }));
|
|
146
|
-
}
|
|
147
|
-
|
|
148
133
|
// Add a txs bot if requested
|
|
149
134
|
if (options.bot) {
|
|
150
135
|
const { addBot } = await import('./start_bot.js');
|
|
151
|
-
|
|
136
|
+
|
|
137
|
+
const pxeConfig = extractRelevantOptions<PXEConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
|
|
138
|
+
const wallet = await TestWallet.create(node, pxeConfig);
|
|
139
|
+
|
|
140
|
+
await addBot(options, signalHandlers, services, wallet, node, telemetry, undefined);
|
|
152
141
|
}
|
|
153
142
|
|
|
154
143
|
if (nodeConfig.autoUpdate !== 'disabled' && nodeConfig.autoUpdateUrl) {
|
|
@@ -45,7 +45,12 @@ export async function startProverAgent(
|
|
|
45
45
|
|
|
46
46
|
await preloadCrsDataForServerSideProving(config, userLog);
|
|
47
47
|
|
|
48
|
-
const fetch = makeTracedFetch(
|
|
48
|
+
const fetch = makeTracedFetch(
|
|
49
|
+
// retry connections every 3s, up to 30s before giving up
|
|
50
|
+
[1, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],
|
|
51
|
+
false,
|
|
52
|
+
makeUndiciFetch(new Agent({ connections: 10 })),
|
|
53
|
+
);
|
|
49
54
|
const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
|
|
50
55
|
|
|
51
56
|
const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getL1Config } from '@aztec/cli/config';
|
|
2
|
+
import { getPublicClient } from '@aztec/ethereum';
|
|
1
3
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
2
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
3
5
|
import {
|
|
@@ -10,8 +12,7 @@ import { getProverNodeBrokerConfigFromEnv } from '@aztec/prover-node';
|
|
|
10
12
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
11
13
|
import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
12
14
|
|
|
13
|
-
import {
|
|
14
|
-
import { extractRelevantOptions } from '../util.js';
|
|
15
|
+
import { extractRelevantOptions, setupUpdateMonitor } from '../util.js';
|
|
15
16
|
|
|
16
17
|
export async function startProverBroker(
|
|
17
18
|
options: any,
|
|
@@ -33,6 +34,7 @@ export async function startProverBroker(
|
|
|
33
34
|
throw new Error('L1 registry address is required to start Aztec Node without --deploy-aztec-contracts option');
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
const followsCanonicalRollup = typeof config.rollupVersion !== 'number';
|
|
36
38
|
const { addresses, config: rollupConfig } = await getL1Config(
|
|
37
39
|
config.l1Contracts.registryAddress,
|
|
38
40
|
config.l1RpcUrls,
|
|
@@ -45,6 +47,18 @@ export async function startProverBroker(
|
|
|
45
47
|
|
|
46
48
|
const client = initTelemetryClient(getTelemetryClientConfig());
|
|
47
49
|
const broker = await createAndStartProvingBroker(config, client);
|
|
50
|
+
|
|
51
|
+
if (options.autoUpdate !== 'disabled' && options.autoUpdateUrl) {
|
|
52
|
+
await setupUpdateMonitor(
|
|
53
|
+
options.autoUpdate,
|
|
54
|
+
new URL(options.autoUpdateUrl),
|
|
55
|
+
followsCanonicalRollup,
|
|
56
|
+
getPublicClient(config),
|
|
57
|
+
config.l1Contracts.registryAddress,
|
|
58
|
+
signalHandlers,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
services.proverBroker = [broker, ProvingJobBrokerSchema];
|
|
49
63
|
signalHandlers.push(() => broker.stop());
|
|
50
64
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/aztec.js';
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
3
3
|
import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
|
|
4
|
+
import { getL1Config } from '@aztec/cli/config';
|
|
4
5
|
import { getPublicClient } from '@aztec/ethereum';
|
|
5
6
|
import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
|
|
6
7
|
import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
|
|
@@ -16,7 +17,6 @@ import { P2PApiSchema, ProverNodeApiSchema, type ProvingJobBroker } from '@aztec
|
|
|
16
17
|
import { initTelemetryClient, makeTracedFetch, telemetryClientConfigMappings } from '@aztec/telemetry-client';
|
|
17
18
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
18
19
|
|
|
19
|
-
import { getL1Config } from '../get_l1_config.js';
|
|
20
20
|
import { extractRelevantOptions, preloadCrsDataForVerifying, setupUpdateMonitor } from '../util.js';
|
|
21
21
|
import { getVersions } from '../versioning.js';
|
|
22
22
|
import { startProverBroker } from './start_prover_broker.js';
|
|
@@ -37,13 +37,8 @@ export async function startProverNode(
|
|
|
37
37
|
...extractRelevantOptions<ProverNodeConfig>(options, proverNodeConfigMappings, 'proverNode'), // override with command line options
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
if (!options.archiver && !proverConfig.archiverUrl) {
|
|
41
|
-
userLog('--archiver.archiverUrl is required to start a Prover Node without --archiver option');
|
|
42
|
-
process.exit(1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
40
|
if (!proverConfig.l1Contracts.registryAddress || proverConfig.l1Contracts.registryAddress.isZero()) {
|
|
46
|
-
throw new Error('L1 registry address is required to start a Prover Node
|
|
41
|
+
throw new Error('L1 registry address is required to start a Prover Node');
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
const followsCanonicalRollup = typeof proverConfig.rollupVersion !== 'number';
|
|
@@ -57,7 +52,7 @@ export async function startProverNode(
|
|
|
57
52
|
proverConfig.l1Contracts = addresses;
|
|
58
53
|
proverConfig = { ...proverConfig, ...config };
|
|
59
54
|
|
|
60
|
-
const testAccounts = proverConfig.testAccounts ? (await
|
|
55
|
+
const testAccounts = proverConfig.testAccounts ? (await getInitialTestAccountsData()).map(a => a.address) : [];
|
|
61
56
|
const sponsoredFPCAccounts = proverConfig.sponsoredFPC ? [await getSponsoredFPCAddress()] : [];
|
|
62
57
|
const initialFundedAccounts = testAccounts.concat(sponsoredFPCAccounts);
|
|
63
58
|
|
|
@@ -78,7 +73,12 @@ export async function startProverNode(
|
|
|
78
73
|
if (proverConfig.proverBrokerUrl) {
|
|
79
74
|
// at 1TPS we'd enqueue ~1k tube proofs and ~1k AVM proofs immediately
|
|
80
75
|
// set a lower connection limit such that we don't overload the server
|
|
81
|
-
|
|
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
82
|
broker = createProvingJobBrokerClient(proverConfig.proverBrokerUrl, getVersions(proverConfig), fetch);
|
|
83
83
|
} else if (options.proverBroker) {
|
|
84
84
|
({ broker } = await startProverBroker(options, signalHandlers, services, userLog));
|
package/src/cli/util.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import type { AztecNodeConfig } from '@aztec/aztec-node';
|
|
2
|
-
import
|
|
2
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
3
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
4
|
+
import { AccountManager } from '@aztec/aztec.js/wallet';
|
|
3
5
|
import type { ViemClient } from '@aztec/ethereum';
|
|
4
6
|
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
5
7
|
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
6
8
|
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
7
|
-
import type { PXEService } from '@aztec/pxe/server';
|
|
8
9
|
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
|
|
9
10
|
import { UpdateChecker } from '@aztec/stdlib/update-checker';
|
|
10
11
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
12
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
11
13
|
|
|
12
14
|
import chalk from 'chalk';
|
|
13
15
|
import type { Command } from 'commander';
|
|
@@ -67,7 +69,7 @@ export const installSignalHandlers = (logFn: LogFn, cb?: Array<() => Promise<voi
|
|
|
67
69
|
/**
|
|
68
70
|
* Creates logs for the initial accounts
|
|
69
71
|
* @param accounts - The initial accounts
|
|
70
|
-
* @param
|
|
72
|
+
* @param wallet - A TestWallet instance to get the registered accounts
|
|
71
73
|
* @returns A string array containing the initial accounts details
|
|
72
74
|
*/
|
|
73
75
|
export async function createAccountLogs(
|
|
@@ -81,13 +83,13 @@ export async function createAccountLogs(
|
|
|
81
83
|
*/
|
|
82
84
|
secretKey: Fr;
|
|
83
85
|
}[],
|
|
84
|
-
|
|
86
|
+
wallet: TestWallet,
|
|
85
87
|
) {
|
|
86
|
-
const registeredAccounts = await
|
|
88
|
+
const registeredAccounts = await wallet.getAccounts();
|
|
87
89
|
const accountLogStrings = [`Initial Accounts:\n\n`];
|
|
88
90
|
for (const accountWithSecretKey of accountsWithSecretKeys) {
|
|
89
91
|
const completeAddress = await accountWithSecretKey.account.getCompleteAddress();
|
|
90
|
-
if (registeredAccounts.find(a => a.equals(completeAddress))) {
|
|
92
|
+
if (registeredAccounts.find(a => a.item.equals(completeAddress.address))) {
|
|
91
93
|
accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
|
|
92
94
|
accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
|
|
93
95
|
accountLogStrings.push(` Secret Key: ${accountWithSecretKey.secretKey.toString()}\n`);
|
|
@@ -144,8 +146,8 @@ const getDefaultOrEnvValue = (opt: AztecStartOption) => {
|
|
|
144
146
|
let val;
|
|
145
147
|
|
|
146
148
|
// if the option is set in the environment, use that
|
|
147
|
-
if (opt.
|
|
148
|
-
val = process.env[opt.
|
|
149
|
+
if (opt.env) {
|
|
150
|
+
val = process.env[opt.env];
|
|
149
151
|
}
|
|
150
152
|
|
|
151
153
|
// if we have fallback env vars, check those
|
|
@@ -164,7 +166,7 @@ const getDefaultOrEnvValue = (opt: AztecStartOption) => {
|
|
|
164
166
|
return opt.parseVal(val);
|
|
165
167
|
}
|
|
166
168
|
return val;
|
|
167
|
-
} else if (opt.defaultValue) {
|
|
169
|
+
} else if (opt.defaultValue !== undefined) {
|
|
168
170
|
return opt.defaultValue;
|
|
169
171
|
}
|
|
170
172
|
return undefined;
|
|
@@ -175,7 +177,7 @@ export const addOptions = (cmd: Command, options: AztecStartOption[]) => {
|
|
|
175
177
|
options.forEach(opt => {
|
|
176
178
|
cmd.option(
|
|
177
179
|
opt.flag,
|
|
178
|
-
`${opt.description} (default: ${opt.defaultValue}) ($${opt.
|
|
180
|
+
`${opt.description} (default: ${opt.defaultValue}) ($${opt.env})`,
|
|
179
181
|
opt.parseVal ? opt.parseVal : val => val,
|
|
180
182
|
getDefaultOrEnvValue(opt),
|
|
181
183
|
);
|
|
@@ -191,10 +193,11 @@ export const printAztecStartHelpText = () => {
|
|
|
191
193
|
helpTextLines.push('');
|
|
192
194
|
|
|
193
195
|
aztecStartOptions[category].forEach(opt => {
|
|
194
|
-
const defaultValueText =
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
const defaultValueText =
|
|
197
|
+
opt.defaultValue || (Array.isArray(opt.defaultValue) && opt.defaultValue.length > 0)
|
|
198
|
+
? `(default: ${opt.printDefault ? opt.printDefault(opt.defaultValue) : opt.defaultValue})`
|
|
199
|
+
: '';
|
|
200
|
+
const envVarText = opt.env ? `($${opt.env})` : '';
|
|
198
201
|
const flagText = `${opt.flag}`;
|
|
199
202
|
|
|
200
203
|
const paddedText = formatHelpLine(flagText, defaultValueText, envVarText, maxFlagLength, maxDefaultLength);
|
package/src/cli/versioning.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
2
|
-
import {
|
|
2
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
3
3
|
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
4
4
|
import { type ComponentsVersions, getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
|
|
5
5
|
|
|
6
6
|
export function getVersions(config?: ChainConfig): Partial<ComponentsVersions> {
|
|
7
7
|
return config
|
|
8
|
-
? getComponentsVersionsFromConfig(config,
|
|
8
|
+
? getComponentsVersionsFromConfig(config, protocolContractsHash, getVKTreeRoot())
|
|
9
9
|
: {
|
|
10
10
|
l2CircuitsVkTreeRoot: getVKTreeRoot().toString(),
|
|
11
|
-
|
|
11
|
+
l2ProtocolContractsHash: protocolContractsHash.toString(),
|
|
12
12
|
};
|
|
13
13
|
}
|
package/src/examples/token.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import { createAztecNodeClient } from '@aztec/aztec.js/node';
|
|
3
3
|
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
5
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
5
6
|
|
|
6
7
|
const logger = createLogger('example:token');
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
+
const nodeUrl = 'http://localhost:8080';
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
+
const node = createAztecNodeClient(nodeUrl);
|
|
11
12
|
|
|
12
13
|
const ALICE_MINT_BALANCE = 333n;
|
|
13
14
|
const TRANSFER_AMOUNT = 33n;
|
|
@@ -18,40 +19,42 @@ const TRANSFER_AMOUNT = 33n;
|
|
|
18
19
|
async function main() {
|
|
19
20
|
logger.info('Running token contract test on HTTP interface.');
|
|
20
21
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const wallet = await TestWallet.create(node);
|
|
23
|
+
|
|
24
|
+
// During sandbox setup we deploy a few accounts. Below we add them to our wallet.
|
|
25
|
+
const [aliceInitialAccountData, bobInitialAccountData] = await getInitialTestAccountsData();
|
|
26
|
+
await wallet.createSchnorrAccount(aliceInitialAccountData.secret, aliceInitialAccountData.salt);
|
|
27
|
+
await wallet.createSchnorrAccount(bobInitialAccountData.secret, bobInitialAccountData.salt);
|
|
28
|
+
|
|
29
|
+
const alice = aliceInitialAccountData.address;
|
|
30
|
+
const bob = bobInitialAccountData.address;
|
|
24
31
|
|
|
25
32
|
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
26
33
|
|
|
27
34
|
logger.info('Deploying Token...');
|
|
28
|
-
const token = await TokenContract.deploy(
|
|
35
|
+
const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18)
|
|
29
36
|
.send({ from: alice })
|
|
30
37
|
.deployed();
|
|
31
38
|
logger.info('Token deployed');
|
|
32
39
|
|
|
33
|
-
// Create the contract abstraction and link it to Alice's and Bob's wallet for future signing
|
|
34
|
-
const tokenAlice = await TokenContract.at(token.address, aliceWallet);
|
|
35
|
-
const tokenBob = await TokenContract.at(token.address, bobWallet);
|
|
36
|
-
|
|
37
40
|
// Mint tokens to Alice
|
|
38
41
|
logger.info(`Minting ${ALICE_MINT_BALANCE} more coins to Alice...`);
|
|
39
|
-
await
|
|
42
|
+
await token.methods.mint_to_private(alice, ALICE_MINT_BALANCE).send({ from: alice }).wait();
|
|
40
43
|
|
|
41
44
|
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
42
45
|
|
|
43
|
-
const balanceAfterMint = await
|
|
46
|
+
const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
44
47
|
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
45
48
|
|
|
46
49
|
// We will now transfer tokens from Alice to Bob
|
|
47
50
|
logger.info(`Transferring ${TRANSFER_AMOUNT} tokens from Alice to Bob...`);
|
|
48
|
-
await
|
|
51
|
+
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice }).wait();
|
|
49
52
|
|
|
50
53
|
// Check the new balances
|
|
51
|
-
const aliceBalance = await
|
|
54
|
+
const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
52
55
|
logger.info(`Alice's balance ${aliceBalance}`);
|
|
53
56
|
|
|
54
|
-
const bobBalance = await
|
|
57
|
+
const bobBalance = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
55
58
|
logger.info(`Bob's balance ${bobBalance}`);
|
|
56
59
|
}
|
|
57
60
|
|
package/src/examples/util.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export {
|
|
2
2
|
createSandbox,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
registerDeployedBananaCoinInWalletAndGetAddress,
|
|
4
|
+
registerDeployedBananaFPCInWalletAndGetAddress,
|
|
5
|
+
registerDeployedSponsoredFPCInWalletAndGetAddress,
|
|
6
6
|
} from './sandbox/index.js';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { type InitialAccountData,
|
|
2
|
-
import type { Wallet } from '@aztec/aztec.js';
|
|
1
|
+
import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { LogFn } from '@aztec/foundation/log';
|
|
5
5
|
import { FPCContract } from '@aztec/noir-contracts.js/FPC';
|
|
6
6
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
7
7
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
8
|
import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
9
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
10
9
|
|
|
11
10
|
const BANANA_COIN_SALT = new Fr(0);
|
|
12
11
|
const bananaCoinArgs = {
|
|
@@ -46,14 +45,14 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
46
45
|
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
export async function setupBananaFPC(initialAccounts: InitialAccountData[],
|
|
48
|
+
export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
|
|
50
49
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
51
50
|
const admin = getBananaAdmin(initialAccounts);
|
|
52
51
|
const [bananaCoin, fpc] = await Promise.all([
|
|
53
|
-
TokenContract.deploy(
|
|
52
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal)
|
|
54
53
|
.send({ from: admin, contractAddressSalt: BANANA_COIN_SALT, universalDeploy: true })
|
|
55
54
|
.deployed(),
|
|
56
|
-
FPCContract.deploy(
|
|
55
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin)
|
|
57
56
|
.send({ from: admin, contractAddressSalt: BANANA_FPC_SALT, universalDeploy: true })
|
|
58
57
|
.deployed(),
|
|
59
58
|
]);
|
|
@@ -62,22 +61,18 @@ export async function setupBananaFPC(initialAccounts: InitialAccountData[], depl
|
|
|
62
61
|
log(`FPC: ${fpc.address}`);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
export async function
|
|
66
|
-
const initialAccounts = await
|
|
67
|
-
const bananaCoin = await
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
return bananaCoin;
|
|
64
|
+
export async function registerDeployedBananaCoinInWalletAndGetAddress(wallet: Wallet) {
|
|
65
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
66
|
+
const bananaCoin = await getBananaCoinInstance(initialAccounts);
|
|
67
|
+
// The following is no-op if the contract is already registered
|
|
68
|
+
await wallet.registerContract(bananaCoin, TokenContract.artifact);
|
|
69
|
+
return bananaCoin.address;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
|
-
export async function
|
|
76
|
-
const initialAccounts = await
|
|
72
|
+
export async function registerDeployedBananaFPCInWalletAndGetAddress(wallet: Wallet) {
|
|
73
|
+
const initialAccounts = await getInitialTestAccountsData();
|
|
77
74
|
const fpc = await getBananaFPCInstance(initialAccounts);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
throw new Error('BananaFPC not deployed.');
|
|
81
|
-
}
|
|
75
|
+
// The following is no-op if the contract is already registered
|
|
76
|
+
await wallet.registerContract(fpc, FPCContract.artifact);
|
|
82
77
|
return fpc.address;
|
|
83
78
|
}
|
package/src/sandbox/index.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export * from './sandbox.js';
|
|
2
2
|
|
|
3
|
-
export {
|
|
4
|
-
|
|
3
|
+
export {
|
|
4
|
+
registerDeployedBananaCoinInWalletAndGetAddress,
|
|
5
|
+
registerDeployedBananaFPCInWalletAndGetAddress,
|
|
6
|
+
} from './banana_fpc.js';
|
|
7
|
+
export { registerDeployedSponsoredFPCInWalletAndGetAddress } from './sponsored_fpc.js';
|
package/src/sandbox/sandbox.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
|
-
import {
|
|
3
|
-
import { deployFundedSchnorrAccounts, getInitialTestAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
4
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
5
|
-
import { EthAddress } from '@aztec/aztec.js';
|
|
4
|
+
import { EthAddress } from '@aztec/aztec.js/addresses';
|
|
6
5
|
import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
|
|
7
|
-
import { setupSponsoredFPC } from '@aztec/cli/cli-utils';
|
|
8
6
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
7
|
import {
|
|
10
8
|
NULL_KEY,
|
|
@@ -20,15 +18,14 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
20
18
|
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
21
19
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
22
20
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
23
|
-
import {
|
|
24
|
-
import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
25
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
21
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
26
22
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
27
23
|
import {
|
|
28
24
|
type TelemetryClient,
|
|
29
25
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
30
26
|
initTelemetryClient,
|
|
31
27
|
} from '@aztec/telemetry-client';
|
|
28
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
32
29
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
33
30
|
|
|
34
31
|
import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
@@ -77,7 +74,7 @@ export async function deployContractsToL1(
|
|
|
77
74
|
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
78
75
|
...aztecNodeConfig,
|
|
79
76
|
vkTreeRoot: getVKTreeRoot(),
|
|
80
|
-
|
|
77
|
+
protocolContractsHash,
|
|
81
78
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
82
79
|
salt: opts.salt,
|
|
83
80
|
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
@@ -101,8 +98,6 @@ export type SandboxConfig = AztecNodeConfig & {
|
|
|
101
98
|
l1Mnemonic: string;
|
|
102
99
|
/** Salt used to deploy L1 contracts.*/
|
|
103
100
|
deployAztecContractsSalt: string;
|
|
104
|
-
/** Whether to expose PXE service on sandbox start.*/
|
|
105
|
-
noPXE: boolean;
|
|
106
101
|
/** Whether to deploy test accounts on sandbox start.*/
|
|
107
102
|
testAccounts: boolean;
|
|
108
103
|
};
|
|
@@ -145,7 +140,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
145
140
|
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
146
141
|
} else {
|
|
147
142
|
userLog(`Setting up test accounts`);
|
|
148
|
-
return await
|
|
143
|
+
return await getInitialTestAccountsData();
|
|
149
144
|
}
|
|
150
145
|
}
|
|
151
146
|
return [];
|
|
@@ -179,7 +174,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
179
174
|
});
|
|
180
175
|
|
|
181
176
|
watcher = new AnvilTestWatcher(
|
|
182
|
-
new EthCheatCodes([l1RpcUrl]),
|
|
177
|
+
new EthCheatCodes([l1RpcUrl], dateProvider),
|
|
183
178
|
l1ContractAddresses.rollupAddress,
|
|
184
179
|
publicClient,
|
|
185
180
|
dateProvider,
|
|
@@ -196,22 +191,26 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
196
191
|
{ telemetry, blobSinkClient, dateProvider },
|
|
197
192
|
{ prefilledPublicData },
|
|
198
193
|
);
|
|
199
|
-
const pxeServiceConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
200
|
-
const pxe = await createAztecPXE(node, pxeServiceConfig);
|
|
201
194
|
|
|
202
195
|
if (initialAccounts.length) {
|
|
196
|
+
const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
197
|
+
const wallet = await TestWallet.create(node, PXEConfig);
|
|
198
|
+
|
|
203
199
|
userLog('Setting up funded test accounts...');
|
|
204
|
-
const
|
|
205
|
-
const accountsWithSecrets =
|
|
206
|
-
account,
|
|
200
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
|
|
201
|
+
const accountsWithSecrets = accountManagers.map((manager, i) => ({
|
|
202
|
+
account: manager,
|
|
207
203
|
secretKey: initialAccounts[i].secret,
|
|
208
204
|
}));
|
|
209
|
-
const accLogs = await createAccountLogs(accountsWithSecrets,
|
|
205
|
+
const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
|
|
210
206
|
userLog(accLogs.join(''));
|
|
211
207
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
await
|
|
208
|
+
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
209
|
+
|
|
210
|
+
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
211
|
+
|
|
212
|
+
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
213
|
+
await wallet.stop();
|
|
215
214
|
}
|
|
216
215
|
|
|
217
216
|
const stop = async () => {
|
|
@@ -219,7 +218,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
219
218
|
await watcher?.stop();
|
|
220
219
|
};
|
|
221
220
|
|
|
222
|
-
return { node,
|
|
221
|
+
return { node, stop };
|
|
223
222
|
}
|
|
224
223
|
|
|
225
224
|
/**
|
|
@@ -241,13 +240,3 @@ export async function createAztecNode(
|
|
|
241
240
|
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
|
|
242
241
|
return node;
|
|
243
242
|
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Create and start a new Aztec PXE HTTP Server
|
|
247
|
-
* @param config - Optional PXE settings.
|
|
248
|
-
*/
|
|
249
|
-
export async function createAztecPXE(node: AztecNode, config: Partial<PXEServiceConfig> = {}) {
|
|
250
|
-
const pxeServiceConfig: PXEServiceConfig = { ...getPXEServiceConfig(), ...config };
|
|
251
|
-
const pxe = await createPXEService(node, pxeServiceConfig);
|
|
252
|
-
return pxe;
|
|
253
|
-
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ContractInstanceWithAddress,
|
|
3
|
-
Fr,
|
|
4
|
-
type PXE,
|
|
5
3
|
getContractInstanceFromInstantiationParams,
|
|
6
|
-
} from '@aztec/aztec.js';
|
|
4
|
+
} from '@aztec/aztec.js/contracts';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
7
7
|
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
8
8
|
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
9
9
|
|
|
@@ -17,11 +17,9 @@ export async function getSponsoredFPCAddress() {
|
|
|
17
17
|
return (await getSponsoredFPCInstance()).address;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
export async function
|
|
21
|
-
const fpc = await
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
return fpc;
|
|
20
|
+
export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet) {
|
|
21
|
+
const fpc = await getSponsoredFPCInstance();
|
|
22
|
+
// The following is no-op if the contract is already registered
|
|
23
|
+
await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
|
|
24
|
+
return fpc.address;
|
|
27
25
|
}
|
|
@@ -50,6 +50,7 @@ export class AnvilTestWatcher {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
setIsMarkingAsProven(isMarkingAsProven: boolean) {
|
|
53
|
+
this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
|
|
53
54
|
this.isMarkingAsProven = isMarkingAsProven;
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -132,7 +133,6 @@ export class AnvilTestWatcher {
|
|
|
132
133
|
try {
|
|
133
134
|
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
134
135
|
resetBlockInterval: true,
|
|
135
|
-
updateDateProvider: this.dateProvider,
|
|
136
136
|
});
|
|
137
137
|
} catch (e) {
|
|
138
138
|
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
@@ -150,10 +150,7 @@ export class AnvilTestWatcher {
|
|
|
150
150
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
151
151
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
152
152
|
try {
|
|
153
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
154
|
-
resetBlockInterval: true,
|
|
155
|
-
updateDateProvider: this.dateProvider,
|
|
156
|
-
});
|
|
153
|
+
await this.cheatcodes.warp(nextSlotTimestamp, { resetBlockInterval: true });
|
|
157
154
|
} catch (e) {
|
|
158
155
|
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
159
156
|
}
|