From 19338a8de91f566cffbcd25ea8b1bf4436a73b34 Mon Sep 17 00:00:00 2001 From: LHerskind Date: Tue, 2 Apr 2024 13:59:46 +0000 Subject: [PATCH] chore: replace Vue with SimulatedTx --- .../contract/contract_function_interaction.ts | 8 ++++---- .../aztec.js/src/rpc_clients/pxe_client.ts | 4 ++-- yarn-project/aztec.js/src/wallet/base_wallet.ts | 4 ++-- yarn-project/circuit-types/src/interfaces/pxe.ts | 4 ++-- yarn-project/circuit-types/src/tx/tx.ts | 8 ++++---- yarn-project/pxe/src/pxe_http/pxe_http_server.ts | 4 ++-- yarn-project/pxe/src/pxe_service/pxe_service.ts | 16 ++++++++-------- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts index 1c3fec195f0b..79948ee0a258 100644 --- a/yarn-project/aztec.js/src/contract/contract_function_interaction.ts +++ b/yarn-project/aztec.js/src/contract/contract_function_interaction.ts @@ -99,13 +99,13 @@ export class ContractFunctionInteraction extends BaseContractInteraction { packedArguments: [packedArgs], authWitnesses: [], }); - const vue = await this.pxe.simulateTx(txRequest, false, options.from ?? this.wallet.getAddress()); - return vue.privateReturnValues && vue.privateReturnValues[0]; + const simulatedTx = await this.pxe.simulateTx(txRequest, false, options.from ?? this.wallet.getAddress()); + return simulatedTx.privateReturnValues && simulatedTx.privateReturnValues[0]; } else { const txRequest = await this.create(); - const vue = await this.pxe.simulateTx(txRequest, true); + const simulatedTx = await this.pxe.simulateTx(txRequest, true); this.txRequest = undefined; - return vue.publicReturnValues && vue.publicReturnValues[0]; + return simulatedTx.publicReturnValues && simulatedTx.publicReturnValues[0]; } } } diff --git a/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts b/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts index 2b817c2449c5..3d82761b62e4 100644 --- a/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts +++ b/yarn-project/aztec.js/src/rpc_clients/pxe_client.ts @@ -8,13 +8,13 @@ import { Note, NullifierMembershipWitness, type PXE, + SimulatedTx, Tx, TxEffect, TxExecutionRequest, TxHash, TxReceipt, UnencryptedL2BlockL2Logs, - Vue, } from '@aztec/circuit-types'; import { AztecAddress, @@ -54,7 +54,7 @@ export const createPXEClient = (url: string, fetch = makeFetch([1, 2, 3], false) TxExecutionRequest, TxHash, }, - { Tx, Vue, TxReceipt, EncryptedL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness }, + { Tx, SimulatedTx, TxReceipt, EncryptedL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness }, false, 'pxe', fetch, diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index ef1d4725b143..e5d5775eaa94 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -7,13 +7,13 @@ import { type LogFilter, type NoteFilter, type PXE, + type SimulatedTx, type SyncStatus, type Tx, type TxEffect, type TxExecutionRequest, type TxHash, type TxReceipt, - type Vue, } from '@aztec/circuit-types'; import { type AztecAddress, @@ -105,7 +105,7 @@ export abstract class BaseWallet implements Wallet { proveTx(txRequest: TxExecutionRequest, simulatePublic: boolean): Promise { return this.pxe.proveTx(txRequest, simulatePublic); } - simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender: AztecAddress): Promise { + simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender: AztecAddress): Promise { return this.pxe.simulateTx(txRequest, simulatePublic, msgSender); } sendTx(tx: Tx): Promise { diff --git a/yarn-project/circuit-types/src/interfaces/pxe.ts b/yarn-project/circuit-types/src/interfaces/pxe.ts index 54ea476cf629..7468d6ae6d4f 100644 --- a/yarn-project/circuit-types/src/interfaces/pxe.ts +++ b/yarn-project/circuit-types/src/interfaces/pxe.ts @@ -14,7 +14,7 @@ import { type L2Block } from '../l2_block.js'; import { type GetUnencryptedLogsResponse, type LogFilter } from '../logs/index.js'; import { type ExtendedNote } from '../notes/index.js'; import { type NoteFilter } from '../notes/note_filter.js'; -import { type Tx, type TxHash, type TxReceipt, type Vue } from '../tx/index.js'; +import { type SimulatedTx, type Tx, type TxHash, type TxReceipt } from '../tx/index.js'; import { type TxEffect } from '../tx_effect.js'; import { type TxExecutionRequest } from '../tx_execution_request.js'; import { type SyncStatus } from './sync-status.js'; @@ -146,7 +146,7 @@ export interface PXE { * Also throws if simulatePublic is true and public simulation reverts. */ proveTx(txRequest: TxExecutionRequest, simulatePublic: boolean): Promise; - simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender?: AztecAddress): Promise; + simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender?: AztecAddress): Promise; /** * Sends a transaction to an Aztec node to be broadcasted to the network and mined. diff --git a/yarn-project/circuit-types/src/tx/tx.ts b/yarn-project/circuit-types/src/tx/tx.ts index f8526a0ba7ed..7222f2d9a50b 100644 --- a/yarn-project/circuit-types/src/tx/tx.ts +++ b/yarn-project/circuit-types/src/tx/tx.ts @@ -17,7 +17,7 @@ import { EncryptedTxL2Logs, UnencryptedTxL2Logs } from '../logs/tx_l2_logs.js'; import { type TxStats } from '../stats/stats.js'; import { TxHash } from './tx_hash.js'; -export class Vue { +export class SimulatedTx { constructor( public tx: Tx, public privateReturnValues?: ProcessReturnValues, @@ -25,8 +25,8 @@ export class Vue { ) {} /** - * Convert a Vue class object to a plain JSON object. - * @returns A plain object with Vue properties. + * Convert a SimulatedTx class object to a plain JSON object. + * @returns A plain object with SimulatedTx properties. */ public toJSON() { const returnToJson = (data: ProcessReturnValues): string => { @@ -77,7 +77,7 @@ export class Vue { const privateReturnValues = returnFromJson(obj.privateReturnValues); const publicReturnValues = returnFromJson(obj.publicReturnValues); - return new Vue(tx, privateReturnValues, publicReturnValues); + return new SimulatedTx(tx, privateReturnValues, publicReturnValues); } } diff --git a/yarn-project/pxe/src/pxe_http/pxe_http_server.ts b/yarn-project/pxe/src/pxe_http/pxe_http_server.ts index 31856cd3ec51..68ae86533bed 100644 --- a/yarn-project/pxe/src/pxe_http/pxe_http_server.ts +++ b/yarn-project/pxe/src/pxe_http/pxe_http_server.ts @@ -9,13 +9,13 @@ import { Note, NullifierMembershipWitness, type PXE, + SimulatedTx, Tx, TxEffect, TxExecutionRequest, TxHash, TxReceipt, UnencryptedL2BlockL2Logs, - Vue, } from '@aztec/circuit-types'; import { FunctionSelector } from '@aztec/circuits.js'; import { AztecAddress } from '@aztec/foundation/aztec-address'; @@ -50,7 +50,7 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer { TxEffect, LogId, }, - { Vue, Tx, TxReceipt, EncryptedL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness }, + { SimulatedTx, Tx, TxReceipt, EncryptedL2BlockL2Logs, UnencryptedL2BlockL2Logs, NullifierMembershipWitness }, ['start', 'stop'], ); } diff --git a/yarn-project/pxe/src/pxe_service/pxe_service.ts b/yarn-project/pxe/src/pxe_service/pxe_service.ts index 47373775809f..398d624c5e5f 100644 --- a/yarn-project/pxe/src/pxe_service/pxe_service.ts +++ b/yarn-project/pxe/src/pxe_service/pxe_service.ts @@ -11,6 +11,7 @@ import { MerkleTreeId, type NoteFilter, type PXE, + SimulatedTx, SimulationError, Tx, type TxEffect, @@ -18,7 +19,6 @@ import { type TxHash, type TxReceipt, UnencryptedTxL2Logs, - Vue, isNoirCallStackUnresolved, } from '@aztec/circuit-types'; import { type TxPXEProcessingStats } from '@aztec/circuit-types/stats'; @@ -403,24 +403,24 @@ export class PXEService implements PXE { } return await this.jobQueue.put(async () => { const timer = new Timer(); - const vue = await this.#simulateAndProve(txRequest, msgSender); + const simulatedTx = await this.#simulateAndProve(txRequest, msgSender); if (!msgSender) { - this.log(`Processed private part of ${vue.tx.getTxHash()}`, { + this.log(`Processed private part of ${simulatedTx.tx.getTxHash()}`, { eventName: 'tx-pxe-processing', duration: timer.ms(), - ...vue.tx.getStats(), + ...simulatedTx.tx.getStats(), } satisfies TxPXEProcessingStats); } if (simulatePublic) { // Only one transaction, so we can take index 0. - vue.publicReturnValues = (await this.#simulatePublicCalls(vue.tx))[0]; + simulatedTx.publicReturnValues = (await this.#simulatePublicCalls(simulatedTx.tx))[0]; } if (!msgSender) { - this.log.info(`Executed local simulation for ${vue.tx.getTxHash()}`); + this.log.info(`Executed local simulation for ${simulatedTx.tx.getTxHash()}`); } - return vue; + return simulatedTx; }); } @@ -644,7 +644,7 @@ export class PXEService implements PXE { await this.patchPublicCallStackOrdering(publicInputs, enqueuedPublicFunctions); const tx = new Tx(publicInputs, proof, encryptedLogs, unencryptedLogs, enqueuedPublicFunctions); - return new Vue(tx, [executionResult.returnValues]); + return new SimulatedTx(tx, [executionResult.returnValues]); } /**