Commit 9e98140f authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge pull request #5008 from ethereum-optimism/fix/metering-readable-2

contracts-bedrock: ResourceMetering more readable
parents d59924d3 feea0e52
......@@ -96,11 +96,11 @@ abstract contract ResourceMetering is Initializable {
// Update base fee by adding the base fee delta and clamp the resulting value between
// min and max.
int256 newBaseFee = Arithmetic.clamp(
int256(uint256(params.prevBaseFee)) + baseFeeDelta,
MINIMUM_BASE_FEE,
MAXIMUM_BASE_FEE
);
int256 newBaseFee = Arithmetic.clamp({
_value: int256(uint256(params.prevBaseFee)) + baseFeeDelta,
_min: MINIMUM_BASE_FEE,
_max: MAXIMUM_BASE_FEE
});
// If we skipped more than one block, we also need to account for every empty block.
// Empty block means there was no demand for deposits in that block, so we should
......@@ -109,15 +109,15 @@ abstract contract ResourceMetering is Initializable {
// Update the base fee by repeatedly applying the exponent 1-(1/change_denominator)
// blockDiff - 1 times. Simulates multiple empty blocks. Clamp the resulting value
// between min and max.
newBaseFee = Arithmetic.clamp(
Arithmetic.cdexp(
newBaseFee,
BASE_FEE_MAX_CHANGE_DENOMINATOR,
int256(blockDiff - 1)
),
MINIMUM_BASE_FEE,
MAXIMUM_BASE_FEE
);
newBaseFee = Arithmetic.clamp({
_value: Arithmetic.cdexp({
_coefficient: newBaseFee,
_denominator: BASE_FEE_MAX_CHANGE_DENOMINATOR,
_exponent: int256(blockDiff - 1)
}),
_min: MINIMUM_BASE_FEE,
_max: MAXIMUM_BASE_FEE
});
}
// Update new base fee, reset bought gas, and update block number.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment