@@ -105,9 +105,12 @@ def compute_gas_limit_bounds(previous_limit: int) -> Tuple[int, int]:
105
105
Compute the boundaries for the block gas limit based on the parent block.
106
106
"""
107
107
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
111
114
112
115
113
116
def 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) ->
152
155
153
156
gas_limit = max (
154
157
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
156
160
)
157
161
158
162
if gas_limit < GAS_LIMIT_MINIMUM :
159
163
return GAS_LIMIT_MINIMUM
160
164
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
162
167
else :
163
168
return gas_limit
0 commit comments