@aztec/end-to-end 0.0.1-commit.6d63667d → 0.0.1-commit.858058eac

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 (79) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +2 -2
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +1 -1
  4. package/dest/bench/client_flows/config.d.ts +2 -2
  5. package/dest/bench/client_flows/config.d.ts.map +1 -1
  6. package/dest/bench/client_flows/config.js +18 -0
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +2 -2
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  9. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +2 -2
  10. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  11. package/dest/e2e_deploy_contract/deploy_test.d.ts +2 -2
  12. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  13. package/dest/e2e_epochs/epochs_test.d.ts +1 -1
  14. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  15. package/dest/e2e_epochs/epochs_test.js +9 -3
  16. package/dest/e2e_fees/fees_test.d.ts +2 -2
  17. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  18. package/dest/e2e_p2p/p2p_network.d.ts +2 -2
  19. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  20. package/dest/e2e_p2p/shared.d.ts +2 -2
  21. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  22. package/dest/e2e_p2p/shared.js +5 -1
  23. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts +2 -0
  24. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.d.ts.map +1 -0
  25. package/dest/e2e_storage_proof/fixtures/storage_proof_fetcher.js +184 -0
  26. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts +18 -0
  27. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.d.ts.map +1 -0
  28. package/dest/e2e_storage_proof/fixtures/storage_proof_fixture.js +120 -0
  29. package/dest/e2e_token_contract/token_contract_test.d.ts +2 -2
  30. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  31. package/dest/fixtures/e2e_prover_test.d.ts +2 -2
  32. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  33. package/dest/fixtures/setup.d.ts +14 -14
  34. package/dest/fixtures/setup.d.ts.map +1 -1
  35. package/dest/fixtures/setup.js +12 -76
  36. package/dest/fixtures/setup_p2p_test.d.ts +10 -5
  37. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  38. package/dest/fixtures/setup_p2p_test.js +6 -3
  39. package/dest/shared/submit-transactions.d.ts +2 -2
  40. package/dest/shared/submit-transactions.d.ts.map +1 -1
  41. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  42. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  43. package/dest/shared/uniswap_l1_l2.js +1 -1
  44. package/dest/spartan/setup_test_wallets.d.ts +2 -2
  45. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  46. package/dest/spartan/setup_test_wallets.js +3 -1
  47. package/dest/test-wallet/test_wallet.d.ts +82 -0
  48. package/dest/test-wallet/test_wallet.d.ts.map +1 -0
  49. package/dest/test-wallet/test_wallet.js +213 -0
  50. package/dest/test-wallet/utils.d.ts +41 -0
  51. package/dest/test-wallet/utils.d.ts.map +1 -0
  52. package/dest/test-wallet/utils.js +71 -0
  53. package/package.json +40 -39
  54. package/src/bench/client_flows/client_flows_benchmark.ts +6 -6
  55. package/src/bench/client_flows/config.ts +9 -1
  56. package/src/bench/utils.ts +1 -1
  57. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +2 -2
  58. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +4 -4
  59. package/src/e2e_deploy_contract/deploy_test.ts +3 -3
  60. package/src/e2e_epochs/epochs_test.ts +13 -3
  61. package/src/e2e_fees/bridging_race.notest.ts +1 -1
  62. package/src/e2e_fees/fees_test.ts +7 -7
  63. package/src/e2e_nested_contract/nested_contract_test.ts +1 -1
  64. package/src/e2e_p2p/inactivity_slash_test.ts +4 -4
  65. package/src/e2e_p2p/p2p_network.ts +5 -5
  66. package/src/e2e_p2p/reqresp/utils.ts +4 -4
  67. package/src/e2e_p2p/shared.ts +3 -1
  68. package/src/e2e_storage_proof/fixtures/storage_proof.json +915 -0
  69. package/src/e2e_storage_proof/fixtures/storage_proof_fetcher.ts +190 -0
  70. package/src/e2e_storage_proof/fixtures/storage_proof_fixture.ts +173 -0
  71. package/src/e2e_token_contract/token_contract_test.ts +2 -2
  72. package/src/fixtures/e2e_prover_test.ts +4 -4
  73. package/src/fixtures/setup.ts +22 -106
  74. package/src/fixtures/setup_p2p_test.ts +16 -7
  75. package/src/shared/submit-transactions.ts +2 -1
  76. package/src/shared/uniswap_l1_l2.ts +2 -2
  77. package/src/spartan/setup_test_wallets.ts +3 -1
  78. package/src/test-wallet/test_wallet.ts +296 -0
  79. package/src/test-wallet/utils.ts +112 -0
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Fetches a ERC20 balance storage proof from the Ethereum mainnet and saves it to a Prover.toml compatible JSON.
3
+ * The JSON can be converted to toml for use with nargo, or used directly as a JSON file when used in
4
+ * Aztec contracts. This script is not using any Aztec library code, so it's easily portable.
5
+ */
6
+ import fs from 'fs';
7
+ import { dirname, join } from 'path';
8
+ import { fileURLToPath } from 'url';
9
+ import { createPublicClient, encodeAbiParameters, fromRlp, hexToBytes, http, keccak256 } from 'viem';
10
+ import { mainnet } from 'viem/chains';
11
+
12
+ const __dirname = dirname(fileURLToPath(import.meta.url));
13
+
14
+ const RPC_URL = process.env.RPC_URL;
15
+ const ERC20_CONTRACT = (process.env.ERC20_CONTRACT || '0xdAC17F958D2ee523a2206206994597C13D831ec7') as `0x${string}`;
16
+ const HOLDER = (process.env.HOLDER || '0x23878914EFE38d27C4D67Ab83ed1b93A74D4086a') as `0x${string}`;
17
+ const SLOT = BigInt(process.env.SLOT || '2');
18
+ const BLOCK_TAG = process.env.BLOCK_NUMBER ? BigInt(process.env.BLOCK_NUMBER) : 'latest';
19
+ const MAX_ACCOUNT_PATH = 15;
20
+ const MAX_STORAGE_PATH = 10;
21
+
22
+ function padTo(arr: number[], len: number) {
23
+ return [...arr, ...Array(len - arr.length).fill(0)].slice(0, len);
24
+ }
25
+
26
+ function toBytes(hex: `0x${string}`) {
27
+ return Array.from(hexToBytes(hex));
28
+ }
29
+
30
+ function bytesToU64s(bytes: number[]) {
31
+ const paddedBytes = padTo(bytes, 32);
32
+ return Array.from({ length: 4 }, (_, i) => {
33
+ let val = 0n;
34
+ for (let j = 0; j < 8; j++) {
35
+ val += BigInt(paddedBytes[i * 8 + j]) << BigInt(j * 8);
36
+ }
37
+ return val.toString();
38
+ });
39
+ }
40
+
41
+ function toBytesAndLen(val: bigint | number) {
42
+ if (val === 0n || val === 0) {
43
+ return { bytes: [0], length: 0 };
44
+ }
45
+ let hex = val.toString(16);
46
+ if (hex.length % 2) {
47
+ hex = '0' + hex;
48
+ }
49
+ const bytes = toBytes(`0x${hex}`);
50
+ return { bytes, length: bytes.length };
51
+ }
52
+
53
+ function parseNode(rlp: `0x${string}`) {
54
+ // Should be safe when working with branches and extensions without embedded children.
55
+ const decoded = fromRlp(rlp) as `0x${string}`[];
56
+ const node = {
57
+ rows: Array(16)
58
+ .fill(0)
59
+ .map(() => Array(32).fill(0)),
60
+ row_exist: Array(16).fill(false),
61
+ node_type: 0,
62
+ };
63
+
64
+ if (decoded.length === 17) {
65
+ for (let i = 0; i < 16; i++) {
66
+ if (decoded[i] !== '0x') {
67
+ node.row_exist[i] = true;
68
+ node.rows[i] = padTo(toBytes(decoded[i]), 32);
69
+ }
70
+ }
71
+ } else if (decoded.length === 2) {
72
+ const keyBytes = toBytes(decoded[0]);
73
+ const prefix = keyBytes[0];
74
+ if (prefix >> 4 >= 2) {
75
+ throw new Error('Unsupported: leaf node in proof path');
76
+ }
77
+ node.node_type = 1;
78
+ // Extension header format expected by the noir code: check out storage_proof types.nr.
79
+ node.rows[0][0] = prefix >> 4;
80
+ node.rows[0][8] = prefix & 0x0f;
81
+ node.rows[0][16] = keyBytes.length - 1;
82
+
83
+ for (let i = 1; i < keyBytes.length && i < 32; i++) {
84
+ node.rows[1][i - 1] = keyBytes[i];
85
+ }
86
+ node.rows[2] = padTo(toBytes(decoded[1]), 32);
87
+ node.row_exist[0] = node.row_exist[1] = node.row_exist[2] = true;
88
+ }
89
+ return node;
90
+ }
91
+
92
+ function parseProof(proof: `0x${string}`[], maxLen: number) {
93
+ const nodes = proof.slice(0, -1).slice(0, maxLen).map(parseNode);
94
+ while (nodes.length < maxLen) {
95
+ nodes.push({
96
+ rows: Array(16)
97
+ .fill(0)
98
+ .map(() => Array(32).fill(0)),
99
+ row_exist: Array(16).fill(false),
100
+ node_type: 0,
101
+ });
102
+ }
103
+ return nodes;
104
+ }
105
+
106
+ function nodeToLibFormat(node: { rows: number[][]; row_exist: boolean[]; node_type: number }) {
107
+ return {
108
+ rows: node.rows.map(bytesToU64s),
109
+ row_exist: node.row_exist,
110
+ node_type: String(node.node_type),
111
+ };
112
+ }
113
+
114
+ async function main() {
115
+ if (!RPC_URL) {
116
+ throw new Error('RPC_URL is not set');
117
+ }
118
+ const storageKey = keccak256(encodeAbiParameters([{ type: 'address' }, { type: 'uint256' }], [HOLDER, SLOT]));
119
+ console.log(`Fetching storage proof for ${ERC20_CONTRACT}, holder ${HOLDER}, slot ${SLOT}`);
120
+ console.log(`Storage key: ${storageKey}`);
121
+
122
+ const client = createPublicClient({
123
+ chain: mainnet,
124
+ transport: http(RPC_URL),
125
+ });
126
+
127
+ const [blockNumber, proof, block] = await Promise.all([
128
+ client.getBlockNumber(),
129
+ client.getProof({
130
+ address: ERC20_CONTRACT,
131
+ storageKeys: [storageKey],
132
+ blockNumber: BLOCK_TAG === 'latest' ? undefined : BLOCK_TAG,
133
+ }),
134
+ client.getBlock({
135
+ blockNumber: BLOCK_TAG === 'latest' ? undefined : BLOCK_TAG,
136
+ }),
137
+ ]);
138
+
139
+ const storageProof = proof.storageProof[0];
140
+ console.log(
141
+ `Block: ${blockNumber}, Account nodes: ${proof.accountProof.length}, Storage nodes: ${storageProof.proof.length}`,
142
+ );
143
+ console.log(`Value: ${storageProof.value}`);
144
+
145
+ // The -1 is because the last node in the proof is the leaf, which is excluded from path verification.
146
+ const accountPathLen = proof.accountProof.length - 1;
147
+ const storagePathLen = storageProof.proof.length - 1;
148
+ if (accountPathLen > MAX_ACCOUNT_PATH) {
149
+ throw new Error(
150
+ `Account proof path length ${accountPathLen} exceeds MAX_ACCOUNT_PATH ${MAX_ACCOUNT_PATH}. Increase the limit.`,
151
+ );
152
+ }
153
+ if (storagePathLen > MAX_STORAGE_PATH) {
154
+ throw new Error(
155
+ `Storage proof path length ${storagePathLen} exceeds MAX_STORAGE_PATH ${MAX_STORAGE_PATH}. Increase the limit.`,
156
+ );
157
+ }
158
+
159
+ const nonce = toBytesAndLen(proof.nonce);
160
+ const balance = toBytesAndLen(proof.balance);
161
+ const slotValue = toBytesAndLen(storageProof.value);
162
+
163
+ const data = {
164
+ account_nodes: parseProof(proof.accountProof, MAX_ACCOUNT_PATH).map(nodeToLibFormat),
165
+ account_node_length: String(accountPathLen),
166
+ storage_nodes: parseProof(storageProof.proof, MAX_STORAGE_PATH).map(nodeToLibFormat),
167
+ storage_node_length: String(storagePathLen),
168
+ account: {
169
+ nonce: padTo(nonce.bytes, 8).map(String),
170
+ nonce_length: String(nonce.length),
171
+ balance: padTo(balance.bytes, 32).map(String),
172
+ balance_length: String(balance.length),
173
+ address: toBytes(ERC20_CONTRACT).map(String),
174
+ storage_hash: bytesToU64s(toBytes(proof.storageHash)),
175
+ code_hash: bytesToU64s(toBytes(proof.codeHash)),
176
+ },
177
+ slot: {
178
+ value: padTo(slotValue.bytes, 32).map(String),
179
+ value_length: String(slotValue.length),
180
+ },
181
+ slot_key: toBytes(storageKey).map(String),
182
+ root: bytesToU64s(toBytes(block.stateRoot)),
183
+ block_number: String(blockNumber),
184
+ };
185
+
186
+ fs.writeFileSync(join(__dirname, 'storage_proof.json'), JSON.stringify(data, null, 2));
187
+ console.log('storage_proof.json generated');
188
+ }
189
+
190
+ main().catch(console.error);
@@ -0,0 +1,173 @@
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { EthAddress } from '@aztec/foundation/eth-address';
5
+ import { Capsule } from '@aztec/stdlib/tx';
6
+
7
+ import { readFileSync } from 'fs';
8
+ import { dirname, join } from 'path';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
+ const FIXTURE_PATH = join(__dirname, './storage_proof.json');
13
+
14
+ // Constants matching the Noir contract
15
+ const ACCOUNT_CAPSULE_KEY_SEPARATOR = 100;
16
+ const ACCOUNT_PROOF_CAPSULE_KEY_SEPARATOR = 101;
17
+ const STORAGE_PROOF_CAPSULE_KEY_SEPARATOR = 102;
18
+ const STORAGE_PROOF_NODE_CAPSULE_KEY_SEPARATOR = 103;
19
+ const MAX_ACCOUNT_PROOF_LENGTH = 15;
20
+ /** Node: rows [[u64;4];16] (64) + row_exist [bool;16] (16) + node_type u8 (1) = 81 fields */
21
+ const NODE_FIELD_COUNT = 81;
22
+
23
+ // --- JSON fixture types ---
24
+
25
+ type JsonNode = { rows: string[][]; row_exist: boolean[]; node_type: string };
26
+
27
+ type JsonAccount = {
28
+ nonce: string[];
29
+ balance: string[];
30
+ address: string[];
31
+ nonce_length: string;
32
+ balance_length: string;
33
+ storage_hash: string[];
34
+ code_hash: string[];
35
+ };
36
+
37
+ type StorageProofJSON = {
38
+ root: string[];
39
+ slot_key: string[];
40
+ account_node_length: string;
41
+ storage_node_length: string;
42
+ account_nodes: JsonNode[];
43
+ storage_nodes: JsonNode[];
44
+ account: JsonAccount;
45
+ slot: { value: string[]; value_length: string };
46
+ };
47
+
48
+ // --- Serialization helpers (Noir struct Serialize layout) ---
49
+
50
+ function serializeNode(node: JsonNode): Fr[] {
51
+ const fields: Fr[] = [];
52
+ for (const row of node.rows) {
53
+ for (const val of row) {
54
+ fields.push(new Fr(BigInt(val)));
55
+ }
56
+ }
57
+ for (const exists of node.row_exist) {
58
+ fields.push(new Fr(exists ? 1n : 0n));
59
+ }
60
+ fields.push(new Fr(BigInt(node.node_type)));
61
+ return fields;
62
+ }
63
+
64
+ /** Account: nonce [u8;8] + balance [u8;32] + address [u8;20] + nonce_length u8 + balance_length u8 + storage_hash [u64;4] + code_hash [u64;4] = 70 fields */
65
+ function serializeAccount(account: JsonAccount): Fr[] {
66
+ const fields: Fr[] = [];
67
+ for (const v of account.nonce) {
68
+ fields.push(new Fr(BigInt(v)));
69
+ }
70
+ for (const v of account.balance) {
71
+ fields.push(new Fr(BigInt(v)));
72
+ }
73
+ for (const v of account.address) {
74
+ fields.push(new Fr(BigInt(v)));
75
+ }
76
+ fields.push(new Fr(BigInt(account.nonce_length)));
77
+ fields.push(new Fr(BigInt(account.balance_length)));
78
+ for (const v of account.storage_hash) {
79
+ fields.push(new Fr(BigInt(v)));
80
+ }
81
+ for (const v of account.code_hash) {
82
+ fields.push(new Fr(BigInt(v)));
83
+ }
84
+ return fields;
85
+ }
86
+
87
+ function zeroNode(): Fr[] {
88
+ return Array(NODE_FIELD_COUNT).fill(Fr.ZERO);
89
+ }
90
+
91
+ // --- Public API ---
92
+
93
+ /** Parsed + typed fixture data ready for use as contract function arguments. */
94
+ export type StorageProofArgs = {
95
+ ethAddress: EthAddress;
96
+ slotKey: number[];
97
+ slotContents: { value: number[]; value_length: number };
98
+ root: bigint[];
99
+ };
100
+
101
+ /** Loads the storage proof fixture from disk and returns the contract args. */
102
+ export function loadStorageProofArgs(): StorageProofArgs {
103
+ const fixture: StorageProofJSON = JSON.parse(readFileSync(FIXTURE_PATH, 'utf8'));
104
+ const addressBytes = Buffer.from(fixture.account.address.map(v => Number(v)));
105
+ return {
106
+ ethAddress: EthAddress.fromString('0x' + addressBytes.toString('hex')),
107
+ slotKey: fixture.slot_key.map(v => Number(v)),
108
+ slotContents: {
109
+ value: fixture.slot.value.map(v => Number(v)),
110
+ // eslint-disable-next-line camelcase
111
+ value_length: Number(fixture.slot.value_length),
112
+ },
113
+ root: fixture.root.map(v => BigInt(v)),
114
+ };
115
+ }
116
+
117
+ /** Builds all the capsules the StorageProofTest contract expects during private execution. */
118
+ export async function buildStorageProofCapsules(contractAddress: AztecAddress): Promise<Capsule[]> {
119
+ const fixture: StorageProofJSON = JSON.parse(readFileSync(FIXTURE_PATH, 'utf8'));
120
+
121
+ const root = fixture.root.map(v => BigInt(v));
122
+ const slotKey = fixture.slot_key.map(v => Number(v));
123
+ const accountNodeLength = Number(fixture.account_node_length);
124
+ const storageNodeLength = Number(fixture.storage_node_length);
125
+ const ethAddress = EthAddress.fromBuffer(Buffer.from(fixture.account.address.map(v => Number(v))));
126
+
127
+ // Compute capsule keys (must match the Noir contract's poseidon2_hash computations)
128
+ const addressCapsuleKey = await poseidon2Hash([
129
+ new Fr(ACCOUNT_CAPSULE_KEY_SEPARATOR),
130
+ ...root.map(v => new Fr(v)),
131
+ ethAddress.toField(),
132
+ ]);
133
+
134
+ const accountProofCapsuleKey = await poseidon2Hash([new Fr(ACCOUNT_PROOF_CAPSULE_KEY_SEPARATOR), addressCapsuleKey]);
135
+
136
+ const storageProofCapsuleKey = await poseidon2Hash([
137
+ new Fr(STORAGE_PROOF_CAPSULE_KEY_SEPARATOR),
138
+ addressCapsuleKey,
139
+ ...slotKey.map(v => new Fr(v)),
140
+ ]);
141
+
142
+ // Build capsule data
143
+
144
+ // 1. Account data
145
+ const accountData = serializeAccount(fixture.account);
146
+
147
+ // 2. Account proof nodes padded to MAX_ACCOUNT_PROOF_LENGTH
148
+ const accountProofData: Fr[] = [new Fr(accountNodeLength)];
149
+ for (let i = 0; i < MAX_ACCOUNT_PROOF_LENGTH; i++) {
150
+ accountProofData.push(...(i < fixture.account_nodes.length ? serializeNode(fixture.account_nodes[i]) : zeroNode()));
151
+ }
152
+
153
+ // 3. Storage proof length (u32)
154
+ const storageProofLengthData = [new Fr(storageNodeLength)];
155
+
156
+ const capsules: Capsule[] = [
157
+ new Capsule(contractAddress, addressCapsuleKey, accountData),
158
+ new Capsule(contractAddress, accountProofCapsuleKey, accountProofData),
159
+ new Capsule(contractAddress, storageProofCapsuleKey, storageProofLengthData),
160
+ ];
161
+
162
+ // 4. Individual storage node capsules for private recursion.
163
+ for (let i = 0; i < storageNodeLength; i++) {
164
+ const nodeCapsuleKey = await poseidon2Hash([
165
+ new Fr(STORAGE_PROOF_NODE_CAPSULE_KEY_SEPARATOR),
166
+ storageProofCapsuleKey,
167
+ new Fr(i),
168
+ ]);
169
+ capsules.push(new Capsule(contractAddress, nodeCapsuleKey, serializeNode(fixture.storage_nodes[i])));
170
+ }
171
+
172
+ return capsules;
173
+ }
@@ -3,13 +3,13 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
3
3
  import type { AztecNode } from '@aztec/aztec.js/node';
4
4
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
5
5
  import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
6
- import type { TestWallet } from '@aztec/test-wallet/server';
7
6
 
8
7
  import { jest } from '@jest/globals';
9
8
 
10
9
  import { type EndToEndContext, deployAccounts, publicDeployAccounts, setup, teardown } from '../fixtures/setup.js';
11
10
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
12
11
  import { TokenSimulator } from '../simulators/token_simulator.js';
12
+ import type { TestWallet } from '../test-wallet/test_wallet.js';
13
13
 
14
14
  const { METRICS_PORT: metricsPort } = process.env;
15
15
 
@@ -70,7 +70,7 @@ export class TokenContractTest {
70
70
  initialFundedAccounts: this.context.initialFundedAccounts,
71
71
  });
72
72
 
73
- this.node = this.context.aztecNodeService!;
73
+ this.node = this.context.aztecNodeService;
74
74
  this.wallet = this.context.wallet;
75
75
  [this.adminAddress, this.account1Address, this.account2Address] = deployedAccounts.map(acc => acc.address);
76
76
 
@@ -20,13 +20,13 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
20
20
  import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
21
21
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
22
22
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
23
- import { TestWallet } from '@aztec/test-wallet/server';
24
23
  import { getGenesisValues } from '@aztec/world-state/testing';
25
24
 
26
25
  import { type Hex, getContract } from 'viem';
27
26
  import { privateKeyToAddress } from 'viem/accounts';
28
27
 
29
28
  import { TokenSimulator } from '../simulators/token_simulator.js';
29
+ import { TestWallet } from '../test-wallet/test_wallet.js';
30
30
  import { getACVMConfig } from './get_acvm_config.js';
31
31
  import { getBBConfig } from './get_bb_config.js';
32
32
  import {
@@ -144,7 +144,7 @@ export class FullProverTest {
144
144
  this.logger.info(`Enabling proving`, { realProofs: this.realProofs });
145
145
 
146
146
  // We don't wish to mark as proven automatically, so we set the flag to false
147
- this.context.watcher!.setIsMarkingAsProven(false);
147
+ this.context.watcher.setIsMarkingAsProven(false);
148
148
 
149
149
  this.simulatedProverNode = this.context.proverNode!;
150
150
  ({
@@ -152,7 +152,7 @@ export class FullProverTest {
152
152
  deployL1ContractsValues: this.l1Contracts,
153
153
  cheatCodes: this.cheatCodes,
154
154
  } = this.context);
155
- this.aztecNodeAdmin = this.context.aztecNodeService!;
155
+ this.aztecNodeAdmin = this.context.aztecNodeService;
156
156
 
157
157
  const config = this.context.aztecNodeConfig;
158
158
  const blobClient = await createBlobClientWithFileStores(config, this.logger);
@@ -225,7 +225,7 @@ export class FullProverTest {
225
225
  this.logger.verbose('Starting archiver for new prover node');
226
226
  const archiver = await createArchiver(
227
227
  { ...this.context.aztecNodeConfig, dataDirectory: undefined },
228
- { blobClient, dateProvider: this.context.dateProvider! },
228
+ { blobClient, dateProvider: this.context.dateProvider },
229
229
  { blockUntilSync: true },
230
230
  );
231
231
 
@@ -1,5 +1,5 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import { type InitialAccountData, generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
2
+ import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
3
  import { type Archiver, createArchiver } from '@aztec/archiver';
4
4
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
5
5
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
@@ -13,7 +13,7 @@ import {
13
13
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
14
14
  import { Fr } from '@aztec/aztec.js/fields';
15
15
  import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
- import { type AztecNode, createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
16
+ import type { AztecNode } from '@aztec/aztec.js/node';
17
17
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
18
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
19
  import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
@@ -67,7 +67,7 @@ import {
67
67
  initTelemetryClient,
68
68
  } from '@aztec/telemetry-client';
69
69
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
- import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
70
+ import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
71
71
  import { getGenesisValues } from '@aztec/world-state/testing';
72
72
 
73
73
  import type { Anvil } from '@viem/anvil';
@@ -84,6 +84,7 @@ import {
84
84
  } from 'viem/accounts';
85
85
  import { type Chain, foundry } from 'viem/chains';
86
86
 
87
+ import { TestWallet } from '../test-wallet/test_wallet.js';
87
88
  import { MNEMONIC, TEST_MAX_PENDING_TX_POOL_COUNT, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
88
89
  import { getACVMConfig } from './get_acvm_config.js';
89
90
  import { getBBConfig } from './get_bb_config.js';
@@ -92,9 +93,6 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
92
93
 
93
94
  export { startAnvil };
94
95
 
95
- const { AZTEC_NODE_URL = '' } = process.env;
96
- const getAztecUrl = () => AZTEC_NODE_URL;
97
-
98
96
  let telemetry: TelemetryClient | undefined = undefined;
99
97
  async function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
100
98
  if (!telemetry) {
@@ -217,13 +215,13 @@ export type EndToEndContext = {
217
215
  anvil: Anvil | undefined;
218
216
  /** The Aztec Node service or client a connected to it. */
219
217
  aztecNode: AztecNode;
220
- /** The Aztec Node as a service (only set if running locally). */
221
- aztecNodeService: AztecNodeService | undefined;
222
- /** Client to the Aztec Node admin interface (undefined if connected to remote environment) */
223
- aztecNodeAdmin: AztecNodeAdmin | undefined;
218
+ /** The Aztec Node as a service. */
219
+ aztecNodeService: AztecNodeService;
220
+ /** Client to the Aztec Node admin interface. */
221
+ aztecNodeAdmin: AztecNodeAdmin;
224
222
  /** The prover node service (only set if startProverNode is true) */
225
223
  proverNode: ProverNode | undefined;
226
- /** A client to the sequencer service (undefined if connected to remote environment) */
224
+ /** A client to the sequencer service. */
227
225
  sequencer: SequencerClient | undefined;
228
226
  /** Return values from deployAztecL1Contracts function. */
229
227
  deployL1ContractsValues: DeployAztecL1ContractsReturnType;
@@ -243,12 +241,12 @@ export type EndToEndContext = {
243
241
  cheatCodes: CheatCodes;
244
242
  /** The cheat codes for L1 */
245
243
  ethCheatCodes: EthCheatCodes;
246
- /** The anvil test watcher (undefined if connected to remote environment) */
247
- watcher: AnvilTestWatcher | undefined;
248
- /** Allows tweaking current system time, used by the epoch cache only (undefined if connected to remote environment) */
249
- dateProvider: TestDateProvider | undefined;
244
+ /** The anvil test watcher. */
245
+ watcher: AnvilTestWatcher;
246
+ /** Allows tweaking current system time, used by the epoch cache only. */
247
+ dateProvider: TestDateProvider;
250
248
  /** Telemetry client */
251
- telemetryClient: TelemetryClient | undefined;
249
+ telemetryClient: TelemetryClient;
252
250
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
253
251
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
254
252
  /** Prefilled public data used for setting up nodes. */
@@ -258,87 +256,11 @@ export type EndToEndContext = {
258
256
  /** BB config (only set if running locally). */
259
257
  bbConfig: Awaited<ReturnType<typeof getBBConfig>>;
260
258
  /** Directory to cleanup on teardown. */
261
- directoryToCleanup: string | undefined;
259
+ directoryToCleanup: string;
262
260
  /** Function to stop the started services. */
263
261
  teardown: () => Promise<void>;
264
262
  };
265
263
 
266
- /**
267
- * Function to setup the test against a remote deployment. It is assumed that L1 contract are already deployed
268
- */
269
- async function setupWithRemoteEnvironment(
270
- account: HDAccount | PrivateKeyAccount,
271
- config: AztecNodeConfig & SetupOptions,
272
- logger: Logger,
273
- numberOfAccounts: number,
274
- ): Promise<EndToEndContext> {
275
- const aztecNodeUrl = getAztecUrl();
276
- logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
277
- const aztecNode = createAztecNodeClient(aztecNodeUrl);
278
- await waitForNode(aztecNode, logger);
279
- logger.verbose('JSON RPC client connected to Aztec Node');
280
- logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
281
- const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
282
-
283
- const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
284
-
285
- const deployL1ContractsValues: DeployAztecL1ContractsReturnType = {
286
- l1ContractAddresses,
287
- l1Client,
288
- rollupVersion,
289
- };
290
- const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
291
- const wallet = await TestWallet.create(aztecNode);
292
-
293
- if (config.walletMinFeePadding !== undefined) {
294
- wallet.setMinFeePadding(config.walletMinFeePadding);
295
- }
296
-
297
- const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
298
- const teardown = () => Promise.resolve();
299
-
300
- logger.verbose('Populating wallet from already registered accounts...');
301
- const initialFundedAccounts = await getInitialTestAccountsData();
302
-
303
- if (initialFundedAccounts.length < numberOfAccounts) {
304
- throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
305
- }
306
-
307
- const testAccounts = await Promise.all(
308
- initialFundedAccounts.slice(0, numberOfAccounts).map(async account => {
309
- const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
310
- return accountManager.address;
311
- }),
312
- );
313
-
314
- return {
315
- anvil: undefined,
316
- aztecNode,
317
- aztecNodeService: undefined,
318
- aztecNodeAdmin: undefined,
319
- sequencer: undefined,
320
- proverNode: undefined,
321
- deployL1ContractsValues,
322
- config,
323
- aztecNodeConfig: config,
324
- initialFundedAccounts,
325
- wallet,
326
- accounts: testAccounts,
327
- logger,
328
- cheatCodes,
329
- ethCheatCodes,
330
- prefilledPublicData: undefined,
331
- mockGossipSubNetwork: undefined,
332
- watcher: undefined,
333
- dateProvider: undefined,
334
- telemetryClient: undefined,
335
- acvmConfig: undefined,
336
- bbConfig: undefined,
337
- directoryToCleanup: undefined,
338
- teardown,
339
- };
340
- }
341
-
342
264
  /**
343
265
  * Sets up the environment for the end-to-end tests.
344
266
  * @param numberOfAccounts - The number of new accounts to be created once the PXE is initiated.
@@ -381,12 +303,6 @@ export async function setup(
381
303
  if (!isAnvilTestChain(chain.id)) {
382
304
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
383
305
  }
384
- if (AZTEC_NODE_URL) {
385
- throw new Error(
386
- `AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
387
- );
388
- }
389
-
390
306
  const res = await startAnvil({
391
307
  l1BlockTime: opts.ethereumSlotDuration,
392
308
  accounts: opts.anvilAccounts,
@@ -441,11 +357,6 @@ export async function setup(
441
357
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
442
358
  }
443
359
 
444
- if (AZTEC_NODE_URL) {
445
- // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
446
- return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
447
- }
448
-
449
360
  // Determine which addresses to fund in genesis
450
361
  const initialFundedAccounts =
451
362
  opts.initialFundedAccounts ??
@@ -595,7 +506,7 @@ export async function setup(
595
506
  const proverNodeConfig = {
596
507
  ...config.proverNodeConfig,
597
508
  dataDirectory: proverNodeDataDirectory,
598
- p2pEnabled: false,
509
+ p2pEnabled: !!mockGossipSubNetwork,
599
510
  };
600
511
  proverNode = await createAndSyncProverNode(
601
512
  proverNodePrivateKeyHex,
@@ -603,6 +514,11 @@ export async function setup(
603
514
  proverNodeConfig,
604
515
  aztecNodeService,
605
516
  prefilledPublicData,
517
+ {
518
+ p2pClientDeps: mockGossipSubNetwork
519
+ ? { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) }
520
+ : undefined,
521
+ },
606
522
  );
607
523
  }
608
524
 
@@ -683,7 +599,7 @@ export async function setup(
683
599
  logger.error(`Error during e2e test teardown`, err);
684
600
  } finally {
685
601
  try {
686
- await telemetryClient?.stop();
602
+ await telemetryClient.stop();
687
603
  } catch (err) {
688
604
  logger.error(`Error during telemetry client stop`, err);
689
605
  }