@aztec/aztec 0.0.1-commit.96dac018d → 0.0.1-commit.993d240
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 +31 -14
- 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 +16 -17
- 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 +15 -9
- 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 +30 -0
- package/dest/cli/cmds/standby.d.ts.map +1 -0
- package/dest/cli/cmds/standby.js +97 -0
- package/dest/cli/cmds/start_bot.d.ts +1 -1
- package/dest/cli/cmds/start_bot.d.ts.map +1 -1
- package/dest/cli/cmds/start_bot.js +3 -3
- 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 +28 -40
- 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 +22 -13
- 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 +6 -5
- 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 +61 -0
- package/dest/cli/util.d.ts +3 -5
- package/dest/cli/util.d.ts.map +1 -1
- package/dest/cli/util.js +46 -85
- package/dest/examples/token.js +4 -4
- package/dest/local-network/auth_registry.d.ts +4 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +15 -0
- package/dest/local-network/banana_fpc.d.ts +1 -1
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +9 -7
- package/dest/local-network/local-network.d.ts +5 -28
- package/dest/local-network/local-network.d.ts.map +1 -1
- package/dest/local-network/local-network.js +44 -17
- package/dest/testing/anvil_test_watcher.d.ts +15 -3
- package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
- package/dest/testing/anvil_test_watcher.js +68 -14
- package/dest/testing/cheat_codes.d.ts +18 -17
- package/dest/testing/cheat_codes.d.ts.map +1 -1
- package/dest/testing/cheat_codes.js +72 -36
- 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 +9 -8
- 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 +35 -34
- package/scripts/add_crate.sh +53 -0
- package/scripts/aztec.sh +10 -3
- 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 +20 -14
- package/src/cli/aztec_start_options.ts +23 -25
- package/src/cli/cli.ts +3 -3
- package/src/cli/cmds/compile.ts +18 -10
- 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_bot.ts +3 -5
- package/src/cli/cmds/start_node.ts +43 -39
- package/src/cli/cmds/start_prover_agent.ts +5 -8
- package/src/cli/cmds/start_prover_broker.ts +23 -24
- package/src/cli/cmds/start_txe.ts +7 -5
- 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 +76 -0
- package/src/cli/util.ts +49 -82
- package/src/examples/token.ts +6 -4
- package/src/local-network/auth_registry.ts +14 -0
- package/src/local-network/banana_fpc.ts +5 -8
- package/src/local-network/local-network.ts +43 -14
- package/src/testing/anvil_test_watcher.ts +76 -13
- package/src/testing/cheat_codes.ts +92 -39
- package/src/testing/epoch_test_settler.ts +6 -8
- package/src/testing/index.ts +2 -1
- package/src/testing/token_allowed_setup.ts +19 -0
- package/dest/cli/cmds/start_archiver.d.ts +0 -9
- package/dest/cli/cmds/start_archiver.d.ts.map +0 -1
- package/dest/cli/cmds/start_archiver.js +0 -48
- 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/cmds/start_archiver.ts +0 -50
- 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
|
|
|
@@ -81,17 +82,17 @@ export async function createAccountLogs(accountManagers: AccountManager[], walle
|
|
|
81
82
|
accountLogStrings.push(` Address: ${completeAddress.address.toString()}\n`);
|
|
82
83
|
accountLogStrings.push(` Partial Address: ${completeAddress.partialAddress.toString()}\n`);
|
|
83
84
|
accountLogStrings.push(` Secret Key: ${account.getSecretKey().toString()}\n`);
|
|
85
|
+
accountLogStrings.push(` Master nullifier public key hash: ${completeAddress.publicKeys.npkMHash.toString()}\n`);
|
|
86
|
+
accountLogStrings.push(` Master incoming viewing public key: ${completeAddress.publicKeys.ivpkM.toString()}\n\n`);
|
|
84
87
|
accountLogStrings.push(
|
|
85
|
-
` Master
|
|
88
|
+
` Master outgoing viewing public key hash: ${completeAddress.publicKeys.ovpkMHash.toString()}\n\n`,
|
|
86
89
|
);
|
|
90
|
+
accountLogStrings.push(` Master tagging public key hash: ${completeAddress.publicKeys.tpkMHash.toString()}\n\n`);
|
|
87
91
|
accountLogStrings.push(
|
|
88
|
-
` Master
|
|
92
|
+
` Master message-signing public key hash: ${completeAddress.publicKeys.mspkMHash.toString()}\n\n`,
|
|
89
93
|
);
|
|
90
94
|
accountLogStrings.push(
|
|
91
|
-
` Master
|
|
92
|
-
);
|
|
93
|
-
accountLogStrings.push(
|
|
94
|
-
` Master tagging public key: ${completeAddress.publicKeys.masterTaggingPublicKey.toString()}\n\n`,
|
|
95
|
+
` Master fallback public key hash: ${completeAddress.publicKeys.fbpkMHash.toString()}\n\n`,
|
|
95
96
|
);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
@@ -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(),
|
|
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
|
|
342
|
+
logger.warn(`New ${name} version available`, { latestVersion, currentVersion });
|
|
357
343
|
});
|
|
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
|
|
376
|
-
});
|
|
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
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
2
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
|
+
import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
4
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
+
|
|
6
|
+
export async function publishStandardAuthRegistry(wallet: Wallet, from: AztecAddress): Promise<void> {
|
|
7
|
+
const { instance, contractClass } = await getStandardAuthRegistry();
|
|
8
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
9
|
+
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from });
|
|
10
|
+
}
|
|
11
|
+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
|
|
12
|
+
await publishInstance(wallet, instance).send({ from });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -48,16 +48,13 @@ 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([
|
|
52
|
-
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal
|
|
53
|
-
|
|
54
|
-
contractAddressSalt: BANANA_COIN_SALT,
|
|
51
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
52
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
|
|
53
|
+
salt: BANANA_COIN_SALT,
|
|
55
54
|
universalDeploy: true,
|
|
56
|
-
}),
|
|
57
|
-
FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
|
|
55
|
+
}).send({ from: admin }),
|
|
56
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
|
|
58
57
|
from: admin,
|
|
59
|
-
contractAddressSalt: BANANA_FPC_SALT,
|
|
60
|
-
universalDeploy: true,
|
|
61
58
|
}),
|
|
62
59
|
]);
|
|
63
60
|
|
|
@@ -11,6 +11,7 @@ import { waitForPublicClient } from '@aztec/ethereum/client';
|
|
|
11
11
|
import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
|
|
12
12
|
import { NULL_KEY } from '@aztec/ethereum/constants';
|
|
13
13
|
import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
|
|
14
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
14
15
|
import { EthCheatCodes } from '@aztec/ethereum/test';
|
|
15
16
|
import { SecretValue } from '@aztec/foundation/config';
|
|
16
17
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
@@ -19,8 +20,9 @@ import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
|
|
|
19
20
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
20
21
|
import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
21
22
|
import { SequencerState } from '@aztec/sequencer-client';
|
|
23
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
22
24
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
23
|
-
import type {
|
|
25
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
24
26
|
import {
|
|
25
27
|
type TelemetryClient,
|
|
26
28
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
@@ -38,6 +40,8 @@ import { createAccountLogs } from '../cli/util.js';
|
|
|
38
40
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
39
41
|
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
40
42
|
import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
43
|
+
import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
|
|
44
|
+
import { publishStandardAuthRegistry } from './auth_registry.js';
|
|
41
45
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
42
46
|
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
43
47
|
|
|
@@ -57,7 +61,7 @@ export async function deployContractsToL1(
|
|
|
57
61
|
genesisArchiveRoot?: Fr;
|
|
58
62
|
feeJuicePortalInitialBalance?: bigint;
|
|
59
63
|
} = {},
|
|
60
|
-
) {
|
|
64
|
+
): Promise<L1ContractAddresses> {
|
|
61
65
|
await waitForPublicClient(aztecNodeConfig);
|
|
62
66
|
|
|
63
67
|
const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
|
|
@@ -68,14 +72,14 @@ export async function deployContractsToL1(
|
|
|
68
72
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
69
73
|
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
70
74
|
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
71
|
-
|
|
75
|
+
slasherEnabled: false, // no slashing in local network
|
|
72
76
|
realVerifier: false,
|
|
73
77
|
});
|
|
74
78
|
|
|
75
|
-
aztecNodeConfig
|
|
79
|
+
Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
|
|
76
80
|
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
77
81
|
|
|
78
|
-
return
|
|
82
|
+
return l1Contracts.l1ContractAddresses;
|
|
79
83
|
}
|
|
80
84
|
|
|
81
85
|
/** Local network settings. */
|
|
@@ -101,9 +105,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
101
105
|
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
102
106
|
}
|
|
103
107
|
|
|
108
|
+
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
109
|
+
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
110
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
111
|
+
|
|
104
112
|
const aztecNodeConfig: AztecNodeConfig = {
|
|
105
113
|
...getConfigEnvVars(),
|
|
106
114
|
...config,
|
|
115
|
+
txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
|
|
107
116
|
};
|
|
108
117
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
109
118
|
if (
|
|
@@ -138,10 +147,13 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
138
147
|
|
|
139
148
|
const bananaFPC = await getBananaFPCAddress(initialAccounts);
|
|
140
149
|
const sponsoredFPC = await getSponsoredFPCAddress();
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
150
|
+
const prefundAddresses = (aztecNodeConfig.prefundAddresses ?? []).map(a => AztecAddress.fromString(a));
|
|
151
|
+
const fundedAddresses = [
|
|
152
|
+
...initialAccounts.map(a => a.address),
|
|
153
|
+
...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
|
|
154
|
+
...prefundAddresses,
|
|
155
|
+
];
|
|
156
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
145
157
|
|
|
146
158
|
const dateProvider = new TestDateProvider();
|
|
147
159
|
|
|
@@ -180,7 +192,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
180
192
|
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
181
193
|
// Create a local blob client client inside the local network, no http connectivity
|
|
182
194
|
const blobClient = createBlobClient();
|
|
183
|
-
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, {
|
|
195
|
+
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
|
|
184
196
|
|
|
185
197
|
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
186
198
|
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
@@ -195,6 +207,21 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
195
207
|
SequencerState.SYNCHRONIZING,
|
|
196
208
|
]);
|
|
197
209
|
watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
|
|
210
|
+
// Under proposer pipelining the L1 publish for slot N happens during wall-clock slot N,
|
|
211
|
+
// but the proposer for slot N has already built the checkpoint during slot N-1 and is
|
|
212
|
+
// waiting for L1 to advance. We need to fast-forward L1 to wake that wait — and the wait
|
|
213
|
+
// we have to break first is `waitForValidParentCheckpointOnL1`, which blocks the
|
|
214
|
+
// checkpoint_proposal_job's background submission task until the archiver has synced past
|
|
215
|
+
// the build slot. That wait happens *before* `PUBLISHING_CHECKPOINT` is set, so a hook on
|
|
216
|
+
// that state transition would be circular (L1 has to advance before the state we'd use to
|
|
217
|
+
// advance L1 fires). The earliest pre-wait signal is `block-proposed`, which the sequencer
|
|
218
|
+
// emits once each block is built. In sandbox single-block-per-slot mode this is
|
|
219
|
+
// effectively "checkpoint built", and the watcher warp is harmless if a subsequent
|
|
220
|
+
// assembly/validation/parent-wait step aborts: L1 just sits one slot ahead, which the
|
|
221
|
+
// cascade absorbs.
|
|
222
|
+
if (watcher) {
|
|
223
|
+
sequencer.on('block-proposed', ({ slot }) => watcher!.setProposedTargetSlot(Number(slot)));
|
|
224
|
+
}
|
|
198
225
|
}
|
|
199
226
|
|
|
200
227
|
let epochTestSettler: EpochTestSettler | undefined;
|
|
@@ -220,6 +247,9 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
220
247
|
const accLogs = await createAccountLogs(accountManagers, wallet);
|
|
221
248
|
userLog(accLogs.join(''));
|
|
222
249
|
|
|
250
|
+
userLog('Publishing standard AuthRegistry contract...');
|
|
251
|
+
await publishStandardAuthRegistry(wallet, initialAccounts[0].address);
|
|
252
|
+
|
|
223
253
|
await setupBananaFPC(initialAccounts, wallet, userLog);
|
|
224
254
|
|
|
225
255
|
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
@@ -249,14 +279,13 @@ export async function createAztecNode(
|
|
|
249
279
|
dateProvider?: DateProvider;
|
|
250
280
|
proverBroker?: ProvingJobBroker;
|
|
251
281
|
} = {},
|
|
252
|
-
options: {
|
|
282
|
+
options: { genesis?: GenesisData } = {},
|
|
253
283
|
) {
|
|
254
284
|
// TODO(#12272): will clean this up. This is criminal.
|
|
255
|
-
|
|
285
|
+
// Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
|
|
256
286
|
const aztecNodeConfig: AztecNodeConfig = {
|
|
257
|
-
...
|
|
287
|
+
...getConfigEnvVars(),
|
|
258
288
|
...config,
|
|
259
|
-
l1Contracts: { ...l1Contracts, ...config.l1Contracts },
|
|
260
289
|
};
|
|
261
290
|
const node = await AztecNodeService.createAndSync(
|
|
262
291
|
aztecNodeConfig,
|
|
@@ -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
|
|
|
@@ -40,11 +44,18 @@ export class AnvilTestWatcher {
|
|
|
40
44
|
// Tracks when we first observed the current unfilled slot with pending txs (real wall time).
|
|
41
45
|
private unfilledSlotFirstSeen?: { slot: number; realTime: number };
|
|
42
46
|
|
|
47
|
+
// Latest target slot for which the proposer has built a block destined for L1 but which has
|
|
48
|
+
// not yet been committed. Set by the proposer-pipelining hook from `block-proposed` events so
|
|
49
|
+
// the watcher can advance L1 (and the injected date provider) to the target slot ahead of the
|
|
50
|
+
// publisher's `sendRequestsAt` sleep, instead of waiting a full wall-clock slot.
|
|
51
|
+
private proposedTargetSlot?: number;
|
|
52
|
+
|
|
43
53
|
constructor(
|
|
44
54
|
private cheatcodes: EthCheatCodes,
|
|
45
55
|
rollupAddress: EthAddress,
|
|
46
56
|
l1Client: ViemClient,
|
|
47
57
|
private dateProvider?: TestDateProvider,
|
|
58
|
+
opts: AnvilTestWatcherOpts = {},
|
|
48
59
|
) {
|
|
49
60
|
this.rollup = getContract({
|
|
50
61
|
address: getAddress(rollupAddress.toString()),
|
|
@@ -56,6 +67,9 @@ export class AnvilTestWatcher {
|
|
|
56
67
|
rollupAddress,
|
|
57
68
|
});
|
|
58
69
|
|
|
70
|
+
this.isLocalNetwork = opts.isLocalNetwork ?? false;
|
|
71
|
+
this.isMarkingAsProven = opts.isMarkingAsProven ?? true;
|
|
72
|
+
|
|
59
73
|
this.logger.debug(`Watcher created for rollup at ${rollupAddress}`);
|
|
60
74
|
}
|
|
61
75
|
|
|
@@ -78,6 +92,18 @@ export class AnvilTestWatcher {
|
|
|
78
92
|
this.isSequencerBuilding = fn;
|
|
79
93
|
}
|
|
80
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Records the target slot for which the proposer has built a block destined for L1. Used by
|
|
97
|
+
* the local-network watcher to fast-forward L1 (and the injected date provider) ahead of the
|
|
98
|
+
* pipelined publisher's `sendRequestsAt` sleep so it ends promptly instead of waiting a full
|
|
99
|
+
* wall-clock slot. Only ratchets up — late warps for stale slots are no-ops.
|
|
100
|
+
*/
|
|
101
|
+
setProposedTargetSlot(slot: number) {
|
|
102
|
+
if (this.proposedTargetSlot === undefined || slot > this.proposedTargetSlot) {
|
|
103
|
+
this.proposedTargetSlot = slot;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
81
107
|
async start() {
|
|
82
108
|
if (this.filledRunningPromise) {
|
|
83
109
|
throw new Error('Watcher already watching for filled slot');
|
|
@@ -130,14 +156,21 @@ export class AnvilTestWatcher {
|
|
|
130
156
|
return;
|
|
131
157
|
}
|
|
132
158
|
|
|
133
|
-
const l1Time = (await this.cheatcodes.
|
|
159
|
+
const l1Time = (await this.cheatcodes.lastBlockTimestamp()) * 1000;
|
|
134
160
|
const wallTime = this.dateProvider.now();
|
|
135
161
|
if (l1Time > wallTime) {
|
|
136
162
|
this.logger.warn(`L1 is ahead of wall time. Syncing wall time to L1 time`);
|
|
137
163
|
this.dateProvider.setTime(l1Time);
|
|
138
164
|
} else if (l1Time + Number(this.l2SlotDuration) * 1000 < wallTime) {
|
|
139
|
-
|
|
140
|
-
|
|
165
|
+
// Warp L1 to the slot boundary at-or-before wall time. Rounding to a slot boundary (rather than
|
|
166
|
+
// `ceil(wallTime / 1000)`) keeps this loop's target aligned with `warpTimeIfNeeded`'s
|
|
167
|
+
// `nextSlotTimestamp` target, avoiding a race where the two loops pick timestamps a fraction of
|
|
168
|
+
// a second apart and one of them is then rejected by anvil as non-monotonic.
|
|
169
|
+
const wallSec = Math.floor(wallTime / 1000);
|
|
170
|
+
const targetSlot = await this.rollup.read.getSlotAt([BigInt(wallSec)]);
|
|
171
|
+
const targetTimestamp = Number(await this.rollup.read.getTimestampForSlot([targetSlot]));
|
|
172
|
+
this.logger.warn(`L1 is more than 1 L2 slot behind wall time. Warping to slot ${targetSlot} boundary`);
|
|
173
|
+
await this.warpToTimestamp(targetTimestamp);
|
|
141
174
|
}
|
|
142
175
|
}
|
|
143
176
|
|
|
@@ -151,8 +184,9 @@ export class AnvilTestWatcher {
|
|
|
151
184
|
|
|
152
185
|
if (BigInt(currentSlot) === checkpointLog.slotNumber) {
|
|
153
186
|
// The current slot has been filled, we should jump to the next slot.
|
|
154
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
155
|
-
|
|
187
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
188
|
+
this.logger.info(`Slot ${currentSlot} was filled, jumped to next slot`);
|
|
189
|
+
}
|
|
156
190
|
return;
|
|
157
191
|
}
|
|
158
192
|
|
|
@@ -161,6 +195,20 @@ export class AnvilTestWatcher {
|
|
|
161
195
|
return;
|
|
162
196
|
}
|
|
163
197
|
|
|
198
|
+
// Pipelined-publish shortcut: if the proposer has built a block destined for a slot
|
|
199
|
+
// beyond the current L1 slot, fast-forward L1 to that slot's timestamp so the publisher's
|
|
200
|
+
// `sendRequestsAt(targetSlot)` sleep ends and the multicall mines inside the target slot.
|
|
201
|
+
// Without this, the publisher waits up to a full real-time slot for wall clock to catch up.
|
|
202
|
+
if (this.proposedTargetSlot !== undefined && this.proposedTargetSlot > currentSlot) {
|
|
203
|
+
const targetSlotTimestamp = Number(
|
|
204
|
+
await this.rollup.read.getTimestampForSlot([BigInt(this.proposedTargetSlot)]),
|
|
205
|
+
);
|
|
206
|
+
if (await this.warpToTimestamp(targetSlotTimestamp)) {
|
|
207
|
+
this.logger.info(`Warped L1 to target slot ${this.proposedTargetSlot} for pipelined publish`);
|
|
208
|
+
}
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
|
|
164
212
|
// If there are pending txs and the sequencer missed them, warp quickly (after a 2s real-time debounce) so the
|
|
165
213
|
// sequencer can retry in the next slot. Without this, we'd have to wait a full real-time slot duration (~36s) for
|
|
166
214
|
// the dateProvider to catch up to the next slot timestamp. We skip the warp if the sequencer is actively building
|
|
@@ -180,9 +228,10 @@ export class AnvilTestWatcher {
|
|
|
180
228
|
}
|
|
181
229
|
|
|
182
230
|
if (realNow - this.unfilledSlotFirstSeen.realTime > 2000) {
|
|
183
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
231
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
232
|
+
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
233
|
+
}
|
|
184
234
|
this.unfilledSlotFirstSeen = undefined;
|
|
185
|
-
this.logger.info(`Slot ${currentSlot} was missed with pending txs, jumped to next slot`);
|
|
186
235
|
}
|
|
187
236
|
|
|
188
237
|
return;
|
|
@@ -192,19 +241,33 @@ export class AnvilTestWatcher {
|
|
|
192
241
|
// Fallback: warp when the dateProvider time has passed the next slot timestamp.
|
|
193
242
|
const currentTimestamp = this.dateProvider?.now() ?? Date.now();
|
|
194
243
|
if (currentTimestamp > nextSlotTimestamp * 1000) {
|
|
195
|
-
await this.warpToTimestamp(nextSlotTimestamp)
|
|
196
|
-
|
|
244
|
+
if (await this.warpToTimestamp(nextSlotTimestamp)) {
|
|
245
|
+
this.logger.info(`Slot ${currentSlot} was missed, jumped to next slot`);
|
|
246
|
+
}
|
|
197
247
|
}
|
|
198
248
|
} catch {
|
|
199
249
|
this.logger.error('mineIfSlotFilled failed');
|
|
200
250
|
}
|
|
201
251
|
}
|
|
202
252
|
|
|
203
|
-
|
|
253
|
+
/**
|
|
254
|
+
* Warps L1 to `timestamp`, unless L1 is already at or past it. Returns true when a warp actually
|
|
255
|
+
* happened, false when skipped or on error. Callers use the return value to gate success logs.
|
|
256
|
+
*/
|
|
257
|
+
private async warpToTimestamp(timestamp: number): Promise<boolean> {
|
|
204
258
|
try {
|
|
259
|
+
// Anvil rejects evm_setNextBlockTimestamp values <= the current block's timestamp. The two
|
|
260
|
+
// watcher loops can race and pick targets a fraction of a second apart; skip here rather than
|
|
261
|
+
// letting the second one error out noisily.
|
|
262
|
+
const lastTimestamp = await this.cheatcodes.lastBlockTimestamp();
|
|
263
|
+
if (timestamp <= lastTimestamp) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
205
266
|
await this.cheatcodes.warp(timestamp, { resetBlockInterval: true });
|
|
267
|
+
return true;
|
|
206
268
|
} catch (e) {
|
|
207
269
|
this.logger.error(`Failed to warp to timestamp ${timestamp}: ${e}`);
|
|
270
|
+
return false;
|
|
208
271
|
}
|
|
209
272
|
}
|
|
210
273
|
}
|