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
1 change: 1 addition & 0 deletions yarn-project/end-to-end/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function test_cmds {
echo "$prefix simple e2e_fees/account_init"
echo "$prefix simple e2e_fees/failures"
echo "$prefix simple e2e_fees/fee_juice_payments"
echo "$prefix simple e2e_fees/fee_settings"
echo "$prefix simple e2e_fees/gas_estimation"
echo "$prefix simple e2e_fees/private_payments"
echo "$prefix simple e2e_fees/public_payments"
Expand Down
12 changes: 6 additions & 6 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 @@ -41,22 +41,23 @@ describe('e2e_fees fee settings', () => {
describe('setting max fee per gas', () => {
const bumpL2Fees = async () => {
const before = await aztecNode.getCurrentBaseFees();
t.logger.info(`Initial L2 base fees are ${inspect(before)}`, { baseFees: before });
t.logger.warn(`Initial L2 base fees are ${inspect(before)}`, { baseFees: before.toInspect() });

// Bumps L1 base fee, updates the L1 fee oracle, and advances slots to update L2 base fees.
// Do we need all these advance and upgrade calls? Probably not, but these calls are blazing fast,
// so it's not big deal if we're throwing some unnecessary calls. We just want higher L2 base fees.
t.logger.info(`Bumping L1 base fee per gas`);
const { baseFeePerGas } = await t.context.deployL1ContractsValues.publicClient.getBlock();
t.logger.info(`Doubling current L1 base fee per gas ${baseFeePerGas}`);
await cheatCodes.rollup.updateL1GasFeeOracle();
await cheatCodes.eth.setNextBlockBaseFeePerGas(1e11);
await cheatCodes.eth.setNextBlockBaseFeePerGas(baseFeePerGas! * 2n);
await cheatCodes.eth.mine();
await cheatCodes.rollup.advanceSlots(6);
await cheatCodes.rollup.updateL1GasFeeOracle();
await cheatCodes.rollup.advanceSlots(6);
await cheatCodes.rollup.updateL1GasFeeOracle();

const after = await aztecNode.getCurrentBaseFees();
t.logger.info(`L2 base fees after L1 gas spike are ${inspect(after)}`, { baseFees: after });
t.logger.warn(`L2 base fees after L1 gas spike are ${inspect(after)}`, { baseFees: after.toInspect() });
expect(after.feePerL2Gas.toBigInt()).toBeGreaterThan(before.feePerL2Gas.toBigInt());
};

Expand All @@ -70,8 +71,7 @@ describe('e2e_fees fee settings', () => {
return tx;
};

// TODO(#12258): This test is currently broken on master. Fix it.
it.skip('handles base fee spikes with default padding', async () => {
it('handles base fee spikes with default padding', async () => {
// Prepare two txs using the current L2 base fees: one with no padding and one with default padding
const txWithNoPadding = await sendTx(0);
const txWithDefaultPadding = await sendTx(undefined);
Expand Down
11 changes: 7 additions & 4 deletions yarn-project/sequencer-client/src/tx_validator/gas_validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class GasTxValidator implements TxValidator<Tx> {
this.#gasFees = gasFees;
}

validateTx(tx: Tx): Promise<TxValidationResult> {
if (this.#shouldSkip(tx)) {
async validateTx(tx: Tx): Promise<TxValidationResult> {
if (await this.#shouldSkip(tx)) {
return Promise.resolve({ result: 'skipped', reason: ['Insufficient fee per gas'] });
}
return this.#validateTxFee(tx);
Expand All @@ -37,7 +37,7 @@ export class GasTxValidator implements TxValidator<Tx> {
* Note that circuits check max fees even if fee payer is unset, so we
* keep this validation even if the tx does not pay fees.
*/
#shouldSkip(tx: Tx): boolean {
async #shouldSkip(tx: Tx): Promise<boolean> {
const gasSettings = tx.data.constants.txContext.gasSettings;

// Skip the tx if its max fees are not enough for the current block's gas fees.
Expand All @@ -47,7 +47,10 @@ export class GasTxValidator implements TxValidator<Tx> {
maxFeesPerGas.feePerL2Gas.lt(this.#gasFees.feePerL2Gas);

if (notEnoughMaxFees) {
this.#log.warn(`Skipping transaction ${tx.getTxHash()} due to insufficient fee per gas`);
this.#log.warn(`Skipping transaction ${await tx.getTxHash()} due to insufficient fee per gas`, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suppose the alternative to this making the whole func async would be to kick this off as an async side-effect. But perhaps would get weird

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The caller was already async, so I didn't worry too much

txMaxFeesPerGas: maxFeesPerGas.toInspect(),
currentGasFees: this.#gasFees.toInspect(),
});
}
return notEnoughMaxFees;
}
Expand Down
9 changes: 8 additions & 1 deletion yarn-project/stdlib/src/gas/gas_fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,14 @@ export class GasFees {
return serializeToFields(this.feePerDaGas, this.feePerL2Gas);
}

toInspect() {
return {
feePerDaGas: this.feePerDaGas.toNumberUnsafe(),
feePerL2Gas: this.feePerL2Gas.toNumberUnsafe(),
};
}

[inspect.custom]() {
return `GasFees { feePerDaGas=${this.feePerDaGas} feePerL2Gas=${this.feePerL2Gas} }`;
return `GasFees { feePerDaGas=${this.feePerDaGas.toBigInt()} feePerL2Gas=${this.feePerL2Gas.toBigInt()} }`;
}
}
Loading