@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-manual.20251030
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 +3 -2
- 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 +16 -12
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +54 -58
- package/dest/bench/client_flows/data_extractor.js +3 -3
- package/dest/bench/utils.d.ts +2 -11
- package/dest/bench/utils.d.ts.map +1 -1
- package/dest/bench/utils.js +10 -34
- 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 +10 -8
- 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 +31 -33
- package/dest/e2e_deploy_contract/deploy_test.d.ts +10 -4
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +9 -18
- package/dest/e2e_epochs/epochs_test.d.ts +9 -3
- package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
- package/dest/e2e_epochs/epochs_test.js +19 -13
- package/dest/e2e_fees/bridging_race.notest.js +12 -9
- 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 +26 -33
- package/dest/e2e_l1_publisher/write_json.d.ts +3 -1
- 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_multi_validator/utils.js +3 -9
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -3
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
- package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
- package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
- package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
- package/dest/e2e_p2p/p2p_network.d.ts +22 -8
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +36 -15
- package/dest/e2e_p2p/shared.d.ts +12 -13
- package/dest/e2e_p2p/shared.d.ts.map +1 -1
- package/dest/e2e_p2p/shared.js +54 -54
- package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +14 -17
- package/dest/fixtures/e2e_prover_test.d.ts +8 -6
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +42 -51
- 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 +10 -9
- package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
- package/dest/fixtures/setup_p2p_test.js +38 -20
- package/dest/fixtures/snapshot_manager.d.ts +10 -7
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +60 -47
- package/dest/fixtures/token_utils.d.ts +6 -4
- package/dest/fixtures/token_utils.d.ts.map +1 -1
- package/dest/fixtures/token_utils.js +11 -15
- package/dest/fixtures/utils.d.ts +26 -28
- package/dest/fixtures/utils.d.ts.map +1 -1
- package/dest/fixtures/utils.js +83 -109
- package/dest/fixtures/web3signer.d.ts +5 -0
- package/dest/fixtures/web3signer.d.ts.map +1 -0
- package/dest/fixtures/web3signer.js +53 -0
- 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 +16 -10
- package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
- package/dest/shared/cross_chain_test_harness.js +13 -15
- package/dest/shared/gas_portal_test_harness.d.ts +9 -6
- package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
- package/dest/shared/gas_portal_test_harness.js +10 -7
- package/dest/shared/jest_setup.js +1 -1
- package/dest/shared/submit-transactions.d.ts +5 -3
- package/dest/shared/submit-transactions.d.ts.map +1 -1
- package/dest/shared/submit-transactions.js +8 -7
- package/dest/shared/uniswap_l1_l2.d.ts +9 -6
- package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
- package/dest/shared/uniswap_l1_l2.js +29 -45
- package/dest/simulators/lending_simulator.d.ts +2 -1
- package/dest/simulators/lending_simulator.d.ts.map +1 -1
- package/dest/simulators/lending_simulator.js +3 -2
- package/dest/simulators/token_simulator.d.ts +3 -1
- 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 +19 -13
- package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
- package/dest/spartan/setup_test_wallets.js +108 -85
- package/dest/spartan/utils.d.ts +68 -3
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +312 -49
- package/package.json +39 -38
- package/src/bench/client_flows/benchmark.ts +8 -8
- package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
- package/src/bench/client_flows/data_extractor.ts +4 -4
- package/src/bench/utils.ts +9 -37
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
- package/src/e2e_deploy_contract/deploy_test.ts +17 -35
- package/src/e2e_epochs/epochs_test.ts +22 -19
- package/src/e2e_fees/bridging_race.notest.ts +14 -9
- package/src/e2e_fees/fees_test.ts +29 -40
- package/src/e2e_l1_publisher/write_json.ts +8 -6
- package/src/e2e_multi_validator/utils.ts +4 -10
- package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
- package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
- package/src/e2e_p2p/p2p_network.ts +110 -71
- package/src/e2e_p2p/shared.ts +57 -56
- package/src/e2e_token_contract/token_contract_test.ts +17 -17
- package/src/fixtures/e2e_prover_test.ts +52 -88
- package/src/fixtures/get_acvm_config.ts +1 -1
- package/src/fixtures/get_bb_config.ts +3 -2
- package/src/fixtures/setup_l1_contracts.ts +3 -3
- package/src/fixtures/setup_p2p_test.ts +60 -27
- package/src/fixtures/snapshot_manager.ts +80 -72
- package/src/fixtures/token_utils.ts +13 -21
- package/src/fixtures/utils.ts +95 -145
- package/src/fixtures/web3signer.ts +63 -0
- package/src/guides/up_quick_start.sh +2 -10
- package/src/quality_of_service/alert_checker.ts +1 -1
- package/src/shared/cross_chain_test_harness.ts +18 -29
- package/src/shared/gas_portal_test_harness.ts +12 -19
- package/src/shared/jest_setup.ts +1 -1
- package/src/shared/submit-transactions.ts +12 -8
- package/src/shared/uniswap_l1_l2.ts +61 -67
- package/src/simulators/lending_simulator.ts +3 -2
- package/src/simulators/token_simulator.ts +5 -2
- package/src/spartan/DEVELOP.md +8 -3
- package/src/spartan/setup_test_wallets.ts +133 -126
- package/src/spartan/utils.ts +373 -48
package/src/e2e_p2p/shared.ts
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
-
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
|
|
2
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
3
2
|
import type { AztecNodeService } from '@aztec/aztec-node';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type SentTx,
|
|
10
|
-
TxStatus,
|
|
11
|
-
getContractInstanceFromInstantiationParams,
|
|
12
|
-
retryUntil,
|
|
13
|
-
} from '@aztec/aztec.js';
|
|
3
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
+
import { type SentTx, getContractInstanceFromInstantiationParams } from '@aztec/aztec.js/contracts';
|
|
5
|
+
import { Fr } from '@aztec/aztec.js/fields';
|
|
6
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
7
|
+
import { Tx, TxStatus } from '@aztec/aztec.js/tx';
|
|
14
8
|
import type { RollupCheatCodes } from '@aztec/aztec/testing';
|
|
15
9
|
import type { EmpireSlashingProposerContract, RollupContract, TallySlashingProposerContract } from '@aztec/ethereum';
|
|
16
10
|
import { timesAsync, unique } from '@aztec/foundation/collection';
|
|
17
|
-
import
|
|
11
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
12
|
+
import { pluralize } from '@aztec/foundation/string';
|
|
18
13
|
import type { SpamContract } from '@aztec/noir-test-contracts.js/Spam';
|
|
19
14
|
import { TestContract, TestContractArtifact } from '@aztec/noir-test-contracts.js/Test';
|
|
20
|
-
import {
|
|
15
|
+
import { getPXEConfig, getPXEConfig as getRpcConfig } from '@aztec/pxe/server';
|
|
21
16
|
import { getRoundForOffense } from '@aztec/slasher';
|
|
22
17
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
23
18
|
import type { SlashFactoryContract } from '@aztec/stdlib/l1-contracts';
|
|
19
|
+
import { TestWallet, proveInteraction } from '@aztec/test-wallet/server';
|
|
24
20
|
|
|
25
|
-
import type { NodeContext } from '../fixtures/setup_p2p_test.js';
|
|
26
21
|
import { submitTxsTo } from '../shared/submit-transactions.js';
|
|
27
22
|
|
|
28
23
|
// submits a set of transactions to the provided Private eXecution Environment (PXE)
|
|
@@ -55,56 +50,46 @@ export const submitComplexTxsTo = async (
|
|
|
55
50
|
return txs;
|
|
56
51
|
};
|
|
57
52
|
|
|
58
|
-
// creates
|
|
59
|
-
export const
|
|
53
|
+
// creates a wallet and submit a given number of transactions through it.
|
|
54
|
+
export const submitTransactions = async (
|
|
60
55
|
logger: Logger,
|
|
61
56
|
node: AztecNodeService,
|
|
62
57
|
numTxs: number,
|
|
63
58
|
fundedAccount: InitialAccountData,
|
|
64
|
-
): Promise<
|
|
59
|
+
): Promise<SentTx[]> => {
|
|
65
60
|
const rpcConfig = getRpcConfig();
|
|
66
61
|
rpcConfig.proverEnabled = false;
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
pxeService,
|
|
71
|
-
fundedAccount.secret,
|
|
72
|
-
fundedAccount.signingKey,
|
|
73
|
-
fundedAccount.salt,
|
|
74
|
-
);
|
|
75
|
-
await account.register();
|
|
76
|
-
const wallet = await account.getWallet();
|
|
77
|
-
|
|
78
|
-
const txs = await submitTxsTo(pxeService, numTxs, wallet, logger);
|
|
79
|
-
return { txs, pxeService, node };
|
|
62
|
+
const wallet = await TestWallet.create(node, { ...getPXEConfig(), proverEnabled: false }, { useLogSuffix: true });
|
|
63
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
64
|
+
return submitTxsTo(wallet, fundedAccountManager.address, numTxs, logger);
|
|
80
65
|
};
|
|
81
66
|
|
|
82
|
-
export async function
|
|
67
|
+
export async function prepareTransactions(
|
|
83
68
|
logger: Logger,
|
|
84
69
|
node: AztecNodeService,
|
|
85
70
|
numTxs: number,
|
|
86
71
|
fundedAccount: InitialAccountData,
|
|
87
|
-
): Promise<
|
|
72
|
+
): Promise<Tx[]> {
|
|
88
73
|
const rpcConfig = getRpcConfig();
|
|
89
74
|
rpcConfig.proverEnabled = false;
|
|
90
|
-
const pxe = await createPXEService(node, rpcConfig, { useLogSuffix: true });
|
|
91
75
|
|
|
92
|
-
const
|
|
93
|
-
await
|
|
94
|
-
const wallet = await account.getWallet();
|
|
76
|
+
const wallet = await TestWallet.create(node, { ...getPXEConfig(), proverEnabled: false }, { useLogSuffix: true });
|
|
77
|
+
const fundedAccountManager = await wallet.createSchnorrAccount(fundedAccount.secret, fundedAccount.salt);
|
|
95
78
|
|
|
96
|
-
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
97
|
-
|
|
79
|
+
const testContractInstance = await getContractInstanceFromInstantiationParams(TestContractArtifact, {
|
|
80
|
+
salt: Fr.random(),
|
|
81
|
+
});
|
|
82
|
+
await wallet.registerContract(testContractInstance, TestContractArtifact);
|
|
98
83
|
const contract = await TestContract.at(testContractInstance.address, wallet);
|
|
99
84
|
|
|
100
|
-
|
|
101
|
-
const tx = await contract.methods.emit_nullifier(Fr.random())
|
|
85
|
+
return timesAsync(numTxs, async () => {
|
|
86
|
+
const tx = await proveInteraction(wallet, contract.methods.emit_nullifier(Fr.random()), {
|
|
87
|
+
from: fundedAccountManager.address,
|
|
88
|
+
});
|
|
102
89
|
const txHash = tx.getTxHash();
|
|
103
90
|
logger.info(`Tx prepared with hash ${txHash}`);
|
|
104
91
|
return tx;
|
|
105
92
|
});
|
|
106
|
-
|
|
107
|
-
return { txs, pxeService: pxe, node };
|
|
108
93
|
}
|
|
109
94
|
|
|
110
95
|
export function awaitProposalExecution(
|
|
@@ -164,26 +149,31 @@ export async function awaitOffenseDetected({
|
|
|
164
149
|
nodeAdmin,
|
|
165
150
|
slashingRoundSize,
|
|
166
151
|
epochDuration,
|
|
152
|
+
waitUntilOffenseCount,
|
|
153
|
+
timeoutSeconds = 120,
|
|
167
154
|
}: {
|
|
168
155
|
nodeAdmin: AztecNodeAdmin;
|
|
169
156
|
logger: Logger;
|
|
170
157
|
slashingRoundSize: number;
|
|
171
158
|
epochDuration: number;
|
|
159
|
+
waitUntilOffenseCount?: number;
|
|
160
|
+
timeoutSeconds?: number;
|
|
172
161
|
}) {
|
|
173
|
-
|
|
162
|
+
const targetOffenseCount = waitUntilOffenseCount ?? 1;
|
|
163
|
+
logger.warn(`Waiting for ${pluralize('offense', targetOffenseCount)} to be detected`);
|
|
174
164
|
const offenses = await retryUntil(
|
|
175
165
|
async () => {
|
|
176
166
|
const offenses = await nodeAdmin.getSlashOffenses('all');
|
|
177
|
-
if (offenses.length
|
|
167
|
+
if (offenses.length >= targetOffenseCount) {
|
|
178
168
|
return offenses;
|
|
179
169
|
}
|
|
180
170
|
},
|
|
181
171
|
'non-empty offenses',
|
|
182
|
-
|
|
172
|
+
timeoutSeconds,
|
|
183
173
|
);
|
|
184
174
|
logger.info(
|
|
185
175
|
`Hit ${offenses.length} offenses on rounds ${unique(offenses.map(o => getRoundForOffense(o, { slashingRoundSize, epochDuration })))}`,
|
|
186
|
-
offenses,
|
|
176
|
+
{ offenses },
|
|
187
177
|
);
|
|
188
178
|
return offenses;
|
|
189
179
|
}
|
|
@@ -200,8 +190,9 @@ export async function awaitCommitteeKicked({
|
|
|
200
190
|
slashingProposer,
|
|
201
191
|
slashingRoundSize,
|
|
202
192
|
aztecSlotDuration,
|
|
193
|
+
aztecEpochDuration,
|
|
203
194
|
logger,
|
|
204
|
-
|
|
195
|
+
offenseEpoch,
|
|
205
196
|
}: {
|
|
206
197
|
rollup: RollupContract;
|
|
207
198
|
cheatCodes: RollupCheatCodes;
|
|
@@ -210,20 +201,22 @@ export async function awaitCommitteeKicked({
|
|
|
210
201
|
slashingProposer: EmpireSlashingProposerContract | TallySlashingProposerContract | undefined;
|
|
211
202
|
slashingRoundSize: number;
|
|
212
203
|
aztecSlotDuration: number;
|
|
213
|
-
|
|
204
|
+
aztecEpochDuration: number;
|
|
214
205
|
logger: Logger;
|
|
206
|
+
offenseEpoch: number;
|
|
215
207
|
}) {
|
|
216
208
|
if (!slashingProposer) {
|
|
217
209
|
throw new Error('No slashing proposer configured. Cannot test slashing.');
|
|
218
210
|
}
|
|
219
211
|
|
|
220
|
-
logger.info(`Advancing epochs so we start slashing`);
|
|
221
212
|
await cheatCodes.debugRollup();
|
|
222
|
-
await cheatCodes.advanceToNextEpoch({ updateDateProvider: dateProvider });
|
|
223
|
-
await cheatCodes.advanceToNextEpoch({ updateDateProvider: dateProvider });
|
|
224
213
|
|
|
225
|
-
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
226
214
|
if (slashingProposer.type === 'empire') {
|
|
215
|
+
// Await for the slash payload to be created if empire (no payload is created on tally until execution time)
|
|
216
|
+
const targetEpoch = (await cheatCodes.getEpoch()) + (await rollup.getLagInEpochs()) + 1n;
|
|
217
|
+
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
218
|
+
await cheatCodes.advanceToEpoch(targetEpoch);
|
|
219
|
+
|
|
227
220
|
const slashPayloadEvents = await retryUntil(
|
|
228
221
|
async () => {
|
|
229
222
|
const events = await slashFactory.getSlashPayloadCreatedEvents();
|
|
@@ -238,6 +231,15 @@ export async function awaitCommitteeKicked({
|
|
|
238
231
|
expect(unique(slashPayloadEvents[0].slashes.map(slash => slash.validator.toString()))).toHaveLength(
|
|
239
232
|
committee.length,
|
|
240
233
|
);
|
|
234
|
+
} else {
|
|
235
|
+
// Use the slash offset to ensure we are in the right epoch for tally
|
|
236
|
+
const slashOffsetInRounds = await slashingProposer.getSlashOffsetInRounds();
|
|
237
|
+
const slashingRoundSizeInEpochs = slashingRoundSize / aztecEpochDuration;
|
|
238
|
+
const slashingOffsetInEpochs = Number(slashOffsetInRounds) * slashingRoundSizeInEpochs;
|
|
239
|
+
const firstEpochInOffenseRound = offenseEpoch - (offenseEpoch % slashingRoundSizeInEpochs);
|
|
240
|
+
const targetEpoch = firstEpochInOffenseRound + slashingOffsetInEpochs;
|
|
241
|
+
logger.info(`Advancing to epoch ${targetEpoch} so we start slashing`);
|
|
242
|
+
await cheatCodes.advanceToEpoch(targetEpoch, { offset: -aztecSlotDuration / 2 });
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
const attestersPre = await rollup.getAttesters();
|
|
@@ -248,7 +250,7 @@ export async function awaitCommitteeKicked({
|
|
|
248
250
|
expect(attesterInfo.status).toEqual(1); // Validating
|
|
249
251
|
}
|
|
250
252
|
|
|
251
|
-
const timeout = slashingRoundSize * 2 * aztecSlotDuration;
|
|
253
|
+
const timeout = slashingRoundSize * 2 * aztecSlotDuration + 30;
|
|
252
254
|
logger.info(`Waiting for slash to be executed (timeout ${timeout}s)`);
|
|
253
255
|
await awaitProposalExecution(slashingProposer, timeout, logger);
|
|
254
256
|
|
|
@@ -265,10 +267,9 @@ export async function awaitCommitteeKicked({
|
|
|
265
267
|
expect(attesterInfo.status).toEqual(2); // Living
|
|
266
268
|
}
|
|
267
269
|
|
|
268
|
-
logger.info(`Advancing
|
|
270
|
+
logger.info(`Advancing to check current committee`);
|
|
269
271
|
await cheatCodes.debugRollup();
|
|
270
|
-
await cheatCodes.
|
|
271
|
-
await cheatCodes.advanceToNextEpoch({ updateDateProvider: dateProvider });
|
|
272
|
+
await cheatCodes.advanceToEpoch((await cheatCodes.getEpoch()) + (await rollup.getLagInEpochs()) + 1n);
|
|
272
273
|
await cheatCodes.debugRollup();
|
|
273
274
|
|
|
274
275
|
const committeeNextEpoch = await rollup.getCurrentEpochCommittee();
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type
|
|
1
|
+
import { AztecAddress } from '@aztec/aztec.js/addresses';
|
|
2
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
3
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
3
4
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
4
5
|
import { InvalidAccountContract } from '@aztec/noir-test-contracts.js/InvalidAccount';
|
|
6
|
+
import type { TestWallet } from '@aztec/test-wallet/server';
|
|
5
7
|
|
|
6
8
|
import { jest } from '@jest/globals';
|
|
7
9
|
|
|
@@ -28,11 +30,9 @@ export class TokenContractTest {
|
|
|
28
30
|
node!: AztecNode;
|
|
29
31
|
|
|
30
32
|
badAccount!: InvalidAccountContract;
|
|
31
|
-
|
|
33
|
+
wallet!: TestWallet;
|
|
32
34
|
adminAddress!: AztecAddress;
|
|
33
|
-
account1!: AccountWallet;
|
|
34
35
|
account1Address!: AztecAddress;
|
|
35
|
-
account2!: AccountWallet;
|
|
36
36
|
account2Address!: AztecAddress;
|
|
37
37
|
|
|
38
38
|
constructor(testName: string) {
|
|
@@ -54,11 +54,11 @@ export class TokenContractTest {
|
|
|
54
54
|
await this.snapshotManager.snapshot(
|
|
55
55
|
'3_accounts',
|
|
56
56
|
deployAccounts(3, this.logger),
|
|
57
|
-
|
|
57
|
+
({ deployedAccounts }, { wallet, aztecNode }) => {
|
|
58
58
|
this.node = aztecNode;
|
|
59
|
-
|
|
60
|
-
[this.
|
|
61
|
-
|
|
59
|
+
this.wallet = wallet;
|
|
60
|
+
[this.adminAddress, this.account1Address, this.account2Address] = deployedAccounts.map(acc => acc.address);
|
|
61
|
+
return Promise.resolve();
|
|
62
62
|
},
|
|
63
63
|
);
|
|
64
64
|
|
|
@@ -68,11 +68,11 @@ export class TokenContractTest {
|
|
|
68
68
|
// Create the token contract state.
|
|
69
69
|
// Move this account thing to addAccounts above?
|
|
70
70
|
this.logger.verbose(`Public deploy accounts...`);
|
|
71
|
-
await publicDeployAccounts(this.
|
|
71
|
+
await publicDeployAccounts(this.wallet, [this.adminAddress, this.account1Address]);
|
|
72
72
|
|
|
73
73
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
74
74
|
const asset = await TokenContract.deploy(
|
|
75
|
-
this.
|
|
75
|
+
this.wallet,
|
|
76
76
|
this.adminAddress,
|
|
77
77
|
TokenContractTest.TOKEN_NAME,
|
|
78
78
|
TokenContractTest.TOKEN_SYMBOL,
|
|
@@ -83,22 +83,22 @@ export class TokenContractTest {
|
|
|
83
83
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
84
84
|
|
|
85
85
|
this.logger.verbose(`Deploying bad account...`);
|
|
86
|
-
this.badAccount = await InvalidAccountContract.deploy(this.
|
|
86
|
+
this.badAccount = await InvalidAccountContract.deploy(this.wallet).send({ from: this.adminAddress }).deployed();
|
|
87
87
|
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
88
88
|
|
|
89
89
|
return { tokenContractAddress: asset.address, badAccountAddress: this.badAccount.address };
|
|
90
90
|
},
|
|
91
91
|
async ({ tokenContractAddress, badAccountAddress }) => {
|
|
92
92
|
// Restore the token contract state.
|
|
93
|
-
this.asset = await TokenContract.at(tokenContractAddress, this.
|
|
93
|
+
this.asset = await TokenContract.at(tokenContractAddress, this.wallet);
|
|
94
94
|
this.logger.verbose(`Token contract address: ${this.asset.address}`);
|
|
95
95
|
|
|
96
|
-
this.tokenSim = new TokenSimulator(this.asset, this.
|
|
96
|
+
this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
|
|
97
97
|
this.adminAddress,
|
|
98
98
|
this.account1Address,
|
|
99
99
|
]);
|
|
100
100
|
|
|
101
|
-
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.
|
|
101
|
+
this.badAccount = await InvalidAccountContract.at(badAccountAddress, this.wallet);
|
|
102
102
|
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
103
103
|
|
|
104
104
|
expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
|
|
@@ -131,14 +131,14 @@ export class TokenContractTest {
|
|
|
131
131
|
await this.snapshotManager.snapshot(
|
|
132
132
|
'mint',
|
|
133
133
|
async () => {
|
|
134
|
-
const { asset,
|
|
134
|
+
const { asset, adminAddress } = this;
|
|
135
135
|
const amount = 10000n;
|
|
136
136
|
|
|
137
137
|
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
138
138
|
await asset.methods.mint_to_public(adminAddress, amount).send({ from: adminAddress }).wait();
|
|
139
139
|
|
|
140
140
|
this.logger.verbose(`Minting ${amount} privately...`);
|
|
141
|
-
await mintTokensToPrivate(asset, adminAddress,
|
|
141
|
+
await mintTokensToPrivate(asset, adminAddress, adminAddress, amount);
|
|
142
142
|
this.logger.verbose(`Minting complete.`);
|
|
143
143
|
|
|
144
144
|
return { amount };
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SchnorrAccountContractArtifact,
|
|
3
|
-
getSchnorrAccount,
|
|
4
|
-
getSchnorrWalletWithSecretKey,
|
|
5
|
-
} from '@aztec/accounts/schnorr';
|
|
6
1
|
import type { InitialAccountData } from '@aztec/accounts/testing';
|
|
7
2
|
import { type Archiver, createArchiver } from '@aztec/archiver';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
type CompleteAddress,
|
|
12
|
-
EthAddress,
|
|
13
|
-
type Logger,
|
|
14
|
-
type PXE,
|
|
15
|
-
createLogger,
|
|
16
|
-
} from '@aztec/aztec.js';
|
|
3
|
+
import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
|
|
4
|
+
import { type Logger, createLogger } from '@aztec/aztec.js/log';
|
|
5
|
+
import type { AztecNode } from '@aztec/aztec.js/node';
|
|
17
6
|
import { CheatCodes } from '@aztec/aztec/testing';
|
|
18
7
|
import {
|
|
19
8
|
BBCircuitVerifier,
|
|
@@ -29,8 +18,8 @@ import { SecretValue } from '@aztec/foundation/config';
|
|
|
29
18
|
import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts';
|
|
30
19
|
import { TokenContract } from '@aztec/noir-contracts.js/Token';
|
|
31
20
|
import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
|
|
32
|
-
import type { PXEService } from '@aztec/pxe/server';
|
|
33
21
|
import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
|
|
22
|
+
import { TestWallet } from '@aztec/test-wallet/server';
|
|
34
23
|
import { getGenesisValues } from '@aztec/world-state/testing';
|
|
35
24
|
|
|
36
25
|
import { type Hex, getContract } from 'viem';
|
|
@@ -46,12 +35,12 @@ import {
|
|
|
46
35
|
deployAccounts,
|
|
47
36
|
publicDeployAccounts,
|
|
48
37
|
} from './snapshot_manager.js';
|
|
49
|
-
import { getPrivateKeyFromIndex, getSponsoredFPCAddress,
|
|
38
|
+
import { getPrivateKeyFromIndex, getSponsoredFPCAddress, setupPXEAndGetWallet } from './utils.js';
|
|
50
39
|
|
|
51
40
|
const { E2E_DATA_PATH: dataPath } = process.env;
|
|
52
41
|
|
|
53
42
|
type ProvenSetup = {
|
|
54
|
-
|
|
43
|
+
wallet: TestWallet;
|
|
55
44
|
teardown: () => Promise<void>;
|
|
56
45
|
};
|
|
57
46
|
|
|
@@ -68,21 +57,21 @@ export class FullProverTest {
|
|
|
68
57
|
static TOKEN_DECIMALS = 18n;
|
|
69
58
|
private snapshotManager: ISnapshotManager;
|
|
70
59
|
logger: Logger;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
accounts:
|
|
60
|
+
wallet!: TestWallet;
|
|
61
|
+
provenWallet!: TestWallet;
|
|
62
|
+
accounts: AztecAddress[] = [];
|
|
63
|
+
deployedAccounts!: InitialAccountData[];
|
|
74
64
|
fakeProofsAsset!: TokenContract;
|
|
75
65
|
tokenSim!: TokenSimulator;
|
|
76
66
|
aztecNode!: AztecNode;
|
|
77
67
|
aztecNodeAdmin!: AztecNodeAdmin;
|
|
78
|
-
pxe!: PXEService;
|
|
79
68
|
cheatCodes!: CheatCodes;
|
|
80
69
|
blobSink!: BlobSinkServer;
|
|
81
70
|
private provenComponents: ProvenSetup[] = [];
|
|
82
71
|
private bbConfigCleanup?: () => Promise<void>;
|
|
83
72
|
private acvmConfigCleanup?: () => Promise<void>;
|
|
84
73
|
circuitProofVerifier?: ClientProtocolCircuitVerifier;
|
|
85
|
-
|
|
74
|
+
provenAsset!: TokenContract;
|
|
86
75
|
private context!: SubsystemsContext;
|
|
87
76
|
private proverNode!: ProverNode;
|
|
88
77
|
private simulatedProverNode!: ProverNode;
|
|
@@ -115,13 +104,11 @@ export class FullProverTest {
|
|
|
115
104
|
await this.snapshotManager.snapshot(
|
|
116
105
|
'2_accounts',
|
|
117
106
|
deployAccounts(2, this.logger),
|
|
118
|
-
|
|
107
|
+
({ deployedAccounts }, { wallet }) => {
|
|
119
108
|
this.deployedAccounts = deployedAccounts;
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
);
|
|
123
|
-
this.accounts = this.wallets.map(w => w.getCompleteAddress());
|
|
124
|
-
this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
|
|
109
|
+
this.accounts = deployedAccounts.map(a => a.address);
|
|
110
|
+
this.wallet = wallet;
|
|
111
|
+
return Promise.resolve();
|
|
125
112
|
},
|
|
126
113
|
);
|
|
127
114
|
|
|
@@ -131,17 +118,17 @@ export class FullProverTest {
|
|
|
131
118
|
// Create the token contract state.
|
|
132
119
|
// Move this account thing to addAccounts above?
|
|
133
120
|
this.logger.verbose(`Public deploy accounts...`);
|
|
134
|
-
await publicDeployAccounts(this.
|
|
121
|
+
await publicDeployAccounts(this.wallet, this.accounts.slice(0, 2));
|
|
135
122
|
|
|
136
123
|
this.logger.verbose(`Deploying TokenContract...`);
|
|
137
124
|
const asset = await TokenContract.deploy(
|
|
138
|
-
this.
|
|
125
|
+
this.wallet,
|
|
139
126
|
this.accounts[0],
|
|
140
127
|
FullProverTest.TOKEN_NAME,
|
|
141
128
|
FullProverTest.TOKEN_SYMBOL,
|
|
142
129
|
FullProverTest.TOKEN_DECIMALS,
|
|
143
130
|
)
|
|
144
|
-
.send({ from: this.
|
|
131
|
+
.send({ from: this.accounts[0] })
|
|
145
132
|
.deployed();
|
|
146
133
|
this.logger.verbose(`Token deployed to ${asset.address}`);
|
|
147
134
|
|
|
@@ -149,19 +136,19 @@ export class FullProverTest {
|
|
|
149
136
|
},
|
|
150
137
|
async ({ tokenContractAddress }) => {
|
|
151
138
|
// Restore the token contract state.
|
|
152
|
-
this.fakeProofsAsset = await TokenContract.at(tokenContractAddress, this.
|
|
139
|
+
this.fakeProofsAsset = await TokenContract.at(tokenContractAddress, this.wallet);
|
|
153
140
|
this.logger.verbose(`Token contract address: ${this.fakeProofsAsset.address}`);
|
|
154
141
|
|
|
155
142
|
this.tokenSim = new TokenSimulator(
|
|
156
143
|
this.fakeProofsAsset,
|
|
157
|
-
this.
|
|
158
|
-
this.
|
|
144
|
+
this.wallet,
|
|
145
|
+
this.accounts[0],
|
|
159
146
|
this.logger,
|
|
160
|
-
this.accounts
|
|
147
|
+
this.accounts,
|
|
161
148
|
);
|
|
162
149
|
|
|
163
|
-
expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0]
|
|
164
|
-
this.accounts[0].
|
|
150
|
+
expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0] })).toBe(
|
|
151
|
+
this.accounts[0].toBigInt(),
|
|
165
152
|
);
|
|
166
153
|
},
|
|
167
154
|
);
|
|
@@ -175,7 +162,6 @@ export class FullProverTest {
|
|
|
175
162
|
|
|
176
163
|
this.simulatedProverNode = this.context.proverNode!;
|
|
177
164
|
({
|
|
178
|
-
pxe: this.pxe,
|
|
179
165
|
aztecNode: this.aztecNode,
|
|
180
166
|
deployL1ContractsValues: this.l1Contracts,
|
|
181
167
|
cheatCodes: this.cheatCodes,
|
|
@@ -224,51 +210,31 @@ export class FullProverTest {
|
|
|
224
210
|
await this.context.cheatCodes.rollup.markAsProven();
|
|
225
211
|
|
|
226
212
|
this.logger.verbose(`Main setup completed, initializing full prover PXE, Node, and Prover Node`);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
-
});
|
|
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);
|
|
263
225
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
this.
|
|
267
|
-
pxe: result.pxe,
|
|
268
|
-
teardown: result.teardown,
|
|
269
|
-
});
|
|
270
|
-
this.provenAssets.push(asset);
|
|
226
|
+
for (let i = 0; i < 2; i++) {
|
|
227
|
+
await provenWallet.createSchnorrAccount(this.deployedAccounts[i].secret, this.deployedAccounts[i].salt);
|
|
228
|
+
await this.wallet.createSchnorrAccount(this.deployedAccounts[i].secret, this.deployedAccounts[i].salt);
|
|
271
229
|
}
|
|
230
|
+
|
|
231
|
+
const asset = await TokenContract.at(this.fakeProofsAsset.address, provenWallet);
|
|
232
|
+
this.provenComponents.push({
|
|
233
|
+
wallet: provenWallet,
|
|
234
|
+
teardown: provenTeardown,
|
|
235
|
+
});
|
|
236
|
+
this.provenAsset = asset;
|
|
237
|
+
this.provenWallet = provenWallet;
|
|
272
238
|
this.logger.info(`Full prover PXE started`);
|
|
273
239
|
|
|
274
240
|
// Shutdown the current, simulated prover node
|
|
@@ -308,6 +274,7 @@ export class FullProverTest {
|
|
|
308
274
|
txGatheringMaxParallelRequestsPerNode: 100,
|
|
309
275
|
txGatheringTimeoutMs: 24_000,
|
|
310
276
|
proverNodeFailedEpochStore: undefined,
|
|
277
|
+
proverNodeEpochProvingDelayMs: undefined,
|
|
311
278
|
};
|
|
312
279
|
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
313
280
|
const { prefilledPublicData } = await getGenesisValues(
|
|
@@ -368,15 +335,12 @@ export class FullProverTest {
|
|
|
368
335
|
|
|
369
336
|
this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
|
|
370
337
|
await asset.methods
|
|
371
|
-
.mint_to_public(accounts[0]
|
|
372
|
-
.send({ from: accounts[0]
|
|
338
|
+
.mint_to_public(accounts[0], privateAmount + publicAmount)
|
|
339
|
+
.send({ from: accounts[0] })
|
|
373
340
|
.wait();
|
|
374
341
|
|
|
375
342
|
this.logger.verbose(`Transferring ${privateAmount} to private...`);
|
|
376
|
-
await asset.methods
|
|
377
|
-
.transfer_to_private(accounts[0].address, privateAmount)
|
|
378
|
-
.send({ from: accounts[0].address })
|
|
379
|
-
.wait();
|
|
343
|
+
await asset.methods.transfer_to_private(accounts[0], privateAmount).send({ from: accounts[0] }).wait();
|
|
380
344
|
|
|
381
345
|
this.logger.verbose(`Minting complete.`);
|
|
382
346
|
|
|
@@ -385,7 +349,7 @@ export class FullProverTest {
|
|
|
385
349
|
async ({ amount }) => {
|
|
386
350
|
const {
|
|
387
351
|
fakeProofsAsset: asset,
|
|
388
|
-
accounts: [
|
|
352
|
+
accounts: [address],
|
|
389
353
|
tokenSim,
|
|
390
354
|
} = this;
|
|
391
355
|
tokenSim.mintPublic(address, amount);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
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';
|
|
8
9
|
|
|
9
10
|
const {
|
|
10
11
|
BB_RELEASE_DIR = 'barretenberg/cpp/build/bin',
|
|
@@ -22,7 +23,7 @@ export const getBBConfig = async (
|
|
|
22
23
|
try {
|
|
23
24
|
const bbBinaryPath =
|
|
24
25
|
BB_BINARY_PATH ??
|
|
25
|
-
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb');
|
|
26
|
+
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb-avm');
|
|
26
27
|
await fs.access(bbBinaryPath, fs.constants.R_OK);
|
|
27
28
|
|
|
28
29
|
let bbWorkingDirectory: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Logger } from '@aztec/aztec.js';
|
|
1
|
+
import type { Logger } from '@aztec/aztec.js/log';
|
|
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 { protocolContractsHash } 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
|
+
protocolContractsHash,
|
|
20
20
|
salt: undefined,
|
|
21
21
|
realVerifier: false,
|
|
22
22
|
...args,
|