1414from dataclasses import dataclass , replace
1515from pathlib import Path
1616from random import Random
17- from typing import Any , Callable , Optional
17+ from typing import Any , Callable , Optional , Union
1818
1919import anyio
2020from chia_puzzles_py .programs import CHIALISP_DESERIALISATION , ROM_BOOTSTRAP_GENERATOR
6464from chia .full_node .bundle_tools import simple_solution_generator , simple_solution_generator_backrefs
6565from chia .plotting .create_plots import PlotKeys , create_plots
6666from chia .plotting .manager import PlotManager
67+ from chia .plotting .prover import PlotVersion
6768from chia .plotting .util import (
6869 Params ,
6970 PlotRefreshEvents ,
9192from chia .types .blockchain_format .proof_of_space import (
9293 calculate_pos_challenge ,
9394 calculate_prefix_bits ,
95+ calculate_required_plot_strength ,
9496 generate_plot_public_key ,
9597 generate_taproot_sk ,
9698 make_pos ,
9799 passes_plot_filter ,
100+ quality_for_partial_proof ,
101+ solve_proof ,
98102)
99103from chia .types .blockchain_format .serialized_program import SerializedProgram
100104from chia .types .blockchain_format .vdf import VDFInfo , VDFProof
@@ -1500,6 +1504,9 @@ def get_pospaces_for_challenge(
15001504 found_proofs : list [tuple [uint64 , ProofOfSpace ]] = []
15011505 rng = random .Random ()
15021506 rng .seed (seed )
1507+
1508+ required_plot_strength = calculate_required_plot_strength (constants , prev_transaction_b_height )
1509+
15031510 for plot_info in self .plot_manager .plots .values ():
15041511 plot_id : bytes32 = plot_info .prover .get_id ()
15051512 if force_plot_id is not None and plot_id != force_plot_id :
@@ -1508,10 +1515,29 @@ def get_pospaces_for_challenge(
15081515 if not passes_plot_filter (prefix_bits , plot_id , challenge_hash , signage_point ):
15091516 continue
15101517
1518+ # v2 plots aren't valid until after the hard fork
1519+ if (
1520+ prev_transaction_b_height < constants .HARD_FORK2_HEIGHT
1521+ and plot_info .prover .get_version () == PlotVersion .V2
1522+ ):
1523+ continue
1524+
15111525 new_challenge : bytes32 = calculate_pos_challenge (plot_id , challenge_hash , signage_point )
1512- qualities = plot_info .prover .get_qualities_for_challenge (new_challenge )
15131526
1514- for proof_index , quality_str in enumerate (qualities ):
1527+ # these are either qualities (v1) or partial proofs (v2)
1528+ proofs : Sequence [Union [bytes32 , bytes ]]
1529+ v = plot_info .prover .get_version ()
1530+ if v == PlotVersion .V1 :
1531+ proofs = plot_info .prover .get_qualities_for_challenge (new_challenge )
1532+ else :
1533+ proofs = plot_info .prover .get_partial_proofs_for_challenge (new_challenge , required_plot_strength )
1534+
1535+ for proof_index , proof in enumerate (proofs ):
1536+ if v == PlotVersion .V2 :
1537+ quality_str = quality_for_partial_proof (proof , new_challenge )
1538+ elif v == PlotVersion .V1 :
1539+ quality_str = bytes32 (proof )
1540+
15151541 required_iters = calculate_iterations_quality (
15161542 constants ,
15171543 quality_str ,
@@ -1524,7 +1550,11 @@ def get_pospaces_for_challenge(
15241550 if required_iters >= calculate_sp_interval_iters (constants , sub_slot_iters ):
15251551 continue
15261552
1527- proof_xs : bytes = plot_info .prover .get_full_proof (new_challenge , proof_index )
1553+ proof_xs : bytes
1554+ if v == PlotVersion .V1 :
1555+ proof_xs = plot_info .prover .get_full_proof (new_challenge , proof_index )
1556+ else :
1557+ proof_xs = solve_proof (proof )
15281558
15291559 # Look up local_sk from plot to save locked memory
15301560 (
0 commit comments