|
2 | 2 | Fixtures for the EIP-7623 tests. |
3 | 3 | """ |
4 | 4 |
|
5 | | -from typing import Callable, List, Sequence |
| 5 | +from typing import List, Sequence |
6 | 6 |
|
7 | 7 | import pytest |
8 | 8 |
|
|
20 | 20 | from ethereum_test_tools import Opcodes as Op |
21 | 21 | from ethereum_test_tools import Transaction, TransactionException |
22 | 22 |
|
23 | | -from .helpers import DataTestType |
| 23 | +from .helpers import DataTestType, floor_cost_find |
24 | 24 |
|
25 | 25 |
|
26 | 26 | @pytest.fixture |
@@ -119,44 +119,6 @@ def contract_creating_tx(to: Address | None) -> bool: |
119 | 119 | return to is None |
120 | 120 |
|
121 | 121 |
|
122 | | -def floor_cost_find( |
123 | | - floor_data_gas_cost_calculator: Callable[[int], int], |
124 | | - intrinsic_gas_cost_calculator: Callable[[int], int], |
125 | | -) -> int: |
126 | | - """ |
127 | | - Find the minimum amount of tokens that will trigger the floor gas cost, by using a binary |
128 | | - search and the intrinsic gas cost and floor data calculators. |
129 | | - """ |
130 | | - # Start with 1000 tokens and if the intrinsic gas cost is greater than the floor gas cost, |
131 | | - # multiply the number of tokens by 2 until it's not. |
132 | | - tokens = 1000 |
133 | | - while floor_data_gas_cost_calculator(tokens) < intrinsic_gas_cost_calculator(tokens): |
134 | | - tokens *= 2 |
135 | | - |
136 | | - # Binary search to find the minimum number of tokens that will trigger the floor gas cost. |
137 | | - left = 0 |
138 | | - right = tokens |
139 | | - while left < right: |
140 | | - tokens = (left + right) // 2 |
141 | | - if floor_data_gas_cost_calculator(tokens) < intrinsic_gas_cost_calculator(tokens): |
142 | | - left = tokens + 1 |
143 | | - else: |
144 | | - right = tokens |
145 | | - tokens = left |
146 | | - |
147 | | - if floor_data_gas_cost_calculator(tokens) > intrinsic_gas_cost_calculator(tokens): |
148 | | - tokens -= 1 |
149 | | - |
150 | | - # Verify that increasing the tokens by one would always trigger the floor gas cost. |
151 | | - assert ( |
152 | | - floor_data_gas_cost_calculator(tokens) <= intrinsic_gas_cost_calculator(tokens) |
153 | | - ) and floor_data_gas_cost_calculator(tokens + 1) > intrinsic_gas_cost_calculator( |
154 | | - tokens + 1 |
155 | | - ), "invalid case" |
156 | | - |
157 | | - return tokens |
158 | | - |
159 | | - |
160 | 122 | @pytest.fixture |
161 | 123 | def intrinsic_gas_data_floor_minimum_delta() -> int: |
162 | 124 | """ |
|
0 commit comments