diff --git a/chia-blockchain-gui b/chia-blockchain-gui index 4969c3b9186c..4a2a72504a3a 160000 --- a/chia-blockchain-gui +++ b/chia-blockchain-gui @@ -1 +1 @@ -Subproject commit 4969c3b9186cf1db87a79ad0486b51327f8375dc +Subproject commit 4a2a72504a3a4efe73c7aa037bffd4fa41cdf5e3 diff --git a/chia/_tests/core/mempool/test_singleton_fast_forward.py b/chia/_tests/core/mempool/test_singleton_fast_forward.py index f96e31bf44fe..be56a39a1a34 100644 --- a/chia/_tests/core/mempool/test_singleton_fast_forward.py +++ b/chia/_tests/core/mempool/test_singleton_fast_forward.py @@ -663,4 +663,4 @@ async def test_double_spend_ff_spend_no_latest_unspent() -> None: status, error = await make_and_send_spend_bundle(sim, sim_client, [singleton_coin_spend], aggsig=sig) # It fails validation because it doesn't currently have a latest unspent assert status == MempoolInclusionStatus.FAILED - assert error == Err.DOUBLE_SPEND + assert error == Err.UNKNOWN_UNSPENT diff --git a/chia/full_node/coin_store.py b/chia/full_node/coin_store.py index f2da3b66f644..f372be2756b1 100644 --- a/chia/full_node/coin_store.py +++ b/chia/full_node/coin_store.py @@ -30,6 +30,9 @@ class CoinStore: """ db_wrapper: DBWrapper2 + # Fall back to the `coin_puzzle_hash` index if the ff unspent index + # does not exist. + _unspent_lineage_for_ph_idx: str = "coin_puzzle_hash" @classmethod async def create(cls, db_wrapper: DBWrapper2) -> CoinStore: @@ -82,6 +85,12 @@ async def create(cls, db_wrapper: DBWrapper2) -> CoinStore: WHERE spent_index = -1 """ ) + async with conn.execute( + "SELECT 1 FROM sqlite_master WHERE type = 'index' AND name = 'coin_record_ph_ff_unspent_idx'" + ) as cursor: + has_ff_unspent_idx = await cursor.fetchone() is not None + if has_ff_unspent_idx: + self._unspent_lineage_for_ph_idx = "coin_record_ph_ff_unspent_idx" return self @@ -639,6 +648,7 @@ async def get_unspent_lineage_info_for_puzzle_hash(self, puzzle_hash: bytes32) - "unspent.coin_parent, " "parent.coin_parent " "FROM coin_record AS unspent " + f"INDEXED BY {self._unspent_lineage_for_ph_idx} " "LEFT JOIN coin_record AS parent ON unspent.coin_parent = parent.coin_name " "WHERE unspent.spent_index = -1 " "AND parent.spent_index > 0 " diff --git a/chia/full_node/mempool_manager.py b/chia/full_node/mempool_manager.py index 3ce59c942cb2..6908fb088e40 100644 --- a/chia/full_node/mempool_manager.py +++ b/chia/full_node/mempool_manager.py @@ -640,7 +640,7 @@ async def validate_spend_bundle( assert eligibility_info.ff_puzzle_hash is not None lineage_info = await get_unspent_lineage_info_for_puzzle_hash(eligibility_info.ff_puzzle_hash) if lineage_info is None: - return Err.DOUBLE_SPEND, None, [] + mark_as_fast_forward = False bundle_coin_spends[coin_id] = BundleCoinSpend( coin_spend=coin_spend, eligible_for_dedup=supports_dedup,