Skip to content

Commit de15642

Browse files
Starttoasterarvidn
andauthored
checkpoint: into main from release/2.5.4 @ 3901126 (#19660)
amendment to Dedup patch #19565 (#19569) Co-authored-by: Arvid Norberg <[email protected]>
2 parents b497690 + ce8a4c3 commit de15642

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
@@ -878,7 +878,7 @@ def mk_coin_spend(coin: Coin, solution: Optional[str] = None) -> CoinSpend:
878878
return make_spend(
879879
coin,
880880
SerializedProgram.to(None),
881-
SerializedProgram.to(bytes.fromhex(solution) if solution is not None else None),
881+
SerializedProgram.fromhex(solution if solution is not None else "80"),
882882
)
883883

884884

@@ -2991,14 +2991,15 @@ async def test_check_removals_with_block_creation(flags: int, old: bool) -> None
29912991

29922992
@pytest.mark.anyio
29932993
async def test_dedup_not_canonical() -> None:
2994-
# this is 1, but with a non-canonical encoding
2995-
coin_spend = mk_coin_spend(TEST_COIN, solution="c00101")
2996-
coins = TestCoins(coins=[], lineage={})
2994+
# this is ((1)), but with a non-canonical encoding
2995+
coin_spend = mk_coin_spend(TEST_COIN, solution="ffffc001018080")
2996+
coins = TestCoins([TEST_COIN], lineage={})
29972997
mempool_manager = await setup_mempool(coins)
29982998
sb = SpendBundle([coin_spend], G2Element())
29992999
sb_conds = make_test_conds(spend_ids=[(TEST_COIN, ELIGIBLE_FOR_DEDUP)])
30003000
bundle_add_info = await mempool_manager.add_spend_bundle(sb, sb_conds, sb.name(), uint32(1))
30013001
assert bundle_add_info.status == MempoolInclusionStatus.FAILED
3002+
assert bundle_add_info.error == Err.INVALID_COIN_SOLUTION
30023003

30033004

30043005
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
@@ -612,7 +612,10 @@ async def validate_spend_bundle(
612612
EligibilityAndAdditions(is_eligible_for_dedup=False, spend_additions=[], ff_puzzle_hash=None),
613613
)
614614

615-
supports_dedup = eligibility_info.is_eligible_for_dedup and is_clvm_canonical(bytes(coin_spend.solution))
615+
supports_dedup = eligibility_info.is_eligible_for_dedup
616+
if supports_dedup and not is_clvm_canonical(bytes(coin_spend.solution)):
617+
return Err.INVALID_COIN_SOLUTION, None, []
618+
616619
mark_as_fast_forward = eligibility_info.ff_puzzle_hash is not None and supports_fast_forward(coin_spend)
617620
lineage_info = None
618621
if mark_as_fast_forward:

0 commit comments

Comments
 (0)