Skip to content

Commit 50e28d5

Browse files
author
sklppy88
committed
init
1 parent f5e388d commit 50e28d5

5 files changed

Lines changed: 57 additions & 31 deletions

File tree

noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,6 @@ contract FeeJuice {
113113
storage.balances.at(to).write(new_balance);
114114
}
115115

116-
// TODO(@just-mitch): remove this function before mainnet deployment
117-
// convenience function for testing
118-
// the true canonical Fee Juice contract will not have this function
119-
#[aztec(public)]
120-
fn mint_public(to: AztecAddress, amount: Field) {
121-
let amount = U128::from_integer(amount);
122-
let new_balance = storage.balances.at(to).read().add(amount);
123-
124-
storage.balances.at(to).write(new_balance);
125-
}
126-
127116
#[aztec(public)]
128117
#[aztec(view)]
129118
fn check_balance(fee_limit: Field) {

yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { jest } from '@jest/globals';
1212
import { getACVMConfig } from '../fixtures/get_acvm_config.js';
1313
import { getBBConfig } from '../fixtures/get_bb_config.js';
1414
import { type EndToEndContext, setup } from '../fixtures/utils.js';
15+
import { FeeJuicePortalTestingHarnessFactory } from '../shared/gas_portal_test_harness.js';
1516

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

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

95+
const feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
96+
aztecNode: ctx.aztecNode,
97+
pxeService: ctx.pxe,
98+
publicClient: ctx.deployL1ContractsValues.publicClient,
99+
walletClient: ctx.deployL1ContractsValues.walletClient,
100+
wallet: ctx.wallets[0],
101+
logger: ctx.logger,
102+
});
103+
104+
const { secret } = await feeJuiceBridgeTestHarness.prepareTokensOnL1(
105+
1_000_000_000_000n,
106+
1_000_000_000_000n,
107+
initialFpContract.address,
108+
);
109+
94110
await Promise.all([
95-
initialGasContract.methods.mint_public(initialFpContract.address, 1e12).send().wait(),
111+
initialGasContract.methods.claim(initialFpContract.address, 1e12, secret).send().wait(),
96112
initialTokenContract.methods.mint_public(initialSchnorrWallet.getAddress(), 1e12).send().wait(),
97113
initialTokenContract.methods.privately_mint_private_note(1e12).send().wait(),
98114
]);

yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ import { FeeJuiceAddress } from '@aztec/protocol-contracts/fee-juice';
1313

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

16-
import { publicDeployAccounts, setup } from '../fixtures/utils.js';
16+
import { type EndToEndContext, publicDeployAccounts, setup } from '../fixtures/utils.js';
17+
import { FeeJuicePortalTestingHarnessFactory } from '../shared/gas_portal_test_harness.js';
1718

1819
jest.setTimeout(100_000);
1920

2021
describe('benchmarks/tx_size_fees', () => {
22+
let ctx: EndToEndContext;
23+
2124
let aliceWallet: AccountWalletWithSecretKey;
2225
let bobAddress: AztecAddress;
2326
let sequencerAddress: AztecAddress;
@@ -27,17 +30,17 @@ describe('benchmarks/tx_size_fees', () => {
2730

2831
// setup the environment
2932
beforeAll(async () => {
30-
const { wallets, aztecNode } = await setup(3, {}, {}, true);
33+
ctx = await setup(3, {}, {}, true);
3134

32-
aliceWallet = wallets[0];
33-
bobAddress = wallets[1].getAddress();
34-
sequencerAddress = wallets[2].getAddress();
35+
aliceWallet = ctx.wallets[0];
36+
bobAddress = ctx.wallets[1].getAddress();
37+
sequencerAddress = ctx.wallets[2].getAddress();
3538

36-
await aztecNode.setConfig({
39+
await ctx.aztecNode.setConfig({
3740
feeRecipient: sequencerAddress,
3841
});
3942

40-
await publicDeployAccounts(aliceWallet, wallets);
43+
await publicDeployAccounts(aliceWallet, ctx.wallets);
4144
});
4245

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

5053
// mint tokens
5154
beforeAll(async () => {
55+
const feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
56+
aztecNode: ctx.aztecNode,
57+
pxeService: ctx.pxe,
58+
publicClient: ctx.deployL1ContractsValues.publicClient,
59+
walletClient: ctx.deployL1ContractsValues.walletClient,
60+
wallet: ctx.wallets[0],
61+
logger: ctx.logger,
62+
});
63+
64+
const { secret: fpcSecret } = await feeJuiceBridgeTestHarness.prepareTokensOnL1(
65+
100_000_000_000n,
66+
100_000_000_000n,
67+
fpc.address,
68+
);
69+
const { secret: aliceSecret } = await feeJuiceBridgeTestHarness.prepareTokensOnL1(
70+
100_000_000_000n,
71+
100_000_000_000n,
72+
aliceWallet.getAddress(),
73+
);
74+
5275
await Promise.all([
53-
feeJuice.methods.mint_public(aliceWallet.getAddress(), 100e9).send().wait(),
54-
feeJuice.methods.mint_public(fpc.address, 100e9).send().wait(),
76+
feeJuice.methods.claim(fpc.address, 100e9, fpcSecret).send().wait(),
77+
feeJuice.methods.claim(aliceWallet.getAddress(), 100e9, aliceSecret).send().wait(),
5578
]);
5679
await token.methods.privately_mint_private_note(100e9).send().wait();
5780
await token.methods.mint_public(aliceWallet.getAddress(), 100e9).send().wait();

yarn-project/end-to-end/src/e2e_fees/account_init.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ describe('e2e_fees account_init', () => {
8585

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

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

185185
// bob generates the private keys for his account on his own

yarn-project/end-to-end/src/e2e_fees/fees_test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,10 @@ export class FeesTest {
109109
expect(balanceAfter).toEqual(balanceBefore + amount);
110110
}
111111

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

120118
/** Alice mints bananaCoin tokens privately to the target address and redeems them. */
@@ -368,7 +366,7 @@ export class FeesTest {
368366
await this.snapshotManager.snapshot(
369367
'fund_alice_with_fee_juice',
370368
async () => {
371-
await this.mintFeeJuice(this.aliceAddress, this.INITIAL_GAS_BALANCE);
369+
await this.mintAndBridgeFeeJuice(this.aliceAddress, this.INITIAL_GAS_BALANCE);
372370
},
373371
() => Promise.resolve(),
374372
);
@@ -398,7 +396,7 @@ export class FeesTest {
398396

399397
// Mint some Fee Juice to the subscription contract
400398
// Could also use bridgeFromL1ToL2 from the harness, but this is more direct
401-
await this.mintFeeJuice(subscriptionContract.address, this.INITIAL_GAS_BALANCE);
399+
await this.mintAndBridgeFeeJuice(subscriptionContract.address, this.INITIAL_GAS_BALANCE);
402400
return {
403401
counterContractAddress: counterContract.address,
404402
subscriptionContractAddress: subscriptionContract.address,

0 commit comments

Comments
 (0)