Skip to content

Commit

Permalink
fix: make simulations validate resulting tx by default (#8157)
Browse files Browse the repository at this point in the history
Closes #7956.

This PR simply flips a switch to make all simulations fail by default if
the transaction is an invalid one. Previously it did not throw due to
wanting to minimize disruptions in the PR, but it seems like there were
not that many effects. The only exception is the e2e prover. These are
failing due to a prover verification, and I have made an issue for this
to be looked into.
  • Loading branch information
sklppy88 authored and codygunton committed Aug 30, 2024
1 parent 8cadd87 commit 2203bc0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
type TxHash,
TxReceipt,
TxStatus,
type TxValidator,
partitionReverts,
} from '@aztec/circuit-types';
import {
Expand Down Expand Up @@ -763,7 +764,7 @@ export class AztecNodeService implements AztecNode {
);
}

public async isValidTx(tx: Tx): Promise<boolean> {
public async isValidTx(tx: Tx, isSimulation: boolean = false): Promise<boolean> {
const blockNumber = (await this.blockSource.getBlockNumber()) + 1;

const newGlobalVariables = await this.globalVariableBuilder.buildGlobalVariables(
Expand All @@ -776,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<Tx | ProcessedTx>[] = [
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) {
Expand Down

0 comments on commit 2203bc0

Please sign in to comment.