@aztec/aztec 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108
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 +1 -1
- package/dest/bin/index.d.ts +1 -1
- package/dest/bin/index.js +11 -10
- package/dest/cli/aztec_start_action.d.ts +1 -1
- package/dest/cli/aztec_start_action.d.ts.map +1 -1
- package/dest/cli/aztec_start_action.js +9 -25
- 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 +22 -39
- package/dest/cli/cli.d.ts +1 -1
- package/dest/cli/cli.d.ts.map +1 -1
- package/dest/cli/cli.js +46 -1
- package/dest/cli/cmds/start_archiver.d.ts +1 -1
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +9 -9
- package/dest/cli/cmds/start_bot.d.ts +4 -7
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +25 -14
- package/dest/cli/cmds/start_node.d.ts +1 -1
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +13 -21
- package/dest/cli/cmds/start_p2p_bootstrap.d.ts +1 -1
- package/dest/cli/cmds/start_p2p_bootstrap.js +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
- package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_agent.js +12 -3
- package/dest/cli/cmds/start_prover_broker.d.ts +1 -1
- package/dest/cli/cmds/start_prover_broker.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_broker.js +8 -3
- package/dest/cli/cmds/start_prover_node.d.ts +1 -1
- package/dest/cli/cmds/start_prover_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_prover_node.js +16 -7
- package/dest/cli/cmds/start_txe.d.ts +1 -1
- package/dest/cli/index.d.ts +1 -1
- package/dest/cli/preload_crs.d.ts +1 -1
- package/dest/cli/release_version.d.ts +1 -1
- package/dest/cli/util.d.ts +12 -10
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +7 -7
- package/dest/cli/versioning.d.ts +1 -1
- package/dest/cli/versioning.js +3 -3
- package/dest/examples/token.d.ts +1 -1
- package/dest/examples/token.js +18 -16
- package/dest/examples/util.d.ts +3 -3
- package/dest/examples/util.d.ts.map +1 -1
- package/dest/examples/util.js +1 -1
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/local-network/banana_fpc.d.ts +10 -0
- package/dest/local-network/banana_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/banana_fpc.js +15 -19
- package/dest/local-network/index.d.ts +4 -0
- package/dest/local-network/index.d.ts.map +1 -0
- package/dest/local-network/index.js +3 -0
- package/dest/local-network/local-network.d.ts +72 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/{sandbox/sandbox.js → local-network/local-network.js} +43 -57
- package/dest/local-network/sponsored_fpc.d.ts +5 -0
- package/dest/local-network/sponsored_fpc.d.ts.map +1 -0
- package/dest/{sandbox → local-network}/sponsored_fpc.js +7 -8
- package/dest/mnemonic.d.ts +1 -1
- package/dest/splash.d.ts +1 -1
- package/dest/testing/anvil_test_watcher.d.ts +4 -4
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +19 -18
- package/dest/testing/cheat_codes.d.ts +7 -10
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +9 -10
- package/dest/testing/index.d.ts +1 -2
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +0 -1
- package/package.json +39 -37
- package/src/bin/index.ts +12 -10
- package/src/cli/aztec_start_action.ts +9 -22
- package/src/cli/aztec_start_options.ts +23 -40
- package/src/cli/cli.ts +46 -1
- package/src/cli/cmds/start_archiver.ts +9 -9
- package/src/cli/cmds/start_bot.ts +36 -13
- package/src/cli/cmds/start_node.ts +16 -17
- package/src/cli/cmds/start_p2p_bootstrap.ts +1 -1
- package/src/cli/cmds/start_prover_agent.ts +8 -11
- package/src/cli/cmds/start_prover_broker.ts +17 -3
- package/src/cli/cmds/start_prover_node.ts +13 -8
- package/src/cli/util.ts +12 -10
- package/src/cli/versioning.ts +3 -3
- package/src/examples/token.ts +20 -17
- package/src/examples/util.ts +2 -2
- package/src/index.ts +5 -5
- package/src/{sandbox → local-network}/banana_fpc.ts +16 -21
- package/src/local-network/index.ts +7 -0
- package/src/{sandbox/sandbox.ts → local-network/local-network.ts} +68 -99
- package/src/local-network/sponsored_fpc.ts +26 -0
- package/src/testing/anvil_test_watcher.ts +18 -19
- package/src/testing/cheat_codes.ts +13 -13
- 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_blob_sink.d.ts +0 -3
- package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
- package/dest/cli/cmds/start_blob_sink.js +0 -33
- 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/sandbox/banana_fpc.d.ts +0 -11
- package/dest/sandbox/banana_fpc.d.ts.map +0 -1
- package/dest/sandbox/index.d.ts +0 -4
- package/dest/sandbox/index.d.ts.map +0 -1
- package/dest/sandbox/index.js +0 -3
- package/dest/sandbox/sandbox.d.ts +0 -83
- package/dest/sandbox/sandbox.d.ts.map +0 -1
- package/dest/sandbox/sponsored_fpc.d.ts +0 -4
- package/dest/sandbox/sponsored_fpc.d.ts.map +0 -1
- 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_blob_sink.ts +0 -57
- package/src/cli/cmds/start_pxe.ts +0 -49
- package/src/cli/get_l1_config.ts +0 -19
- package/src/sandbox/index.ts +0 -4
- package/src/sandbox/sponsored_fpc.ts +0 -27
- package/src/testing/aztec_cheat_codes.ts +0 -77
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env -S node --no-warnings
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { type AztecNodeConfig,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
3
|
+
import { AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
+
import { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import { createLogger } from '@aztec/aztec.js/log';
|
|
7
|
+
import { type BlobClientInterface, createBlobClient } from '@aztec/blob-client/client';
|
|
8
8
|
import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getL1ContractsConfigEnvVars,
|
|
15
|
-
waitForPublicClient,
|
|
16
|
-
} from '@aztec/ethereum';
|
|
9
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
10
|
+
import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
11
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
12
|
+
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
13
|
+
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
17
14
|
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
18
15
|
import { SecretValue } from '@aztec/foundation/config';
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
16
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
17
|
+
import type { LogFn } from '@aztec/foundation/log';
|
|
21
18
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
22
19
|
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';
|
|
20
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
26
21
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
27
22
|
import {
|
|
28
23
|
type TelemetryClient,
|
|
29
24
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
30
25
|
initTelemetryClient,
|
|
31
26
|
} from '@aztec/telemetry-client';
|
|
27
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
32
28
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
33
29
|
|
|
34
|
-
import { type
|
|
30
|
+
import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
35
31
|
import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
|
|
36
32
|
import { foundry } from 'viem/chains';
|
|
37
33
|
|
|
@@ -41,53 +37,37 @@ import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
|
41
37
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
42
38
|
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
43
39
|
|
|
44
|
-
const logger = createLogger('
|
|
40
|
+
const logger = createLogger('local-network');
|
|
45
41
|
|
|
46
42
|
const localAnvil = foundry;
|
|
47
43
|
|
|
48
44
|
/**
|
|
49
|
-
* Function to deploy our L1 contracts to the
|
|
45
|
+
* Function to deploy our L1 contracts to the local network L1
|
|
50
46
|
* @param aztecNodeConfig - The Aztec Node Config
|
|
51
47
|
* @param hdAccount - Account for publishing L1 contracts
|
|
52
48
|
*/
|
|
53
49
|
export async function deployContractsToL1(
|
|
54
50
|
aztecNodeConfig: AztecNodeConfig,
|
|
55
|
-
|
|
56
|
-
contractDeployLogger = logger,
|
|
51
|
+
privateKey: Hex,
|
|
57
52
|
opts: {
|
|
58
53
|
assumeProvenThroughBlockNumber?: number;
|
|
59
|
-
salt?: number;
|
|
60
54
|
genesisArchiveRoot?: Fr;
|
|
61
55
|
feeJuicePortalInitialBalance?: bigint;
|
|
62
56
|
} = {},
|
|
63
57
|
) {
|
|
64
|
-
const chain =
|
|
65
|
-
aztecNodeConfig.l1RpcUrls.length > 0
|
|
66
|
-
? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId)
|
|
67
|
-
: { chainInfo: localAnvil };
|
|
68
|
-
|
|
69
58
|
await waitForPublicClient(aztecNodeConfig);
|
|
70
59
|
|
|
71
|
-
const l1Contracts = await
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
salt: opts.salt,
|
|
83
|
-
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
84
|
-
aztecTargetCommitteeSize: 0, // no committee in sandbox
|
|
85
|
-
slasherFlavor: 'none', // no slashing in sandbox
|
|
86
|
-
realVerifier: false,
|
|
87
|
-
},
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
await deployMulticall3(l1Contracts.l1Client, logger);
|
|
60
|
+
const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
|
|
61
|
+
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
62
|
+
...aztecNodeConfig,
|
|
63
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
64
|
+
protocolContractsHash,
|
|
65
|
+
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
66
|
+
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
67
|
+
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
68
|
+
slasherFlavor: 'none', // no slashing in local network
|
|
69
|
+
realVerifier: false,
|
|
70
|
+
});
|
|
91
71
|
|
|
92
72
|
aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
|
|
93
73
|
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
@@ -95,31 +75,27 @@ export async function deployContractsToL1(
|
|
|
95
75
|
return aztecNodeConfig.l1Contracts;
|
|
96
76
|
}
|
|
97
77
|
|
|
98
|
-
/**
|
|
99
|
-
export type
|
|
78
|
+
/** Local network settings. */
|
|
79
|
+
export type LocalNetworkConfig = AztecNodeConfig & {
|
|
100
80
|
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
101
81
|
l1Mnemonic: string;
|
|
102
|
-
/**
|
|
103
|
-
deployAztecContractsSalt: string;
|
|
104
|
-
/** Whether to expose PXE service on sandbox start.*/
|
|
105
|
-
noPXE: boolean;
|
|
106
|
-
/** Whether to deploy test accounts on sandbox start.*/
|
|
82
|
+
/** Whether to deploy test accounts on local network start.*/
|
|
107
83
|
testAccounts: boolean;
|
|
108
84
|
};
|
|
109
85
|
|
|
110
86
|
/**
|
|
111
87
|
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
112
88
|
* Does not start any HTTP services nor populate any initial accounts.
|
|
113
|
-
* @param config - Optional
|
|
89
|
+
* @param config - Optional local network settings.
|
|
114
90
|
*/
|
|
115
|
-
export async function
|
|
116
|
-
//
|
|
91
|
+
export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {}, userLog: LogFn) {
|
|
92
|
+
// local network is meant for test envs. We should only need one l1RpcUrl
|
|
117
93
|
const l1RpcUrl = config.l1RpcUrls?.[0];
|
|
118
94
|
if (!l1RpcUrl) {
|
|
119
95
|
throw new Error('An L1 RPC URL is required');
|
|
120
96
|
}
|
|
121
97
|
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
122
|
-
logger.warn(`Multiple L1 RPC URLs provided.
|
|
98
|
+
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
123
99
|
}
|
|
124
100
|
const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
|
|
125
101
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
@@ -145,7 +121,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
145
121
|
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
146
122
|
} else {
|
|
147
123
|
userLog(`Setting up test accounts`);
|
|
148
|
-
return await
|
|
124
|
+
return await getInitialTestAccountsData();
|
|
149
125
|
}
|
|
150
126
|
}
|
|
151
127
|
return [];
|
|
@@ -161,12 +137,15 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
161
137
|
let watcher: AnvilTestWatcher | undefined = undefined;
|
|
162
138
|
const dateProvider = new TestDateProvider();
|
|
163
139
|
if (!aztecNodeConfig.p2pEnabled) {
|
|
164
|
-
const l1ContractAddresses = await deployContractsToL1(
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
140
|
+
const l1ContractAddresses = await deployContractsToL1(
|
|
141
|
+
aztecNodeConfig,
|
|
142
|
+
aztecNodeConfig.validatorPrivateKeys.getValue()[0],
|
|
143
|
+
{
|
|
144
|
+
assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
|
|
145
|
+
genesisArchiveRoot,
|
|
146
|
+
feeJuicePortalInitialBalance: fundingNeeded,
|
|
147
|
+
},
|
|
148
|
+
);
|
|
170
149
|
|
|
171
150
|
const chain =
|
|
172
151
|
aztecNodeConfig.l1RpcUrls.length > 0
|
|
@@ -179,39 +158,39 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
179
158
|
});
|
|
180
159
|
|
|
181
160
|
watcher = new AnvilTestWatcher(
|
|
182
|
-
new EthCheatCodes([l1RpcUrl]),
|
|
161
|
+
new EthCheatCodes([l1RpcUrl], dateProvider),
|
|
183
162
|
l1ContractAddresses.rollupAddress,
|
|
184
163
|
publicClient,
|
|
185
164
|
dateProvider,
|
|
186
165
|
);
|
|
187
|
-
watcher.
|
|
166
|
+
watcher.setisLocalNetwork(true);
|
|
188
167
|
await watcher.start();
|
|
189
168
|
}
|
|
190
169
|
|
|
191
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
192
|
-
// Create a local blob
|
|
193
|
-
const
|
|
194
|
-
const node = await createAztecNode(
|
|
195
|
-
aztecNodeConfig,
|
|
196
|
-
{ telemetry, blobSinkClient, dateProvider },
|
|
197
|
-
{ prefilledPublicData },
|
|
198
|
-
);
|
|
199
|
-
const pxeServiceConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
200
|
-
const pxe = await createAztecPXE(node, pxeServiceConfig);
|
|
170
|
+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
171
|
+
// Create a local blob client client inside the local network, no http connectivity
|
|
172
|
+
const blobClient = createBlobClient();
|
|
173
|
+
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
|
|
201
174
|
|
|
202
175
|
if (initialAccounts.length) {
|
|
176
|
+
const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
177
|
+
const wallet = await TestWallet.create(node, PXEConfig);
|
|
178
|
+
|
|
203
179
|
userLog('Setting up funded test accounts...');
|
|
204
|
-
const
|
|
205
|
-
const accountsWithSecrets =
|
|
206
|
-
account,
|
|
180
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
|
|
181
|
+
const accountsWithSecrets = accountManagers.map((manager, i) => ({
|
|
182
|
+
account: manager,
|
|
207
183
|
secretKey: initialAccounts[i].secret,
|
|
208
184
|
}));
|
|
209
|
-
const accLogs = await createAccountLogs(accountsWithSecrets,
|
|
185
|
+
const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
|
|
210
186
|
userLog(accLogs.join(''));
|
|
211
187
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
await
|
|
188
|
+
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
189
|
+
|
|
190
|
+
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
191
|
+
|
|
192
|
+
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
193
|
+
await wallet.stop();
|
|
215
194
|
}
|
|
216
195
|
|
|
217
196
|
const stop = async () => {
|
|
@@ -219,7 +198,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
219
198
|
await watcher?.stop();
|
|
220
199
|
};
|
|
221
200
|
|
|
222
|
-
return { node,
|
|
201
|
+
return { node, stop };
|
|
223
202
|
}
|
|
224
203
|
|
|
225
204
|
/**
|
|
@@ -228,7 +207,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
228
207
|
*/
|
|
229
208
|
export async function createAztecNode(
|
|
230
209
|
config: Partial<AztecNodeConfig> = {},
|
|
231
|
-
deps: { telemetry?: TelemetryClient;
|
|
210
|
+
deps: { telemetry?: TelemetryClient; blobClient?: BlobClientInterface; dateProvider?: DateProvider } = {},
|
|
232
211
|
options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
|
|
233
212
|
) {
|
|
234
213
|
// TODO(#12272): will clean this up. This is criminal.
|
|
@@ -241,13 +220,3 @@ export async function createAztecNode(
|
|
|
241
220
|
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
|
|
242
221
|
return node;
|
|
243
222
|
}
|
|
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
|
-
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import {
|
|
3
|
+
type ContractInstanceWithAddress,
|
|
4
|
+
getContractInstanceFromInstantiationParams,
|
|
5
|
+
} from '@aztec/aztec.js/contracts';
|
|
6
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
7
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
8
|
+
import { SPONSORED_FPC_SALT } from '@aztec/constants';
|
|
9
|
+
import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
|
|
10
|
+
|
|
11
|
+
async function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress> {
|
|
12
|
+
return await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
|
|
13
|
+
salt: new Fr(SPONSORED_FPC_SALT),
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function getSponsoredFPCAddress(): Promise<AztecAddress> {
|
|
18
|
+
return (await getSponsoredFPCInstance()).address;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function registerDeployedSponsoredFPCInWalletAndGetAddress(wallet: Wallet): Promise<AztecAddress> {
|
|
22
|
+
const fpc = await getSponsoredFPCInstance();
|
|
23
|
+
// The following is no-op if the contract is already registered
|
|
24
|
+
await wallet.registerContract(fpc, SponsoredFPCContract.artifact);
|
|
25
|
+
return fpc.address;
|
|
26
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ViemClient } from '@aztec/ethereum';
|
|
2
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import type { ViemClient } from '@aztec/ethereum/types';
|
|
3
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
5
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
@@ -16,11 +17,11 @@ import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
|
16
17
|
* block within the slot. And if so, it will time travel into the next slot.
|
|
17
18
|
*/
|
|
18
19
|
export class AnvilTestWatcher {
|
|
19
|
-
private
|
|
20
|
+
private isLocalNetwork: boolean = false;
|
|
20
21
|
|
|
21
22
|
private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
22
23
|
private rollupCheatCodes: RollupCheatCodes;
|
|
23
|
-
private l2SlotDuration!:
|
|
24
|
+
private l2SlotDuration!: number;
|
|
24
25
|
|
|
25
26
|
private filledRunningPromise?: RunningPromise;
|
|
26
27
|
private syncDateProviderPromise?: RunningPromise;
|
|
@@ -50,11 +51,12 @@ export class AnvilTestWatcher {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
setIsMarkingAsProven(isMarkingAsProven: boolean) {
|
|
54
|
+
this.logger.warn(`Watcher is now ${isMarkingAsProven ? 'marking' : 'not marking'} blocks as proven`);
|
|
53
55
|
this.isMarkingAsProven = isMarkingAsProven;
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
this.
|
|
58
|
+
setisLocalNetwork(isLocalNetwork: boolean) {
|
|
59
|
+
this.isLocalNetwork = isLocalNetwork;
|
|
58
60
|
}
|
|
59
61
|
|
|
60
62
|
async start() {
|
|
@@ -67,7 +69,7 @@ export class AnvilTestWatcher {
|
|
|
67
69
|
|
|
68
70
|
// If auto mining is not supported (e.g., we are on a real network), then we
|
|
69
71
|
// will simple do nothing. But if on an anvil or the like, this make sure that
|
|
70
|
-
// the
|
|
72
|
+
// the local network and tests don't break because time is frozen and we never get to
|
|
71
73
|
// the next slot.
|
|
72
74
|
const isAutoMining = await this.cheatcodes.isAutoMining();
|
|
73
75
|
|
|
@@ -104,7 +106,7 @@ export class AnvilTestWatcher {
|
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
async syncDateProviderToL1IfBehind() {
|
|
107
|
-
// this doesn't apply to the
|
|
109
|
+
// this doesn't apply to the local network, because we don't have a date provider in the local network
|
|
108
110
|
if (!this.dateProvider) {
|
|
109
111
|
return;
|
|
110
112
|
}
|
|
@@ -122,17 +124,17 @@ export class AnvilTestWatcher {
|
|
|
122
124
|
|
|
123
125
|
async warpTimeIfNeeded() {
|
|
124
126
|
try {
|
|
125
|
-
const currentSlot = await this.rollup.read.getCurrentSlot();
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
127
|
+
const currentSlot = SlotNumber.fromBigInt(await this.rollup.read.getCurrentSlot());
|
|
128
|
+
const pendingCheckpointNumber = await this.rollup.read.getPendingCheckpointNumber();
|
|
129
|
+
const checkpointLog = await this.rollup.read.getCheckpoint([pendingCheckpointNumber]);
|
|
130
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
131
|
+
const nextSlotTimestamp = Number(await this.rollup.read.getTimestampForSlot([BigInt(nextSlot)]));
|
|
129
132
|
|
|
130
|
-
if (currentSlot ===
|
|
133
|
+
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
131
134
|
// We should jump to the next slot
|
|
132
135
|
try {
|
|
133
136
|
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
134
137
|
resetBlockInterval: true,
|
|
135
|
-
updateDateProvider: this.dateProvider,
|
|
136
138
|
});
|
|
137
139
|
} catch (e) {
|
|
138
140
|
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
@@ -142,18 +144,15 @@ export class AnvilTestWatcher {
|
|
|
142
144
|
return;
|
|
143
145
|
}
|
|
144
146
|
|
|
145
|
-
// If we are not in
|
|
146
|
-
if (!this.
|
|
147
|
+
// If we are not in local network, we don't need to warp time
|
|
148
|
+
if (!this.isLocalNetwork) {
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
151
153
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
152
154
|
try {
|
|
153
|
-
await this.cheatcodes.warp(nextSlotTimestamp, {
|
|
154
|
-
resetBlockInterval: true,
|
|
155
|
-
updateDateProvider: this.dateProvider,
|
|
156
|
-
});
|
|
155
|
+
await this.cheatcodes.warp(nextSlotTimestamp, { resetBlockInterval: true });
|
|
157
156
|
} catch (e) {
|
|
158
157
|
this.logger.error(`Failed to warp to timestamp ${nextSlotTimestamp}: ${e}`);
|
|
159
158
|
}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { retryUntil } from '@aztec/aztec.js';
|
|
2
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
|
+
import type { DateProvider } from '@aztec/foundation/timer';
|
|
3
5
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
4
|
-
import type { AztecNode
|
|
5
|
-
|
|
6
|
-
import { AztecCheatCodes } from './aztec_cheat_codes.js';
|
|
6
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* A class that provides utility functions for interacting with the chain.
|
|
10
|
+
* @deprecated There used to be 3 kinds of cheat codes: eth, rollup and aztec. We have nuked the Aztec ones because
|
|
11
|
+
* they became unused (we now have better testing tools). If you are introducing a new functionality to the cheat
|
|
12
|
+
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
10
13
|
*/
|
|
11
14
|
export class CheatCodes {
|
|
12
15
|
constructor(
|
|
13
16
|
/** Cheat codes for L1.*/
|
|
14
17
|
public eth: EthCheatCodes,
|
|
15
|
-
/** Cheat codes for Aztec L2. */
|
|
16
|
-
public aztec: AztecCheatCodes,
|
|
17
18
|
/** Cheat codes for the Aztec Rollup contract on L1. */
|
|
18
19
|
public rollup: RollupCheatCodes,
|
|
19
20
|
) {}
|
|
20
21
|
|
|
21
|
-
static async create(rpcUrls: string[],
|
|
22
|
-
const ethCheatCodes = new EthCheatCodes(rpcUrls);
|
|
23
|
-
const aztecCheatCodes = new AztecCheatCodes(pxe);
|
|
22
|
+
static async create(rpcUrls: string[], node: AztecNode, dateProvider: DateProvider): Promise<CheatCodes> {
|
|
23
|
+
const ethCheatCodes = new EthCheatCodes(rpcUrls, dateProvider);
|
|
24
24
|
const rollupCheatCodes = new RollupCheatCodes(
|
|
25
25
|
ethCheatCodes,
|
|
26
|
-
await
|
|
26
|
+
await node.getNodeInfo().then(n => n.l1ContractAddresses),
|
|
27
27
|
);
|
|
28
|
-
return new CheatCodes(ethCheatCodes,
|
|
28
|
+
return new CheatCodes(ethCheatCodes, rollupCheatCodes);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -38,7 +38,7 @@ export class CheatCodes {
|
|
|
38
38
|
* @param targetTimestamp - The target timestamp to warp to (in seconds)
|
|
39
39
|
*/
|
|
40
40
|
async warpL2TimeAtLeastTo(sequencerClient: SequencerClient, node: AztecNode, targetTimestamp: bigint | number) {
|
|
41
|
-
const currentL2BlockNumber = await node.getBlockNumber();
|
|
41
|
+
const currentL2BlockNumber: BlockNumber = await node.getBlockNumber();
|
|
42
42
|
|
|
43
43
|
// We warp the L1 timestamp
|
|
44
44
|
await this.eth.warp(targetTimestamp, { resetBlockInterval: true });
|
|
@@ -50,7 +50,7 @@ export class CheatCodes {
|
|
|
50
50
|
|
|
51
51
|
await retryUntil(
|
|
52
52
|
async () => {
|
|
53
|
-
const newL2BlockNumber = await node.getBlockNumber();
|
|
53
|
+
const newL2BlockNumber: BlockNumber = await node.getBlockNumber();
|
|
54
54
|
return newL2BlockNumber > currentL2BlockNumber;
|
|
55
55
|
},
|
|
56
56
|
'new block after warping L2 time',
|
package/src/testing/index.ts
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type L1ContractsConfig } from '@aztec/ethereum';
|
|
2
|
-
import type { NetworkNames } from '@aztec/foundation/config';
|
|
3
|
-
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
4
|
-
import type { SlasherConfig } from '@aztec/stdlib/interfaces/server';
|
|
5
|
-
export type L2ChainConfig = L1ContractsConfig & Omit<SlasherConfig, 'slashValidatorsNever' | 'slashValidatorsAlways'> & {
|
|
6
|
-
l1ChainId: number;
|
|
7
|
-
testAccounts: boolean;
|
|
8
|
-
sponsoredFPC: boolean;
|
|
9
|
-
p2pEnabled: boolean;
|
|
10
|
-
p2pBootstrapNodes: string[];
|
|
11
|
-
registryAddress: string;
|
|
12
|
-
slashFactoryAddress: string;
|
|
13
|
-
feeAssetHandlerAddress: string;
|
|
14
|
-
seqMinTxsPerBlock: number;
|
|
15
|
-
seqMaxTxsPerBlock: number;
|
|
16
|
-
realProofs: boolean;
|
|
17
|
-
snapshotsUrl: string;
|
|
18
|
-
autoUpdate: SharedNodeConfig['autoUpdate'];
|
|
19
|
-
autoUpdateUrl?: string;
|
|
20
|
-
maxTxPoolSize: number;
|
|
21
|
-
publicIncludeMetrics?: string[];
|
|
22
|
-
publicMetricsCollectorUrl?: string;
|
|
23
|
-
publicMetricsCollectFrom?: string[];
|
|
24
|
-
sentinelEnabled: boolean;
|
|
25
|
-
};
|
|
26
|
-
export declare const testnetIgnitionL2ChainConfig: L2ChainConfig;
|
|
27
|
-
export declare const alphaTestnetL2ChainConfig: L2ChainConfig;
|
|
28
|
-
export declare function getBootnodes(networkName: NetworkNames, cacheDir?: string): Promise<any>;
|
|
29
|
-
export declare function getL2ChainConfig(networkName: NetworkNames, cacheDir?: string): Promise<L2ChainConfig | undefined>;
|
|
30
|
-
export declare function enrichEnvironmentWithChainConfig(networkName: NetworkNames): Promise<void>;
|
|
31
|
-
//# sourceMappingURL=chain_l2_config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"chain_l2_config.d.ts","sourceRoot":"","sources":["../../src/cli/chain_l2_config.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAOrE,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,IAAI,CAAC,aAAa,EAAE,sBAAsB,GAAG,uBAAuB,CAAC,GAAG;IACtE,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC3C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,wBAAwB,CAAC,EAAE,MAAM,EAAE,CAAC;IAGpC,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEJ,eAAO,MAAM,4BAA4B,EAAE,aAqD1C,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,aA4EvC,CAAC;AAIF,wBAAsB,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,MAAM,gBAgC9E;AAED,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,YAAY,EACzB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAWpC;AAgCD,wBAAsB,gCAAgC,CAAC,WAAW,EAAE,YAAY,iBAyF/E"}
|