@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
package/src/bench/utils.ts
CHANGED
|
@@ -22,7 +22,9 @@ export async function benchmarkSetup(
|
|
|
22
22
|
},
|
|
23
23
|
) {
|
|
24
24
|
const context = await setup(1, { ...opts, telemetryConfig: { benchmark: true } });
|
|
25
|
-
const contract = await BenchmarkingContract.deploy(context.wallet)
|
|
25
|
+
const contract = await BenchmarkingContract.deploy(context.wallet)
|
|
26
|
+
.send({ from: context.wallet.getAddress() })
|
|
27
|
+
.deployed();
|
|
26
28
|
context.logger.info(`Deployed benchmarking contract at ${contract.address}`);
|
|
27
29
|
const sequencer = (context.aztecNode as AztecNodeService).getSequencer()!;
|
|
28
30
|
const telemetry = context.telemetryClient! as BenchmarkTelemetryClient;
|
|
@@ -110,12 +112,11 @@ function makeCall(
|
|
|
110
112
|
heavyPublicCompute: boolean,
|
|
111
113
|
) {
|
|
112
114
|
const owner = context.wallet.getAddress();
|
|
113
|
-
const sender = owner;
|
|
114
115
|
if (heavyPublicCompute) {
|
|
115
116
|
return new BatchCall(context.wallet, [contract.methods.sha256_hash_2048(randomBytesAsBigInts(2048))]);
|
|
116
117
|
} else {
|
|
117
118
|
return new BatchCall(context.wallet, [
|
|
118
|
-
contract.methods.create_note(owner,
|
|
119
|
+
contract.methods.create_note(owner, index + 1),
|
|
119
120
|
contract.methods.increment_balance(owner, index + 1),
|
|
120
121
|
]);
|
|
121
122
|
}
|
|
@@ -138,7 +139,7 @@ export async function sendTxs(
|
|
|
138
139
|
): Promise<SentTx[]> {
|
|
139
140
|
const calls = times(txCount, index => makeCall(index, context, contract, heavyPublicCompute));
|
|
140
141
|
context.logger.info(`Creating ${txCount} txs`);
|
|
141
|
-
const provenTxs = await Promise.all(calls.map(call => call.prove()));
|
|
142
|
+
const provenTxs = await Promise.all(calls.map(call => call.prove({ from: context.wallet.getAddress() })));
|
|
142
143
|
context.logger.info(`Sending ${txCount} txs`);
|
|
143
144
|
return provenTxs.map(tx => tx.send());
|
|
144
145
|
}
|
|
@@ -2,6 +2,7 @@ import { getSchnorrWallet } from '@aztec/accounts/schnorr';
|
|
|
2
2
|
import {
|
|
3
3
|
type AccountWallet,
|
|
4
4
|
AztecAddress,
|
|
5
|
+
type AztecNode,
|
|
5
6
|
type CompleteAddress,
|
|
6
7
|
Fr,
|
|
7
8
|
type Logger,
|
|
@@ -10,9 +11,11 @@ import {
|
|
|
10
11
|
computeSecretHash,
|
|
11
12
|
createLogger,
|
|
12
13
|
} from '@aztec/aztec.js';
|
|
14
|
+
import type { CheatCodes } from '@aztec/aztec/testing';
|
|
13
15
|
import type { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
14
16
|
import { TokenBlacklistContract } from '@aztec/noir-contracts.js/TokenBlacklist';
|
|
15
17
|
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
18
|
+
import type { SequencerClient } from '@aztec/sequencer-client';
|
|
16
19
|
|
|
17
20
|
import { jest } from '@jest/globals';
|
|
18
21
|
|
|
@@ -55,9 +58,8 @@ export class Role {
|
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
export class BlacklistTokenContractTest {
|
|
58
|
-
// A low delay is really poor ux, but we need to keep it low for the tests to run "quickly".
|
|
59
61
|
// This value MUST match the same value that we have in the contract
|
|
60
|
-
static
|
|
62
|
+
static CHANGE_ROLES_DELAY = 86400;
|
|
61
63
|
|
|
62
64
|
private snapshotManager: ISnapshotManager;
|
|
63
65
|
logger: Logger;
|
|
@@ -67,20 +69,28 @@ export class BlacklistTokenContractTest {
|
|
|
67
69
|
asset!: TokenBlacklistContract;
|
|
68
70
|
tokenSim!: TokenSimulator;
|
|
69
71
|
badAccount!: InvalidAccountContract;
|
|
72
|
+
cheatCodes!: CheatCodes;
|
|
73
|
+
sequencer!: SequencerClient;
|
|
74
|
+
aztecNode!: AztecNode;
|
|
70
75
|
|
|
71
76
|
admin!: AccountWallet;
|
|
77
|
+
adminAddress!: AztecAddress;
|
|
72
78
|
other!: AccountWallet;
|
|
79
|
+
otherAddress!: AztecAddress;
|
|
73
80
|
blacklisted!: AccountWallet;
|
|
81
|
+
blacklistedAddress!: AztecAddress;
|
|
74
82
|
|
|
75
83
|
constructor(testName: string) {
|
|
76
84
|
this.logger = createLogger(`e2e:e2e_blacklist_token_contract:${testName}`);
|
|
77
85
|
this.snapshotManager = createSnapshotManager(`e2e_blacklist_token_contract/${testName}`, dataPath);
|
|
78
86
|
}
|
|
79
87
|
|
|
80
|
-
async
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
async crossTimestampOfChange() {
|
|
89
|
+
await this.cheatCodes.warpL2TimeAtLeastBy(
|
|
90
|
+
this.sequencer,
|
|
91
|
+
this.aztecNode,
|
|
92
|
+
BlacklistTokenContractTest.CHANGE_ROLES_DELAY,
|
|
93
|
+
);
|
|
84
94
|
}
|
|
85
95
|
|
|
86
96
|
/**
|
|
@@ -95,12 +105,18 @@ export class BlacklistTokenContractTest {
|
|
|
95
105
|
await this.snapshotManager.snapshot(
|
|
96
106
|
'3_accounts',
|
|
97
107
|
deployAccounts(3, this.logger),
|
|
98
|
-
async ({ deployedAccounts }, { pxe }) => {
|
|
108
|
+
async ({ deployedAccounts }, { pxe, cheatCodes, aztecNode, sequencer }) => {
|
|
99
109
|
this.pxe = pxe;
|
|
110
|
+
this.cheatCodes = cheatCodes;
|
|
111
|
+
this.aztecNode = aztecNode;
|
|
112
|
+
this.sequencer = sequencer;
|
|
100
113
|
this.wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
101
114
|
this.admin = this.wallets[0];
|
|
115
|
+
this.adminAddress = this.admin.getAddress();
|
|
102
116
|
this.other = this.wallets[1];
|
|
117
|
+
this.otherAddress = this.other.getAddress();
|
|
103
118
|
this.blacklisted = this.wallets[2];
|
|
119
|
+
this.blacklistedAddress = this.blacklisted.getAddress();
|
|
104
120
|
this.accounts = this.wallets.map(w => w.getCompleteAddress());
|
|
105
121
|
},
|
|
106
122
|
);
|
|
@@ -111,17 +127,19 @@ export class BlacklistTokenContractTest {
|
|
|
111
127
|
// Create the token contract state.
|
|
112
128
|
// Move this account thing to addAccounts above?
|
|
113
129
|
this.logger.verbose(`Public deploy accounts...`);
|
|
114
|
-
await publicDeployAccounts(this.
|
|
130
|
+
await publicDeployAccounts(this.admin, this.accounts.slice(0, 3));
|
|
115
131
|
|
|
116
132
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
117
|
-
this.asset = await TokenBlacklistContract.deploy(this.admin, this.
|
|
133
|
+
this.asset = await TokenBlacklistContract.deploy(this.admin, this.adminAddress)
|
|
134
|
+
.send({ from: this.adminAddress })
|
|
135
|
+
.deployed();
|
|
118
136
|
this.logger.verbose(`Token deployed to ${this.asset.address}`);
|
|
119
137
|
|
|
120
138
|
this.logger.verbose(`Deploying bad account...`);
|
|
121
|
-
this.badAccount = await InvalidAccountContract.deploy(this.
|
|
139
|
+
this.badAccount = await InvalidAccountContract.deploy(this.admin).send({ from: this.adminAddress }).deployed();
|
|
122
140
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
123
141
|
|
|
124
|
-
await this.
|
|
142
|
+
await this.crossTimestampOfChange();
|
|
125
143
|
|
|
126
144
|
return { tokenContractAddress: this.asset.address, badAccountAddress: this.badAccount.address };
|
|
127
145
|
},
|
|
@@ -132,7 +150,8 @@ export class BlacklistTokenContractTest {
|
|
|
132
150
|
|
|
133
151
|
this.tokenSim = new TokenSimulator(
|
|
134
152
|
this.asset as unknown as TokenContract,
|
|
135
|
-
this.
|
|
153
|
+
this.admin,
|
|
154
|
+
this.adminAddress,
|
|
136
155
|
this.logger,
|
|
137
156
|
this.accounts.map(a => a.address),
|
|
138
157
|
);
|
|
@@ -140,7 +159,7 @@ export class BlacklistTokenContractTest {
|
|
|
140
159
|
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallets[0]);
|
|
141
160
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
142
161
|
|
|
143
|
-
expect(await this.asset.methods.get_roles(this.
|
|
162
|
+
expect(await this.asset.methods.get_roles(this.adminAddress).simulate({ from: this.adminAddress })).toEqual(
|
|
144
163
|
new Role().withAdmin().toNoirStruct(),
|
|
145
164
|
);
|
|
146
165
|
},
|
|
@@ -179,7 +198,7 @@ export class BlacklistTokenContractTest {
|
|
|
179
198
|
txEffects!.data.nullifiers[0],
|
|
180
199
|
recipient,
|
|
181
200
|
)
|
|
182
|
-
.simulate();
|
|
201
|
+
.simulate({ from: recipient });
|
|
183
202
|
}
|
|
184
203
|
|
|
185
204
|
async applyMintSnapshot() {
|
|
@@ -193,32 +212,34 @@ export class BlacklistTokenContractTest {
|
|
|
193
212
|
await this.asset
|
|
194
213
|
.withWallet(this.admin)
|
|
195
214
|
.methods.update_roles(this.admin.getAddress(), adminMinterRole.toNoirStruct())
|
|
196
|
-
.send()
|
|
215
|
+
.send({ from: this.adminAddress })
|
|
197
216
|
.wait();
|
|
198
217
|
|
|
199
218
|
const blacklistRole = new Role().withBlacklisted();
|
|
200
219
|
await this.asset
|
|
201
220
|
.withWallet(this.admin)
|
|
202
221
|
.methods.update_roles(this.blacklisted.getAddress(), blacklistRole.toNoirStruct())
|
|
203
|
-
.send()
|
|
222
|
+
.send({ from: this.adminAddress })
|
|
204
223
|
.wait();
|
|
205
224
|
|
|
206
|
-
await this.
|
|
225
|
+
await this.crossTimestampOfChange();
|
|
207
226
|
|
|
208
|
-
expect(
|
|
209
|
-
|
|
210
|
-
);
|
|
227
|
+
expect(
|
|
228
|
+
await this.asset.methods.get_roles(this.admin.getAddress()).simulate({ from: this.adminAddress }),
|
|
229
|
+
).toEqual(adminMinterRole.toNoirStruct());
|
|
211
230
|
|
|
212
231
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
213
|
-
await asset.methods.mint_public(accounts[0].address, amount).send().wait();
|
|
232
|
+
await asset.methods.mint_public(accounts[0].address, amount).send({ from: this.adminAddress }).wait();
|
|
214
233
|
|
|
215
234
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
216
235
|
const secret = Fr.random();
|
|
217
236
|
const secretHash = await computeSecretHash(secret);
|
|
218
|
-
const receipt = await asset.methods.mint_private(amount, secretHash).send().wait();
|
|
237
|
+
const receipt = await asset.methods.mint_private(amount, secretHash).send({ from: this.adminAddress }).wait();
|
|
219
238
|
|
|
220
239
|
await this.addPendingShieldNoteToPXE(asset, wallets[0].getAddress(), amount, secretHash, receipt.txHash);
|
|
221
|
-
const txClaim = asset.methods
|
|
240
|
+
const txClaim = asset.methods
|
|
241
|
+
.redeem_shield(accounts[0].address, amount, secret)
|
|
242
|
+
.send({ from: this.adminAddress });
|
|
222
243
|
await txClaim.wait();
|
|
223
244
|
this.logger.verbose(`Minting complete.`);
|
|
224
245
|
|
|
@@ -232,16 +253,16 @@ export class BlacklistTokenContractTest {
|
|
|
232
253
|
} = this;
|
|
233
254
|
tokenSim.mintPublic(address, amount);
|
|
234
255
|
|
|
235
|
-
const publicBalance = await asset.methods.balance_of_public(address).simulate();
|
|
256
|
+
const publicBalance = await asset.methods.balance_of_public(address).simulate({ from: address });
|
|
236
257
|
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
237
258
|
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(address));
|
|
238
259
|
|
|
239
260
|
tokenSim.mintPrivate(address, amount);
|
|
240
|
-
const privateBalance = await asset.methods.balance_of_private(address).simulate();
|
|
261
|
+
const privateBalance = await asset.methods.balance_of_private(address).simulate({ from: address });
|
|
241
262
|
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
242
263
|
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(address));
|
|
243
264
|
|
|
244
|
-
const totalSupply = await asset.methods.total_supply().simulate();
|
|
265
|
+
const totalSupply = await asset.methods.total_supply().simulate({ from: address });
|
|
245
266
|
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
246
267
|
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
247
268
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
type PXE,
|
|
11
11
|
createLogger,
|
|
12
12
|
} from '@aztec/aztec.js';
|
|
13
|
-
import { CheatCodes } from '@aztec/aztec
|
|
13
|
+
import { CheatCodes } from '@aztec/aztec/testing';
|
|
14
14
|
import {
|
|
15
15
|
type DeployL1ContractsReturnType,
|
|
16
16
|
type ExtendedViemWalletClient,
|
|
@@ -39,7 +39,6 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
39
39
|
export class CrossChainMessagingTest {
|
|
40
40
|
private snapshotManager: ISnapshotManager;
|
|
41
41
|
logger: Logger;
|
|
42
|
-
wallets: AccountWallet[] = [];
|
|
43
42
|
accounts: CompleteAddress[] = [];
|
|
44
43
|
aztecNode!: AztecNode;
|
|
45
44
|
pxe!: PXE;
|
|
@@ -49,7 +48,9 @@ export class CrossChainMessagingTest {
|
|
|
49
48
|
l1Client!: ExtendedViemWalletClient | undefined;
|
|
50
49
|
|
|
51
50
|
user1Wallet!: AccountWallet;
|
|
51
|
+
user1Address!: AztecAddress;
|
|
52
52
|
user2Wallet!: AccountWallet;
|
|
53
|
+
user2Address!: AztecAddress;
|
|
53
54
|
crossChainTestHarness!: CrossChainTestHarness;
|
|
54
55
|
ethAccount!: EthAddress;
|
|
55
56
|
ownerAddress!: AztecAddress;
|
|
@@ -99,12 +100,14 @@ export class CrossChainMessagingTest {
|
|
|
99
100
|
'3_accounts',
|
|
100
101
|
deployAccounts(3, this.logger),
|
|
101
102
|
async ({ deployedAccounts }, { pxe, aztecNodeConfig, aztecNode }) => {
|
|
102
|
-
|
|
103
|
-
this.accounts =
|
|
104
|
-
|
|
103
|
+
const wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
104
|
+
this.accounts = wallets.map(w => w.getCompleteAddress());
|
|
105
|
+
wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
105
106
|
|
|
106
|
-
this.user1Wallet =
|
|
107
|
-
this.
|
|
107
|
+
this.user1Wallet = wallets[0];
|
|
108
|
+
this.user1Address = this.user1Wallet.getAddress();
|
|
109
|
+
this.user2Wallet = wallets[1];
|
|
110
|
+
this.user2Address = this.user2Wallet.getAddress();
|
|
108
111
|
|
|
109
112
|
this.pxe = pxe;
|
|
110
113
|
this.aztecNode = aztecNode;
|
|
@@ -118,7 +121,7 @@ export class CrossChainMessagingTest {
|
|
|
118
121
|
// Create the token contract state.
|
|
119
122
|
// Move this account thing to addAccounts above?
|
|
120
123
|
this.logger.verbose(`Public deploy accounts...`);
|
|
121
|
-
await publicDeployAccounts(this.
|
|
124
|
+
await publicDeployAccounts(this.user1Wallet, this.accounts.slice(0, 3));
|
|
122
125
|
|
|
123
126
|
this.l1Client = createExtendedL1Client(this.aztecNodeConfig.l1RpcUrls, MNEMONIC);
|
|
124
127
|
|
|
@@ -133,7 +136,8 @@ export class CrossChainMessagingTest {
|
|
|
133
136
|
this.aztecNode,
|
|
134
137
|
this.pxe,
|
|
135
138
|
this.l1Client,
|
|
136
|
-
this.
|
|
139
|
+
this.user1Wallet,
|
|
140
|
+
this.user1Address,
|
|
137
141
|
this.logger,
|
|
138
142
|
underlyingERC20Address,
|
|
139
143
|
);
|
|
@@ -176,6 +180,7 @@ export class CrossChainMessagingTest {
|
|
|
176
180
|
l1Client,
|
|
177
181
|
this.aztecNodeConfig.l1Contracts,
|
|
178
182
|
this.user1Wallet,
|
|
183
|
+
this.user1Address,
|
|
179
184
|
);
|
|
180
185
|
|
|
181
186
|
this.l1Client = l1Client;
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type PublicKeys,
|
|
12
12
|
type Wallet,
|
|
13
13
|
createLogger,
|
|
14
|
-
|
|
14
|
+
getContractInstanceFromInstantiationParams,
|
|
15
15
|
} from '@aztec/aztec.js';
|
|
16
16
|
import type { StatefulTestContract } from '@aztec/noir-test-contracts.js/StatefulTest';
|
|
17
17
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
@@ -22,11 +22,10 @@ const { E2E_DATA_PATH: dataPath } = process.env;
|
|
|
22
22
|
|
|
23
23
|
export class DeployTest {
|
|
24
24
|
private snapshotManager: ISnapshotManager;
|
|
25
|
-
private wallets: AccountWallet[] = [];
|
|
26
|
-
|
|
27
25
|
public logger: Logger;
|
|
28
26
|
public pxe!: PXE;
|
|
29
27
|
public wallet!: AccountWallet;
|
|
28
|
+
public defaultAccountAddress!: AztecAddress;
|
|
30
29
|
public aztecNode!: AztecNode;
|
|
31
30
|
public aztecNodeAdmin!: AztecNodeAdmin;
|
|
32
31
|
|
|
@@ -52,9 +51,10 @@ export class DeployTest {
|
|
|
52
51
|
'initial_account',
|
|
53
52
|
deployAccounts(1, this.logger),
|
|
54
53
|
async ({ deployedAccounts }, { pxe }) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.wallet =
|
|
54
|
+
const wallets = await Promise.all(deployedAccounts.map(a => getSchnorrWallet(pxe, a.address, a.signingKey)));
|
|
55
|
+
wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
56
|
+
this.wallet = wallets[0];
|
|
57
|
+
this.defaultAccountAddress = this.wallet.getAddress();
|
|
58
58
|
},
|
|
59
59
|
);
|
|
60
60
|
}
|
|
@@ -71,7 +71,7 @@ export class DeployTest {
|
|
|
71
71
|
} = {},
|
|
72
72
|
): Promise<T> {
|
|
73
73
|
const { salt, publicKeys, initArgs, constructorName, deployer } = opts;
|
|
74
|
-
const instance = await
|
|
74
|
+
const instance = await getContractInstanceFromInstantiationParams(contractArtifact.artifact, {
|
|
75
75
|
constructorArgs: initArgs ?? [],
|
|
76
76
|
constructorArtifact: constructorName,
|
|
77
77
|
salt,
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type Logger,
|
|
5
5
|
MerkleTreeId,
|
|
6
6
|
type Wallet,
|
|
7
|
-
|
|
7
|
+
getContractInstanceFromInstantiationParams,
|
|
8
8
|
getTimestampRangeForEpoch,
|
|
9
9
|
retryUntil,
|
|
10
10
|
sleep,
|
|
@@ -19,9 +19,14 @@ import { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
|
19
19
|
import { getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
|
|
20
20
|
import { ProverNode, ProverNodePublisher } from '@aztec/prover-node';
|
|
21
21
|
import type { TestProverNode } from '@aztec/prover-node/test';
|
|
22
|
-
import
|
|
22
|
+
import {
|
|
23
|
+
type SequencerClient,
|
|
24
|
+
type SequencerEvents,
|
|
25
|
+
type SequencerPublisher,
|
|
26
|
+
SequencerState,
|
|
27
|
+
} from '@aztec/sequencer-client';
|
|
23
28
|
import type { TestSequencerClient } from '@aztec/sequencer-client/test';
|
|
24
|
-
import type { L2BlockNumber } from '@aztec/stdlib/block';
|
|
29
|
+
import type { EthAddress, L2BlockNumber } from '@aztec/stdlib/block';
|
|
25
30
|
import { type L1RollupConstants, getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers';
|
|
26
31
|
import { tryStop } from '@aztec/stdlib/interfaces/server';
|
|
27
32
|
|
|
@@ -40,24 +45,17 @@ import {
|
|
|
40
45
|
export const WORLD_STATE_BLOCK_HISTORY = 2;
|
|
41
46
|
export const WORLD_STATE_BLOCK_CHECK_INTERVAL = 50;
|
|
42
47
|
export const ARCHIVER_POLL_INTERVAL = 50;
|
|
48
|
+
export const DEFAULT_L1_BLOCK_TIME = process.env.CI ? 12 : 8;
|
|
49
|
+
|
|
50
|
+
export type EpochsTestOpts = Partial<SetupOptions> & { numberOfAccounts?: number };
|
|
43
51
|
|
|
44
|
-
export type
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| 'l1PublishRetryIntervalMS'
|
|
52
|
-
| 'txPropagationMaxQueryAttempts'
|
|
53
|
-
| 'proverNodeConfig'
|
|
54
|
-
| 'ethereumSlotDuration'
|
|
55
|
-
| 'aztecSlotDuration'
|
|
56
|
-
| 'initialValidators'
|
|
57
|
-
| 'mockGossipSubNetwork'
|
|
58
|
-
| 'disableAnvilTestWatcher'
|
|
59
|
-
>
|
|
60
|
-
> & { numberOfAccounts?: number };
|
|
52
|
+
export type TrackedSequencerEvent = {
|
|
53
|
+
[K in keyof SequencerEvents]: Parameters<SequencerEvents[K]>[0] & {
|
|
54
|
+
type: K;
|
|
55
|
+
sequencerIndex: number;
|
|
56
|
+
validator: EthAddress;
|
|
57
|
+
};
|
|
58
|
+
}[keyof SequencerEvents];
|
|
61
59
|
|
|
62
60
|
/**
|
|
63
61
|
* Tests building of epochs using fast block times and short epochs.
|
|
@@ -89,7 +87,9 @@ export class EpochsTestContext {
|
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
public static getSlotDurations(opts: EpochsTestOpts = {}) {
|
|
92
|
-
const envEthereumSlotDuration = process.env.L1_BLOCK_TIME
|
|
90
|
+
const envEthereumSlotDuration = process.env.L1_BLOCK_TIME
|
|
91
|
+
? parseInt(process.env.L1_BLOCK_TIME)
|
|
92
|
+
: DEFAULT_L1_BLOCK_TIME;
|
|
93
93
|
const ethereumSlotDuration = opts.ethereumSlotDuration ?? envEthereumSlotDuration;
|
|
94
94
|
const aztecSlotDuration = opts.aztecSlotDuration ?? ethereumSlotDuration * 2;
|
|
95
95
|
const aztecEpochDuration = opts.aztecEpochDuration ?? 4;
|
|
@@ -141,7 +141,7 @@ export class EpochsTestContext {
|
|
|
141
141
|
this.rollup = RollupContract.getFromConfig(context.config);
|
|
142
142
|
|
|
143
143
|
// Loop that tracks L1 and L2 block numbers and logs whenever there's a new one.
|
|
144
|
-
this.monitor = new ChainMonitor(this.rollup, this.logger).start();
|
|
144
|
+
this.monitor = new ChainMonitor(this.rollup, context.dateProvider, this.logger).start();
|
|
145
145
|
|
|
146
146
|
// This is hideous.
|
|
147
147
|
// We ought to have a definite reference to the l1TxUtils that we're using in both places, provided by the test context.
|
|
@@ -192,6 +192,8 @@ export class EpochsTestContext {
|
|
|
192
192
|
{ ...this.context.config, proverId: Fr.fromString(suffix) },
|
|
193
193
|
{ dataDirectory: join(this.context.config.dataDirectory!, randomBytes(8).toString('hex')) },
|
|
194
194
|
this.context.aztecNode,
|
|
195
|
+
undefined,
|
|
196
|
+
{ dateProvider: this.context.dateProvider },
|
|
195
197
|
),
|
|
196
198
|
);
|
|
197
199
|
this.proverNodes.push(proverNode);
|
|
@@ -205,13 +207,15 @@ export class EpochsTestContext {
|
|
|
205
207
|
|
|
206
208
|
public createValidatorNode(
|
|
207
209
|
privateKeys: `0x${string}`[],
|
|
208
|
-
opts: Partial<AztecNodeConfig> & { dontStartSequencer?: boolean } = {},
|
|
210
|
+
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
209
211
|
) {
|
|
210
212
|
this.logger.warn('Creating and syncing a validator node...');
|
|
211
213
|
return this.createNode({ ...opts, disableValidator: false, validatorPrivateKeys: new SecretValue(privateKeys) });
|
|
212
214
|
}
|
|
213
215
|
|
|
214
|
-
private async createNode(
|
|
216
|
+
private async createNode(
|
|
217
|
+
opts: Partial<AztecNodeConfig> & { txDelayerMaxInclusionTimeIntoSlot?: number; dontStartSequencer?: boolean } = {},
|
|
218
|
+
) {
|
|
215
219
|
const suffix = (this.nodes.length + 1).toString();
|
|
216
220
|
const { mockGossipSubNetwork } = this.context;
|
|
217
221
|
const resolvedConfig = { ...this.context.config, ...opts };
|
|
@@ -238,6 +242,21 @@ export class EpochsTestContext {
|
|
|
238
242
|
},
|
|
239
243
|
),
|
|
240
244
|
);
|
|
245
|
+
|
|
246
|
+
// REFACTOR: We're getting too much into the internals of the sequencer here.
|
|
247
|
+
// We should have a single method for constructing an aztec node that returns a TestAztecNodeService
|
|
248
|
+
// which directly exposes the delayer and sets any test config.
|
|
249
|
+
if (opts.txDelayerMaxInclusionTimeIntoSlot !== undefined) {
|
|
250
|
+
this.logger.info(
|
|
251
|
+
`Setting tx delayer max inclusion time into slot to ${opts.txDelayerMaxInclusionTimeIntoSlot} seconds`,
|
|
252
|
+
);
|
|
253
|
+
const sequencer = node.getSequencer() as TestSequencerClient;
|
|
254
|
+
const publisher = sequencer.sequencer.publisher;
|
|
255
|
+
const delayed = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, this.L1_BLOCK_TIME_IN_S);
|
|
256
|
+
delayed.delayer!.setMaxInclusionTimeIntoSlot(opts.txDelayerMaxInclusionTimeIntoSlot);
|
|
257
|
+
publisher.l1TxUtils = delayed;
|
|
258
|
+
}
|
|
259
|
+
|
|
241
260
|
this.nodes.push(node);
|
|
242
261
|
return node;
|
|
243
262
|
}
|
|
@@ -310,7 +329,7 @@ export class EpochsTestContext {
|
|
|
310
329
|
|
|
311
330
|
/** Registers the SpamContract on the given wallet. */
|
|
312
331
|
public async registerSpamContract(wallet: Wallet, salt = Fr.ZERO) {
|
|
313
|
-
const instance = await
|
|
332
|
+
const instance = await getContractInstanceFromInstantiationParams(SpamContract.artifact, {
|
|
314
333
|
constructorArgs: [],
|
|
315
334
|
constructorArtifact: undefined,
|
|
316
335
|
salt,
|
|
@@ -329,6 +348,7 @@ export class EpochsTestContext {
|
|
|
329
348
|
privateKeyToAccount(this.getNextPrivateKey()),
|
|
330
349
|
this.l1Client.chain,
|
|
331
350
|
),
|
|
351
|
+
this.context.dateProvider!,
|
|
332
352
|
{ ethereumSlotDuration: this.L1_BLOCK_TIME_IN_S },
|
|
333
353
|
);
|
|
334
354
|
expect(await client.getBalance({ address: client.account.address })).toBeGreaterThan(0n);
|
|
@@ -346,4 +366,56 @@ export class EpochsTestContext {
|
|
|
346
366
|
.catch(_ => false);
|
|
347
367
|
expect(result).toBe(expectedSuccess);
|
|
348
368
|
}
|
|
369
|
+
|
|
370
|
+
public watchSequencerEvents(
|
|
371
|
+
sequencers: SequencerClient[],
|
|
372
|
+
getMetadata: (i: number) => Record<string, any> = () => ({}),
|
|
373
|
+
) {
|
|
374
|
+
const stateChanges: TrackedSequencerEvent[] = [];
|
|
375
|
+
const failEvents: TrackedSequencerEvent[] = [];
|
|
376
|
+
|
|
377
|
+
// Note we do not include the 'tx-count-check-failed' event here, since it is fine if we dont build
|
|
378
|
+
// due to lack of txs available.
|
|
379
|
+
const failEventsKeys: (keyof SequencerEvents)[] = [
|
|
380
|
+
'block-build-failed',
|
|
381
|
+
'block-publish-failed',
|
|
382
|
+
'proposer-rollup-check-failed',
|
|
383
|
+
];
|
|
384
|
+
|
|
385
|
+
const makeEvent = (
|
|
386
|
+
i: number,
|
|
387
|
+
eventName: keyof SequencerEvents,
|
|
388
|
+
args: Parameters<SequencerEvents[keyof SequencerEvents]>[0],
|
|
389
|
+
) =>
|
|
390
|
+
({
|
|
391
|
+
...args,
|
|
392
|
+
type: eventName,
|
|
393
|
+
sequencerIndex: i + 2,
|
|
394
|
+
...getMetadata(i),
|
|
395
|
+
}) as TrackedSequencerEvent;
|
|
396
|
+
|
|
397
|
+
sequencers.forEach((sequencer, i) => {
|
|
398
|
+
const sequencerIndex = i + 2;
|
|
399
|
+
sequencer.getSequencer().on('state-changed', (args: Parameters<SequencerEvents['state-changed']>[0]) => {
|
|
400
|
+
const noisyStates = [SequencerState.IDLE, SequencerState.PROPOSER_CHECK, SequencerState.SYNCHRONIZING];
|
|
401
|
+
if (!noisyStates.includes(args.newState)) {
|
|
402
|
+
const evt = makeEvent(i, 'state-changed', args);
|
|
403
|
+
stateChanges.push(evt);
|
|
404
|
+
this.logger.verbose(
|
|
405
|
+
`Sequencer ${sequencerIndex} transitioned from state ${args.oldState} to state ${args.newState}`,
|
|
406
|
+
evt,
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
failEventsKeys.forEach(eventName => {
|
|
411
|
+
sequencer.getSequencer().on(eventName, (args: Parameters<SequencerEvents[typeof eventName]>[0]) => {
|
|
412
|
+
const evt = makeEvent(i, eventName, args);
|
|
413
|
+
failEvents.push(evt);
|
|
414
|
+
this.logger.error(`Failed event ${eventName} from sequencer ${sequencerIndex}`, evt);
|
|
415
|
+
});
|
|
416
|
+
});
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
return { failEvents, stateChanges };
|
|
420
|
+
}
|
|
349
421
|
}
|
|
@@ -67,7 +67,7 @@ describe('e2e_fees bridging_race', () => {
|
|
|
67
67
|
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
|
|
68
68
|
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, bobsAddress);
|
|
69
69
|
const { claimSecret: secret, messageLeafIndex: index } = claim;
|
|
70
|
-
await t.feeJuiceContract.methods.claim(bobsAddress, amount, secret, index).send().wait();
|
|
70
|
+
await t.feeJuiceContract.methods.claim(bobsAddress, amount, secret, index).send({ from: bobsAddress }).wait();
|
|
71
71
|
const [balance] = await t.getGasBalanceFn(bobsAddress);
|
|
72
72
|
expect(balance).toEqual(amount);
|
|
73
73
|
});
|