Skip to content

Commit 3d769be

Browse files
committed
address review comments
1 parent 05631d1 commit 3d769be

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

chia/full_node/weight_proof.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from chia.consensus.blockchain_interface import BlockchainInterface
3131
from chia.consensus.deficit import calculate_deficit
3232
from chia.consensus.full_block_to_block_record import header_block_to_sub_block_record
33-
from chia.consensus.get_block_challenge import prev_tx_block
3433
from chia.consensus.pot_iterations import (
3534
calculate_ip_iters,
3635
calculate_sp_iters,
@@ -1320,14 +1319,17 @@ def _validate_pospace_recent_chain(
13201319
cc_sp_hash = block.reward_chain_block.challenge_chain_sp_vdf.output.get_hash()
13211320
assert cc_sp_hash is not None
13221321

1322+
# when sampling blocks as part of weight proof validation, the previous
1323+
# transaction height is a conservative estimate, since we don't have direct
1324+
# access to it.
13231325
required_iters = validate_pospace_and_get_required_iters(
13241326
constants,
13251327
block.reward_chain_block.proof_of_space,
13261328
challenge if not overflow else prev_challenge,
13271329
cc_sp_hash,
13281330
block.height,
13291331
diff,
1330-
prev_tx_block(blocks, blocks.block_record(block.prev_header_hash)),
1332+
uint32(max(0, block.height - constants.MAX_SUB_SLOT_BLOCKS)),
13311333
)
13321334
if required_iters is None:
13331335
log.error(f"could not verify proof of space block {block.height} {overflow}")
@@ -1367,14 +1369,17 @@ def __validate_pospace(
13671369
# validate proof of space
13681370
assert sub_slot_data.proof_of_space is not None
13691371

1372+
# when sampling blocks as part of weight proof validation, the previous
1373+
# transaction height is a conservative estimate, since we don't have direct
1374+
# access to it.
13701375
required_iters = validate_pospace_and_get_required_iters(
13711376
constants,
13721377
sub_slot_data.proof_of_space,
13731378
challenge,
13741379
cc_sp_hash,
13751380
height,
13761381
curr_diff,
1377-
uint32(0), # prev_tx_block(blocks, prev_b), todo need to get height of prev tx block somehow here
1382+
uint32(max(0, height - constants.MAX_SUB_SLOT_BLOCKS)),
13781383
)
13791384
if required_iters is None:
13801385
log.error("could not verify proof of space")

chia/types/blockchain_format/proof_of_space.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ def is_v1_phased_out(
109109
return proof_value > epoch_counter
110110

111111

112-
# TODO: the "height" parameter is a bit suspect. It can probably be removed in
113-
# favor of prev_transaction_block_height
114112
def verify_and_get_quality_string(
115113
pos: ProofOfSpace,
116114
constants: ConsensusConstants,
@@ -123,6 +121,7 @@ def verify_and_get_quality_string(
123121
plot_size = pos.size()
124122

125123
if plot_size.size_v1 is not None and is_v1_phased_out(pos.proof, prev_transaction_block_height, constants):
124+
log.info("v1 proof has been phased-out and is no longer valid")
126125
return None
127126

128127
# Exactly one of (pool_public_key, pool_contract_puzzle_hash) must not be None

0 commit comments

Comments
 (0)