@aztec/aztec 0.0.1-commit.181e2d196 → 0.0.1-commit.189eedb3
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 +36 -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 +26 -96
- 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 +43 -82
- package/dest/examples/token.js +4 -4
- package/dest/local-network/auth_registry.d.ts +5 -0
- package/dest/local-network/auth_registry.d.ts.map +1 -0
- package/dest/local-network/auth_registry.js +17 -0
- package/dest/local-network/banana_fpc.d.ts +3 -2
- package/dest/local-network/banana_fpc.d.ts.map +1 -1
- package/dest/local-network/banana_fpc.js +12 -8
- 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 +45 -15
- 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 +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 +26 -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 +35 -119
- 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 +47 -80
- package/src/examples/token.ts +6 -4
- package/src/local-network/auth_registry.ts +19 -0
- package/src/local-network/banana_fpc.ts +13 -9
- package/src/local-network/local-network.ts +45 -13
- 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
|
}
|
|
@@ -290,92 +291,58 @@ export async function preloadCrsDataForServerSideProving(
|
|
|
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,19 @@
|
|
|
1
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
3
|
+
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
4
|
+
import { AuthRegistryArtifact, getStandardAuthRegistry } from '@aztec/standard-contracts/auth-registry';
|
|
5
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
+
|
|
7
|
+
export async function publishStandardAuthRegistry(
|
|
8
|
+
wallet: Wallet,
|
|
9
|
+
from: AztecAddress,
|
|
10
|
+
waitOpts?: WaitOpts,
|
|
11
|
+
): Promise<void> {
|
|
12
|
+
const { instance, contractClass } = await getStandardAuthRegistry();
|
|
13
|
+
if (!(await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
14
|
+
await (await publishContractClass(wallet, AuthRegistryArtifact)).send({ from, wait: waitOpts });
|
|
15
|
+
}
|
|
16
|
+
if (!(await wallet.getContractMetadata(instance.address)).isContractPublished) {
|
|
17
|
+
await publishInstance(wallet, instance).send({ from, wait: waitOpts });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
|
|
2
|
+
import type { WaitOpts } from '@aztec/aztec.js/contracts';
|
|
2
3
|
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
3
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
5
|
import type { LogFn } from '@aztec/foundation/log';
|
|
@@ -45,19 +46,22 @@ export async function getBananaFPCAddress(initialAccounts: InitialAccountData[])
|
|
|
45
46
|
return (await getBananaFPCInstance(initialAccounts)).address;
|
|
46
47
|
}
|
|
47
48
|
|
|
48
|
-
export async function setupBananaFPC(
|
|
49
|
+
export async function setupBananaFPC(
|
|
50
|
+
initialAccounts: InitialAccountData[],
|
|
51
|
+
wallet: Wallet,
|
|
52
|
+
log: LogFn,
|
|
53
|
+
waitOpts?: WaitOpts,
|
|
54
|
+
) {
|
|
49
55
|
const bananaCoinAddress = await getBananaCoinAddress(initialAccounts);
|
|
50
56
|
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,
|
|
57
|
+
const [{ contract: bananaCoin }, { contract: fpc }] = await Promise.all([
|
|
58
|
+
TokenContract.deploy(wallet, admin, bananaCoinArgs.name, bananaCoinArgs.symbol, bananaCoinArgs.decimal, {
|
|
59
|
+
salt: BANANA_COIN_SALT,
|
|
55
60
|
universalDeploy: true,
|
|
56
|
-
}),
|
|
57
|
-
FPCContract.deploy(wallet, bananaCoinAddress, admin).send({
|
|
61
|
+
}).send({ from: admin, wait: waitOpts }),
|
|
62
|
+
FPCContract.deploy(wallet, bananaCoinAddress, admin, { salt: BANANA_FPC_SALT, universalDeploy: true }).send({
|
|
58
63
|
from: admin,
|
|
59
|
-
|
|
60
|
-
universalDeploy: true,
|
|
64
|
+
wait: waitOpts,
|
|
61
65
|
}),
|
|
62
66
|
]);
|
|
63
67
|
|
|
@@ -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';
|
|
@@ -21,7 +22,8 @@ import { protocolContractsHash } from '@aztec/protocol-contracts';
|
|
|
21
22
|
import { SequencerState } from '@aztec/sequencer-client';
|
|
22
23
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
23
24
|
import type { ProvingJobBroker } from '@aztec/stdlib/interfaces/server';
|
|
24
|
-
import
|
|
25
|
+
import { TxStatus } from '@aztec/stdlib/tx';
|
|
26
|
+
import type { GenesisData } from '@aztec/stdlib/world-state';
|
|
25
27
|
import {
|
|
26
28
|
type TelemetryClient,
|
|
27
29
|
getConfigEnvVars as getTelemetryClientConfig,
|
|
@@ -39,11 +41,19 @@ import { createAccountLogs } from '../cli/util.js';
|
|
|
39
41
|
import { DefaultMnemonic } from '../mnemonic.js';
|
|
40
42
|
import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
|
|
41
43
|
import { EpochTestSettler } from '../testing/epoch_test_settler.js';
|
|
44
|
+
import { getTokenAllowedSetupFunctions } from '../testing/token_allowed_setup.js';
|
|
45
|
+
import { publishStandardAuthRegistry } from './auth_registry.js';
|
|
42
46
|
import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
|
|
43
47
|
import { getSponsoredFPCAddress } from './sponsored_fpc.js';
|
|
44
48
|
|
|
45
49
|
const logger = createLogger('local-network');
|
|
46
50
|
|
|
51
|
+
// The embedded wallet defaults to waiting for PROPOSED, which returns as soon as a tx lands in a
|
|
52
|
+
// proposed L2 block. That is flaky for the serial sandbox setup below: a proposed block can be
|
|
53
|
+
// pruned before its checkpoint is published, dropping a tx we already moved on from ("Tx dropped by
|
|
54
|
+
// P2P node"). Wait for the checkpoint so each setup tx is durably included before the next is sent.
|
|
55
|
+
const setupWaitOpts = { waitForStatus: TxStatus.CHECKPOINTED };
|
|
56
|
+
|
|
47
57
|
const localAnvil = foundry;
|
|
48
58
|
|
|
49
59
|
/**
|
|
@@ -58,7 +68,7 @@ export async function deployContractsToL1(
|
|
|
58
68
|
genesisArchiveRoot?: Fr;
|
|
59
69
|
feeJuicePortalInitialBalance?: bigint;
|
|
60
70
|
} = {},
|
|
61
|
-
) {
|
|
71
|
+
): Promise<L1ContractAddresses> {
|
|
62
72
|
await waitForPublicClient(aztecNodeConfig);
|
|
63
73
|
|
|
64
74
|
const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
|
|
@@ -69,14 +79,14 @@ export async function deployContractsToL1(
|
|
|
69
79
|
genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
|
|
70
80
|
feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
|
|
71
81
|
aztecTargetCommitteeSize: 0, // no committee in local network
|
|
72
|
-
|
|
82
|
+
slasherEnabled: false, // no slashing in local network
|
|
73
83
|
realVerifier: false,
|
|
74
84
|
});
|
|
75
85
|
|
|
76
|
-
aztecNodeConfig
|
|
86
|
+
Object.assign(aztecNodeConfig, l1Contracts.l1ContractAddresses);
|
|
77
87
|
aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
|
|
78
88
|
|
|
79
|
-
return
|
|
89
|
+
return l1Contracts.l1ContractAddresses;
|
|
80
90
|
}
|
|
81
91
|
|
|
82
92
|
/** Local network settings. */
|
|
@@ -102,9 +112,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
102
112
|
logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
|
|
103
113
|
}
|
|
104
114
|
|
|
115
|
+
// The local network deploys a banana FPC with Token contracts, so include Token entries
|
|
116
|
+
// in the setup allowlist so FPC-based fee payments work out of the box.
|
|
117
|
+
const tokenAllowList = await getTokenAllowedSetupFunctions();
|
|
118
|
+
|
|
105
119
|
const aztecNodeConfig: AztecNodeConfig = {
|
|
106
120
|
...getConfigEnvVars(),
|
|
107
121
|
...config,
|
|
122
|
+
txPublicSetupAllowListExtend: [...tokenAllowList, ...(config.txPublicSetupAllowListExtend ?? [])],
|
|
108
123
|
};
|
|
109
124
|
const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
|
|
110
125
|
if (
|
|
@@ -145,7 +160,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
145
160
|
...(initialAccounts.length ? [bananaFPC, sponsoredFPC] : []),
|
|
146
161
|
...prefundAddresses,
|
|
147
162
|
];
|
|
148
|
-
const { genesisArchiveRoot,
|
|
163
|
+
const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(fundedAddresses);
|
|
149
164
|
|
|
150
165
|
const dateProvider = new TestDateProvider();
|
|
151
166
|
|
|
@@ -184,7 +199,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
184
199
|
const telemetry = await initTelemetryClient(getTelemetryClientConfig());
|
|
185
200
|
// Create a local blob client client inside the local network, no http connectivity
|
|
186
201
|
const blobClient = createBlobClient();
|
|
187
|
-
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, {
|
|
202
|
+
const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { genesis });
|
|
188
203
|
|
|
189
204
|
// Now that the node is up, let the watcher check for pending txs so it can skip unfilled slots faster when
|
|
190
205
|
// transactions are waiting in the mempool. Also let it check if the sequencer is actively building, to avoid
|
|
@@ -199,6 +214,21 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
199
214
|
SequencerState.SYNCHRONIZING,
|
|
200
215
|
]);
|
|
201
216
|
watcher?.setIsSequencerBuilding(() => !idleStates.has(sequencer.getState()));
|
|
217
|
+
// Under proposer pipelining the L1 publish for slot N happens during wall-clock slot N,
|
|
218
|
+
// but the proposer for slot N has already built the checkpoint during slot N-1 and is
|
|
219
|
+
// waiting for L1 to advance. We need to fast-forward L1 to wake that wait — and the wait
|
|
220
|
+
// we have to break first is `waitForValidParentCheckpointOnL1`, which blocks the
|
|
221
|
+
// checkpoint_proposal_job's background submission task until the archiver has synced past
|
|
222
|
+
// the build slot. That wait happens *before* `PUBLISHING_CHECKPOINT` is set, so a hook on
|
|
223
|
+
// that state transition would be circular (L1 has to advance before the state we'd use to
|
|
224
|
+
// advance L1 fires). The earliest pre-wait signal is `block-proposed`, which the sequencer
|
|
225
|
+
// emits once each block is built. In sandbox single-block-per-slot mode this is
|
|
226
|
+
// effectively "checkpoint built", and the watcher warp is harmless if a subsequent
|
|
227
|
+
// assembly/validation/parent-wait step aborts: L1 just sits one slot ahead, which the
|
|
228
|
+
// cascade absorbs.
|
|
229
|
+
if (watcher) {
|
|
230
|
+
sequencer.on('block-proposed', ({ slot }) => watcher!.setProposedTargetSlot(Number(slot)));
|
|
231
|
+
}
|
|
202
232
|
}
|
|
203
233
|
|
|
204
234
|
let epochTestSettler: EpochTestSettler | undefined;
|
|
@@ -220,11 +250,14 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
|
|
|
220
250
|
});
|
|
221
251
|
|
|
222
252
|
userLog('Setting up funded test accounts...');
|
|
223
|
-
const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts);
|
|
253
|
+
const accountManagers = await deployFundedSchnorrAccounts(wallet, initialAccounts, setupWaitOpts);
|
|
224
254
|
const accLogs = await createAccountLogs(accountManagers, wallet);
|
|
225
255
|
userLog(accLogs.join(''));
|
|
226
256
|
|
|
227
|
-
|
|
257
|
+
userLog('Publishing standard AuthRegistry contract...');
|
|
258
|
+
await publishStandardAuthRegistry(wallet, initialAccounts[0].address, setupWaitOpts);
|
|
259
|
+
|
|
260
|
+
await setupBananaFPC(initialAccounts, wallet, userLog, setupWaitOpts);
|
|
228
261
|
|
|
229
262
|
userLog(`SponsoredFPC: ${await getSponsoredFPCAddress()}`);
|
|
230
263
|
|
|
@@ -253,14 +286,13 @@ export async function createAztecNode(
|
|
|
253
286
|
dateProvider?: DateProvider;
|
|
254
287
|
proverBroker?: ProvingJobBroker;
|
|
255
288
|
} = {},
|
|
256
|
-
options: {
|
|
289
|
+
options: { genesis?: GenesisData } = {},
|
|
257
290
|
) {
|
|
258
291
|
// TODO(#12272): will clean this up. This is criminal.
|
|
259
|
-
|
|
292
|
+
// Not sure why this was ever done. Will be fixed in A-989, A-991, A-990.
|
|
260
293
|
const aztecNodeConfig: AztecNodeConfig = {
|
|
261
|
-
...
|
|
294
|
+
...getConfigEnvVars(),
|
|
262
295
|
...config,
|
|
263
|
-
l1Contracts: { ...l1Contracts, ...config.l1Contracts },
|
|
264
296
|
};
|
|
265
297
|
const node = await AztecNodeService.createAndSync(
|
|
266
298
|
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
|
}
|