diff --git a/chia/_tests/clvm/coin_store.py b/chia/_tests/clvm/coin_store.py index a9d52407d538..b599a52f3850 100644 --- a/chia/_tests/clvm/coin_store.py +++ b/chia/_tests/clvm/coin_store.py @@ -112,13 +112,8 @@ def update_coin_store_for_spend_bundle( self._add_coin_entry(new_coin, now) for spent_coin in removals: coin_name = spent_coin.name() - self._db[coin_name] = CoinRecord( - self._db[coin_name].coin, - self._db[coin_name].confirmed_block_index, - now.height, - self._db[coin_name].coinbase, - self._db[coin_name].timestamp, - ) + coin_record = self._db[coin_name] + self._db[coin_name] = coin_record.replace(spent_block_index=now.height) return additions, spend_bundle.coin_spends def coins_for_puzzle_hash(self, puzzle_hash: bytes32) -> Iterator[Coin]: diff --git a/chia/_tests/core/mempool/test_mempool_manager.py b/chia/_tests/core/mempool/test_mempool_manager.py index 543fc6698353..ff531fdfbb71 100644 --- a/chia/_tests/core/mempool/test_mempool_manager.py +++ b/chia/_tests/core/mempool/test_mempool_manager.py @@ -431,16 +431,17 @@ def test_conditions( conds: SpendBundleConditions, expected: Optional[Err], ) -> None: - res: Optional[Union[int, Err]] = check_time_locks( + res: Optional[int] = check_time_locks( dict(self.REMOVALS), conds, self.PREV_BLOCK_HEIGHT, self.PREV_BLOCK_TIMESTAMP, ) + e: Optional[Err] = None if res is not None: # TODO: remove when Rust errors and Python Errors are the same - res = Err(res) - assert res == expected + e = Err(res) + assert e == expected def expect( @@ -2340,13 +2341,7 @@ def __init__(self, coins: list[Coin], lineage: dict[bytes32, Coin]) -> None: self.lineage_info[ph] = UnspentLineageInfo(c.name(), c.parent_coin_info, bytes32([42] * 32)) def spend_coin(self, coin_id: bytes32, height: uint32 = uint32(10)) -> None: - self.coin_records[coin_id] = CoinRecord( - self.coin_records[coin_id].coin, - self.coin_records[coin_id].confirmed_block_index, - height, - self.coin_records[coin_id].coinbase, - self.coin_records[coin_id].timestamp, - ) + self.coin_records[coin_id] = self.coin_records[coin_id].replace(spent_block_index=height) def update_lineage(self, puzzle_hash: bytes32, coin: Optional[Coin]) -> None: if coin is None: diff --git a/chia/full_node/mempool_manager.py b/chia/full_node/mempool_manager.py index 67c35d204d44..5210dcf6f694 100644 --- a/chia/full_node/mempool_manager.py +++ b/chia/full_node/mempool_manager.py @@ -6,7 +6,7 @@ from collections.abc import Awaitable, Collection from concurrent.futures import Executor, ThreadPoolExecutor from dataclasses import dataclass, field -from typing import Callable, Optional, TypeVar, Union +from typing import Callable, Optional, TypeVar from chia_rs import ( ELIGIBLE_FOR_DEDUP, @@ -734,14 +734,15 @@ async def validate_spend_bundle( # point-of-view of the next block to be farmed. Therefore we pass in the # current peak's height and timestamp assert self.peak.timestamp is not None - tl_error: Optional[Union[int, Err]] = check_time_locks( + tl_error_rust: Optional[int] = check_time_locks( removal_record_dict, conds, self.peak.height, self.peak.timestamp, ) - if tl_error is not None: - tl_error = Err(tl_error) + tl_error: Optional[Err] = None + if tl_error_rust is not None: + tl_error = Err(tl_error_rust) timelocks: TimelockConditions = compute_assert_height(removal_record_dict, conds)