Skip to content

Commit

Permalink
chore: replace Vue with SimulatedTx
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Apr 2, 2024
1 parent f726832 commit 19338a8
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
}
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/rpc_clients/pxe_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
Note,
NullifierMembershipWitness,
type PXE,
SimulatedTx,
Tx,
TxEffect,
TxExecutionRequest,
TxHash,
TxReceipt,
UnencryptedL2BlockL2Logs,
Vue,
} from '@aztec/circuit-types';
import {
AztecAddress,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/aztec.js/src/wallet/base_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -105,7 +105,7 @@ export abstract class BaseWallet implements Wallet {
proveTx(txRequest: TxExecutionRequest, simulatePublic: boolean): Promise<Tx> {
return this.pxe.proveTx(txRequest, simulatePublic);
}
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender: AztecAddress): Promise<Vue> {
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender: AztecAddress): Promise<SimulatedTx> {
return this.pxe.simulateTx(txRequest, simulatePublic, msgSender);
}
sendTx(tx: Tx): Promise<TxHash> {
Expand Down
4 changes: 2 additions & 2 deletions yarn-project/circuit-types/src/interfaces/pxe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -146,7 +146,7 @@ export interface PXE {
* Also throws if simulatePublic is true and public simulation reverts.
*/
proveTx(txRequest: TxExecutionRequest, simulatePublic: boolean): Promise<Tx>;
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender?: AztecAddress): Promise<Vue>;
simulateTx(txRequest: TxExecutionRequest, simulatePublic: boolean, msgSender?: AztecAddress): Promise<SimulatedTx>;

/**
* Sends a transaction to an Aztec node to be broadcasted to the network and mined.
Expand Down
8 changes: 4 additions & 4 deletions yarn-project/circuit-types/src/tx/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ 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,
public publicReturnValues?: ProcessReturnValues,
) {}

/**
* 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 => {
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions yarn-project/pxe/src/pxe_http/pxe_http_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'],
);
}
Expand Down
16 changes: 8 additions & 8 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import {
MerkleTreeId,
type NoteFilter,
type PXE,
SimulatedTx,
SimulationError,
Tx,
type TxEffect,
type TxExecutionRequest,
type TxHash,
type TxReceipt,
UnencryptedTxL2Logs,
Vue,
isNoirCallStackUnresolved,
} from '@aztec/circuit-types';
import { type TxPXEProcessingStats } from '@aztec/circuit-types/stats';
Expand Down Expand Up @@ -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;
});
}

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

/**
Expand Down

0 comments on commit 19338a8

Please sign in to comment.