@aztec/end-to-end 0.0.1-commit.5de5ca79e → 0.0.1-commit.6201a7b05

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 (109) 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 +15 -30
  5. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -2
  6. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +1 -1
  8. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +1 -1
  9. package/dest/e2e_epochs/epochs_test.d.ts +16 -1
  10. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  11. package/dest/e2e_epochs/epochs_test.js +56 -8
  12. package/dest/e2e_fees/fees_test.d.ts +1 -1
  13. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  14. package/dest/e2e_fees/fees_test.js +4 -4
  15. package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
  16. package/dest/e2e_p2p/p2p_network.d.ts +10 -9
  17. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  18. package/dest/e2e_p2p/p2p_network.js +46 -27
  19. package/dest/e2e_p2p/reqresp/utils.d.ts +1 -1
  20. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  21. package/dest/e2e_p2p/reqresp/utils.js +10 -7
  22. package/dest/e2e_p2p/shared.d.ts +5 -7
  23. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  24. package/dest/e2e_p2p/shared.js +36 -47
  25. package/dest/fixtures/authwit_proxy.d.ts +1 -1
  26. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  27. package/dest/fixtures/authwit_proxy.js +4 -0
  28. package/dest/fixtures/e2e_prover_test.d.ts +4 -3
  29. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  30. package/dest/fixtures/e2e_prover_test.js +7 -12
  31. package/dest/fixtures/fixtures.d.ts +12 -1
  32. package/dest/fixtures/fixtures.d.ts.map +1 -1
  33. package/dest/fixtures/fixtures.js +10 -0
  34. package/dest/fixtures/get_bb_config.d.ts +1 -1
  35. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  36. package/dest/fixtures/get_bb_config.js +5 -5
  37. package/dest/fixtures/ha_setup.d.ts +2 -2
  38. package/dest/fixtures/ha_setup.d.ts.map +1 -1
  39. package/dest/fixtures/ha_setup.js +1 -1
  40. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts +25 -0
  41. package/dest/fixtures/schnorr_hardcoded_account_contract.d.ts.map +1 -0
  42. package/dest/fixtures/schnorr_hardcoded_account_contract.js +39 -0
  43. package/dest/fixtures/setup.d.ts +17 -10
  44. package/dest/fixtures/setup.d.ts.map +1 -1
  45. package/dest/fixtures/setup.js +41 -22
  46. package/dest/fixtures/setup_p2p_test.d.ts +6 -6
  47. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  48. package/dest/fixtures/setup_p2p_test.js +8 -8
  49. package/dest/fixtures/token_utils.d.ts +1 -1
  50. package/dest/fixtures/token_utils.d.ts.map +1 -1
  51. package/dest/fixtures/token_utils.js +2 -5
  52. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  53. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  54. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  55. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  56. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  57. package/dest/forward-compatibility/wallet_service.js +109 -0
  58. package/dest/legacy-jest-resolver.d.cts +3 -0
  59. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  60. package/dest/shared/gas_portal_test_harness.js +1 -1
  61. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  62. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  63. package/dest/shared/uniswap_l1_l2.js +0 -4
  64. package/dest/simulators/lending_simulator.d.ts +1 -1
  65. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  66. package/dest/simulators/lending_simulator.js +2 -2
  67. package/dest/spartan/setup_test_wallets.d.ts +1 -1
  68. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  69. package/dest/spartan/setup_test_wallets.js +63 -45
  70. package/dest/spartan/tx_metrics.d.ts +1 -1
  71. package/dest/spartan/tx_metrics.d.ts.map +1 -1
  72. package/dest/spartan/tx_metrics.js +18 -2
  73. package/dest/test-wallet/test_wallet.d.ts +16 -8
  74. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  75. package/dest/test-wallet/test_wallet.js +111 -70
  76. package/dest/test-wallet/worker_wallet.d.ts +4 -4
  77. package/dest/test-wallet/worker_wallet.d.ts.map +1 -1
  78. package/dest/test-wallet/worker_wallet_schema.d.ts +9 -4
  79. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -1
  80. package/package.json +40 -39
  81. package/src/bench/client_flows/client_flows_benchmark.ts +33 -24
  82. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +3 -6
  83. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -1
  84. package/src/e2e_epochs/epochs_test.ts +56 -7
  85. package/src/e2e_fees/fees_test.ts +5 -3
  86. package/src/e2e_p2p/inactivity_slash_test.ts +3 -3
  87. package/src/e2e_p2p/p2p_network.ts +57 -39
  88. package/src/e2e_p2p/reqresp/utils.ts +8 -7
  89. package/src/e2e_p2p/shared.ts +33 -61
  90. package/src/fixtures/authwit_proxy.ts +4 -0
  91. package/src/fixtures/e2e_prover_test.ts +12 -17
  92. package/src/fixtures/fixtures.ts +22 -0
  93. package/src/fixtures/get_bb_config.ts +7 -6
  94. package/src/fixtures/ha_setup.ts +4 -2
  95. package/src/fixtures/schnorr_hardcoded_account_contract.ts +49 -0
  96. package/src/fixtures/setup.ts +55 -26
  97. package/src/fixtures/setup_p2p_test.ts +9 -9
  98. package/src/fixtures/token_utils.ts +1 -4
  99. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  100. package/src/forward-compatibility/wallet_service.ts +104 -0
  101. package/src/guides/up_quick_start.sh +0 -2
  102. package/src/legacy-jest-resolver.cjs +135 -0
  103. package/src/shared/gas_portal_test_harness.ts +0 -1
  104. package/src/shared/uniswap_l1_l2.ts +0 -4
  105. package/src/simulators/lending_simulator.ts +4 -2
  106. package/src/spartan/setup_test_wallets.ts +63 -39
  107. package/src/spartan/tx_metrics.ts +16 -4
  108. package/src/test-wallet/test_wallet.ts +137 -74
  109. package/src/test-wallet/worker_wallet.ts +3 -2
@@ -1,4 +1,5 @@
1
1
  import { generateSchnorrAccounts } from '@aztec/accounts/testing';
2
+ import { NO_FROM } from '@aztec/aztec.js/account';
2
3
  import { AztecAddress } from '@aztec/aztec.js/addresses';
3
4
  import { NO_WAIT } from '@aztec/aztec.js/contracts';
4
5
  import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
@@ -10,7 +11,7 @@ import type { Wallet } from '@aztec/aztec.js/wallet';
10
11
  import { createEthereumChain } from '@aztec/ethereum/chain';
11
12
  import { createExtendedL1Client } from '@aztec/ethereum/client';
12
13
  import type { Logger } from '@aztec/foundation/log';
13
- import { retryUntil } from '@aztec/foundation/retry';
14
+ import { makeBackoff, retry, retryUntil } from '@aztec/foundation/retry';
14
15
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
15
16
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
16
17
  import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/testing';
@@ -89,7 +90,7 @@ export async function deploySponsoredTestAccountsWithTokens(
89
90
  const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
90
91
  const recipientDeployMethod = await recipientAccount.getDeployMethod();
91
92
  await recipientDeployMethod.send({
92
- from: AztecAddress.ZERO,
93
+ from: NO_FROM,
93
94
  fee: { paymentMethod },
94
95
  wait: { timeout: 2400 },
95
96
  });
@@ -97,7 +98,7 @@ export async function deploySponsoredTestAccountsWithTokens(
97
98
  fundedAccounts.map(async a => {
98
99
  const deployMethod = await a.getDeployMethod();
99
100
  await deployMethod.send({
100
- from: AztecAddress.ZERO,
101
+ from: NO_FROM,
101
102
  fee: { paymentMethod },
102
103
  wait: { timeout: 2400 },
103
104
  }); // increase timeout on purpose in order to account for two empty epochs
@@ -137,38 +138,57 @@ async function deployAccountWithDiagnostics(
137
138
  estimateGas?: boolean,
138
139
  ): Promise<void> {
139
140
  const deployMethod = await account.getDeployMethod();
140
- let txHash;
141
- try {
142
- let gasSettings;
143
- if (estimateGas) {
144
- const sim = await deployMethod.simulate({ from: AztecAddress.ZERO, fee: { paymentMethod } });
145
- gasSettings = sim.estimatedGas;
146
- logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`);
147
- }
148
- const deployResult = await deployMethod.send({
149
- from: AztecAddress.ZERO,
150
- fee: { paymentMethod, gasSettings },
151
- wait: NO_WAIT,
152
- });
153
- txHash = deployResult.txHash;
154
- await waitForTx(aztecNode, txHash, { timeout: 2400 });
155
- logger.info(`${accountLabel} deployed at ${account.address}`);
156
- } catch (error) {
157
- const blockNumber = await aztecNode.getBlockNumber();
158
- let receipt;
159
- try {
160
- receipt = await aztecNode.getTxReceipt(txHash);
161
- } catch {
162
- receipt = 'unavailable';
163
- }
164
- logger.error(`${accountLabel} deployment failed`, {
165
- txHash: txHash.toString(),
166
- receipt: JSON.stringify(receipt),
167
- currentBlockNumber: blockNumber,
168
- error: String(error),
169
- });
170
- throw error;
141
+ let gasSettings: any;
142
+ if (estimateGas) {
143
+ const sim = await deployMethod.simulate({ from: NO_FROM, fee: { paymentMethod } });
144
+ gasSettings = sim.estimatedGas;
145
+ logger.info(`${accountLabel} estimated gas: DA=${gasSettings.gasLimits.daGas} L2=${gasSettings.gasLimits.l2Gas}`);
171
146
  }
147
+
148
+ // Track the tx hash across retries so we don't re-send when the previous tx is still pending.
149
+ let sentTxHash: { txHash: any } | undefined;
150
+
151
+ await retry(
152
+ async () => {
153
+ // Check if already deployed (handles case where previous attempt succeeded but waitForTx timed out)
154
+ const existing = await aztecNode.getContract(account.address);
155
+ if (existing) {
156
+ logger.info(`${accountLabel} already deployed at ${account.address}, skipping`);
157
+ return;
158
+ }
159
+
160
+ // If we already sent a tx, check if it was dropped before deciding to re-send.
161
+ if (sentTxHash) {
162
+ const prevReceipt = await aztecNode.getTxReceipt(sentTxHash.txHash);
163
+ if (prevReceipt.isDropped()) {
164
+ logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} was dropped, re-sending`);
165
+ sentTxHash = undefined;
166
+ } else {
167
+ logger.info(`${accountLabel} previous tx ${sentTxHash.txHash} still pending, waiting again...`);
168
+ }
169
+ }
170
+
171
+ if (!sentTxHash) {
172
+ const deployResult = await deployMethod.send({
173
+ from: NO_FROM,
174
+ fee: { paymentMethod, gasSettings },
175
+ wait: NO_WAIT,
176
+ });
177
+ sentTxHash = { txHash: deployResult.txHash };
178
+ logger.info(`${accountLabel} tx sent`, { txHash: sentTxHash.txHash.toString() });
179
+ }
180
+
181
+ const receipt = await waitForTx(aztecNode, sentTxHash.txHash, { timeout: 600 });
182
+ if (receipt.isDropped()) {
183
+ sentTxHash = undefined;
184
+ throw new Error(`${accountLabel} tx was dropped, retrying...`);
185
+ }
186
+ logger.info(`${accountLabel} deployed at ${account.address}`);
187
+ },
188
+ `deploy ${accountLabel}`,
189
+ makeBackoff([1, 2, 4, 8, 16]),
190
+ logger,
191
+ );
172
192
  }
173
193
 
174
194
  async function deployAccountsInBatches(
@@ -269,7 +289,7 @@ export async function deployTestAccountsWithTokens(
269
289
  fundedAccounts.map(async (a, i) => {
270
290
  const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
271
291
  const deployMethod = await a.getDeployMethod();
272
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } });
292
+ await deployMethod.send({ from: NO_FROM, fee: { paymentMethod } });
273
293
  logger.info(`Account deployed at ${a.address}`);
274
294
  }),
275
295
  );
@@ -345,14 +365,18 @@ async function deployTokenAndMint(
345
365
  logger: Logger,
346
366
  ) {
347
367
  logger.verbose(`Deploying TokenContract...`);
348
- const {
349
- receipt: { contract: tokenContract },
350
- } = await TokenContract.deploy(wallet, admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS).send({
368
+ const { contract: tokenContract } = await TokenContract.deploy(
369
+ wallet,
370
+ admin,
371
+ TOKEN_NAME,
372
+ TOKEN_SYMBOL,
373
+ TOKEN_DECIMALS,
374
+ ).send({
351
375
  from: admin,
352
376
  fee: {
353
377
  paymentMethod,
354
378
  },
355
- wait: { timeout: 600, returnReceipt: true },
379
+ wait: { timeout: 600 },
356
380
  });
357
381
 
358
382
  const tokenAddress = tokenContract.address;
@@ -1,6 +1,6 @@
1
1
  import type { AztecNode } from '@aztec/aztec.js/node';
2
2
  import type { Logger } from '@aztec/foundation/log';
3
- import type { L2Block } from '@aztec/stdlib/block';
3
+ import type { BlockResponse } from '@aztec/stdlib/interfaces/client';
4
4
  import type { TopicType } from '@aztec/stdlib/p2p';
5
5
  import { Tx, type TxReceipt } from '@aztec/stdlib/tx';
6
6
 
@@ -147,7 +147,7 @@ export type TxInclusionData = {
147
147
  export class TxInclusionMetrics {
148
148
  private data = new Map<string, TxInclusionData>();
149
149
  private groups = new Set<string>();
150
- private blocks = new Map<number, Promise<L2Block | undefined>>();
150
+ private blocks = new Map<number, Promise<BlockResponse<{ includeTransactions: true }> | undefined>>();
151
151
 
152
152
  private p2pGossipLatencyByTopic: Partial<Record<TopicType, { p50: number; p95: number }>> = {};
153
153
 
@@ -198,7 +198,7 @@ export class TxInclusionMetrics {
198
198
  }
199
199
 
200
200
  if (!this.blocks.has(blockNumber)) {
201
- this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber));
201
+ this.blocks.set(blockNumber, this.aztecNode.getBlock(blockNumber, { includeTransactions: true }));
202
202
  }
203
203
 
204
204
  const block = await this.blocks.get(blockNumber)!;
@@ -229,12 +229,24 @@ export class TxInclusionMetrics {
229
229
  p99: number;
230
230
  } {
231
231
  const histogram = createHistogram({});
232
+ let nonPositive = 0;
232
233
  for (const tx of this.data.values()) {
233
234
  if (!tx.blocknumber || tx.group !== group || tx.minedAt === -1) {
234
235
  continue;
235
236
  }
236
237
 
237
- histogram.record(tx.minedAt - tx.sentAt);
238
+ // `minedAt` is the block's L2 slot timestamp (seconds) while `sentAt` is the wall-clock
239
+ // send time. Because the slot timestamp can precede or equal the send time, the delta
240
+ // can be <= 0, which perf_hooks.createHistogram rejects. Skip those instead of crashing.
241
+ const delta = tx.minedAt - tx.sentAt;
242
+ if (delta <= 0) {
243
+ nonPositive++;
244
+ continue;
245
+ }
246
+ histogram.record(delta);
247
+ }
248
+ if (nonPositive > 0) {
249
+ this.logger?.debug(`Dropped ${nonPositive} tx inclusion samples with non-positive delta`, { group });
238
250
  }
239
251
 
240
252
  if (histogram.count === 0) {
@@ -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,7 +15,9 @@ 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
23
  import type { NotesFilter } from '@aztec/pxe/client/lazy';
@@ -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, SimulationOverrides, 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
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,53 +91,81 @@ 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);
112
+ });
103
113
  }
104
114
 
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}`);
115
+ /**
116
+ * Builds contract overrides for all provided addresses by replacing their account contracts with stub implementations.
117
+ */
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
+ };
114
147
  }
115
- const stubAccount = createStubAccount(originalAddress);
116
- const instance = await getContractInstanceFromInstantiationParams(StubAccountContractArtifact, {
117
- salt: Fr.random(),
118
- });
119
- return {
120
- account: stubAccount,
121
- instance,
122
- artifact: StubAccountContractArtifact,
123
- };
148
+
149
+ return contracts;
150
+ }
151
+
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);
124
168
  }
125
- protected accounts: Map<string, Account> = new Map();
126
169
 
127
170
  /**
128
171
  * Controls how the test wallet simulates transactions:
@@ -137,31 +180,29 @@ export class TestWallet extends BaseWallet {
137
180
  }
138
181
 
139
182
  setMinFeePadding(value?: number) {
140
- this.minFeePadding = value ?? 0.5;
183
+ this.minFeePadding = value ?? DEFAULT_MIN_FEE_PADDING;
141
184
  }
142
185
 
143
186
  protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
144
- let account: Account | undefined;
145
- if (address.equals(AztecAddress.ZERO)) {
146
- account = new SignerlessAccount();
147
- } else {
148
- account = this.accounts.get(address?.toString() ?? '');
149
- }
187
+ const entry = this.accounts.get(address?.toString() ?? '');
150
188
 
151
- if (!account) {
189
+ if (!entry) {
152
190
  throw new Error(`Account not found in wallet for address: ${address}`);
153
191
  }
154
192
 
155
- return Promise.resolve(account);
193
+ return Promise.resolve(entry.account);
156
194
  }
157
195
 
158
196
  getAccounts() {
159
- 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
+ );
160
200
  }
161
201
 
162
202
  async createAccount(accountData?: AccountData): Promise<AccountManager> {
163
203
  const secret = accountData?.secret ?? Fr.random();
164
204
  const salt = accountData?.salt ?? Fr.random();
205
+ const type = accountData?.type ?? 'schnorr';
165
206
  const contract = accountData?.contract ?? new SchnorrAccountContract(GrumpkinScalar.random());
166
207
 
167
208
  const accountManager = await AccountManager.create(this, secret, contract, salt);
@@ -171,7 +212,8 @@ export class TestWallet extends BaseWallet {
171
212
 
172
213
  await this.registerContract(instance, artifact, secret);
173
214
 
174
- 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 });
175
217
 
176
218
  return accountManager;
177
219
  }
@@ -217,53 +259,74 @@ export class TestWallet extends BaseWallet {
217
259
  protected override async simulateViaEntrypoint(
218
260
  executionPayload: ExecutionPayload,
219
261
  opts: SimulateViaEntrypointOptions,
220
- ): Promise<TxSimulationResult> {
221
- const { from, feeOptions, scopes, skipTxValidation, skipFeeEnforcement } = opts;
262
+ ): Promise<TxSimulationResultWithAppOffset> {
263
+ const { from, feeOptions, additionalScopes, skipTxValidation, skipFeeEnforcement, sendMessagesAs } = opts;
264
+ const scopes = this.scopesFrom(from, additionalScopes);
222
265
  const skipKernels = this.simulationMode !== 'full';
223
- const useOverride = this.simulationMode === 'kernelless-override' && !from.equals(AztecAddress.ZERO);
224
-
225
- let overrides: SimulationOverrides | undefined;
226
- let fromAccount: Account;
227
- if (useOverride) {
228
- const { account, instance, artifact } = await this.getFakeAccountDataFor(from);
229
- fromAccount = account;
230
- overrides = {
231
- contracts: { [from.toString()]: { instance, artifact } },
232
- };
233
- } else {
234
- fromAccount = await this.getAccountFromAddress(from);
235
- }
266
+ const useOverride = this.simulationMode === 'kernelless-override';
236
267
 
237
268
  const feeExecutionPayload = await feeOptions.walletFeePaymentMethod?.getExecutionPayload();
238
- const executionOptions: DefaultAccountEntrypointOptions = {
239
- txNonce: Fr.random(),
240
- cancellable: this.cancellableTransactions,
241
- feePaymentMethodOptions: feeOptions.accountFeePaymentMethodOptions,
242
- };
243
269
  const finalExecutionPayload = feeExecutionPayload
244
270
  ? mergeExecutionPayloads([feeExecutionPayload, executionPayload])
245
271
  : executionPayload;
246
272
  const chainInfo = await this.getChainInfo();
247
- const txRequest = await fromAccount.createTxExecutionRequest(
248
- finalExecutionPayload,
249
- feeOptions.gasSettings,
250
- chainInfo,
251
- executionOptions,
252
- );
253
- 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, {
254
307
  simulatePublic: true,
255
308
  skipKernels,
256
309
  skipFeeEnforcement,
257
310
  skipTxValidation,
258
311
  overrides,
259
312
  scopes,
313
+ senderForTags: this.senderForTagsFrom(from, sendMessagesAs),
260
314
  });
315
+ const appCallOffset = await this.computeAppCallOffset(from, feeOptions);
316
+ return TxSimulationResultWithAppOffset.fromResultAndOffset(result, appCallOffset);
261
317
  }
262
318
 
263
319
  async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
264
- 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
+ });
265
325
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
266
- 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
+ });
267
330
  return new ProvenTx(
268
331
  this.aztecNode,
269
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