Skip to content

Commit

Permalink
fix #10075
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Dec 2, 2024
1 parent 0fea14a commit f670067
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
5 changes: 5 additions & 0 deletions yarn-project/circuit-types/src/tx_execution_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -141,4 +142,8 @@ export class TxExecutionRequest {
[AuthWitness.random()],
);
}

[inspect.custom]() {
return `TxExecutionRequest(${this.functionSelector}(${this.argsOfCalls.map(arg => arg.toString()).join(', ')}))`;
}
}
36 changes: 28 additions & 8 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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());
});
}

Expand Down Expand Up @@ -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'}`,
);
});
}

Expand All @@ -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;
Expand All @@ -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'}`,
);
});
}

Expand Down Expand Up @@ -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;
}
}

0 comments on commit f670067

Please sign in to comment.