From 73844798afa8781d72a378ca257cebb6fa5a358a Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Mon, 16 Dec 2024 19:47:42 -0300 Subject: [PATCH] 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 c083a5183157..0489f18e9092 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 f426c02a05d5..830f8f697d50 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 b95c3802fffb..f2afd1b3d7cb 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 83f20067665d..a271f11d05fe 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 9dff8dc8a802..f91bc05f7ffc 100644 --- a/yarn-project/bb-prover/package.json +++ b/yarn-project/bb-prover/package.json @@ -6,7 +6,8 @@ ".": "./dest/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" @@ -107,4 +108,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 16e7a95ee1e1..73878d18416a 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 1c8398033f60..98c779964842 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 864aa34ec425..41f280451cd2 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 8dbca3df63bb..33bdbc4a772c 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 ef84023d8fa2..f0852956a224 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 08d1188e20f2..31dcf1da552a 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 addfbc8283fe..b716dd3ad65a 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 6fe164390660..ad999367e4f5 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 d49befc0e794..c395650e41e9 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 b609ffd7d5ce..7bdde17af5c9 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 334377750069..1fcf01f6a858 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 0d8ca0a8d2bd..5254df78ef8b 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 000000000000..164a2a948b7e --- /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 222789119350..268baef40ca6 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 e6756d5f7b3d..c6961d599532 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 637cbb5a31e3..e14fc7e52c33 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 4da25512fd15..b3cc7dadddd1 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