Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolás Venturo <nicolas.venturo@gmail.com>
  • Loading branch information
sklppy88 and nventuro committed Aug 12, 2024
1 parent 595b0ad commit 33c9509
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ export class AztecNodeService implements AztecNode {
const timer = new Timer();
this.log.info(`Received tx ${tx.getTxHash()}`);

if ((await this.validateTx(tx)) === false) {
if (!(await this.isValidTx(tx))) {
this.metrics.receivedTx(timer.ms(), false);
return;
}
Expand Down Expand Up @@ -768,7 +768,7 @@ export class AztecNodeService implements AztecNode {
);
}

public async validateTx(tx: Tx): Promise<boolean> {
public async isValidTx(tx: Tx): Promise<boolean> {
const [_, invalidTxs] = await this.txValidator.validateTxs([tx]);
if (invalidTxs.length > 0) {
this.log.warn(`Rejecting tx ${tx.getTxHash()} because of validation errors`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type SimulateMethodOptions = {
from?: AztecAddress;
/** Gas settings for the simulation. */
gasSettings?: GasSettings;
/** Simulate without validating tx against current state. */
/** Simulate without validating tx results against current state. */
offline?: boolean;
};

Expand Down
7 changes: 4 additions & 3 deletions yarn-project/circuit-types/src/interfaces/aztec-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,12 @@ export interface AztecNode {
simulatePublicCalls(tx: Tx): Promise<PublicSimulationOutput>;

/**
* Validates the correctness of the execution, namely that a transaction is valid if and
* only if the transaction can be added to a valid block at the current state.
* Returns true if the transaction is valid for inclusion at the current state. Valid transactions can be
* 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.
*/
validateTx(tx: Tx): Promise<boolean>;
isValidTx(tx: Tx): Promise<boolean>;

/**
* Updates the configuration of this node.
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ export class PXEService implements PXE {
}

if (!offline) {
const isValidTx = await this.node.validateTx(simulatedTx.tx);
const isValidTx = await this.node.isValidTx(simulatedTx.tx);

if (!isValidTx) {
throw new Error('The simulated transaction is unable to be added to state and is invalid.');
Expand Down

0 comments on commit 33c9509

Please sign in to comment.