From 2ea6e2518b6906b01dd49d789b5edeb3eb7a2737 Mon Sep 17 00:00:00 2001 From: sklppy88 Date: Fri, 23 Aug 2024 10:05:37 +0000 Subject: [PATCH] init --- yarn-project/aztec-node/src/aztec-node/server.ts | 15 +++++++++++---- yarn-project/aztec.js/src/contract/batch_call.ts | 2 +- .../circuit-types/src/interfaces/aztec-node.ts | 3 ++- yarn-project/end-to-end/package.local.json | 2 +- yarn-project/pxe/src/pxe_service/pxe_service.ts | 4 ++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index 27d0cbc032fb..da98547c0bf4 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -15,6 +15,7 @@ import { LogType, MerkleTreeId, NullifierMembershipWitness, + type ProcessedTx, type ProverConfig, PublicDataWitness, PublicSimulationOutput, @@ -25,6 +26,7 @@ import { type TxHash, TxReceipt, TxStatus, + type TxValidator, partitionReverts, } from '@aztec/circuit-types'; import { @@ -762,7 +764,7 @@ export class AztecNodeService implements AztecNode { ); } - public async isValidTx(tx: Tx): Promise { + public async isValidTx(tx: Tx, isSimulation: boolean = false): Promise { const blockNumber = (await this.blockSource.getBlockNumber()) + 1; const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables( @@ -775,12 +777,17 @@ export class AztecNodeService implements AztecNode { // These validators are taken from the sequencer, and should match. // The reason why `phases` and `gas` tx validator is in the sequencer and not here is because // those tx validators are customizable by the sequencer. - const txValidator = new AggregateTxValidator( + const txValidators: TxValidator[] = [ new DataTxValidator(), new MetadataTxValidator(newGlobalVariables), new DoubleSpendTxValidator(new WorldStateDB(this.worldStateSynchronizer.getLatest())), - new TxProofValidator(this.proofVerifier), - ); + ]; + + if (!isSimulation) { + txValidators.push(new TxProofValidator(this.proofVerifier)); + } + + const txValidator = new AggregateTxValidator(...txValidators); const [_, invalidTxs] = await txValidator.validateTxs([tx]); if (invalidTxs.length > 0) { diff --git a/yarn-project/aztec.js/src/contract/batch_call.ts b/yarn-project/aztec.js/src/contract/batch_call.ts index 3a02a7139015..19fb03999f69 100644 --- a/yarn-project/aztec.js/src/contract/batch_call.ts +++ b/yarn-project/aztec.js/src/contract/batch_call.ts @@ -78,7 +78,7 @@ export class BatchCall extends BaseContractInteraction { const [unconstrainedResults, simulatedTx] = await Promise.all([ Promise.all(unconstrainedCalls), - this.wallet.simulateTx(txRequest, true, options?.from), + this.wallet.simulateTx(txRequest, true, options?.from, options?.skipTxValidation), ]); const results: any[] = []; diff --git a/yarn-project/circuit-types/src/interfaces/aztec-node.ts b/yarn-project/circuit-types/src/interfaces/aztec-node.ts index 70dbc3fb8b4f..16c64a1ac423 100644 --- a/yarn-project/circuit-types/src/interfaces/aztec-node.ts +++ b/yarn-project/circuit-types/src/interfaces/aztec-node.ts @@ -327,8 +327,9 @@ export interface AztecNode { * made invalid by *other* transactions if e.g. they emit the same nullifiers, or come become invalid * due to e.g. the max_block_number property. * @param tx - The transaction to validate for correctness. + * @param isSimulation - True if the transaction is a simulated one without generated proofs. (Optional) */ - isValidTx(tx: Tx): Promise; + isValidTx(tx: Tx, isSimulation?: boolean): Promise; /** * Updates the configuration of this node. diff --git a/yarn-project/end-to-end/package.local.json b/yarn-project/end-to-end/package.local.json index c76111c3c265..16ebe7dc24aa 100644 --- a/yarn-project/end-to-end/package.local.json +++ b/yarn-project/end-to-end/package.local.json @@ -5,4 +5,4 @@ "test": "TIME_TRAVELER=${TIME_TRAVELER:-true} LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit", "test:unit": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures" } -} \ No newline at end of file +} diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 972ef5ce916a..1b058896756b 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -532,7 +532,7 @@ export class PXEService implements PXE { txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender: AztecAddress | undefined = undefined, - skipTxValidation: boolean = true, // TODO(#7956): make the default be false + skipTxValidation: boolean = false, scopes?: AztecAddress[], ): Promise { return await this.jobQueue.put(async () => { @@ -542,7 +542,7 @@ export class PXEService implements PXE { } if (!skipTxValidation) { - if (!(await this.node.isValidTx(simulatedTx.tx))) { + if (!(await this.node.isValidTx(simulatedTx.tx, true))) { throw new Error('The simulated transaction is unable to be added to state and is invalid.'); } }