@aztec/end-to-end 0.0.0-test.0 → 0.0.1-fake-c83136db25

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 (166) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +61 -0
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/benchmark.js +261 -0
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +73 -0
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  6. package/dest/bench/client_flows/client_flows_benchmark.js +311 -0
  7. package/dest/bench/client_flows/config.d.ts +14 -0
  8. package/dest/bench/client_flows/config.d.ts.map +1 -0
  9. package/dest/bench/client_flows/config.js +106 -0
  10. package/dest/bench/client_flows/data_extractor.d.ts +2 -0
  11. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  12. package/dest/bench/client_flows/data_extractor.js +99 -0
  13. package/dest/bench/utils.d.ts +10 -36
  14. package/dest/bench/utils.d.ts.map +1 -1
  15. package/dest/bench/utils.js +26 -66
  16. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +20 -12
  17. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  18. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +85 -57
  19. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +18 -24
  20. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  21. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +48 -69
  22. package/dest/e2e_deploy_contract/deploy_test.d.ts +14 -6
  23. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  24. package/dest/e2e_deploy_contract/deploy_test.js +13 -19
  25. package/dest/e2e_epochs/epochs_test.d.ts +58 -17
  26. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  27. package/dest/e2e_epochs/epochs_test.js +224 -43
  28. package/dest/e2e_fees/bridging_race.notest.d.ts +2 -0
  29. package/dest/e2e_fees/bridging_race.notest.d.ts.map +1 -0
  30. package/dest/e2e_fees/bridging_race.notest.js +63 -0
  31. package/dest/e2e_fees/fees_test.d.ts +20 -9
  32. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  33. package/dest/e2e_fees/fees_test.js +98 -107
  34. package/dest/e2e_l1_publisher/write_json.d.ts +10 -0
  35. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -0
  36. package/dest/e2e_l1_publisher/write_json.js +57 -0
  37. package/dest/e2e_multi_validator/utils.d.ts +12 -0
  38. package/dest/e2e_multi_validator/utils.d.ts.map +1 -0
  39. package/dest/e2e_multi_validator/utils.js +214 -0
  40. package/dest/e2e_nested_contract/nested_contract_test.d.ts +9 -6
  41. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  42. package/dest/e2e_nested_contract/nested_contract_test.js +22 -19
  43. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  44. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  45. package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
  46. package/dest/e2e_p2p/p2p_network.d.ts +69 -22
  47. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  48. package/dest/e2e_p2p/p2p_network.js +180 -129
  49. package/dest/e2e_p2p/shared.d.ts +41 -5
  50. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  51. package/dest/e2e_p2p/shared.js +163 -19
  52. package/dest/e2e_token_contract/token_contract_test.d.ts +11 -5
  53. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  54. package/dest/e2e_token_contract/token_contract_test.js +50 -26
  55. package/dest/{e2e_prover → fixtures}/e2e_prover_test.d.ts +14 -9
  56. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -0
  57. package/dest/{e2e_prover → fixtures}/e2e_prover_test.js +95 -100
  58. package/dest/fixtures/fixtures.d.ts +5 -6
  59. package/dest/fixtures/fixtures.d.ts.map +1 -1
  60. package/dest/fixtures/fixtures.js +4 -3
  61. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  62. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  63. package/dest/fixtures/get_acvm_config.js +2 -14
  64. package/dest/fixtures/get_bb_config.d.ts +1 -1
  65. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  66. package/dest/fixtures/get_bb_config.js +10 -17
  67. package/dest/fixtures/l1_to_l2_messaging.d.ts +8 -5
  68. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  69. package/dest/fixtures/l1_to_l2_messaging.js +44 -18
  70. package/dest/fixtures/setup_l1_contracts.d.ts +3 -3
  71. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  72. package/dest/fixtures/setup_l1_contracts.js +4 -4
  73. package/dest/fixtures/setup_p2p_test.d.ts +14 -13
  74. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  75. package/dest/fixtures/setup_p2p_test.js +73 -21
  76. package/dest/fixtures/snapshot_manager.d.ts +15 -7
  77. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  78. package/dest/fixtures/snapshot_manager.js +147 -121
  79. package/dest/fixtures/token_utils.d.ts +6 -3
  80. package/dest/fixtures/token_utils.d.ts.map +1 -1
  81. package/dest/fixtures/token_utils.js +23 -10
  82. package/dest/fixtures/utils.d.ts +76 -37
  83. package/dest/fixtures/utils.d.ts.map +1 -1
  84. package/dest/fixtures/utils.js +464 -368
  85. package/dest/fixtures/web3signer.d.ts +5 -0
  86. package/dest/fixtures/web3signer.d.ts.map +1 -0
  87. package/dest/fixtures/web3signer.js +53 -0
  88. package/dest/quality_of_service/alert_checker.d.ts +1 -1
  89. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  90. package/dest/shared/cross_chain_test_harness.d.ts +41 -25
  91. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  92. package/dest/shared/cross_chain_test_harness.js +104 -50
  93. package/dest/shared/gas_portal_test_harness.d.ts +32 -24
  94. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  95. package/dest/shared/gas_portal_test_harness.js +50 -29
  96. package/dest/shared/jest_setup.js +1 -1
  97. package/dest/shared/submit-transactions.d.ts +5 -3
  98. package/dest/shared/submit-transactions.d.ts.map +1 -1
  99. package/dest/shared/submit-transactions.js +8 -7
  100. package/dest/shared/uniswap_l1_l2.d.ts +13 -11
  101. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  102. package/dest/shared/uniswap_l1_l2.js +138 -108
  103. package/dest/simulators/lending_simulator.d.ts +6 -6
  104. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  105. package/dest/simulators/lending_simulator.js +13 -16
  106. package/dest/simulators/token_simulator.d.ts +5 -2
  107. package/dest/simulators/token_simulator.d.ts.map +1 -1
  108. package/dest/simulators/token_simulator.js +16 -13
  109. package/dest/spartan/setup_test_wallets.d.ts +23 -10
  110. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  111. package/dest/spartan/setup_test_wallets.js +167 -58
  112. package/dest/spartan/utils.d.ts +100 -303
  113. package/dest/spartan/utils.d.ts.map +1 -1
  114. package/dest/spartan/utils.js +407 -130
  115. package/package.json +61 -56
  116. package/src/bench/client_flows/benchmark.ts +341 -0
  117. package/src/bench/client_flows/client_flows_benchmark.ts +402 -0
  118. package/src/bench/client_flows/config.ts +61 -0
  119. package/src/bench/client_flows/data_extractor.ts +111 -0
  120. package/src/bench/utils.ts +22 -76
  121. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +80 -77
  122. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +63 -105
  123. package/src/e2e_deploy_contract/deploy_test.ts +23 -38
  124. package/src/e2e_epochs/epochs_test.ts +274 -54
  125. package/src/e2e_fees/bridging_race.notest.ts +80 -0
  126. package/src/e2e_fees/fees_test.ts +137 -136
  127. package/src/e2e_l1_publisher/write_json.ts +76 -0
  128. package/src/e2e_multi_validator/utils.ts +258 -0
  129. package/src/e2e_nested_contract/nested_contract_test.ts +27 -18
  130. package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
  131. package/src/e2e_p2p/p2p_network.ts +272 -166
  132. package/src/e2e_p2p/shared.ts +244 -29
  133. package/src/e2e_token_contract/token_contract_test.ts +43 -39
  134. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  135. package/src/{e2e_prover → fixtures}/e2e_prover_test.ts +101 -145
  136. package/src/fixtures/fixtures.ts +4 -3
  137. package/src/fixtures/get_acvm_config.ts +3 -11
  138. package/src/fixtures/get_bb_config.ts +18 -13
  139. package/src/fixtures/l1_to_l2_messaging.ts +53 -23
  140. package/src/fixtures/setup_l1_contracts.ts +6 -7
  141. package/src/fixtures/setup_p2p_test.ts +112 -38
  142. package/src/fixtures/snapshot_manager.ts +187 -139
  143. package/src/fixtures/token_utils.ts +29 -12
  144. package/src/fixtures/utils.ts +552 -425
  145. package/src/fixtures/web3signer.ts +63 -0
  146. package/src/guides/up_quick_start.sh +6 -14
  147. package/src/quality_of_service/alert_checker.ts +1 -1
  148. package/src/shared/cross_chain_test_harness.ts +108 -79
  149. package/src/shared/gas_portal_test_harness.ts +58 -49
  150. package/src/shared/jest_setup.ts +1 -1
  151. package/src/shared/submit-transactions.ts +12 -8
  152. package/src/shared/uniswap_l1_l2.ts +173 -176
  153. package/src/simulators/lending_simulator.ts +12 -15
  154. package/src/simulators/token_simulator.ts +21 -13
  155. package/src/spartan/DEVELOP.md +121 -0
  156. package/src/spartan/setup_test_wallets.ts +215 -93
  157. package/src/spartan/utils.ts +458 -130
  158. package/dest/e2e_prover/e2e_prover_test.d.ts.map +0 -1
  159. package/dest/sample-dapp/connect.js +0 -12
  160. package/dest/sample-dapp/contracts.js +0 -10
  161. package/dest/sample-dapp/deploy.js +0 -35
  162. package/dest/sample-dapp/index.js +0 -98
  163. package/src/sample-dapp/connect.mjs +0 -16
  164. package/src/sample-dapp/contracts.mjs +0 -14
  165. package/src/sample-dapp/deploy.mjs +0 -40
  166. package/src/sample-dapp/index.mjs +0 -128
@@ -1,13 +1,12 @@
1
1
  // Convenience struct to hold an account's address and secret that can easily be passed around.
2
- import { AztecAddress, type CheatCodes, Fr } from '@aztec/aztec.js';
2
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
3
+ import { Fr } from '@aztec/aztec.js/fields';
4
+ import { CheatCodes } from '@aztec/aztec/testing';
5
+ import type { RollupContract } from '@aztec/ethereum';
3
6
  import { pedersenHash } from '@aztec/foundation/crypto';
4
7
  import type { TestDateProvider } from '@aztec/foundation/timer';
5
- import type { RollupAbi } from '@aztec/l1-artifacts';
6
8
  import type { LendingContract } from '@aztec/noir-contracts.js/Lending';
7
9
 
8
- import type { Account, GetContractReturnType, HttpTransport, WalletClient } from 'viem';
9
- import type * as chains from 'viem/chains';
10
-
11
10
  import type { TokenSimulator } from './token_simulator.js';
12
11
 
13
12
  /**
@@ -83,7 +82,7 @@ export class LendingSimulator {
83
82
  private rate: bigint,
84
83
  private ethereumSlotDuration: number,
85
84
  /** the rollup contract */
86
- public rollup: GetContractReturnType<typeof RollupAbi, WalletClient<HttpTransport, chains.Chain, Account>>,
85
+ public rollup: RollupContract,
87
86
  /** the lending contract */
88
87
  public lendingContract: LendingContract,
89
88
  /** the collateral asset used in the lending contract */
@@ -94,10 +93,8 @@ export class LendingSimulator {
94
93
 
95
94
  async prepare() {
96
95
  this.accumulator = BASE;
97
- const slot = await this.rollup.read.getSlotAt([
98
- BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration),
99
- ]);
100
- this.time = Number(await this.rollup.read.getTimestampForSlot([slot]));
96
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()) + BigInt(this.ethereumSlotDuration));
97
+ this.time = Number(await this.rollup.getTimestampForSlot(slot));
101
98
  }
102
99
 
103
100
  async progressSlots(diff: number, dateProvider?: TestDateProvider) {
@@ -105,8 +102,8 @@ export class LendingSimulator {
105
102
  return;
106
103
  }
107
104
 
108
- const slot = await this.rollup.read.getSlotAt([BigInt(await this.cc.eth.timestamp())]);
109
- const ts = Number(await this.rollup.read.getTimestampForSlot([slot + BigInt(diff)]));
105
+ const slot = await this.rollup.getSlotAt(BigInt(await this.cc.eth.timestamp()));
106
+ const ts = Number(await this.rollup.getTimestampForSlot(slot + BigInt(diff)));
110
107
  const timeDiff = ts - this.time;
111
108
  this.time = ts;
112
109
 
@@ -115,7 +112,7 @@ export class LendingSimulator {
115
112
  if (dateProvider) {
116
113
  dateProvider.setTime(this.time * 1000);
117
114
  }
118
- await this.cc.rollup.markAsProven(await this.rollup.read.getPendingBlockNumber());
115
+ await this.cc.rollup.markAsProven(await this.rollup.getBlockNumber());
119
116
  this.accumulator = muldivDown(this.accumulator, computeMultiplier(this.rate, BigInt(timeDiff)), BASE);
120
117
  }
121
118
 
@@ -187,14 +184,14 @@ export class LendingSimulator {
187
184
 
188
185
  expect(this.borrowed).toEqual(this.stableCoin.totalSupply - this.mintedOutside);
189
186
 
190
- const asset = await this.lendingContract.methods.get_asset(0).simulate();
187
+ const asset = await this.lendingContract.methods.get_asset(0).simulate({ from: this.account.address });
191
188
 
192
189
  const interestAccumulator = asset['interest_accumulator'];
193
190
  expect(interestAccumulator).toEqual(this.accumulator);
194
191
  expect(asset['last_updated_ts']).toEqual(BigInt(this.time));
195
192
 
196
193
  for (const key of [this.account.address, AztecAddress.fromField(await this.account.key())]) {
197
- const privatePos = await this.lendingContract.methods.get_position(key).simulate();
194
+ const privatePos = await this.lendingContract.methods.get_position(key).simulate({ from: this.account.address });
198
195
  expect(new Fr(privatePos['collateral'])).toEqual(this.collateral[key.toString()] ?? Fr.ZERO);
199
196
  expect(new Fr(privatePos['static_debt'])).toEqual(this.staticDebt[key.toString()] ?? Fr.ZERO);
200
197
  expect(privatePos['debt']).toEqual(
@@ -1,5 +1,7 @@
1
- /* eslint-disable jsdoc/require-jsdoc */
2
- import { type AztecAddress, BatchCall, type Logger, type Wallet } from '@aztec/aztec.js';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { BatchCall } from '@aztec/aztec.js/contracts';
3
+ import type { Logger } from '@aztec/aztec.js/log';
4
+ import type { Wallet } from '@aztec/aztec.js/wallet';
3
5
  import type { TokenContract } from '@aztec/noir-contracts.js/Token';
4
6
 
5
7
  import chunk from 'lodash.chunk';
@@ -14,6 +16,7 @@ export class TokenSimulator {
14
16
  constructor(
15
17
  protected token: TokenContract,
16
18
  protected defaultWallet: Wallet,
19
+ protected defaultAddress: AztecAddress,
17
20
  protected logger: Logger,
18
21
  protected accounts: AztecAddress[],
19
22
  ) {}
@@ -97,13 +100,15 @@ export class TokenSimulator {
97
100
 
98
101
  async checkPublic() {
99
102
  // public calls
100
- const calls = [await this.token.methods.total_supply().request()];
101
- for (const address of this.accounts) {
102
- calls.push(await this.token.methods.balance_of_public(address).request());
103
- }
103
+ const calls = [
104
+ this.token.methods.total_supply(),
105
+ ...this.accounts.map(address => this.token.methods.balance_of_public(address)),
106
+ ];
104
107
 
105
108
  const results = (
106
- await Promise.all(chunk(calls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate()))
109
+ await Promise.all(
110
+ chunk(calls, 5).map(batch => new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress })),
111
+ )
107
112
  ).flat();
108
113
  expect(results[0]).toEqual(this.totalSupply);
109
114
 
@@ -126,12 +131,13 @@ export class TokenSimulator {
126
131
  }
127
132
  }
128
133
 
129
- const defaultCalls = [];
130
- for (const address of defaultLookups) {
131
- defaultCalls.push(await this.token.methods.balance_of_private(address).request());
132
- }
134
+ const defaultCalls = defaultLookups.map(address => this.token.methods.balance_of_private(address));
133
135
  const results = (
134
- await Promise.all(chunk(defaultCalls, 4).map(batch => new BatchCall(this.defaultWallet, batch).simulate()))
136
+ await Promise.all(
137
+ chunk(defaultCalls, 4).map(batch =>
138
+ new BatchCall(this.defaultWallet, batch).simulate({ from: this.defaultAddress }),
139
+ ),
140
+ )
135
141
  ).flat();
136
142
  for (let i = 0; i < defaultLookups.length; i++) {
137
143
  expect(results[i]).toEqual(this.balanceOfPrivate(defaultLookups[i]));
@@ -143,7 +149,9 @@ export class TokenSimulator {
143
149
  const wallet = this.lookupProvider.get(address.toString());
144
150
  const asset = wallet ? this.token.withWallet(wallet) : this.token;
145
151
 
146
- const actualPrivateBalance = await asset.methods.balance_of_private({ address }).simulate();
152
+ const actualPrivateBalance = await asset.methods
153
+ .balance_of_private({ address })
154
+ .simulate({ from: this.defaultAddress });
147
155
  expect(actualPrivateBalance).toEqual(this.balanceOfPrivate(address));
148
156
  }
149
157
  }
@@ -0,0 +1,121 @@
1
+ The flow is as follows:
2
+
3
+ 1. Install/start KIND locally
4
+ 2. Bootstrap (to build an aztec image)
5
+ 3. Load image into kind
6
+ 4. Deploy networks
7
+ 5. Run tests in `yarn-project/end-to-end/src/spartan`
8
+
9
+ # Setup KIND
10
+
11
+ KIND is a kubernetes cluster that runs locally out of docker containers.
12
+
13
+ You can just
14
+
15
+ ```bash
16
+ spartan/bootstrap.sh kind
17
+ ```
18
+
19
+ You only need to do that once. If you do it again, it will destroy the cluster and recreate it (which you almost never need to do).
20
+
21
+ Now you’ll likely want some visibility into your cluster. You can
22
+
23
+ ```bash
24
+ spartan/scripts/create_k8s_dashboard.sh
25
+ ```
26
+
27
+ And after ~30 seconds or so you can
28
+
29
+ ```bash
30
+ spartan/scripts/forward_k8s_dashboard.sh
31
+ ```
32
+
33
+ That will run a port forward to your port `8443` . If you’re running in a remote environment (e.g. the mainframe), you’ll need to subsequently forward that back to your local machine. Cursor/VSCode have built in port forwarding (cmd/ctrl shift P, “forward”)
34
+
35
+ Open the forwarded page, and copy/paste the token that was generated when you forwarded the dashboard.
36
+
37
+ # Build an aztecprotocol:aztec image
38
+
39
+ ```bash
40
+ ./bootstrap.sh
41
+ export AZTEC_DOCKER_IMAGE="aztecprotocol/aztec:$(docker images "aztecprotocol/aztec" --format json | \
42
+ jq -r 'select(.Tag != "latest") | .Tag' | \
43
+ head -1)"
44
+ kind load docker-image $AZTEC_DOCKER_IMAGE
45
+ ```
46
+
47
+ If you just changed typescript, you can (after the initial bootstrap)
48
+
49
+ ```bash
50
+ ./yarn-project/bootstrap.sh
51
+ ./release-image/bootstrap.sh
52
+ export AZTEC_DOCKER_IMAGE="aztecprotocol/aztec:$(docker images "aztecprotocol/aztec" --format json | \
53
+ jq -r 'select(.Tag != "latest") | .Tag' | \
54
+ head -1)"
55
+ kind load docker-image $AZTEC_DOCKER_IMAGE
56
+ ```
57
+
58
+ The export is important there. The `AZTEC_DOCKER_IMAGE` env var is used as both:
59
+
60
+ - the container that runs the rollup contract deployment
61
+ - the containers for the aztec infrastructure (validators, provers, etc)
62
+
63
+ # Deploy Metrics
64
+ ```bash
65
+ ./spartan/bootstrap.sh metrics-kind
66
+ ```
67
+
68
+ # Deploy stuff
69
+
70
+ ```bash
71
+ ./spartan/bootstrap.sh network_deploy scenario.local
72
+ ```
73
+
74
+ That will take 1-3 minutes. But at the end you should have everything you need.
75
+
76
+ You can (`k` is just an alias over `kubectl`)
77
+
78
+ ```bash
79
+ ❯ k get pods -n scenario
80
+ NAME READY STATUS RESTARTS AGE
81
+ deploy-rollup-contracts-2025-08-31-1511-w2dlb 0/1 Completed 0 2m34s
82
+ scenario-eth-beacon-0 1/1 Running 0 39m
83
+ scenario-eth-execution-0 1/1 Running 0 39m
84
+ scenario-eth-validator-0 1/1 Running 0 39m
85
+ scenario-p2p-bootstrap-node-5cbf9658b9-6vd9b 1/1 Running 0 20m
86
+ scenario-prover-agent-59bd96899d-46k5s 1/1 Running 0 116s
87
+ scenario-prover-agent-59bd96899d-vzvkd 1/1 Running 0 116s
88
+ scenario-prover-broker-0 1/1 Running 0 116s
89
+ scenario-prover-node-0 1/1 Running 0 116s
90
+ scenario-rpc-aztec-node-0 1/1 Running 0 116s
91
+ scenario-validator-0 1/1 Running 0 116s
92
+ scenario-validator-1 1/1 Running 0 116s
93
+ scenario-validator-2 1/1 Running 0 116s
94
+ scenario-validator-3 1/1 Running 0 116s
95
+ ```
96
+
97
+ For example, you can forward back the ethereum node with
98
+
99
+ ```bash
100
+ k port-forward -n scenario services/eth-devnet-eth-execution 8545:8545
101
+ ```
102
+
103
+ And then do whatever you like with it.
104
+
105
+ # Run tests
106
+
107
+ With the cluster running, you can now easily run tests.
108
+
109
+ ```bash
110
+ # run one
111
+ ./spartan/bootstrap.sh single_test scenario.local spartan/smoke.test.ts
112
+
113
+ # run all (serially)
114
+ ./spartan/bootstrap.sh network_tests scenario.local
115
+ ```
116
+
117
+ Right now, I recommend running the smoke test first, always, as it waits for the committee to exist.
118
+
119
+ # Teardown
120
+
121
+ You can just `k delete namespace scenario`. That will destroy everything in your kind cluster. To destroy the associated terraform state that was stored locally, just `./spartan/terraform/purge_local_state.sh`.
@@ -1,27 +1,30 @@
1
- import { getSchnorrAccount, getSchnorrWalletWithSecretKey } from '@aztec/accounts/schnorr';
2
- import { generateSchnorrAccounts, getDeployedTestAccountsWallets } from '@aztec/accounts/testing';
3
- import {
4
- type AccountWalletWithSecretKey,
5
- type AztecAddress,
6
- type AztecNode,
7
- FeeJuicePaymentMethodWithClaim,
8
- Fr,
9
- L1FeeJuicePortalManager,
10
- type PXE,
11
- createAztecNodeClient,
12
- createCompatibleClient,
13
- retryUntil,
14
- } from '@aztec/aztec.js';
15
- import { createEthereumChain, createL1Clients } from '@aztec/ethereum';
1
+ import { generateSchnorrAccounts } from '@aztec/accounts/testing';
2
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
3
+ import { L1FeeJuicePortalManager } from '@aztec/aztec.js/ethereum';
4
+ import { FeeJuicePaymentMethodWithClaim } from '@aztec/aztec.js/fee';
5
+ import { type FeePaymentMethod, SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee';
6
+ import { Fr } from '@aztec/aztec.js/fields';
7
+ import { type AztecNode, createAztecNodeClient } from '@aztec/aztec.js/node';
8
+ import type { Wallet } from '@aztec/aztec.js/wallet';
9
+ import { createEthereumChain, createExtendedL1Client } from '@aztec/ethereum';
16
10
  import type { Logger } from '@aztec/foundation/log';
11
+ import { retryUntil } from '@aztec/foundation/retry';
17
12
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
13
+ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
14
+ import { TestWallet, proveInteraction, registerInitialSandboxAccountsInWallet } from '@aztec/test-wallet/server';
18
15
 
19
- export interface TestWallets {
20
- pxe: PXE;
21
- wallets: AccountWalletWithSecretKey[];
22
- tokenAdminWallet: TokenContract;
16
+ import { getACVMConfig } from '../fixtures/get_acvm_config.js';
17
+ import { getBBConfig } from '../fixtures/get_bb_config.js';
18
+ import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
19
+
20
+ export interface TestAccounts {
21
+ aztecNode: AztecNode;
22
+ wallet: TestWallet;
23
+ accounts: AztecAddress[];
24
+ tokenContract: TokenContract;
25
+ tokenAdminAddress: AztecAddress;
23
26
  tokenName: string;
24
- recipientWallet: AccountWalletWithSecretKey;
27
+ recipientAddress: AztecAddress;
25
28
  tokenAddress: AztecAddress;
26
29
  }
27
30
 
@@ -29,121 +32,206 @@ const TOKEN_NAME = 'USDC';
29
32
  const TOKEN_SYMBOL = 'USD';
30
33
  const TOKEN_DECIMALS = 18n;
31
34
 
32
- export async function setupTestWalletsWithTokens(
33
- pxeUrl: string,
35
+ export async function setupTestAccountsWithTokens(
36
+ nodeUrl: string,
37
+ mintAmount: bigint,
38
+ logger: Logger,
39
+ ): Promise<TestAccounts> {
40
+ const ACCOUNT_COUNT = 1; // TODO fix this to allow for 16 wallets again
41
+
42
+ const aztecNode = createAztecNodeClient(nodeUrl);
43
+ const wallet = await TestWallet.create(aztecNode);
44
+
45
+ const [recipientAccount, ...accounts] = (await registerInitialSandboxAccountsInWallet(wallet)).slice(
46
+ 0,
47
+ ACCOUNT_COUNT + 1,
48
+ );
49
+
50
+ const tokenAdmin = accounts[0];
51
+ const tokenAddress = await deployTokenAndMint(wallet, accounts, tokenAdmin, mintAmount, undefined, logger);
52
+ const tokenContract = await TokenContract.at(tokenAddress, wallet);
53
+
54
+ return {
55
+ aztecNode,
56
+ accounts,
57
+ wallet,
58
+ tokenAdminAddress: tokenAdmin,
59
+ tokenName: TOKEN_NAME,
60
+ tokenAddress,
61
+ tokenContract,
62
+ recipientAddress: recipientAccount,
63
+ };
64
+ }
65
+
66
+ export async function deploySponsoredTestAccounts(
67
+ wallet: TestWallet,
68
+ aztecNode: AztecNode,
34
69
  mintAmount: bigint,
35
70
  logger: Logger,
36
- ): Promise<TestWallets> {
37
- const WALLET_COUNT = 1; // TODO fix this to allow for 16 wallets again
71
+ numberOfFundedWallets = 1,
72
+ ): Promise<TestAccounts> {
73
+ const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
74
+ const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
75
+ const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
38
76
 
39
- const pxe = await createCompatibleClient(pxeUrl, logger);
77
+ await registerSponsoredFPC(wallet);
40
78
 
41
- const [recipientWallet, ...wallets] = (await getDeployedTestAccountsWallets(pxe)).slice(0, WALLET_COUNT + 1);
79
+ const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
80
+ const recipientDeployMethod = await recipientAccount.getDeployMethod();
81
+ await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 });
82
+ await Promise.all(
83
+ fundedAccounts.map(async a => {
84
+ const deployMethod = await a.getDeployMethod();
85
+ await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait({ timeout: 2400 }); // increase timeout on purpose in order to account for two empty epochs
86
+ logger.info(`Account deployed at ${a.address}`);
87
+ }),
88
+ );
42
89
 
43
- const tokenAdmin = wallets[0];
44
- const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, logger);
45
- const tokenAdminWallet = await TokenContract.at(tokenAddress, tokenAdmin);
90
+ const tokenAdmin = fundedAccounts[0];
91
+ const tokenAddress = await deployTokenAndMint(
92
+ wallet,
93
+ fundedAccounts.map(acc => acc.address),
94
+ tokenAdmin.address,
95
+ mintAmount,
96
+ new SponsoredFeePaymentMethod(await getSponsoredFPCAddress()),
97
+ logger,
98
+ );
99
+ const tokenContract = await TokenContract.at(tokenAddress, wallet);
46
100
 
47
- return { pxe, wallets, tokenAdminWallet, tokenName: TOKEN_NAME, tokenAddress, recipientWallet };
101
+ return {
102
+ aztecNode,
103
+ wallet,
104
+ accounts: fundedAccounts.map(acc => acc.address),
105
+ tokenAdminAddress: tokenAdmin.address,
106
+ tokenName: TOKEN_NAME,
107
+ tokenAddress,
108
+ tokenContract,
109
+ recipientAddress: recipientAccount.address,
110
+ };
48
111
  }
49
112
 
50
- export async function deployTestWalletWithTokens(
51
- pxeUrl: string,
113
+ export async function deployTestAccountsWithTokens(
52
114
  nodeUrl: string,
53
- l1RpcUrl: string,
115
+ l1RpcUrls: string[],
54
116
  mnemonicOrPrivateKey: string,
55
117
  mintAmount: bigint,
56
118
  logger: Logger,
57
119
  numberOfFundedWallets = 1,
58
- initialFeeJuice = 10n ** 22n,
59
- ): Promise<TestWallets> {
60
- const pxe = await createCompatibleClient(pxeUrl, logger);
61
- const node = createAztecNodeClient(nodeUrl);
120
+ ): Promise<TestAccounts> {
121
+ const aztecNode = createAztecNodeClient(nodeUrl);
122
+ const wallet = await TestWallet.create(aztecNode);
62
123
 
63
124
  const [recipient, ...funded] = await generateSchnorrAccounts(numberOfFundedWallets + 1);
64
- const recipientWallet = await getSchnorrWalletWithSecretKey(
65
- pxe,
66
- recipient.secret,
67
- recipient.signingKey,
68
- recipient.salt,
69
- );
70
- const fundedAccounts = await Promise.all(funded.map(a => getSchnorrAccount(pxe, a.secret, a.signingKey, a.salt)));
125
+ const recipientAccount = await wallet.createSchnorrAccount(recipient.secret, recipient.salt);
126
+ const fundedAccounts = await Promise.all(funded.map(a => wallet.createSchnorrAccount(a.secret, a.salt)));
71
127
 
72
128
  const claims = await Promise.all(
73
- fundedAccounts.map(a =>
74
- bridgeL1FeeJuice(l1RpcUrl, mnemonicOrPrivateKey, pxe, a.getAddress(), initialFeeJuice, logger),
75
- ),
129
+ fundedAccounts.map(a => bridgeL1FeeJuice(l1RpcUrls, mnemonicOrPrivateKey, aztecNode, a.address, undefined, logger)),
76
130
  );
77
131
 
78
- // Progress by 2 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
79
- await advanceL2Block(node);
80
- await advanceL2Block(node);
132
+ // Progress by 3 L2 blocks so that the l1ToL2Message added above will be available to use on L2.
133
+ await advanceL2Block(aztecNode);
134
+ await advanceL2Block(aztecNode);
135
+ await advanceL2Block(aztecNode);
81
136
 
82
- const wallets = await Promise.all(
137
+ await Promise.all(
83
138
  fundedAccounts.map(async (a, i) => {
84
- const wallet = await a.getWallet();
85
- const paymentMethod = new FeeJuicePaymentMethodWithClaim(wallet, claims[i]);
86
- await a.deploy({ fee: { paymentMethod } }).wait();
87
- logger.info(`Account deployed at ${a.getAddress()}`);
88
- return wallet;
139
+ const paymentMethod = new FeeJuicePaymentMethodWithClaim(a.address, claims[i]);
140
+ const deployMethod = await a.getDeployMethod();
141
+ await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod } }).wait();
142
+ logger.info(`Account deployed at ${a.address}`);
89
143
  }),
90
144
  );
91
145
 
92
- const tokenAdmin = wallets[0];
93
- const tokenAddress = await deployTokenAndMint(wallets, tokenAdmin.getAddress(), mintAmount, logger);
94
- const tokenAdminWallet = await TokenContract.at(tokenAddress, tokenAdmin);
146
+ const tokenAdmin = fundedAccounts[0];
147
+ const tokenAddress = await deployTokenAndMint(
148
+ wallet,
149
+ fundedAccounts.map(acc => acc.address),
150
+ tokenAdmin.address,
151
+ mintAmount,
152
+ undefined,
153
+ logger,
154
+ );
155
+ const tokenContract = await TokenContract.at(tokenAddress, wallet);
95
156
 
96
- return { pxe, wallets, tokenAdminWallet, tokenName: TOKEN_NAME, tokenAddress, recipientWallet };
157
+ return {
158
+ aztecNode,
159
+ wallet,
160
+ accounts: fundedAccounts.map(acc => acc.address),
161
+ tokenAdminAddress: tokenAdmin.address,
162
+ tokenName: TOKEN_NAME,
163
+ tokenAddress,
164
+ tokenContract,
165
+ recipientAddress: recipientAccount.address,
166
+ };
97
167
  }
98
168
 
99
169
  async function bridgeL1FeeJuice(
100
- l1RpcUrl: string,
170
+ l1RpcUrls: string[],
101
171
  mnemonicOrPrivateKey: string,
102
- pxe: PXE,
172
+ aztecNode: AztecNode,
103
173
  recipient: AztecAddress,
104
- amount: bigint,
174
+ amount: bigint | undefined,
105
175
  log: Logger,
106
176
  ) {
107
- const { l1ChainId } = await pxe.getNodeInfo();
108
- const chain = createEthereumChain([l1RpcUrl], l1ChainId);
109
- const { publicClient, walletClient } = createL1Clients(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
177
+ const { l1ChainId } = await aztecNode.getNodeInfo();
178
+ const chain = createEthereumChain(l1RpcUrls, l1ChainId);
179
+ const l1Client = createExtendedL1Client(chain.rpcUrls, mnemonicOrPrivateKey, chain.chainInfo);
110
180
 
111
- const portal = await L1FeeJuicePortalManager.new(pxe, publicClient, walletClient, log);
181
+ const portal = await L1FeeJuicePortalManager.new(aztecNode, l1Client, log);
112
182
  const claim = await portal.bridgeTokensPublic(recipient, amount, true /* mint */);
113
183
 
114
- const isSynced = async () => await pxe.isL1ToL2MessageSynced(Fr.fromHexString(claim.messageHash));
184
+ const isSynced = async () =>
185
+ (await aztecNode.getL1ToL2MessageBlock(Fr.fromHexString(claim.messageHash))) !== undefined;
115
186
  await retryUntil(isSynced, `message ${claim.messageHash} sync`, 24, 0.5);
116
187
 
117
188
  log.info(`Created a claim for ${amount} L1 fee juice to ${recipient}.`, claim);
118
189
  return claim;
119
190
  }
120
191
 
121
- async function advanceL2Block(node: AztecNode) {
122
- const initialBlockNumber = await node.getBlockNumber();
123
- await node!.flushTxs();
124
- await retryUntil(async () => (await node.getBlockNumber()) >= initialBlockNumber + 1);
192
+ async function advanceL2Block(aztecNode: AztecNode, nodeAdmin?: AztecNodeAdmin) {
193
+ const initialBlockNumber = await aztecNode.getBlockNumber();
194
+
195
+ let minTxsPerBlock = undefined;
196
+ if (nodeAdmin) {
197
+ ({ minTxsPerBlock } = await nodeAdmin.getConfig());
198
+ await nodeAdmin.setConfig({ minTxsPerBlock: 0 }); // Set to 0 to ensure we can advance the block
199
+ }
200
+
201
+ await retryUntil(async () => (await aztecNode.getBlockNumber()) >= initialBlockNumber + 1);
202
+
203
+ if (nodeAdmin && minTxsPerBlock !== undefined) {
204
+ await nodeAdmin.setConfig({ minTxsPerBlock });
205
+ }
125
206
  }
126
207
 
127
208
  async function deployTokenAndMint(
128
- wallets: AccountWalletWithSecretKey[],
209
+ wallet: Wallet,
210
+ accounts: AztecAddress[],
129
211
  admin: AztecAddress,
130
212
  mintAmount: bigint,
213
+ paymentMethod: FeePaymentMethod | undefined,
131
214
  logger: Logger,
132
215
  ) {
133
216
  logger.verbose(`Deploying TokenContract...`);
134
- const tokenContract = await TokenContract.deploy(wallets[0], admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS)
135
- .send()
217
+ const tokenContract = await TokenContract.deploy(wallet, admin, TOKEN_NAME, TOKEN_SYMBOL, TOKEN_DECIMALS)
218
+ .send({
219
+ from: admin,
220
+ fee: {
221
+ paymentMethod,
222
+ },
223
+ })
136
224
  .deployed({ timeout: 600 });
137
225
 
138
226
  const tokenAddress = tokenContract.address;
139
227
 
140
- logger.verbose(`Minting ${mintAmount} public assets to the ${wallets.length} wallets...`);
228
+ logger.verbose(`Minting ${mintAmount} public assets to the ${accounts.length} accounts...`);
141
229
 
142
230
  await Promise.all(
143
- wallets.map(async w =>
144
- (await TokenContract.at(tokenAddress, w)).methods
145
- .mint_to_public(w.getAddress(), mintAmount)
146
- .send()
231
+ accounts.map(async acc =>
232
+ (await TokenContract.at(tokenAddress, wallet)).methods
233
+ .mint_to_public(acc, mintAmount)
234
+ .send({ from: admin, fee: { paymentMethod } })
147
235
  .wait({ timeout: 600 }),
148
236
  ),
149
237
  );
@@ -154,31 +242,65 @@ async function deployTokenAndMint(
154
242
  }
155
243
 
156
244
  export async function performTransfers({
157
- testWallets,
245
+ wallet,
246
+ testAccounts,
158
247
  rounds,
159
248
  transferAmount,
160
249
  logger,
250
+ feePaymentMethod,
161
251
  }: {
162
- testWallets: TestWallets;
252
+ wallet: TestWallet;
253
+ testAccounts: TestAccounts;
163
254
  rounds: number;
164
255
  transferAmount: bigint;
165
256
  logger: Logger;
257
+ feePaymentMethod?: FeePaymentMethod;
166
258
  }) {
167
- const recipient = testWallets.recipientWallet.getAddress();
168
-
259
+ const recipient = testAccounts.recipientAddress;
260
+ // Default to sponsored fee payment if no fee method is provided
261
+ const defaultFeePaymentMethod = feePaymentMethod || new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
169
262
  for (let i = 0; i < rounds; i++) {
170
- const interactions = await Promise.all(
171
- testWallets.wallets.map(async w =>
172
- (
173
- await TokenContract.at(testWallets.tokenAddress, w)
174
- ).methods.transfer_in_public(w.getAddress(), recipient, transferAmount, 0),
175
- ),
176
- );
263
+ const txs = testAccounts.accounts.map(async acc => {
264
+ const token = await TokenContract.at(testAccounts.tokenAddress, testAccounts.wallet);
265
+ return proveInteraction(wallet, token.methods.transfer_in_public(acc, recipient, transferAmount, 0), {
266
+ from: acc,
267
+ fee: {
268
+ paymentMethod: defaultFeePaymentMethod,
269
+ },
270
+ });
271
+ });
177
272
 
178
- const txs = await Promise.all(interactions.map(async i => await i.prove()));
273
+ const provenTxs = await Promise.all(txs);
179
274
 
180
- await Promise.all(txs.map(t => t.send().wait({ timeout: 600 })));
275
+ await Promise.all(provenTxs.map(t => t.send().wait({ timeout: 600 })));
181
276
 
182
277
  logger.info(`Completed round ${i + 1} / ${rounds}`);
183
278
  }
184
279
  }
280
+
281
+ export async function createWalletAndAztecNodeClient(
282
+ nodeUrl: string,
283
+ proverEnabled: boolean,
284
+ logger: Logger,
285
+ ): Promise<{ wallet: TestWallet; aztecNode: AztecNode; cleanup: () => Promise<void> }> {
286
+ const aztecNode = createAztecNodeClient(nodeUrl);
287
+ const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
288
+ const pxeConfig = {
289
+ dataDirectory: undefined,
290
+ dataStoreMapSizeKb: 1024 * 1024,
291
+ ...bbConfig,
292
+ ...acvmConfig,
293
+ proverEnabled,
294
+ };
295
+ const wallet = await TestWallet.create(aztecNode, pxeConfig);
296
+
297
+ return {
298
+ wallet,
299
+ aztecNode,
300
+ async cleanup() {
301
+ await wallet.stop();
302
+ await bbConfig?.cleanup();
303
+ await acvmConfig?.cleanup();
304
+ },
305
+ };
306
+ }