Skip to content

Commit 70b182e

Browse files
authored
[CHIA-3805] reduce use of pool_reward_puzzle_hash feature of BlockTools (#20277)
* reduce use of pool_reward_puzzle_hash feature of BlockTools, since it's not supported by v2 plots * the BlockTools feature to ask for a specific pool puzzle hash are not supported by v2 proofs. v2 plots only have pool contract puzzle hash
1 parent 8beb3ee commit 70b182e

File tree

15 files changed

+102
-147
lines changed

15 files changed

+102
-147
lines changed

chia/_tests/blockchain/test_blockchain.py

Lines changed: 38 additions & 73 deletions
Large diffs are not rendered by default.

chia/_tests/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,6 @@ async def one_node_one_block(
812812
1,
813813
guarantee_transaction_block=True,
814814
farmer_reward_puzzle_hash=reward_ph,
815-
pool_reward_puzzle_hash=reward_ph,
816815
genesis_timestamp=uint64(10000),
817816
time_per_block=10,
818817
)
@@ -841,7 +840,6 @@ async def two_nodes_one_block(blockchain_constants: ConsensusConstants):
841840
1,
842841
guarantee_transaction_block=True,
843842
farmer_reward_puzzle_hash=reward_ph,
844-
pool_reward_puzzle_hash=reward_ph,
845843
genesis_timestamp=uint64(10000),
846844
time_per_block=10,
847845
)

chia/_tests/core/full_node/stores/test_block_store.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from chia_rs.sized_ints import uint8, uint32, uint64
1717

1818
from chia._tests.blockchain.blockchain_test_utils import _validate_and_add_block
19+
from chia._tests.core.full_node.test_full_node import find_reward_coin
1920
from chia._tests.util.db_connection import DBConnection, PathDBConnection
2021
from chia.consensus.block_body_validation import ForkInfo
2122
from chia.consensus.block_height_map import BlockHeightMap
@@ -57,11 +58,11 @@ async def test_block_store(tmp_dir: Path, db_version: int, bt: BlockTools, use_c
5758
3,
5859
guarantee_transaction_block=True,
5960
farmer_reward_puzzle_hash=bt.pool_ph,
60-
pool_reward_puzzle_hash=bt.pool_ph,
6161
time_per_block=10,
6262
)
6363
wt: WalletTool = bt.get_pool_wallet_tool()
64-
tx = wt.generate_signed_transaction(uint64(10), wt.get_new_puzzlehash(), blocks[-1].get_included_reward_coins()[0])
64+
coin = find_reward_coin(blocks[-1], bt.pool_ph)
65+
tx = wt.generate_signed_transaction(uint64(10), wt.get_new_puzzlehash(), coin)
6566
blocks = bt.get_consecutive_blocks(
6667
10,
6768
block_list_input=blocks,

chia/_tests/core/full_node/stores/test_coin_store.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ async def test_basic_coin_store(db_version: int, softfork_height: uint32, bt: Bl
6767
10,
6868
[],
6969
farmer_reward_puzzle_hash=reward_ph,
70-
pool_reward_puzzle_hash=reward_ph,
7170
)
7271

7372
coins_to_spend: list[Coin] = []
@@ -86,7 +85,6 @@ async def test_basic_coin_store(db_version: int, softfork_height: uint32, bt: Bl
8685
10,
8786
blocks,
8887
farmer_reward_puzzle_hash=reward_ph,
89-
pool_reward_puzzle_hash=reward_ph,
9088
transaction_data=spend_bundle,
9189
)
9290

@@ -374,11 +372,9 @@ async def test_get_puzzle_hash(tmp_dir: Path, db_version: int, bt: BlockTools) -
374372
async with DBConnection(db_version) as db_wrapper:
375373
num_blocks = 20
376374
farmer_ph = bytes32(32 * b"0")
377-
pool_ph = bytes32(32 * b"1")
378375
blocks = bt.get_consecutive_blocks(
379376
num_blocks,
380377
farmer_reward_puzzle_hash=farmer_ph,
381-
pool_reward_puzzle_hash=pool_ph,
382378
guarantee_transaction_block=True,
383379
)
384380
coin_store = await CoinStore.create(db_wrapper)
@@ -391,7 +387,7 @@ async def test_get_puzzle_hash(tmp_dir: Path, db_version: int, bt: BlockTools) -
391387
assert peak is not None
392388
assert peak.height == num_blocks - 1
393389

394-
coins_farmer = await coin_store.get_coin_records_by_puzzle_hash(True, pool_ph)
390+
coins_farmer = await coin_store.get_coin_records_by_puzzle_hash(True, bt.pool_ph)
395391
coins_pool = await coin_store.get_coin_records_by_puzzle_hash(True, farmer_ph)
396392

397393
assert len(coins_farmer) == num_blocks - 2

chia/_tests/core/full_node/stores/test_hint_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from chia_rs.sized_bytes import bytes32
77
from chia_rs.sized_ints import uint64
88

9+
from chia._tests.core.full_node.test_full_node import find_reward_coin
910
from chia._tests.util.db_connection import DBConnection
1011
from chia.full_node.hint_store import HintStore
1112
from chia.server.server import ChiaServer
@@ -151,7 +152,6 @@ async def test_hints_in_blockchain(
151152
block_list_input=[],
152153
guarantee_transaction_block=True,
153154
farmer_reward_puzzle_hash=bt.pool_ph,
154-
pool_reward_puzzle_hash=bt.pool_ph,
155155
)
156156
for block in blocks:
157157
await full_node_1.full_node.add_block(block, None)
@@ -160,7 +160,7 @@ async def test_hints_in_blockchain(
160160
puzzle_hash = bytes32(32 * b"\0")
161161
amount = int_to_bytes(1)
162162
hint = bytes32(32 * b"\5")
163-
coin_spent = blocks[-1].get_included_reward_coins()[0]
163+
coin_spent = find_reward_coin(blocks[-1], bt.pool_ph)
164164
condition_dict = {
165165
ConditionOpcode.CREATE_COIN: [ConditionWithArgs(ConditionOpcode.CREATE_COIN, [puzzle_hash, amount, hint])]
166166
}

chia/_tests/core/full_node/test_full_node.py

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import pytest
1313
from chia_rs import (
1414
AugSchemeMPL,
15+
Coin,
1516
ConsensusConstants,
1617
Foliage,
1718
FoliageTransactionBlock,
@@ -111,6 +112,13 @@
111112
from chia.wallet.wallet_spend_bundle import WalletSpendBundle
112113

113114

115+
def find_reward_coin(b: FullBlock, puzzle_hash: bytes32) -> Coin:
116+
for c in b.get_included_reward_coins():
117+
if c.puzzle_hash == puzzle_hash:
118+
return c
119+
raise ValueError("no reward coin with the specified puzzle hash found")
120+
121+
114122
def test_pre_validation_result() -> None:
115123
conds = SpendBundleConditions([], 0, 0, 0, None, None, [], 0, 0, 0, True, 0, 0, 0, 0, 0)
116124
results = PreValidationResult(None, uint64(1), conds, uint32(0))
@@ -812,11 +820,10 @@ async def test_respond_unfinished(
812820
block_list_input=blocks,
813821
guarantee_transaction_block=True,
814822
farmer_reward_puzzle_hash=ph,
815-
pool_reward_puzzle_hash=ph,
816823
)
817824
await full_node_1.full_node.add_block(blocks[-2])
818825
await full_node_1.full_node.add_block(blocks[-1])
819-
coin_to_spend = blocks[-1].get_included_reward_coins()[0]
826+
coin_to_spend = find_reward_coin(blocks[-1], ph)
820827

821828
spend_bundle = wallet_a.generate_signed_transaction(coin_to_spend.amount, ph_receiver, coin_to_spend)
822829

@@ -936,7 +943,6 @@ async def test_new_transaction_and_mempool(
936943
3,
937944
guarantee_transaction_block=True,
938945
farmer_reward_puzzle_hash=wallet_ph,
939-
pool_reward_puzzle_hash=wallet_ph,
940946
)
941947
for block in blocks:
942948
await full_node_1.full_node.add_block(block)
@@ -1127,7 +1133,6 @@ async def test_request_respond_transaction(
11271133
block_list_input=blocks,
11281134
guarantee_transaction_block=True,
11291135
farmer_reward_puzzle_hash=wallet_ph,
1130-
pool_reward_puzzle_hash=wallet_ph,
11311136
)
11321137

11331138
incoming_queue, _dummy_node_id = await add_dummy_connection(server_1, self_hostname, 12312)
@@ -1148,9 +1153,8 @@ async def test_request_respond_transaction(
11481153

11491154
receiver_puzzlehash = wallet_receiver.get_new_puzzlehash()
11501155

1151-
spend_bundle = wallet_a.generate_signed_transaction(
1152-
uint64(100), receiver_puzzlehash, blocks[-1].get_included_reward_coins()[0]
1153-
)
1156+
coin = find_reward_coin(blocks[-1], wallet_ph)
1157+
spend_bundle = wallet_a.generate_signed_transaction(uint64(100), receiver_puzzlehash, coin)
11541158
assert spend_bundle is not None
11551159
respond_transaction = fnp.RespondTransaction(spend_bundle)
11561160
res = await full_node_1.respond_transaction(respond_transaction, peer)
@@ -1192,7 +1196,6 @@ async def test_respond_transaction_fail(
11921196
block_list_input=blocks,
11931197
guarantee_transaction_block=True,
11941198
farmer_reward_puzzle_hash=cb_ph,
1195-
pool_reward_puzzle_hash=cb_ph,
11961199
)
11971200
await asyncio.sleep(1)
11981201
while incoming_queue.qsize() > 0:
@@ -1204,11 +1207,8 @@ async def test_respond_transaction_fail(
12041207

12051208
await time_out_assert(10, time_out_messages(incoming_queue, "new_peak", 3))
12061209
# Invalid transaction does not propagate
1207-
spend_bundle = wallet_a.generate_signed_transaction(
1208-
uint64(100_000_000_000_000),
1209-
receiver_puzzlehash,
1210-
blocks_new[-1].get_included_reward_coins()[0],
1211-
)
1210+
coin = find_reward_coin(blocks_new[-1], cb_ph)
1211+
spend_bundle = wallet_a.generate_signed_transaction(uint64(100_000_000_000_000), receiver_puzzlehash, coin)
12121212

12131213
assert spend_bundle is not None
12141214
respond_transaction = fnp.RespondTransaction(spend_bundle)
@@ -1228,18 +1228,15 @@ async def test_request_block(
12281228
full_node_1, _full_node_2, _server_1, _server_2, wallet_a, wallet_receiver, bt = wallet_nodes
12291229
blocks = await full_node_1.get_all_full_blocks()
12301230

1231+
wallet_ph = wallet_a.get_new_puzzlehash()
12311232
blocks = bt.get_consecutive_blocks(
12321233
3,
12331234
block_list_input=blocks,
12341235
guarantee_transaction_block=True,
1235-
farmer_reward_puzzle_hash=wallet_a.get_new_puzzlehash(),
1236-
pool_reward_puzzle_hash=wallet_a.get_new_puzzlehash(),
1237-
)
1238-
spend_bundle = wallet_a.generate_signed_transaction(
1239-
uint64(1123),
1240-
wallet_receiver.get_new_puzzlehash(),
1241-
blocks[-1].get_included_reward_coins()[0],
1236+
farmer_reward_puzzle_hash=wallet_ph,
12421237
)
1238+
coin = find_reward_coin(blocks[-1], wallet_ph)
1239+
spend_bundle = wallet_a.generate_signed_transaction(uint64(1123), wallet_receiver.get_new_puzzlehash(), coin)
12431240
blocks = bt.get_consecutive_blocks(
12441241
1, block_list_input=blocks, guarantee_transaction_block=True, transaction_data=spend_bundle
12451242
)
@@ -1280,18 +1277,19 @@ async def test_request_blocks(
12801277
blocks = await full_node_1.get_all_full_blocks()
12811278

12821279
# create more blocks than constants.MAX_BLOCK_COUNT_PER_REQUEST (32)
1280+
wallet_ph = wallet_a.get_new_puzzlehash()
12831281
blocks = bt.get_consecutive_blocks(
12841282
33,
12851283
block_list_input=blocks,
12861284
guarantee_transaction_block=True,
1287-
farmer_reward_puzzle_hash=wallet_a.get_new_puzzlehash(),
1288-
pool_reward_puzzle_hash=wallet_a.get_new_puzzlehash(),
1285+
farmer_reward_puzzle_hash=wallet_ph,
12891286
)
12901287

1288+
coin = find_reward_coin(blocks[-1], wallet_ph)
12911289
spend_bundle = wallet_a.generate_signed_transaction(
12921290
uint64(1123),
12931291
wallet_receiver.get_new_puzzlehash(),
1294-
blocks[-1].get_included_reward_coins()[0],
1292+
coin,
12951293
)
12961294
blocks_t = bt.get_consecutive_blocks(
12971295
1, block_list_input=blocks, guarantee_transaction_block=True, transaction_data=spend_bundle
@@ -3325,15 +3323,17 @@ async def test_pending_tx_cache_retry_on_new_peak(
33253323
wallet = WalletTool(test_constants)
33263324
ph = wallet.get_new_puzzlehash()
33273325
blocks = bt.get_consecutive_blocks(
3328-
3, guarantee_transaction_block=True, farmer_reward_puzzle_hash=ph, pool_reward_puzzle_hash=ph
3326+
3,
3327+
guarantee_transaction_block=True,
3328+
farmer_reward_puzzle_hash=ph,
33293329
)
33303330
for block in blocks:
33313331
await full_node_api.full_node.add_block(block)
33323332
peak = full_node_api.full_node.blockchain.get_peak()
33333333
assert peak is not None
33343334
current_height = peak.height
33353335
# Create a transaction with a height condition that makes it pending
3336-
coin = blocks[-1].get_included_reward_coins()[0]
3336+
coin = find_reward_coin(blocks[-1], ph)
33373337
if condition == ConditionOpcode.ASSERT_HEIGHT_RELATIVE:
33383338
condition_height = 1
33393339
else:
@@ -3406,13 +3406,11 @@ async def test_ban_for_mismatched_tx_cost_fee(
34063406
else:
34073407
node = full_node_2.full_node
34083408
ws_con = ws_con_2
3409-
blocks = bt.get_consecutive_blocks(
3410-
3, guarantee_transaction_block=True, farmer_reward_puzzle_hash=wallet_ph, pool_reward_puzzle_hash=wallet_ph
3411-
)
3409+
blocks = bt.get_consecutive_blocks(3, guarantee_transaction_block=True, farmer_reward_puzzle_hash=wallet_ph)
34123410
for block in blocks:
34133411
await node.add_block(block)
34143412
# Create a transaction and add it to the relevant full node's mempool
3415-
coin = blocks[-1].get_included_reward_coins()[0]
3413+
coin = find_reward_coin(blocks[-1], wallet_ph)
34163414
sb = wallet.generate_signed_transaction(uint64(42), wallet_ph, coin)
34173415
sb_name = sb.name()
34183416
await node.add_transaction(sb, sb_name, ws_con)

chia/_tests/core/full_node/test_performance.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ async def test_full_block_performance(
3636
block_list_input=blocks,
3737
guarantee_transaction_block=True,
3838
farmer_reward_puzzle_hash=wallet_ph,
39-
pool_reward_puzzle_hash=wallet_ph,
4039
)
4140
for block in blocks:
4241
await full_node_1.full_node.add_block(block)

0 commit comments

Comments
 (0)