From 7a85b93b52697d9607b8ce05259ae2f8e210b696 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 16 Dec 2024 17:22:58 -0300 Subject: [PATCH 1/3] Lazy loading in CLI --- yarn-project/archiver/package.json | 5 +- yarn-project/aztec-faucet/package.json | 5 +- yarn-project/aztec-node/package.json | 7 +- .../aztec/src/cli/aztec_start_action.ts | 101 +++++++++++++++++ .../aztec/src/cli/aztec_start_options.ts | 22 ++-- yarn-project/aztec/src/cli/cli.ts | 105 +----------------- yarn-project/aztec/src/mnemonic.ts | 1 + yarn-project/aztec/src/sandbox.ts | 4 +- yarn-project/bot/package.json | 5 +- yarn-project/circuit-types/package.json | 5 +- yarn-project/circuit-types/src/config.ts | 2 + yarn-project/cli-wallet/src/cmds/check_tx.ts | 2 +- yarn-project/cli/package.json | 5 +- yarn-project/cli/src/utils/aztec.ts | 2 +- yarn-project/cli/src/utils/commands.ts | 2 +- yarn-project/cli/src/utils/index.ts | 1 - yarn-project/l1-artifacts/package.json | 3 +- yarn-project/p2p/package.json | 5 +- yarn-project/proof-verifier/package.json | 5 +- yarn-project/prover-node/package.json | 5 +- 20 files changed, 154 insertions(+), 138 deletions(-) create mode 100644 yarn-project/aztec/src/cli/aztec_start_action.ts create mode 100644 yarn-project/aztec/src/mnemonic.ts create mode 100644 yarn-project/circuit-types/src/config.ts diff --git a/yarn-project/archiver/package.json b/yarn-project/archiver/package.json index 61b84434170..c802f7aaf33 100644 --- a/yarn-project/archiver/package.json +++ b/yarn-project/archiver/package.json @@ -6,7 +6,8 @@ ".": "./dest/index.js", "./data-retrieval": "./dest/archiver/data_retrieval.js", "./epoch": "./dest/archiver/epoch_helpers.js", - "./test": "./dest/test/index.js" + "./test": "./dest/test/index.js", + "./config": "./dest/archiver/config.js" }, "typedocOptions": { "entryPoints": [ @@ -109,4 +110,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/aztec-faucet/package.json b/yarn-project/aztec-faucet/package.json index 2285a4087c0..64290005c93 100644 --- a/yarn-project/aztec-faucet/package.json +++ b/yarn-project/aztec-faucet/package.json @@ -5,7 +5,8 @@ "type": "module", "bin": "./dest/bin/index.js", "exports": { - ".": "./dest/index.js" + ".": "./dest/index.js", + "./config": "./dest/config.js" }, "typedocOptions": { "entryPoints": [ @@ -93,4 +94,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/aztec-node/package.json b/yarn-project/aztec-node/package.json index f23417a5b7b..ad55b09fe21 100644 --- a/yarn-project/aztec-node/package.json +++ b/yarn-project/aztec-node/package.json @@ -3,7 +3,10 @@ "version": "0.1.0", "main": "dest/index.js", "type": "module", - "exports": "./dest/index.js", + "exports": { + ".": "./dest/index.js", + "./config": "./dest/aztec-node/config.js" + }, "bin": "./dest/bin/index.js", "typedocOptions": { "entryPoints": [ @@ -103,4 +106,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/aztec/src/cli/aztec_start_action.ts b/yarn-project/aztec/src/cli/aztec_start_action.ts new file mode 100644 index 00000000000..983afecf019 --- /dev/null +++ b/yarn-project/aztec/src/cli/aztec_start_action.ts @@ -0,0 +1,101 @@ +import { deployInitialTestAccounts } from '@aztec/accounts/testing'; +import { AztecNodeApiSchema, PXESchema } from '@aztec/circuit-types'; +import { + type NamespacedApiHandlers, + createNamespacedSafeJsonRpcServer, + startHttpRpcServer, +} from '@aztec/foundation/json-rpc/server'; +import { type LogFn, type Logger } from '@aztec/foundation/log'; + +import { createSandbox } from '../sandbox.js'; +import { github, splash } from '../splash.js'; +import { createAccountLogs, extractNamespacedOptions, installSignalHandlers } from './util.js'; + +export async function aztecStart(options: any, userLog: LogFn, debugLogger: Logger) { + // list of 'stop' functions to call when process ends + const signalHandlers: Array<() => Promise> = []; + const services: NamespacedApiHandlers = {}; + + if (options.sandbox) { + const sandboxOptions = extractNamespacedOptions(options, 'sandbox'); + userLog(`${splash}\n${github}\n\n`); + userLog(`Setting up Aztec Sandbox, please stand by...`); + const { aztecNodeConfig, node, pxe, stop } = await createSandbox({ + enableGas: sandboxOptions.enableGas, + l1Mnemonic: options.l1Mnemonic, + l1RpcUrl: options.l1RpcUrl, + }); + + // Deploy test accounts by default + if (sandboxOptions.testAccounts) { + if (aztecNodeConfig.p2pEnabled) { + userLog(`Not setting up test accounts as we are connecting to a network`); + } else if (sandboxOptions.noPXE) { + userLog(`Not setting up test accounts as we are not exposing a PXE`); + } else { + userLog('Setting up test accounts...'); + const accounts = await deployInitialTestAccounts(pxe); + const accLogs = await createAccountLogs(accounts, pxe); + userLog(accLogs.join('')); + } + } + + // Start Node and PXE JSON-RPC server + signalHandlers.push(stop); + services.node = [node, AztecNodeApiSchema]; + if (!sandboxOptions.noPXE) { + services.pxe = [pxe, PXESchema]; + } else { + userLog(`Not exposing PXE API through JSON-RPC server`); + } + } else { + if (options.node) { + const { startNode } = await import('./cmds/start_node.js'); + await startNode(options, signalHandlers, services, userLog); + } else if (options.proofVerifier) { + const { startProofVerifier } = await import('./cmds/start_proof_verifier.js'); + await startProofVerifier(options, signalHandlers, userLog); + } else if (options.bot) { + const { startBot } = await import('./cmds/start_bot.js'); + await startBot(options, signalHandlers, services, userLog); + } else if (options.proverNode) { + const { startProverNode } = await import('./cmds/start_prover_node.js'); + await startProverNode(options, signalHandlers, services, userLog); + } else if (options.pxe) { + const { startPXE } = await import('./cmds/start_pxe.js'); + await startPXE(options, signalHandlers, services, userLog); + } else if (options.archiver) { + const { startArchiver } = await import('./cmds/start_archiver.js'); + await startArchiver(options, signalHandlers, services); + } else if (options.p2pBootstrap) { + const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js'); + await startP2PBootstrap(options, signalHandlers, services, userLog); + } else if (options.proverAgent) { + const { startProverAgent } = await import('./cmds/start_prover_agent.js'); + await startProverAgent(options, signalHandlers, services, userLog); + } else if (options.proverBroker) { + const { startProverBroker } = await import('./cmds/start_prover_broker.js'); + await startProverBroker(options, signalHandlers, services, userLog); + } else if (options.txe) { + const { startTXE } = await import('./cmds/start_txe.js'); + await startTXE(options, debugLogger); + } else if (options.sequencer) { + userLog(`Cannot run a standalone sequencer without a node`); + process.exit(1); + } else if (options.faucet) { + const { startFaucet } = await import('./cmds/start_faucet.js'); + await startFaucet(options, signalHandlers, services, userLog); + } else { + userLog(`No module specified to start`); + process.exit(1); + } + } + + installSignalHandlers(debugLogger.info, signalHandlers); + + if (Object.entries(services).length > 0) { + const rpcServer = createNamespacedSafeJsonRpcServer(services, debugLogger); + const { port } = await startHttpRpcServer(rpcServer, { port: options.port }); + debugLogger.info(`Aztec Server listening on port ${port}`); + } +} diff --git a/yarn-project/aztec/src/cli/aztec_start_options.ts b/yarn-project/aztec/src/cli/aztec_start_options.ts index 06ae9c449d0..ab0c4d0fd4e 100644 --- a/yarn-project/aztec/src/cli/aztec_start_options.ts +++ b/yarn-project/aztec/src/cli/aztec_start_options.ts @@ -1,13 +1,13 @@ -import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver'; -import { faucetConfigMapping } from '@aztec/aztec-faucet'; -import { sequencerClientConfigMappings } from '@aztec/aztec-node'; -import { botConfigMappings } from '@aztec/bot'; +import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config'; +import { faucetConfigMapping } from '@aztec/aztec-faucet/config'; +import { sequencerClientConfigMappings } from '@aztec/aztec-node/config'; +import { botConfigMappings } from '@aztec/bot/config'; import { type ProverAgentConfig, type ProverBrokerConfig, proverAgentConfigMappings, proverBrokerConfigMappings, -} from '@aztec/circuit-types'; +} from '@aztec/circuit-types/config'; import { type ConfigMapping, type EnvVar, @@ -15,13 +15,13 @@ import { isBooleanConfigValue, omitConfigMappings, } from '@aztec/foundation/config'; -import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p'; -import { proofVerifierConfigMappings } from '@aztec/proof-verifier'; -import { proverNodeConfigMappings } from '@aztec/prover-node'; -import { allPxeConfigMappings } from '@aztec/pxe'; +import { bootnodeConfigMappings, p2pConfigMappings } from '@aztec/p2p/config'; +import { proofVerifierConfigMappings } from '@aztec/proof-verifier/config'; +import { proverNodeConfigMappings } from '@aztec/prover-node/config'; +import { allPxeConfigMappings } from '@aztec/pxe/config'; import { telemetryClientConfigMappings } from '@aztec/telemetry-client/start'; -import { defaultMnemonic } from '../sandbox.js'; +import { DefaultMnemonic } from '../mnemonic.js'; // Define an interface for options export interface AztecStartOption { @@ -115,7 +115,7 @@ export const aztecStartOptions: { [key: string]: AztecStartOption[] } = { { flag: '--l1-mnemonic ', description: 'Mnemonic for L1 accounts. Will be used if no publisher private keys are provided', - defaultValue: defaultMnemonic, + defaultValue: DefaultMnemonic, envVar: 'MNEMONIC', }, ], diff --git a/yarn-project/aztec/src/cli/cli.ts b/yarn-project/aztec/src/cli/cli.ts index 3273aa715a7..90ff22b6336 100644 --- a/yarn-project/aztec/src/cli/cli.ts +++ b/yarn-project/aztec/src/cli/cli.ts @@ -1,24 +1,9 @@ -import { deployInitialTestAccounts } from '@aztec/accounts/testing'; -import { AztecNodeApiSchema, PXESchema } from '@aztec/circuit-types'; -import { - type NamespacedApiHandlers, - createNamespacedSafeJsonRpcServer, - startHttpRpcServer, -} from '@aztec/foundation/json-rpc/server'; import { type LogFn, type Logger } from '@aztec/foundation/log'; import { Command } from 'commander'; -import { createSandbox } from '../sandbox.js'; -import { github, splash } from '../splash.js'; import { aztecStartOptions } from './aztec_start_options.js'; -import { - addOptions, - createAccountLogs, - extractNamespacedOptions, - installSignalHandlers, - printAztecStartHelpText, -} from './util.js'; +import { addOptions, printAztecStartHelpText } from './util.js'; /** * Returns commander program that defines the 'aztec' command line interface. @@ -38,92 +23,8 @@ export function injectAztecCommands(program: Command, userLog: LogFn, debugLogge startCmd.helpInformation = printAztecStartHelpText; startCmd.action(async options => { - // list of 'stop' functions to call when process ends - const signalHandlers: Array<() => Promise> = []; - const services: NamespacedApiHandlers = {}; - - if (options.sandbox) { - const sandboxOptions = extractNamespacedOptions(options, 'sandbox'); - userLog(`${splash}\n${github}\n\n`); - userLog(`Setting up Aztec Sandbox, please stand by...`); - const { aztecNodeConfig, node, pxe, stop } = await createSandbox({ - enableGas: sandboxOptions.enableGas, - l1Mnemonic: options.l1Mnemonic, - l1RpcUrl: options.l1RpcUrl, - }); - - // Deploy test accounts by default - if (sandboxOptions.testAccounts) { - if (aztecNodeConfig.p2pEnabled) { - userLog(`Not setting up test accounts as we are connecting to a network`); - } else if (sandboxOptions.noPXE) { - userLog(`Not setting up test accounts as we are not exposing a PXE`); - } else { - userLog('Setting up test accounts...'); - const accounts = await deployInitialTestAccounts(pxe); - const accLogs = await createAccountLogs(accounts, pxe); - userLog(accLogs.join('')); - } - } - - // Start Node and PXE JSON-RPC server - signalHandlers.push(stop); - services.node = [node, AztecNodeApiSchema]; - if (!sandboxOptions.noPXE) { - services.pxe = [pxe, PXESchema]; - } else { - userLog(`Not exposing PXE API through JSON-RPC server`); - } - } else { - if (options.node) { - const { startNode } = await import('./cmds/start_node.js'); - await startNode(options, signalHandlers, services, userLog); - } else if (options.proofVerifier) { - const { startProofVerifier } = await import('./cmds/start_proof_verifier.js'); - await startProofVerifier(options, signalHandlers, userLog); - } else if (options.bot) { - const { startBot } = await import('./cmds/start_bot.js'); - await startBot(options, signalHandlers, services, userLog); - } else if (options.proverNode) { - const { startProverNode } = await import('./cmds/start_prover_node.js'); - await startProverNode(options, signalHandlers, services, userLog); - } else if (options.pxe) { - const { startPXE } = await import('./cmds/start_pxe.js'); - await startPXE(options, signalHandlers, services, userLog); - } else if (options.archiver) { - const { startArchiver } = await import('./cmds/start_archiver.js'); - await startArchiver(options, signalHandlers, services); - } else if (options.p2pBootstrap) { - const { startP2PBootstrap } = await import('./cmds/start_p2p_bootstrap.js'); - await startP2PBootstrap(options, signalHandlers, services, userLog); - } else if (options.proverAgent) { - const { startProverAgent } = await import('./cmds/start_prover_agent.js'); - await startProverAgent(options, signalHandlers, services, userLog); - } else if (options.proverBroker) { - const { startProverBroker } = await import('./cmds/start_prover_broker.js'); - await startProverBroker(options, signalHandlers, services, userLog); - } else if (options.txe) { - const { startTXE } = await import('./cmds/start_txe.js'); - await startTXE(options, debugLogger); - } else if (options.sequencer) { - userLog(`Cannot run a standalone sequencer without a node`); - process.exit(1); - } else if (options.faucet) { - const { startFaucet } = await import('./cmds/start_faucet.js'); - await startFaucet(options, signalHandlers, services, userLog); - } else { - userLog(`No module specified to start`); - process.exit(1); - } - } - - installSignalHandlers(debugLogger.info, signalHandlers); - - if (Object.entries(services).length > 0) { - const rpcServer = createNamespacedSafeJsonRpcServer(services, debugLogger); - const { port } = await startHttpRpcServer(rpcServer, { port: options.port }); - debugLogger.info(`Aztec Server listening on port ${port}`); - } + const { aztecStart } = await import('./aztec_start_action.js'); + return await aztecStart(options, userLog, debugLogger); }); program.addCommand(startCmd); diff --git a/yarn-project/aztec/src/mnemonic.ts b/yarn-project/aztec/src/mnemonic.ts new file mode 100644 index 00000000000..35e4cc86b4a --- /dev/null +++ b/yarn-project/aztec/src/mnemonic.ts @@ -0,0 +1 @@ +export const DefaultMnemonic = 'test test test test test test test test test test test junk'; diff --git a/yarn-project/aztec/src/sandbox.ts b/yarn-project/aztec/src/sandbox.ts index d720894da3a..83f20067665 100644 --- a/yarn-project/aztec/src/sandbox.ts +++ b/yarn-project/aztec/src/sandbox.ts @@ -25,7 +25,7 @@ import { type HDAccount, type PrivateKeyAccount, createPublicClient, http as htt import { mnemonicToAccount } from 'viem/accounts'; import { foundry } from 'viem/chains'; -export const defaultMnemonic = 'test test test test test test test test test test test junk'; +import { DefaultMnemonic } from './mnemonic.js'; const logger = createLogger('sandbox'); @@ -110,7 +110,7 @@ export type SandboxConfig = AztecNodeConfig & { */ export async function createSandbox(config: Partial = {}) { const aztecNodeConfig: AztecNodeConfig = { ...getConfigEnvVars(), ...config }; - const hdAccount = mnemonicToAccount(config.l1Mnemonic || defaultMnemonic); + const hdAccount = mnemonicToAccount(config.l1Mnemonic || DefaultMnemonic); if (!aztecNodeConfig.publisherPrivateKey || aztecNodeConfig.publisherPrivateKey === NULL_KEY) { const privKey = hdAccount.getHdKey().privateKey; aztecNodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey!).toString('hex')}`; diff --git a/yarn-project/bot/package.json b/yarn-project/bot/package.json index bbd80898817..fcd38c0be00 100644 --- a/yarn-project/bot/package.json +++ b/yarn-project/bot/package.json @@ -3,7 +3,8 @@ "version": "0.1.0", "type": "module", "exports": { - ".": "./dest/index.js" + ".": "./dest/index.js", + "./config": "./dest/config.js" }, "inherits": [ "../package.common.json" @@ -90,4 +91,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/circuit-types/package.json b/yarn-project/circuit-types/package.json index e8c4974633e..94e6136a449 100644 --- a/yarn-project/circuit-types/package.json +++ b/yarn-project/circuit-types/package.json @@ -9,7 +9,8 @@ "./interfaces": "./dest/interfaces/index.js", "./log_id": "./dest/logs/log_id.js", "./test": "./dest/test/index.js", - "./tx_hash": "./dest/tx/tx_hash.js" + "./tx_hash": "./dest/tx/tx_hash.js", + "./config": "./dest/config.js" }, "typedocOptions": { "entryPoints": [ @@ -105,4 +106,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/circuit-types/src/config.ts b/yarn-project/circuit-types/src/config.ts new file mode 100644 index 00000000000..16e7a95ee1e --- /dev/null +++ b/yarn-project/circuit-types/src/config.ts @@ -0,0 +1,2 @@ +export { ProverAgentConfig, proverAgentConfigMappings } from './interfaces/prover-agent.js'; +export { ProverBrokerConfig, proverBrokerConfigMappings } from './interfaces/prover-broker.js'; diff --git a/yarn-project/cli-wallet/src/cmds/check_tx.ts b/yarn-project/cli-wallet/src/cmds/check_tx.ts index 945c0b2a0cd..b586cd28ae2 100644 --- a/yarn-project/cli-wallet/src/cmds/check_tx.ts +++ b/yarn-project/cli-wallet/src/cmds/check_tx.ts @@ -1,5 +1,5 @@ import { type PXE, type TxHash } from '@aztec/aztec.js'; -import { inspectTx } from '@aztec/cli/utils'; +import { inspectTx } from '@aztec/cli/inspect'; import { type LogFn } from '@aztec/foundation/log'; export async function checkTx(client: PXE, txHash: TxHash, statusOnly: boolean, log: LogFn) { diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json index ea86f4fdb5d..08d1188e20f 100644 --- a/yarn-project/cli/package.json +++ b/yarn-project/cli/package.json @@ -10,7 +10,8 @@ "./pxe": "./dest/cmds/pxe/index.js", "./cli-utils": "./dest/utils/index.js", "./misc": "./dest/cmds/misc/index.js", - "./utils": "./dest/utils/index.js" + "./utils": "./dest/utils/index.js", + "./inspect": "./dest/utils/inspect.js" }, "typedocOptions": { "entryPoints": [ @@ -125,4 +126,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/cli/src/utils/aztec.ts b/yarn-project/cli/src/utils/aztec.ts index 9949adb635a..aa7388ab478 100644 --- a/yarn-project/cli/src/utils/aztec.ts +++ b/yarn-project/cli/src/utils/aztec.ts @@ -5,7 +5,7 @@ import { FunctionType } from '@aztec/foundation/abi'; import { type EthAddress } from '@aztec/foundation/eth-address'; import { type LogFn, type Logger } from '@aztec/foundation/log'; import { type NoirPackageConfig } from '@aztec/foundation/noir'; -import { RollupAbi } from '@aztec/l1-artifacts'; +import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi'; import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts'; import TOML from '@iarna/toml'; diff --git a/yarn-project/cli/src/utils/commands.ts b/yarn-project/cli/src/utils/commands.ts index 073505caf2c..4065c8fa84a 100644 --- a/yarn-project/cli/src/utils/commands.ts +++ b/yarn-project/cli/src/utils/commands.ts @@ -5,7 +5,7 @@ import { Fr } from '@aztec/aztec.js/fields'; import { LogId } from '@aztec/aztec.js/log_id'; import { TxHash } from '@aztec/aztec.js/tx_hash'; import { type PXE } from '@aztec/circuit-types'; -import { PublicKeys } from '@aztec/circuits.js'; +import { PublicKeys } from '@aztec/circuits.js/types'; import { type LogFn } from '@aztec/foundation/log'; import { type Command, CommanderError, InvalidArgumentError, Option } from 'commander'; diff --git a/yarn-project/cli/src/utils/index.ts b/yarn-project/cli/src/utils/index.ts index 1e4c577e271..49b74224250 100644 --- a/yarn-project/cli/src/utils/index.ts +++ b/yarn-project/cli/src/utils/index.ts @@ -2,4 +2,3 @@ export * from './commands.js'; export * from './aztec.js'; export * from './encoding.js'; export * from './github.js'; -export * from './inspect.js'; diff --git a/yarn-project/l1-artifacts/package.json b/yarn-project/l1-artifacts/package.json index 5bf298bbb3c..f5469172c8e 100644 --- a/yarn-project/l1-artifacts/package.json +++ b/yarn-project/l1-artifacts/package.json @@ -3,6 +3,7 @@ "version": "0.1.0", "type": "module", "exports": { + "./*": "./dest/*.js", ".": "./dest/index.js" }, "typedocOptions": { @@ -31,4 +32,4 @@ "generated" ], "types": "./dest/index.d.ts" -} +} \ No newline at end of file diff --git a/yarn-project/p2p/package.json b/yarn-project/p2p/package.json index 69c44f33562..a24e71fbc38 100644 --- a/yarn-project/p2p/package.json +++ b/yarn-project/p2p/package.json @@ -5,7 +5,8 @@ "exports": { ".": "./dest/index.js", "./mocks": "./dest/mocks/index.js", - "./bootstrap": "./dest/bootstrap/bootstrap.js" + "./bootstrap": "./dest/bootstrap/bootstrap.js", + "./config": "./dest/config.js" }, "typedocOptions": { "entryPoints": [ @@ -122,4 +123,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/proof-verifier/package.json b/yarn-project/proof-verifier/package.json index 9dcd38472e9..1af22444af1 100644 --- a/yarn-project/proof-verifier/package.json +++ b/yarn-project/proof-verifier/package.json @@ -2,7 +2,8 @@ "name": "@aztec/proof-verifier", "type": "module", "exports": { - ".": "./dest/index.js" + ".": "./dest/index.js", + "./config": "./dest/config.js" }, "scripts": { "build": "yarn clean && tsc -b", @@ -80,4 +81,4 @@ "../../foundation/src/jest/setup.mjs" ] } -} +} \ No newline at end of file diff --git a/yarn-project/prover-node/package.json b/yarn-project/prover-node/package.json index 27bb2c8bd60..53fa2943cc4 100644 --- a/yarn-project/prover-node/package.json +++ b/yarn-project/prover-node/package.json @@ -3,7 +3,8 @@ "version": "0.1.0", "type": "module", "exports": { - ".": "./dest/index.js" + ".": "./dest/index.js", + "./config": "./dest/config.js" }, "inherits": [ "../package.common.json" @@ -95,4 +96,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file From d6a296788266b9089e2bf35598f760cfa0528a15 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 16 Dec 2024 19:47:42 -0300 Subject: [PATCH 2/3] chore: Granular CLI imports to reduce start time CLI now shows help in under a second. --- .../aztec-node/src/aztec-node/config.ts | 12 ++--- yarn-project/aztec.js/package.json | 3 +- .../aztec.js/src/rpc_clients/pxe_client.ts | 2 +- yarn-project/aztec/src/sandbox.ts | 2 +- yarn-project/bb-prover/package.json | 5 +- yarn-project/circuit-types/src/config.ts | 1 + .../circuit-types/src/interfaces/configs.ts | 5 +- yarn-project/cli-wallet/src/cmds/index.ts | 5 +- yarn-project/cli-wallet/src/utils/accounts.ts | 10 ++-- .../cli-wallet/src/utils/options/fees.ts | 34 ++++++------- yarn-project/cli/package.json | 1 + yarn-project/cli/src/cmds/misc/index.ts | 2 - yarn-project/foundation/src/config/env_var.ts | 1 - yarn-project/prover-client/package.json | 5 +- yarn-project/prover-node/src/config.ts | 14 ++--- yarn-project/sequencer-client/package.json | 7 ++- yarn-project/sequencer-client/src/config.ts | 51 ++----------------- .../sequencer-client/src/sequencer/allowed.ts | 36 +++++++++++++ .../sequencer-client/src/sequencer/config.ts | 2 +- .../src/sequencer/sequencer.ts | 8 ++- yarn-project/validator-client/package.json | 7 ++- yarn-project/world-state/package.json | 5 +- 22 files changed, 109 insertions(+), 109 deletions(-) create mode 100644 yarn-project/sequencer-client/src/sequencer/allowed.ts diff --git a/yarn-project/aztec-node/src/aztec-node/config.ts b/yarn-project/aztec-node/src/aztec-node/config.ts index c083a518315..0489f18e909 100644 --- a/yarn-project/aztec-node/src/aztec-node/config.ts +++ b/yarn-project/aztec-node/src/aztec-node/config.ts @@ -1,11 +1,11 @@ -import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver'; +import { type ArchiverConfig, archiverConfigMappings } from '@aztec/archiver/config'; import { type ConfigMappingsType, booleanConfigHelper, getConfigFromMappings } from '@aztec/foundation/config'; import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config'; -import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p'; -import { type ProverClientConfig, proverClientConfigMappings } from '@aztec/prover-client'; -import { type SequencerClientConfig, sequencerClientConfigMappings } from '@aztec/sequencer-client'; -import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client'; -import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state'; +import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config'; +import { type ProverClientConfig, proverClientConfigMappings } from '@aztec/prover-client/config'; +import { type SequencerClientConfig, sequencerClientConfigMappings } from '@aztec/sequencer-client/config'; +import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client/config'; +import { type WorldStateConfig, worldStateConfigMappings } from '@aztec/world-state/config'; import { readFileSync } from 'fs'; import { dirname, resolve } from 'path'; diff --git a/yarn-project/aztec.js/package.json b/yarn-project/aztec.js/package.json index f426c02a05d..830f8f697d5 100644 --- a/yarn-project/aztec.js/package.json +++ b/yarn-project/aztec.js/package.json @@ -17,6 +17,7 @@ "./fields": "./dest/api/fields.js", "./init": "./dest/api/init.js", "./log_id": "./dest/api/log_id.js", + "./rpc": "./dest/rpc_clients/index.js", "./tx_hash": "./dest/api/tx_hash.js", "./wallet": "./dest/api/wallet.js" }, @@ -118,4 +119,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts b/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts index b95c3802fff..f2afd1b3d7c 100644 --- a/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts +++ b/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts @@ -1,4 +1,4 @@ -import { type PXE, PXESchema } from '@aztec/circuit-types'; +import { type PXE, PXESchema } from '@aztec/circuit-types/interfaces'; import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client'; /** diff --git a/yarn-project/aztec/src/sandbox.ts b/yarn-project/aztec/src/sandbox.ts index 83f20067665..a271f11d05f 100644 --- a/yarn-project/aztec/src/sandbox.ts +++ b/yarn-project/aztec/src/sandbox.ts @@ -3,7 +3,7 @@ import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec import { AnvilTestWatcher, EthCheatCodes, SignerlessWallet, retryUntil } from '@aztec/aztec.js'; import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint'; import { type AztecNode } from '@aztec/circuit-types'; -import { setupCanonicalL2FeeJuice } from '@aztec/cli/misc'; +import { setupCanonicalL2FeeJuice } from '@aztec/cli/setup-contracts'; import { type DeployL1Contracts, NULL_KEY, diff --git a/yarn-project/bb-prover/package.json b/yarn-project/bb-prover/package.json index 82b623c73a9..d32a9343fb1 100644 --- a/yarn-project/bb-prover/package.json +++ b/yarn-project/bb-prover/package.json @@ -7,7 +7,8 @@ "./wasm": "./dest/wasm/index.js", "./prover": "./dest/prover/index.js", "./verifier": "./dest/verifier/index.js", - "./test": "./dest/test/index.js" + "./test": "./dest/test/index.js", + "./config": "./dest/config.js" }, "bin": { "bb-cli": "./dest/bb/index.js" @@ -110,4 +111,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/circuit-types/src/config.ts b/yarn-project/circuit-types/src/config.ts index 16e7a95ee1e..73878d18416 100644 --- a/yarn-project/circuit-types/src/config.ts +++ b/yarn-project/circuit-types/src/config.ts @@ -1,2 +1,3 @@ export { ProverAgentConfig, proverAgentConfigMappings } from './interfaces/prover-agent.js'; export { ProverBrokerConfig, proverBrokerConfigMappings } from './interfaces/prover-broker.js'; +export { SequencerConfig, AllowedElement, SequencerConfigSchema } from './interfaces/configs.js'; diff --git a/yarn-project/circuit-types/src/interfaces/configs.ts b/yarn-project/circuit-types/src/interfaces/configs.ts index 1c8398033f6..98c77996484 100644 --- a/yarn-project/circuit-types/src/interfaces/configs.ts +++ b/yarn-project/circuit-types/src/interfaces/configs.ts @@ -34,8 +34,6 @@ export interface SequencerConfig { acvmBinaryPath?: string; /** The list of functions calls allowed to run in setup */ allowedInSetup?: AllowedElement[]; - /** The list of functions calls allowed to run teardown */ - allowedInTeardown?: AllowedElement[]; /** Max block size */ maxBlockSizeInBytes?: number; /** Whether to require every tx to have a fee payer */ @@ -63,8 +61,7 @@ export const SequencerConfigSchema = z.object({ feeRecipient: schemas.AztecAddress.optional(), acvmWorkingDirectory: z.string().optional(), acvmBinaryPath: z.string().optional(), - allowedInSetup: z.array(AllowedElementSchema), - allowedInTeardown: z.array(AllowedElementSchema), + allowedInSetup: z.array(AllowedElementSchema).optional(), maxBlockSizeInBytes: z.number().optional(), enforceFees: z.boolean().optional(), gerousiaPayload: schemas.EthAddress.optional(), diff --git a/yarn-project/cli-wallet/src/cmds/index.ts b/yarn-project/cli-wallet/src/cmds/index.ts index 864aa34ec42..41f280451cd 100644 --- a/yarn-project/cli-wallet/src/cmds/index.ts +++ b/yarn-project/cli-wallet/src/cmds/index.ts @@ -1,6 +1,7 @@ import { getIdentities } from '@aztec/accounts/utils'; -import { TxHash, createCompatibleClient } from '@aztec/aztec.js'; -import { PublicKeys } from '@aztec/circuits.js'; +import { createCompatibleClient } from '@aztec/aztec.js/rpc'; +import { TxHash } from '@aztec/aztec.js/tx_hash'; +import { PublicKeys } from '@aztec/circuits.js/types'; import { ETHEREUM_HOST, PRIVATE_KEY, diff --git a/yarn-project/cli-wallet/src/utils/accounts.ts b/yarn-project/cli-wallet/src/utils/accounts.ts index 8dbca3df63b..33bdbc4a772 100644 --- a/yarn-project/cli-wallet/src/utils/accounts.ts +++ b/yarn-project/cli-wallet/src/utils/accounts.ts @@ -1,10 +1,10 @@ -import { getEcdsaRSSHAccount } from '@aztec/accounts/ecdsa'; -import { getSchnorrAccount } from '@aztec/accounts/schnorr'; import { getIdentities } from '@aztec/accounts/utils'; import { type AccountManager, type AccountWalletWithSecretKey } from '@aztec/aztec.js'; -import { AztecAddress, Fr, deriveSigningKey } from '@aztec/circuits.js'; +import { type PXE } from '@aztec/circuit-types/interfaces'; +import { deriveSigningKey } from '@aztec/circuits.js/keys'; +import { AztecAddress } from '@aztec/foundation/aztec-address'; +import { Fr } from '@aztec/foundation/fields'; -import { type PXE } from '../../../circuit-types/src/interfaces/pxe.js'; import { type WalletDB } from '../storage/wallet_db.js'; import { extractECDSAPublicKeyFromBase64String } from './ecdsa.js'; @@ -38,6 +38,7 @@ export async function createOrRetrieveAccount( switch (type) { case 'schnorr': { + const { getSchnorrAccount } = await import('@aztec/accounts/schnorr'); account = getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt); break; } @@ -58,6 +59,7 @@ export async function createOrRetrieveAccount( throw new Error('Public key must be provided for ECDSA SSH account'); } + const { getEcdsaRSSHAccount } = await import('@aztec/accounts/ecdsa'); account = getEcdsaRSSHAccount(pxe, secretKey, publicSigningKey, salt); break; } diff --git a/yarn-project/cli-wallet/src/utils/options/fees.ts b/yarn-project/cli-wallet/src/utils/options/fees.ts index ef84023d8fa..f0852956a22 100644 --- a/yarn-project/cli-wallet/src/utils/options/fees.ts +++ b/yarn-project/cli-wallet/src/utils/options/fees.ts @@ -1,14 +1,4 @@ -import { - type AccountWallet, - FeeJuicePaymentMethod, - FeeJuicePaymentMethodWithClaim, - type FeePaymentMethod, - NoFeePaymentMethod, - type PXE, - PrivateFeePaymentMethod, - PublicFeePaymentMethod, - type SendMethodOptions, -} from '@aztec/aztec.js'; +import { type AccountWallet, type FeePaymentMethod, type PXE, type SendMethodOptions } from '@aztec/aztec.js'; import { AztecAddress, Fr, Gas, GasFees, GasSettings } from '@aztec/circuits.js'; import { type LogFn } from '@aztec/foundation/log'; @@ -99,10 +89,15 @@ export class FeeOpts implements IFeeOpts { return new NoFeeOpts(estimateOnly, gasSettings); } + const defaultPaymentMethod = async () => { + const { NoFeePaymentMethod } = await import('@aztec/aztec.js/fee'); + return new NoFeePaymentMethod(); + }; + return new FeeOpts( estimateOnly, gasSettings, - args.payment ? parsePaymentMethod(args.payment, log, db) : () => Promise.resolve(new NoFeePaymentMethod()), + args.payment ? parsePaymentMethod(args.payment, log, db) : defaultPaymentMethod, !!args.estimateGas, ); } @@ -147,10 +142,12 @@ export function parsePaymentMethod( return async (sender: AccountWallet) => { switch (parsed.method) { - case 'none': + case 'none': { log('Using no fee payment'); + const { NoFeePaymentMethod } = await import('@aztec/aztec.js/fee'); return new NoFeePaymentMethod(); - case 'native': + } + case 'native': { if (parsed.claim || (parsed.claimSecret && parsed.claimAmount && parsed.messageLeafIndex)) { let claimAmount, claimSecret, messageLeafIndex; if (parsed.claim && db) { @@ -163,6 +160,7 @@ export function parsePaymentMethod( ({ claimAmount, claimSecret, messageLeafIndex } = parsed); } log(`Using Fee Juice for fee payments with claim for ${claimAmount} tokens`); + const { FeeJuicePaymentMethodWithClaim } = await import('@aztec/aztec.js/fee'); return new FeeJuicePaymentMethodWithClaim(sender.getAddress(), { claimAmount: typeof claimAmount === 'string' ? Fr.fromHexString(claimAmount) : new Fr(claimAmount), claimSecret: Fr.fromHexString(claimSecret), @@ -170,18 +168,20 @@ export function parsePaymentMethod( }); } else { log(`Using Fee Juice for fee payment`); + const { FeeJuicePaymentMethod } = await import('@aztec/aztec.js/fee'); return new FeeJuicePaymentMethod(sender.getAddress()); } + } case 'fpc-public': { const [asset, fpc] = getFpcOpts(parsed, db); log(`Using public fee payment with asset ${asset} via paymaster ${fpc}`); + const { PublicFeePaymentMethod } = await import('@aztec/aztec.js/fee'); return new PublicFeePaymentMethod(asset, fpc, sender); } case 'fpc-private': { const [asset, fpc, feeRecipient] = getFpcOpts(parsed, db); - log( - `Using private fee payment with asset ${asset} via paymaster ${fpc} with rebate secret ${feeRecipient.toString()}`, - ); + log(`Using private fee payment with asset ${asset} via paymaster ${fpc} with rebate secret ${feeRecipient}`); + const { PrivateFeePaymentMethod } = await import('@aztec/aztec.js/fee'); return new PrivateFeePaymentMethod(asset, fpc, sender, feeRecipient); } case undefined: diff --git a/yarn-project/cli/package.json b/yarn-project/cli/package.json index 08d1188e20f..31dcf1da552 100644 --- a/yarn-project/cli/package.json +++ b/yarn-project/cli/package.json @@ -10,6 +10,7 @@ "./pxe": "./dest/cmds/pxe/index.js", "./cli-utils": "./dest/utils/index.js", "./misc": "./dest/cmds/misc/index.js", + "./setup-contracts": "./dest/cmds/misc/setup_contracts.js", "./utils": "./dest/utils/index.js", "./inspect": "./dest/utils/inspect.js" }, diff --git a/yarn-project/cli/src/cmds/misc/index.ts b/yarn-project/cli/src/cmds/misc/index.ts index addfbc8283f..b716dd3ad65 100644 --- a/yarn-project/cli/src/cmds/misc/index.ts +++ b/yarn-project/cli/src/cmds/misc/index.ts @@ -4,8 +4,6 @@ import { type Command } from 'commander'; import { prettyPrintJSON } from '../../utils/commands.js'; -export * from './setup_contracts.js'; - export function injectCommands(program: Command, log: LogFn) { program .command('generate-keys') diff --git a/yarn-project/foundation/src/config/env_var.ts b/yarn-project/foundation/src/config/env_var.ts index 6fe16439066..ad999367e4f 100644 --- a/yarn-project/foundation/src/config/env_var.ts +++ b/yarn-project/foundation/src/config/env_var.ts @@ -136,7 +136,6 @@ export type EnvVar = | 'REGISTRY_CONTRACT_ADDRESS' | 'ROLLUP_CONTRACT_ADDRESS' | 'SEQ_ALLOWED_SETUP_FN' - | 'SEQ_ALLOWED_TEARDOWN_FN' | 'SEQ_MAX_BLOCK_SIZE_IN_BYTES' | 'SEQ_MAX_SECONDS_BETWEEN_BLOCKS' | 'SEQ_MAX_TX_PER_BLOCK' diff --git a/yarn-project/prover-client/package.json b/yarn-project/prover-client/package.json index d49befc0e79..c395650e41e 100644 --- a/yarn-project/prover-client/package.json +++ b/yarn-project/prover-client/package.json @@ -8,7 +8,8 @@ "./broker": "./dest/proving_broker/index.js", "./prover-agent": "./dest/prover-agent/index.js", "./orchestrator": "./dest/orchestrator/index.js", - "./helpers": "./dest/orchestrator/block-building-helpers.js" + "./helpers": "./dest/orchestrator/block-building-helpers.js", + "./config": "./dest/config.js" }, "typedocOptions": { "entryPoints": [ @@ -108,4 +109,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/prover-node/src/config.ts b/yarn-project/prover-node/src/config.ts index b609ffd7d5c..7bdde17af5c 100644 --- a/yarn-project/prover-node/src/config.ts +++ b/yarn-project/prover-node/src/config.ts @@ -1,11 +1,11 @@ -import { type ArchiverConfig, archiverConfigMappings, getArchiverConfigFromEnv } from '@aztec/archiver'; -import { type ACVMConfig, type BBConfig } from '@aztec/bb-prover'; +import { type ArchiverConfig, archiverConfigMappings, getArchiverConfigFromEnv } from '@aztec/archiver/config'; +import { type ACVMConfig, type BBConfig } from '@aztec/bb-prover/config'; import { type ProverAgentConfig, type ProverBrokerConfig, proverAgentConfigMappings, proverBrokerConfigMappings, -} from '@aztec/circuit-types'; +} from '@aztec/circuit-types/config'; import { type ConfigMappingsType, bigintConfigHelper, @@ -13,13 +13,13 @@ import { numberConfigHelper, } from '@aztec/foundation/config'; import { type DataStoreConfig, dataConfigMappings, getDataConfigFromEnv } from '@aztec/kv-store/config'; -import { type P2PConfig, getP2PConfigFromEnv, p2pConfigMappings } from '@aztec/p2p'; +import { type P2PConfig, getP2PConfigFromEnv, p2pConfigMappings } from '@aztec/p2p/config'; import { type ProverClientConfig, bbConfigMappings, getProverEnvVars, proverClientConfigMappings, -} from '@aztec/prover-client'; +} from '@aztec/prover-client/config'; import { type PublisherConfig, type TxSenderConfig, @@ -27,8 +27,8 @@ import { getPublisherConfigMappings, getTxSenderConfigFromEnv, getTxSenderConfigMappings, -} from '@aztec/sequencer-client'; -import { type WorldStateConfig, getWorldStateConfigFromEnv, worldStateConfigMappings } from '@aztec/world-state'; +} from '@aztec/sequencer-client/config'; +import { type WorldStateConfig, getWorldStateConfigFromEnv, worldStateConfigMappings } from '@aztec/world-state/config'; import { type ProverBondManagerConfig, proverBondManagerConfigMappings } from './bond/config.js'; import { diff --git a/yarn-project/sequencer-client/package.json b/yarn-project/sequencer-client/package.json index 33437775006..1fcf01f6a85 100644 --- a/yarn-project/sequencer-client/package.json +++ b/yarn-project/sequencer-client/package.json @@ -2,7 +2,10 @@ "name": "@aztec/sequencer-client", "version": "0.1.0", "type": "module", - "exports": "./dest/index.js", + "exports": { + ".": "./dest/index.js", + "./config": "./dest/config.js" + }, "typedocOptions": { "entryPoints": [ "./src/index.ts" @@ -115,4 +118,4 @@ "../../foundation/src/jest/setup.mjs" ] } -} +} \ No newline at end of file diff --git a/yarn-project/sequencer-client/src/config.ts b/yarn-project/sequencer-client/src/config.ts index 0d8ca0a8d2b..5254df78ef8 100644 --- a/yarn-project/sequencer-client/src/config.ts +++ b/yarn-project/sequencer-client/src/config.ts @@ -1,5 +1,5 @@ import { type AllowedElement } from '@aztec/circuit-types'; -import { AztecAddress, Fr, FunctionSelector, getContractClassFromArtifact } from '@aztec/circuits.js'; +import { AztecAddress, Fr, FunctionSelector } from '@aztec/circuits.js'; import { type L1ContractsConfig, type L1ReaderConfig, @@ -14,9 +14,6 @@ import { } from '@aztec/foundation/config'; import { pickConfigMappings } from '@aztec/foundation/config'; import { EthAddress } from '@aztec/foundation/eth-address'; -import { FPCContract } from '@aztec/noir-contracts.js/FPC'; -import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token'; -import { ProtocolContractAddress } from '@aztec/protocol-contracts'; import { type PublisherConfig, @@ -26,6 +23,9 @@ import { } from './publisher/config.js'; import { type SequencerConfig } from './sequencer/config.js'; +export * from './publisher/config.js'; +export * from './sequencer/config.js'; + /** Chain configuration. */ type ChainConfig = { /** The chain id of the ethereum host. */ @@ -92,18 +92,10 @@ export const sequencerConfigMappings: ConfigMappingsType = { allowedInSetup: { env: 'SEQ_ALLOWED_SETUP_FN', parseEnv: (val: string) => parseSequencerAllowList(val), - defaultValue: getDefaultAllowedSetupFunctions(), description: 'The list of functions calls allowed to run in setup', printDefault: () => 'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee', }, - allowedInTeardown: { - env: 'SEQ_ALLOWED_TEARDOWN_FN', - parseEnv: (val: string) => parseSequencerAllowList(val), - defaultValue: getDefaultAllowedTeardownFunctions(), - description: 'The list of functions calls allowed to run teardown', - printDefault: () => 'FPC.pay_refund', - }, maxBlockSizeInBytes: { env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES', description: 'Max block size', @@ -202,38 +194,3 @@ export function parseSequencerAllowList(value: string): AllowedElement[] { return entries; } - -function getDefaultAllowedSetupFunctions(): AllowedElement[] { - return [ - // needed for authwit support - { - address: ProtocolContractAddress.AuthRegistry, - }, - // needed for claiming on the same tx as a spend - { - address: ProtocolContractAddress.FeeJuice, - // We can't restrict the selector because public functions get routed via dispatch. - // selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'), - }, - // needed for private transfers via FPC - { - classId: getContractClassFromArtifact(TokenContractArtifact).id, - // We can't restrict the selector because public functions get routed via dispatch. - // selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'), - }, - { - classId: getContractClassFromArtifact(FPCContract.artifact).id, - // We can't restrict the selector because public functions get routed via dispatch. - // selector: FunctionSelector.fromSignature('prepare_fee((Field),Field,(Field),Field)'), - }, - ]; -} - -function getDefaultAllowedTeardownFunctions(): AllowedElement[] { - return [ - { - classId: getContractClassFromArtifact(FPCContract.artifact).id, - selector: FunctionSelector.fromSignature('pay_refund((Field),Field,(Field))'), - }, - ]; -} diff --git a/yarn-project/sequencer-client/src/sequencer/allowed.ts b/yarn-project/sequencer-client/src/sequencer/allowed.ts new file mode 100644 index 00000000000..164a2a948b7 --- /dev/null +++ b/yarn-project/sequencer-client/src/sequencer/allowed.ts @@ -0,0 +1,36 @@ +import { type AllowedElement } from '@aztec/circuit-types'; +import { getContractClassFromArtifact } from '@aztec/circuits.js'; +import { FPCContract } from '@aztec/noir-contracts.js/FPC'; +import { TokenContractArtifact } from '@aztec/noir-contracts.js/Token'; +import { ProtocolContractAddress } from '@aztec/protocol-contracts'; + +let defaultAllowedSetupFunctions: AllowedElement[] | undefined = undefined; + +export function getDefaultAllowedSetupFunctions(): AllowedElement[] { + if (defaultAllowedSetupFunctions === undefined) { + defaultAllowedSetupFunctions = [ + // needed for authwit support + { + address: ProtocolContractAddress.AuthRegistry, + }, + // needed for claiming on the same tx as a spend + { + address: ProtocolContractAddress.FeeJuice, + // We can't restrict the selector because public functions get routed via dispatch. + // selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'), + }, + // needed for private transfers via FPC + { + classId: getContractClassFromArtifact(TokenContractArtifact).id, + // We can't restrict the selector because public functions get routed via dispatch. + // selector: FunctionSelector.fromSignature('_increase_public_balance((Field),Field)'), + }, + { + classId: getContractClassFromArtifact(FPCContract.artifact).id, + // We can't restrict the selector because public functions get routed via dispatch. + // selector: FunctionSelector.fromSignature('prepare_fee((Field),Field,(Field),Field)'), + }, + ]; + } + return defaultAllowedSetupFunctions; +} diff --git a/yarn-project/sequencer-client/src/sequencer/config.ts b/yarn-project/sequencer-client/src/sequencer/config.ts index 22278911935..268baef40ca 100644 --- a/yarn-project/sequencer-client/src/sequencer/config.ts +++ b/yarn-project/sequencer-client/src/sequencer/config.ts @@ -1 +1 @@ -export { SequencerConfig } from '@aztec/circuit-types'; +export { SequencerConfig } from '@aztec/circuit-types/config'; diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index e6756d5f7b3..c6961d59953 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -38,6 +38,7 @@ import { type GlobalVariableBuilder } from '../global_variable_builder/global_bu import { type L1Publisher } from '../publisher/l1-publisher.js'; import { prettyLogViemErrorMsg } from '../publisher/utils.js'; import { type TxValidatorFactory } from '../tx_validator/tx_validator_factory.js'; +import { getDefaultAllowedSetupFunctions } from './allowed.js'; import { type SequencerConfig } from './config.js'; import { SequencerMetrics } from './metrics.js'; import { SequencerState, getSecondsIntoSlot, orderAttestations } from './utils.js'; @@ -82,7 +83,7 @@ export class Sequencer { private _coinbase = EthAddress.ZERO; private _feeRecipient = AztecAddress.ZERO; private state = SequencerState.STOPPED; - private allowedInSetup: AllowedElement[] = []; + private allowedInSetup: AllowedElement[] = getDefaultAllowedSetupFunctions(); private maxBlockSizeInBytes: number = 1024 * 1024; private metrics: SequencerMetrics; private isFlushing: boolean = false; @@ -127,10 +128,7 @@ export class Sequencer { * @param config - New parameters. */ public updateConfig(config: SequencerConfig) { - this.log.info( - `Sequencer config set`, - omit(pickFromSchema(this.config, SequencerConfigSchema), 'allowedInSetup', 'allowedInTeardown'), - ); + this.log.info(`Sequencer config set`, omit(pickFromSchema(this.config, SequencerConfigSchema), 'allowedInSetup')); if (config.transactionPollingIntervalMS !== undefined) { this.pollingIntervalMs = config.transactionPollingIntervalMS; diff --git a/yarn-project/validator-client/package.json b/yarn-project/validator-client/package.json index 637cbb5a31e..e14fc7e52c3 100644 --- a/yarn-project/validator-client/package.json +++ b/yarn-project/validator-client/package.json @@ -3,7 +3,10 @@ "version": "0.1.0", "main": "dest/index.js", "type": "module", - "exports": "./dest/index.js", + "exports": { + ".": "./dest/index.js", + "./config": "./dest/config.js" + }, "bin": "./dest/bin/index.js", "typedocOptions": { "entryPoints": [ @@ -94,4 +97,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file diff --git a/yarn-project/world-state/package.json b/yarn-project/world-state/package.json index 4da25512fd1..b3cc7dadddd 100644 --- a/yarn-project/world-state/package.json +++ b/yarn-project/world-state/package.json @@ -4,7 +4,8 @@ "type": "module", "exports": { ".": "./dest/index.js", - "./native": "./dest/native/index.js" + "./native": "./dest/native/index.js", + "./config": "./dest/synchronizer/config.js" }, "typedocOptions": { "entryPoints": [ @@ -101,4 +102,4 @@ "engines": { "node": ">=18" } -} +} \ No newline at end of file From f9fe6777bfdb62fbcb34e58477c01798f1d18f0c Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 16 Dec 2024 22:18:16 -0300 Subject: [PATCH 3/3] Fix build issue --- yarn-project/sequencer-client/src/config.ts | 5 ++--- yarn-project/sequencer-client/src/index.ts | 1 - yarn-project/sequencer-client/src/publisher/index.ts | 1 - yarn-project/sequencer-client/src/sequencer/config.ts | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/yarn-project/sequencer-client/src/config.ts b/yarn-project/sequencer-client/src/config.ts index 5254df78ef8..47f06247b53 100644 --- a/yarn-project/sequencer-client/src/config.ts +++ b/yarn-project/sequencer-client/src/config.ts @@ -1,4 +1,4 @@ -import { type AllowedElement } from '@aztec/circuit-types'; +import { type AllowedElement, type SequencerConfig } from '@aztec/circuit-types/config'; import { AztecAddress, Fr, FunctionSelector } from '@aztec/circuits.js'; import { type L1ContractsConfig, @@ -21,10 +21,9 @@ import { getPublisherConfigMappings, getTxSenderConfigMappings, } from './publisher/config.js'; -import { type SequencerConfig } from './sequencer/config.js'; export * from './publisher/config.js'; -export * from './sequencer/config.js'; +export { SequencerConfig }; /** Chain configuration. */ type ChainConfig = { diff --git a/yarn-project/sequencer-client/src/index.ts b/yarn-project/sequencer-client/src/index.ts index 1718ed0a3a6..cb826f2c545 100644 --- a/yarn-project/sequencer-client/src/index.ts +++ b/yarn-project/sequencer-client/src/index.ts @@ -1,7 +1,6 @@ export * from './client/index.js'; export * from './config.js'; export * from './publisher/index.js'; -export * from './sequencer/index.js'; // Used by the node to simulate public parts of transactions. Should these be moved to a shared library? // ISSUE(#9832) diff --git a/yarn-project/sequencer-client/src/publisher/index.ts b/yarn-project/sequencer-client/src/publisher/index.ts index 5590025020a..f0a2f3b5092 100644 --- a/yarn-project/sequencer-client/src/publisher/index.ts +++ b/yarn-project/sequencer-client/src/publisher/index.ts @@ -1,3 +1,2 @@ export { L1Publisher, L1SubmitEpochProofArgs } from './l1-publisher.js'; export * from './test-l1-publisher.js'; -export * from './config.js'; diff --git a/yarn-project/sequencer-client/src/sequencer/config.ts b/yarn-project/sequencer-client/src/sequencer/config.ts index 268baef40ca..5bdc2772a99 100644 --- a/yarn-project/sequencer-client/src/sequencer/config.ts +++ b/yarn-project/sequencer-client/src/sequencer/config.ts @@ -1 +1 @@ -export { SequencerConfig } from '@aztec/circuit-types/config'; +export { type SequencerConfig } from '@aztec/circuit-types/config';