Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable profiling with local PXE in cli-wallet #10736

Merged
merged 10 commits into from
Dec 20, 2024
5 changes: 4 additions & 1 deletion aztec-up/bin/aztec-wallet
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ set -euo pipefail

export SKIP_PORT_ASSIGNMENT=1
export WALLET_DATA_DIRECTORY=$(dirname $0)/wallet-data
export ENV_VARS_TO_INJECT="WALLET_DATA_DIRECTORY SSH_AUTH_SOCK"
export BB_WORKING_DIRECTORY=$(dirname $0)/bb-workdir
export BB_BINARY_PATH=$(which bb)
export ENV_VARS_TO_INJECT="WALLET_DATA_DIRECTORY SSH_AUTH_SOCK PXE_PROVER_ENABLED BB_BINARY_PATH BB_WORKING_DIRECTORY"

mkdir -p $BB_WORKING_DIRECTORY
mkdir -p $WALLET_DATA_DIRECTORY

$(dirname $0)/.aztec-run aztecprotocol/cli-wallet $@
19 changes: 18 additions & 1 deletion yarn-project/cli-wallet/src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,28 @@ async function main() {
.env('AZTEC_NODE_URL')
.default(`http://${LOCALHOST}:8080`),
)
.addOption(
new Option('-b, --bb-binary-path <string>', 'Path to the BB binary')
.env('BB_BINARY_PATH')
.default(`$HOME/.bb/bb`),
)
.addOption(
new Option('-w, --bb-working-directory <string>', 'Path to the BB working directory')
.env('BB_WORKING_DIRECTORY')
.default(`$HOME/.bb-workdir`),
)
.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));
});
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/cli-wallet/src/utils/pxe_wrapper.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,9 +12,9 @@ export class PXEWrapper {
return PXEWrapper.pxe;
}

async init(nodeUrl: string, dataDir: string) {
async init(nodeUrl: string, dataDir: string, overridePXEServiceConfig?: Partial<PXEServiceConfig>) {
const aztecNode = createAztecNodeClient(nodeUrl);
const pxeConfig = getPXEServiceConfig();
const pxeConfig = Object.assign(getPXEServiceConfig(), overridePXEServiceConfig);
pxeConfig.dataDirectory = dataDir;
PXEWrapper.pxe = await createPXEService(aztecNode, pxeConfig);
}
Expand Down
Loading