From f670067d520180dd5ba8f3003d09726145e32d38 Mon Sep 17 00:00:00 2001 From: Mitch Date: Tue, 26 Nov 2024 13:41:42 -0500 Subject: [PATCH] fix #10075 --- .../circuit-types/src/tx_execution_request.ts | 5 +++ .../pxe/src/pxe_service/pxe_service.ts | 36 ++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/yarn-project/circuit-types/src/tx_execution_request.ts b/yarn-project/circuit-types/src/tx_execution_request.ts index 2a99636da2e..ea633eabb33 100644 --- a/yarn-project/circuit-types/src/tx_execution_request.ts +++ b/yarn-project/circuit-types/src/tx_execution_request.ts @@ -4,6 +4,7 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize'; import { bufferToHex, hexToBuffer } from '@aztec/foundation/string'; import { type FieldsOf } from '@aztec/foundation/types'; +import { inspect } from 'util'; import { z } from 'zod'; import { AuthWitness } from './auth_witness.js'; @@ -141,4 +142,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 4a5ab7a7576..5a80db11457 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -67,6 +67,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'; @@ -519,8 +521,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()); }); } @@ -576,8 +577,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'}`, + ); }); } @@ -588,8 +596,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; @@ -613,8 +620,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'}`, + ); }); } @@ -986,4 +997,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; + } }