@aztec/wallet-sdk 0.0.1-commit.6d63667d → 0.0.1-commit.7cf39cb55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,7 +2,7 @@ import type { Account } from '@aztec/aztec.js/account';
2
2
  import type { CallIntent, IntentInnerHash } from '@aztec/aztec.js/authorization';
3
3
  import { type InteractionWaitOptions, type SendReturn } from '@aztec/aztec.js/contracts';
4
4
  import type { FeePaymentMethod } from '@aztec/aztec.js/fee';
5
- import type { Aliased, AppCapabilities, BatchResults, BatchedMethod, PrivateEvent, PrivateEventFilter, ProfileOptions, SendOptions, SimulateOptions, Wallet, WalletCapabilities } from '@aztec/aztec.js/wallet';
5
+ import type { Aliased, AppCapabilities, BatchResults, BatchedMethod, PrivateEvent, PrivateEventFilter, ProfileOptions, SendOptions, SimulateOptions, SimulateUtilityOptions, Wallet, WalletCapabilities } from '@aztec/aztec.js/wallet';
6
6
  import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
7
7
  import type { ChainInfo } from '@aztec/entrypoints/interfaces';
8
8
  import { Fr } from '@aztec/foundation/curves/bn254';
@@ -14,7 +14,7 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
14
14
  import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
15
15
  import { GasSettings } from '@aztec/stdlib/gas';
16
16
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
17
- import type { TxExecutionRequest, TxProfileResult, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
17
+ import { type TxExecutionRequest, type TxProfileResult, TxSimulationResult, type UtilitySimulationResult } from '@aztec/stdlib/tx';
18
18
  import { ExecutionPayload } from '@aztec/stdlib/tx';
19
19
  /**
20
20
  * Options to configure fee payment for a transaction
@@ -39,7 +39,8 @@ export declare abstract class BaseWallet implements Wallet {
39
39
  protected log: import("@aztec/foundation/log").Logger;
40
40
  protected minFeePadding: number;
41
41
  protected cancellableTransactions: boolean;
42
- protected constructor(pxe: PXE, aztecNode: AztecNode);
42
+ protected constructor(pxe: PXE, aztecNode: AztecNode, log?: import("@aztec/foundation/log").Logger);
43
+ protected scopesFor(from: AztecAddress): AztecAddress[];
43
44
  protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
44
45
  abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
45
46
  /**
@@ -96,11 +97,29 @@ export declare abstract class BaseWallet implements Wallet {
96
97
  }>;
97
98
  registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
98
99
  registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
100
+ /**
101
+ * Simulates calls through the standard PXE path (account entrypoint).
102
+ * @param executionPayload - The execution payload to simulate.
103
+ * @param from - The sender address.
104
+ * @param feeOptions - Fee options for the transaction.
105
+ * @param skipTxValidation - Whether to skip tx validation.
106
+ * @param skipFeeEnforcement - Whether to skip fee enforcement.
107
+ * @param scopes - The scopes to use for the simulation.
108
+ */
109
+ protected simulateViaEntrypoint(executionPayload: ExecutionPayload, from: AztecAddress, feeOptions: FeeOptions, skipTxValidation?: boolean, skipFeeEnforcement?: boolean, scopes?: AztecAddress[]): Promise<TxSimulationResult>;
110
+ /**
111
+ * Simulates a transaction, optimizing leading public static calls by running them directly
112
+ * on the node while sending the remaining calls through the standard PXE path.
113
+ * Return values from both paths are merged back in original call order.
114
+ * @param executionPayload - The execution payload to simulate.
115
+ * @param opts - Simulation options (from address, fee settings, etc.).
116
+ * @returns The merged simulation result.
117
+ */
99
118
  simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
100
119
  profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
101
120
  sendTx<W extends InteractionWaitOptions = undefined>(executionPayload: ExecutionPayload, opts: SendOptions<W>): Promise<SendReturn<W>>;
102
121
  protected contextualizeError(err: Error, ...context: string[]): Error;
103
- simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
122
+ simulateUtility(call: FunctionCall, opts: SimulateUtilityOptions): Promise<UtilitySimulationResult>;
104
123
  getPrivateEvents<T>(eventDef: EventMetadataDefinition, eventFilter: PrivateEventFilter): Promise<PrivateEvent<T>[]>;
105
124
  getContractMetadata(address: AztecAddress): Promise<{
106
125
  instance: ContractInstanceWithAddress | undefined;
@@ -114,4 +133,4 @@ export declare abstract class BaseWallet implements Wallet {
114
133
  isContractClassPubliclyRegistered: boolean;
115
134
  }>;
116
135
  }
117
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmFzZV93YWxsZXQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9iYXNlX3dhbGxldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN2RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsZUFBZSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDakYsT0FBTyxFQUFFLEtBQUssc0JBQXNCLEVBQVcsS0FBSyxVQUFVLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNsRyxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRTVELE9BQU8sS0FBSyxFQUNWLE9BQU8sRUFDUCxlQUFlLEVBQ2YsWUFBWSxFQUNaLGFBQWEsRUFDYixZQUFZLEVBQ1osa0JBQWtCLEVBQ2xCLGNBQWMsRUFDZCxXQUFXLEVBQ1gsZUFBZSxFQUNmLE1BQU0sRUFDTixrQkFBa0IsRUFDbkIsTUFBTSx3QkFBd0IsQ0FBQztBQU9oQyxPQUFPLEVBQUUsOEJBQThCLEVBQXdDLE1BQU0sNEJ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} from '@aztec/stdlib/gas';
11
11
  import { siloNullifier } from '@aztec/stdlib/hash';
12
12
  import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
13
13
  import { inspect } from 'util';
14
+ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
14
15
  /**
15
16
  * A base class for Wallet implementations
16
17
  */ export class BaseWallet {
@@ -20,13 +21,20 @@ import { inspect } from 'util';
20
21
  minFeePadding;
21
22
  cancellableTransactions;
22
23
  // Protected because we want to force wallets to instantiate their own PXE.
23
- constructor(pxe, aztecNode){
24
+ constructor(pxe, aztecNode, log = createLogger('wallet-sdk:base_wallet')){
24
25
  this.pxe = pxe;
25
26
  this.aztecNode = aztecNode;
26
- this.log = createLogger('wallet-sdk:base_wallet');
27
+ this.log = log;
27
28
  this.minFeePadding = 0.5;
28
29
  this.cancellableTransactions = false;
29
30
  }
31
+ // When `from` is the zero address (e.g. when deploying a new account contract), we return an
32
+ // empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
33
+ scopesFor(from) {
34
+ return from.isZero() ? [] : [
35
+ from
36
+ ];
37
+ }
30
38
  /**
31
39
  * Returns the list of aliased contacts associated with the wallet.
32
40
  * This base implementation directly returns PXE's senders, but note that in general contacts are a superset of senders.
@@ -183,20 +191,65 @@ import { inspect } from 'util';
183
191
  }
184
192
  return instance;
185
193
  }
186
- async simulateTx(executionPayload, opts) {
194
+ /**
195
+ * Simulates calls through the standard PXE path (account entrypoint).
196
+ * @param executionPayload - The execution payload to simulate.
197
+ * @param from - The sender address.
198
+ * @param feeOptions - Fee options for the transaction.
199
+ * @param skipTxValidation - Whether to skip tx validation.
200
+ * @param skipFeeEnforcement - Whether to skip fee enforcement.
201
+ * @param scopes - The scopes to use for the simulation.
202
+ */ async simulateViaEntrypoint(executionPayload, from, feeOptions, skipTxValidation, skipFeeEnforcement, scopes) {
203
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
204
+ return this.pxe.simulateTx(txRequest, {
205
+ simulatePublic: true,
206
+ skipTxValidation,
207
+ skipFeeEnforcement,
208
+ scopes
209
+ });
210
+ }
211
+ /**
212
+ * Simulates a transaction, optimizing leading public static calls by running them directly
213
+ * on the node while sending the remaining calls through the standard PXE path.
214
+ * Return values from both paths are merged back in original call order.
215
+ * @param executionPayload - The execution payload to simulate.
216
+ * @param opts - Simulation options (from address, fee settings, etc.).
217
+ * @returns The merged simulation result.
218
+ */ async simulateTx(executionPayload, opts) {
187
219
  const feeOptions = opts.fee?.estimateGas ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings) : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
188
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
189
- return this.pxe.simulateTx(txRequest, true, opts?.skipTxValidation, opts?.skipFeeEnforcement ?? true);
220
+ const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
221
+ const remainingPayload = {
222
+ ...executionPayload,
223
+ calls: remainingCalls
224
+ };
225
+ const chainInfo = await this.getChainInfo();
226
+ let blockHeader;
227
+ // PXE might not be synced yet, so we pull the latest header from the node
228
+ // To keep things consistent, we'll always try with PXE first
229
+ try {
230
+ blockHeader = await this.pxe.getSyncedBlockHeader();
231
+ } catch {
232
+ blockHeader = await this.aztecNode.getBlockHeader();
233
+ }
234
+ const [optimizedResults, normalResult] = await Promise.all([
235
+ optimizableCalls.length > 0 ? simulateViaNode(this.aztecNode, optimizableCalls, opts.from, chainInfo, feeOptions.gasSettings, blockHeader, opts.skipFeeEnforcement ?? true) : Promise.resolve([]),
236
+ remainingCalls.length > 0 ? this.simulateViaEntrypoint(remainingPayload, opts.from, feeOptions, opts.skipTxValidation, opts.skipFeeEnforcement ?? true, this.scopesFor(opts.from)) : Promise.resolve(null)
237
+ ]);
238
+ return buildMergedSimulationResult(optimizedResults, normalResult);
190
239
  }
191
240
  async profileTx(executionPayload, opts) {
192
241
  const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
193
242
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
194
- return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
243
+ return this.pxe.profileTx(txRequest, {
244
+ profileMode: opts.profileMode,
245
+ skipProofGeneration: opts.skipProofGeneration ?? true,
246
+ scopes: this.scopesFor(opts.from)
247
+ });
195
248
  }
196
249
  async sendTx(executionPayload, opts) {
197
250
  const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
198
251
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
199
- const provenTx = await this.pxe.proveTx(txRequest);
252
+ const provenTx = await this.pxe.proveTx(txRequest, this.scopesFor(opts.from));
200
253
  const tx = await provenTx.toTx();
201
254
  const txHash = tx.getTxHash();
202
255
  if (await this.aztecNode.getTxEffect(txHash)) {
@@ -228,8 +281,13 @@ import { inspect } from 'util';
228
281
  }
229
282
  return err;
230
283
  }
231
- simulateUtility(call, authwits) {
232
- return this.pxe.simulateUtility(call, authwits);
284
+ simulateUtility(call, opts) {
285
+ return this.pxe.simulateUtility(call, {
286
+ authwits: opts.authWitnesses,
287
+ scopes: [
288
+ opts.scope
289
+ ]
290
+ });
233
291
  }
234
292
  async getPrivateEvents(eventDef, eventFilter) {
235
293
  const pxeEvents = await this.pxe.getPrivateEvents(eventDef.eventSelector, eventFilter);
@@ -1,2 +1,3 @@
1
1
  export { BaseWallet, type FeeOptions } from './base_wallet.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLEtBQUssVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUMifQ==
2
+ export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iYXNlLXdhbGxldC9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLEtBQUssVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDL0QsT0FBTyxFQUFFLGVBQWUsRUFBRSwyQkFBMkIsRUFBRSxtQ0FBbUMsRUFBRSxNQUFNLFlBQVksQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base-wallet/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,mCAAmC,EAAE,MAAM,YAAY,CAAC"}
@@ -1 +1,2 @@
1
1
  export { BaseWallet } from './base_wallet.js';
2
+ export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
@@ -0,0 +1,48 @@
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
3
+ import { type FunctionCall } from '@aztec/stdlib/abi';
4
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import type { GasSettings } from '@aztec/stdlib/gas';
6
+ import { type BlockHeader, type ExecutionPayload, TxSimulationResult } from '@aztec/stdlib/tx';
7
+ /**
8
+ * Splits an execution payload into a leading prefix of public static calls
9
+ * (eligible for direct node simulation) and the remaining calls.
10
+ *
11
+ * Only a leading run of public static calls is eligible for optimization.
12
+ * Any non-public-static call may enqueue public state mutations
13
+ * (e.g. private calls can enqueue public calls), so all calls that follow
14
+ * must go through the normal simulation path to see the correct state.
15
+ *
16
+ */
17
+ export declare function extractOptimizablePublicStaticCalls(payload: ExecutionPayload): {
18
+ /** Leading public static calls eligible for direct node simulation. */
19
+ optimizableCalls: FunctionCall[];
20
+ /** All remaining calls. */
21
+ remainingCalls: FunctionCall[];
22
+ };
23
+ /**
24
+ * Simulates public static calls by splitting them into batches of MAX_ENQUEUED_CALLS_PER_CALL
25
+ * and sending each batch directly to the node.
26
+ *
27
+ * @param node - The Aztec node to simulate on.
28
+ * @param publicStaticCalls - Array of public static function calls to optimize.
29
+ * @param from - The account address making the calls.
30
+ * @param chainInfo - Chain information (chainId and version).
31
+ * @param gasSettings - Gas settings for the transaction.
32
+ * @param blockHeader - Block header to use as anchor.
33
+ * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
34
+ * @returns Array of TxSimulationResult, one per batch.
35
+ */
36
+ export declare function simulateViaNode(node: AztecNode, publicStaticCalls: FunctionCall[], from: AztecAddress, chainInfo: ChainInfo, gasSettings: GasSettings, blockHeader: BlockHeader, skipFeeEnforcement?: boolean): Promise<TxSimulationResult[]>;
37
+ /**
38
+ * Merges simulation results from the optimized (public static) and normal paths.
39
+ * Since optimized calls are always a leading prefix, return values are simply
40
+ * concatenated: optimized first, then normal.
41
+ * Stats are taken from the normal result only (the optimized path doesn't produce them).
42
+ *
43
+ * @param optimizedResults - Results from optimized public static call batches.
44
+ * @param normalResult - Result from normal simulation (null if all calls were optimized).
45
+ * @returns A single TxSimulationResult with return values in original call order.
46
+ */
47
+ export declare function buildMergedSimulationResult(optimized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xB,kBAAkB,GAAE,OAAc,GACjC,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAuB/B;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,gBAAgB,EAAE,kBAAkB,EAAE,EACtC,YAAY,EAAE,kBAAkB,GAAG,IAAI,GACtC,kBAAkB,CAoBpB"}
@@ -0,0 +1,128 @@
1
+ import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
2
+ import { makeTuple } from '@aztec/foundation/array';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { generateSimulatedProvingResult } from '@aztec/pxe/simulator';
5
+ import { ClaimedLengthArray, CountedPublicCallRequest, PrivateCircuitPublicInputs, PublicCallRequest } from '@aztec/stdlib/kernel';
6
+ import { ChonkProof } from '@aztec/stdlib/proofs';
7
+ import { HashedValues, PrivateCallExecutionResult, PrivateExecutionResult, Tx, TxContext, TxSimulationResult } from '@aztec/stdlib/tx';
8
+ /**
9
+ * Splits an execution payload into a leading prefix of public static calls
10
+ * (eligible for direct node simulation) and the remaining calls.
11
+ *
12
+ * Only a leading run of public static calls is eligible for optimization.
13
+ * Any non-public-static call may enqueue public state mutations
14
+ * (e.g. private calls can enqueue public calls), so all calls that follow
15
+ * must go through the normal simulation path to see the correct state.
16
+ *
17
+ */ export function extractOptimizablePublicStaticCalls(payload) {
18
+ const splitIndex = payload.calls.findIndex((call)=>!call.isPublicStatic());
19
+ const boundary = splitIndex === -1 ? payload.calls.length : splitIndex;
20
+ return {
21
+ optimizableCalls: payload.calls.slice(0, boundary),
22
+ remainingCalls: payload.calls.slice(boundary)
23
+ };
24
+ }
25
+ /**
26
+ * Simulates a batch of public static calls by bypassing account entrypoint and private execution,
27
+ * directly constructing a minimal Tx and calling node.simulatePublicCalls.
28
+ *
29
+ * @param node - The Aztec node to simulate on.
30
+ * @param publicStaticCalls - Array of public static function calls (max MAX_ENQUEUED_CALLS_PER_CALL).
31
+ * @param from - The account address making the calls.
32
+ * @param chainInfo - Chain information (chainId and version).
33
+ * @param gasSettings - Gas settings for the transaction.
34
+ * @param blockHeader - Block header to use as anchor.
35
+ * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
36
+ * @returns TxSimulationResult with public return values.
37
+ */ async function simulateBatchViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement) {
38
+ const txContext = new TxContext(chainInfo.chainId, chainInfo.version, gasSettings);
39
+ const publicFunctionCalldata = [];
40
+ for (const call of publicStaticCalls){
41
+ const calldata = await HashedValues.fromCalldata([
42
+ call.selector.toField(),
43
+ ...call.args
44
+ ]);
45
+ publicFunctionCalldata.push(calldata);
46
+ }
47
+ const publicCallRequests = makeTuple(MAX_ENQUEUED_CALLS_PER_CALL, (i)=>{
48
+ const call = publicStaticCalls[i];
49
+ if (!call) {
50
+ return CountedPublicCallRequest.empty();
51
+ }
52
+ const publicCallRequest = new PublicCallRequest(from, call.to, call.isStatic, publicFunctionCalldata[i].hash);
53
+ // Counter starts at 1 (minRevertibleSideEffectCounter) so all calls are revertible
54
+ return new CountedPublicCallRequest(publicCallRequest, i + 1);
55
+ });
56
+ const publicCallRequestsArray = new ClaimedLengthArray(publicCallRequests, publicStaticCalls.length);
57
+ const publicInputs = PrivateCircuitPublicInputs.from({
58
+ ...PrivateCircuitPublicInputs.empty(),
59
+ anchorBlockHeader: blockHeader,
60
+ txContext: txContext,
61
+ publicCallRequests: publicCallRequestsArray,
62
+ startSideEffectCounter: new Fr(0),
63
+ endSideEffectCounter: new Fr(publicStaticCalls.length + 1)
64
+ });
65
+ // Minimal entrypoint structure — no real private execution, just public call requests
66
+ const emptyEntrypoint = new PrivateCallExecutionResult(Buffer.alloc(0), Buffer.alloc(0), new Map(), publicInputs, [], new Map(), [], [], [], [], []);
67
+ const privateResult = new PrivateExecutionResult(emptyEntrypoint, Fr.random(), publicFunctionCalldata);
68
+ const provingResult = await generateSimulatedProvingResult(privateResult, (_contractAddress, _functionSelector)=>Promise.resolve(''), node, 1);
69
+ provingResult.publicInputs.feePayer = from;
70
+ const tx = await Tx.create({
71
+ data: provingResult.publicInputs,
72
+ chonkProof: ChonkProof.empty(),
73
+ contractClassLogFields: [],
74
+ publicFunctionCalldata: publicFunctionCalldata
75
+ });
76
+ const publicOutput = await node.simulatePublicCalls(tx, skipFeeEnforcement);
77
+ if (publicOutput.revertReason) {
78
+ throw publicOutput.revertReason;
79
+ }
80
+ return new TxSimulationResult(privateResult, provingResult.publicInputs, publicOutput, undefined);
81
+ }
82
+ /**
83
+ * Simulates public static calls by splitting them into batches of MAX_ENQUEUED_CALLS_PER_CALL
84
+ * and sending each batch directly to the node.
85
+ *
86
+ * @param node - The Aztec node to simulate on.
87
+ * @param publicStaticCalls - Array of public static function calls to optimize.
88
+ * @param from - The account address making the calls.
89
+ * @param chainInfo - Chain information (chainId and version).
90
+ * @param gasSettings - Gas settings for the transaction.
91
+ * @param blockHeader - Block header to use as anchor.
92
+ * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
93
+ * @returns Array of TxSimulationResult, one per batch.
94
+ */ export async function simulateViaNode(node, publicStaticCalls, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement = true) {
95
+ const batches = [];
96
+ for(let i = 0; i < publicStaticCalls.length; i += MAX_ENQUEUED_CALLS_PER_CALL){
97
+ batches.push(publicStaticCalls.slice(i, i + MAX_ENQUEUED_CALLS_PER_CALL));
98
+ }
99
+ const results = [];
100
+ for (const batch of batches){
101
+ const result = await simulateBatchViaNode(node, batch, from, chainInfo, gasSettings, blockHeader, skipFeeEnforcement);
102
+ results.push(result);
103
+ }
104
+ return results;
105
+ }
106
+ /**
107
+ * Merges simulation results from the optimized (public static) and normal paths.
108
+ * Since optimized calls are always a leading prefix, return values are simply
109
+ * concatenated: optimized first, then normal.
110
+ * Stats are taken from the normal result only (the optimized path doesn't produce them).
111
+ *
112
+ * @param optimizedResults - Results from optimized public static call batches.
113
+ * @param normalResult - Result from normal simulation (null if all calls were optimized).
114
+ * @returns A single TxSimulationResult with return values in original call order.
115
+ */ export function buildMergedSimulationResult(optimizedResults, normalResult) {
116
+ const optimizedReturnValues = optimizedResults.flatMap((r)=>r.publicOutput?.publicReturnValues ?? []);
117
+ const normalReturnValues = normalResult?.publicOutput?.publicReturnValues ?? [];
118
+ const allReturnValues = [
119
+ ...optimizedReturnValues,
120
+ ...normalReturnValues
121
+ ];
122
+ const baseResult = normalResult ?? optimizedResults[0];
123
+ const mergedPublicOutput = baseResult.publicOutput ? {
124
+ ...baseResult.publicOutput,
125
+ publicReturnValues: allReturnValues
126
+ } : undefined;
127
+ return new TxSimulationResult(baseResult.privateExecutionResult, baseResult.publicInputs, mergedPublicOutput, normalResult?.stats);
128
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@aztec/wallet-sdk",
3
3
  "homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/wallet-sdk",
4
- "version": "0.0.1-commit.6d63667d",
4
+ "version": "0.0.1-commit.7cf39cb55",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  "./base-wallet": "./dest/base-wallet/index.js",
@@ -71,15 +71,15 @@
71
71
  ]
72
72
  },
73
73
  "dependencies": {
74
- "@aztec/aztec.js": "0.0.1-commit.6d63667d",
75
- "@aztec/constants": "0.0.1-commit.6d63667d",
76
- "@aztec/entrypoints": "0.0.1-commit.6d63667d",
77
- "@aztec/foundation": "0.0.1-commit.6d63667d",
78
- "@aztec/pxe": "0.0.1-commit.6d63667d",
79
- "@aztec/stdlib": "0.0.1-commit.6d63667d"
74
+ "@aztec/aztec.js": "0.0.1-commit.7cf39cb55",
75
+ "@aztec/constants": "0.0.1-commit.7cf39cb55",
76
+ "@aztec/entrypoints": "0.0.1-commit.7cf39cb55",
77
+ "@aztec/foundation": "0.0.1-commit.7cf39cb55",
78
+ "@aztec/pxe": "0.0.1-commit.7cf39cb55",
79
+ "@aztec/stdlib": "0.0.1-commit.7cf39cb55"
80
80
  },
81
81
  "devDependencies": {
82
- "@aztec/noir-contracts.js": "0.0.1-commit.6d63667d",
82
+ "@aztec/noir-contracts.js": "0.0.1-commit.7cf39cb55",
83
83
  "@jest/globals": "^30.0.0",
84
84
  "@types/jest": "^30.0.0",
85
85
  "@types/node": "^22.15.17",
@@ -13,6 +13,7 @@ import type {
13
13
  ProfileOptions,
14
14
  SendOptions,
15
15
  SimulateOptions,
16
+ SimulateUtilityOptions,
16
17
  Wallet,
17
18
  WalletCapabilities,
18
19
  } from '@aztec/aztec.js/wallet';
@@ -45,16 +46,19 @@ import { SimulationError } from '@aztec/stdlib/errors';
45
46
  import { Gas, GasSettings } from '@aztec/stdlib/gas';
46
47
  import { siloNullifier } from '@aztec/stdlib/hash';
47
48
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
48
- import type {
49
- TxExecutionRequest,
50
- TxProfileResult,
49
+ import {
50
+ BlockHeader,
51
+ type TxExecutionRequest,
52
+ type TxProfileResult,
51
53
  TxSimulationResult,
52
- UtilitySimulationResult,
54
+ type UtilitySimulationResult,
53
55
  } from '@aztec/stdlib/tx';
54
56
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
55
57
 
56
58
  import { inspect } from 'util';
57
59
 
60
+ import { buildMergedSimulationResult, extractOptimizablePublicStaticCalls, simulateViaNode } from './utils.js';
61
+
58
62
  /**
59
63
  * Options to configure fee payment for a transaction
60
64
  */
@@ -74,8 +78,6 @@ export type FeeOptions = {
74
78
  * A base class for Wallet implementations
75
79
  */
76
80
  export abstract class BaseWallet implements Wallet {
77
- protected log = createLogger('wallet-sdk:base_wallet');
78
-
79
81
  protected minFeePadding = 0.5;
80
82
  protected cancellableTransactions = false;
81
83
 
@@ -83,8 +85,15 @@ export abstract class BaseWallet implements Wallet {
83
85
  protected constructor(
84
86
  protected readonly pxe: PXE,
85
87
  protected readonly aztecNode: AztecNode,
88
+ protected log = createLogger('wallet-sdk:base_wallet'),
86
89
  ) {}
87
90
 
91
+ // When `from` is the zero address (e.g. when deploying a new account contract), we return an
92
+ // empty scope list which acts as deny-all: no notes are visible and no keys are accessible.
93
+ protected scopesFor(from: AztecAddress): AztecAddress[] {
94
+ return from.isZero() ? [] : [from];
95
+ }
96
+
88
97
  protected abstract getAccountFromAddress(address: AztecAddress): Promise<Account>;
89
98
 
90
99
  abstract getAccounts(): Promise<Aliased<AztecAddress>[]>;
@@ -282,23 +291,87 @@ export abstract class BaseWallet implements Wallet {
282
291
  return instance;
283
292
  }
284
293
 
294
+ /**
295
+ * Simulates calls through the standard PXE path (account entrypoint).
296
+ * @param executionPayload - The execution payload to simulate.
297
+ * @param from - The sender address.
298
+ * @param feeOptions - Fee options for the transaction.
299
+ * @param skipTxValidation - Whether to skip tx validation.
300
+ * @param skipFeeEnforcement - Whether to skip fee enforcement.
301
+ * @param scopes - The scopes to use for the simulation.
302
+ */
303
+ protected async simulateViaEntrypoint(
304
+ executionPayload: ExecutionPayload,
305
+ from: AztecAddress,
306
+ feeOptions: FeeOptions,
307
+ skipTxValidation?: boolean,
308
+ skipFeeEnforcement?: boolean,
309
+ scopes?: AztecAddress[],
310
+ ) {
311
+ const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, from, feeOptions);
312
+ return this.pxe.simulateTx(txRequest, { simulatePublic: true, skipTxValidation, skipFeeEnforcement, scopes });
313
+ }
314
+
315
+ /**
316
+ * Simulates a transaction, optimizing leading public static calls by running them directly
317
+ * on the node while sending the remaining calls through the standard PXE path.
318
+ * Return values from both paths are merged back in original call order.
319
+ * @param executionPayload - The execution payload to simulate.
320
+ * @param opts - Simulation options (from address, fee settings, etc.).
321
+ * @returns The merged simulation result.
322
+ */
285
323
  async simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
286
324
  const feeOptions = opts.fee?.estimateGas
287
325
  ? await this.completeFeeOptionsForEstimation(opts.from, executionPayload.feePayer, opts.fee?.gasSettings)
288
326
  : await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
289
- const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
290
- return this.pxe.simulateTx(
291
- txRequest,
292
- true /* simulatePublic */,
293
- opts?.skipTxValidation,
294
- opts?.skipFeeEnforcement ?? true,
295
- );
327
+ const { optimizableCalls, remainingCalls } = extractOptimizablePublicStaticCalls(executionPayload);
328
+ const remainingPayload = { ...executionPayload, calls: remainingCalls };
329
+
330
+ const chainInfo = await this.getChainInfo();
331
+ let blockHeader: BlockHeader;
332
+ // PXE might not be synced yet, so we pull the latest header from the node
333
+ // To keep things consistent, we'll always try with PXE first
334
+ try {
335
+ blockHeader = await this.pxe.getSyncedBlockHeader();
336
+ } catch {
337
+ blockHeader = (await this.aztecNode.getBlockHeader())!;
338
+ }
339
+
340
+ const [optimizedResults, normalResult] = await Promise.all([
341
+ optimizableCalls.length > 0
342
+ ? simulateViaNode(
343
+ this.aztecNode,
344
+ optimizableCalls,
345
+ opts.from,
346
+ chainInfo,
347
+ feeOptions.gasSettings,
348
+ blockHeader,
349
+ opts.skipFeeEnforcement ?? true,
350
+ )
351
+ : Promise.resolve([]),
352
+ remainingCalls.length > 0
353
+ ? this.simulateViaEntrypoint(
354
+ remainingPayload,
355
+ opts.from,
356
+ feeOptions,
357
+ opts.skipTxValidation,
358
+ opts.skipFeeEnforcement ?? true,
359
+ this.scopesFor(opts.from),
360
+ )
361
+ : Promise.resolve(null),
362
+ ]);
363
+
364
+ return buildMergedSimulationResult(optimizedResults, normalResult);
296
365
  }
297
366
 
298
367
  async profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult> {
299
368
  const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
300
369
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
301
- return this.pxe.profileTx(txRequest, opts.profileMode, opts.skipProofGeneration ?? true);
370
+ return this.pxe.profileTx(txRequest, {
371
+ profileMode: opts.profileMode,
372
+ skipProofGeneration: opts.skipProofGeneration ?? true,
373
+ scopes: this.scopesFor(opts.from),
374
+ });
302
375
  }
303
376
 
304
377
  public async sendTx<W extends InteractionWaitOptions = undefined>(
@@ -307,7 +380,7 @@ export abstract class BaseWallet implements Wallet {
307
380
  ): Promise<SendReturn<W>> {
308
381
  const feeOptions = await this.completeFeeOptions(opts.from, executionPayload.feePayer, opts.fee?.gasSettings);
309
382
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(executionPayload, opts.from, feeOptions);
310
- const provenTx = await this.pxe.proveTx(txRequest);
383
+ const provenTx = await this.pxe.proveTx(txRequest, this.scopesFor(opts.from));
311
384
  const tx = await provenTx.toTx();
312
385
  const txHash = tx.getTxHash();
313
386
  if (await this.aztecNode.getTxEffect(txHash)) {
@@ -343,8 +416,8 @@ export abstract class BaseWallet implements Wallet {
343
416
  return err;
344
417
  }
345
418
 
346
- simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult> {
347
- return this.pxe.simulateUtility(call, authwits);
419
+ simulateUtility(call: FunctionCall, opts: SimulateUtilityOptions): Promise<UtilitySimulationResult> {
420
+ return this.pxe.simulateUtility(call, { authwits: opts.authWitnesses, scopes: [opts.scope] });
348
421
  }
349
422
 
350
423
  async getPrivateEvents<T>(
@@ -1 +1,2 @@
1
1
  export { BaseWallet, type FeeOptions } from './base_wallet.js';
2
+ export { simulateViaNode, buildMergedSimulationResult, extractOptimizablePublicStaticCalls } from './utils.js';
@@ -0,0 +1,230 @@
1
+ import type { AztecNode } from '@aztec/aztec.js/node';
2
+ import { MAX_ENQUEUED_CALLS_PER_CALL } from '@aztec/constants';
3
+ import type { ChainInfo } from '@aztec/entrypoints/interfaces';
4
+ import { makeTuple } from '@aztec/foundation/array';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
+ import type { Tuple } from '@aztec/foundation/serialize';
7
+ import { generateSimulatedProvingResult } from '@aztec/pxe/simulator';
8
+ import { type FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
9
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
10
+ import type { GasSettings } from '@aztec/stdlib/gas';
11
+ import {
12
+ ClaimedLengthArray,
13
+ CountedPublicCallRequest,
14
+ PrivateCircuitPublicInputs,
15
+ PublicCallRequest,
16
+ } from '@aztec/stdlib/kernel';
17
+ import { ChonkProof } from '@aztec/stdlib/proofs';
18
+ import {
19
+ type BlockHeader,
20
+ type ExecutionPayload,
21
+ HashedValues,
22
+ PrivateCallExecutionResult,
23
+ PrivateExecutionResult,
24
+ PublicSimulationOutput,
25
+ Tx,
26
+ TxContext,
27
+ TxSimulationResult,
28
+ } from '@aztec/stdlib/tx';
29
+
30
+ /**
31
+ * Splits an execution payload into a leading prefix of public static calls
32
+ * (eligible for direct node simulation) and the remaining calls.
33
+ *
34
+ * Only a leading run of public static calls is eligible for optimization.
35
+ * Any non-public-static call may enqueue public state mutations
36
+ * (e.g. private calls can enqueue public calls), so all calls that follow
37
+ * must go through the normal simulation path to see the correct state.
38
+ *
39
+ */
40
+ export function extractOptimizablePublicStaticCalls(payload: ExecutionPayload): {
41
+ /** Leading public static calls eligible for direct node simulation. */
42
+ optimizableCalls: FunctionCall[];
43
+ /** All remaining calls. */
44
+ remainingCalls: FunctionCall[];
45
+ } {
46
+ const splitIndex = payload.calls.findIndex(call => !call.isPublicStatic());
47
+ const boundary = splitIndex === -1 ? payload.calls.length : splitIndex;
48
+ return {
49
+ optimizableCalls: payload.calls.slice(0, boundary),
50
+ remainingCalls: payload.calls.slice(boundary),
51
+ };
52
+ }
53
+
54
+ /**
55
+ * Simulates a batch of public static calls by bypassing account entrypoint and private execution,
56
+ * directly constructing a minimal Tx and calling node.simulatePublicCalls.
57
+ *
58
+ * @param node - The Aztec node to simulate on.
59
+ * @param publicStaticCalls - Array of public static function calls (max MAX_ENQUEUED_CALLS_PER_CALL).
60
+ * @param from - The account address making the calls.
61
+ * @param chainInfo - Chain information (chainId and version).
62
+ * @param gasSettings - Gas settings for the transaction.
63
+ * @param blockHeader - Block header to use as anchor.
64
+ * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
65
+ * @returns TxSimulationResult with public return values.
66
+ */
67
+ async function simulateBatchViaNode(
68
+ node: AztecNode,
69
+ publicStaticCalls: FunctionCall[],
70
+ from: AztecAddress,
71
+ chainInfo: ChainInfo,
72
+ gasSettings: GasSettings,
73
+ blockHeader: BlockHeader,
74
+ skipFeeEnforcement: boolean,
75
+ ): Promise<TxSimulationResult> {
76
+ const txContext = new TxContext(chainInfo.chainId, chainInfo.version, gasSettings);
77
+
78
+ const publicFunctionCalldata: HashedValues[] = [];
79
+ for (const call of publicStaticCalls) {
80
+ const calldata = await HashedValues.fromCalldata([call.selector.toField(), ...call.args]);
81
+ publicFunctionCalldata.push(calldata);
82
+ }
83
+
84
+ const publicCallRequests = makeTuple(MAX_ENQUEUED_CALLS_PER_CALL, i => {
85
+ const call = publicStaticCalls[i];
86
+ if (!call) {
87
+ return CountedPublicCallRequest.empty();
88
+ }
89
+ const publicCallRequest = new PublicCallRequest(from, call.to, call.isStatic, publicFunctionCalldata[i]!.hash);
90
+ // Counter starts at 1 (minRevertibleSideEffectCounter) so all calls are revertible
91
+ return new CountedPublicCallRequest(publicCallRequest, i + 1);
92
+ });
93
+
94
+ const publicCallRequestsArray: ClaimedLengthArray<CountedPublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_CALL> =
95
+ new ClaimedLengthArray(
96
+ publicCallRequests as Tuple<CountedPublicCallRequest, typeof MAX_ENQUEUED_CALLS_PER_CALL>,
97
+ publicStaticCalls.length,
98
+ );
99
+
100
+ const publicInputs = PrivateCircuitPublicInputs.from({
101
+ ...PrivateCircuitPublicInputs.empty(),
102
+ anchorBlockHeader: blockHeader,
103
+ txContext: txContext,
104
+ publicCallRequests: publicCallRequestsArray,
105
+ startSideEffectCounter: new Fr(0),
106
+ endSideEffectCounter: new Fr(publicStaticCalls.length + 1),
107
+ });
108
+
109
+ // Minimal entrypoint structure — no real private execution, just public call requests
110
+ const emptyEntrypoint = new PrivateCallExecutionResult(
111
+ Buffer.alloc(0),
112
+ Buffer.alloc(0),
113
+ new Map(),
114
+ publicInputs,
115
+ [],
116
+ new Map(),
117
+ [],
118
+ [],
119
+ [],
120
+ [],
121
+ [],
122
+ );
123
+
124
+ const privateResult = new PrivateExecutionResult(emptyEntrypoint, Fr.random(), publicFunctionCalldata);
125
+
126
+ const provingResult = await generateSimulatedProvingResult(
127
+ privateResult,
128
+ (_contractAddress: AztecAddress, _functionSelector: FunctionSelector) => Promise.resolve(''),
129
+ node,
130
+ 1, // minRevertibleSideEffectCounter
131
+ );
132
+
133
+ provingResult.publicInputs.feePayer = from;
134
+
135
+ const tx = await Tx.create({
136
+ data: provingResult.publicInputs,
137
+ chonkProof: ChonkProof.empty(),
138
+ contractClassLogFields: [],
139
+ publicFunctionCalldata: publicFunctionCalldata,
140
+ });
141
+
142
+ const publicOutput = await node.simulatePublicCalls(tx, skipFeeEnforcement);
143
+
144
+ if (publicOutput.revertReason) {
145
+ throw publicOutput.revertReason;
146
+ }
147
+
148
+ return new TxSimulationResult(privateResult, provingResult.publicInputs, publicOutput, undefined);
149
+ }
150
+
151
+ /**
152
+ * Simulates public static calls by splitting them into batches of MAX_ENQUEUED_CALLS_PER_CALL
153
+ * and sending each batch directly to the node.
154
+ *
155
+ * @param node - The Aztec node to simulate on.
156
+ * @param publicStaticCalls - Array of public static function calls to optimize.
157
+ * @param from - The account address making the calls.
158
+ * @param chainInfo - Chain information (chainId and version).
159
+ * @param gasSettings - Gas settings for the transaction.
160
+ * @param blockHeader - Block header to use as anchor.
161
+ * @param skipFeeEnforcement - Whether to skip fee enforcement during simulation.
162
+ * @returns Array of TxSimulationResult, one per batch.
163
+ */
164
+ export async function simulateViaNode(
165
+ node: AztecNode,
166
+ publicStaticCalls: FunctionCall[],
167
+ from: AztecAddress,
168
+ chainInfo: ChainInfo,
169
+ gasSettings: GasSettings,
170
+ blockHeader: BlockHeader,
171
+ skipFeeEnforcement: boolean = true,
172
+ ): Promise<TxSimulationResult[]> {
173
+ const batches: FunctionCall[][] = [];
174
+
175
+ for (let i = 0; i < publicStaticCalls.length; i += MAX_ENQUEUED_CALLS_PER_CALL) {
176
+ batches.push(publicStaticCalls.slice(i, i + MAX_ENQUEUED_CALLS_PER_CALL));
177
+ }
178
+
179
+ const results: TxSimulationResult[] = [];
180
+
181
+ for (const batch of batches) {
182
+ const result = await simulateBatchViaNode(
183
+ node,
184
+ batch,
185
+ from,
186
+ chainInfo,
187
+ gasSettings,
188
+ blockHeader,
189
+ skipFeeEnforcement,
190
+ );
191
+ results.push(result);
192
+ }
193
+
194
+ return results;
195
+ }
196
+
197
+ /**
198
+ * Merges simulation results from the optimized (public static) and normal paths.
199
+ * Since optimized calls are always a leading prefix, return values are simply
200
+ * concatenated: optimized first, then normal.
201
+ * Stats are taken from the normal result only (the optimized path doesn't produce them).
202
+ *
203
+ * @param optimizedResults - Results from optimized public static call batches.
204
+ * @param normalResult - Result from normal simulation (null if all calls were optimized).
205
+ * @returns A single TxSimulationResult with return values in original call order.
206
+ */
207
+ export function buildMergedSimulationResult(
208
+ optimizedResults: TxSimulationResult[],
209
+ normalResult: TxSimulationResult | null,
210
+ ): TxSimulationResult {
211
+ const optimizedReturnValues = optimizedResults.flatMap(r => r.publicOutput?.publicReturnValues ?? []);
212
+ const normalReturnValues = normalResult?.publicOutput?.publicReturnValues ?? [];
213
+ const allReturnValues = [...optimizedReturnValues, ...normalReturnValues];
214
+
215
+ const baseResult = normalResult ?? optimizedResults[0];
216
+
217
+ const mergedPublicOutput: PublicSimulationOutput | undefined = baseResult.publicOutput
218
+ ? {
219
+ ...baseResult.publicOutput,
220
+ publicReturnValues: allReturnValues,
221
+ }
222
+ : undefined;
223
+
224
+ return new TxSimulationResult(
225
+ baseResult.privateExecutionResult,
226
+ baseResult.publicInputs,
227
+ mergedPublicOutput,
228
+ normalResult?.stats,
229
+ );
230
+ }