@aztec/aztec 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212
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 +9 -9
- 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 +10 -25
- package/dest/cli/aztec_start_options.d.ts +2 -2
- package/dest/cli/aztec_start_options.d.ts.map +1 -1
- package/dest/cli/aztec_start_options.js +115 -231
- 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 +4 -4
- package/dest/cli/cmds/start_blob_sink.d.ts +1 -1
- package/dest/cli/cmds/start_blob_sink.d.ts.map +1 -1
- package/dest/cli/cmds/start_blob_sink.js +2 -2
- 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 -30
- 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 +11 -2
- 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 +17 -12
- 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 +13 -13
- 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 +74 -0
- package/dest/local-network/local-network.d.ts.map +1 -0
- package/dest/{sandbox/sandbox.js → local-network/local-network.js} +35 -43
- 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 +38 -36
- package/src/bin/index.ts +9 -9
- package/src/cli/aztec_start_action.ts +10 -22
- package/src/cli/aztec_start_options.ts +124 -238
- package/src/cli/cli.ts +46 -1
- package/src/cli/cmds/start_archiver.ts +4 -4
- package/src/cli/cmds/start_blob_sink.ts +2 -2
- package/src/cli/cmds/start_bot.ts +36 -13
- package/src/cli/cmds/start_node.ts +16 -27
- package/src/cli/cmds/start_p2p_bootstrap.ts +1 -1
- package/src/cli/cmds/start_prover_agent.ts +7 -2
- package/src/cli/cmds/start_prover_broker.ts +17 -3
- package/src/cli/cmds/start_prover_node.ts +14 -14
- package/src/cli/util.ts +21 -18
- 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} +42 -55
- 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_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/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_faucet.ts +0 -34
- 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,34 +1,29 @@
|
|
|
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
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
waitForPublicClient,
|
|
16
|
-
} from '@aztec/ethereum';
|
|
7
|
+
import { createEthereumChain } from '@aztec/ethereum/chain';
|
|
8
|
+
import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
9
|
+
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
10
|
+
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
11
|
+
import { deployMulticall3 } from '@aztec/ethereum/contracts';
|
|
12
|
+
import { deployL1Contracts } from '@aztec/ethereum/deploy-l1-contracts';
|
|
17
13
|
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
18
14
|
import { SecretValue } from '@aztec/foundation/config';
|
|
19
|
-
import { Fr } from '@aztec/foundation/
|
|
15
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
20
16
|
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
21
17
|
import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
22
18
|
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';
|
|
19
|
+
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
26
20
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
27
21
|
import {
|
|
28
22
|
type TelemetryClient,
|
|
29
23
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
30
24
|
initTelemetryClient,
|
|
31
25
|
} from '@aztec/telemetry-client';
|
|
26
|
+
import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
|
|
32
27
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
33
28
|
|
|
34
29
|
import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
|
|
@@ -41,12 +36,12 @@ import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
|
41
36
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
42
37
|
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
43
38
|
|
|
44
|
-
const logger = createLogger('
|
|
39
|
+
const logger = createLogger('local-network');
|
|
45
40
|
|
|
46
41
|
const localAnvil = foundry;
|
|
47
42
|
|
|
48
43
|
/**
|
|
49
|
-
* Function to deploy our L1 contracts to the
|
|
44
|
+
* Function to deploy our L1 contracts to the local network L1
|
|
50
45
|
* @param aztecNodeConfig - The Aztec Node Config
|
|
51
46
|
* @param hdAccount - Account for publishing L1 contracts
|
|
52
47
|
*/
|
|
@@ -77,12 +72,12 @@ export async function deployContractsToL1(
|
|
|
77
72
|
...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
|
|
78
73
|
...aztecNodeConfig,
|
|
79
74
|
vkTreeRoot: getVKTreeRoot(),
|
|
80
|
-
|
|
75
|
+
protocolContractsHash,
|
|
81
76
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
82
77
|
salt: opts.salt,
|
|
83
78
|
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
84
|
-
aztecTargetCommitteeSize: 0, // no committee in
|
|
85
|
-
slasherFlavor: 'none', // no slashing in
|
|
79
|
+
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
80
|
+
slasherFlavor: 'none', // no slashing in local network
|
|
86
81
|
realVerifier: false,
|
|
87
82
|
},
|
|
88
83
|
);
|
|
@@ -95,31 +90,29 @@ export async function deployContractsToL1(
|
|
|
95
90
|
return aztecNodeConfig.l1Contracts;
|
|
96
91
|
}
|
|
97
92
|
|
|
98
|
-
/**
|
|
99
|
-
export type
|
|
93
|
+
/** Local network settings. */
|
|
94
|
+
export type LocalNetworkConfig = AztecNodeConfig & {
|
|
100
95
|
/** Mnemonic used to derive the L1 deployer private key.*/
|
|
101
96
|
l1Mnemonic: string;
|
|
102
97
|
/** Salt used to deploy L1 contracts.*/
|
|
103
98
|
deployAztecContractsSalt: string;
|
|
104
|
-
/** Whether to
|
|
105
|
-
noPXE: boolean;
|
|
106
|
-
/** Whether to deploy test accounts on sandbox start.*/
|
|
99
|
+
/** Whether to deploy test accounts on local network start.*/
|
|
107
100
|
testAccounts: boolean;
|
|
108
101
|
};
|
|
109
102
|
|
|
110
103
|
/**
|
|
111
104
|
* Create and start a new Aztec Node and PXE. Deploys L1 contracts.
|
|
112
105
|
* Does not start any HTTP services nor populate any initial accounts.
|
|
113
|
-
* @param config - Optional
|
|
106
|
+
* @param config - Optional local network settings.
|
|
114
107
|
*/
|
|
115
|
-
export async function
|
|
116
|
-
//
|
|
108
|
+
export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {}, userLog: LogFn) {
|
|
109
|
+
// local network is meant for test envs. We should only need one l1RpcUrl
|
|
117
110
|
const l1RpcUrl = config.l1RpcUrls?.[0];
|
|
118
111
|
if (!l1RpcUrl) {
|
|
119
112
|
throw new Error('An L1 RPC URL is required');
|
|
120
113
|
}
|
|
121
114
|
if ((config.l1RpcUrls?.length || 0) > 1) {
|
|
122
|
-
logger.warn(`Multiple L1 RPC URLs provided.
|
|
115
|
+
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
123
116
|
}
|
|
124
117
|
const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
|
|
125
118
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
@@ -145,7 +138,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
145
138
|
userLog(`Not setting up test accounts as we are connecting to a network`);
|
|
146
139
|
} else {
|
|
147
140
|
userLog(`Setting up test accounts`);
|
|
148
|
-
return await
|
|
141
|
+
return await getInitialTestAccountsData();
|
|
149
142
|
}
|
|
150
143
|
}
|
|
151
144
|
return [];
|
|
@@ -179,39 +172,43 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
179
172
|
});
|
|
180
173
|
|
|
181
174
|
watcher = new AnvilTestWatcher(
|
|
182
|
-
new EthCheatCodes([l1RpcUrl]),
|
|
175
|
+
new EthCheatCodes([l1RpcUrl], dateProvider),
|
|
183
176
|
l1ContractAddresses.rollupAddress,
|
|
184
177
|
publicClient,
|
|
185
178
|
dateProvider,
|
|
186
179
|
);
|
|
187
|
-
watcher.
|
|
180
|
+
watcher.setisLocalNetwork(true);
|
|
188
181
|
await watcher.start();
|
|
189
182
|
}
|
|
190
183
|
|
|
191
|
-
const telemetry = initTelemetryClient(getTelemetryClientConfig());
|
|
192
|
-
// Create a local blob sink client inside the
|
|
184
|
+
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
185
|
+
// Create a local blob sink client inside the local network, no http connectivity
|
|
193
186
|
const blobSinkClient = createBlobSinkClient();
|
|
194
187
|
const node = await createAztecNode(
|
|
195
188
|
aztecNodeConfig,
|
|
196
189
|
{ telemetry, blobSinkClient, dateProvider },
|
|
197
190
|
{ prefilledPublicData },
|
|
198
191
|
);
|
|
199
|
-
const pxeServiceConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
200
|
-
const pxe = await createAztecPXE(node, pxeServiceConfig);
|
|
201
192
|
|
|
202
193
|
if (initialAccounts.length) {
|
|
194
|
+
const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
|
|
195
|
+
const wallet = await TestWallet.create(node, PXEConfig);
|
|
196
|
+
|
|
203
197
|
userLog('Setting up funded test accounts...');
|
|
204
|
-
const
|
|
205
|
-
const accountsWithSecrets =
|
|
206
|
-
account,
|
|
198
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, node, initialAccounts);
|
|
199
|
+
const accountsWithSecrets = accountManagers.map((manager, i) => ({
|
|
200
|
+
account: manager,
|
|
207
201
|
secretKey: initialAccounts[i].secret,
|
|
208
202
|
}));
|
|
209
|
-
const accLogs = await createAccountLogs(accountsWithSecrets,
|
|
203
|
+
const accLogs = await createAccountLogs(accountsWithSecrets, wallet);
|
|
210
204
|
userLog(accLogs.join(''));
|
|
211
205
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
await
|
|
206
|
+
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
207
|
+
|
|
208
|
+
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
209
|
+
|
|
210
|
+
// We no longer need the wallet once we've setup the accounts so we stop the underlying PXE job queue
|
|
211
|
+
await wallet.stop();
|
|
215
212
|
}
|
|
216
213
|
|
|
217
214
|
const stop = async () => {
|
|
@@ -219,7 +216,7 @@ export async function createSandbox(config: Partial<SandboxConfig> = {}, userLog
|
|
|
219
216
|
await watcher?.stop();
|
|
220
217
|
};
|
|
221
218
|
|
|
222
|
-
return { node,
|
|
219
|
+
return { node, stop };
|
|
223
220
|
}
|
|
224
221
|
|
|
225
222
|
/**
|
|
@@ -241,13 +238,3 @@ export async function createAztecNode(
|
|
|
241
238
|
const node = await AztecNodeService.createAndSync(aztecNodeConfig, deps, options);
|
|
242
239
|
return node;
|
|
243
240
|
}
|
|
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"}
|