@aztec/end-to-end 4.0.0-nightly.20260113 → 4.0.0-nightly.20260114
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/client_flows_benchmark.d.ts +10 -10
- package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
- package/dest/bench/client_flows/client_flows_benchmark.js +98 -133
- package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +5 -6
- 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 +94 -112
- package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +5 -5
- 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 +60 -62
- package/dest/e2e_deploy_contract/deploy_test.d.ts +4 -3
- package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
- package/dest/e2e_deploy_contract/deploy_test.js +15 -13
- package/dest/e2e_fees/bridging_race.notest.js +2 -4
- package/dest/e2e_fees/fees_test.d.ts +11 -11
- package/dest/e2e_fees/fees_test.d.ts.map +1 -1
- package/dest/e2e_fees/fees_test.js +118 -139
- package/dest/e2e_l1_publisher/write_json.d.ts +1 -1
- package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
- package/dest/e2e_l1_publisher/write_json.js +1 -0
- package/dest/e2e_nested_contract/nested_contract_test.d.ts +5 -8
- package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
- package/dest/e2e_nested_contract/nested_contract_test.js +29 -40
- package/dest/e2e_p2p/inactivity_slash_test.js +1 -1
- package/dest/e2e_p2p/p2p_network.d.ts +5 -3
- package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
- package/dest/e2e_p2p/p2p_network.js +99 -102
- package/dest/e2e_token_contract/token_contract_test.d.ts +15 -8
- package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
- package/dest/e2e_token_contract/token_contract_test.js +88 -92
- package/dest/fixtures/e2e_prover_test.d.ts +7 -13
- package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
- package/dest/fixtures/e2e_prover_test.js +78 -91
- package/dest/fixtures/snapshot_manager.d.ts +10 -44
- package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
- package/dest/fixtures/snapshot_manager.js +12 -255
- package/dest/fixtures/utils.js +3 -3
- package/dest/quality_of_service/prometheus_client.d.ts +38 -0
- package/dest/quality_of_service/prometheus_client.d.ts.map +1 -0
- package/dest/quality_of_service/prometheus_client.js +67 -0
- package/dest/spartan/tx_metrics.d.ts +4 -1
- package/dest/spartan/tx_metrics.d.ts.map +1 -1
- package/dest/spartan/tx_metrics.js +21 -1
- package/dest/spartan/utils.d.ts +5 -1
- package/dest/spartan/utils.d.ts.map +1 -1
- package/dest/spartan/utils.js +25 -8
- package/package.json +38 -38
- package/src/bench/client_flows/client_flows_benchmark.ts +134 -192
- package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +104 -136
- package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +91 -103
- package/src/e2e_deploy_contract/deploy_test.ts +18 -14
- package/src/e2e_fees/bridging_race.notest.ts +2 -5
- package/src/e2e_fees/fees_test.ts +165 -210
- package/src/e2e_l1_publisher/write_json.ts +1 -0
- package/src/e2e_nested_contract/nested_contract_test.ts +30 -54
- package/src/e2e_p2p/inactivity_slash_test.ts +1 -1
- package/src/e2e_p2p/p2p_network.ts +149 -165
- package/src/e2e_token_contract/token_contract_test.ts +104 -113
- package/src/fixtures/e2e_prover_test.ts +97 -130
- package/src/fixtures/snapshot_manager.ts +12 -325
- package/src/fixtures/utils.ts +3 -3
- package/src/quality_of_service/prometheus_client.ts +113 -0
- package/src/spartan/tx_metrics.ts +21 -1
- package/src/spartan/utils.ts +26 -8
|
@@ -39,12 +39,7 @@ import {
|
|
|
39
39
|
createValidatorConfig,
|
|
40
40
|
generatePrivateKeys,
|
|
41
41
|
} from '../fixtures/setup_p2p_test.js';
|
|
42
|
-
import {
|
|
43
|
-
type ISnapshotManager,
|
|
44
|
-
type SubsystemsContext,
|
|
45
|
-
createSnapshotManager,
|
|
46
|
-
deployAccounts,
|
|
47
|
-
} from '../fixtures/snapshot_manager.js';
|
|
42
|
+
import { type SubsystemsContext, deployAccounts, setupFromFresh, teardown } from '../fixtures/snapshot_manager.js';
|
|
48
43
|
import { type SetupOptions, getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
|
|
49
44
|
import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
|
|
50
45
|
|
|
@@ -60,7 +55,7 @@ export const SHORTENED_BLOCK_TIME_CONFIG_NO_PRUNES = {
|
|
|
60
55
|
};
|
|
61
56
|
|
|
62
57
|
export class P2PNetworkTest {
|
|
63
|
-
|
|
58
|
+
public context!: SubsystemsContext;
|
|
64
59
|
public baseAccountPrivateKey: `0x${string}`;
|
|
65
60
|
public baseAccount;
|
|
66
61
|
|
|
@@ -83,6 +78,10 @@ export class P2PNetworkTest {
|
|
|
83
78
|
|
|
84
79
|
public bootstrapNode?: BootstrapNode;
|
|
85
80
|
|
|
81
|
+
// Store setup options for use in setup()
|
|
82
|
+
private setupOptions: SetupOptions;
|
|
83
|
+
private deployL1ContractsArgs: any;
|
|
84
|
+
|
|
86
85
|
constructor(
|
|
87
86
|
public readonly testName: string,
|
|
88
87
|
public bootstrapNodeEnr: string,
|
|
@@ -107,43 +106,41 @@ export class P2PNetworkTest {
|
|
|
107
106
|
|
|
108
107
|
const zkPassportParams = ZkPassportProofParams.random();
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
slashingRoundSizeInEpochs
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
aztecProofSubmissionEpochs
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
zkPassportScope: zkPassportParams.scope,
|
|
144
|
-
},
|
|
109
|
+
// Store setup options for later use
|
|
110
|
+
this.setupOptions = {
|
|
111
|
+
...initialValidatorConfig,
|
|
112
|
+
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
113
|
+
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
114
|
+
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
115
|
+
aztecProofSubmissionEpochs:
|
|
116
|
+
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
117
|
+
slashingRoundSizeInEpochs:
|
|
118
|
+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
119
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
120
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
121
|
+
metricsPort: metricsPort,
|
|
122
|
+
numberOfInitialFundedAccounts: 2,
|
|
123
|
+
startProverNode,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
this.deployL1ContractsArgs = {
|
|
127
|
+
...initialValidatorConfig,
|
|
128
|
+
aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
|
|
129
|
+
slashingRoundSizeInEpochs:
|
|
130
|
+
initialValidatorConfig.slashingRoundSizeInEpochs ?? l1ContractsConfig.slashingRoundSizeInEpochs,
|
|
131
|
+
slasherFlavor: initialValidatorConfig.slasherFlavor ?? 'tally',
|
|
132
|
+
|
|
133
|
+
ethereumSlotDuration: initialValidatorConfig.ethereumSlotDuration ?? l1ContractsConfig.ethereumSlotDuration,
|
|
134
|
+
aztecSlotDuration: initialValidatorConfig.aztecSlotDuration ?? l1ContractsConfig.aztecSlotDuration,
|
|
135
|
+
aztecProofSubmissionEpochs:
|
|
136
|
+
initialValidatorConfig.aztecProofSubmissionEpochs ?? l1ContractsConfig.aztecProofSubmissionEpochs,
|
|
137
|
+
aztecTargetCommitteeSize: numberOfValidators,
|
|
138
|
+
initialValidators: [],
|
|
139
|
+
zkPassportArgs: {
|
|
140
|
+
zkPassportDomain: zkPassportParams.domain,
|
|
141
|
+
zkPassportScope: zkPassportParams.scope,
|
|
145
142
|
},
|
|
146
|
-
|
|
143
|
+
};
|
|
147
144
|
}
|
|
148
145
|
|
|
149
146
|
static async create({
|
|
@@ -187,23 +184,22 @@ export class P2PNetworkTest {
|
|
|
187
184
|
|
|
188
185
|
get fundedAccount() {
|
|
189
186
|
if (!this.deployedAccounts[0]) {
|
|
190
|
-
throw new Error('Call
|
|
187
|
+
throw new Error('Call setupAccount to create a funded account.');
|
|
191
188
|
}
|
|
192
189
|
return this.deployedAccounts[0];
|
|
193
190
|
}
|
|
194
191
|
|
|
195
192
|
async addBootstrapNode() {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
});
|
|
193
|
+
this.logger.info('Adding bootstrap node');
|
|
194
|
+
const telemetry = await getEndToEndTestTelemetryClient(this.metricsPort);
|
|
195
|
+
this.bootstrapNode = await createBootstrapNodeFromPrivateKey(
|
|
196
|
+
BOOTSTRAP_NODE_PRIVATE_KEY,
|
|
197
|
+
this.bootNodePort,
|
|
198
|
+
telemetry,
|
|
199
|
+
this.context.aztecNodeConfig,
|
|
200
|
+
);
|
|
201
|
+
// Overwrite enr with updated info
|
|
202
|
+
this.bootstrapNodeEnr = this.bootstrapNode.getENR().encodeTxt();
|
|
207
203
|
}
|
|
208
204
|
|
|
209
205
|
getValidators() {
|
|
@@ -224,128 +220,114 @@ export class P2PNetworkTest {
|
|
|
224
220
|
return { validators };
|
|
225
221
|
}
|
|
226
222
|
|
|
227
|
-
async
|
|
223
|
+
async applyBaseSetup() {
|
|
228
224
|
await this.addBootstrapNode();
|
|
229
|
-
await this.snapshotManager.snapshot('add-validators', async ({ deployL1ContractsValues, cheatCodes }) => {
|
|
230
|
-
const rollup = getContract({
|
|
231
|
-
address: deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
232
|
-
abi: RollupAbi,
|
|
233
|
-
client: deployL1ContractsValues.l1Client,
|
|
234
|
-
});
|
|
235
225
|
|
|
236
|
-
|
|
226
|
+
this.logger.info('Adding validators');
|
|
227
|
+
const rollup = getContract({
|
|
228
|
+
address: this.context.deployL1ContractsValues.l1ContractAddresses.rollupAddress.toString(),
|
|
229
|
+
abi: RollupAbi,
|
|
230
|
+
client: this.context.deployL1ContractsValues.l1Client,
|
|
231
|
+
});
|
|
237
232
|
|
|
238
|
-
|
|
239
|
-
address: deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
240
|
-
abi: TestERC20Abi,
|
|
241
|
-
client: deployL1ContractsValues.l1Client,
|
|
242
|
-
});
|
|
233
|
+
this.logger.info(`Adding ${this.numberOfValidators} validators`);
|
|
243
234
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
const multiAdder = getContract({
|
|
252
|
-
address: multiAdderAddress.toString(),
|
|
253
|
-
abi: MultiAdderArtifact.contractAbi,
|
|
254
|
-
client: deployL1ContractsValues.l1Client,
|
|
255
|
-
});
|
|
235
|
+
const stakingAsset = getContract({
|
|
236
|
+
address: this.context.deployL1ContractsValues.l1ContractAddresses.stakingAssetAddress.toString(),
|
|
237
|
+
abi: TestERC20Abi,
|
|
238
|
+
client: this.context.deployL1ContractsValues.l1Client,
|
|
239
|
+
});
|
|
256
240
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
const { validators } = this.getValidators();
|
|
265
|
-
this.validators = validators;
|
|
266
|
-
|
|
267
|
-
const gseAddress = deployL1ContractsValues.l1ContractAddresses.gseAddress!;
|
|
268
|
-
if (!gseAddress) {
|
|
269
|
-
throw new Error('GSE contract not deployed');
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const gseContract = new GSEContract(deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
273
|
-
|
|
274
|
-
const makeValidatorTuples = async (validator: Operator) => {
|
|
275
|
-
const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
|
|
276
|
-
return {
|
|
277
|
-
attester: validator.attester.toString() as `0x${string}`,
|
|
278
|
-
withdrawer: validator.withdrawer.toString() as `0x${string}`,
|
|
279
|
-
...registrationTuple,
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
241
|
+
const { address: multiAdderAddress } = await deployL1Contract(
|
|
242
|
+
this.context.deployL1ContractsValues.l1Client,
|
|
243
|
+
MultiAdderArtifact.contractAbi,
|
|
244
|
+
MultiAdderArtifact.contractBytecode,
|
|
245
|
+
[rollup.address, this.context.deployL1ContractsValues.l1Client.account.address],
|
|
246
|
+
);
|
|
283
247
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
248
|
+
const multiAdder = getContract({
|
|
249
|
+
address: multiAdderAddress.toString(),
|
|
250
|
+
abi: MultiAdderArtifact.contractAbi,
|
|
251
|
+
client: this.context.deployL1ContractsValues.l1Client,
|
|
252
|
+
});
|
|
287
253
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
),
|
|
292
|
-
)
|
|
254
|
+
const stakeNeeded = (await rollup.read.getActivationThreshold()) * BigInt(this.numberOfValidators);
|
|
255
|
+
await Promise.all(
|
|
256
|
+
[await stakingAsset.write.mint([multiAdder.address, stakeNeeded], {} as any)].map(txHash =>
|
|
257
|
+
this.context.deployL1ContractsValues.l1Client.waitForTransactionReceipt({ hash: txHash }),
|
|
258
|
+
),
|
|
259
|
+
);
|
|
293
260
|
|
|
294
|
-
|
|
295
|
-
|
|
261
|
+
const { validators } = this.getValidators();
|
|
262
|
+
this.validators = validators;
|
|
263
|
+
|
|
264
|
+
const gseAddress = this.context.deployL1ContractsValues.l1ContractAddresses.gseAddress!;
|
|
265
|
+
if (!gseAddress) {
|
|
266
|
+
throw new Error('GSE contract not deployed');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const gseContract = new GSEContract(this.context.deployL1ContractsValues.l1Client, gseAddress.toString());
|
|
270
|
+
|
|
271
|
+
const makeValidatorTuples = async (validator: Operator) => {
|
|
272
|
+
const registrationTuple = await gseContract.makeRegistrationTuple(validator.bn254SecretKey.getValue());
|
|
273
|
+
return {
|
|
274
|
+
attester: validator.attester.toString() as `0x${string}`,
|
|
275
|
+
withdrawer: validator.withdrawer.toString() as `0x${string}`,
|
|
276
|
+
...registrationTuple,
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
const validatorTuples = await Promise.all(validators.map(makeValidatorTuples));
|
|
280
|
+
|
|
281
|
+
await this.context.deployL1ContractsValues.l1Client.waitForTransactionReceipt({
|
|
282
|
+
hash: await multiAdder.write.addValidators([validatorTuples]),
|
|
296
283
|
});
|
|
284
|
+
|
|
285
|
+
await this.context.cheatCodes.rollup.advanceToEpoch(
|
|
286
|
+
EpochNumber.fromBigInt(
|
|
287
|
+
BigInt(await this.context.cheatCodes.rollup.getEpoch()) +
|
|
288
|
+
(await rollup.read.getLagInEpochsForValidatorSet()) +
|
|
289
|
+
1n,
|
|
290
|
+
),
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
294
|
+
await this._sendDummyTx(this.context.deployL1ContractsValues.l1Client);
|
|
297
295
|
}
|
|
298
296
|
|
|
299
297
|
async setupAccount() {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
298
|
+
this.logger.info('Setting up account');
|
|
299
|
+
const { deployedAccounts } = await deployAccounts(
|
|
300
|
+
1,
|
|
301
|
+
this.logger,
|
|
302
|
+
)({
|
|
303
|
+
wallet: this.context.wallet,
|
|
304
|
+
initialFundedAccounts: this.context.initialFundedAccounts,
|
|
305
|
+
});
|
|
306
|
+
this.deployedAccounts = deployedAccounts;
|
|
307
|
+
[{ address: this.defaultAccountAddress }] = deployedAccounts;
|
|
308
|
+
this.wallet = this.context.wallet;
|
|
310
309
|
}
|
|
311
310
|
|
|
312
311
|
async deploySpamContract() {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
const spamContract = await SpamContract.deploy(this.wallet)
|
|
321
|
-
.send({ from: this.defaultAccountAddress! })
|
|
322
|
-
.deployed();
|
|
323
|
-
return { contractAddress: spamContract.address };
|
|
324
|
-
},
|
|
325
|
-
({ contractAddress }) => {
|
|
326
|
-
if (!this.wallet) {
|
|
327
|
-
throw new Error('Call snapshot t.setupAccount before deploying account contract');
|
|
328
|
-
}
|
|
329
|
-
this.spamContract = SpamContract.at(contractAddress, this.wallet);
|
|
330
|
-
return Promise.resolve();
|
|
331
|
-
},
|
|
332
|
-
);
|
|
312
|
+
this.logger.info('Deploying spam contract');
|
|
313
|
+
if (!this.wallet) {
|
|
314
|
+
throw new Error('Call setupAccount before deploying spam contract');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const spamContract = await SpamContract.deploy(this.wallet).send({ from: this.defaultAccountAddress! }).deployed();
|
|
318
|
+
this.spamContract = spamContract;
|
|
333
319
|
}
|
|
334
320
|
|
|
335
321
|
async removeInitialNode() {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
await aztecNode.stop();
|
|
347
|
-
},
|
|
348
|
-
);
|
|
322
|
+
this.logger.info('Removing initial node');
|
|
323
|
+
// Send and await a tx to make sure we mine a block for the warp to correctly progress.
|
|
324
|
+
const { receipt } = await this._sendDummyTx(this.context.deployL1ContractsValues.l1Client);
|
|
325
|
+
const block = await this.context.deployL1ContractsValues.l1Client.getBlock({
|
|
326
|
+
blockNumber: receipt.blockNumber,
|
|
327
|
+
});
|
|
328
|
+
this.context.dateProvider.setTime(Number(block.timestamp) * 1000);
|
|
329
|
+
|
|
330
|
+
await this.context.aztecNode.stop();
|
|
349
331
|
}
|
|
350
332
|
|
|
351
333
|
async sendDummyTx() {
|
|
@@ -361,17 +343,19 @@ export class P2PNetworkTest {
|
|
|
361
343
|
}
|
|
362
344
|
|
|
363
345
|
async setup() {
|
|
364
|
-
this.
|
|
346
|
+
this.logger.info('Setting up subsystems from fresh');
|
|
347
|
+
this.context = await setupFromFresh(this.logger, this.setupOptions, this.deployL1ContractsArgs);
|
|
348
|
+
this.ctx = this.context;
|
|
365
349
|
|
|
366
350
|
const sponsoredFPCAddress = await getSponsoredFPCAddress();
|
|
367
|
-
const initialFundedAccounts = [...this.
|
|
351
|
+
const initialFundedAccounts = [...this.context.initialFundedAccounts.map(a => a.address), sponsoredFPCAddress];
|
|
368
352
|
|
|
369
353
|
const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
|
|
370
354
|
this.prefilledPublicData = prefilledPublicData;
|
|
371
355
|
|
|
372
|
-
const rollupContract = RollupContract.getFromL1ContractsValues(this.
|
|
373
|
-
this.monitor = new ChainMonitor(rollupContract, this.
|
|
374
|
-
this.monitor.on('l1-block', ({ timestamp }) => this.
|
|
356
|
+
const rollupContract = RollupContract.getFromL1ContractsValues(this.context.deployL1ContractsValues);
|
|
357
|
+
this.monitor = new ChainMonitor(rollupContract, this.context.dateProvider).start();
|
|
358
|
+
this.monitor.on('l1-block', ({ timestamp }) => this.context.dateProvider.setTime(Number(timestamp) * 1000));
|
|
375
359
|
}
|
|
376
360
|
|
|
377
361
|
async stopNodes(nodes: AztecNodeService[]) {
|
|
@@ -432,7 +416,7 @@ export class P2PNetworkTest {
|
|
|
432
416
|
async teardown() {
|
|
433
417
|
await this.monitor.stop();
|
|
434
418
|
await tryStop(this.bootstrapNode, this.logger);
|
|
435
|
-
await this.
|
|
419
|
+
await teardown(this.context);
|
|
436
420
|
}
|
|
437
421
|
|
|
438
422
|
async getContracts(): Promise<{
|
|
@@ -8,23 +8,24 @@ import type { TestWallet } from '@aztec/test-wallet/server';
|
|
|
8
8
|
import { jest } from '@jest/globals';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
type ISnapshotManager,
|
|
12
11
|
type SubsystemsContext,
|
|
13
|
-
createSnapshotManager,
|
|
14
12
|
deployAccounts,
|
|
15
13
|
publicDeployAccounts,
|
|
14
|
+
setupFromFresh,
|
|
15
|
+
teardown,
|
|
16
16
|
} from '../fixtures/snapshot_manager.js';
|
|
17
17
|
import { mintTokensToPrivate } from '../fixtures/token_utils.js';
|
|
18
18
|
import { TokenSimulator } from '../simulators/token_simulator.js';
|
|
19
19
|
|
|
20
|
-
const {
|
|
20
|
+
const { METRICS_PORT: metricsPort } = process.env;
|
|
21
21
|
|
|
22
22
|
export class TokenContractTest {
|
|
23
23
|
static TOKEN_NAME = 'USDC';
|
|
24
24
|
static TOKEN_SYMBOL = 'USD';
|
|
25
25
|
static TOKEN_DECIMALS = 18n;
|
|
26
|
-
|
|
26
|
+
context!: SubsystemsContext;
|
|
27
27
|
logger: Logger;
|
|
28
|
+
metricsPort?: number;
|
|
28
29
|
asset!: TokenContract;
|
|
29
30
|
tokenSim!: TokenSimulator;
|
|
30
31
|
node!: AztecNode;
|
|
@@ -35,133 +36,123 @@ export class TokenContractTest {
|
|
|
35
36
|
account1Address!: AztecAddress;
|
|
36
37
|
account2Address!: AztecAddress;
|
|
37
38
|
|
|
39
|
+
private shouldApplyBaseSetup = false;
|
|
40
|
+
private shouldApplyMint = false;
|
|
41
|
+
|
|
38
42
|
constructor(testName: string) {
|
|
39
43
|
this.logger = createLogger(`e2e:e2e_token_contract:${testName}`);
|
|
40
|
-
this.
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
this.metricsPort = metricsPort ? parseInt(metricsPort) : undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Registers that base setup should be applied during setup().
|
|
49
|
+
* Call this before setup() to deploy 3 accounts, publicly deploy accounts, token contract and a "bad account".
|
|
50
|
+
*/
|
|
51
|
+
applyBaseSnapshots() {
|
|
52
|
+
this.shouldApplyBaseSetup = true;
|
|
43
53
|
}
|
|
44
54
|
|
|
45
55
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* 2. Publicly deploy accounts, deploy token contract and a "bad account".
|
|
56
|
+
* Registers that mint should be applied during setup().
|
|
57
|
+
* Call this before setup() to mint tokens to the admin account.
|
|
49
58
|
*/
|
|
50
|
-
|
|
59
|
+
applyMintSnapshot() {
|
|
60
|
+
this.shouldApplyMint = true;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Applies base setup: deploys 3 accounts, publicly deploys accounts, token contract and a "bad account".
|
|
65
|
+
*/
|
|
66
|
+
private async applyBaseSetup() {
|
|
51
67
|
// Adding a timeout of 2 minutes in here such that it is propagated to the underlying tests
|
|
52
68
|
jest.setTimeout(120_000);
|
|
53
69
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
);
|
|
70
|
+
this.logger.info('Applying base setup - deploying 3 accounts');
|
|
71
|
+
const { deployedAccounts } = await deployAccounts(
|
|
72
|
+
3,
|
|
73
|
+
this.logger,
|
|
74
|
+
)({
|
|
75
|
+
wallet: this.context.wallet,
|
|
76
|
+
initialFundedAccounts: this.context.initialFundedAccounts,
|
|
77
|
+
});
|
|
64
78
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
|
|
97
|
-
this.adminAddress,
|
|
98
|
-
this.account1Address,
|
|
99
|
-
]);
|
|
100
|
-
|
|
101
|
-
this.badAccount = InvalidAccountContract.at(badAccountAddress, this.wallet);
|
|
102
|
-
this.logger.verbose(`Bad account address: ${this.badAccount.address}`);
|
|
103
|
-
|
|
104
|
-
expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
|
|
105
|
-
this.adminAddress.toBigInt(),
|
|
106
|
-
);
|
|
107
|
-
},
|
|
79
|
+
this.node = this.context.aztecNode;
|
|
80
|
+
this.wallet = this.context.wallet;
|
|
81
|
+
[this.adminAddress, this.account1Address, this.account2Address] = deployedAccounts.map(acc => acc.address);
|
|
82
|
+
|
|
83
|
+
this.logger.info('Applying base setup - deploying token contract');
|
|
84
|
+
this.logger.verbose(`Public deploy accounts...`);
|
|
85
|
+
await publicDeployAccounts(this.wallet, [this.adminAddress, this.account1Address]);
|
|
86
|
+
|
|
87
|
+
this.logger.verbose(`Deploying TokenContract...`);
|
|
88
|
+
this.asset = await TokenContract.deploy(
|
|
89
|
+
this.wallet,
|
|
90
|
+
this.adminAddress,
|
|
91
|
+
TokenContractTest.TOKEN_NAME,
|
|
92
|
+
TokenContractTest.TOKEN_SYMBOL,
|
|
93
|
+
TokenContractTest.TOKEN_DECIMALS,
|
|
94
|
+
)
|
|
95
|
+
.send({ from: this.adminAddress })
|
|
96
|
+
.deployed();
|
|
97
|
+
this.logger.verbose(`Token deployed to ${this.asset.address}`);
|
|
98
|
+
|
|
99
|
+
this.logger.verbose(`Deploying bad account...`);
|
|
100
|
+
this.badAccount = await InvalidAccountContract.deploy(this.wallet).send({ from: this.adminAddress }).deployed();
|
|
101
|
+
this.logger.verbose(`Deployed to ${this.badAccount.address}.`);
|
|
102
|
+
|
|
103
|
+
this.tokenSim = new TokenSimulator(this.asset, this.wallet, this.adminAddress, this.logger, [
|
|
104
|
+
this.adminAddress,
|
|
105
|
+
this.account1Address,
|
|
106
|
+
]);
|
|
107
|
+
|
|
108
|
+
expect(await this.asset.methods.get_admin().simulate({ from: this.adminAddress })).toBe(
|
|
109
|
+
this.adminAddress.toBigInt(),
|
|
108
110
|
);
|
|
109
|
-
|
|
110
|
-
// TokenContract.artifact.functions.forEach(fn => {
|
|
111
|
-
// const sig = decodeFunctionSignature(fn.name, fn.parameters);
|
|
112
|
-
// logger.verbose(`Function ${sig} and the selector: ${FunctionSelector.fromNameAndParameters(fn.name, fn.parameters)}`);
|
|
113
|
-
// });
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
async setup() {
|
|
117
|
-
await this.
|
|
118
|
-
|
|
114
|
+
this.context = await setupFromFresh(this.logger, {
|
|
115
|
+
metricsPort: this.metricsPort,
|
|
116
|
+
});
|
|
119
117
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
if (this.shouldApplyBaseSetup) {
|
|
119
|
+
await this.applyBaseSetup();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (this.shouldApplyMint) {
|
|
123
|
+
await this.applyMint();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
125
126
|
|
|
126
127
|
async teardown() {
|
|
127
|
-
await this.
|
|
128
|
+
await teardown(this.context);
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
async
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
157
|
-
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
|
|
158
|
-
|
|
159
|
-
const totalSupply = await asset.methods.total_supply().simulate({ from: adminAddress });
|
|
160
|
-
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
161
|
-
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
162
|
-
|
|
163
|
-
return Promise.resolve();
|
|
164
|
-
},
|
|
165
|
-
);
|
|
131
|
+
private async applyMint() {
|
|
132
|
+
this.logger.info('Applying mint setup');
|
|
133
|
+
const { asset, adminAddress, tokenSim } = this;
|
|
134
|
+
const amount = 10000n;
|
|
135
|
+
|
|
136
|
+
this.logger.verbose(`Minting ${amount} publicly...`);
|
|
137
|
+
await asset.methods.mint_to_public(adminAddress, amount).send({ from: adminAddress }).wait();
|
|
138
|
+
tokenSim.mintPublic(adminAddress, amount);
|
|
139
|
+
|
|
140
|
+
const publicBalance = await asset.methods.balance_of_public(adminAddress).simulate({ from: adminAddress });
|
|
141
|
+
this.logger.verbose(`Public balance of wallet 0: ${publicBalance}`);
|
|
142
|
+
expect(publicBalance).toEqual(this.tokenSim.balanceOfPublic(adminAddress));
|
|
143
|
+
|
|
144
|
+
this.logger.verbose(`Minting ${amount} privately...`);
|
|
145
|
+
await mintTokensToPrivate(asset, adminAddress, adminAddress, amount);
|
|
146
|
+
tokenSim.mintPrivate(adminAddress, amount);
|
|
147
|
+
|
|
148
|
+
const privateBalance = await asset.methods.balance_of_private(adminAddress).simulate({ from: adminAddress });
|
|
149
|
+
this.logger.verbose(`Private balance of wallet 0: ${privateBalance}`);
|
|
150
|
+
expect(privateBalance).toEqual(tokenSim.balanceOfPrivate(adminAddress));
|
|
151
|
+
|
|
152
|
+
const totalSupply = await asset.methods.total_supply().simulate({ from: adminAddress });
|
|
153
|
+
this.logger.verbose(`Total supply: ${totalSupply}`);
|
|
154
|
+
expect(totalSupply).toEqual(tokenSim.totalSupply);
|
|
155
|
+
|
|
156
|
+
this.logger.verbose(`Minting complete.`);
|
|
166
157
|
}
|
|
167
158
|
}
|