diff --git a/yarn-project/circuit-types/src/tx_execution_request.ts b/yarn-project/circuit-types/src/tx_execution_request.ts index 9588de8c1609..250b7abcbba8 100644 --- a/yarn-project/circuit-types/src/tx_execution_request.ts +++ b/yarn-project/circuit-types/src/tx_execution_request.ts @@ -3,6 +3,7 @@ import { schemas } from '@aztec/foundation/schemas'; import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { type FieldsOf } from '@aztec/foundation/types'; +import { inspect } from 'util'; import { z } from 'zod'; import { AuthWitness } from './auth_witness.js'; @@ -140,4 +141,8 @@ export class TxExecutionRequest { [AuthWitness.random()], ); } + + [inspect.custom]() { + return `TxExecutionRequest(${this.functionSelector}(${this.argsOfCalls.map(arg => arg.toString()).join(', ')}))`; + } } diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index b7ed140aa730..72d2eb85443c 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -65,6 +65,8 @@ import { } from '@aztec/protocol-contracts'; import { type AcirSimulator } from '@aztec/simulator'; +import { inspect } from 'util'; + import { type PXEServiceConfig, getPackageInfo } from '../config/index.js'; import { ContractDataOracle } from '../contract_data_oracle/index.js'; import { IncomingNoteDao } from '../database/incoming_note_dao.js'; @@ -513,8 +515,7 @@ export class PXEService implements PXE { return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof!); }) .catch(err => { - this.log.error(err); - throw err; + throw this.contextualizeError(err, inspect(txRequest), privateExecutionResult.toJSON()); }); } @@ -570,8 +571,15 @@ export class PXEService implements PXE { ); }) .catch(err => { - this.log.error(err); - throw err; + throw this.contextualizeError( + err, + inspect(txRequest), + `simulatePublic=${simulatePublic}`, + `msgSender=${msgSender?.toString() ?? 'undefined'}`, + `skipTxValidation=${skipTxValidation}`, + `profile=${profile}`, + `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`, + ); }); } @@ -582,8 +590,7 @@ export class PXEService implements PXE { } this.log.info(`Sending transaction ${txHash}`); await this.node.sendTx(tx).catch(err => { - this.log.error(err); - throw err; + throw this.contextualizeError(err, inspect(tx)); }); this.log.info(`Sent transaction ${txHash}`); return txHash; @@ -607,8 +614,12 @@ export class PXEService implements PXE { return executionResult; }) .catch(err => { - this.log.error(err); - throw err; + const stringifiedArgs = args.map(arg => arg.toString()).join(', '); + throw this.contextualizeError( + err, + `simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`, + `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`, + ); }); } @@ -981,4 +992,13 @@ export class PXEService implements PXE { async resetNoteSyncData() { return await this.db.resetNoteSyncData(); } + + private contextualizeError(err: Error, ...context: string[]): Error { + this.log.error(err.name, err); + this.log.debug('Context:'); + for (const c of context) { + this.log.debug(c); + } + return err; + } }