Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions yarn-project/end-to-end/src/shared/cross_chain_test_harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,17 @@ export async function deployAndInitializeTokenAndBridgeContracts(
client: l1Client,
});

// deploy l2 token
const { contract: token } = await testSpan('deploy:token', () =>
TokenContract.deploy(wallet, owner, 'TokenName', 'TokenSymbol', 18).send({
from: owner,
}),
);

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

if ((await token.methods.get_admin().simulate({ from: owner })).result !== owner.toBigInt()) {
throw new Error(`Token admin is not ${owner}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ describe('single-node/fees/account_init', () => {

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

Expand Down
21 changes: 17 additions & 4 deletions yarn-project/end-to-end/src/single-node/fees/fees_test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -408,12 +409,24 @@ export class FeesTest extends SingleNodeTestContext {
public async applyFundAliceWithBananas() {
this.logger.info('Applying fund Alice with bananas setup');

await this.mintPrivateBananas(this.ALICE_INITIAL_BANANAS, 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', () =>
this.bananaCoin.methods.mint_to_public(this.aliceAddress, this.ALICE_INITIAL_BANANAS).send({
from: this.aliceAddress,
}),
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ describe('single-node/fees/gas_estimation', () => {

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

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