Skip to content

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented Aug 8, 2025

Purpose:

  • update the Prover protocol to make get_size() return PlotSize. This allows to seamlessly pass it to calculate_prefix_bits() and calculate_iterations_quality()
  • ProofOfSpace is part of the protocol and can't change, but this PR adds a function, make_pos() which makes it a bit simpler to construct a ProofOfSpace object from a PlotSize.
  • extend tests in chia/_tests/util/test_full_block_utils.py to cover blocks with v2 proofs
  • add preliminary v2 support to _expected_plot_size()
  • mark up a few more places with todo_v2_plots comments, to indicate they need to be addressed for v2 plots.

@arvidn arvidn force-pushed the pos-size-type branch 2 times, most recently from 622b772 to fe41662 Compare August 9, 2025 10:55
@arvidn arvidn added the Changed Required label for PR that categorizes merge commit message as "Changed" for changelog label Aug 9, 2025
@arvidn arvidn force-pushed the pos-size-type branch 2 times, most recently from 1575403 to 3284a57 Compare August 10, 2025 22:32
@arvidn arvidn marked this pull request as ready for review August 11, 2025 00:12
@arvidn arvidn requested a review from a team as a code owner August 11, 2025 00:12
@arvidn arvidn requested a review from almogdepaz August 11, 2025 00:13
@arvidn
Copy link
Contributor Author

arvidn commented Aug 11, 2025

most of the missing coverage also have TODO comments indicating they will need to be addressed for v2 plots support.

almogdepaz
almogdepaz previously approved these changes Aug 11, 2025
@arvidn arvidn requested a review from wjblanke August 11, 2025 10:52
wjblanke
wjblanke previously approved these changes Aug 12, 2025
Copy link
Contributor

@wjblanke wjblanke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aok

@arvidn arvidn added the ready_to_merge Submitter and reviewers think this is ready label Aug 13, 2025
@github-actions github-actions bot added merge_conflict Branch has conflicts that prevent merge to main labels Aug 13, 2025
@arvidn arvidn dismissed stale reviews from wjblanke and almogdepaz via e3fd426 August 14, 2025 05:01
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Aug 14, 2025
@arvidn
Copy link
Contributor Author

arvidn commented Aug 14, 2025

there was a merge conflict and I had to rebase. The conflict was in the import statement of chia/_tests/core/custom_types/test_proof_of_space.py

This is the diff of the diff:

--- original.diff	2025-08-14 06:58:06
+++ new.diff	2025-08-14 06:59:15
@@ -1,10 +1,3 @@
-diff --git a/chia-blockchain-gui b/chia-blockchain-gui
-index 1c6fb425c5..5d57f5dc60 160000
---- a/chia-blockchain-gui
-+++ b/chia-blockchain-gui
-@@ -1 +1 @@
--Subproject commit 1c6fb425c5b5f03e7c10cd11d0ff6003866a6e0c
-+Subproject commit 5d57f5dc60945dda2c94dcbde1ec80fb2d59c2d7
 diff --git a/chia/_tests/core/consensus/test_pot_iterations.py b/chia/_tests/core/consensus/test_pot_iterations.py
 index 2d2ddaeba1..187213263b 100644
 --- a/chia/_tests/core/consensus/test_pot_iterations.py
@@ -60,7 +53,7 @@
 +        assert plot_size > last_size
 +        last_size = plot_size
 diff --git a/chia/_tests/core/custom_types/test_proof_of_space.py b/chia/_tests/core/custom_types/test_proof_of_space.py
-index ed8520f360..d51b194654 100644
+index 8d99a94254..8f78fb9a93 100644
 --- a/chia/_tests/core/custom_types/test_proof_of_space.py
 +++ b/chia/_tests/core/custom_types/test_proof_of_space.py
 @@ -5,7 +5,7 @@ from dataclasses import dataclass
@@ -72,15 +65,15 @@
  from chia_rs.sized_bytes import bytes32, bytes48
  from chia_rs.sized_ints import uint8, uint32
  
-@@ -14,6 +14,7 @@ from chia.consensus.default_constants import DEFAULT_CONSTANTS
- from chia.types.blockchain_format.proof_of_space import (
+@@ -15,6 +15,7 @@ from chia.types.blockchain_format.proof_of_space import (
      calculate_plot_difficulty,
      calculate_prefix_bits,
+     check_plot_size,
 +    make_pos,
      passes_plot_filter,
      verify_and_get_quality_string,
  )
-@@ -23,7 +24,7 @@ from chia.types.blockchain_format.proof_of_space import (
+@@ -24,7 +25,7 @@ from chia.types.blockchain_format.proof_of_space import (
  class ProofOfSpaceCase:
      id: str
      pos_challenge: bytes32
@@ -89,7 +82,7 @@
      plot_public_key: G1Element
      pool_public_key: Optional[G1Element] = None
      pool_contract_puzzle_hash: Optional[bytes32] = None
-@@ -45,14 +46,14 @@ def b32(key: str) -> bytes32:
+@@ -46,14 +47,14 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="Neither pool public key nor pool contract puzzle hash",
          pos_challenge=bytes32(b"1" * 32),
@@ -106,7 +99,7 @@
          plot_public_key=G1Element(),
          pool_public_key=G1Element(),
          pool_contract_puzzle_hash=bytes32(b"1" * 32),
-@@ -61,7 +62,7 @@ def b32(key: str) -> bytes32:
+@@ -62,7 +63,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="Lower than minimum plot size",
          pos_challenge=bytes32(b"1" * 32),
@@ -115,7 +108,7 @@
          plot_public_key=G1Element(),
          pool_public_key=G1Element(),
          expected_error="Plot size is lower than the minimum",
-@@ -69,7 +70,7 @@ def b32(key: str) -> bytes32:
+@@ -70,7 +71,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="Higher than maximum plot size",
          pos_challenge=bytes32(b"1" * 32),
@@ -124,7 +117,7 @@
          plot_public_key=G1Element(),
          pool_public_key=G1Element(),
          expected_error="Plot size is higher than the maximum",
-@@ -77,7 +78,7 @@ def b32(key: str) -> bytes32:
+@@ -78,7 +79,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="Different challenge",
          pos_challenge=bytes32(b"1" * 32),
@@ -133,7 +126,7 @@
          pool_public_key=G1Element(),
          plot_public_key=G1Element(),
          expected_error="Calculated pos challenge doesn't match the provided one",
-@@ -85,7 +86,7 @@ def b32(key: str) -> bytes32:
+@@ -86,7 +87,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="Not passing the plot filter with size 9",
          pos_challenge=b32("08b23cc2844dfb92d2eedaa705a1ce665d571ee753bd81cbb67b92caa6d34722"),
@@ -142,7 +135,7 @@
          pool_public_key=g1(
              "b6449c2c68df97c19e884427e42ee7350982d4020571ead08732615ff39bd216bfd630b6460784982bec98b49fea79d0"
          ),
-@@ -98,7 +99,7 @@ def b32(key: str) -> bytes32:
+@@ -99,7 +100,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="Passing the plot filter with size 8",
          pos_challenge=b32("08b23cc2844dfb92d2eedaa705a1ce665d571ee753bd81cbb67b92caa6d34722"),
@@ -151,7 +144,7 @@
          pool_public_key=g1(
              "b6449c2c68df97c19e884427e42ee7350982d4020571ead08732615ff39bd216bfd630b6460784982bec98b49fea79d0"
          ),
-@@ -110,7 +111,7 @@ def b32(key: str) -> bytes32:
+@@ -111,7 +112,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="v2 plot size 0",
          pos_challenge=bytes32(b"1" * 32),
@@ -160,7 +153,7 @@
          plot_public_key=G1Element(),
          pool_public_key=G1Element(),
          expected_error="Plot size is lower than the minimum",
-@@ -118,7 +119,7 @@ def b32(key: str) -> bytes32:
+@@ -119,7 +120,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="v2 plot size 34",
          pos_challenge=bytes32(b"1" * 32),
@@ -169,7 +162,7 @@
          plot_public_key=G1Element(),
          pool_public_key=G1Element(),
          expected_error="Plot size is higher than the maximum",
-@@ -126,7 +127,7 @@ def b32(key: str) -> bytes32:
+@@ -127,7 +128,7 @@ def b32(key: str) -> bytes32:
      ProofOfSpaceCase(
          id="Not passing the plot filter v2",
          pos_challenge=b32("3d29ea79d19b3f7e99ebf764ae53697cbe143603909873946af6ab1ece606861"),
@@ -178,7 +171,7 @@
          pool_public_key=g1(
              "b6449c2c68df97c19e884427e42ee7350982d4020571ead08732615ff39bd216bfd630b6460784982bec98b49fea79d0"
          ),
-@@ -137,7 +138,7 @@ def b32(key: str) -> bytes32:
+@@ -138,7 +139,7 @@ def b32(key: str) -> bytes32:
      ),
  )
  def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: ProofOfSpaceCase) -> None:
@@ -187,7 +180,7 @@
          challenge=case.pos_challenge,
          pool_public_key=case.pool_public_key,
          pool_contract_puzzle_hash=case.pool_contract_puzzle_hash,
-@@ -159,7 +160,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P
+@@ -160,7 +161,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P
  @datacases(
      ProofOfSpaceCase(
          id="v2 plot are not implemented",
@@ -196,7 +189,7 @@
          pos_challenge=b32("47deb938e145d25d7b3b3c85ca9e3972b76c01aeeb78a02fe5d3b040d282317e"),
          plot_public_key=g1(
              "afa3aaf09c03885154be49216ee7fb2e4581b9c4a4d7e9cc402e27280bf0cfdbdf1b9ba674e301fd1d1450234b3b1868"
-@@ -171,7 +172,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P
+@@ -172,7 +173,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P
      ),
  )
  def test_verify_and_get_quality_string_v2(caplog: pytest.LogCaptureFixture, case: ProofOfSpaceCase) -> None:
@@ -341,10 +334,10 @@
      assert plot_sync_dict_3["last_sync_time"] > 0
      assert plot_sync_dict_3["syncing"] is None
 diff --git a/chia/_tests/plotting/test_plot_manager.py b/chia/_tests/plotting/test_plot_manager.py
-index 3108da7569..1dd5e10b9a 100644
+index 15ea5c2e38..d326da25e4 100644
 --- a/chia/_tests/plotting/test_plot_manager.py
 +++ b/chia/_tests/plotting/test_plot_manager.py
-@@ -509,7 +509,8 @@ async def test_plot_info_caching(environment, bt):
+@@ -508,7 +508,8 @@ async def test_plot_info_caching(environment, bt):
          assert plot_manager.plots[path].prover.get_filename() == plot_info.prover.get_filename()
          assert plot_manager.plots[path].prover.get_id() == plot_info.prover.get_id()
          assert plot_manager.plots[path].prover.get_memo() == plot_info.prover.get_memo()
@@ -632,7 +625,7 @@
  
                  log.info(f"Parsed {len(self._data)} cache entries in {time.time() - start:.2f}s")
 diff --git a/chia/plotting/check_plots.py b/chia/plotting/check_plots.py
-index 0fe7c2567f..75165c4c4e 100644
+index f4d2a7ab61..9bbe427351 100644
 --- a/chia/plotting/check_plots.py
 +++ b/chia/plotting/check_plots.py
 @@ -133,14 +133,16 @@ def check_plots(
@@ -768,7 +761,7 @@
      def get_memo(self) -> bytes:
          return bytes(self._disk_prover.get_memo())
 diff --git a/chia/simulator/block_tools.py b/chia/simulator/block_tools.py
-index e51143c08e..323cc25bf4 100644
+index 79678a4924..500fc69a58 100644
 --- a/chia/simulator/block_tools.py
 +++ b/chia/simulator/block_tools.py
 @@ -28,7 +28,6 @@ from chia_rs import (
@@ -787,7 +780,7 @@
      passes_plot_filter,
  )
  from chia.types.blockchain_format.serialized_program import SerializedProgram
-@@ -1506,8 +1506,7 @@ class BlockTools:
+@@ -1504,8 +1504,7 @@ class BlockTools:
              plot_id: bytes32 = plot_info.prover.get_id()
              if force_plot_id is not None and plot_id != force_plot_id:
                  continue
@@ -797,7 +790,7 @@
              if passes_plot_filter(prefix_bits, plot_id, challenge_hash, signage_point):
                  new_challenge: bytes32 = calculate_pos_challenge(plot_id, challenge_hash, signage_point)
                  qualities = plot_info.prover.get_qualities_for_challenge(new_challenge)
-@@ -1516,8 +1515,7 @@ class BlockTools:
+@@ -1514,8 +1513,7 @@ class BlockTools:
                      required_iters = calculate_iterations_quality(
                          constants,
                          quality_str,
@@ -807,7 +800,7 @@
                          difficulty,
                          signage_point,
                          sub_slot_iters,
-@@ -1540,7 +1538,7 @@ class BlockTools:
+@@ -1538,7 +1536,7 @@ class BlockTools:
                              assert isinstance(pool_public_key_or_puzzle_hash, bytes32)
                              include_taproot = True
                          plot_pk = generate_plot_public_key(local_sk.get_g1(), farmer_public_key, include_taproot)
@@ -817,7 +810,7 @@
                              plot_info.pool_public_key,
                              plot_info.pool_contract_puzzle_hash,
 diff --git a/chia/types/blockchain_format/proof_of_space.py b/chia/types/blockchain_format/proof_of_space.py
-index 3befb30fc6..47962d699b 100644
+index 6512177290..1b574d13f3 100644
 --- a/chia/types/blockchain_format/proof_of_space.py
 +++ b/chia/types/blockchain_format/proof_of_space.py
 @@ -14,6 +14,33 @@ from chia.util.hash import std_hash

@arvidn arvidn requested review from almogdepaz and wjblanke August 14, 2025 05:09
Copy link
Contributor

File Coverage Missing Lines
chia/harvester/harvester.py 60.0% lines 197-198
chia/plotting/cache.py 85.7% lines 184, 193
chia/plotting/check_plots.py 0.0% lines 136-137, 237-241, 243-246, 268, 270-273
chia/plotting/manager.py 66.7% lines 342, 348, 351
Total Missing Coverage
104 lines 23 lines 77%

Copy link
Contributor

@wjblanke wjblanke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aok

@Starttoaster Starttoaster merged commit 18fd65d into main Aug 14, 2025
1025 of 1033 checks passed
@Starttoaster Starttoaster deleted the pos-size-type branch August 14, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changed Required label for PR that categorizes merge commit message as "Changed" for changelog ready_to_merge Submitter and reviewers think this is ready

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants