@aztec/end-to-end 0.0.1-fake-c83136db25 → 0.0.1-fake-ceab37513c
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.
- package/dest/bench/client_flows/benchmark.d.ts +2 -3
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +2 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +12 -16
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +58 -54
- package/dest/bench/client_flows/data_extractor.js +3 -3
- package/dest/bench/utils.d.ts +11 -2
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +34 -10
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +8 -10
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +33 -31
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +18 -9
- package/dest/e2e_epochs/epochs_test.d.ts +1 -3
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +9 -10
- package/dest/e2e_fees/bridging_race.notest.js +9 -12
- package/dest/e2e_fees/fees_test.d.ts +5 -5
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +31 -23
- package/dest/e2e_l1_publisher/write_json.d.ts +1 -3
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +5 -5
- package/dest/e2e_multi_validator/utils.d.ts +1 -1
- package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -6
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +9 -7
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +2 -2
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
- package/dest/e2e_p2p/inactivity_slash_test.js +2 -5
- package/dest/e2e_p2p/p2p_network.d.ts +2 -14
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +10 -32
- package/dest/e2e_p2p/shared.d.ts +13 -11
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +45 -49
- package/dest/e2e_token_contract/token_contract_test.d.ts +4 -5
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +17 -14
- package/dest/fixtures/e2e_prover_test.d.ts +6 -8
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +50 -40
- package/dest/fixtures/get_acvm_config.d.ts +1 -1
- package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.d.ts +1 -1
- package/dest/fixtures/get_bb_config.d.ts.map +1 -1
- package/dest/fixtures/get_bb_config.js +2 -2
- package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
- package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
- package/dest/fixtures/setup_l1_contracts.js +2 -2
- package/dest/fixtures/setup_p2p_test.d.ts +7 -0
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.d.ts +7 -10
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +32 -42
- package/dest/fixtures/token_utils.d.ts +4 -6
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +15 -11
- package/dest/fixtures/utils.d.ts +27 -23
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +100 -75
- package/dest/fixtures/web3signer.d.ts +1 -1
- package/dest/fixtures/web3signer.d.ts.map +1 -1
- package/dest/fixtures/web3signer.js +5 -16
- package/dest/quality_of_service/alert_checker.d.ts +1 -1
- package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.d.ts +10 -16
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +15 -13
- package/dest/shared/gas_portal_test_harness.d.ts +6 -9
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +7 -10
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +3 -5
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +7 -8
- package/dest/shared/uniswap_l1_l2.d.ts +6 -9
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +45 -29
- package/dest/simulators/lending_simulator.d.ts +1 -2
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +2 -3
- package/dest/simulators/token_simulator.d.ts +1 -3
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +2 -2
- package/dest/spartan/setup_test_wallets.d.ts +13 -19
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +84 -107
- package/dest/spartan/utils.d.ts +0 -44
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +20 -212
- package/package.json +36 -37
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +82 -62
- package/src/bench/client_flows/data_extractor.ts +4 -4
- package/src/bench/utils.ts +37 -9
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +63 -46
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +47 -33
- package/src/e2e_deploy_contract/deploy_test.ts +35 -17
- package/src/e2e_epochs/epochs_test.ts +14 -12
- package/src/e2e_fees/bridging_race.notest.ts +9 -14
- package/src/e2e_fees/fees_test.ts +38 -26
- package/src/e2e_l1_publisher/write_json.ts +6 -8
- package/src/e2e_multi_validator/utils.ts +1 -1
- package/src/e2e_nested_contract/nested_contract_test.ts +10 -11
- package/src/e2e_p2p/inactivity_slash_test.ts +3 -7
- package/src/e2e_p2p/p2p_network.ts +67 -105
- package/src/e2e_p2p/shared.ts +55 -50
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +88 -51
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +2 -3
- package/src/fixtures/setup_l1_contracts.ts +3 -3
- package/src/fixtures/setup_p2p_test.ts +8 -0
- package/src/fixtures/snapshot_manager.ts +59 -59
- package/src/fixtures/token_utils.ts +21 -13
- package/src/fixtures/utils.ts +137 -86
- package/src/fixtures/web3signer.ts +5 -22
- package/src/guides/up_quick_start.sh +10 -2
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +29 -18
- package/src/shared/gas_portal_test_harness.ts +19 -12
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +8 -12
- package/src/shared/uniswap_l1_l2.ts +67 -61
- package/src/simulators/lending_simulator.ts +2 -3
- package/src/simulators/token_simulator.ts +2 -5
- package/src/spartan/DEVELOP.md +3 -8
- package/src/spartan/setup_test_wallets.ts +125 -132
- package/src/spartan/utils.ts +18 -268
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SchnorrAccountContractArtifact,
|
|
3
|
+
getSchnorrAccount,
|
|
4
|
+
getSchnorrWalletWithSecretKey,
|
|
5
|
+
} from '@aztec/accounts/schnorr';
|
|
1
6
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
2
7
|
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
import {
|
|
9
|
+
type AccountWalletWithSecretKey,
|
|
10
|
+
type AztecNode,
|
|
11
|
+
type CompleteAddress,
|
|
12
|
+
EthAddress,
|
|
13
|
+
type Logger,
|
|
14
|
+
type PXE,
|
|
15
|
+
createLogger,
|
|
16
|
+
} from '@aztec/aztec.js';
|
|
6
17
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
7
18
|
import {
|
|
8
19
|
BBCircuitVerifier,
|
|
@@ -18,8 +29,8 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
18
29
|
import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
19
30
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
20
31
|
import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
|
|
32
|
+
import type { PXEService } from '@aztec/pxe/server';
|
|
21
33
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
22
|
-
import { TestWallet } from '@aztec/test-wallet/server';
|
|
23
34
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
24
35
|
|
|
25
36
|
import { type Hex, getContract } from 'viem';
|
|
@@ -35,12 +46,12 @@ import {
|
|
|
35
46
|
deployAccounts,
|
|
36
47
|
publicDeployAccounts,
|
|
37
48
|
} from './snapshot_manager.js';
|
|
38
|
-
import { getPrivateKeyFromIndex, getSponsoredFPCAddress,
|
|
49
|
+
import { getPrivateKeyFromIndex, getSponsoredFPCAddress, setupPXEService } from './utils.js';
|
|
39
50
|
|
|
40
51
|
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
41
52
|
|
|
42
53
|
type ProvenSetup = {
|
|
43
|
-
|
|
54
|
+
pxe: PXE;
|
|
44
55
|
teardown: () => Promise<void>;
|
|
45
56
|
};
|
|
46
57
|
|
|
@@ -57,21 +68,21 @@ export class FullProverTest {
|
|
|
57
68
|
static TOKEN_DECIMALS = 18n;
|
|
58
69
|
private snapshotManager: ISnapshotManager;
|
|
59
70
|
logger: Logger;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
accounts:
|
|
63
|
-
deployedAccounts!: InitialAccountData[];
|
|
71
|
+
deployedAccounts: InitialAccountData[] = [];
|
|
72
|
+
wallets: AccountWalletWithSecretKey[] = [];
|
|
73
|
+
accounts: CompleteAddress[] = [];
|
|
64
74
|
fakeProofsAsset!: TokenContract;
|
|
65
75
|
tokenSim!: TokenSimulator;
|
|
66
76
|
aztecNode!: AztecNode;
|
|
67
77
|
aztecNodeAdmin!: AztecNodeAdmin;
|
|
78
|
+
pxe!: PXEService;
|
|
68
79
|
cheatCodes!: CheatCodes;
|
|
69
80
|
blobSink!: BlobSinkServer;
|
|
70
81
|
private provenComponents: ProvenSetup[] = [];
|
|
71
82
|
private bbConfigCleanup?: () => Promise<void>;
|
|
72
83
|
private acvmConfigCleanup?: () => Promise<void>;
|
|
73
84
|
circuitProofVerifier?: ClientProtocolCircuitVerifier;
|
|
74
|
-
|
|
85
|
+
provenAssets: TokenContract[] = [];
|
|
75
86
|
private context!: SubsystemsContext;
|
|
76
87
|
private proverNode!: ProverNode;
|
|
77
88
|
private simulatedProverNode!: ProverNode;
|
|
@@ -104,11 +115,13 @@ export class FullProverTest {
|
|
|
104
115
|
await this.snapshotManager.snapshot(
|
|
105
116
|
'2_accounts',
|
|
106
117
|
deployAccounts(2, this.logger),
|
|
107
|
-
({ deployedAccounts }, {
|
|
118
|
+
async ({ deployedAccounts }, { pxe }) => {
|
|
108
119
|
this.deployedAccounts = deployedAccounts;
|
|
109
|
-
this.
|
|
110
|
-
|
|
111
|
-
|
|
120
|
+
this.wallets = await Promise.all(
|
|
121
|
+
deployedAccounts.map(a => getSchnorrWalletWithSecretKey(pxe, a.secret, a.signingKey, a.salt)),
|
|
122
|
+
);
|
|
123
|
+
this.accounts = this.wallets.map(w => w.getCompleteAddress());
|
|
124
|
+
this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
112
125
|
},
|
|
113
126
|
);
|
|
114
127
|
|
|
@@ -118,17 +131,17 @@ export class FullProverTest {
|
|
|
118
131
|
// Create the token contract state.
|
|
119
132
|
// Move this account thing to addAccounts above?
|
|
120
133
|
this.logger.verbose(`Public deploy accounts...`);
|
|
121
|
-
await publicDeployAccounts(this.
|
|
134
|
+
await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2));
|
|
122
135
|
|
|
123
136
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
124
137
|
const asset = await TokenContract.deploy(
|
|
125
|
-
this.
|
|
138
|
+
this.wallets[0],
|
|
126
139
|
this.accounts[0],
|
|
127
140
|
FullProverTest.TOKEN_NAME,
|
|
128
141
|
FullProverTest.TOKEN_SYMBOL,
|
|
129
142
|
FullProverTest.TOKEN_DECIMALS,
|
|
130
143
|
)
|
|
131
|
-
.send({ from: this.
|
|
144
|
+
.send({ from: this.wallets[0].getAddress() })
|
|
132
145
|
.deployed();
|
|
133
146
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
134
147
|
|
|
@@ -136,19 +149,19 @@ export class FullProverTest {
|
|
|
136
149
|
},
|
|
137
150
|
async ({ tokenContractAddress }) => {
|
|
138
151
|
// Restore the token contract state.
|
|
139
|
-
this.fakeProofsAsset = await TokenContract.at(tokenContractAddress, this.
|
|
152
|
+
this.fakeProofsAsset = await TokenContract.at(tokenContractAddress, this.wallets[0]);
|
|
140
153
|
this.logger.verbose(`Token contract address: ${this.fakeProofsAsset.address}`);
|
|
141
154
|
|
|
142
155
|
this.tokenSim = new TokenSimulator(
|
|
143
156
|
this.fakeProofsAsset,
|
|
144
|
-
this.
|
|
145
|
-
this.
|
|
157
|
+
this.wallets[0],
|
|
158
|
+
this.wallets[0].getAddress(),
|
|
146
159
|
this.logger,
|
|
147
|
-
this.accounts,
|
|
160
|
+
this.accounts.map(a => a.address),
|
|
148
161
|
);
|
|
149
162
|
|
|
150
|
-
expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0] })).toBe(
|
|
151
|
-
this.accounts[0].toBigInt(),
|
|
163
|
+
expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0].address })).toBe(
|
|
164
|
+
this.accounts[0].address.toBigInt(),
|
|
152
165
|
);
|
|
153
166
|
},
|
|
154
167
|
);
|
|
@@ -162,6 +175,7 @@ export class FullProverTest {
|
|
|
162
175
|
|
|
163
176
|
this.simulatedProverNode = this.context.proverNode!;
|
|
164
177
|
({
|
|
178
|
+
pxe: this.pxe,
|
|
165
179
|
aztecNode: this.aztecNode,
|
|
166
180
|
deployL1ContractsValues: this.l1Contracts,
|
|
167
181
|
cheatCodes: this.cheatCodes,
|
|
@@ -210,31 +224,51 @@ export class FullProverTest {
|
|
|
210
224
|
await this.context.cheatCodes.rollup.markAsProven();
|
|
211
225
|
|
|
212
226
|
this.logger.verbose(`Main setup completed, initializing full prover PXE, Node, and Prover Node`);
|
|
213
|
-
const { wallet: provenWallet, teardown: provenTeardown } = await setupPXEAndGetWallet(
|
|
214
|
-
this.aztecNode,
|
|
215
|
-
{
|
|
216
|
-
proverEnabled: this.realProofs,
|
|
217
|
-
bbBinaryPath: bbConfig?.bbBinaryPath,
|
|
218
|
-
bbWorkingDirectory: bbConfig?.bbWorkingDirectory,
|
|
219
|
-
},
|
|
220
|
-
undefined,
|
|
221
|
-
true,
|
|
222
|
-
);
|
|
223
|
-
this.logger.debug(`Contract address ${this.fakeProofsAsset.address}`);
|
|
224
|
-
await provenWallet.registerContract(this.fakeProofsAsset);
|
|
225
|
-
|
|
226
227
|
for (let i = 0; i < 2; i++) {
|
|
227
|
-
await
|
|
228
|
-
|
|
229
|
-
|
|
228
|
+
const result = await setupPXEService(
|
|
229
|
+
this.aztecNode,
|
|
230
|
+
{
|
|
231
|
+
proverEnabled: this.realProofs,
|
|
232
|
+
bbBinaryPath: bbConfig?.bbBinaryPath,
|
|
233
|
+
bbWorkingDirectory: bbConfig?.bbWorkingDirectory,
|
|
234
|
+
},
|
|
235
|
+
undefined,
|
|
236
|
+
true,
|
|
237
|
+
);
|
|
238
|
+
this.logger.debug(`Contract address ${this.fakeProofsAsset.address}`);
|
|
239
|
+
await result.pxe.registerContract(this.fakeProofsAsset);
|
|
240
|
+
|
|
241
|
+
for (let i = 0; i < 2; i++) {
|
|
242
|
+
await result.pxe.registerAccount(
|
|
243
|
+
this.deployedAccounts[i].secret,
|
|
244
|
+
this.wallets[i].getCompleteAddress().partialAddress,
|
|
245
|
+
);
|
|
246
|
+
await this.pxe.registerAccount(
|
|
247
|
+
this.deployedAccounts[i].secret,
|
|
248
|
+
this.wallets[i].getCompleteAddress().partialAddress,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const account = await getSchnorrAccount(
|
|
253
|
+
result.pxe,
|
|
254
|
+
this.deployedAccounts[0].secret,
|
|
255
|
+
this.deployedAccounts[0].signingKey,
|
|
256
|
+
this.deployedAccounts[0].salt,
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
await result.pxe.registerContract({
|
|
260
|
+
instance: account.getInstance(),
|
|
261
|
+
artifact: SchnorrAccountContractArtifact,
|
|
262
|
+
});
|
|
230
263
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
264
|
+
const provenWallet = await account.getWallet();
|
|
265
|
+
const asset = await TokenContract.at(this.fakeProofsAsset.address, provenWallet);
|
|
266
|
+
this.provenComponents.push({
|
|
267
|
+
pxe: result.pxe,
|
|
268
|
+
teardown: result.teardown,
|
|
269
|
+
});
|
|
270
|
+
this.provenAssets.push(asset);
|
|
271
|
+
}
|
|
238
272
|
this.logger.info(`Full prover PXE started`);
|
|
239
273
|
|
|
240
274
|
// Shutdown the current, simulated prover node
|
|
@@ -335,12 +369,15 @@ export class FullProverTest {
|
|
|
335
369
|
|
|
336
370
|
this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
|
|
337
371
|
await asset.methods
|
|
338
|
-
.mint_to_public(accounts[0], privateAmount + publicAmount)
|
|
339
|
-
.send({ from: accounts[0] })
|
|
372
|
+
.mint_to_public(accounts[0].address, privateAmount + publicAmount)
|
|
373
|
+
.send({ from: accounts[0].address })
|
|
340
374
|
.wait();
|
|
341
375
|
|
|
342
376
|
this.logger.verbose(`Transferring ${privateAmount} to private...`);
|
|
343
|
-
await asset.methods
|
|
377
|
+
await asset.methods
|
|
378
|
+
.transfer_to_private(accounts[0].address, privateAmount)
|
|
379
|
+
.send({ from: accounts[0].address })
|
|
380
|
+
.wait();
|
|
344
381
|
|
|
345
382
|
this.logger.verbose(`Minting complete.`);
|
|
346
383
|
|
|
@@ -349,7 +386,7 @@ export class FullProverTest {
|
|
|
349
386
|
async ({ amount }) => {
|
|
350
387
|
const {
|
|
351
388
|
fakeProofsAsset: asset,
|
|
352
|
-
accounts: [address],
|
|
389
|
+
accounts: [{ address }],
|
|
353
390
|
tokenSim,
|
|
354
391
|
} = this;
|
|
355
392
|
tokenSim.mintPublic(address, amount);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Logger, fileURLToPath } from '@aztec/aztec.js';
|
|
2
2
|
import type { BBConfig } from '@aztec/bb-prover';
|
|
3
3
|
import { tryRmDir } from '@aztec/foundation/fs';
|
|
4
4
|
|
|
5
5
|
import fs from 'node:fs/promises';
|
|
6
6
|
import { tmpdir } from 'node:os';
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import { fileURLToPath } from 'url';
|
|
9
8
|
|
|
10
9
|
const {
|
|
11
10
|
BB_RELEASE_DIR = 'barretenberg/cpp/build/bin',
|
|
@@ -23,7 +22,7 @@ export const getBBConfig = async (
|
|
|
23
22
|
try {
|
|
24
23
|
const bbBinaryPath =
|
|
25
24
|
BB_BINARY_PATH ??
|
|
26
|
-
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb
|
|
25
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb');
|
|
27
26
|
await fs.access(bbBinaryPath, fs.constants.R_OK);
|
|
28
27
|
|
|
29
28
|
let bbWorkingDirectory: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Logger } from '@aztec/aztec.js
|
|
1
|
+
import type { Logger } from '@aztec/aztec.js';
|
|
2
2
|
import { type DeployL1ContractsArgs, type L1ContractsConfig, deployL1Contracts } from '@aztec/ethereum';
|
|
3
3
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
-
import {
|
|
4
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
5
5
|
|
|
6
6
|
import type { HDAccount, PrivateKeyAccount } from 'viem';
|
|
7
7
|
import { foundry } from 'viem/chains';
|
|
@@ -16,7 +16,7 @@ export const setupL1Contracts = async (
|
|
|
16
16
|
) => {
|
|
17
17
|
const l1Data = await deployL1Contracts([l1RpcUrl], account, foundry, logger, {
|
|
18
18
|
vkTreeRoot: getVKTreeRoot(),
|
|
19
|
-
|
|
19
|
+
protocolContractTreeRoot,
|
|
20
20
|
salt: undefined,
|
|
21
21
|
realVerifier: false,
|
|
22
22
|
...args,
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
* Test fixtures and utilities to set up and run a test using multiple validators
|
|
3
3
|
*/
|
|
4
4
|
import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
5
|
+
import type { SentTx } from '@aztec/aztec.js';
|
|
5
6
|
import { SecretValue } from '@aztec/foundation/config';
|
|
6
7
|
import { addLogNameHandler, removeLogNameHandler } from '@aztec/foundation/log';
|
|
7
8
|
import { bufferToHex } from '@aztec/foundation/string';
|
|
8
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
9
10
|
import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
|
|
11
|
+
import type { PXEService } from '@aztec/pxe/server';
|
|
10
12
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
11
13
|
|
|
12
14
|
import getPort from 'get-port';
|
|
@@ -21,6 +23,12 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
|
21
23
|
// to avoid running validators with the same key
|
|
22
24
|
export const ATTESTER_PRIVATE_KEYS_START_INDEX = 3;
|
|
23
25
|
|
|
26
|
+
export interface NodeContext {
|
|
27
|
+
node: AztecNodeService;
|
|
28
|
+
pxeService: PXEService;
|
|
29
|
+
txs: SentTx[];
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[] {
|
|
25
33
|
const privateKeys: `0x${string}`[] = [];
|
|
26
34
|
// Do not start from 0 as it is used during setup
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
2
|
+
import { type InitialAccountData, deployFundedSchnorrAccounts, generateSchnorrAccounts } from '@aztec/accounts/testing';
|
|
3
3
|
import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
type AztecAddress,
|
|
6
|
+
type AztecNode,
|
|
7
|
+
BatchCall,
|
|
8
|
+
type CompleteAddress,
|
|
9
|
+
type ContractFunctionInteraction,
|
|
10
|
+
DefaultWaitForProvenOpts,
|
|
11
|
+
EthAddress,
|
|
12
|
+
type Logger,
|
|
13
|
+
type PXE,
|
|
14
|
+
type Wallet,
|
|
15
|
+
getContractClassFromArtifact,
|
|
16
|
+
waitForProven,
|
|
17
|
+
} from '@aztec/aztec.js';
|
|
7
18
|
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
8
|
-
import type { Logger } from '@aztec/aztec.js/log';
|
|
9
|
-
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
10
|
-
import type { Wallet } from '@aztec/aztec.js/wallet';
|
|
11
19
|
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
12
20
|
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
13
21
|
import {
|
|
@@ -26,11 +34,10 @@ import { createLogger } from '@aztec/foundation/log';
|
|
|
26
34
|
import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
27
35
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
28
36
|
import type { ProverNode } from '@aztec/prover-node';
|
|
29
|
-
import {
|
|
37
|
+
import { type PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
30
38
|
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
31
39
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
32
40
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
33
|
-
import { TestWallet } from '@aztec/test-wallet/server';
|
|
34
41
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
35
42
|
|
|
36
43
|
import type { Anvil } from '@viem/anvil';
|
|
@@ -63,7 +70,7 @@ export type SubsystemsContext = {
|
|
|
63
70
|
bbConfig: any;
|
|
64
71
|
aztecNode: AztecNodeService;
|
|
65
72
|
aztecNodeConfig: AztecNodeConfig;
|
|
66
|
-
|
|
73
|
+
pxe: PXEService;
|
|
67
74
|
deployL1ContractsValues: DeployL1ContractsReturnType;
|
|
68
75
|
proverNode?: ProverNode;
|
|
69
76
|
watcher: AnvilTestWatcher;
|
|
@@ -199,7 +206,7 @@ class SnapshotManager implements ISnapshotManager {
|
|
|
199
206
|
await restore(snapshotData, context);
|
|
200
207
|
|
|
201
208
|
// Save the snapshot data.
|
|
202
|
-
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls
|
|
209
|
+
const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
|
|
203
210
|
const anvilStateFile = `${this.livePath}/anvil.dat`;
|
|
204
211
|
await ethCheatCodes.dumpChainState(anvilStateFile);
|
|
205
212
|
writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
|
|
@@ -346,9 +353,7 @@ async function setupFromFresh(
|
|
|
346
353
|
const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
|
|
347
354
|
const anvil = res.anvil;
|
|
348
355
|
aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
|
|
349
|
-
|
|
350
|
-
const dateProvider = new TestDateProvider();
|
|
351
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
356
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
352
357
|
|
|
353
358
|
// Deploy our L1 contracts.
|
|
354
359
|
logger.verbose('Deploying L1 contracts...');
|
|
@@ -376,8 +381,10 @@ async function setupFromFresh(
|
|
|
376
381
|
aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
|
|
377
382
|
aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
|
|
378
383
|
|
|
384
|
+
const dateProvider = new TestDateProvider();
|
|
385
|
+
|
|
379
386
|
const watcher = new AnvilTestWatcher(
|
|
380
|
-
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls
|
|
387
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
381
388
|
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
382
389
|
deployL1ContractsValues.l1Client,
|
|
383
390
|
dateProvider,
|
|
@@ -436,12 +443,13 @@ async function setupFromFresh(
|
|
|
436
443
|
}
|
|
437
444
|
|
|
438
445
|
logger.verbose('Creating pxe...');
|
|
439
|
-
const pxeConfig =
|
|
446
|
+
const pxeConfig = getPXEServiceConfig();
|
|
440
447
|
pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
|
|
441
448
|
// Only enable proving if specifically requested.
|
|
442
449
|
pxeConfig.proverEnabled = !!opts.realProofs;
|
|
443
|
-
const
|
|
444
|
-
|
|
450
|
+
const pxe = await createPXEService(aztecNode, pxeConfig);
|
|
451
|
+
|
|
452
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
445
453
|
|
|
446
454
|
if (statePath) {
|
|
447
455
|
writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
|
|
@@ -452,7 +460,7 @@ async function setupFromFresh(
|
|
|
452
460
|
aztecNodeConfig,
|
|
453
461
|
anvil,
|
|
454
462
|
aztecNode,
|
|
455
|
-
|
|
463
|
+
pxe,
|
|
456
464
|
sequencer: aztecNode.getSequencer()!,
|
|
457
465
|
acvmConfig,
|
|
458
466
|
bbConfig,
|
|
@@ -497,9 +505,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
497
505
|
aztecNodeConfig.l1RpcUrls = [rpcUrl];
|
|
498
506
|
// Load anvil state.
|
|
499
507
|
const anvilStateFile = `${statePath}/anvil.dat`;
|
|
500
|
-
|
|
501
|
-
const dateProvider = new TestDateProvider();
|
|
502
|
-
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
|
|
508
|
+
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
503
509
|
await ethCheatCodes.loadChainState(anvilStateFile);
|
|
504
510
|
|
|
505
511
|
// TODO: Encapsulate this in a NativeAcvm impl.
|
|
@@ -518,8 +524,9 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
518
524
|
logger.verbose('Creating ETH clients...');
|
|
519
525
|
const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
|
|
520
526
|
|
|
527
|
+
const dateProvider = new TestDateProvider();
|
|
521
528
|
const watcher = new AnvilTestWatcher(
|
|
522
|
-
|
|
529
|
+
new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
|
|
523
530
|
aztecNodeConfig.l1Contracts.rollupAddress,
|
|
524
531
|
l1Client,
|
|
525
532
|
dateProvider,
|
|
@@ -566,16 +573,17 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
566
573
|
}
|
|
567
574
|
|
|
568
575
|
logger.verbose('Creating pxe...');
|
|
569
|
-
const pxeConfig =
|
|
576
|
+
const pxeConfig = getPXEServiceConfig();
|
|
570
577
|
pxeConfig.dataDirectory = statePath;
|
|
571
|
-
const
|
|
572
|
-
|
|
578
|
+
const pxe = await createPXEService(aztecNode, pxeConfig);
|
|
579
|
+
|
|
580
|
+
const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
|
|
573
581
|
|
|
574
582
|
return {
|
|
575
583
|
aztecNodeConfig,
|
|
576
584
|
anvil,
|
|
577
585
|
aztecNode,
|
|
578
|
-
|
|
586
|
+
pxe,
|
|
579
587
|
sequencer: aztecNode.getSequencer()!,
|
|
580
588
|
acvmConfig,
|
|
581
589
|
bbConfig,
|
|
@@ -599,29 +607,20 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
599
607
|
* The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
|
|
600
608
|
*/
|
|
601
609
|
export const deployAccounts =
|
|
602
|
-
(numberOfAccounts: number, logger: Logger) =>
|
|
603
|
-
async ({
|
|
610
|
+
(numberOfAccounts: number, logger: Logger, waitUntilProven = false) =>
|
|
611
|
+
async ({ pxe, initialFundedAccounts }: { pxe: PXE; initialFundedAccounts: InitialAccountData[] }) => {
|
|
604
612
|
if (initialFundedAccounts.length < numberOfAccounts) {
|
|
605
613
|
throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
|
|
606
614
|
}
|
|
607
615
|
|
|
608
616
|
logger.verbose('Deploying accounts funded with fee juice...');
|
|
609
617
|
const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
);
|
|
617
|
-
const deployMethod = await accountManager.getDeployMethod();
|
|
618
|
-
await deployMethod
|
|
619
|
-
.send({
|
|
620
|
-
from: AztecAddress.ZERO,
|
|
621
|
-
skipClassPublication: i !== 0, // Publish the contract class at most once.
|
|
622
|
-
})
|
|
623
|
-
.wait();
|
|
624
|
-
}
|
|
618
|
+
await deployFundedSchnorrAccounts(
|
|
619
|
+
pxe,
|
|
620
|
+
deployedAccounts,
|
|
621
|
+
undefined,
|
|
622
|
+
waitUntilProven ? DefaultWaitForProvenOpts : undefined,
|
|
623
|
+
);
|
|
625
624
|
|
|
626
625
|
return { deployedAccounts };
|
|
627
626
|
};
|
|
@@ -632,34 +631,35 @@ export const deployAccounts =
|
|
|
632
631
|
* @param sender - Wallet to send the deployment tx.
|
|
633
632
|
* @param accountsToDeploy - Which accounts to publicly deploy.
|
|
634
633
|
* @param waitUntilProven - Whether to wait for the tx to be proven.
|
|
635
|
-
* @param
|
|
634
|
+
* @param pxeOrNode - PXE or AztecNode to wait for proven.
|
|
636
635
|
*/
|
|
637
636
|
export async function publicDeployAccounts(
|
|
638
|
-
|
|
639
|
-
accountsToDeploy: AztecAddress[],
|
|
637
|
+
sender: Wallet,
|
|
638
|
+
accountsToDeploy: (CompleteAddress | AztecAddress)[],
|
|
640
639
|
waitUntilProven = false,
|
|
641
|
-
|
|
640
|
+
pxeOrNode?: PXE | AztecNode,
|
|
642
641
|
) {
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
642
|
+
const accountAddressesToDeploy = accountsToDeploy.map(a => ('address' in a ? a.address : a));
|
|
643
|
+
const instances = (
|
|
644
|
+
await Promise.all(accountAddressesToDeploy.map(account => sender.getContractMetadata(account)))
|
|
645
|
+
).map(metadata => metadata.contractInstance);
|
|
646
646
|
|
|
647
647
|
const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
|
|
648
|
-
const alreadyRegistered = (await
|
|
648
|
+
const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
649
649
|
|
|
650
650
|
const calls: ContractFunctionInteraction[] = await Promise.all([
|
|
651
|
-
...(!alreadyRegistered ? [publishContractClass(
|
|
652
|
-
...instances.map(instance => publishInstance(
|
|
651
|
+
...(!alreadyRegistered ? [publishContractClass(sender, SchnorrAccountContractArtifact)] : []),
|
|
652
|
+
...instances.map(instance => publishInstance(sender, instance!)),
|
|
653
653
|
]);
|
|
654
654
|
|
|
655
|
-
const batch = new BatchCall(
|
|
655
|
+
const batch = new BatchCall(sender, calls);
|
|
656
656
|
|
|
657
|
-
const txReceipt = await batch.send({ from:
|
|
657
|
+
const txReceipt = await batch.send({ from: accountAddressesToDeploy[0] }).wait();
|
|
658
658
|
if (waitUntilProven) {
|
|
659
|
-
if (!
|
|
660
|
-
throw new Error('Need to provide
|
|
659
|
+
if (!pxeOrNode) {
|
|
660
|
+
throw new Error('Need to provide a PXE or AztecNode to wait for proven.');
|
|
661
661
|
} else {
|
|
662
|
-
await waitForProven(
|
|
662
|
+
await waitForProven(pxeOrNode, txReceipt);
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
665
|
}
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
import type
|
|
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';
|
|
1
|
+
import { type AztecAddress, BatchCall, type Logger, type Wallet } from '@aztec/aztec.js';
|
|
5
2
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
// docs:start:token_utils
|
|
5
|
+
|
|
6
|
+
export async function deployToken(
|
|
7
|
+
adminWallet: Wallet,
|
|
8
|
+
deployerAddress: AztecAddress,
|
|
9
|
+
initialAdminBalance: bigint,
|
|
10
|
+
logger: Logger,
|
|
11
|
+
) {
|
|
8
12
|
logger.info(`Deploying Token contract...`);
|
|
9
|
-
const contract = await TokenContract.deploy(
|
|
10
|
-
.send({ from:
|
|
13
|
+
const contract = await TokenContract.deploy(adminWallet, deployerAddress, 'TokenName', 'TokenSymbol', 18)
|
|
14
|
+
.send({ from: deployerAddress })
|
|
11
15
|
.deployed();
|
|
12
16
|
|
|
13
17
|
if (initialAdminBalance > 0n) {
|
|
14
|
-
|
|
18
|
+
// Minter is minting to herself so contract as minter is the same as contract as recipient
|
|
19
|
+
await mintTokensToPrivate(contract, deployerAddress, adminWallet, deployerAddress, initialAdminBalance);
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
logger.info('L2 contract deployed');
|
|
@@ -22,11 +27,14 @@ export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAd
|
|
|
22
27
|
export async function mintTokensToPrivate(
|
|
23
28
|
token: TokenContract,
|
|
24
29
|
minter: AztecAddress,
|
|
30
|
+
minterWallet: Wallet,
|
|
25
31
|
recipient: AztecAddress,
|
|
26
32
|
amount: bigint,
|
|
27
33
|
) {
|
|
28
|
-
await token.
|
|
34
|
+
const tokenAsMinter = await TokenContract.at(token.address, minterWallet);
|
|
35
|
+
await tokenAsMinter.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
|
|
29
36
|
}
|
|
37
|
+
// docs:end:token_utils
|
|
30
38
|
|
|
31
39
|
export async function expectTokenBalance(
|
|
32
40
|
wallet: Wallet,
|
|
@@ -43,19 +51,19 @@ export async function expectTokenBalance(
|
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
export async function mintNotes(
|
|
46
|
-
|
|
54
|
+
sender: Wallet,
|
|
47
55
|
minter: AztecAddress,
|
|
48
56
|
recipient: AztecAddress,
|
|
49
57
|
asset: TokenContract,
|
|
50
58
|
noteAmounts: bigint[],
|
|
51
59
|
): Promise<bigint> {
|
|
52
|
-
// We can only mint
|
|
60
|
+
// We can only mint 4 notes at a time, since that's the maximum number of calls our entrypoints allow
|
|
53
61
|
// TODO(#13024): mint as many notes as possible in a single tx
|
|
54
|
-
const notesPerIteration =
|
|
62
|
+
const notesPerIteration = 4;
|
|
55
63
|
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
|
|
56
64
|
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
|
|
57
65
|
const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
|
|
58
|
-
await new BatchCall(
|
|
66
|
+
await new BatchCall(sender, actions).send({ from: minter }).wait();
|
|
59
67
|
}
|
|
60
68
|
|
|
61
69
|
return noteAmounts.reduce((prev, curr) => prev + curr, 0n);
|