From 2d4c21315c2b09252afe8f16221f8852ff367b2d Mon Sep 17 00:00:00 2001 From: arvidn Date: Fri, 21 Nov 2025 16:21:53 +0100 Subject: [PATCH 1/3] make test_conditions.py use the farmer reward, and not the pool reward, for its tests. This prepares this test to work with v2 plots, since they don't support redirecting the pool reward --- chia/_tests/core/full_node/test_conditions.py | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/chia/_tests/core/full_node/test_conditions.py b/chia/_tests/core/full_node/test_conditions.py index 3e8c92e43a97..554125f33cae 100644 --- a/chia/_tests/core/full_node/test_conditions.py +++ b/chia/_tests/core/full_node/test_conditions.py @@ -15,6 +15,7 @@ from chia._tests.blockchain.blockchain_test_utils import _validate_and_add_block from chia._tests.conftest import ConsensusMode from chia._tests.core.full_node.ram_db import create_ram_blockchain +from chia._tests.core.full_node.test_full_node import find_reward_coin from chia.consensus.condition_tools import agg_sig_additional_data from chia.simulator.block_tools import BlockTools from chia.simulator.keyring import TempKeyring @@ -47,7 +48,6 @@ async def initial_blocks(bt: BlockTools, block_count: int = 4) -> list[FullBlock block_count, guarantee_transaction_block=True, farmer_reward_puzzle_hash=EASY_PUZZLE_HASH, - pool_reward_puzzle_hash=EASY_PUZZLE_HASH, genesis_timestamp=uint64(10000), time_per_block=10, ) @@ -101,7 +101,7 @@ async def check_conditions( aggsig: G2Element = G2Element(), ) -> tuple[list[CoinRecord], list[CoinRecord], FullBlock]: blocks = await initial_blocks(bt) - coin = blocks[spend_reward_index].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[spend_reward_index], EASY_PUZZLE_HASH) coin_spend = make_spend(coin, EASY_PUZZLE, condition_solution) spend_bundle = SpendBundle([coin_spend], aggsig) @@ -143,9 +143,9 @@ async def test_unknown_conditions_with_cost( # once the hard fork activates, blocks no longer pay the cost of the ROM # generator (which includes hashing all puzzles). if consensus_mode >= ConsensusMode.HARD_FORK_2_0: - block_base_cost = 756064 + block_base_cost = 756064 - 12000 else: - block_base_cost = 761056 + block_base_cost = 761056 - 12000 assert new_block.transactions_info is not None assert new_block.transactions_info.cost - block_base_cost == expected_cost @@ -164,11 +164,11 @@ async def test_softfork_condition( _additions, _removals, new_block = await check_conditions(bt, conditions) if consensus_mode < ConsensusMode.HARD_FORK_2_0: - block_base_cost = 737056 + block_base_cost = 737056 - 12000 else: # once the hard fork activates, blocks no longer pay the cost of the ROM # generator (which includes hashing all puzzles). - block_base_cost = 732064 + block_base_cost = 732064 - 12000 # the block_base_cost includes the cost of the bytes for the condition # with 2 bytes argument. This test works as long as the conditions it's @@ -267,7 +267,7 @@ async def test_condition(self, opcode: ConditionOpcode, value: int, expected: Er @pytest.mark.anyio async def test_invalid_my_id(self, bt: BlockTools) -> None: blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) wrong_name = bytearray(coin.name()) wrong_name[-1] ^= 1 conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{wrong_name.hex()}))")) @@ -276,14 +276,14 @@ async def test_invalid_my_id(self, bt: BlockTools) -> None: @pytest.mark.anyio async def test_valid_my_id(self, bt: BlockTools) -> None: blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) conditions = Program.to(assemble(f"(({ConditionOpcode.ASSERT_MY_COIN_ID[0]} 0x{coin.name().hex()}))")) await check_conditions(bt, conditions) @pytest.mark.anyio async def test_invalid_coin_announcement(self, bt: BlockTools) -> None: blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) announce = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test_bad") conditions = Program.to( assemble( @@ -296,7 +296,7 @@ async def test_invalid_coin_announcement(self, bt: BlockTools) -> None: @pytest.mark.anyio async def test_valid_coin_announcement(self, bt: BlockTools) -> None: blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) announce = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test") conditions = Program.to( assemble( @@ -374,7 +374,7 @@ async def test_announce_conditions_limit( """ blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) coin_announcement = AssertCoinAnnouncement(asserted_id=coin.name(), asserted_msg=b"test") puzzle_announcement = AssertPuzzleAnnouncement(asserted_ph=EASY_PUZZLE_HASH, asserted_msg=b"test") @@ -404,7 +404,7 @@ async def test_announce_conditions_limit( @pytest.mark.anyio async def test_coin_messages(self, bt: BlockTools, consensus_mode: ConsensusMode) -> None: blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) conditions = Program.to( assemble( f"(({ConditionOpcode.SEND_MESSAGE[0]} 0x3f 'test' 0x{coin.name().hex()})" @@ -416,7 +416,7 @@ async def test_coin_messages(self, bt: BlockTools, consensus_mode: ConsensusMode @pytest.mark.anyio async def test_parent_messages(self, bt: BlockTools, consensus_mode: ConsensusMode) -> None: blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) conditions = Program.to( assemble( f"(({ConditionOpcode.SEND_MESSAGE[0]} 0x24 'test' 0x{coin.parent_coin_info})" @@ -437,7 +437,7 @@ async def test_parent_messages(self, bt: BlockTools, consensus_mode: ConsensusMo ('(66 0x27 "foo" {coin}) (67 0x3f "foo" {coin})', Err.MESSAGE_NOT_SENT_OR_RECEIVED), ('(66 0 "foo") (67 0 "foo")', None), ('(66 0 "foobar") (67 0 "foo")', Err.MESSAGE_NOT_SENT_OR_RECEIVED), - ('(66 0x09 "foo" 1750000000000) (67 0x09 "foo" 1750000000000)', None), + ('(66 0x09 "foo" 250000000000) (67 0x09 "foo" 250000000000)', None), ('(66 -1 "foo")', Err.INVALID_MESSAGE_MODE), ('(67 -1 "foo")', Err.INVALID_MESSAGE_MODE), ('(66 0x40 "foo")', Err.INVALID_MESSAGE_MODE), @@ -448,7 +448,7 @@ async def test_message_conditions( self, bt: BlockTools, consensus_mode: ConsensusMode, conds: str, expected: Err | None ) -> None: blocks = await initial_blocks(bt) - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) conditions = Program.to(assemble("(" + conds.format(coin="0x" + coin.name().hex()) + ")")) await check_conditions(bt, conditions, expected_err=expected) @@ -521,7 +521,7 @@ async def test_agg_sig_illegal_suffix( sk = AugSchemeMPL.key_gen(b"8" * 32) pubkey = sk.get_g1() - coin = blocks[-2].get_included_reward_coins()[0] + coin = find_reward_coin(blocks[-2], EASY_PUZZLE_HASH) for msg in [ c.AGG_SIG_ME_ADDITIONAL_DATA, c.AGG_SIG_PARENT_ADDITIONAL_DATA, From 11a2cdefa62fb33794372a9087e844bbca2ae8d1 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 23 Nov 2025 11:05:56 +0100 Subject: [PATCH 2/3] fix get_plot_id() for v2 proofs --- chia/types/blockchain_format/proof_of_space.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chia/types/blockchain_format/proof_of_space.py b/chia/types/blockchain_format/proof_of_space.py index 8456bf88bdb6..3c69e1b86948 100644 --- a/chia/types/blockchain_format/proof_of_space.py +++ b/chia/types/blockchain_format/proof_of_space.py @@ -46,7 +46,7 @@ def get_plot_id(pos: ProofOfSpace) -> bytes32: plot_param = pos.param() if plot_param.strength_v2 is not None: assert pos.pool_contract_puzzle_hash is not None - return calculate_plot_id_v2(pos.pool_contract_puzzle_hash, pos.plot_public_key, plot_param.strength_v2) + return calculate_plot_id_v2(pos.pool_contract_puzzle_hash, pos.plot_public_key, uint8(plot_param.strength_v2)) assert pos.pool_public_key is None or pos.pool_contract_puzzle_hash is None if pos.pool_public_key is None: From 2f693a545a0737d55998a684a1488bf4902dee8d Mon Sep 17 00:00:00 2001 From: arvidn Date: Sun, 23 Nov 2025 11:35:32 +0100 Subject: [PATCH 3/3] fix proof-of-space tests --- chia/_tests/core/custom_types/test_proof_of_space.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 c8162398675d..37b0586da215 100644 --- a/chia/_tests/core/custom_types/test_proof_of_space.py +++ b/chia/_tests/core/custom_types/test_proof_of_space.py @@ -128,7 +128,7 @@ def b32(key: str) -> bytes32: ), ProofOfSpaceCase( id="Not passing the plot filter v2", - pos_challenge=b32("5706ae15c4a437399f464c64ef4f33c362d860ccd2945b76b3ebdb0505783817"), + pos_challenge=b32("4cfaacbd2782db64d07cf490ca938534adb07dfbd2f92b0e479e2e5b196178db"), plot_size=PlotParam.make_v2(32), pool_contract_puzzle_hash=bytes32(b"1" * 32), plot_public_key=g1( @@ -180,7 +180,7 @@ def test_verify_and_get_quality_string(caplog: pytest.LogCaptureFixture, case: P ProofOfSpaceCase( id="not passing the plot filter v2", plot_size=PlotParam.make_v2(2), - pos_challenge=b32("fb1d676f0e3ce173f4e6cfb06d7059886cbc3b91cf65be0af0fc2fbe569c6597"), + pos_challenge=b32("aefba5c94bc9bbfe2c538b7faaaf03384ac5a6170e40b024657df6b0a27c34a7"), plot_public_key=g1( "afa3aaf09c03885154be49216ee7fb2e4581b9c4a4d7e9cc402e27280bf0cfdbdf1b9ba674e301fd1d1450234b3b1868" ),