@@ -309,7 +309,11 @@ library FeeLib {
309309
310310 function congestionMultiplier (uint256 _numerator ) internal view returns (uint256 ) {
311311 FeeStore storage feeStore = getStorage ();
312- return fakeExponential (MINIMUM_CONGESTION_MULTIPLIER, _numerator, feeStore.config.getCongestionUpdateFraction ());
312+ uint256 denominator = feeStore.config.getCongestionUpdateFraction ();
313+ // Cap the exponent to prevent overflow in the Taylor series.
314+ // At e^100, the multiplier is ~2.69e43 * MINIMUM_CONGESTION_MULTIPLIER, more than enough
315+ uint256 cappedNumerator = Math.min (_numerator, denominator * 100 );
316+ return fakeExponential (MINIMUM_CONGESTION_MULTIPLIER, cappedNumerator, denominator);
313317 }
314318
315319 function computeManaLimit (uint256 _manaTarget ) internal pure returns (uint256 ) {
@@ -342,7 +346,12 @@ library FeeLib {
342346 }
343347
344348 function summedMinFee (ManaMinFeeComponents memory _components ) internal pure returns (uint256 ) {
345- return _components.sequencerCost + _components.proverCost + _components.congestionCost;
349+ // Cap at uint128 max to ensure the fee can always be represented in the proposal header's
350+ // feePerL2Gas field (uint128). Without this cap, extreme congestion or parameter combinations
351+ // could produce fees that no valid header can represent, causing a liveness failure.
352+ return Math.min (
353+ _components.sequencerCost + _components.proverCost + _components.congestionCost, type (uint128 ).max
354+ );
346355 }
347356
348357 function getStorage () internal pure returns (FeeStore storage storageStruct ) {
0 commit comments