From 7b9cd122573bb63ca5e0c1eab465bd54aecf9782 Mon Sep 17 00:00:00 2001 From: Santiago Palladino Date: Tue, 7 Jul 2026 10:50:27 -0300 Subject: [PATCH] perf(e2e): batch same-sender setup txs into single txs --- .../src/single-node/fees/fees_test.ts | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/yarn-project/end-to-end/src/single-node/fees/fees_test.ts b/yarn-project/end-to-end/src/single-node/fees/fees_test.ts index 0f47cc57e4c6..267bc0527a6f 100644 --- a/yarn-project/end-to-end/src/single-node/fees/fees_test.ts +++ b/yarn-project/end-to-end/src/single-node/fees/fees_test.ts @@ -1,4 +1,5 @@ import type { AztecAddress } from '@aztec/aztec.js/addresses'; +import { BatchCall } from '@aztec/aztec.js/contracts'; import { Fr } from '@aztec/aztec.js/fields'; import { createLogger } from '@aztec/aztec.js/log'; import type { AztecNode } from '@aztec/aztec.js/node'; @@ -401,16 +402,24 @@ export class FeesTest extends SingleNodeTestContext { public async applyFundAliceWithBananas() { this.logger.info('Applying fund Alice with bananas setup'); - // The private and public mints touch disjoint balances, so they are sent concurrently to share a - // slot instead of paying one slot each. - await Promise.all([ - this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress), - testSpan('tx:mint', () => - this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send({ - from: this.aliceAddress, - }), - ), - ]); + // Both mints are alice sends on BananaCoin touching disjoint balances, so they ride a single + // BatchCall tx (one proof, one slot) rather than two concurrent txs. The PXE serializes proving, + // so two concurrent sends would still be proven back-to-back and land in consecutive slots. + const { result: privateBalanceBefore } = await this.bananaCoin.methods + .balance_of_private(this.aliceAddress) + .simulate({ from: this.aliceAddress }); + + await testSpan('tx:mint', () => + new BatchCall(this.wallet, [ + this.bananaCoin.methods.mint_to_private(this.aliceAddress, this.ALICE_INITIAL_BANANAS), + this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS), + ]).send({ from: this.aliceAddress }), + ); + + const { result: privateBalanceAfter } = await this.bananaCoin.methods + .balance_of_private(this.aliceAddress) + .simulate({ from: this.aliceAddress }); + expect(privateBalanceAfter).toEqual(privateBalanceBefore + this.ALICE_INITIAL_BANANAS); } public async applyFundAliceWithPrivateBananas() {