Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove fee juice mint public #8260

Merged
merged 1 commit into from
Aug 30, 2024
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
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thank you!

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
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
4 changes: 2 additions & 2 deletions yarn-project/end-to-end/src/e2e_fees/account_init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('e2e_fees account_init', () => {

describe('account pays its own fee', () => {
it('pays natively in the Fee Juice after Alice bridges funds', async () => {
await t.mintFeeJuice(bobsAddress, t.INITIAL_GAS_BALANCE);
await t.mintAndBridgeFeeJuice(bobsAddress, t.INITIAL_GAS_BALANCE);
const [bobsInitialGas] = await t.getGasBalanceFn(bobsAddress);
expect(bobsInitialGas).toEqual(t.INITIAL_GAS_BALANCE);

Expand Down Expand Up @@ -179,7 +179,7 @@ describe('e2e_fees account_init', () => {
describe('another account pays the fee', () => {
it('pays natively in the Fee Juice', async () => {
// mint Fee Juice to alice
await t.mintFeeJuice(aliceAddress, t.INITIAL_GAS_BALANCE);
await t.mintAndBridgeFeeJuice(aliceAddress, t.INITIAL_GAS_BALANCE);
const [alicesInitialGas] = await t.getGasBalanceFn(aliceAddress);

// bob generates the private keys for his account on his own
Expand Down
14 changes: 6 additions & 8 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,12 +109,10 @@ export class FeesTest {
expect(balanceAfter).toEqual(balanceBefore + amount);
}

// 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);
async mintAndBridgeFeeJuice(address: AztecAddress, amount: bigint) {
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 Expand Up @@ -368,7 +366,7 @@ export class FeesTest {
await this.snapshotManager.snapshot(
'fund_alice_with_fee_juice',
async () => {
await this.mintFeeJuice(this.aliceAddress, this.INITIAL_GAS_BALANCE);
await this.mintAndBridgeFeeJuice(this.aliceAddress, this.INITIAL_GAS_BALANCE);
},
() => Promise.resolve(),
);
Expand Down Expand Up @@ -398,7 +396,7 @@ export class FeesTest {

// Mint some Fee Juice to the subscription contract
// Could also use bridgeFromL1ToL2 from the harness, but this is more direct
await this.mintFeeJuice(subscriptionContract.address, this.INITIAL_GAS_BALANCE);
await this.mintAndBridgeFeeJuice(subscriptionContract.address, this.INITIAL_GAS_BALANCE);
return {
counterContractAddress: counterContract.address,
subscriptionContractAddress: subscriptionContract.address,
Expand Down
Loading