@aztec/end-to-end 1.2.0 → 2.0.0-nightly.20250813
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 -2
- package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/benchmark.js +4 -2
- package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +33 -15
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +7 -4
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +11 -3
- 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 +59 -24
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +3 -2
- 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 +13 -10
- package/dest/e2e_deploy_contract/deploy_test.d.ts +1 -1
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +7 -6
- package/dest/e2e_epochs/epochs_test.d.ts +16 -2
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +65 -7
- package/dest/e2e_fees/bridging_race.notest.js +3 -1
- package/dest/e2e_fees/fees_test.d.ts +5 -4
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +44 -59
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +3 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +17 -12
- package/dest/e2e_p2p/p2p_network.d.ts +7 -4
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +43 -22
- package/dest/e2e_p2p/shared.d.ts +3 -3
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +16 -12
- package/dest/e2e_token_contract/token_contract_test.d.ts +8 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +48 -23
- package/dest/fixtures/e2e_prover_test.d.ts +1 -1
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +27 -10
- package/dest/fixtures/setup_p2p_test.d.ts +4 -1
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +39 -8
- package/dest/fixtures/snapshot_manager.d.ts +3 -1
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +20 -17
- package/dest/fixtures/token_utils.d.ts +3 -3
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +14 -10
- package/dest/fixtures/utils.d.ts +23 -8
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +88 -56
- package/dest/integration_l1_publisher/write_json.d.ts +8 -0
- package/dest/integration_l1_publisher/write_json.d.ts.map +1 -0
- package/dest/integration_l1_publisher/write_json.js +57 -0
- package/dest/sample-dapp/connect.d.mts +2 -0
- package/dest/sample-dapp/connect.d.mts.map +1 -0
- package/dest/sample-dapp/connect.js +1 -1
- package/dest/sample-dapp/contracts.d.mts +3 -0
- package/dest/sample-dapp/contracts.d.mts.map +1 -0
- package/dest/sample-dapp/contracts.js +1 -1
- package/dest/sample-dapp/deploy.d.mts +3 -0
- package/dest/sample-dapp/deploy.d.mts.map +1 -0
- package/dest/sample-dapp/deploy.js +4 -1
- package/dest/sample-dapp/index.d.mts +2 -0
- package/dest/sample-dapp/index.d.mts.map +1 -0
- package/dest/sample-dapp/index.js +18 -8
- package/dest/shared/cross_chain_test_harness.d.ts +6 -3
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +50 -20
- package/dest/shared/gas_portal_test_harness.d.ts +3 -3
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +21 -6
- package/dest/shared/uniswap_l1_l2.d.ts +1 -1
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +45 -22
- package/dest/simulators/lending_simulator.d.ts +1 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +6 -2
- package/dest/simulators/token_simulator.d.ts +2 -1
- package/dest/simulators/token_simulator.d.ts.map +1 -1
- package/dest/simulators/token_simulator.js +12 -4
- package/dest/spartan/setup_test_wallets.d.ts +7 -0
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +96 -11
- package/dest/spartan/utils.d.ts +23 -3
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +9 -6
- package/package.json +36 -36
- package/src/bench/client_flows/benchmark.ts +8 -3
- package/src/bench/client_flows/client_flows_benchmark.ts +23 -14
- package/src/bench/utils.ts +5 -4
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +47 -26
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +14 -9
- package/src/e2e_deploy_contract/deploy_test.ts +7 -7
- package/src/e2e_epochs/epochs_test.ts +97 -25
- package/src/e2e_fees/bridging_race.notest.ts +1 -1
- package/src/e2e_fees/fees_test.ts +55 -82
- package/src/e2e_nested_contract/nested_contract_test.ts +16 -11
- package/src/e2e_p2p/p2p_network.ts +51 -26
- package/src/e2e_p2p/shared.ts +14 -12
- package/src/e2e_token_contract/token_contract_test.ts +38 -36
- package/src/fixtures/e2e_prover_test.ts +17 -10
- package/src/fixtures/setup_p2p_test.ts +51 -9
- package/src/fixtures/snapshot_manager.ts +24 -17
- package/src/fixtures/token_utils.ts +14 -9
- package/src/fixtures/utils.ts +116 -57
- package/src/guides/up_quick_start.sh +1 -1
- package/src/integration_l1_publisher/write_json.ts +74 -0
- package/src/sample-dapp/connect.mjs +1 -1
- package/src/sample-dapp/contracts.mjs +1 -1
- package/src/sample-dapp/deploy.mjs +3 -3
- package/src/sample-dapp/index.mjs +11 -8
- package/src/shared/cross_chain_test_harness.ts +31 -18
- package/src/shared/gas_portal_test_harness.ts +17 -7
- package/src/shared/uniswap_l1_l2.ts +28 -24
- package/src/simulators/lending_simulator.ts +3 -3
- package/src/simulators/token_simulator.ts +12 -3
- package/src/spartan/setup_test_wallets.ts +130 -19
- package/src/spartan/utils.ts +10 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
2
|
-
import { type AccountWallet,
|
|
2
|
+
import { type AccountWallet, AztecAddress, type AztecNode, type Logger, createLogger } from '@aztec/aztec.js';
|
|
3
3
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
4
|
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
5
5
|
|
|
@@ -23,13 +23,18 @@ export class TokenContractTest {
|
|
|
23
23
|
static TOKEN_DECIMALS = 18n;
|
|
24
24
|
private snapshotManager: ISnapshotManager;
|
|
25
25
|
logger: Logger;
|
|
26
|
-
wallets: AccountWallet[] = [];
|
|
27
|
-
accounts: CompleteAddress[] = [];
|
|
28
26
|
asset!: TokenContract;
|
|
29
27
|
tokenSim!: TokenSimulator;
|
|
30
|
-
badAccount!: InvalidAccountContract;
|
|
31
28
|
node!: AztecNode;
|
|
32
29
|
|
|
30
|
+
badAccount!: InvalidAccountContract;
|
|
31
|
+
admin!: AccountWallet;
|
|
32
|
+
adminAddress!: AztecAddress;
|
|
33
|
+
account1!: AccountWallet;
|
|
34
|
+
account1Address!: AztecAddress;
|
|
35
|
+
account2!: AccountWallet;
|
|
36
|
+
account2Address!: AztecAddress;
|
|
37
|
+
|
|
33
38
|
constructor(testName: string) {
|
|
34
39
|
this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
|
|
35
40
|
this.snapshotManager = createSnapshotManager(`e2e_token_contract/${testName}`, dataPath, {
|
|
@@ -51,8 +56,9 @@ export class TokenContractTest {
|
|
|
51
56
|
deployAccounts(3, this.logger),
|
|
52
57
|
async ({ deployedAccounts }, { pxe, aztecNode }) => {
|
|
53
58
|
this.node = aztecNode;
|
|
54
|
-
|
|
55
|
-
this.
|
|
59
|
+
const wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
60
|
+
[this.admin, this.account1, this.account2] = wallets;
|
|
61
|
+
[this.adminAddress, this.account1Address, this.account2Address] = wallets.map(w => w.getAddress());
|
|
56
62
|
},
|
|
57
63
|
);
|
|
58
64
|
|
|
@@ -62,42 +68,42 @@ export class TokenContractTest {
|
|
|
62
68
|
// Create the token contract state.
|
|
63
69
|
// Move this account thing to addAccounts above?
|
|
64
70
|
this.logger.verbose(`Public deploy accounts...`);
|
|
65
|
-
await publicDeployAccounts(this.
|
|
71
|
+
await publicDeployAccounts(this.admin, [this.adminAddress, this.account1Address]);
|
|
66
72
|
|
|
67
73
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
68
74
|
const asset = await TokenContract.deploy(
|
|
69
|
-
this.
|
|
70
|
-
this.
|
|
75
|
+
this.admin,
|
|
76
|
+
this.adminAddress,
|
|
71
77
|
TokenContractTest.TOKEN_NAME,
|
|
72
78
|
TokenContractTest.TOKEN_SYMBOL,
|
|
73
79
|
TokenContractTest.TOKEN_DECIMALS,
|
|
74
80
|
)
|
|
75
|
-
.send()
|
|
81
|
+
.send({ from: this.adminAddress })
|
|
76
82
|
.deployed();
|
|
77
83
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
78
84
|
|
|
79
85
|
this.logger.verbose(`Deploying bad account...`);
|
|
80
|
-
this.badAccount = await InvalidAccountContract.deploy(this.
|
|
86
|
+
this.badAccount = await InvalidAccountContract.deploy(this.admin).send({ from: this.adminAddress }).deployed();
|
|
81
87
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
82
88
|
|
|
83
89
|
return { tokenContractAddress: asset.address, badAccountAddress: this.badAccount.address };
|
|
84
90
|
},
|
|
85
91
|
async ({ tokenContractAddress, badAccountAddress }) => {
|
|
86
92
|
// Restore the token contract state.
|
|
87
|
-
this.asset = await TokenContract.at(tokenContractAddress, this.
|
|
93
|
+
this.asset = await TokenContract.at(tokenContractAddress, this.admin);
|
|
88
94
|
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
89
95
|
|
|
90
|
-
this.tokenSim = new TokenSimulator(
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
this.accounts.map(a => a.address),
|
|
95
|
-
);
|
|
96
|
+
this.tokenSim = new TokenSimulator(this.asset, this.admin, this.adminAddress, this.logger, [
|
|
97
|
+
this.adminAddress,
|
|
98
|
+
this.account1Address,
|
|
99
|
+
]);
|
|
96
100
|
|
|
97
|
-
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.
|
|
101
|
+
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.admin);
|
|
98
102
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
99
103
|
|
|
100
|
-
expect(await this.asset.methods.get_admin().simulate()).toBe(
|
|
104
|
+
expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
|
|
105
|
+
this.adminAddress.toBigInt(),
|
|
106
|
+
);
|
|
101
107
|
},
|
|
102
108
|
);
|
|
103
109
|
|
|
@@ -125,36 +131,32 @@ export class TokenContractTest {
|
|
|
125
131
|
await this.snapshotManager.snapshot(
|
|
126
132
|
'mint',
|
|
127
133
|
async () => {
|
|
128
|
-
const { asset,
|
|
134
|
+
const { asset, admin, adminAddress } = this;
|
|
129
135
|
const amount = 10000n;
|
|
130
136
|
|
|
131
137
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
132
|
-
await asset.methods.mint_to_public(
|
|
138
|
+
await asset.methods.mint_to_public(adminAddress, amount).send({ from: adminAddress }).wait();
|
|
133
139
|
|
|
134
140
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
135
|
-
await mintTokensToPrivate(asset,
|
|
141
|
+
await mintTokensToPrivate(asset, adminAddress, admin, adminAddress, amount);
|
|
136
142
|
this.logger.verbose(`Minting complete.`);
|
|
137
143
|
|
|
138
144
|
return { amount };
|
|
139
145
|
},
|
|
140
146
|
async ({ amount }) => {
|
|
141
|
-
const {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
} = this;
|
|
146
|
-
tokenSim.mintPublic(address, amount);
|
|
147
|
-
|
|
148
|
-
const publicBalance = await asset.methods.balance_of_public(address).simulate();
|
|
147
|
+
const { asset, adminAddress, tokenSim } = this;
|
|
148
|
+
tokenSim.mintPublic(adminAddress, amount);
|
|
149
|
+
|
|
150
|
+
const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({ from: adminAddress });
|
|
149
151
|
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
150
|
-
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(
|
|
152
|
+
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
|
|
151
153
|
|
|
152
|
-
tokenSim.mintPrivate(
|
|
153
|
-
const privateBalance = await asset.methods.balance_of_private(
|
|
154
|
+
tokenSim.mintPrivate(adminAddress, amount);
|
|
155
|
+
const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({ from: adminAddress });
|
|
154
156
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
155
|
-
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(
|
|
157
|
+
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
|
|
156
158
|
|
|
157
|
-
const totalSupply = await asset.methods.total_supply().simulate();
|
|
159
|
+
const totalSupply = await asset.methods.total_supply().simulate({ from: adminAddress });
|
|
158
160
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
159
161
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
160
162
|
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
type PXE,
|
|
15
15
|
createLogger,
|
|
16
16
|
} from '@aztec/aztec.js';
|
|
17
|
-
import { CheatCodes } from '@aztec/aztec
|
|
17
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
18
18
|
import {
|
|
19
19
|
BBCircuitVerifier,
|
|
20
20
|
type ClientProtocolCircuitVerifier,
|
|
@@ -141,7 +141,7 @@ export class FullProverTest {
|
|
|
141
141
|
FullProverTest.TOKEN_SYMBOL,
|
|
142
142
|
FullProverTest.TOKEN_DECIMALS,
|
|
143
143
|
)
|
|
144
|
-
.send()
|
|
144
|
+
.send({ from: this.wallets[0].getAddress() })
|
|
145
145
|
.deployed();
|
|
146
146
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
147
147
|
|
|
@@ -155,11 +155,14 @@ export class FullProverTest {
|
|
|
155
155
|
this.tokenSim = new TokenSimulator(
|
|
156
156
|
this.fakeProofsAsset,
|
|
157
157
|
this.wallets[0],
|
|
158
|
+
this.wallets[0].getAddress(),
|
|
158
159
|
this.logger,
|
|
159
160
|
this.accounts.map(a => a.address),
|
|
160
161
|
);
|
|
161
162
|
|
|
162
|
-
expect(await this.fakeProofsAsset.methods.get_admin().simulate(
|
|
163
|
+
expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0].address })).toBe(
|
|
164
|
+
this.accounts[0].address.toBigInt(),
|
|
165
|
+
);
|
|
163
166
|
},
|
|
164
167
|
);
|
|
165
168
|
}
|
|
@@ -276,7 +279,7 @@ export class FullProverTest {
|
|
|
276
279
|
this.logger.verbose('Starting archiver for new prover node');
|
|
277
280
|
const archiver = await createArchiver(
|
|
278
281
|
{ ...this.context.aztecNodeConfig, dataDirectory: undefined },
|
|
279
|
-
blobSinkClient,
|
|
282
|
+
{ blobSinkClient },
|
|
280
283
|
{ blockUntilSync: true },
|
|
281
284
|
);
|
|
282
285
|
|
|
@@ -291,7 +294,7 @@ export class FullProverTest {
|
|
|
291
294
|
this.logger.verbose('Starting prover node');
|
|
292
295
|
const proverConfig: ProverNodeConfig = {
|
|
293
296
|
...this.context.aztecNodeConfig,
|
|
294
|
-
|
|
297
|
+
txCollectionNodeRpcUrls: [],
|
|
295
298
|
dataDirectory: undefined,
|
|
296
299
|
proverId: this.proverAddress.toField(),
|
|
297
300
|
realProofs: this.realProofs,
|
|
@@ -303,6 +306,7 @@ export class FullProverTest {
|
|
|
303
306
|
txGatheringIntervalMs: 1000,
|
|
304
307
|
txGatheringBatchSize: 10,
|
|
305
308
|
txGatheringMaxParallelRequestsPerNode: 100,
|
|
309
|
+
txGatheringTimeoutMs: 24_000,
|
|
306
310
|
proverNodeFailedEpochStore: undefined,
|
|
307
311
|
};
|
|
308
312
|
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
@@ -364,11 +368,14 @@ export class FullProverTest {
|
|
|
364
368
|
this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
|
|
365
369
|
await asset.methods
|
|
366
370
|
.mint_to_public(accounts[0].address, privateAmount + publicAmount)
|
|
367
|
-
.send()
|
|
371
|
+
.send({ from: accounts[0].address })
|
|
368
372
|
.wait();
|
|
369
373
|
|
|
370
374
|
this.logger.verbose(`Transferring ${privateAmount} to private...`);
|
|
371
|
-
await asset.methods
|
|
375
|
+
await asset.methods
|
|
376
|
+
.transfer_to_private(accounts[0].address, privateAmount)
|
|
377
|
+
.send({ from: accounts[0].address })
|
|
378
|
+
.wait();
|
|
372
379
|
|
|
373
380
|
this.logger.verbose(`Minting complete.`);
|
|
374
381
|
|
|
@@ -382,16 +389,16 @@ export class FullProverTest {
|
|
|
382
389
|
} = this;
|
|
383
390
|
tokenSim.mintPublic(address, amount);
|
|
384
391
|
|
|
385
|
-
const publicBalance = await asset.methods.balance_of_public(address).simulate();
|
|
392
|
+
const publicBalance = await asset.methods.balance_of_public(address).simulate({ from: address });
|
|
386
393
|
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
387
394
|
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
|
|
388
395
|
|
|
389
396
|
tokenSim.mintPrivate(address, amount);
|
|
390
|
-
const privateBalance = await asset.methods.balance_of_private(address).simulate();
|
|
397
|
+
const privateBalance = await asset.methods.balance_of_private(address).simulate({ from: address });
|
|
391
398
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
392
399
|
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
|
|
393
400
|
|
|
394
|
-
const totalSupply = await asset.methods.total_supply().simulate();
|
|
401
|
+
const totalSupply = await asset.methods.total_supply().simulate({ from: address });
|
|
395
402
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
396
403
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
397
404
|
|
|
@@ -5,7 +5,9 @@ import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
|
|
|
5
5
|
import type { SentTx } from '@aztec/aztec.js';
|
|
6
6
|
import { SecretValue } from '@aztec/foundation/config';
|
|
7
7
|
import { addLogNameHandler, removeLogNameHandler } from '@aztec/foundation/log';
|
|
8
|
+
import { bufferToHex } from '@aztec/foundation/string';
|
|
8
9
|
import type { DateProvider } from '@aztec/foundation/timer';
|
|
10
|
+
import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
|
|
9
11
|
import type { PXEService } from '@aztec/pxe/server';
|
|
10
12
|
import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
|
|
11
13
|
|
|
@@ -13,12 +15,14 @@ import getPort from 'get-port';
|
|
|
13
15
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
14
16
|
|
|
15
17
|
import { TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
|
|
16
|
-
import { getPrivateKeyFromIndex } from './utils.js';
|
|
18
|
+
import { createAndSyncProverNode, getPrivateKeyFromIndex } from './utils.js';
|
|
17
19
|
import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
|
|
18
20
|
|
|
19
21
|
// Setup snapshots will create a node with index 0, and run extra bootstrap with
|
|
20
22
|
// index 1, so all of our loops here need to start from 2 to avoid running validators with the same key
|
|
21
23
|
export const ATTESTER_PRIVATE_KEYS_START_INDEX = 2;
|
|
24
|
+
// We use slasher keys after the first 10 anvil keys, note that this requires anvil to be started with more than the default 10 accounts
|
|
25
|
+
export const SLASHER_PRIVATE_KEYS_START_INDEX = 12;
|
|
22
26
|
|
|
23
27
|
export interface NodeContext {
|
|
24
28
|
node: AztecNodeService;
|
|
@@ -44,6 +48,7 @@ export async function createNodes(
|
|
|
44
48
|
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
45
49
|
dataDirectory?: string,
|
|
46
50
|
metricsPort?: number,
|
|
51
|
+
indexOffset = 0,
|
|
47
52
|
): Promise<AztecNodeService[]> {
|
|
48
53
|
const nodePromises: Promise<AztecNodeService>[] = [];
|
|
49
54
|
const loggerIdStorage = new AsyncLocalStorage<string>();
|
|
@@ -52,16 +57,17 @@ export async function createNodes(
|
|
|
52
57
|
addLogNameHandler(logNameHandler);
|
|
53
58
|
|
|
54
59
|
for (let i = 0; i < numNodes; i++) {
|
|
60
|
+
const index = indexOffset + i;
|
|
55
61
|
// We run on ports from the bootnode upwards
|
|
56
|
-
const port = bootNodePort +
|
|
62
|
+
const port = bootNodePort + 1 + index;
|
|
57
63
|
|
|
58
|
-
const dataDir = dataDirectory ? `${dataDirectory}-${
|
|
64
|
+
const dataDir = dataDirectory ? `${dataDirectory}-${index}` : undefined;
|
|
59
65
|
const nodePromise = createNode(
|
|
60
66
|
config,
|
|
61
67
|
dateProvider,
|
|
62
68
|
port,
|
|
63
69
|
bootstrapNodeEnr,
|
|
64
|
-
|
|
70
|
+
index,
|
|
65
71
|
prefilledPublicData,
|
|
66
72
|
dataDir,
|
|
67
73
|
metricsPort,
|
|
@@ -71,9 +77,9 @@ export async function createNodes(
|
|
|
71
77
|
}
|
|
72
78
|
const nodes = await Promise.all(nodePromises);
|
|
73
79
|
|
|
74
|
-
// Sanity check that we have a sequencer
|
|
80
|
+
// Sanity check that we have a sequencer if required
|
|
75
81
|
const seqClient = nodes[0].getSequencer();
|
|
76
|
-
if (!seqClient) {
|
|
82
|
+
if (!seqClient && config.disableValidator === false) {
|
|
77
83
|
throw new Error('Sequencer not found');
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -101,6 +107,42 @@ export async function createNode(
|
|
|
101
107
|
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
|
|
102
108
|
}
|
|
103
109
|
|
|
110
|
+
export async function createProverNode(
|
|
111
|
+
config: AztecNodeConfig,
|
|
112
|
+
tcpPort: number,
|
|
113
|
+
bootstrapNode: string | undefined,
|
|
114
|
+
addressIndex: number,
|
|
115
|
+
proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>,
|
|
116
|
+
prefilledPublicData?: PublicDataTreeLeaf[],
|
|
117
|
+
dataDirectory?: string,
|
|
118
|
+
metricsPort?: number,
|
|
119
|
+
loggerIdStorage?: AsyncLocalStorage<string>,
|
|
120
|
+
) {
|
|
121
|
+
const createProverNode = async () => {
|
|
122
|
+
const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
|
|
123
|
+
const telemetry = getEndToEndTestTelemetryClient(metricsPort);
|
|
124
|
+
|
|
125
|
+
const proverConfig: Partial<ProverNodeConfig> = {
|
|
126
|
+
p2pIp: `127.0.0.1`,
|
|
127
|
+
p2pPort: tcpPort ?? (await getPort()),
|
|
128
|
+
p2pEnabled: true,
|
|
129
|
+
peerCheckIntervalMS: TEST_PEER_CHECK_INTERVAL_MS,
|
|
130
|
+
blockCheckIntervalMS: 1000,
|
|
131
|
+
bootstrapNodes: bootstrapNode ? [bootstrapNode] : [],
|
|
132
|
+
};
|
|
133
|
+
const aztecNodeRpcTxProvider = undefined;
|
|
134
|
+
return await createAndSyncProverNode(
|
|
135
|
+
bufferToHex(proverNodePrivateKey),
|
|
136
|
+
config,
|
|
137
|
+
{ ...proverConfig, dataDirectory },
|
|
138
|
+
aztecNodeRpcTxProvider,
|
|
139
|
+
prefilledPublicData,
|
|
140
|
+
{ ...proverNodeDeps, telemetry },
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
|
|
144
|
+
}
|
|
145
|
+
|
|
104
146
|
export async function createValidatorConfig(
|
|
105
147
|
config: AztecNodeConfig,
|
|
106
148
|
bootstrapNodeEnr?: string,
|
|
@@ -110,12 +152,12 @@ export async function createValidatorConfig(
|
|
|
110
152
|
) {
|
|
111
153
|
port = port ?? (await getPort());
|
|
112
154
|
|
|
113
|
-
const attesterPrivateKey
|
|
114
|
-
|
|
115
|
-
)!.toString('hex')}`;
|
|
155
|
+
const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
|
|
156
|
+
const slasherPrivateKey = bufferToHex(getPrivateKeyFromIndex(SLASHER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
|
|
116
157
|
|
|
117
158
|
config.validatorPrivateKeys = new SecretValue([attesterPrivateKey]);
|
|
118
159
|
config.publisherPrivateKey = new SecretValue(attesterPrivateKey);
|
|
160
|
+
config.slasherPrivateKey = new SecretValue(slasherPrivateKey);
|
|
119
161
|
|
|
120
162
|
const nodeConfig: AztecNodeConfig = {
|
|
121
163
|
...config,
|
|
@@ -14,16 +14,17 @@ import {
|
|
|
14
14
|
getContractClassFromArtifact,
|
|
15
15
|
waitForProven,
|
|
16
16
|
} from '@aztec/aztec.js';
|
|
17
|
-
import {
|
|
18
|
-
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec
|
|
17
|
+
import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
|
|
18
|
+
import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
|
|
19
19
|
import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
|
|
20
20
|
import {
|
|
21
21
|
type DeployL1ContractsArgs,
|
|
22
22
|
type DeployL1ContractsReturnType,
|
|
23
|
+
FeeAssetArtifact,
|
|
24
|
+
RollupContract,
|
|
23
25
|
createExtendedL1Client,
|
|
24
26
|
deployMulticall3,
|
|
25
27
|
getL1ContractsConfigEnvVars,
|
|
26
|
-
l1Artifacts,
|
|
27
28
|
} from '@aztec/ethereum';
|
|
28
29
|
import { EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
|
|
29
30
|
import { asyncMap } from '@aztec/foundation/async-map';
|
|
@@ -35,6 +36,7 @@ import { resolver, reviver } from '@aztec/foundation/serialize';
|
|
|
35
36
|
import { TestDateProvider } from '@aztec/foundation/timer';
|
|
36
37
|
import type { ProverNode } from '@aztec/prover-node';
|
|
37
38
|
import { type PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
|
|
39
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
38
40
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
39
41
|
import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
|
|
40
42
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
@@ -74,6 +76,7 @@ export type SubsystemsContext = {
|
|
|
74
76
|
proverNode?: ProverNode;
|
|
75
77
|
watcher: AnvilTestWatcher;
|
|
76
78
|
cheatCodes: CheatCodes;
|
|
79
|
+
sequencer: SequencerClient;
|
|
77
80
|
dateProvider: TestDateProvider;
|
|
78
81
|
blobSink: BlobSinkServer;
|
|
79
82
|
initialFundedAccounts: InitialAccountData[];
|
|
@@ -348,7 +351,7 @@ async function setupFromFresh(
|
|
|
348
351
|
const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
|
|
349
352
|
|
|
350
353
|
if (opts.l1StartTime) {
|
|
351
|
-
await ethCheatCodes.warp(opts.l1StartTime);
|
|
354
|
+
await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
|
|
352
355
|
}
|
|
353
356
|
|
|
354
357
|
const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
|
|
@@ -376,22 +379,24 @@ async function setupFromFresh(
|
|
|
376
379
|
if (opts.fundRewardDistributor) {
|
|
377
380
|
// Mints block rewards for 10000 blocks to the rewardDistributor contract
|
|
378
381
|
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
});
|
|
382
|
+
const rollup = new RollupContract(
|
|
383
|
+
deployL1ContractsValues.l1Client,
|
|
384
|
+
deployL1ContractsValues.l1ContractAddresses.rollupAddress,
|
|
385
|
+
);
|
|
384
386
|
|
|
385
|
-
const blockReward = await
|
|
387
|
+
const blockReward = await rollup.getBlockReward();
|
|
386
388
|
const mintAmount = 10_000n * (blockReward as bigint);
|
|
387
389
|
|
|
388
390
|
const feeJuice = getContract({
|
|
389
391
|
address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
|
|
390
|
-
abi:
|
|
392
|
+
abi: FeeAssetArtifact.contractAbi,
|
|
391
393
|
client: deployL1ContractsValues.l1Client,
|
|
392
394
|
});
|
|
393
395
|
|
|
394
|
-
const rewardDistributorMintTxHash = await feeJuice.write.mint(
|
|
396
|
+
const rewardDistributorMintTxHash = await feeJuice.write.mint(
|
|
397
|
+
[deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(), mintAmount],
|
|
398
|
+
{} as any,
|
|
399
|
+
);
|
|
395
400
|
await deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
|
|
396
401
|
logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
|
|
397
402
|
}
|
|
@@ -443,11 +448,11 @@ async function setupFromFresh(
|
|
|
443
448
|
|
|
444
449
|
let proverNode: ProverNode | undefined = undefined;
|
|
445
450
|
if (opts.startProverNode) {
|
|
446
|
-
logger.verbose('Creating and syncing a simulated prover node...');
|
|
451
|
+
logger.verbose('Creating and syncing a simulated prover node with p2p disabled...');
|
|
447
452
|
proverNode = await createAndSyncProverNode(
|
|
448
453
|
`0x${proverNodePrivateKey!.toString('hex')}`,
|
|
449
454
|
aztecNodeConfig,
|
|
450
|
-
{ dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')) },
|
|
455
|
+
{ dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')), p2pEnabled: false },
|
|
451
456
|
aztecNode,
|
|
452
457
|
prefilledPublicData,
|
|
453
458
|
);
|
|
@@ -472,6 +477,7 @@ async function setupFromFresh(
|
|
|
472
477
|
anvil,
|
|
473
478
|
aztecNode,
|
|
474
479
|
pxe,
|
|
480
|
+
sequencer: aztecNode.getSequencer()!,
|
|
475
481
|
acvmConfig,
|
|
476
482
|
bbConfig,
|
|
477
483
|
deployL1ContractsValues,
|
|
@@ -590,6 +596,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
|
|
|
590
596
|
anvil,
|
|
591
597
|
aztecNode,
|
|
592
598
|
pxe,
|
|
599
|
+
sequencer: aztecNode.getSequencer()!,
|
|
593
600
|
acvmConfig,
|
|
594
601
|
bbConfig,
|
|
595
602
|
proverNode,
|
|
@@ -653,13 +660,13 @@ export async function publicDeployAccounts(
|
|
|
653
660
|
const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
|
|
654
661
|
|
|
655
662
|
const calls: ContractFunctionInteraction[] = await Promise.all([
|
|
656
|
-
...(!alreadyRegistered ? [
|
|
657
|
-
...instances.map(instance =>
|
|
663
|
+
...(!alreadyRegistered ? [publishContractClass(sender, SchnorrAccountContractArtifact)] : []),
|
|
664
|
+
...instances.map(instance => publishInstance(sender, instance!)),
|
|
658
665
|
]);
|
|
659
666
|
|
|
660
667
|
const batch = new BatchCall(sender, calls);
|
|
661
668
|
|
|
662
|
-
const txReceipt = await batch.send().wait();
|
|
669
|
+
const txReceipt = await batch.send({ from: accountAddressesToDeploy[0] }).wait();
|
|
663
670
|
if (waitUntilProven) {
|
|
664
671
|
if (!pxeOrNode) {
|
|
665
672
|
throw new Error('Need to provide a PXE or AztecNode to wait for proven.');
|
|
@@ -3,15 +3,20 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
|
3
3
|
|
|
4
4
|
// docs:start:token_utils
|
|
5
5
|
|
|
6
|
-
export async function deployToken(
|
|
6
|
+
export async function deployToken(
|
|
7
|
+
adminWallet: Wallet,
|
|
8
|
+
deployerAddress: AztecAddress,
|
|
9
|
+
initialAdminBalance: bigint,
|
|
10
|
+
logger: Logger,
|
|
11
|
+
) {
|
|
7
12
|
logger.info(`Deploying Token contract...`);
|
|
8
|
-
const contract = await TokenContract.deploy(adminWallet,
|
|
9
|
-
.send()
|
|
13
|
+
const contract = await TokenContract.deploy(adminWallet, deployerAddress, 'TokenName', 'TokenSymbol', 18)
|
|
14
|
+
.send({ from: deployerAddress })
|
|
10
15
|
.deployed();
|
|
11
16
|
|
|
12
17
|
if (initialAdminBalance > 0n) {
|
|
13
18
|
// Minter is minting to herself so contract as minter is the same as contract as recipient
|
|
14
|
-
await mintTokensToPrivate(contract,
|
|
19
|
+
await mintTokensToPrivate(contract, deployerAddress, adminWallet, deployerAddress, initialAdminBalance);
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
logger.info('L2 contract deployed');
|
|
@@ -21,13 +26,13 @@ export async function deployToken(adminWallet: Wallet, initialAdminBalance: bigi
|
|
|
21
26
|
|
|
22
27
|
export async function mintTokensToPrivate(
|
|
23
28
|
token: TokenContract,
|
|
29
|
+
minter: AztecAddress,
|
|
24
30
|
minterWallet: Wallet,
|
|
25
31
|
recipient: AztecAddress,
|
|
26
32
|
amount: bigint,
|
|
27
33
|
) {
|
|
28
34
|
const tokenAsMinter = await TokenContract.at(token.address, minterWallet);
|
|
29
|
-
|
|
30
|
-
await tokenAsMinter.methods.mint_to_private(from, recipient, amount).send().wait();
|
|
35
|
+
await tokenAsMinter.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
|
|
31
36
|
}
|
|
32
37
|
// docs:end:token_utils
|
|
33
38
|
|
|
@@ -47,6 +52,7 @@ export async function expectTokenBalance(
|
|
|
47
52
|
|
|
48
53
|
export async function mintNotes(
|
|
49
54
|
sender: Wallet,
|
|
55
|
+
minter: AztecAddress,
|
|
50
56
|
recipient: AztecAddress,
|
|
51
57
|
asset: TokenContract,
|
|
52
58
|
noteAmounts: bigint[],
|
|
@@ -56,9 +62,8 @@ export async function mintNotes(
|
|
|
56
62
|
const notesPerIteration = 4;
|
|
57
63
|
for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
|
|
58
64
|
const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
await new BatchCall(sender, actions).send().wait();
|
|
65
|
+
const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
|
|
66
|
+
await new BatchCall(sender, actions).send({ from: minter }).wait();
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
return noteAmounts.reduce((prev, curr) => prev + curr, 0n);
|