Skip to content

Commit 3901126

Browse files
authored
amendment to Dedup patch #19565 (#19569)
1 parent a36d994 commit 3901126

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

chia/_tests/core/mempool/test_mempool_manager.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ def mk_coin_spend(coin: Coin, solution: Optional[str] = None) -> CoinSpend:
834834
return make_spend(
835835
coin,
836836
SerializedProgram.to(None),
837-
SerializedProgram.to(bytes.fromhex(solution) if solution is not None else None),
837+
SerializedProgram.fromhex(solution if solution is not None else "80"),
838838
)
839839

840840

@@ -2641,14 +2641,15 @@ async def test_check_removals_with_block_creation(flags: int) -> None:
26412641

26422642
@pytest.mark.anyio
26432643
async def test_dedup_not_canonical() -> None:
2644-
# this is 1, but with a non-canonical encoding
2645-
coin_spend = mk_coin_spend(TEST_COIN, solution="c00101")
2646-
coins = TestCoins(coins=[], lineage={})
2644+
# this is ((1)), but with a non-canonical encoding
2645+
coin_spend = mk_coin_spend(TEST_COIN, solution="ffffc001018080")
2646+
coins = TestCoins([TEST_COIN], lineage={})
26472647
mempool_manager = await setup_mempool(coins)
26482648
sb = SpendBundle([coin_spend], G2Element())
26492649
sb_conds = make_test_conds(spend_ids=[(TEST_COIN, ELIGIBLE_FOR_DEDUP)])
26502650
bundle_add_info = await mempool_manager.add_spend_bundle(sb, sb_conds, sb.name(), uint32(1))
26512651
assert bundle_add_info.status == MempoolInclusionStatus.FAILED
2652+
assert bundle_add_info.error == Err.INVALID_COIN_SOLUTION
26522653

26532654

26542655
def make_coin_record(coin: Coin, spent_block_index: int = 0) -> CoinRecord:

chia/full_node/mempool_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,10 @@ async def validate_spend_bundle(
625625
EligibilityAndAdditions(is_eligible_for_dedup=False, spend_additions=[], ff_puzzle_hash=None),
626626
)
627627

628-
supports_dedup = eligibility_info.is_eligible_for_dedup and is_clvm_canonical(bytes(coin_spend.solution))
628+
supports_dedup = eligibility_info.is_eligible_for_dedup
629+
if supports_dedup and not is_clvm_canonical(bytes(coin_spend.solution)):
630+
return Err.INVALID_COIN_SOLUTION, None, []
631+
629632
mark_as_fast_forward = eligibility_info.ff_puzzle_hash is not None and supports_fast_forward(coin_spend)
630633
latest_singleton_coin = None
631634
if mark_as_fast_forward:

0 commit comments

Comments
 (0)