|
89 | 89 | from chia.types.blockchain_format.coin import Coin
|
90 | 90 | from chia.types.blockchain_format.program import DEFAULT_FLAGS, INFINITE_COST, Program, _run, run_with_cost
|
91 | 91 | from chia.types.blockchain_format.proof_of_space import (
|
| 92 | + calculate_plot_strength, |
92 | 93 | calculate_pos_challenge,
|
93 | 94 | calculate_prefix_bits,
|
94 | 95 | generate_plot_public_key,
|
@@ -1500,51 +1501,57 @@ def get_pospaces_for_challenge(
|
1500 | 1501 | found_proofs: list[tuple[uint64, ProofOfSpace]] = []
|
1501 | 1502 | rng = random.Random()
|
1502 | 1503 | rng.seed(seed)
|
| 1504 | + |
| 1505 | + plot_strength = calculate_plot_strength(constants, height) |
1503 | 1506 | for plot_info in self.plot_manager.plots.values():
|
1504 | 1507 | plot_id: bytes32 = plot_info.prover.get_id()
|
1505 | 1508 | if force_plot_id is not None and plot_id != force_plot_id:
|
1506 | 1509 | continue
|
1507 | 1510 | prefix_bits = calculate_prefix_bits(constants, height, plot_info.prover.get_size())
|
1508 |
| - if passes_plot_filter(prefix_bits, plot_id, challenge_hash, signage_point): |
1509 |
| - new_challenge: bytes32 = calculate_pos_challenge(plot_id, challenge_hash, signage_point) |
1510 |
| - qualities = plot_info.prover.get_qualities_for_challenge(new_challenge) |
| 1511 | + if not passes_plot_filter(prefix_bits, plot_id, challenge_hash, signage_point): |
| 1512 | + continue |
1511 | 1513 |
|
1512 |
| - for proof_index, quality_str in enumerate(qualities): |
1513 |
| - required_iters = calculate_iterations_quality( |
1514 |
| - constants, |
1515 |
| - quality_str, |
1516 |
| - plot_info.prover.get_size(), |
1517 |
| - difficulty, |
1518 |
| - signage_point, |
1519 |
| - sub_slot_iters, |
1520 |
| - prev_transaction_b_height, |
1521 |
| - ) |
1522 |
| - if required_iters < calculate_sp_interval_iters(constants, sub_slot_iters): |
1523 |
| - proof_xs: bytes = plot_info.prover.get_full_proof(new_challenge, proof_index) |
| 1514 | + new_challenge: bytes32 = calculate_pos_challenge(plot_id, challenge_hash, signage_point) |
| 1515 | + qualities = plot_info.prover.get_qualities_for_challenge(new_challenge, plot_strength) |
1524 | 1516 |
|
1525 |
| - # Look up local_sk from plot to save locked memory |
1526 |
| - ( |
1527 |
| - pool_public_key_or_puzzle_hash, |
1528 |
| - farmer_public_key, |
1529 |
| - local_master_sk, |
1530 |
| - ) = parse_plot_info(plot_info.prover.get_memo()) |
1531 |
| - local_sk = master_sk_to_local_sk(local_master_sk) |
1532 |
| - |
1533 |
| - if isinstance(pool_public_key_or_puzzle_hash, G1Element): |
1534 |
| - include_taproot = False |
1535 |
| - else: |
1536 |
| - assert isinstance(pool_public_key_or_puzzle_hash, bytes32) |
1537 |
| - include_taproot = True |
1538 |
| - plot_pk = generate_plot_public_key(local_sk.get_g1(), farmer_public_key, include_taproot) |
1539 |
| - proof_of_space: ProofOfSpace = make_pos( |
1540 |
| - new_challenge, |
1541 |
| - plot_info.pool_public_key, |
1542 |
| - plot_info.pool_contract_puzzle_hash, |
1543 |
| - plot_pk, |
1544 |
| - plot_info.prover.get_size(), |
1545 |
| - proof_xs, |
1546 |
| - ) |
1547 |
| - found_proofs.append((required_iters, proof_of_space)) |
| 1517 | + for proof_index, quality_str in enumerate(qualities): |
| 1518 | + required_iters = calculate_iterations_quality( |
| 1519 | + constants, |
| 1520 | + quality_str, |
| 1521 | + plot_info.prover.get_size(), |
| 1522 | + difficulty, |
| 1523 | + signage_point, |
| 1524 | + sub_slot_iters, |
| 1525 | + prev_transaction_b_height, |
| 1526 | + ) |
| 1527 | + if required_iters >= calculate_sp_interval_iters(constants, sub_slot_iters): |
| 1528 | + continue |
| 1529 | + |
| 1530 | + proof_xs: bytes = plot_info.prover.get_full_proof(new_challenge, proof_index) |
| 1531 | + |
| 1532 | + # Look up local_sk from plot to save locked memory |
| 1533 | + ( |
| 1534 | + pool_public_key_or_puzzle_hash, |
| 1535 | + farmer_public_key, |
| 1536 | + local_master_sk, |
| 1537 | + ) = parse_plot_info(plot_info.prover.get_memo()) |
| 1538 | + local_sk = master_sk_to_local_sk(local_master_sk) |
| 1539 | + |
| 1540 | + if isinstance(pool_public_key_or_puzzle_hash, G1Element): |
| 1541 | + include_taproot = False |
| 1542 | + else: |
| 1543 | + assert isinstance(pool_public_key_or_puzzle_hash, bytes32) |
| 1544 | + include_taproot = True |
| 1545 | + plot_pk = generate_plot_public_key(local_sk.get_g1(), farmer_public_key, include_taproot) |
| 1546 | + proof_of_space: ProofOfSpace = make_pos( |
| 1547 | + new_challenge, |
| 1548 | + plot_info.pool_public_key, |
| 1549 | + plot_info.pool_contract_puzzle_hash, |
| 1550 | + plot_pk, |
| 1551 | + plot_info.prover.get_size(), |
| 1552 | + proof_xs, |
| 1553 | + ) |
| 1554 | + found_proofs.append((required_iters, proof_of_space)) |
1548 | 1555 | random_sample = found_proofs
|
1549 | 1556 | if len(found_proofs) >= 1:
|
1550 | 1557 | if rng.random() < 0.1:
|
|
0 commit comments