|
30 | 30 | from chia.consensus.blockchain_interface import BlockchainInterface |
31 | 31 | from chia.consensus.deficit import calculate_deficit |
32 | 32 | 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 |
34 | 33 | from chia.consensus.pot_iterations import ( |
35 | 34 | calculate_ip_iters, |
36 | 35 | calculate_sp_iters, |
@@ -1320,14 +1319,17 @@ def _validate_pospace_recent_chain( |
1320 | 1319 | cc_sp_hash = block.reward_chain_block.challenge_chain_sp_vdf.output.get_hash() |
1321 | 1320 | assert cc_sp_hash is not None |
1322 | 1321 |
|
| 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. |
1323 | 1325 | required_iters = validate_pospace_and_get_required_iters( |
1324 | 1326 | constants, |
1325 | 1327 | block.reward_chain_block.proof_of_space, |
1326 | 1328 | challenge if not overflow else prev_challenge, |
1327 | 1329 | cc_sp_hash, |
1328 | 1330 | block.height, |
1329 | 1331 | diff, |
1330 | | - prev_tx_block(blocks, blocks.block_record(block.prev_header_hash)), |
| 1332 | + uint32(max(0, block.height - constants.MAX_SUB_SLOT_BLOCKS)), |
1331 | 1333 | ) |
1332 | 1334 | if required_iters is None: |
1333 | 1335 | log.error(f"could not verify proof of space block {block.height} {overflow}") |
@@ -1367,14 +1369,17 @@ def __validate_pospace( |
1367 | 1369 | # validate proof of space |
1368 | 1370 | assert sub_slot_data.proof_of_space is not None |
1369 | 1371 |
|
| 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. |
1370 | 1375 | required_iters = validate_pospace_and_get_required_iters( |
1371 | 1376 | constants, |
1372 | 1377 | sub_slot_data.proof_of_space, |
1373 | 1378 | challenge, |
1374 | 1379 | cc_sp_hash, |
1375 | 1380 | height, |
1376 | 1381 | 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)), |
1378 | 1383 | ) |
1379 | 1384 | if required_iters is None: |
1380 | 1385 | log.error("could not verify proof of space") |
|
0 commit comments