@aztec/aztec 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8
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 +28 -10
- 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 +15 -9
- 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 +10 -15
- package/dest/cli/cmds/profile.d.ts +1 -1
- package/dest/cli/cmds/profile.d.ts.map +1 -1
- package/dest/cli/cmds/profile.js +1 -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 +2 -2
- package/dest/cli/cmds/profile_gates.d.ts.map +1 -1
- package/dest/cli/cmds/profile_gates.js +23 -4
- 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 +5 -17
- 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 +14 -8
- package/dest/cli/cmds/start_txe.d.ts +2 -2
- package/dest/cli/cmds/start_txe.d.ts.map +1 -1
- package/dest/cli/cmds/start_txe.js +4 -3
- 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 +62 -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.d.ts +7 -3
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +40 -14
- 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 +3 -2
- 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 +52 -0
- package/scripts/aztec.sh +9 -2
- package/scripts/init.sh +18 -24
- package/scripts/new.sh +45 -22
- package/scripts/setup_workspace.sh +12 -67
- package/scripts/templates/blank/contract/Nargo.toml +6 -0
- package/scripts/templates/blank/contract/src/main.nr +10 -0
- package/scripts/templates/blank/test/Nargo.toml +7 -0
- package/scripts/templates/blank/test/src/lib.nr +11 -0
- package/scripts/templates/counter/contract/Nargo.toml +7 -0
- package/scripts/templates/counter/contract/src/main.nr +48 -0
- package/scripts/templates/counter/test/Nargo.toml +7 -0
- package/scripts/templates/counter/test/src/lib.nr +32 -0
- package/src/bin/index.ts +2 -2
- package/src/cli/aztec_start_action.ts +17 -10
- package/src/cli/aztec_start_options.ts +22 -14
- package/src/cli/cli.ts +3 -3
- package/src/cli/cmds/compile.ts +12 -18
- package/src/cli/cmds/profile.ts +2 -1
- package/src/cli/cmds/profile_flamegraph.ts +2 -1
- package/src/cli/cmds/profile_gates.ts +22 -5
- 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 +5 -8
- package/src/cli/cmds/start_prover_broker.ts +16 -16
- package/src/cli/cmds/start_txe.ts +5 -3
- 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 +77 -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 +44 -13
- package/src/testing/cheat_codes.ts +42 -36
- package/src/testing/epoch_test_settler.ts +3 -4
- package/src/testing/index.ts +2 -1
- 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();
|
|
@@ -9,6 +9,11 @@ import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
|
9
9
|
|
|
10
10
|
import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
11
11
|
|
|
12
|
+
export type AnvilTestWatcherOpts = {
|
|
13
|
+
isLocalNetwork?: boolean;
|
|
14
|
+
isMarkingAsProven?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
12
17
|
/**
|
|
13
18
|
* Represents a watcher for a rollup contract.
|
|
14
19
|
*
|
|
@@ -17,7 +22,8 @@ import { type GetContractReturnType, getAddress, getContract } from 'viem';
|
|
|
17
22
|
* block within the slot. And if so, it will time travel into the next slot.
|
|
18
23
|
*/
|
|
19
24
|
export class AnvilTestWatcher {
|
|
20
|
-
private isLocalNetwork
|
|
25
|
+
private isLocalNetwork;
|
|
26
|
+
private isMarkingAsProven;
|
|
21
27
|
|
|
22
28
|
private rollup: GetContractReturnType<typeof RollupAbi, ViemClient>;
|
|
23
29
|
private rollupCheatCodes: RollupCheatCodes;
|
|
@@ -29,8 +35,6 @@ export class AnvilTestWatcher {
|
|
|
29
35
|
|
|
30
36
|
private logger: Logger = createLogger(`aztecjs:utils:watcher`);
|
|
31
37
|
|
|
32
|
-
private isMarkingAsProven = true;
|
|
33
|
-
|
|
34
38
|
// Optional callback to check if there are pending txs in the mempool.
|
|
35
39
|
private getPendingTxCount?: () => Promise<number>;
|
|
36
40
|
|
|
@@ -45,6 +49,7 @@ export class AnvilTestWatcher {
|
|
|
45
49
|
rollupAddress: EthAddress,
|
|
46
50
|
l1Client: ViemClient,
|
|
47
51
|
private dateProvider?: TestDateProvider,
|
|
52
|
+
opts: AnvilTestWatcherOpts = {},
|
|
48
53
|
) {
|
|
49
54
|
this.rollup = getContract({
|
|
50
55
|
address: getAddress(rollupAddress.toString()),
|
|
@@ -56,6 +61,9 @@ export class AnvilTestWatcher {
|
|
|
56
61
|
rollupAddress,
|
|
57
62
|
});
|
|
58
63
|
|
|
64
|
+
this.isLocalNetwork = opts.isLocalNetwork ?? false;
|
|
65
|
+
this.isMarkingAsProven = opts.isMarkingAsProven ?? true;
|
|
66
|
+
|
|
59
67
|
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
60
68
|
}
|
|
61
69
|
|
|
@@ -130,14 +138,21 @@ export class AnvilTestWatcher {
|
|
|
130
138
|
return;
|
|
131
139
|
}
|
|
132
140
|
|
|
133
|
-
const l1Time = (await this.cheatcodes.
|
|
141
|
+
const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
|
|
134
142
|
const wallTime = this.dateProvider.now();
|
|
135
143
|
if (l1Time > wallTime) {
|
|
136
144
|
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
137
145
|
this.dateProvider.setTime(l1Time);
|
|
138
146
|
} else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
|
|
139
|
-
|
|
140
|
-
|
|
147
|
+
// Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
|
|
148
|
+
// `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
|
|
149
|
+
// `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
|
|
150
|
+
// a second apart and one of them is then rejected by anvil as non-monotonic.
|
|
151
|
+
const wallSec = Math.floor(wallTime / 1000);
|
|
152
|
+
const targetSlot = await this.rollup.read.getSlotAt([BigInt(wallSec)]);
|
|
153
|
+
const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([targetSlot]));
|
|
154
|
+
this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
|
|
155
|
+
await this.warpToTimestamp(targetTimestamp);
|
|
141
156
|
}
|
|
142
157
|
}
|
|
143
158
|
|
|
@@ -151,8 +166,9 @@ export class AnvilTestWatcher {
|
|
|
151
166
|
|
|
152
167
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
153
168
|
// The current slot has been filled, we should jump to the next slot.
|
|
154
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
155
|
-
|
|
169
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
170
|
+
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
171
|
+
}
|
|
156
172
|
return;
|
|
157
173
|
}
|
|
158
174
|
|
|
@@ -180,9 +196,10 @@ export class AnvilTestWatcher {
|
|
|
180
196
|
}
|
|
181
197
|
|
|
182
198
|
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
183
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
199
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
200
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
201
|
+
}
|
|
184
202
|
this.unfilledSlotFirstSeen = undefined;
|
|
185
|
-
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
186
203
|
}
|
|
187
204
|
|
|
188
205
|
return;
|
|
@@ -192,19 +209,33 @@ export class AnvilTestWatcher {
|
|
|
192
209
|
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
193
210
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
194
211
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
195
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
196
|
-
|
|
212
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
213
|
+
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
214
|
+
}
|
|
197
215
|
}
|
|
198
216
|
} catch {
|
|
199
217
|
this.logger.error('mineIfSlotFilled failed');
|
|
200
218
|
}
|
|
201
219
|
}
|
|
202
220
|
|
|
203
|
-
|
|
221
|
+
/**
|
|
222
|
+
* Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
|
|
223
|
+
* happened, false when skipped or on error. Callers use the return value to gate success logs.
|
|
224
|
+
*/
|
|
225
|
+
private async warpToTimestamp(timestamp: number): Promise<boolean> {
|
|
204
226
|
try {
|
|
227
|
+
// Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
|
|
228
|
+
// watcher loops can race and pick targets a fraction of a second apart; skip here rather than
|
|
229
|
+
// letting the second one error out noisily.
|
|
230
|
+
const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
|
|
231
|
+
if (timestamp <= lastTimestamp) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
205
234
|
await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
|
|
235
|
+
return true;
|
|
206
236
|
} catch (e) {
|
|
207
237
|
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
238
|
+
return false;
|
|
208
239
|
}
|
|
209
240
|
}
|
|
210
241
|
}
|
|
@@ -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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { AnvilTestWatcher } from './anvil_test_watcher.js';
|
|
1
|
+
export { AnvilTestWatcher, type AnvilTestWatcherOpts } 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
|
-
};
|