Skip to content

Commit

Permalink
fix #10075
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Nov 26, 2024
1 parent 9c84292 commit d94330f
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 @@ -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';
Expand Down Expand Up @@ -140,4 +141,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 @@ -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';
Expand Down Expand Up @@ -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());
});
}

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

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

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

0 comments on commit d94330f

Please sign in to comment.