Skip to content
Closed
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
49 changes: 29 additions & 20 deletions yarn-project/end-to-end/src/e2e_fees/fee_settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,31 @@ describe('e2e_fees fee settings', () => {
});

describe('setting max fee per gas', () => {
const bumpL2Fees = async () => {
const before = await aztecNode.getCurrentMinFees();
t.logger.info(`Initial L2 min fees are ${inspect(before)}`, { minFees: before.toInspect() });
await cheatCodes.rollup.bumpProvingCostPerMana(current => (current * 120n) / 100n);
return await retryUntil(
async () => {
const after = await aztecNode.getCurrentMinFees();
t.logger.info(`L2 min fees are now ${inspect(after)}`, {
minFeesBefore: before.toInspect(),
minFeesAfter: after.toInspect(),
});
return after.feePerL2Gas > before.feePerL2Gas ? after : undefined;
},
'L2 min fee increase',
5,
1,
);
const bumpL2Fees = async (minTarget?: GasFees) => {
let current = await aztecNode.getCurrentMinFees();
t.logger.info(`Initial L2 min fees are ${inspect(current)}`, { minFees: current.toInspect() });

// Keep bumping until fees exceed the minimum target (if provided).
// Fees can decay between when the target was captured and now, so a single bump may not suffice.
do {
const before = current;
await cheatCodes.rollup.bumpProvingCostPerMana(c => (c * 120n) / 100n);
current = await retryUntil(
async () => {
const after = await aztecNode.getCurrentMinFees();
t.logger.info(`L2 min fees are now ${inspect(after)}`, {
minFeesBefore: before.toInspect(),
minFeesAfter: after.toInspect(),
});
return after.feePerL2Gas > before.feePerL2Gas ? after : undefined;
},
'L2 min fee increase',
5,
1,
);
} while (minTarget && current.feePerL2Gas <= minTarget.feePerL2Gas);

return current;
};

// Pick a baseline from the post-checkpoint chain state. The prove step itself is
Expand Down Expand Up @@ -121,8 +129,9 @@ describe('e2e_fees fee settings', () => {
txWithDefaultPadding.data.constants.txContext.gasSettings.maxFeesPerGas.equals(stableMinFees.mul(1.5)),
).toBe(true);

// Now bump the L2 fees before we actually send them
const bumpedMinFees = await bumpL2Fees();
// Now bump the L2 fees before we actually send them.
// Pass stableMinFees as target so fees are bumped past the level the txs were prepared at.
const bumpedMinFees = await bumpL2Fees(stableMinFees);
expect(stableMinFees.feePerL2Gas).toBeLessThan(bumpedMinFees.feePerL2Gas);
expect(stableMinFees.mul(1.5).feePerL2Gas).toBeGreaterThan(bumpedMinFees.feePerL2Gas);

Expand All @@ -143,7 +152,7 @@ describe('e2e_fees fee settings', () => {
txWithDefaultPadding.data.constants.txContext.gasSettings.maxFeesPerGas.equals(lowerMinFees.mul(1.5)),
).toBe(true);

const bumpedMinFees = await bumpL2Fees();
const bumpedMinFees = await bumpL2Fees(lowerMinFees);
expect(lowerMinFees.feePerL2Gas).toBeLessThan(bumpedMinFees.feePerL2Gas);
expect(higherMinFees.feePerL2Gas).toBeGreaterThan(bumpedMinFees.feePerL2Gas);
expect(lowerMinFees.mul(1.5).feePerL2Gas).toBeGreaterThan(bumpedMinFees.feePerL2Gas);
Expand Down
Loading