Skip to content

Commit c4e7f5b

Browse files
committed
perf(e2e): overlap and batch setup txs in e2e harnesses (#24569)
(cherry picked from commit 1d280af)
1 parent eae69fb commit c4e7f5b

5 files changed

Lines changed: 38 additions & 26 deletions

File tree

yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,17 @@ export async function deployAndInitializeTokenAndBridgeContracts(
7676
client: l1Client,
7777
});
7878

79-
// deploy l2 token
80-
const { contract: token } = await testSpan('deploy:token', () =>
81-
TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
82-
from: owner,
83-
}),
84-
);
85-
86-
// deploy l2 token bridge and attach to the portal
87-
const { contract: bridge } = await testSpan('deploy:bridge', () =>
88-
TokenBridgeContract.deploy(wallet, token.address, tokenPortalAddress).send({
89-
from: owner,
90-
}),
91-
);
79+
// Deploy the L2 token and its bridge concurrently so they share a slot: the bridge takes the token
80+
// address as a constructor arg, but that address is known deterministically before the token deploy
81+
// mines, and the bridge's constructor only stores it without calling into the token.
82+
const tokenDeploy = TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18, { deployer: owner });
83+
const tokenAddress = await tokenDeploy.getAddress();
84+
const [{ contract: token }, { contract: bridge }] = await Promise.all([
85+
testSpan('deploy:token', () => tokenDeploy.send({ from: owner })),
86+
testSpan('deploy:bridge', () =>
87+
TokenBridgeContract.deploy(wallet, tokenAddress, tokenPortalAddress).send({ from: owner }),
88+
),
89+
]);
9290

9391
if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
9492
throw new Error(`Token admin is not ${owner}`);

yarn-project/end-to-end/src/single-node/fees/account_init.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ describe('single-node/fees/account_init', () => {
3333

3434
beforeAll(async () => {
3535
await t.setup({ ...PIPELINING_SETUP_OPTS });
36-
await t.applyFundAliceWithBananas();
37-
await t.applyFPCSetup();
36+
// Alice's banana mints and the BananaFPC deploy each depend only on the BananaCoin deployed
37+
// during setup, so they run concurrently and share slots.
38+
await Promise.all([t.applyFundAliceWithBananas(), t.applyFPCSetup()]);
3839
({ aliceAddress, wallet, bananaCoin, bananaFPC, logger, aztecNode } = t);
3940
});
4041

yarn-project/end-to-end/src/single-node/fees/fees_test.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AztecAddress } from '@aztec/aztec.js/addresses';
2+
import { BatchCall } from '@aztec/aztec.js/contracts';
23
import { Fr } from '@aztec/aztec.js/fields';
34
import { createLogger } from '@aztec/aztec.js/log';
45
import type { AztecNode } from '@aztec/aztec.js/node';
@@ -408,12 +409,24 @@ export class FeesTest extends SingleNodeTestContext {
408409
public async applyFundAliceWithBananas() {
409410
this.logger.info('Applying fund Alice with bananas setup');
410411

411-
await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress);
412+
// Both mints are alice sends on BananaCoin touching disjoint balances, so they ride a single
413+
// BatchCall tx (one proof, one slot) rather than two concurrent txs. The PXE serializes proving,
414+
// so two concurrent sends would still be proven back-to-back and land in consecutive slots.
415+
const { result: privateBalanceBefore } = await this.bananaCoin.methods
416+
.balance_of_private(this.aliceAddress)
417+
.simulate({ from: this.aliceAddress });
418+
412419
await testSpan('tx:mint', () =>
413-
this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send({
414-
from: this.aliceAddress,
415-
}),
420+
new BatchCall(this.wallet, [
421+
this.bananaCoin.methods.mint_to_private(this.aliceAddress, this.ALICE_INITIAL_BANANAS),
422+
this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS),
423+
]).send({ from: this.aliceAddress }),
416424
);
425+
426+
const { result: privateBalanceAfter } = await this.bananaCoin.methods
427+
.balance_of_private(this.aliceAddress)
428+
.simulate({ from: this.aliceAddress });
429+
expect(privateBalanceAfter).toEqual(privateBalanceBefore + this.ALICE_INITIAL_BANANAS);
417430
}
418431

419432
public async applyFundAliceWithPrivateBananas() {

yarn-project/end-to-end/src/single-node/fees/gas_estimation.parallel.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ describe('single-node/fees/gas_estimation', () => {
4646

4747
beforeAll(async () => {
4848
await t.setup({ ...PIPELINING_SETUP_OPTS });
49-
await t.applyFPCSetup();
50-
await t.applyFundAliceWithBananas();
49+
// Alice's banana mints and the BananaFPC deploy each depend only on the BananaCoin deployed
50+
// during setup, so they run concurrently and share slots.
51+
await Promise.all([t.applyFPCSetup(), t.applyFundAliceWithBananas()]);
5152
({ wallet, aliceAddress, bobAddress, bananaCoin, bananaFPC, gasSettings, logger, aztecNode } = t);
5253
});
5354

yarn-project/end-to-end/src/single-node/fees/private_payments.parallel.test.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ describe('single-node/fees/private_payments', () => {
4646
// cycle: the prover-node submits a proof as soon as the epoch is complete, so ~8x shorter
4747
// epochs ≈ ~8x faster proof cadence per cycle. Setup itself stays slot-bound.
4848
await t.setup({ ...PIPELINING_SETUP_OPTS, aztecProofSubmissionEpochs: 640, aztecEpochDuration: 4 });
49-
await t.applyFPCSetup();
50-
// Register the SponsoredFPC (funded at genesis via FeesTest's fundSponsoredFPC) so the folded
51-
// sponsored-payment it can use it; this is a PXE registration, not an L2 tx.
52-
await t.applySponsoredFPCSetup();
53-
await t.applyFundAliceWithBananas();
49+
// The BananaFPC deploy, the SponsoredFPC registration (funded at genesis via FeesTest's
50+
// fundSponsoredFPC; a PXE registration, not an L2 tx), and Alice's banana mints each depend only
51+
// on the BananaCoin deployed during setup, so they run concurrently and share slots.
52+
await Promise.all([t.applyFPCSetup(), t.applySponsoredFPCSetup(), t.applyFundAliceWithBananas()]);
5453
({
5554
wallet,
5655
aliceAddress,

0 commit comments

Comments
 (0)