Skip to content

Commit a7f21ec

Browse files
committed
perf(e2e): batch same-sender setup txs into single txs
1 parent fe6c81d commit a7f21ec

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

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

Lines changed: 19 additions & 10 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,16 +409,24 @@ export class FeesTest extends SingleNodeTestContext {
408409
public async applyFundAliceWithBananas() {
409410
this.logger.info('Applying fund Alice with bananas setup');
410411

411-
// The private and public mints touch disjoint balances, so they are sent concurrently to share a
412-
// slot instead of paying one slot each.
413-
await Promise.all([
414-
this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, this.aliceAddress),
415-
testSpan('tx:mint', () =>
416-
this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send({
417-
from: this.aliceAddress,
418-
}),
419-
),
420-
]);
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+
419+
await testSpan('tx:mint', () =>
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 }),
424+
);
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);
421430
}
422431

423432
public async applyFundAliceWithPrivateBananas() {

0 commit comments

Comments
 (0)