@aztec/aztec 0.0.1-commit.d3ec352c → 0.0.1-commit.f295ac2

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.
Files changed (68) hide show
  1. package/dest/bin/index.js +5 -2
  2. package/dest/cli/aztec_start_action.d.ts +1 -1
  3. package/dest/cli/aztec_start_action.d.ts.map +1 -1
  4. package/dest/cli/aztec_start_action.js +6 -5
  5. package/dest/cli/aztec_start_options.d.ts +1 -1
  6. package/dest/cli/aztec_start_options.d.ts.map +1 -1
  7. package/dest/cli/aztec_start_options.js +12 -25
  8. package/dest/cli/cli.d.ts +1 -1
  9. package/dest/cli/cli.d.ts.map +1 -1
  10. package/dest/cli/cli.js +5 -37
  11. package/dest/cli/cmds/migrate_ha_db.d.ts +3 -0
  12. package/dest/cli/cmds/migrate_ha_db.d.ts.map +1 -0
  13. package/dest/cli/cmds/migrate_ha_db.js +27 -0
  14. package/dest/cli/cmds/start_archiver.d.ts +1 -1
  15. package/dest/cli/cmds/start_archiver.d.ts.map +1 -1
  16. package/dest/cli/cmds/start_archiver.js +11 -13
  17. package/dest/cli/cmds/start_bot.js +1 -1
  18. package/dest/cli/cmds/start_node.js +2 -2
  19. package/dest/cli/cmds/start_p2p_bootstrap.js +1 -1
  20. package/dest/cli/cmds/start_prover_agent.d.ts +1 -1
  21. package/dest/cli/cmds/start_prover_agent.d.ts.map +1 -1
  22. package/dest/cli/cmds/start_prover_agent.js +2 -2
  23. package/dest/cli/cmds/start_prover_broker.js +2 -2
  24. package/dest/cli/cmds/start_prover_node.js +2 -2
  25. package/dest/cli/util.d.ts +5 -5
  26. package/dest/cli/util.d.ts.map +1 -1
  27. package/dest/cli/util.js +3 -3
  28. package/dest/examples/util.d.ts +2 -2
  29. package/dest/examples/util.d.ts.map +1 -1
  30. package/dest/local-network/banana_fpc.js +1 -1
  31. package/dest/local-network/local-network.d.ts +10 -12
  32. package/dest/local-network/local-network.d.ts.map +1 -1
  33. package/dest/local-network/local-network.js +35 -23
  34. package/dest/testing/anvil_test_watcher.d.ts +2 -2
  35. package/dest/testing/anvil_test_watcher.d.ts.map +1 -1
  36. package/dest/testing/cheat_codes.d.ts +3 -1
  37. package/dest/testing/cheat_codes.d.ts.map +1 -1
  38. package/dest/testing/epoch_test_settler.d.ts +17 -0
  39. package/dest/testing/epoch_test_settler.d.ts.map +1 -0
  40. package/dest/testing/epoch_test_settler.js +52 -0
  41. package/dest/testing/index.d.ts +2 -1
  42. package/dest/testing/index.d.ts.map +1 -1
  43. package/dest/testing/index.js +1 -0
  44. package/package.json +35 -33
  45. package/scripts/aztec.sh +13 -6
  46. package/src/bin/index.ts +6 -2
  47. package/src/cli/aztec_start_action.ts +5 -4
  48. package/src/cli/aztec_start_options.ts +12 -26
  49. package/src/cli/cli.ts +5 -37
  50. package/src/cli/cmds/migrate_ha_db.ts +43 -0
  51. package/src/cli/cmds/start_archiver.ts +7 -18
  52. package/src/cli/cmds/start_bot.ts +1 -1
  53. package/src/cli/cmds/start_node.ts +2 -2
  54. package/src/cli/cmds/start_p2p_bootstrap.ts +1 -1
  55. package/src/cli/cmds/start_prover_agent.ts +2 -10
  56. package/src/cli/cmds/start_prover_broker.ts +2 -2
  57. package/src/cli/cmds/start_prover_node.ts +2 -2
  58. package/src/cli/util.ts +7 -7
  59. package/src/examples/util.ts +1 -1
  60. package/src/local-network/banana_fpc.ts +1 -1
  61. package/src/local-network/local-network.ts +63 -67
  62. package/src/testing/anvil_test_watcher.ts +1 -1
  63. package/src/testing/epoch_test_settler.ts +59 -0
  64. package/src/testing/index.ts +1 -0
  65. package/dest/cli/cmds/start_blob_sink.d.ts +0 -3
  66. package/dest/cli/cmds/start_blob_sink.d.ts.map +0 -1
  67. package/dest/cli/cmds/start_blob_sink.js +0 -33
  68. package/src/cli/cmds/start_blob_sink.ts +0 -57
@@ -0,0 +1,43 @@
1
+ import { runMigrations } from '@aztec/validator-ha-signer/migrations';
2
+
3
+ import type { Command } from 'commander';
4
+
5
+ export function injectMigrateCommand(program: Command, log: (msg: string) => void): Command {
6
+ const migrateCommand = program.command('migrate-ha-db').description('Run validator-ha-signer database migrations');
7
+
8
+ migrateCommand
9
+ .command('up')
10
+ .description('Apply pending migrations')
11
+ .requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL)
12
+ .option('--verbose', 'Enable verbose output', false)
13
+ .action(async options => {
14
+ const migrations = await runMigrations(options.databaseUrl, {
15
+ direction: 'up',
16
+ verbose: options.verbose,
17
+ });
18
+ if (migrations.length > 0) {
19
+ log(`Applied migrations: ${migrations.join(', ')}`);
20
+ } else {
21
+ log('No migrations to apply - schema is up to date');
22
+ }
23
+ });
24
+
25
+ migrateCommand
26
+ .command('down')
27
+ .description('Rollback the last migration')
28
+ .requiredOption('--database-url <string>', 'PostgreSQL connection string', process.env.DATABASE_URL)
29
+ .option('--verbose', 'Enable verbose output', false)
30
+ .action(async options => {
31
+ const migrations = await runMigrations(options.databaseUrl, {
32
+ direction: 'down',
33
+ verbose: options.verbose,
34
+ });
35
+ if (migrations.length > 0) {
36
+ log(`Rolled back migrations: ${migrations.join(', ')}`);
37
+ } else {
38
+ log('No migrations to rollback');
39
+ }
40
+ });
41
+
42
+ return program;
43
+ }
@@ -1,16 +1,9 @@
1
- import {
2
- Archiver,
3
- type ArchiverConfig,
4
- KVArchiverDataStore,
5
- archiverConfigMappings,
6
- getArchiverConfigFromEnv,
7
- } from '@aztec/archiver';
1
+ import { type ArchiverConfig, archiverConfigMappings, createArchiver, getArchiverConfigFromEnv } from '@aztec/archiver';
8
2
  import { createLogger } from '@aztec/aztec.js/log';
9
- import { type BlobSinkConfig, blobSinkConfigMapping, createBlobSinkClient } from '@aztec/blob-sink/client';
3
+ import { type BlobClientConfig, blobClientConfigMapping, createBlobClient } from '@aztec/blob-client/client';
10
4
  import { getL1Config } from '@aztec/cli/config';
11
5
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
12
6
  import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
13
- import { createStore } from '@aztec/kv-store/lmdb-v2';
14
7
  import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server';
15
8
  import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
16
9
 
@@ -25,9 +18,9 @@ export async function startArchiver(
25
18
  services: NamespacedApiHandlers,
26
19
  ): Promise<{ config: ArchiverConfig & DataStoreConfig }> {
27
20
  const envConfig = getArchiverConfigFromEnv();
28
- const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobSinkConfig>(
21
+ const cliOptions = extractRelevantOptions<ArchiverConfig & DataStoreConfig & BlobClientConfig>(
29
22
  options,
30
- { ...archiverConfigMappings, ...dataConfigMappings, ...blobSinkConfigMapping },
23
+ { ...archiverConfigMappings, ...dataConfigMappings, ...blobClientConfigMapping },
31
24
  'archiver',
32
25
  );
33
26
 
@@ -47,13 +40,9 @@ export async function startArchiver(
47
40
  archiverConfig.l1Contracts = addresses;
48
41
  archiverConfig = { ...archiverConfig, ...l1Config };
49
42
 
50
- const storeLog = createLogger('archiver:lmdb');
51
- const store = await createStore('archiver', KVArchiverDataStore.SCHEMA_VERSION, archiverConfig, storeLog);
52
- const archiverStore = new KVArchiverDataStore(store, archiverConfig.maxLogs);
53
-
54
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
55
- const blobSinkClient = createBlobSinkClient(archiverConfig, { logger: createLogger('archiver:blob-sink:client') });
56
- const archiver = await Archiver.createAndSync(archiverConfig, archiverStore, { telemetry, blobSinkClient }, true);
43
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
44
+ const blobClient = createBlobClient(archiverConfig, { logger: createLogger('archiver:blob-client:client') });
45
+ const archiver = await createArchiver(archiverConfig, { telemetry, blobClient }, { blockUntilSync: true });
57
46
  services.archiver = [archiver, ArchiverApiSchema];
58
47
  signalHandlers.push(archiver.stop);
59
48
 
@@ -40,7 +40,7 @@ export async function startBot(
40
40
  const pxeConfig = extractRelevantOptions<PXEConfig & CliPXEOptions>(options, allPxeConfigMappings, 'pxe');
41
41
  const wallet = await TestWallet.create(aztecNode, pxeConfig);
42
42
 
43
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
43
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
44
44
  await addBot(options, signalHandlers, services, wallet, aztecNode, telemetry, undefined);
45
45
  }
46
46
 
@@ -3,7 +3,7 @@ import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from
3
3
  import { Fr } from '@aztec/aztec.js/fields';
4
4
  import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
5
5
  import { getL1Config } from '@aztec/cli/config';
6
- import { getPublicClient } from '@aztec/ethereum';
6
+ import { getPublicClient } from '@aztec/ethereum/client';
7
7
  import { SecretValue } from '@aztec/foundation/config';
8
8
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
9
9
  import type { LogFn } from '@aztec/foundation/log';
@@ -117,7 +117,7 @@ export async function startNode(
117
117
  }
118
118
 
119
119
  const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
120
- const telemetry = initTelemetryClient(telemetryConfig);
120
+ const telemetry = await initTelemetryClient(telemetryConfig);
121
121
 
122
122
  // Create and start Aztec Node
123
123
  const node = await createAztecNode(nodeConfig, { telemetry }, { prefilledPublicData });
@@ -25,7 +25,7 @@ export async function startP2PBootstrap(
25
25
  userLog(`Starting P2P bootstrap node with config: ${jsonStringify(safeConfig)}`);
26
26
 
27
27
  const telemetryConfig = extractRelevantOptions<TelemetryClientConfig>(options, telemetryClientConfigMappings, 'tel');
28
- const telemetryClient = initTelemetryClient(telemetryConfig);
28
+ const telemetryClient = await initTelemetryClient(telemetryConfig);
29
29
 
30
30
  const store = await createStore('p2p-bootstrap', 1, config, createLogger('p2p:bootstrap:store'));
31
31
  const node = new BootstrapNode(store, telemetryClient);
@@ -53,20 +53,12 @@ export async function startProverAgent(
53
53
  );
54
54
  const broker = createProvingJobBrokerClient(config.proverBrokerUrl, getVersions(), fetch);
55
55
 
56
- const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
56
+ const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
57
57
  const prover = await buildServerCircuitProver(config, telemetry);
58
58
  const proofStore = new InlineProofStore();
59
59
  const agents = times(
60
60
  config.proverAgentCount,
61
- () =>
62
- new ProvingAgent(
63
- broker,
64
- proofStore,
65
- prover,
66
- config.proverAgentProofTypes,
67
- config.proverAgentPollIntervalMs,
68
- telemetry,
69
- ),
61
+ () => new ProvingAgent(broker, proofStore, prover, config.proverAgentProofTypes, config.proverAgentPollIntervalMs),
70
62
  );
71
63
 
72
64
  // expose all agents as individual services
@@ -1,5 +1,5 @@
1
1
  import { getL1Config } from '@aztec/cli/config';
2
- import { getPublicClient } from '@aztec/ethereum';
2
+ import { getPublicClient } from '@aztec/ethereum/client';
3
3
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
4
4
  import type { LogFn } from '@aztec/foundation/log';
5
5
  import {
@@ -45,7 +45,7 @@ export async function startProverBroker(
45
45
  config.l1Contracts = addresses;
46
46
  config.rollupVersion = rollupConfig.rollupVersion;
47
47
 
48
- const client = initTelemetryClient(getTelemetryClientConfig());
48
+ const client = await initTelemetryClient(getTelemetryClientConfig());
49
49
  const broker = await createAndStartProvingBroker(config, client);
50
50
 
51
51
  if (options.autoUpdate !== 'disabled' && options.autoUpdateUrl) {
@@ -2,7 +2,7 @@ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
2
2
  import { Fr } from '@aztec/aztec.js/fields';
3
3
  import { getSponsoredFPCAddress } from '@aztec/cli/cli-utils';
4
4
  import { getL1Config } from '@aztec/cli/config';
5
- import { getPublicClient } from '@aztec/ethereum';
5
+ import { getPublicClient } from '@aztec/ethereum/client';
6
6
  import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server';
7
7
  import { Agent, makeUndiciFetch } from '@aztec/foundation/json-rpc/undici';
8
8
  import type { LogFn } from '@aztec/foundation/log';
@@ -67,7 +67,7 @@ export async function startProverNode(
67
67
  );
68
68
  }
69
69
 
70
- const telemetry = initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
70
+ const telemetry = await initTelemetryClient(extractRelevantOptions(options, telemetryClientConfigMappings, 'tel'));
71
71
 
72
72
  let broker: ProvingJobBroker;
73
73
  if (proverConfig.proverBrokerUrl) {
package/src/cli/util.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  import type { AztecNodeConfig } from '@aztec/aztec-node';
2
- import { EthAddress } from '@aztec/aztec.js/addresses';
3
- import { Fr } from '@aztec/aztec.js/fields';
4
- import { AccountManager } from '@aztec/aztec.js/wallet';
5
- import type { ViemClient } from '@aztec/ethereum';
2
+ import type { AccountManager } from '@aztec/aztec.js/wallet';
3
+ import type { ViemClient } from '@aztec/ethereum/types';
6
4
  import type { ConfigMappingsType } from '@aztec/foundation/config';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
+ import { EthAddress } from '@aztec/foundation/eth-address';
7
7
  import { type LogFn, createLogger } from '@aztec/foundation/log';
8
8
  import type { SharedNodeConfig } from '@aztec/node-lib/config';
9
9
  import type { ProverConfig } from '@aztec/stdlib/interfaces/server';
10
- import { UpdateChecker } from '@aztec/stdlib/update-checker';
11
- import { getTelemetryClient } from '@aztec/telemetry-client';
10
+ import { getTelemetryClient } from '@aztec/telemetry-client/start';
12
11
  import type { TestWallet } from '@aztec/test-wallet/server';
13
12
 
14
13
  import chalk from 'chalk';
@@ -37,7 +36,7 @@ export function shutdown(logFn: LogFn, exitCode: ExitCode, cb?: Array<() => Prom
37
36
 
38
37
  logFn('Shutting down...', { exitCode });
39
38
  if (cb) {
40
- shutdownPromise = Promise.allSettled(cb).then(() => process.exit(exitCode));
39
+ shutdownPromise = Promise.allSettled(cb.map(fn => fn())).then(() => process.exit(exitCode));
41
40
  } else {
42
41
  // synchronously shuts down the process
43
42
  // no need to set shutdownPromise on this branch of the if statement because no more code will be executed
@@ -312,6 +311,7 @@ export async function setupUpdateMonitor(
312
311
  updateNodeConfig?: (config: object) => Promise<void>,
313
312
  ) {
314
313
  const logger = createLogger('update-check');
314
+ const { UpdateChecker } = await import('@aztec/stdlib/update-checker');
315
315
  const checker = await UpdateChecker.new({
316
316
  baseURL: updatesLocation,
317
317
  publicClient,
@@ -1,5 +1,5 @@
1
1
  import { EthAddress } from '@aztec/aztec.js/addresses';
2
- import type { ExtendedViemWalletClient } from '@aztec/ethereum';
2
+ import type { ExtendedViemWalletClient } from '@aztec/ethereum/types';
3
3
  import { jsonStringify } from '@aztec/foundation/json-rpc';
4
4
 
5
5
  import type { Abi, Narrow } from 'abitype';
@@ -1,6 +1,6 @@
1
1
  import { type InitialAccountData, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
2
  import type { Wallet } from '@aztec/aztec.js/wallet';
3
- import { Fr } from '@aztec/foundation/fields';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import type { LogFn } from '@aztec/foundation/log';
5
5
  import { FPCContract } from '@aztec/noir-contracts.js/FPC';
6
6
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
@@ -1,21 +1,20 @@
1
1
  #!/usr/bin/env -S node --no-warnings
2
2
  import { getInitialTestAccountsData } from '@aztec/accounts/testing';
3
- import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
- import { EthAddress } from '@aztec/aztec.js/addresses';
5
- import { type BlobSinkClientInterface, createBlobSinkClient } from '@aztec/blob-sink/client';
3
+ import { AztecNodeService } from '@aztec/aztec-node';
4
+ import { type AztecNodeConfig, getConfigEnvVars } from '@aztec/aztec-node/config';
5
+ import { Fr } from '@aztec/aztec.js/fields';
6
+ import { createLogger } from '@aztec/aztec.js/log';
7
+ import { type BlobClientInterface, createBlobClient } from '@aztec/blob-client/client';
6
8
  import { GENESIS_ARCHIVE_ROOT } from '@aztec/constants';
7
- import {
8
- NULL_KEY,
9
- createEthereumChain,
10
- deployL1Contracts,
11
- deployMulticall3,
12
- getL1ContractsConfigEnvVars,
13
- waitForPublicClient,
14
- } from '@aztec/ethereum';
9
+ import { createEthereumChain } from '@aztec/ethereum/chain';
10
+ import { waitForPublicClient } from '@aztec/ethereum/client';
11
+ import { getL1ContractsConfigEnvVars } from '@aztec/ethereum/config';
12
+ import { NULL_KEY } from '@aztec/ethereum/constants';
13
+ import { deployAztecL1Contracts } from '@aztec/ethereum/deploy-aztec-l1-contracts';
15
14
  import { EthCheatCodes } from '@aztec/ethereum/test';
16
15
  import { SecretValue } from '@aztec/foundation/config';
17
- import { Fr } from '@aztec/foundation/fields';
18
- import { type LogFn, createLogger } from '@aztec/foundation/log';
16
+ import { EthAddress } from '@aztec/foundation/eth-address';
17
+ import type { LogFn } from '@aztec/foundation/log';
19
18
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
20
19
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
21
20
  import { protocolContractsHash } from '@aztec/protocol-contracts';
@@ -28,13 +27,14 @@ import {
28
27
  import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
29
28
  import { getGenesisValues } from '@aztec/world-state/testing';
30
29
 
31
- import { type HDAccount, type PrivateKeyAccount, createPublicClient, fallback, http as httpViemTransport } from 'viem';
30
+ import { type Hex, createPublicClient, fallback, http as httpViemTransport } from 'viem';
32
31
  import { mnemonicToAccount, privateKeyToAddress } from 'viem/accounts';
33
32
  import { foundry } from 'viem/chains';
34
33
 
35
34
  import { createAccountLogs } from '../cli/util.js';
36
35
  import { DefaultMnemonic } from '../mnemonic.js';
37
36
  import { AnvilTestWatcher } from '../testing/anvil_test_watcher.js';
37
+ import { EpochTestSettler } from '../testing/epoch_test_settler.js';
38
38
  import { getBananaFPCAddress, setupBananaFPC } from './banana_fpc.js';
39
39
  import { getSponsoredFPCAddress } from './sponsored_fpc.js';
40
40
 
@@ -49,42 +49,26 @@ const localAnvil = foundry;
49
49
  */
50
50
  export async function deployContractsToL1(
51
51
  aztecNodeConfig: AztecNodeConfig,
52
- hdAccount: HDAccount | PrivateKeyAccount,
53
- contractDeployLogger = logger,
52
+ privateKey: Hex,
54
53
  opts: {
55
54
  assumeProvenThroughBlockNumber?: number;
56
- salt?: number;
57
55
  genesisArchiveRoot?: Fr;
58
56
  feeJuicePortalInitialBalance?: bigint;
59
57
  } = {},
60
58
  ) {
61
- const chain =
62
- aztecNodeConfig.l1RpcUrls.length > 0
63
- ? createEthereumChain(aztecNodeConfig.l1RpcUrls, aztecNodeConfig.l1ChainId)
64
- : { chainInfo: localAnvil };
65
-
66
59
  await waitForPublicClient(aztecNodeConfig);
67
60
 
68
- const l1Contracts = await deployL1Contracts(
69
- aztecNodeConfig.l1RpcUrls,
70
- hdAccount,
71
- chain.chainInfo,
72
- contractDeployLogger,
73
- {
74
- ...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
75
- ...aztecNodeConfig,
76
- vkTreeRoot: getVKTreeRoot(),
77
- protocolContractsHash,
78
- genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
79
- salt: opts.salt,
80
- feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
81
- aztecTargetCommitteeSize: 0, // no committee in local network
82
- slasherFlavor: 'none', // no slashing in local network
83
- realVerifier: false,
84
- },
85
- );
86
-
87
- await deployMulticall3(l1Contracts.l1Client, logger);
61
+ const l1Contracts = await deployAztecL1Contracts(aztecNodeConfig.l1RpcUrls[0], privateKey, foundry.id, {
62
+ ...getL1ContractsConfigEnvVars(), // TODO: We should not need to be loading config from env again, caller should handle this
63
+ ...aztecNodeConfig,
64
+ vkTreeRoot: getVKTreeRoot(),
65
+ protocolContractsHash,
66
+ genesisArchiveRoot: opts.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
67
+ feeJuicePortalInitialBalance: opts.feeJuicePortalInitialBalance,
68
+ aztecTargetCommitteeSize: 0, // no committee in local network
69
+ slasherFlavor: 'none', // no slashing in local network
70
+ realVerifier: false,
71
+ });
88
72
 
89
73
  aztecNodeConfig.l1Contracts = l1Contracts.l1ContractAddresses;
90
74
  aztecNodeConfig.rollupVersion = l1Contracts.rollupVersion;
@@ -96,8 +80,6 @@ export async function deployContractsToL1(
96
80
  export type LocalNetworkConfig = AztecNodeConfig & {
97
81
  /** Mnemonic used to derive the L1 deployer private key.*/
98
82
  l1Mnemonic: string;
99
- /** Salt used to deploy L1 contracts.*/
100
- deployAztecContractsSalt: string;
101
83
  /** Whether to deploy test accounts on local network start.*/
102
84
  testAccounts: boolean;
103
85
  };
@@ -116,7 +98,11 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
116
98
  if ((config.l1RpcUrls?.length || 0) > 1) {
117
99
  logger.warn(`Multiple L1 RPC URLs provided. Local networks will only use the first one: ${l1RpcUrl}`);
118
100
  }
119
- const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config };
101
+
102
+ const aztecNodeConfig: AztecNodeConfig = {
103
+ ...getConfigEnvVars(),
104
+ ...config,
105
+ };
120
106
  const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic);
121
107
  if (
122
108
  aztecNodeConfig.publisherPrivateKeys == undefined ||
@@ -153,15 +139,21 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
153
139
  : [];
154
140
  const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(fundedAddresses);
155
141
 
156
- let watcher: AnvilTestWatcher | undefined = undefined;
157
142
  const dateProvider = new TestDateProvider();
143
+
144
+ let cheatcodes: EthCheatCodes | undefined;
145
+ let rollupAddress: EthAddress | undefined;
146
+ let watcher: AnvilTestWatcher | undefined;
158
147
  if (!aztecNodeConfig.p2pEnabled) {
159
- const l1ContractAddresses = await deployContractsToL1(aztecNodeConfig, hdAccount, undefined, {
160
- assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
161
- genesisArchiveRoot,
162
- salt: config.deployAztecContractsSalt ? parseInt(config.deployAztecContractsSalt) : undefined,
163
- feeJuicePortalInitialBalance: fundingNeeded,
164
- });
148
+ ({ rollupAddress } = await deployContractsToL1(
149
+ aztecNodeConfig,
150
+ aztecNodeConfig.validatorPrivateKeys.getValue()[0],
151
+ {
152
+ assumeProvenThroughBlockNumber: Number.MAX_SAFE_INTEGER,
153
+ genesisArchiveRoot,
154
+ feeJuicePortalInitialBalance: fundingNeeded,
155
+ },
156
+ ));
165
157
 
166
158
  const chain =
167
159
  aztecNodeConfig.l1RpcUrls.length > 0
@@ -173,24 +165,27 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
173
165
  transport: fallback([httpViemTransport(l1RpcUrl)]) as any,
174
166
  });
175
167
 
176
- watcher = new AnvilTestWatcher(
177
- new EthCheatCodes([l1RpcUrl], dateProvider),
178
- l1ContractAddresses.rollupAddress,
179
- publicClient,
180
- dateProvider,
181
- );
168
+ cheatcodes = new EthCheatCodes([l1RpcUrl], dateProvider);
169
+
170
+ watcher = new AnvilTestWatcher(cheatcodes, rollupAddress, publicClient, dateProvider);
182
171
  watcher.setisLocalNetwork(true);
172
+ watcher.setIsMarkingAsProven(false); // Do not mark as proven in the watcher. It's marked in the epochTestSettler after the out hash is set.
173
+
183
174
  await watcher.start();
184
175
  }
185
176
 
186
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
187
- // Create a local blob sink client inside the local network, no http connectivity
188
- const blobSinkClient = createBlobSinkClient();
189
- const node = await createAztecNode(
190
- aztecNodeConfig,
191
- { telemetry, blobSinkClient, dateProvider },
192
- { prefilledPublicData },
193
- );
177
+ const telemetry = await initTelemetryClient(getTelemetryClientConfig());
178
+ // Create a local blob client client inside the local network, no http connectivity
179
+ const blobClient = createBlobClient();
180
+ const node = await createAztecNode(aztecNodeConfig, { telemetry, blobClient, dateProvider }, { prefilledPublicData });
181
+
182
+ let epochTestSettler: EpochTestSettler | undefined;
183
+ if (!aztecNodeConfig.p2pEnabled) {
184
+ epochTestSettler = new EpochTestSettler(cheatcodes!, rollupAddress!, node.getBlockSource(), {
185
+ pollingIntervalMs: 200,
186
+ });
187
+ await epochTestSettler.start();
188
+ }
194
189
 
195
190
  if (initialAccounts.length) {
196
191
  const PXEConfig = { proverEnabled: aztecNodeConfig.realProofs };
@@ -216,6 +211,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
216
211
  const stop = async () => {
217
212
  await node.stop();
218
213
  await watcher?.stop();
214
+ await epochTestSettler?.stop();
219
215
  };
220
216
 
221
217
  return { node, stop };
@@ -227,7 +223,7 @@ export async function createLocalNetwork(config: Partial<LocalNetworkConfig> = {
227
223
  */
228
224
  export async function createAztecNode(
229
225
  config: Partial<AztecNodeConfig> = {},
230
- deps: { telemetry?: TelemetryClient; blobSinkClient?: BlobSinkClientInterface; dateProvider?: DateProvider } = {},
226
+ deps: { telemetry?: TelemetryClient; blobClient?: BlobClientInterface; dateProvider?: DateProvider } = {},
231
227
  options: { prefilledPublicData?: PublicDataTreeLeaf[] } = {},
232
228
  ) {
233
229
  // TODO(#12272): will clean this up. This is criminal.
@@ -1,5 +1,5 @@
1
- import type { ViemClient } from '@aztec/ethereum';
2
1
  import { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
2
+ import type { ViemClient } from '@aztec/ethereum/types';
3
3
  import { SlotNumber } from '@aztec/foundation/branded-types';
4
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { type Logger, createLogger } from '@aztec/foundation/log';
@@ -0,0 +1,59 @@
1
+ import { Fr } from '@aztec/aztec.js/fields';
2
+ import { type EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
+ import { type EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
+ import { EpochMonitor } from '@aztec/prover-node';
5
+ import type { EthAddress, L2BlockSource } from '@aztec/stdlib/block';
6
+ import { computeL2ToL1MembershipWitnessFromMessagesInEpoch } from '@aztec/stdlib/messaging';
7
+
8
+ export class EpochTestSettler {
9
+ private rollupCheatCodes: RollupCheatCodes;
10
+ private epochMonitor?: EpochMonitor;
11
+
12
+ constructor(
13
+ cheatcodes: EthCheatCodes,
14
+ rollupAddress: EthAddress,
15
+ private l2BlockSource: L2BlockSource,
16
+ private options: { pollingIntervalMs: number; provingDelayMs?: number },
17
+ ) {
18
+ this.rollupCheatCodes = new RollupCheatCodes(cheatcodes, { rollupAddress });
19
+ }
20
+
21
+ async start() {
22
+ const { epochDuration } = await this.rollupCheatCodes.getConfig();
23
+ this.epochMonitor = new EpochMonitor(this.l2BlockSource, { epochDuration: Number(epochDuration) }, this.options);
24
+ this.epochMonitor.start(this);
25
+ }
26
+
27
+ async stop() {
28
+ await this.epochMonitor?.stop();
29
+ }
30
+
31
+ async handleEpochReadyToProve(epoch: EpochNumber): Promise<boolean> {
32
+ const blocks = await this.l2BlockSource.getBlocksForEpoch(epoch);
33
+ const messagesInEpoch: Fr[][][][] = [];
34
+ let previousSlotNumber = SlotNumber.ZERO;
35
+ let checkpointIndex = -1;
36
+ for (const block of blocks) {
37
+ const slotNumber = block.header.globalVariables.slotNumber;
38
+ if (slotNumber !== previousSlotNumber) {
39
+ checkpointIndex++;
40
+ messagesInEpoch[checkpointIndex] = [];
41
+ previousSlotNumber = slotNumber;
42
+ }
43
+ messagesInEpoch[checkpointIndex].push(block.body.txEffects.map(txEffect => txEffect.l2ToL1Msgs));
44
+ }
45
+
46
+ const [firstMessage] = messagesInEpoch.flat(3);
47
+ if (firstMessage) {
48
+ const { root: outHash } = computeL2ToL1MembershipWitnessFromMessagesInEpoch(messagesInEpoch, firstMessage);
49
+ await this.rollupCheatCodes.insertOutbox(epoch, outHash.toBigInt());
50
+ }
51
+
52
+ // Mark the blocks as proven.
53
+ for (const block of blocks) {
54
+ await this.rollupCheatCodes.markAsProven(block.number);
55
+ }
56
+
57
+ return true;
58
+ }
59
+ }
@@ -1,3 +1,4 @@
1
1
  export { AnvilTestWatcher } from './anvil_test_watcher.js';
2
2
  export { EthCheatCodes, RollupCheatCodes } from '@aztec/ethereum/test';
3
3
  export { CheatCodes } from './cheat_codes.js';
4
+ export { EpochTestSettler } from './epoch_test_settler.js';
@@ -1,3 +0,0 @@
1
- import type { LogFn } from '@aztec/foundation/log';
2
- export declare function startBlobSink(options: any, signalHandlers: (() => Promise<void>)[], userLog: LogFn): Promise<void>;
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhcnRfYmxvYl9zaW5rLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvY2xpL2NtZHMvc3RhcnRfYmxvYl9zaW5rLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQU9BLE9BQU8sS0FBSyxFQUFFLEtBQUssRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBS25ELHdCQUFzQixhQUFhLENBQUMsT0FBTyxFQUFFLEdBQUcsRUFBRSxjQUFjLEVBQUUsQ0FBQyxNQUFNLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxFQUFFLEVBQUUsT0FBTyxFQUFFLEtBQUssaUJBNEN4RyJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"start_blob_sink.d.ts","sourceRoot":"","sources":["../../../src/cli/cmds/start_blob_sink.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAKnD,wBAAsB,aAAa,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,iBA4CxG"}
@@ -1,33 +0,0 @@
1
- import { blobSinkConfigMappings, createBlobSinkServer, getBlobSinkConfigFromEnv } from '@aztec/blob-sink/server';
2
- import { getL1Config } from '@aztec/cli/config';
3
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
4
- import { extractRelevantOptions } from '../util.js';
5
- export async function startBlobSink(options, signalHandlers, userLog) {
6
- if (options.prover || options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
7
- userLog(`Starting a blob sink with --node, --sequencer, --pxe, --p2p-bootstrap, --prover or --txe is not supported.`);
8
- process.exit(1);
9
- }
10
- let blobSinkConfig = {
11
- ...getBlobSinkConfigFromEnv(),
12
- ...extractRelevantOptions(options, blobSinkConfigMappings, 'blobSink')
13
- };
14
- if (!blobSinkConfig.l1Contracts?.registryAddress || blobSinkConfig.l1Contracts.registryAddress.isZero()) {
15
- throw new Error('REGISTRY_CONTRACT_ADDRESS not set');
16
- }
17
- if (!blobSinkConfig.l1RpcUrls || blobSinkConfig.l1RpcUrls.length === 0) {
18
- throw new Error('ETHEREUM_HOSTS not set');
19
- }
20
- if (typeof blobSinkConfig.l1ChainId !== 'number') {
21
- throw new Error('L1_CHAIN_ID');
22
- }
23
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
24
- const { config: chainConfig, addresses } = await getL1Config(blobSinkConfig.l1Contracts.registryAddress, blobSinkConfig.l1RpcUrls, blobSinkConfig.l1ChainId, blobSinkConfig.rollupVersion);
25
- blobSinkConfig = {
26
- ...blobSinkConfig,
27
- l1Contracts: addresses,
28
- ...chainConfig
29
- };
30
- const blobSink = await createBlobSinkServer(blobSinkConfig, telemetry);
31
- signalHandlers.push(blobSink.stop.bind(blobSink));
32
- await blobSink.start();
33
- }
@@ -1,57 +0,0 @@
1
- import {
2
- type BlobSinkConfig,
3
- blobSinkConfigMappings,
4
- createBlobSinkServer,
5
- getBlobSinkConfigFromEnv,
6
- } from '@aztec/blob-sink/server';
7
- import { getL1Config } from '@aztec/cli/config';
8
- import type { LogFn } from '@aztec/foundation/log';
9
- import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client';
10
-
11
- import { extractRelevantOptions } from '../util.js';
12
-
13
- export async function startBlobSink(options: any, signalHandlers: (() => Promise<void>)[], userLog: LogFn) {
14
- if (options.prover || options.node || options.sequencer || options.pxe || options.p2pBootstrap || options.txe) {
15
- userLog(
16
- `Starting a blob sink with --node, --sequencer, --pxe, --p2p-bootstrap, --prover or --txe is not supported.`,
17
- );
18
- process.exit(1);
19
- }
20
-
21
- let blobSinkConfig: BlobSinkConfig = {
22
- ...getBlobSinkConfigFromEnv(), // get default config from env
23
- ...extractRelevantOptions<BlobSinkConfig>(options, blobSinkConfigMappings, 'blobSink'), // override with command line options
24
- };
25
-
26
- if (!blobSinkConfig.l1Contracts?.registryAddress || blobSinkConfig.l1Contracts.registryAddress.isZero()) {
27
- throw new Error('REGISTRY_CONTRACT_ADDRESS not set');
28
- }
29
-
30
- if (!blobSinkConfig.l1RpcUrls || blobSinkConfig.l1RpcUrls.length === 0) {
31
- throw new Error('ETHEREUM_HOSTS not set');
32
- }
33
-
34
- if (typeof blobSinkConfig.l1ChainId !== 'number') {
35
- throw new Error('L1_CHAIN_ID');
36
- }
37
-
38
- const telemetry = initTelemetryClient(getTelemetryClientConfig());
39
-
40
- const { config: chainConfig, addresses } = await getL1Config(
41
- blobSinkConfig.l1Contracts.registryAddress,
42
- blobSinkConfig.l1RpcUrls,
43
- blobSinkConfig.l1ChainId,
44
- blobSinkConfig.rollupVersion,
45
- );
46
-
47
- blobSinkConfig = {
48
- ...blobSinkConfig,
49
- l1Contracts: addresses,
50
- ...chainConfig,
51
- };
52
-
53
- const blobSink = await createBlobSinkServer(blobSinkConfig, telemetry);
54
- signalHandlers.push(blobSink.stop.bind(blobSink));
55
-
56
- await blobSink.start();
57
- }