Skip to content

Commit 04eef67

Browse files
arvidnaltendky
andauthored
Bump chia rs 0.28 (#19891)
* bump chia_rs to 0.29 * correct return value from get_spends_for_trusted_block() * remove unnecessary casts * adjust test for the new error messages in chia_rs * Update chia/full_node/full_node_rpc_api.py Co-authored-by: Kyle Altendorf <[email protected]> --------- Co-authored-by: Kyle Altendorf <[email protected]>
1 parent 4857c6f commit 04eef67

File tree

12 files changed

+54
-51
lines changed

12 files changed

+54
-51
lines changed

chia/_tests/clvm/coin_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def validate_spend_bundle(self, spend_bundle: SpendBundle, now: CoinTimestamp, m
7373
assert result.conds is not None
7474
for spend in result.conds.spends:
7575
for puzzle_hash, amount, hint in spend.create_coin:
76-
coin = Coin(bytes32(spend.coin_id), bytes32(puzzle_hash), uint64(amount))
76+
coin = Coin(spend.coin_id, puzzle_hash, uint64(amount))
7777
name = coin.name()
7878
ephemeral_db[name] = CoinRecord(
7979
coin,

chia/_tests/core/full_node/test_generator_tools.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
get_spends_for_trusted_block,
99
get_spends_for_trusted_block_with_conditions,
1010
)
11-
from chia_rs.sized_bytes import bytes32
1211
from chia_rs.sized_ints import uint32, uint64
1312

1413
from chia.consensus.generator_tools import tx_removals_and_additions
@@ -86,7 +85,7 @@ def test_tx_removals_and_additions() -> None:
8685
expected_additions = []
8786
for spend in spends:
8887
for puzzle_hash, am, _ in spend.create_coin:
89-
expected_additions.append(Coin(bytes32(spend.coin_id), bytes32(puzzle_hash), uint64(am)))
88+
expected_additions.append(Coin(spend.coin_id, puzzle_hash, uint64(am)))
9089
rems, adds = tx_removals_and_additions(conditions)
9190
assert rems == expected_rems
9291
assert adds == expected_additions
@@ -109,7 +108,7 @@ def test_get_spends_for_block(caplog: pytest.LogCaptureFixture) -> None:
109108
conditions = get_spends_for_trusted_block(
110109
test_constants, TEST_GENERATOR.program, TEST_GENERATOR.generator_refs, 100
111110
)
112-
assert conditions[0]["block_spends"] == []
111+
assert conditions["block_spends"] == []
113112

114113

115114
def test_get_spends_for_block_with_conditions(caplog: pytest.LogCaptureFixture) -> None:

chia/_tests/core/mempool/test_mempool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,9 @@ def add_spend_bundles(spend_bundles: list[SpendBundle]) -> None:
31973197

31983198
def test_get_puzzle_and_solution_for_coin_failure() -> None:
31993199
with pytest.raises(
3200-
ValueError, match=f"Failed to get puzzle and solution for coin {TEST_COIN}, error: \\('coin not found', '80'\\)"
3200+
ValueError,
3201+
match=f"Failed to get puzzle and solution for coin {TEST_COIN}, "
3202+
"error: \\('InvalidOperatorArg: coin not found', '80'\\)",
32013203
):
32023204
try:
32033205
get_puzzle_and_solution_for_coin(

chia/_tests/generator/test_rom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def test_get_name_puzzle_conditions(self, softfork_height: int) -> None:
146146
before_seconds_relative=None,
147147
birth_height=None,
148148
birth_seconds=None,
149-
create_coin=[(bytes([0] * 31 + [1]), 500, None)],
149+
create_coin=[(bytes32([0] * 31 + [1]), 500, None)],
150150
agg_sig_me=[],
151151
agg_sig_parent=[],
152152
agg_sig_puzzle=[],

chia/cmds/show_funcs.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def print_blockchain_state(node_client: FullNodeRpcClient, config: dict[st
3939

4040
if synced:
4141
print("Current Blockchain Status: Full Node Synced")
42-
print("\nPeak: Hash:", bytes32(peak.header_hash) if peak is not None else "")
42+
print("\nPeak: Hash:", peak.header_hash if peak is not None else "")
4343
elif peak is not None and sync_mode:
4444
sync_max_block = blockchain_state["sync"]["sync_tip_height"]
4545
sync_current_block = blockchain_state["sync"]["sync_progress_height"]
@@ -48,7 +48,7 @@ async def print_blockchain_state(node_client: FullNodeRpcClient, config: dict[st
4848
f"({sync_max_block - sync_current_block} behind). "
4949
f"({sync_current_block * 100.0 / sync_max_block:2.2f}% synced)"
5050
)
51-
print("Peak: Hash:", bytes32(peak.header_hash) if peak is not None else "")
51+
print("Peak: Hash:", peak.header_hash if peak is not None else "")
5252
elif peak is not None:
5353
print(f"Current Blockchain Status: Not Synced. Peak height: {peak.height}")
5454
else:
@@ -59,7 +59,7 @@ async def print_blockchain_state(node_client: FullNodeRpcClient, config: dict[st
5959
if peak.is_transaction_block:
6060
peak_time = peak.timestamp
6161
else:
62-
peak_hash = bytes32(peak.header_hash)
62+
peak_hash = peak.header_hash
6363
curr = await node_client.get_block_record(peak_hash)
6464
while curr is not None and not curr.is_transaction_block:
6565
curr = await node_client.get_block_record(curr.prev_hash)
@@ -88,7 +88,7 @@ async def print_blockchain_state(node_client: FullNodeRpcClient, config: dict[st
8888
curr = await node_client.get_block_record(curr.prev_hash)
8989

9090
for b in added_blocks:
91-
print(f"{b.height:>9} | {bytes32(b.header_hash)}")
91+
print(f"{b.height:>9} | {b.header_hash}")
9292
else:
9393
print("Blockchain has no blocks yet")
9494
return False
@@ -125,7 +125,7 @@ async def print_block_from_hash(
125125
cost = str(full_block.transactions_info.cost)
126126
tx_filter_hash: Union[str, bytes32] = "Not a transaction block"
127127
if full_block.foliage_transaction_block:
128-
tx_filter_hash = bytes32(full_block.foliage_transaction_block.filter_hash)
128+
tx_filter_hash = full_block.foliage_transaction_block.filter_hash
129129
fees: Any = block.fees
130130
else:
131131
block_time_string = "Not a transaction block"

chia/consensus/block_body_validation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ def include_spends(self, conds: Optional[SpendBundleConditions], block: FullBloc
116116
timestamp = block.foliage_transaction_block.timestamp
117117
for spend in conds.spends:
118118
spend_coin_id = bytes32(spend.coin_id)
119-
self.removals_since_fork[spend_coin_id] = ForkRem(bytes32(spend.puzzle_hash), block.height)
119+
self.removals_since_fork[spend_coin_id] = ForkRem(spend.puzzle_hash, block.height)
120120
for puzzle_hash, amount, hint in spend.create_coin:
121-
coin = Coin(spend_coin_id, bytes32(puzzle_hash), uint64(amount))
121+
coin = Coin(spend_coin_id, puzzle_hash, uint64(amount))
122122
same_as_parent = coin.puzzle_hash == spend.puzzle_hash and amount == spend.coin_amount
123123
self.additions_since_fork[coin.name()] = ForkAdd(
124124
coin, block.height, timestamp, hint=hint, is_coinbase=False, same_as_parent=same_as_parent
@@ -137,8 +137,8 @@ def include_block(
137137
timestamp = block.foliage_transaction_block.timestamp
138138
spent_coins: dict[bytes32, Coin] = {}
139139
for spend_id, spend in removals:
140-
spent_coins[bytes32(spend_id)] = spend
141-
self.removals_since_fork[bytes32(spend_id)] = ForkRem(bytes32(spend.puzzle_hash), block.height)
140+
spent_coins[spend_id] = spend
141+
self.removals_since_fork[spend_id] = ForkRem(spend.puzzle_hash, block.height)
142142
for coin, hint in additions:
143143
parent = spent_coins.get(coin.parent_coin_info)
144144
assert parent is not None
@@ -382,9 +382,9 @@ async def validate_block_body(
382382

383383
for spend in conds.spends:
384384
removals.append(bytes32(spend.coin_id))
385-
removals_puzzle_dic[bytes32(spend.coin_id)] = bytes32(spend.puzzle_hash)
385+
removals_puzzle_dic[spend.coin_id] = spend.puzzle_hash
386386
for puzzle_hash, amount, _ in spend.create_coin:
387-
c = Coin(bytes32(spend.coin_id), bytes32(puzzle_hash), uint64(amount))
387+
c = Coin(spend.coin_id, puzzle_hash, uint64(amount))
388388
additions.append((c, c.name()))
389389
else:
390390
assert conds is None

chia/consensus/generator_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ def tx_removals_and_additions(results: Optional[SpendBundleConditions]) -> tuple
6565
for spend in results.spends:
6666
removals.append(bytes32(spend.coin_id))
6767
for puzzle_hash, amount, _ in spend.create_coin:
68-
additions.append(Coin(bytes32(spend.coin_id), bytes32(puzzle_hash), uint64(amount)))
68+
additions.append(Coin(spend.coin_id, puzzle_hash, uint64(amount)))
6969

7070
return removals, additions

chia/full_node/full_node_rpc_api.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,9 @@ async def get_block_spends(self, request: dict[str, Any]) -> EndpointResult:
481481
if full_block is None:
482482
raise ValueError(f"Block {header_hash.hex()} not found")
483483

484-
spends: list[dict[str, list[CoinSpend]]] = []
485484
block_generator = await get_block_generator(self.service.blockchain.lookup_block_generators, full_block)
486485
if block_generator is None: # if block is not a transaction block.
487-
return {"block_spends": spends}
486+
return {"block_spends": []}
488487

489488
spends = get_spends_for_trusted_block(
490489
self.service.constants,
@@ -493,9 +492,7 @@ async def get_block_spends(self, request: dict[str, Any]) -> EndpointResult:
493492
get_flags_for_height_and_constants(full_block.height, self.service.constants),
494493
)
495494

496-
# chia_rs returning a list is a mistake that will be fixed in the next release
497-
# it ought to be returning a dict of {"block_spends": [spends]}
498-
return spends[0]
495+
return spends
499496

500497
async def get_block_spends_with_conditions(self, request: dict[str, Any]) -> EndpointResult:
501498
if "header_hash" not in request:

chia/full_node/mempool_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ async def validate_spend_bundle(
609609
# Make sure the fast forward spend still has a version that is
610610
# still unspent, because if the singleton has been melted, the
611611
# fast forward spend will never become valid.
612-
lineage_info = await get_unspent_lineage_info_for_puzzle_hash(bytes32(spend_conds.puzzle_hash))
612+
lineage_info = await get_unspent_lineage_info_for_puzzle_hash(spend_conds.puzzle_hash)
613613
if lineage_info is None:
614614
return Err.DOUBLE_SPEND, None, []
615615

chia/full_node/subscriptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,11 @@ def peers_for_spend_bundle(
225225

226226
for spend in conds.spends:
227227
coin_ids.add(bytes32(spend.coin_id))
228-
puzzle_hashes.add(bytes32(spend.puzzle_hash))
228+
puzzle_hashes.add(spend.puzzle_hash)
229229

230230
for puzzle_hash, amount, memo in spend.create_coin:
231231
coin_ids.add(Coin(spend.coin_id, puzzle_hash, uint64(amount)).name())
232-
puzzle_hashes.add(bytes32(puzzle_hash))
232+
puzzle_hashes.add(puzzle_hash)
233233

234234
if memo is not None and len(memo) == 32:
235235
puzzle_hashes.add(bytes32(memo))

0 commit comments

Comments
 (0)