@aztec/aztec 0.0.1-commit.358457c → 0.0.1-commit.3750d92a7
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 +2 -2
- 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 +26 -7
- 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 +9 -3
- package/dest/cli/cli.js +3 -3
- package/dest/cli/cmds/compile.d.ts +1 -1
- package/dest/cli/cmds/compile.d.ts.map +1 -1
- package/dest/cli/cmds/compile.js +9 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts +1 -1
- package/dest/cli/cmds/profile_flamegraph.d.ts.map +1 -1
- package/dest/cli/cmds/profile_flamegraph.js +2 -1
- package/dest/cli/cmds/profile_gates.d.ts +1 -1
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +2 -1
- package/dest/cli/cmds/standby.d.ts +32 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +97 -0
- package/dest/cli/cmds/start_archiver.d.ts +2 -2
- package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
- package/dest/cli/cmds/start_archiver.js +4 -2
- package/dest/cli/cmds/start_node.d.ts +3 -2
- package/dest/cli/cmds/start_node.d.ts.map +1 -1
- package/dest/cli/cmds/start_node.js +26 -36
- 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 +3 -15
- 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 +12 -6
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts +21 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.d.ts.map +1 -0
- package/dest/cli/cmds/utils/collect_crate_dirs.js +114 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts +10 -0
- package/dest/cli/cmds/utils/needs_recompile.d.ts.map +1 -0
- package/dest/cli/cmds/utils/needs_recompile.js +90 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts +4 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.d.ts.map +1 -0
- package/dest/cli/cmds/utils/warn_if_aztec_version_mismatch.js +41 -0
- package/dest/cli/util.d.ts +3 -5
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +40 -81
- package/dest/examples/token.js +4 -4
- package/dest/local-network/banana_fpc.js +1 -1
- package/dest/local-network/local-network.d.ts +3 -4
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +21 -8
- package/dest/testing/anvil_test_watcher.js +1 -1
- package/dest/testing/cheat_codes.d.ts +11 -15
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +34 -32
- package/dest/testing/epoch_test_settler.d.ts +1 -1
- package/dest/testing/epoch_test_settler.d.ts.map +1 -1
- package/dest/testing/epoch_test_settler.js +3 -4
- package/dest/testing/index.d.ts +2 -1
- package/dest/testing/index.d.ts.map +1 -1
- package/dest/testing/index.js +1 -0
- package/dest/testing/token_allowed_setup.d.ts +7 -0
- package/dest/testing/token_allowed_setup.d.ts.map +1 -0
- package/dest/testing/token_allowed_setup.js +20 -0
- package/package.json +34 -34
- package/scripts/add_crate.sh +102 -0
- package/scripts/aztec.sh +5 -2
- package/scripts/init.sh +15 -21
- package/scripts/new.sh +45 -22
- package/scripts/setup_workspace.sh +10 -66
- package/src/bin/index.ts +2 -2
- package/src/cli/aztec_start_action.ts +15 -7
- package/src/cli/aztec_start_options.ts +15 -5
- package/src/cli/cli.ts +3 -3
- package/src/cli/cmds/compile.ts +11 -1
- package/src/cli/cmds/profile_flamegraph.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +2 -1
- package/src/cli/cmds/standby.ts +132 -0
- package/src/cli/cmds/start_archiver.ts +8 -2
- package/src/cli/cmds/start_node.ts +40 -34
- package/src/cli/cmds/start_prover_agent.ts +3 -6
- package/src/cli/cmds/start_prover_broker.ts +14 -14
- package/src/cli/cmds/utils/collect_crate_dirs.ts +118 -0
- package/src/cli/cmds/utils/needs_recompile.ts +98 -0
- package/src/cli/cmds/utils/warn_if_aztec_version_mismatch.ts +54 -0
- package/src/cli/util.ts +43 -76
- package/src/examples/token.ts +6 -4
- package/src/local-network/banana_fpc.ts +1 -1
- package/src/local-network/local-network.ts +18 -8
- package/src/testing/anvil_test_watcher.ts +1 -1
- package/src/testing/cheat_codes.ts +42 -36
- package/src/testing/epoch_test_settler.ts +3 -4
- package/src/testing/index.ts +1 -0
- package/src/testing/token_allowed_setup.ts +19 -0
- package/dest/cli/release_version.d.ts +0 -2
- package/dest/cli/release_version.d.ts.map +0 -1
- package/dest/cli/release_version.js +0 -14
- package/src/cli/release_version.ts +0 -21
package/src/cli/util.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { AztecNodeConfig } from '@aztec/aztec-node';
|
|
2
2
|
import type { AccountManager } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import { getNetworkConfig } from '@aztec/cli/config';
|
|
4
|
+
import { RegistryContract } from '@aztec/ethereum/contracts';
|
|
3
5
|
import type { ViemClient } from '@aztec/ethereum/types';
|
|
4
|
-
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
5
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import type { ConfigMappingsType, NetworkNames } from '@aztec/foundation/config';
|
|
6
7
|
import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
7
8
|
import { type LogFn, createLogger } from '@aztec/foundation/log';
|
|
8
|
-
import type { SharedNodeConfig } from '@aztec/node-lib/config';
|
|
9
9
|
import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
|
|
10
|
-
import {
|
|
10
|
+
import { type VersionCheck, getPackageVersion } from '@aztec/stdlib/update-checker';
|
|
11
11
|
import type { EmbeddedWallet } from '@aztec/wallets/embedded';
|
|
12
12
|
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import type { Command } from 'commander';
|
|
15
|
+
import type { Hex } from 'viem';
|
|
15
16
|
|
|
16
17
|
import { type AztecStartOption, aztecStartOptions } from './aztec_start_options.js';
|
|
17
18
|
|
|
@@ -271,7 +272,7 @@ export async function preloadCrsDataForVerifying(
|
|
|
271
272
|
): Promise<void> {
|
|
272
273
|
if (realProofs) {
|
|
273
274
|
const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
|
|
274
|
-
await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16
|
|
275
|
+
await Promise.all([Crs.new(2 ** 1, undefined, log), GrumpkinCrs.new(2 ** 16, undefined, log)]);
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
|
|
@@ -286,96 +287,62 @@ export async function preloadCrsDataForServerSideProving(
|
|
|
286
287
|
): Promise<void> {
|
|
287
288
|
if (realProofs) {
|
|
288
289
|
const { Crs, GrumpkinCrs } = await import('@aztec/bb.js');
|
|
289
|
-
await Promise.all([Crs.new(2 ** 25
|
|
290
|
+
await Promise.all([Crs.new(2 ** 25, undefined, log), GrumpkinCrs.new(2 ** 18, undefined, log)]);
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
|
|
293
|
-
export async function
|
|
294
|
-
|
|
295
|
-
updatesLocation: URL,
|
|
294
|
+
export async function setupVersionChecker(
|
|
295
|
+
network: NetworkNames,
|
|
296
296
|
followsCanonicalRollup: boolean,
|
|
297
297
|
publicClient: ViemClient,
|
|
298
|
-
registryContractAddress: EthAddress,
|
|
299
298
|
signalHandlers: Array<() => Promise<void>>,
|
|
300
|
-
|
|
301
|
-
) {
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
publicClient,
|
|
307
|
-
registryContractAddress,
|
|
308
|
-
});
|
|
299
|
+
cacheDir?: string,
|
|
300
|
+
): Promise<void> {
|
|
301
|
+
const networkConfig = await getNetworkConfig(network, cacheDir);
|
|
302
|
+
if (!networkConfig) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
309
305
|
|
|
310
|
-
|
|
311
|
-
checker.on('newRollupVersion', async ({ latestVersion, currentVersion }) => {
|
|
312
|
-
if (isShuttingDown()) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
306
|
+
const { VersionChecker } = await import('@aztec/stdlib/update-checker');
|
|
315
307
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
308
|
+
const logger = createLogger('version_check');
|
|
309
|
+
const registry = new RegistryContract(publicClient, networkConfig.registryAddress as Hex);
|
|
320
310
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
311
|
+
const checks: Array<VersionCheck> = [];
|
|
312
|
+
checks.push({
|
|
313
|
+
name: 'node',
|
|
314
|
+
currentVersion: getPackageVersion() ?? 'unknown',
|
|
315
|
+
getLatestVersion: async () => {
|
|
316
|
+
const cfg = await getNetworkConfig(network, cacheDir);
|
|
317
|
+
return cfg?.nodeVersion;
|
|
318
|
+
},
|
|
327
319
|
});
|
|
328
320
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
321
|
+
if (followsCanonicalRollup) {
|
|
322
|
+
const getLatestVersion = async () => {
|
|
323
|
+
const version = (await registry.getRollupVersions()).at(-1);
|
|
324
|
+
return version !== undefined ? String(version) : undefined;
|
|
325
|
+
};
|
|
326
|
+
const currentVersion = await getLatestVersion();
|
|
327
|
+
if (currentVersion !== undefined) {
|
|
328
|
+
checks.push({
|
|
329
|
+
name: 'rollup',
|
|
330
|
+
currentVersion,
|
|
331
|
+
getLatestVersion,
|
|
332
|
+
});
|
|
339
333
|
}
|
|
340
|
-
}
|
|
334
|
+
}
|
|
341
335
|
|
|
342
|
-
|
|
343
|
-
checker.on('
|
|
336
|
+
const checker = new VersionChecker(checks, 600_000, logger);
|
|
337
|
+
checker.on('newVersion', ({ name, latestVersion, currentVersion }) => {
|
|
344
338
|
if (isShuttingDown()) {
|
|
345
339
|
return;
|
|
346
340
|
}
|
|
347
341
|
|
|
348
|
-
|
|
349
|
-
logger.warn(`Config change detected. Updating node`, config);
|
|
350
|
-
try {
|
|
351
|
-
await updateNodeConfig(config);
|
|
352
|
-
} catch (err) {
|
|
353
|
-
logger.warn('Failed to update config', { err });
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
// don't notify on these config changes
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
checker.on('updatePublicTelemetryConfig', config => {
|
|
360
|
-
if (autoUpdateMode === 'config' || autoUpdateMode === 'config-and-version') {
|
|
361
|
-
logger.warn(`Public telemetry config change detected. Updating telemetry client`, config);
|
|
362
|
-
try {
|
|
363
|
-
const publicIncludeMetrics: unknown = (config as any).publicIncludeMetrics;
|
|
364
|
-
if (Array.isArray(publicIncludeMetrics) && publicIncludeMetrics.every(m => typeof m === 'string')) {
|
|
365
|
-
getTelemetryClient().setExportedPublicTelemetry(publicIncludeMetrics);
|
|
366
|
-
}
|
|
367
|
-
const publicMetricsCollectFrom: unknown = (config as any).publicMetricsCollectFrom;
|
|
368
|
-
if (Array.isArray(publicMetricsCollectFrom) && publicMetricsCollectFrom.every(m => typeof m === 'string')) {
|
|
369
|
-
getTelemetryClient().setPublicTelemetryCollectFrom(publicMetricsCollectFrom);
|
|
370
|
-
}
|
|
371
|
-
} catch (err) {
|
|
372
|
-
logger.warn('Failed to update config', { err });
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// don't notify on these config changes
|
|
342
|
+
logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
|
|
376
343
|
});
|
|
377
|
-
|
|
378
344
|
checker.start();
|
|
345
|
+
signalHandlers.push(() => checker.stop());
|
|
379
346
|
}
|
|
380
347
|
|
|
381
348
|
export function stringifyConfig(config: object): string {
|
package/src/examples/token.ts
CHANGED
|
@@ -32,7 +32,9 @@ async function main() {
|
|
|
32
32
|
logger.info(`Fetched Alice and Bob accounts: ${alice.toString()}, ${bob.toString()}`);
|
|
33
33
|
|
|
34
34
|
logger.info('Deploying Token...');
|
|
35
|
-
const token = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
35
|
+
const { contract: token } = await TokenContract.deploy(wallet, alice, 'TokenName', 'TokenSymbol', 18).send({
|
|
36
|
+
from: alice,
|
|
37
|
+
});
|
|
36
38
|
logger.info('Token deployed');
|
|
37
39
|
|
|
38
40
|
// Mint tokens to Alice
|
|
@@ -41,7 +43,7 @@ async function main() {
|
|
|
41
43
|
|
|
42
44
|
logger.info(`${ALICE_MINT_BALANCE} tokens were successfully minted by Alice and transferred to private`);
|
|
43
45
|
|
|
44
|
-
const balanceAfterMint = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
46
|
+
const { result: balanceAfterMint } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
45
47
|
logger.info(`Tokens successfully minted. New Alice's balance: ${balanceAfterMint}`);
|
|
46
48
|
|
|
47
49
|
// We will now transfer tokens from Alice to Bob
|
|
@@ -49,10 +51,10 @@ async function main() {
|
|
|
49
51
|
await token.methods.transfer(bob, TRANSFER_AMOUNT).send({ from: alice });
|
|
50
52
|
|
|
51
53
|
// Check the new balances
|
|
52
|
-
const aliceBalance = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
54
|
+
const { result: aliceBalance } = await token.methods.balance_of_private(alice).simulate({ from: alice });
|
|
53
55
|
logger.info(`Alice's balance ${aliceBalance}`);
|
|
54
56
|
|
|
55
|
-
const bobBalance = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
57
|
+
const { result: bobBalance } = await token.methods.balance_of_private(bob).simulate({ from: bob });
|
|
56
58
|
logger.info(`Bob's balance ${bobBalance}`);
|
|
57
59
|
}
|
|
58
60
|
|
|
@@ -48,7 +48,7 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
48
48
|
export async function setupBananaFPC(initialAccounts: InitialAccountData[], wallet: Wallet, log: LogFn) {
|
|
49
49
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
50
50
|
const admin = getBananaAdmin(initialAccounts);
|
|
51
|
-
const [bananaCoin, fpc] = await Promise.all([
|
|
51
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
52
52
|
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal).send({
|
|
53
53
|
from: admin,
|
|
54
54
|
contractAddressSalt: BANANA_COIN_SALT,
|
|
@@ -19,8 +19,9 @@ import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
|
19
19
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
20
20
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
21
21
|
import { SequencerState } from '@aztec/sequencer-client';
|
|
22
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
22
23
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import type {
|
|
24
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
24
25
|
import {
|
|
25
26
|
type TelemetryClient,
|
|
26
27
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
@@ -38,6 +39,7 @@ import { createAccountLogs } from '../cli/util.js';
|
|
|
38
39
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
39
40
|
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
40
41
|
import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
42
|
+
import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
|
|
41
43
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
42
44
|
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
43
45
|
|
|
@@ -68,7 +70,7 @@ export async function deployContractsToL1(
|
|
|
68
70
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
69
71
|
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
70
72
|
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
71
|
-
|
|
73
|
+
slasherEnabled: false, // no slashing in local network
|
|
72
74
|
realVerifier: false,
|
|
73
75
|
});
|
|
74
76
|
|
|
@@ -101,9 +103,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
101
103
|
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
102
104
|
}
|
|
103
105
|
|
|
106
|
+
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
107
|
+
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
108
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
109
|
+
|
|
104
110
|
const aztecNodeConfig: AztecNodeConfig = {
|
|
105
111
|
...getConfigEnvVars(),
|
|
106
112
|
...config,
|
|
113
|
+
txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
|
|
107
114
|
};
|
|
108
115
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
109
116
|
if (
|
|
@@ -138,10 +145,13 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
138
145
|
|
|
139
146
|
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
140
147
|
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
|
|
149
|
+
const fundedAddresses = [
|
|
150
|
+
...initialAccounts.map(a => a.address),
|
|
151
|
+
...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
|
|
152
|
+
...prefundAddresses,
|
|
153
|
+
];
|
|
154
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
145
155
|
|
|
146
156
|
const dateProvider = new TestDateProvider();
|
|
147
157
|
|
|
@@ -180,7 +190,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
180
190
|
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
181
191
|
// Create a local blob client client inside the local network, no http connectivity
|
|
182
192
|
const blobClient = createBlobClient();
|
|
183
|
-
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, {
|
|
193
|
+
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
|
|
184
194
|
|
|
185
195
|
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
186
196
|
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
@@ -249,7 +259,7 @@ export async function createAztecNode(
|
|
|
249
259
|
dateProvider?: DateProvider;
|
|
250
260
|
proverBroker?: ProvingJobBroker;
|
|
251
261
|
} = {},
|
|
252
|
-
options: {
|
|
262
|
+
options: { genesis?: GenesisData } = {},
|
|
253
263
|
) {
|
|
254
264
|
// TODO(#12272): will clean this up. This is criminal.
|
|
255
265
|
const { l1Contracts, ...rest } = getConfigEnvVars();
|
|
@@ -130,7 +130,7 @@ export class AnvilTestWatcher {
|
|
|
130
130
|
return;
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
const l1Time = (await this.cheatcodes.
|
|
133
|
+
const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
|
|
134
134
|
const wallTime = this.dateProvider.now();
|
|
135
135
|
if (l1Time > wallTime) {
|
|
136
136
|
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
4
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import type {
|
|
6
|
-
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
5
|
+
import type { AztecNode, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* A class that provides utility functions for interacting with the chain.
|
|
@@ -12,6 +11,8 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
12
11
|
* codes, please consider whether it makes sense to just introduce new utils in your tests instead.
|
|
13
12
|
*/
|
|
14
13
|
export class CheatCodes {
|
|
14
|
+
private logger = createLogger('aztecjs:cheat_codes');
|
|
15
|
+
|
|
15
16
|
constructor(
|
|
16
17
|
/** Cheat codes for L1.*/
|
|
17
18
|
public eth: EthCheatCodes,
|
|
@@ -30,50 +31,55 @@ export class CheatCodes {
|
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Warps the L1 timestamp to a target timestamp and mines an L2 block that advances the L2 timestamp to at least
|
|
33
|
-
* the target timestamp.
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
37
|
-
* @param node - The Aztec node used to query if a new block has been mined.
|
|
34
|
+
* the target timestamp. If the target timestamp falls within the current L2 slot (which already has a block),
|
|
35
|
+
* the timestamp is automatically adjusted forward to the start of the next slot so that `mineBlock()` succeeds.
|
|
36
|
+
* @param node - The Aztec node used to force an empty block to be mined.
|
|
38
37
|
* @param targetTimestamp - The target timestamp to warp to (in seconds)
|
|
39
38
|
*/
|
|
40
|
-
async warpL2TimeAtLeastTo(
|
|
41
|
-
const
|
|
39
|
+
async warpL2TimeAtLeastTo(node: AztecNodeDebug, targetTimestamp: bigint | number) {
|
|
40
|
+
const targetBigInt = BigInt(targetTimestamp);
|
|
41
|
+
const currentTimestamp = BigInt(await this.eth.lastBlockTimestamp());
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
if (targetBigInt <= currentTimestamp) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} is not in the future (current L1 timestamp is ${currentTimestamp}).`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
45
48
|
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
const minTxsPerBlock = sequencer.getConfig().minTxsPerBlock;
|
|
49
|
-
sequencer.updateConfig({ minTxsPerBlock: 0 });
|
|
49
|
+
const currentSlot = await this.rollup.getSlot();
|
|
50
|
+
const targetSlot = await this.rollup.getSlotAt(targetBigInt);
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
async () => {
|
|
53
|
-
const newL2BlockNumber: BlockNumber = await node.getBlockNumber();
|
|
54
|
-
return newL2BlockNumber > currentL2BlockNumber;
|
|
55
|
-
},
|
|
56
|
-
'new block after warping L2 time',
|
|
57
|
-
36,
|
|
58
|
-
1,
|
|
59
|
-
);
|
|
52
|
+
let effectiveTimestamp = targetBigInt;
|
|
60
53
|
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
if (targetSlot <= currentSlot) {
|
|
55
|
+
// Target lands in the same (or earlier) slot — auto-adjust to the next slot's start.
|
|
56
|
+
const nextSlot = SlotNumber(currentSlot + 1);
|
|
57
|
+
const nextSlotTimestamp = await this.rollup.getTimestampForSlot(nextSlot);
|
|
58
|
+
this.logger.warn(
|
|
59
|
+
`warpL2TimeAtLeastTo: target timestamp ${targetBigInt} falls in current slot ${currentSlot}. ` +
|
|
60
|
+
`Auto-adjusting to start of slot ${nextSlot} at timestamp ${nextSlotTimestamp}.`,
|
|
61
|
+
);
|
|
62
|
+
effectiveTimestamp = nextSlotTimestamp;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
await this.eth.warp(effectiveTimestamp, { resetBlockInterval: true });
|
|
66
|
+
await node.mineBlock();
|
|
63
67
|
}
|
|
64
68
|
|
|
65
69
|
/**
|
|
66
70
|
* Warps the L1 timestamp forward by a specified duration and mines an L2 block that advances the L2 timestamp at
|
|
67
|
-
* least by the duration.
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* @param sequencerClient - The sequencer client to use to force an empty block to be mined.
|
|
71
|
-
* @param node - The Aztec node used to query if a new block has been mined.
|
|
71
|
+
* least by the duration. If the duration is too short to cross an L2 slot boundary, the warp is automatically
|
|
72
|
+
* extended to the start of the next slot so that `mineBlock()` succeeds.
|
|
73
|
+
* @param node - The Aztec node used to force an empty block to be mined.
|
|
72
74
|
* @param duration - The duration to advance time by (in seconds)
|
|
73
75
|
*/
|
|
74
|
-
async warpL2TimeAtLeastBy(
|
|
75
|
-
|
|
76
|
+
async warpL2TimeAtLeastBy(node: AztecNodeDebug, duration: bigint | number) {
|
|
77
|
+
if (BigInt(duration) <= 0n) {
|
|
78
|
+
throw new Error(`warpL2TimeAtLeastBy: duration must be positive, got ${duration} seconds.`);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const currentTimestamp = await this.eth.lastBlockTimestamp();
|
|
76
82
|
const targetTimestamp = BigInt(currentTimestamp) + BigInt(duration);
|
|
77
|
-
await this.warpL2TimeAtLeastTo(
|
|
83
|
+
await this.warpL2TimeAtLeastTo(node, targetTimestamp);
|
|
78
84
|
}
|
|
79
85
|
}
|
|
@@ -4,7 +4,7 @@ import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
|
4
4
|
import type { Logger } from '@aztec/foundation/log';
|
|
5
5
|
import { EpochMonitor } from '@aztec/prover-node';
|
|
6
6
|
import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
|
|
7
|
-
import {
|
|
7
|
+
import { computeEpochOutHash } from '@aztec/stdlib/messaging';
|
|
8
8
|
|
|
9
9
|
export class EpochTestSettler {
|
|
10
10
|
private rollupCheatCodes: RollupCheatCodes;
|
|
@@ -51,9 +51,8 @@ export class EpochTestSettler {
|
|
|
51
51
|
messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
const { root: outHash } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, firstMessage);
|
|
54
|
+
const outHash = computeEpochOutHash(messagesInEpoch);
|
|
55
|
+
if (!outHash.isZero()) {
|
|
57
56
|
await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
|
|
58
57
|
} else {
|
|
59
58
|
this.log.info(`No L2 to L1 messages in epoch ${epoch}`);
|
package/src/testing/index.ts
CHANGED
|
@@ -2,3 +2,4 @@ export { AnvilTestWatcher } from './anvil_test_watcher.js';
|
|
|
2
2
|
export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
|
|
3
3
|
export { CheatCodes } from './cheat_codes.js';
|
|
4
4
|
export { EpochTestSettler } from './epoch_test_settler.js';
|
|
5
|
+
export { getTokenAllowedSetupFunctions } from './token_allowed_setup.js';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token';
|
|
2
|
+
import { buildAllowedElement } from '@aztec/p2p/msg_validators';
|
|
3
|
+
import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
4
|
+
import type { AllowedElement } from '@aztec/stdlib/interfaces/server';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Returns Token-specific allowlist entries needed for FPC-based fee payments.
|
|
8
|
+
* These are test-only: FPC-based fee payment with custom tokens won't work on mainnet alpha.
|
|
9
|
+
*/
|
|
10
|
+
export async function getTokenAllowedSetupFunctions(): Promise<AllowedElement[]> {
|
|
11
|
+
const tokenClassId = (await getContractClassFromArtifact(TokenContractArtifact)).id;
|
|
12
|
+
const target = { classId: tokenClassId };
|
|
13
|
+
return Promise.all([
|
|
14
|
+
// Token: needed for private transfers via FPC (transfer_to_public enqueues this)
|
|
15
|
+
buildAllowedElement(TokenContractArtifact, target, '_increase_public_balance', { onlySelf: true }),
|
|
16
|
+
// Token: needed for public transfers via FPC (fee_entrypoint_public enqueues this)
|
|
17
|
+
buildAllowedElement(TokenContractArtifact, target, 'transfer_in_public'),
|
|
18
|
+
]);
|
|
19
|
+
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const getCliVersion: () => any;
|
|
2
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVsZWFzZV92ZXJzaW9uLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY2xpL3JlbGVhc2VfdmVyc2lvbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxlQUFPLE1BQU0sYUFBYSxXQWV6QixDQUFDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release_version.d.ts","sourceRoot":"","sources":["../../src/cli/release_version.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,aAAa,WAezB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
2
|
-
import { readFileSync } from 'fs';
|
|
3
|
-
import { dirname, resolve } from 'path';
|
|
4
|
-
export const getCliVersion = ()=>{
|
|
5
|
-
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
|
|
6
|
-
const cliVersion = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
7
|
-
// If the version is 0.1.0, this is a placeholder version and we are in a docker container; query release please for the latest version
|
|
8
|
-
if (cliVersion === '0.1.0') {
|
|
9
|
-
const releasePleasePath = resolve(dirname(fileURLToPath(import.meta.url)), '../../../../.release-please-manifest.json');
|
|
10
|
-
const releaseVersion = JSON.parse(readFileSync(releasePleasePath).toString())['.'];
|
|
11
|
-
return releaseVersion;
|
|
12
|
-
}
|
|
13
|
-
return cliVersion;
|
|
14
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
2
|
-
|
|
3
|
-
import { readFileSync } from 'fs';
|
|
4
|
-
import { dirname, resolve } from 'path';
|
|
5
|
-
|
|
6
|
-
export const getCliVersion = () => {
|
|
7
|
-
const packageJsonPath = resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json');
|
|
8
|
-
const cliVersion: string = JSON.parse(readFileSync(packageJsonPath).toString()).version;
|
|
9
|
-
|
|
10
|
-
// If the version is 0.1.0, this is a placeholder version and we are in a docker container; query release please for the latest version
|
|
11
|
-
if (cliVersion === '0.1.0') {
|
|
12
|
-
const releasePleasePath = resolve(
|
|
13
|
-
dirname(fileURLToPath(import.meta.url)),
|
|
14
|
-
'../../../../.release-please-manifest.json',
|
|
15
|
-
);
|
|
16
|
-
const releaseVersion = JSON.parse(readFileSync(releasePleasePath).toString())['.'];
|
|
17
|
-
return releaseVersion;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return cliVersion;
|
|
21
|
-
};
|