From e27cd6511ad0f915ee4877a730039b6772061fff Mon Sep 17 00:00:00 2001 From: Alex Gherghisan Date: Sun, 24 Mar 2024 14:29:17 +0000 Subject: [PATCH] feat: use zod for config --- cspell.json | 1 + yarn-project/aztec/src/cli/cmds/start_node.ts | 41 ++--- .../circuit-types/src/interfaces/configs.ts | 53 +++++-- .../ethereum/src/l1_contract_addresses.ts | 13 ++ yarn-project/foundation/package.json | 3 +- .../foundation/src/aztec-address/index.ts | 24 +++ .../foundation/src/eth-address/index.ts | 21 +++ yarn-project/foundation/src/zod/index.ts | 30 ++++ .../src/client/sequencer-client.ts | 2 +- yarn-project/sequencer-client/src/config.ts | 143 ++++++++---------- .../src/global_variable_builder/config.ts | 9 +- .../sequencer-client/src/publisher/config.ts | 42 +++-- .../src/sequencer/sequencer.test.ts | 5 +- .../src/sequencer/sequencer.ts | 4 +- 14 files changed, 255 insertions(+), 136 deletions(-) create mode 100644 yarn-project/foundation/src/zod/index.ts diff --git a/cspell.json b/cspell.json index f6c12ff5d82e..76b6c5779c05 100644 --- a/cspell.json +++ b/cspell.json @@ -201,6 +201,7 @@ "SSTORE", "staticcall", "stdlib", + "stringly", "struct", "structs", "subarrays", diff --git a/yarn-project/aztec/src/cli/cmds/start_node.ts b/yarn-project/aztec/src/cli/cmds/start_node.ts index f498b42fdef5..6f8c7e884328 100644 --- a/yarn-project/aztec/src/cli/cmds/start_node.ts +++ b/yarn-project/aztec/src/cli/cmds/start_node.ts @@ -9,7 +9,7 @@ import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts'; import { MNEMONIC, createAztecNode, createAztecPXE, deployContractsToL1 } from '../../sandbox.js'; import { mergeEnvVarsAndCliOptions, parseModuleOptions } from '../util.js'; -const { DEPLOY_AZTEC_CONTRACTS } = process.env; +const { DEPLOY_AZTEC_CONTRACTS = '' } = process.env; export const startNode = async ( options: any, @@ -23,7 +23,26 @@ export const startNode = async ( // get config from options const nodeCliOptions = parseModuleOptions(options.node); // merge env vars and cli options - let nodeConfig = mergeEnvVarsAndCliOptions(aztecNodeConfigEnvVars, nodeCliOptions); + let nodeConfig = mergeEnvVarsAndCliOptions(aztecNodeConfigEnvVars, { + ...nodeCliOptions, + ...parseModuleOptions(options.archiver), + ...parseModuleOptions(options.sequencer), + ...parseModuleOptions(options.prover), + }); + + let hdAccount; + if (nodeConfig.publisherPrivateKey === NULL_KEY) { + hdAccount = mnemonicToAccount(MNEMONIC); + const privKey = hdAccount.getHdKey().privateKey; + nodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey!).toString('hex')}`; + } else { + hdAccount = privateKeyToAccount(nodeConfig.publisherPrivateKey); + } + + // Deploy contracts if needed + if (nodeCliOptions.deployAztecContracts || ['1', 'true'].includes(DEPLOY_AZTEC_CONTRACTS)) { + await deployContractsToL1(nodeConfig, hdAccount); + } // if no publisher private key, then use MNEMONIC if (!options.archiver) { @@ -36,27 +55,11 @@ export const startNode = async ( nodeConfig.archiverUrl = archiverUrl; } else { const archiverCliOptions = parseModuleOptions(options.archiver); - nodeConfig = mergeEnvVarsAndCliOptions(aztecNodeConfigEnvVars, archiverCliOptions, true); - } - - // Deploy contracts if needed - if (nodeCliOptions.deployAztecContracts || DEPLOY_AZTEC_CONTRACTS === 'true') { - let account; - if (nodeConfig.publisherPrivateKey === NULL_KEY) { - account = mnemonicToAccount(MNEMONIC); - } else { - account = privateKeyToAccount(nodeConfig.publisherPrivateKey); - } - await deployContractsToL1(nodeConfig, account); + nodeConfig = mergeEnvVarsAndCliOptions(nodeConfig, archiverCliOptions, true); } if (!options.sequencer) { nodeConfig.disableSequencer = true; - } else if (nodeConfig.publisherPrivateKey === NULL_KEY) { - // If we have a sequencer, ensure there's a publisher private key set. - const hdAccount = mnemonicToAccount(MNEMONIC); - const privKey = hdAccount.getHdKey().privateKey; - nodeConfig.publisherPrivateKey = `0x${Buffer.from(privKey!).toString('hex')}`; } if (!options.prover) { diff --git a/yarn-project/circuit-types/src/interfaces/configs.ts b/yarn-project/circuit-types/src/interfaces/configs.ts index 80198bfca29c..a33cb4a049b8 100644 --- a/yarn-project/circuit-types/src/interfaces/configs.ts +++ b/yarn-project/circuit-types/src/interfaces/configs.ts @@ -1,27 +1,48 @@ -import { AztecAddress, EthAddress, Fr } from '@aztec/circuits.js'; +import { aztecAddress, ethAddress, fr, stringlyNumber, z } from '@aztec/foundation/zod'; -/** - * The sequencer configuration. - */ -export interface SequencerConfig { +export const sequencerConfig = z.object({ /** The number of ms to wait between polling for pending txs. */ - transactionPollingIntervalMS?: number; + transactionPollingIntervalMS: stringlyNumber.optional().default(1_000), /** The maximum number of txs to include in a block. */ - maxTxsPerBlock?: number; + maxTxsPerBlock: stringlyNumber.optional().default(32), /** The minimum number of txs to include in a block. */ - minTxsPerBlock?: number; + minTxsPerBlock: stringlyNumber.optional().default(1), /** Recipient of block reward. */ - coinbase?: EthAddress; + coinbase: ethAddress.optional(), /** Address to receive fees. */ - feeRecipient?: AztecAddress; + feeRecipient: aztecAddress.optional(), /** The working directory to use for simulation/proving */ - acvmWorkingDirectory?: string; + acvmWorkingDirectory: z.string().optional(), /** The path to the ACVM binary */ - acvmBinaryPath?: string; + acvmBinaryPath: z.string().optional(), /** The list of permitted fee payment contract classes */ - allowedFeePaymentContractClasses?: Fr[]; - + allowedFeePaymentContractClasses: z + .preprocess(val => { + if (typeof val === 'string') { + return val.split(','); + } else { + return z.NEVER; + } + }, z.array(fr)) + .or(z.array(fr)) + .optional() + .default([]), /** The list of permitted fee payment contract instances. Takes precedence over contract classes */ - allowedFeePaymentContractInstances?: AztecAddress[]; -} + allowedFeePaymentContractInstances: z + .preprocess(val => { + if (typeof val === 'string') { + return val.split(','); + } else { + return z.NEVER; + } + }, z.array(aztecAddress)) + .or(z.array(aztecAddress)) + .optional() + .default([]), +}); + +/** + * The sequencer configuration. + */ +export type SequencerConfig = z.infer; diff --git a/yarn-project/ethereum/src/l1_contract_addresses.ts b/yarn-project/ethereum/src/l1_contract_addresses.ts index ff4e4c6a3738..e614d6b4721e 100644 --- a/yarn-project/ethereum/src/l1_contract_addresses.ts +++ b/yarn-project/ethereum/src/l1_contract_addresses.ts @@ -1,4 +1,5 @@ import { EthAddress } from '@aztec/foundation/eth-address'; +import { optionalEthAddress, z } from '@aztec/foundation/zod'; export const l1ContractsNames = [ 'availabilityOracleAddress', @@ -16,3 +17,15 @@ export const l1ContractsNames = [ export type L1ContractAddresses = { [K in (typeof l1ContractsNames)[number]]: EthAddress; }; + +export const l1ContractAddresses = z + .object>({ + availabilityOracleAddress: optionalEthAddress, + rollupAddress: optionalEthAddress, + registryAddress: optionalEthAddress, + inboxAddress: optionalEthAddress, + outboxAddress: optionalEthAddress, + gasTokenAddress: optionalEthAddress, + gasPortalAddress: optionalEthAddress, + }) + .default({}); diff --git a/yarn-project/foundation/package.json b/yarn-project/foundation/package.json index 780d5cd721f0..40fb54c32e4c 100644 --- a/yarn-project/foundation/package.json +++ b/yarn-project/foundation/package.json @@ -39,7 +39,8 @@ "./noir": "./dest/noir/index.js", "./testing": "./dest/testing/index.js", "./array": "./dest/array/index.js", - "./validation": "./dest/validation/index.js" + "./validation": "./dest/validation/index.js", + "./zod": "./dest/zod/index.js" }, "scripts": { "build": "yarn clean && tsc -b", diff --git a/yarn-project/foundation/src/aztec-address/index.ts b/yarn-project/foundation/src/aztec-address/index.ts index ea1407b9eaa0..43a01426ba22 100644 --- a/yarn-project/foundation/src/aztec-address/index.ts +++ b/yarn-project/foundation/src/aztec-address/index.ts @@ -53,4 +53,28 @@ export class AztecAddress extends Fr { static random() { return new AztecAddress(super.random().toBuffer()); } + + static isAddress(address: string): boolean { + if (/^(0x)?[0-9a-f]{64}$/i.test(address)) { + return true; + } + + return false; + } + + static isAztecAddress(value: any): value is AztecAddress { + if (!value || typeof value !== 'object') { + return false; + } + + if (value instanceof AztecAddress) { + return true; + } + + if ('buffer' in value && Buffer.isBuffer(value.buffer) && value.buffer.length === AztecAddress.SIZE_IN_BYTES) { + return true; + } + + return false; + } } diff --git a/yarn-project/foundation/src/eth-address/index.ts b/yarn-project/foundation/src/eth-address/index.ts index f61c1f75b4fd..5a5b07f2e482 100644 --- a/yarn-project/foundation/src/eth-address/index.ts +++ b/yarn-project/foundation/src/eth-address/index.ts @@ -74,6 +74,27 @@ export class EthAddress { } } + /** + * Checks if the given value is an EthAddress instance even if the prototype chain is incorrect + * @param value - A value to check if it is an EthAddress instance. + * @returns Whether the value is an EthAddress instance. + */ + public static isEthAddress(value: any): value is EthAddress { + if (!value || typeof value !== 'object') { + return false; + } + + if (value instanceof EthAddress) { + return true; + } + + if ('buffer' in value && Buffer.isBuffer(value.buffer) && value.buffer.length === EthAddress.SIZE_IN_BYTES) { + return true; + } + + return false; + } + /** * Checks if the EthAddress instance represents a zero address. * A zero address consists of 20 bytes filled with zeros and is considered an invalid address. diff --git a/yarn-project/foundation/src/zod/index.ts b/yarn-project/foundation/src/zod/index.ts new file mode 100644 index 000000000000..2346b24b0bf4 --- /dev/null +++ b/yarn-project/foundation/src/zod/index.ts @@ -0,0 +1,30 @@ +import { z } from 'zod'; + +import { AztecAddress } from '../aztec-address/index.js'; +import { EthAddress } from '../eth-address/index.js'; +import { Fr } from '../fields/fields.js'; + +export const ethAddress = z + .custom<`0x${string}` | EthAddress>( + val => (typeof val === 'string' && EthAddress.isAddress(val)) || EthAddress.isEthAddress(val), + ) + .transform(val => (typeof val === 'string' ? EthAddress.fromString(val) : val)); + +export const optionalEthAddress = ethAddress.optional().default(EthAddress.ZERO); + +export const aztecAddress = z + .custom<`0x${string}` | AztecAddress>( + val => (typeof val === 'string' && AztecAddress.isAddress(val)) || AztecAddress.isAztecAddress(val), + ) + .transform(val => (typeof val === 'string' ? AztecAddress.fromString(val) : val)); + +export const stringlyNumber = z.number().or(z.string()).pipe(z.coerce.number()); + +export const fr = z + .number() + .or(z.string()) + .or(z.bigint()) + .or(z.instanceof(Fr)) + .transform(val => (typeof val === 'string' ? Fr.fromString(val) : new Fr(val))); + +export { z }; diff --git a/yarn-project/sequencer-client/src/client/sequencer-client.ts b/yarn-project/sequencer-client/src/client/sequencer-client.ts index 79a96f8fe14f..6280b6fed5a9 100644 --- a/yarn-project/sequencer-client/src/client/sequencer-client.ts +++ b/yarn-project/sequencer-client/src/client/sequencer-client.ts @@ -67,7 +67,7 @@ export class SequencerClient { * Updates sequencer config. * @param config - New parameters. */ - public updateSequencerConfig(config: SequencerConfig) { + public updateSequencerConfig(config: Partial) { this.sequencer.updateConfig(config); } diff --git a/yarn-project/sequencer-client/src/config.ts b/yarn-project/sequencer-client/src/config.ts index f54dabbe3a9e..4c991edb6a85 100644 --- a/yarn-project/sequencer-client/src/config.ts +++ b/yarn-project/sequencer-client/src/config.ts @@ -1,98 +1,83 @@ -import { AztecAddress, Fr } from '@aztec/circuits.js'; -import { L1ContractAddresses, NULL_KEY } from '@aztec/ethereum'; -import { EthAddress } from '@aztec/foundation/eth-address'; +import { sequencerConfig } from '@aztec/circuit-types'; +import { stringlyNumber, z } from '@aztec/foundation/zod'; -import { Hex } from 'viem'; - -import { GlobalReaderConfig } from './global_variable_builder/index.js'; -import { PublisherConfig, TxSenderConfig } from './publisher/config.js'; -import { SequencerConfig } from './sequencer/config.js'; +import { globalReaderConfig } from './global_variable_builder/config.js'; +import { publisherConfig, txSenderConfig } from './publisher/config.js'; /** Chain configuration. */ -type ChainConfig = { +const chainConfig = z.object({ /** The chain id of the ethereum host. */ - chainId: number; + chainId: stringlyNumber.default(31337), // 31337 is the default chain id for anvil /** The version of the rollup. */ - version: number; -}; + version: stringlyNumber.default(1), // 1 is our default version +}); + +const sequencerClientConfig = publisherConfig + .merge(txSenderConfig) + .merge(sequencerConfig) + .merge(globalReaderConfig) + .merge(chainConfig); /** * Configuration settings for the SequencerClient. */ -export type SequencerClientConfig = PublisherConfig & - TxSenderConfig & - SequencerConfig & - GlobalReaderConfig & - ChainConfig; +export type SequencerClientConfig = z.infer; /** * Creates an instance of SequencerClientConfig out of environment variables using sensible defaults for integration testing if not set. */ export function getConfigEnvVars(): SequencerClientConfig { const { - SEQ_PUBLISHER_PRIVATE_KEY, - ETHEREUM_HOST, - CHAIN_ID, - VERSION, - API_KEY, - SEQ_REQUIRED_CONFIRMATIONS, - SEQ_PUBLISH_RETRY_INTERVAL_MS, - SEQ_TX_POLLING_INTERVAL_MS, - SEQ_MAX_TX_PER_BLOCK, - SEQ_MIN_TX_PER_BLOCK, - SEQ_FPC_CLASSES, - SEQ_FPC_INSTANCES, - AVAILABILITY_ORACLE_CONTRACT_ADDRESS, - ROLLUP_CONTRACT_ADDRESS, - REGISTRY_CONTRACT_ADDRESS, - INBOX_CONTRACT_ADDRESS, - OUTBOX_CONTRACT_ADDRESS, - GAS_TOKEN_CONTRACT_ADDRESS, - GAS_PORTAL_CONTRACT_ADDRESS, - COINBASE, - FEE_RECIPIENT, - ACVM_WORKING_DIRECTORY, - ACVM_BINARY_PATH, + SEQ_PUBLISHER_PRIVATE_KEY: publisherPrivateKey, + ETHEREUM_HOST: rpcUrl, + CHAIN_ID: chainId, + VERSION: version, + API_KEY: apiKey, + SEQ_REQUIRED_CONFIRMATIONS: requiredConfirmations, + SEQ_PUBLISH_RETRY_INTERVAL_MS: l1BlockPublishRetryIntervalMS, + SEQ_TX_POLLING_INTERVAL_MS: transactionPollingIntervalMS, + SEQ_MAX_TX_PER_BLOCK: maxTxsPerBlock, + SEQ_MIN_TX_PER_BLOCK: minTxsPerBlock, + SEQ_FPC_CLASSES: allowedFeePaymentContractClasses, + SEQ_FPC_INSTANCES: allowedFeePaymentContractInstances, + AVAILABILITY_ORACLE_CONTRACT_ADDRESS: availabilityOracleAddress, + ROLLUP_CONTRACT_ADDRESS: rollupAddress, + REGISTRY_CONTRACT_ADDRESS: registryAddress, + INBOX_CONTRACT_ADDRESS: inboxAddress, + OUTBOX_CONTRACT_ADDRESS: outboxAddress, + GAS_TOKEN_CONTRACT_ADDRESS: gasTokenAddress, + GAS_PORTAL_CONTRACT_ADDRESS: gasPortalAddress, + COINBASE: coinbase, + FEE_RECIPIENT: feeRecipient, + ACVM_WORKING_DIRECTORY: acvmWorkingDirectory, + ACVM_BINARY_PATH: acvmBinaryPath, } = process.env; - const publisherPrivateKey: Hex = SEQ_PUBLISHER_PRIVATE_KEY - ? `0x${SEQ_PUBLISHER_PRIVATE_KEY.replace('0x', '')}` - : NULL_KEY; - // Populate the relevant addresses for use by the sequencer - const addresses: L1ContractAddresses = { - availabilityOracleAddress: AVAILABILITY_ORACLE_CONTRACT_ADDRESS - ? EthAddress.fromString(AVAILABILITY_ORACLE_CONTRACT_ADDRESS) - : EthAddress.ZERO, - rollupAddress: ROLLUP_CONTRACT_ADDRESS ? EthAddress.fromString(ROLLUP_CONTRACT_ADDRESS) : EthAddress.ZERO, - registryAddress: REGISTRY_CONTRACT_ADDRESS ? EthAddress.fromString(REGISTRY_CONTRACT_ADDRESS) : EthAddress.ZERO, - inboxAddress: INBOX_CONTRACT_ADDRESS ? EthAddress.fromString(INBOX_CONTRACT_ADDRESS) : EthAddress.ZERO, - outboxAddress: OUTBOX_CONTRACT_ADDRESS ? EthAddress.fromString(OUTBOX_CONTRACT_ADDRESS) : EthAddress.ZERO, - gasTokenAddress: GAS_TOKEN_CONTRACT_ADDRESS ? EthAddress.fromString(GAS_TOKEN_CONTRACT_ADDRESS) : EthAddress.ZERO, - gasPortalAddress: GAS_PORTAL_CONTRACT_ADDRESS - ? EthAddress.fromString(GAS_PORTAL_CONTRACT_ADDRESS) - : EthAddress.ZERO, - }; - - return { - rpcUrl: ETHEREUM_HOST ? ETHEREUM_HOST : '', - chainId: CHAIN_ID ? +CHAIN_ID : 31337, // 31337 is the default chain id for anvil - version: VERSION ? +VERSION : 1, // 1 is our default version - apiKey: API_KEY, - requiredConfirmations: SEQ_REQUIRED_CONFIRMATIONS ? +SEQ_REQUIRED_CONFIRMATIONS : 1, - l1BlockPublishRetryIntervalMS: SEQ_PUBLISH_RETRY_INTERVAL_MS ? +SEQ_PUBLISH_RETRY_INTERVAL_MS : 1_000, - transactionPollingIntervalMS: SEQ_TX_POLLING_INTERVAL_MS ? +SEQ_TX_POLLING_INTERVAL_MS : 1_000, - l1Contracts: addresses, + return sequencerClientConfig.parse({ + rpcUrl, + chainId, + version, + apiKey, + requiredConfirmations, + l1BlockPublishRetryIntervalMS, + transactionPollingIntervalMS, + l1Contracts: { + availabilityOracleAddress, + rollupAddress, + registryAddress, + inboxAddress, + outboxAddress, + gasTokenAddress, + gasPortalAddress, + }, publisherPrivateKey, - maxTxsPerBlock: SEQ_MAX_TX_PER_BLOCK ? +SEQ_MAX_TX_PER_BLOCK : 32, - minTxsPerBlock: SEQ_MIN_TX_PER_BLOCK ? +SEQ_MIN_TX_PER_BLOCK : 1, - // TODO: undefined should not be allowed for the following 2 values in PROD - coinbase: COINBASE ? EthAddress.fromString(COINBASE) : undefined, - feeRecipient: FEE_RECIPIENT ? AztecAddress.fromString(FEE_RECIPIENT) : undefined, - acvmWorkingDirectory: ACVM_WORKING_DIRECTORY ? ACVM_WORKING_DIRECTORY : undefined, - acvmBinaryPath: ACVM_BINARY_PATH ? ACVM_BINARY_PATH : undefined, - allowedFeePaymentContractClasses: SEQ_FPC_CLASSES ? SEQ_FPC_CLASSES.split(',').map(Fr.fromString) : [], - allowedFeePaymentContractInstances: SEQ_FPC_INSTANCES - ? SEQ_FPC_INSTANCES.split(',').map(AztecAddress.fromString) - : [], - }; + maxTxsPerBlock, + minTxsPerBlock, + allowedFeePaymentContractClasses, + allowedFeePaymentContractInstances, + coinbase, + feeRecipient, + acvmWorkingDirectory, + acvmBinaryPath, + }); } diff --git a/yarn-project/sequencer-client/src/global_variable_builder/config.ts b/yarn-project/sequencer-client/src/global_variable_builder/config.ts index 2884374561a9..02993e3a4f67 100644 --- a/yarn-project/sequencer-client/src/global_variable_builder/config.ts +++ b/yarn-project/sequencer-client/src/global_variable_builder/config.ts @@ -1,4 +1,5 @@ -import { L1ContractAddresses } from '@aztec/ethereum'; +import { L1ContractAddresses, l1ContractAddresses } from '@aztec/ethereum'; +import { z } from '@aztec/foundation/zod'; /** * Configuration of the L1GlobalReader. @@ -18,3 +19,9 @@ export interface GlobalReaderConfig { */ l1Contracts: L1ContractAddresses; } + +export const globalReaderConfig = z.object({ + rpcUrl: z.string().url().optional().default('http://127.0.0.1:8545'), + apiKey: z.string().optional(), + l1Contracts: l1ContractAddresses, +}); diff --git a/yarn-project/sequencer-client/src/publisher/config.ts b/yarn-project/sequencer-client/src/publisher/config.ts index 96ad07bd6f15..d3bb53c1f46d 100644 --- a/yarn-project/sequencer-client/src/publisher/config.ts +++ b/yarn-project/sequencer-client/src/publisher/config.ts @@ -1,41 +1,53 @@ -import { L1ContractAddresses } from '@aztec/ethereum'; +import { NULL_KEY, l1ContractAddresses } from '@aztec/ethereum'; +import { stringlyNumber, z } from '@aztec/foundation/zod'; -/** - * The configuration of the rollup transaction publisher. - */ -export interface TxSenderConfig { +export const txSenderConfig = z.object({ /** * The private key to be used by the publisher. */ - publisherPrivateKey: `0x${string}`; + publisherPrivateKey: z + .string() + .regex(/^0x[0-9a-f]+$/i) + .optional() + .default(NULL_KEY) + .transform((val): `0x${string}` => { + return val.startsWith('0x') ? (val as `0x${string}`) : `0x${val}`; + }), /** * The RPC Url of the ethereum host. */ - rpcUrl: string; + rpcUrl: z.string().url().optional().default('http://127.0.0.1:8545'), /** * The API key of the ethereum host. */ - apiKey?: string; + apiKey: z.string().optional(), /** * The number of confirmations required. */ - requiredConfirmations: number; + requiredConfirmations: stringlyNumber.default(1), /** * The deployed l1 contract addresses */ - l1Contracts: L1ContractAddresses; -} + l1Contracts: l1ContractAddresses, +}); /** - * Configuration of the L1Publisher. + * The configuration of the rollup transaction publisher. */ -export interface PublisherConfig { +export type TxSenderConfig = z.infer; + +export const publisherConfig = z.object({ /** * The interval to wait between publish retries. */ - l1BlockPublishRetryIntervalMS: number; -} + l1BlockPublishRetryIntervalMS: stringlyNumber.default(1000), +}); + +/** + * Configuration of the L1Publisher. + */ +export type PublisherConfig = z.infer; diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts index ed46187cd94c..6e2b4473a887 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts @@ -10,6 +10,7 @@ import { makeEmptyProcessedTx, makeProcessedTx, mockTx, + sequencerConfig, } from '@aztec/circuit-types'; import { AztecAddress, @@ -104,9 +105,9 @@ describe('sequencer', () => { l1ToL2MessageSource, publicProcessorFactory, new TxValidatorFactory(merkleTreeOps, contractSource, EthAddress.random()), - { + sequencerConfig.parse({ allowedFeePaymentContractClasses: [fpcClassId], - }, + }), ); }); diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index 4823f48d3fa6..6d793a370b57 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -48,7 +48,7 @@ export class Sequencer { private l1ToL2MessageSource: L1ToL2MessageSource, private publicProcessorFactory: PublicProcessorFactory, private txValidatorFactory: TxValidatorFactory, - config: SequencerConfig = {}, + config: SequencerConfig, private log = createDebugLogger('aztec:sequencer'), ) { this.updateConfig(config); @@ -59,7 +59,7 @@ export class Sequencer { * Updates sequencer config. * @param config - New parameters. */ - public updateConfig(config: SequencerConfig) { + public updateConfig(config: Partial) { if (config.transactionPollingIntervalMS) { this.pollingIntervalMs = config.transactionPollingIntervalMS; }