Skip to content

Commit fa4e91b

Browse files
committed
fix plot filter for v2 plots
1 parent 8d4cbab commit fa4e91b

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

chia/_tests/core/custom_types/test_proof_of_space.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,10 @@ def test_calculate_prefix_bits_v1(height: uint32, expected: int) -> None:
291291
argvalues=[
292292
(0, 5),
293293
(0xFFFFFFFA, 5),
294-
(0xFFFFFFFB, 6),
295-
(0xFFFFFFFC, 7),
296-
(0xFFFFFFFD, 8),
297-
(0xFFFFFFFF, 8),
294+
(0xFFFFFFFB, 4),
295+
(0xFFFFFFFC, 3),
296+
(0xFFFFFFFD, 2),
297+
(0xFFFFFFFF, 2),
298298
],
299299
)
300300
def test_calculate_prefix_bits_v2(height: uint32, expected: int) -> None:

chia/types/blockchain_format/proof_of_space.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,14 @@ def passes_plot_filter(
211211

212212
def calculate_prefix_bits(constants: ConsensusConstants, height: uint32, plot_param: PlotParam) -> int:
213213
if plot_param.strength_v2 is not None:
214+
prefix_bits = int(constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2)
214215
if height >= constants.PLOT_FILTER_V2_THIRD_ADJUSTMENT_HEIGHT:
215-
return constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2 + 3
216-
if height >= constants.PLOT_FILTER_V2_SECOND_ADJUSTMENT_HEIGHT:
217-
return constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2 + 2
218-
if height >= constants.PLOT_FILTER_V2_FIRST_ADJUSTMENT_HEIGHT:
219-
return constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2 + 1
220-
return constants.NUMBER_ZERO_BITS_PLOT_FILTER_V2
216+
prefix_bits -= 3
217+
elif height >= constants.PLOT_FILTER_V2_SECOND_ADJUSTMENT_HEIGHT:
218+
prefix_bits -= 2
219+
elif height >= constants.PLOT_FILTER_V2_FIRST_ADJUSTMENT_HEIGHT:
220+
prefix_bits -= 1
221+
return max(0, prefix_bits)
221222

222223
prefix_bits = int(constants.NUMBER_ZERO_BITS_PLOT_FILTER_V1)
223224
if height >= constants.PLOT_FILTER_32_HEIGHT:

0 commit comments

Comments
 (0)