From 9defad092717dcd3bd7d7baaa4e3685fc94b656f Mon Sep 17 00:00:00 2001 From: saleel Date: Fri, 13 Dec 2024 21:52:23 +0000 Subject: [PATCH] feat: enable profiling with local PXE in cli-wallet --- yarn-project/cli-wallet/src/bin/index.ts | 9 ++++++++- yarn-project/cli-wallet/src/utils/pxe_wrapper.ts | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/yarn-project/cli-wallet/src/bin/index.ts b/yarn-project/cli-wallet/src/bin/index.ts index 1147134a56f..0954a5123f2 100644 --- a/yarn-project/cli-wallet/src/bin/index.ts +++ b/yarn-project/cli-wallet/src/bin/index.ts @@ -88,9 +88,16 @@ async function main() { ) .hook('preSubcommand', async command => { const { dataDir, remotePxe, nodeUrl } = command.optsWithGlobals(); + if (!remotePxe) { debugLogger.info('Using local PXE service'); - await pxeWrapper.init(nodeUrl, join(dataDir, 'pxe')); + const subcommand = command.args[0]; + const isProfiling = command.args.includes('--profile'); + const enableProving = subcommand === 'simulate' && isProfiling; + + await pxeWrapper.init(nodeUrl, join(dataDir, 'pxe'), { + proverEnabled: enableProving, + }); } db.init(AztecLmdbStore.open(dataDir)); }); diff --git a/yarn-project/cli-wallet/src/utils/pxe_wrapper.ts b/yarn-project/cli-wallet/src/utils/pxe_wrapper.ts index 4fcf026373a..f0621737fb7 100644 --- a/yarn-project/cli-wallet/src/utils/pxe_wrapper.ts +++ b/yarn-project/cli-wallet/src/utils/pxe_wrapper.ts @@ -1,5 +1,5 @@ import { type PXE, createAztecNodeClient } from '@aztec/circuit-types'; -import { createPXEService, getPXEServiceConfig } from '@aztec/pxe'; +import { type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe'; /* * Wrapper class for PXE service, avoids initialization issues due to @@ -12,9 +12,9 @@ export class PXEWrapper { return PXEWrapper.pxe; } - async init(nodeUrl: string, dataDir: string) { + async init(nodeUrl: string, dataDir: string, overridePXEServiceConfig?: Partial) { const aztecNode = createAztecNodeClient(nodeUrl); - const pxeConfig = getPXEServiceConfig(); + const pxeConfig = Object.assign(getPXEServiceConfig(), overridePXEServiceConfig); pxeConfig.dataDirectory = dataDir; PXEWrapper.pxe = await createPXEService(aztecNode, pxeConfig); }