Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sklppy88 committed Aug 29, 2024
1 parent 54e1cc7 commit c4a8b5a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,6 @@ contract FeeJuice {
storage.balances.at(to).write(new_balance);
}

// TODO(@just-mitch): remove this function before mainnet deployment
// convenience function for testing
// the true canonical Fee Juice contract will not have this function
#[aztec(public)]
fn mint_public(to: AztecAddress, amount: Field) {
let amount = U128::from_integer(amount);
let new_balance = storage.balances.at(to).read().add(amount);

storage.balances.at(to).write(new_balance);
}

#[aztec(public)]
#[aztec(view)]
fn check_balance(fee_limit: Field) {
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/package.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"test": "TIME_TRAVELER=${TIME_TRAVELER:-true} LOG_LEVEL=${LOG_LEVEL:-verbose} DEBUG_COLORS=1 NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --testTimeout=300000 --forceExit",
"test:unit": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest src/fixtures"
}
}
}
18 changes: 17 additions & 1 deletion yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { jest } from '@jest/globals';
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
import { getBBConfig } from '../fixtures/get_bb_config.js';
import { type EndToEndContext, setup } from '../fixtures/utils.js';
import { FeeJuicePortalTestingHarnessFactory } from '../shared/gas_portal_test_harness.js';

// TODO(@PhilWindle): Some part of this test are commented out until we speed up proving.

Expand Down Expand Up @@ -91,8 +92,23 @@ describe('benchmarks/proving', () => {
initialGasContract = await FeeJuiceContract.at(FeeJuiceAddress, initialSchnorrWallet);
initialFpContract = await FPCContract.deploy(initialSchnorrWallet, initialTokenContract.address).send().deployed();

const feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
aztecNode: ctx.aztecNode,
pxeService: ctx.pxe,
publicClient: ctx.deployL1ContractsValues.publicClient,
walletClient: ctx.deployL1ContractsValues.walletClient,
wallet: ctx.wallets[0],
logger: ctx.logger,
});

const { secret } = await feeJuiceBridgeTestHarness.prepareTokensOnL1(
1_000_000_000_000n,
1_000_000_000_000n,
initialFpContract.address,
);

await Promise.all([
initialGasContract.methods.mint_public(initialFpContract.address, 1e12).send().wait(),
initialGasContract.methods.claim(initialFpContract.address, 1e12, secret).send().wait(),
initialTokenContract.methods.mint_public(initialSchnorrWallet.getAddress(), 1e12).send().wait(),
initialTokenContract.methods.privately_mint_private_note(1e12).send().wait(),
]);
Expand Down
41 changes: 32 additions & 9 deletions yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ import { FeeJuiceAddress } from '@aztec/protocol-contracts/fee-juice';

import { jest } from '@jest/globals';

import { publicDeployAccounts, setup } from '../fixtures/utils.js';
import { type EndToEndContext, publicDeployAccounts, setup } from '../fixtures/utils.js';
import { FeeJuicePortalTestingHarnessFactory } from '../shared/gas_portal_test_harness.js';

jest.setTimeout(100_000);

describe('benchmarks/tx_size_fees', () => {
let ctx: EndToEndContext;

let aliceWallet: AccountWalletWithSecretKey;
let bobAddress: AztecAddress;
let sequencerAddress: AztecAddress;
Expand All @@ -27,17 +30,17 @@ describe('benchmarks/tx_size_fees', () => {

// setup the environment
beforeAll(async () => {
const { wallets, aztecNode } = await setup(3, {}, {}, true);
ctx = await setup(3, {}, {}, true);

aliceWallet = wallets[0];
bobAddress = wallets[1].getAddress();
sequencerAddress = wallets[2].getAddress();
aliceWallet = ctx.wallets[0];
bobAddress = ctx.wallets[1].getAddress();
sequencerAddress = ctx.wallets[2].getAddress();

await aztecNode.setConfig({
await ctx.aztecNode.setConfig({
feeRecipient: sequencerAddress,
});

await publicDeployAccounts(aliceWallet, wallets);
await publicDeployAccounts(aliceWallet, ctx.wallets);
});

// deploy the contracts
Expand All @@ -49,9 +52,29 @@ describe('benchmarks/tx_size_fees', () => {

// mint tokens
beforeAll(async () => {
const feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
aztecNode: ctx.aztecNode,
pxeService: ctx.pxe,
publicClient: ctx.deployL1ContractsValues.publicClient,
walletClient: ctx.deployL1ContractsValues.walletClient,
wallet: ctx.wallets[0],
logger: ctx.logger,
});

const { secret: fpcSecret } = await feeJuiceBridgeTestHarness.prepareTokensOnL1(
100_000_000_000n,
100_000_000_000n,
fpc.address,
);
const { secret: aliceSecret } = await feeJuiceBridgeTestHarness.prepareTokensOnL1(
100_000_000_000n,
100_000_000_000n,
aliceWallet.getAddress(),
);

await Promise.all([
feeJuice.methods.mint_public(aliceWallet.getAddress(), 100e9).send().wait(),
feeJuice.methods.mint_public(fpc.address, 100e9).send().wait(),
feeJuice.methods.claim(fpc.address, 100e9, fpcSecret).send().wait(),
feeJuice.methods.claim(aliceWallet.getAddress(), 100e9, aliceSecret).send().wait(),
]);
await token.methods.privately_mint_private_note(100e9).send().wait();
await token.methods.mint_public(aliceWallet.getAddress(), 100e9).send().wait();
Expand Down
7 changes: 3 additions & 4 deletions yarn-project/end-to-end/src/e2e_fees/fees_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ export class FeesTest {

// Mint fee juice AND mint funds to the portal to emulate the L1 -> L2 bridge
async mintFeeJuice(address: AztecAddress, amount: bigint) {
await this.feeJuiceContract.methods.mint_public(address, amount).send().wait();
// Need to also mint funds to the portal
const portalAddress = EthAddress.fromString(this.feeJuiceBridgeTestHarness.tokenPortal.address);
await this.feeJuiceBridgeTestHarness.mintTokensOnL1(amount, portalAddress);
const { secret } = await this.feeJuiceBridgeTestHarness.prepareTokensOnL1(amount, amount, address);

await this.feeJuiceContract.methods.claim(address, amount, secret).send().wait();
}

/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
Expand Down

0 comments on commit c4a8b5a

Please sign in to comment.