Skip to content

Commit f8deac0

Browse files
committed
v2 plots only support pool contract puzzle hash
1 parent e947dd1 commit f8deac0

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

chia/consensus/block_header_validation.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,10 +756,15 @@ def validate_unfinished_header_block(
756756
!= constants.GENESIS_PRE_FARM_FARMER_PUZZLE_HASH
757757
):
758758
return None, ValidationError(Err.INVALID_PREFARM)
759-
# 20b. If pospace has a pool pk, heck pool target signature. Should not check this for genesis block.
759+
# 20b. If pospace has a pool pk, check pool target signature. Should not check this for genesis block.
760760
elif header_block.reward_chain_block.proof_of_space.pool_public_key is not None:
761761
assert header_block.reward_chain_block.proof_of_space.pool_contract_puzzle_hash is None
762762
assert header_block.foliage.foliage_block_data.pool_signature is not None
763+
764+
# v2 plots require pool contract puzzle hash, not pool pk
765+
if header_block.reward_chain_block.proof_of_space.size().size_v2 is not None:
766+
return None, ValidationError(Err.INVALID_POOL_SIGNATURE)
767+
763768
if not AugSchemeMPL.verify(
764769
header_block.reward_chain_block.proof_of_space.pool_public_key,
765770
bytes(header_block.foliage.foliage_block_data.pool_target),

chia/types/blockchain_format/proof_of_space.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ def make_pos(
4949
k = version_and_size.size_v1
5050
else:
5151
assert version_and_size.size_v2 is not None
52+
# v2 plots only support pool contract puzzle hash, not pool pk
53+
assert pool_contract_puzzle_hash is not None
5254
k = version_and_size.size_v2
5355
assert k is not None
5456
k |= 0x80
@@ -64,6 +66,11 @@ def make_pos(
6466

6567

6668
def get_plot_id(pos: ProofOfSpace) -> bytes32:
69+
plot_size = pos.size()
70+
if plot_size.size_v2 is not None:
71+
assert pos.pool_contract_puzzle_hash is not None
72+
return calculate_plot_id_v2(pos.pool_contract_puzzle_hash, pos.plot_public_key, plot_size.size_v2)
73+
6774
assert pos.pool_public_key is None or pos.pool_contract_puzzle_hash is None
6875
if pos.pool_public_key is None:
6976
assert pos.pool_contract_puzzle_hash is not None
@@ -114,6 +121,10 @@ def verify_and_get_quality_string(
114121
return None
115122

116123
plot_size = pos.size()
124+
if plot_size.size_v2 is not None and pos.pool_contract_puzzle_hash is None:
125+
log.error("v2 plots require pool_contract_puzzle_hash, pool public key is not supported")
126+
return None
127+
117128
if not check_plot_size(constants, plot_size):
118129
return None
119130

@@ -204,6 +215,14 @@ def calculate_pos_challenge(plot_id: bytes32, challenge_hash: bytes32, signage_p
204215
return std_hash(calculate_plot_filter_input(plot_id, challenge_hash, signage_point))
205216

206217

218+
def calculate_plot_id_v2(
219+
pool_contract_puzzle_hash: bytes32,
220+
plot_public_key: G1Element,
221+
strength: uint8,
222+
) -> bytes32:
223+
return std_hash(bytes(pool_contract_puzzle_hash) + bytes(plot_public_key) + bytes(strength))
224+
225+
207226
def calculate_plot_id_pk(
208227
pool_public_key: G1Element,
209228
plot_public_key: G1Element,

0 commit comments

Comments
 (0)