Skip to content

Commit d178979

Browse files
spalladinoclaude
andcommitted
fix(sequencer-client): clamp ethPerFeeAsset decay to MIN_ETH_PER_FEE_ASSET
Ensures the conservative ethPerFeeAsset decay doesn't go below the protocol minimum (100), matching the on-chain clamp in computeManaMinFee. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 3b165d6 commit d178979

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

yarn-project/sequencer-client/src/global_variable_builder/fee_predictor.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ import { SlotNumber } from '@aztec/foundation/branded-types';
33
import { times } from '@aztec/foundation/collection';
44
import type { DateProvider } from '@aztec/foundation/timer';
55
import { getSlotAtNextL1Block, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
6-
import { FEE_ORACLE_LAG, GasFees, ManaUsageEstimate, computeExcessMana, computeManaMinFee } from '@aztec/stdlib/gas';
6+
import {
7+
FEE_ORACLE_LAG,
8+
GasFees,
9+
MIN_ETH_PER_FEE_ASSET,
10+
ManaUsageEstimate,
11+
computeExcessMana,
12+
computeManaMinFee,
13+
} from '@aztec/stdlib/gas';
714

815
/** Cached rollup state for fee prediction. Refreshed once per L1 block. */
916
type FeeOracleState = {
@@ -109,7 +116,8 @@ export class FeePredictor {
109116
// Lower ethPerFeeAsset means higher fees in fee asset terms.
110117
for (let i = 1; i < state.l1FeesBySlot.length; i++) {
111118
excessMana = computeExcessMana(excessMana, assumedManaUsed, state.manaTarget);
112-
ethPerFeeAsset = (ethPerFeeAsset * (10000n - MAX_FEE_ASSET_PRICE_MODIFIER_BPS)) / 10000n;
119+
const decayed = (ethPerFeeAsset * (10000n - MAX_FEE_ASSET_PRICE_MODIFIER_BPS)) / 10000n;
120+
ethPerFeeAsset = decayed < MIN_ETH_PER_FEE_ASSET ? MIN_ETH_PER_FEE_ASSET : decayed;
113121
result.push(this.computeGasFees(state, excessMana, ethPerFeeAsset, state.l1FeesBySlot[i]));
114122
}
115123

0 commit comments

Comments
 (0)