@@ -105,9 +105,12 @@ def compute_gas_limit_bounds(previous_limit: int) -> Tuple[int, int]:
105105 Compute the boundaries for the block gas limit based on the parent block.
106106 """
107107 boundary_range = previous_limit // GAS_LIMIT_ADJUSTMENT_FACTOR
108- upper_bound = min (GAS_LIMIT_MAXIMUM , previous_limit + boundary_range )
109- lower_bound = max (GAS_LIMIT_MINIMUM , previous_limit - boundary_range )
110- return lower_bound , upper_bound
108+
109+ # the boundary range is the exclusive limit, therefore the inclusive bounds are
110+ # (boundary_range - 1) and (boundary_range + 1) for upper and lower bounds, respectively
111+ upper_bound_inclusive = min (GAS_LIMIT_MAXIMUM , previous_limit + boundary_range - 1 )
112+ lower_bound_inclusive = max (GAS_LIMIT_MINIMUM , previous_limit - boundary_range + 1 )
113+ return lower_bound_inclusive , upper_bound_inclusive
111114
112115
113116def compute_gas_limit (parent_header : BlockHeaderAPI , genesis_gas_limit : int ) -> int :
@@ -152,12 +155,14 @@ def compute_gas_limit(parent_header: BlockHeaderAPI, genesis_gas_limit: int) ->
152155
153156 gas_limit = max (
154157 GAS_LIMIT_MINIMUM ,
155- parent_header .gas_limit - decay + usage_increase
158+ # + 1 because the decay is an exclusive limit we have to remain inside of
159+ (parent_header .gas_limit - decay + 1 ) + usage_increase
156160 )
157161
158162 if gas_limit < GAS_LIMIT_MINIMUM :
159163 return GAS_LIMIT_MINIMUM
160164 elif gas_limit < genesis_gas_limit :
161- return parent_header .gas_limit + decay
165+ # - 1 because the decay is an exclusive limit we have to remain inside of
166+ return parent_header .gas_limit + decay - 1
162167 else :
163168 return gas_limit
0 commit comments