@aztec/end-to-end 0.0.1-commit.934299a21 → 0.0.1-commit.949a33fd8

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.
Files changed (149) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.js +21 -28
  5. package/dest/bench/utils.d.ts +1 -1
  6. package/dest/bench/utils.d.ts.map +1 -1
  7. package/dest/bench/utils.js +6 -3
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -2
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +15 -15
  11. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +1 -1
  12. package/dest/e2e_epochs/epochs_test.d.ts +18 -1
  13. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  14. package/dest/e2e_epochs/epochs_test.js +61 -10
  15. package/dest/e2e_fees/fees_test.d.ts +1 -1
  16. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  17. package/dest/e2e_fees/fees_test.js +16 -9
  18. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  19. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  20. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  21. package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
  22. package/dest/e2e_p2p/p2p_network.d.ts +13 -11
  23. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  24. package/dest/e2e_p2p/p2p_network.js +65 -43
  25. package/dest/e2e_p2p/reqresp/utils.d.ts +1 -1
  26. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  27. package/dest/e2e_p2p/reqresp/utils.js +23 -7
  28. package/dest/e2e_p2p/shared.d.ts +25 -7
  29. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  30. package/dest/e2e_p2p/shared.js +69 -49
  31. package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
  32. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  33. package/dest/e2e_token_contract/token_contract_test.js +11 -11
  34. package/dest/fixtures/authwit_proxy.d.ts +3 -3
  35. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  36. package/dest/fixtures/authwit_proxy.js +4 -0
  37. package/dest/fixtures/e2e_prover_test.d.ts +4 -3
  38. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  39. package/dest/fixtures/e2e_prover_test.js +11 -16
  40. package/dest/fixtures/fixtures.d.ts +12 -1
  41. package/dest/fixtures/fixtures.d.ts.map +1 -1
  42. package/dest/fixtures/fixtures.js +10 -0
  43. package/dest/fixtures/get_bb_config.d.ts +1 -1
  44. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  45. package/dest/fixtures/get_bb_config.js +5 -5
  46. package/dest/fixtures/ha_setup.d.ts +2 -2
  47. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  48. package/dest/fixtures/ha_setup.js +1 -1
  49. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  50. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  51. package/dest/fixtures/schnorr_hardcoded_account_contract.js +39 -0
  52. package/dest/fixtures/setup.d.ts +24 -13
  53. package/dest/fixtures/setup.d.ts.map +1 -1
  54. package/dest/fixtures/setup.js +45 -25
  55. package/dest/fixtures/setup_p2p_test.d.ts +6 -6
  56. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  57. package/dest/fixtures/setup_p2p_test.js +8 -8
  58. package/dest/fixtures/token_utils.d.ts +1 -1
  59. package/dest/fixtures/token_utils.d.ts.map +1 -1
  60. package/dest/fixtures/token_utils.js +2 -5
  61. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  62. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  63. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  64. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  65. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  66. package/dest/forward-compatibility/wallet_service.js +109 -0
  67. package/dest/legacy-jest-resolver.d.cts +3 -0
  68. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  69. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  70. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  71. package/dest/shared/cross_chain_test_harness.js +13 -13
  72. package/dest/shared/gas_portal_test_harness.js +3 -3
  73. package/dest/shared/jest_setup.js +32 -1
  74. package/dest/shared/submit-transactions.d.ts +1 -1
  75. package/dest/shared/submit-transactions.d.ts.map +1 -1
  76. package/dest/shared/submit-transactions.js +1 -1
  77. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  78. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  79. package/dest/shared/uniswap_l1_l2.js +14 -21
  80. package/dest/simulators/lending_simulator.d.ts +1 -1
  81. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  82. package/dest/simulators/lending_simulator.js +4 -4
  83. package/dest/simulators/token_simulator.d.ts +1 -1
  84. package/dest/simulators/token_simulator.d.ts.map +1 -1
  85. package/dest/simulators/token_simulator.js +2 -2
  86. package/dest/spartan/setup_test_wallets.d.ts +4 -2
  87. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  88. package/dest/spartan/setup_test_wallets.js +69 -38
  89. package/dest/spartan/tx_metrics.d.ts +1 -1
  90. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  91. package/dest/spartan/tx_metrics.js +19 -3
  92. package/dest/spartan/utils/config.d.ts +7 -1
  93. package/dest/spartan/utils/config.d.ts.map +1 -1
  94. package/dest/spartan/utils/config.js +3 -1
  95. package/dest/spartan/utils/index.d.ts +3 -1
  96. package/dest/spartan/utils/index.d.ts.map +1 -1
  97. package/dest/spartan/utils/index.js +4 -0
  98. package/dest/spartan/utils/nodes.js +1 -1
  99. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  100. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  101. package/dest/spartan/utils/pod_logs.js +74 -0
  102. package/dest/test-wallet/test_wallet.d.ts +24 -23
  103. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  104. package/dest/test-wallet/test_wallet.js +124 -83
  105. package/dest/test-wallet/worker_wallet.d.ts +4 -4
  106. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  107. package/dest/test-wallet/worker_wallet_schema.d.ts +10 -5
  108. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  109. package/package.json +43 -44
  110. package/src/bench/client_flows/client_flows_benchmark.ts +29 -12
  111. package/src/bench/utils.ts +7 -2
  112. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +21 -20
  113. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
  114. package/src/e2e_epochs/epochs_test.ts +70 -9
  115. package/src/e2e_fees/fees_test.ts +17 -8
  116. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  117. package/src/e2e_p2p/inactivity_slash_test.ts +3 -3
  118. package/src/e2e_p2p/p2p_network.ts +82 -60
  119. package/src/e2e_p2p/reqresp/utils.ts +29 -7
  120. package/src/e2e_p2p/shared.ts +88 -63
  121. package/src/e2e_token_contract/token_contract_test.ts +16 -8
  122. package/src/fixtures/authwit_proxy.ts +4 -0
  123. package/src/fixtures/e2e_prover_test.ts +19 -18
  124. package/src/fixtures/fixtures.ts +22 -0
  125. package/src/fixtures/get_bb_config.ts +7 -6
  126. package/src/fixtures/ha_setup.ts +4 -2
  127. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  128. package/src/fixtures/setup.ts +69 -33
  129. package/src/fixtures/setup_p2p_test.ts +9 -9
  130. package/src/fixtures/token_utils.ts +1 -2
  131. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  132. package/src/forward-compatibility/wallet_service.ts +104 -0
  133. package/src/guides/up_quick_start.sh +0 -2
  134. package/src/legacy-jest-resolver.cjs +135 -0
  135. package/src/shared/cross_chain_test_harness.ts +13 -9
  136. package/src/shared/gas_portal_test_harness.ts +1 -2
  137. package/src/shared/jest_setup.ts +36 -1
  138. package/src/shared/submit-transactions.ts +1 -4
  139. package/src/shared/uniswap_l1_l2.ts +35 -32
  140. package/src/simulators/lending_simulator.ts +8 -4
  141. package/src/simulators/token_simulator.ts +6 -2
  142. package/src/spartan/setup_test_wallets.ts +90 -35
  143. package/src/spartan/tx_metrics.ts +17 -5
  144. package/src/spartan/utils/config.ts +2 -0
  145. package/src/spartan/utils/index.ts +6 -0
  146. package/src/spartan/utils/nodes.ts +1 -1
  147. package/src/spartan/utils/pod_logs.ts +99 -0
  148. package/src/test-wallet/test_wallet.ts +152 -101
  149. package/src/test-wallet/worker_wallet.ts +3 -2
@@ -1,7 +1,9 @@
1
1
  import { EcdsaKAccountContract, EcdsaRAccountContract } from '@aztec/accounts/ecdsa';
2
2
  import { SchnorrAccountContract } from '@aztec/accounts/schnorr';
3
- import { StubAccountContractArtifact, createStubAccount } from '@aztec/accounts/stub';
4
- import { type Account, type AccountContract, SignerlessAccount } from '@aztec/aztec.js/account';
3
+ import { StubEcdsaAccountContractArtifact, createStubEcdsaAccount } from '@aztec/accounts/stub/ecdsa';
4
+ import { StubSchnorrAccountContractArtifact, createStubSchnorrAccount } from '@aztec/accounts/stub/schnorr';
5
+ import { type Account, type AccountContract, NO_FROM } from '@aztec/aztec.js/account';
6
+ import type { CompleteAddress } from '@aztec/aztec.js/addresses';
5
7
  import {
6
8
  type CallIntent,
7
9
  type ContractFunctionInteractionCallIntent,
@@ -13,10 +15,12 @@ import {
13
15
  } from '@aztec/aztec.js/authorization';
14
16
  import type { AztecNode } from '@aztec/aztec.js/node';
15
17
  import { AccountManager, type SendOptions } from '@aztec/aztec.js/wallet';
18
+ import { TxSimulationResultWithAppOffset } from '@aztec/aztec.js/wallet';
16
19
  import type { DefaultAccountEntrypointOptions } from '@aztec/entrypoints/account';
20
+ import { DefaultEntrypoint } from '@aztec/entrypoints/default';
17
21
  import { Fq, Fr } from '@aztec/foundation/curves/bn254';
18
22
  import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
19
- import type { AccessScopes, NotesFilter } from '@aztec/pxe/client/lazy';
23
+ import type { NotesFilter } from '@aztec/pxe/client/lazy';
20
24
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/config';
21
25
  import { PXE, type PXECreationOptions, createPXE } from '@aztec/pxe/server';
22
26
  import { AuthWitness } from '@aztec/stdlib/auth-witness';
@@ -24,10 +28,19 @@ import { AztecAddress } from '@aztec/stdlib/aztec-address';
24
28
  import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
25
29
  import { deriveSigningKey } from '@aztec/stdlib/keys';
26
30
  import type { NoteDao } from '@aztec/stdlib/note';
27
- import type { BlockHeader, TxHash, TxReceipt, TxSimulationResult } from '@aztec/stdlib/tx';
31
+ import {
32
+ type BlockHeader,
33
+ type ContractOverrides,
34
+ SimulationOverrides,
35
+ type TxExecutionRequest,
36
+ type TxHash,
37
+ type TxReceipt,
38
+ } from '@aztec/stdlib/tx';
28
39
  import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
29
- import { BaseWallet, type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
40
+ import { BaseWallet, type SimulateViaEntrypointOptions } from '@aztec/wallet-sdk/base-wallet';
41
+ import type { AccountType } from '@aztec/wallets/embedded';
30
42
 
43
+ import { DEFAULT_MIN_FEE_PADDING } from '../fixtures/fixtures.js';
31
44
  import { AztecNodeProxy, ProvenTx } from './utils.js';
32
45
 
33
46
  /**
@@ -36,6 +49,7 @@ import { AztecNodeProxy, ProvenTx } from './utils.js';
36
49
  export interface AccountData {
37
50
  secret: Fr;
38
51
  salt: Fr;
52
+ type?: AccountType;
39
53
  contract: AccountContract;
40
54
  }
41
55
 
@@ -50,6 +64,7 @@ export class TestWallet extends BaseWallet {
50
64
  private readonly nodeRef: AztecNodeProxy,
51
65
  ) {
52
66
  super(pxe, nodeRef);
67
+ this.minFeePadding = DEFAULT_MIN_FEE_PADDING;
53
68
  }
54
69
 
55
70
  static async create(
@@ -76,98 +91,118 @@ export class TestWallet extends BaseWallet {
76
91
 
77
92
  createSchnorrAccount(secret: Fr, salt: Fr, signingKey?: Fq): Promise<AccountManager> {
78
93
  signingKey = signingKey ?? deriveSigningKey(secret);
79
- const accountData = {
80
- secret,
81
- salt,
82
- contract: new SchnorrAccountContract(signingKey),
83
- };
84
- return this.createAccount(accountData);
94
+ return this.createAccount({ secret, salt, type: 'schnorr', contract: new SchnorrAccountContract(signingKey) });
85
95
  }
86
96
 
87
97
  createECDSARAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
88
- const accountData = {
98
+ return this.createAccount({
89
99
  secret,
90
100
  salt,
101
+ type: 'ecdsasecp256r1',
91
102
  contract: new EcdsaRAccountContract(signingKey),
92
- };
93
- return this.createAccount(accountData);
103
+ });
94
104
  }
95
105
 
96
106
  createECDSAKAccount(secret: Fr, salt: Fr, signingKey: Buffer): Promise<AccountManager> {
97
- const accountData = {
107
+ return this.createAccount({
98
108
  secret,
99
109
  salt,
110
+ type: 'ecdsasecp256k1',
100
111
  contract: new EcdsaKAccountContract(signingKey),
101
- };
102
- return this.createAccount(accountData);
103
- }
104
-
105
- async getFakeAccountDataFor(address: AztecAddress) {
106
- const originalAccount = await this.getAccountFromAddress(address);
107
- if (originalAccount instanceof SignerlessAccount) {
108
- throw new Error(`Cannot create fake account data for SignerlessAccount at address: ${address}`);
109
- }
110
- const originalAddress = (originalAccount as Account).getCompleteAddress();
111
- const contractInstance = await this.pxe.getContractInstance(originalAddress.address);
112
- if (!contractInstance) {
113
- throw new Error(`No contract instance found for address: ${originalAddress.address}`);
114
- }
115
- const stubAccount = createStubAccount(originalAddress);
116
- const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
117
- salt: Fr.random(),
118
112
  });
119
- return {
120
- account: stubAccount,
121
- instance,
122
- artifact: StubAccountContractArtifact,
123
- };
124
113
  }
125
- protected accounts: Map<string, Account> = new Map();
126
114
 
127
115
  /**
128
- * Toggle for running "simulated simulations" when calling simulateTx.
129
- *
130
- * When this flag is true, simulateViaEntrypoint constructs a request using a fake account
131
- * (and accepts contract overrides on the input) and the PXE emulates kernel effects without
132
- * generating kernel witnesses. When false, simulateViaEntrypoint defers to the standard
133
- * simulation path via the real account entrypoint.
116
+ * Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
134
117
  */
135
- private simulatedSimulations = false;
118
+ protected async buildAccountOverrides(addresses: AztecAddress[]): Promise<ContractOverrides> {
119
+ const accounts = await this.getAccounts();
120
+ const contracts: ContractOverrides = {};
121
+
122
+ const filtered = accounts.filter(acc => addresses.some(addr => addr.equals(acc.item)));
123
+
124
+ for (const account of filtered) {
125
+ const address = account.item;
126
+ const originalAccount = await this.getAccountFromAddress(address);
127
+ const completeAddress = originalAccount.getCompleteAddress();
128
+ const contractInstance = await this.pxe.getContractInstance(completeAddress.address);
129
+ if (!contractInstance) {
130
+ throw new Error(
131
+ `No contract instance found for address: ${completeAddress.address} during account override building. This is a bug!`,
132
+ );
133
+ }
134
+
135
+ const stubArtifact = this.getStubArtifactFor(address);
136
+ const stubConstructorArgs =
137
+ this.getTypeFor(address) === 'schnorr' ? [Fr.ZERO, Fr.ZERO] : [Buffer.alloc(32), Buffer.alloc(32)];
138
+ const stubInstance = await getContractInstanceFromInstantiationParams(stubArtifact, {
139
+ salt: Fr.random(),
140
+ constructorArgs: stubConstructorArgs,
141
+ });
142
+
143
+ contracts[address.toString()] = {
144
+ instance: stubInstance,
145
+ artifact: stubArtifact,
146
+ };
147
+ }
136
148
 
137
- enableSimulatedSimulations() {
138
- this.simulatedSimulations = true;
149
+ return contracts;
139
150
  }
140
151
 
141
- disableSimulatedSimulations() {
142
- this.simulatedSimulations = false;
152
+ protected accounts: Map<string, { account: Account; type: AccountType }> = new Map();
153
+
154
+ private getTypeFor(address: AztecAddress): AccountType {
155
+ return this.accounts.get(address.toString())?.type ?? 'schnorr';
156
+ }
157
+
158
+ private getStubArtifactFor(address: AztecAddress) {
159
+ return this.getTypeFor(address) === 'schnorr'
160
+ ? StubSchnorrAccountContractArtifact
161
+ : StubEcdsaAccountContractArtifact;
162
+ }
163
+
164
+ private getStubAccountFor(address: AztecAddress, completeAddress: CompleteAddress) {
165
+ return this.getTypeFor(address) === 'schnorr'
166
+ ? createStubSchnorrAccount(completeAddress)
167
+ : createStubEcdsaAccount(completeAddress);
168
+ }
169
+
170
+ /**
171
+ * Controls how the test wallet simulates transactions:
172
+ * - `kernelless`: Skips kernel circuits but uses the real account contract. Default.
173
+ * - `kernelless-override`: Skips kernels and replaces the account with a stub that doesn't do authwit validation.
174
+ * - `full`: Uses real kernel circuits and real account contracts. Slow!
175
+ */
176
+ private simulationMode: 'kernelless' | 'kernelless-override' | 'full' = 'kernelless';
177
+
178
+ setSimulationMode(mode: 'kernelless' | 'kernelless-override' | 'full') {
179
+ this.simulationMode = mode;
143
180
  }
144
181
 
145
182
  setMinFeePadding(value?: number) {
146
- this.minFeePadding = value ?? 0.5;
183
+ this.minFeePadding = value ?? DEFAULT_MIN_FEE_PADDING;
147
184
  }
148
185
 
149
186
  protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
150
- let account: Account | undefined;
151
- if (address.equals(AztecAddress.ZERO)) {
152
- account = new SignerlessAccount();
153
- } else {
154
- account = this.accounts.get(address?.toString() ?? '');
155
- }
187
+ const entry = this.accounts.get(address?.toString() ?? '');
156
188
 
157
- if (!account) {
189
+ if (!entry) {
158
190
  throw new Error(`Account not found in wallet for address: ${address}`);
159
191
  }
160
192
 
161
- return Promise.resolve(account);
193
+ return Promise.resolve(entry.account);
162
194
  }
163
195
 
164
196
  getAccounts() {
165
- return Promise.resolve(Array.from(this.accounts.values()).map(acc => ({ alias: '', item: acc.getAddress() })));
197
+ return Promise.resolve(
198
+ Array.from(this.accounts.values()).map(entry => ({ alias: '', item: entry.account.getAddress() })),
199
+ );
166
200
  }
167
201
 
168
202
  async createAccount(accountData?: AccountData): Promise<AccountManager> {
169
203
  const secret = accountData?.secret ?? Fr.random();
170
204
  const salt = accountData?.salt ?? Fr.random();
205
+ const type = accountData?.type ?? 'schnorr';
171
206
  const contract = accountData?.contract ?? new SchnorrAccountContract(GrumpkinScalar.random());
172
207
 
173
208
  const accountManager = await AccountManager.create(this, secret, contract, salt);
@@ -177,7 +212,8 @@ export class TestWallet extends BaseWallet {
177
212
 
178
213
  await this.registerContract(instance, artifact, secret);
179
214
 
180
- this.accounts.set(accountManager.address.toString(), await accountManager.getAccount());
215
+ const address = accountManager.address.toString();
216
+ this.accounts.set(address, { account: await accountManager.getAccount(), type });
181
217
 
182
218
  return accountManager;
183
219
  }
@@ -220,62 +256,77 @@ export class TestWallet extends BaseWallet {
220
256
  return account.createAuthWit(intentInnerHash, chainInfo);
221
257
  }
222
258
 
223
- /**
224
- * Override simulateViaEntrypoint to use fake accounts for kernelless simulation
225
- * when simulatedSimulations is enabled. Otherwise falls through to the real entrypoint path.
226
- */
227
259
  protected override async simulateViaEntrypoint(
228
260
  executionPayload: ExecutionPayload,
229
- from: AztecAddress,
230
- feeOptions: FeeOptions,
231
- scopes: AccessScopes,
232
- skipTxValidation?: boolean,
233
- skipFeeEnforcement?: boolean,
234
- ): Promise<TxSimulationResult> {
235
- if (!this.simulatedSimulations) {
236
- return super.simulateViaEntrypoint(
237
- executionPayload,
238
- from,
239
- feeOptions,
240
- scopes,
241
- skipTxValidation,
242
- skipFeeEnforcement,
243
- );
244
- }
261
+ opts: SimulateViaEntrypointOptions,
262
+ ): Promise<TxSimulationResultWithAppOffset> {
263
+ const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
264
+ const scopes = this.scopesFrom(from, additionalScopes);
265
+ const skipKernels = this.simulationMode !== 'full';
266
+ const useOverride = this.simulationMode === 'kernelless-override';
245
267
 
246
268
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
247
- const executionOptions: DefaultAccountEntrypointOptions = {
248
- txNonce: Fr.random(),
249
- cancellable: this.cancellableTransactions,
250
- feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
251
- };
252
269
  const finalExecutionPayload = feeExecutionPayload
253
270
  ? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
254
271
  : executionPayload;
255
- const { account: fromAccount, instance, artifact } = await this.getFakeAccountDataFor(from);
256
272
  const chainInfo = await this.getChainInfo();
257
- const txRequest = await fromAccount.createTxExecutionRequest(
258
- finalExecutionPayload,
259
- feeOptions.gasSettings,
260
- chainInfo,
261
- executionOptions,
262
- );
263
- const contractOverrides = {
264
- [from.toString()]: { instance, artifact },
265
- };
266
- return this.pxe.simulateTx(txRequest, {
273
+
274
+ let overrides: SimulationOverrides | undefined;
275
+ let txRequest: TxExecutionRequest;
276
+ if (useOverride) {
277
+ const accountOverrides = await this.buildAccountOverrides(scopes);
278
+ overrides = new SimulationOverrides(accountOverrides);
279
+ }
280
+
281
+ if (from === NO_FROM) {
282
+ const entrypoint = new DefaultEntrypoint();
283
+ txRequest = await entrypoint.createTxExecutionRequest(finalExecutionPayload, feeOptions.gasSettings, chainInfo);
284
+ } else {
285
+ let fromAccount: Account;
286
+ if (useOverride) {
287
+ const originalAccount = await this.getAccountFromAddress(from);
288
+ fromAccount = this.getStubAccountFor(from, originalAccount.getCompleteAddress());
289
+ } else {
290
+ fromAccount = await this.getAccountFromAddress(from);
291
+ }
292
+ const executionOptions: DefaultAccountEntrypointOptions = {
293
+ txNonce: Fr.random(),
294
+ cancellable: this.cancellableTransactions,
295
+ // If from is an address, feeOptions include the way the account contract should handle the fee payment
296
+ feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions!,
297
+ };
298
+ txRequest = await fromAccount.createTxExecutionRequest(
299
+ finalExecutionPayload,
300
+ feeOptions.gasSettings,
301
+ chainInfo,
302
+ executionOptions,
303
+ );
304
+ }
305
+
306
+ const result = await this.pxe.simulateTx(txRequest, {
267
307
  simulatePublic: true,
268
- skipFeeEnforcement: true,
269
- skipTxValidation: true,
270
- overrides: { contracts: contractOverrides },
308
+ skipKernels,
309
+ skipFeeEnforcement,
310
+ skipTxValidation,
311
+ overrides,
271
312
  scopes,
313
+ senderForTags: this.senderForTagsFrom(from, sendMessagesAs),
272
314
  });
315
+ const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
316
+ return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
273
317
  }
274
318
 
275
319
  async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
276
- const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
320
+ const fee = await this.completeFeeOptions({
321
+ from: opts.from,
322
+ feePayer: exec.feePayer,
323
+ gasSettings: opts.fee?.gasSettings,
324
+ });
277
325
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
278
- const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
326
+ const txProvingResult = await this.pxe.proveTx(txRequest, {
327
+ scopes: this.scopesFrom(opts.from, opts.additionalScopes),
328
+ senderForTags: this.senderForTagsFrom(opts.from, opts.sendMessagesAs),
329
+ });
279
330
  return new ProvenTx(
280
331
  this.aztecNode,
281
332
  await txProvingResult.toTx(),
@@ -13,6 +13,7 @@ import type {
13
13
  ProfileOptions,
14
14
  SendOptions,
15
15
  SimulateOptions,
16
+ TxSimulationResultWithAppOffset,
16
17
  Wallet,
17
18
  WalletCapabilities,
18
19
  } from '@aztec/aztec.js/wallet';
@@ -29,7 +30,7 @@ import type { ContractArtifact, EventMetadataDefinition, FunctionCall } from '@a
29
30
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
30
31
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
31
32
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
32
- import type { ExecutionPayload, TxProfileResult, TxSimulationResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
33
+ import type { ExecutionPayload, TxProfileResult, UtilityExecutionResult } from '@aztec/stdlib/tx';
33
34
  import { Tx } from '@aztec/stdlib/tx';
34
35
 
35
36
  import { Worker } from 'worker_threads';
@@ -165,7 +166,7 @@ export class WorkerWallet implements Wallet {
165
166
  return this.call('registerContract', instance, artifact, secretKey);
166
167
  }
167
168
 
168
- simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult> {
169
+ simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResultWithAppOffset> {
169
170
  return this.call('simulateTx', exec, opts);
170
171
  }
171
172