Skip to content

Commit

Permalink
Adapt to fixing get_conditions_from_spendbundle's return value to inc…
Browse files Browse the repository at this point in the history
…lude the cost of the whole spend.
  • Loading branch information
AmineKhaldi committed Sep 3, 2024
1 parent fb71e79 commit 0d66536
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions chia/_tests/core/full_node/test_full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,8 @@ async def test_new_transaction_and_mempool(self, wallet_nodes, self_hostname, se
# these numbers reflect the capacity of the mempool. In these
# tests MEMPOOL_BLOCK_BUFFER is 1. The other factors are COST_PER_BYTE
# and MAX_BLOCK_COST_CLVM
assert included_tx == 27
assert not_included_tx == 6
assert included_tx == 23
assert not_included_tx == 10
assert seen_bigger_transaction_has_high_fee

# Mempool is full
Expand Down
8 changes: 4 additions & 4 deletions chia/_tests/core/mempool/test_mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ async def test_duplicate_output() -> None:
async def test_block_cost_exceeds_max() -> None:
mempool_manager = await instantiate_mempool_manager(zero_calls_get_coin_records)
conditions = []
for i in range(3800):
for i in range(2400):
conditions.append([ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, i])
sb = spend_bundle_from_conditions(conditions)
with pytest.raises(ValidationError, match="BLOCK_COST_EXCEEDS_MAX"):
Expand Down Expand Up @@ -582,7 +582,7 @@ async def test_same_sb_twice_with_eligible_coin() -> None:
sb = SpendBundle.aggregate([sb1, sb2])
sb_name = sb.name()
result = await add_spendbundle(mempool_manager, sb, sb_name)
expected_cost = uint64(6_600_088)
expected_cost = uint64(10_236_088)
assert result == (expected_cost, MempoolInclusionStatus.SUCCESS, None)
assert mempool_manager.get_spendbundle(sb_name) == sb
result = await add_spendbundle(mempool_manager, sb, sb_name)
Expand Down Expand Up @@ -615,7 +615,7 @@ async def test_sb_twice_with_eligible_coin_and_different_spends_order() -> None:
assert mempool_manager.get_spendbundle(sb_name) is None
assert mempool_manager.get_spendbundle(reordered_sb_name) is None
result = await add_spendbundle(mempool_manager, sb, sb_name)
expected_cost = uint64(7_800_132)
expected_cost = uint64(13_056_132)
assert result == (expected_cost, MempoolInclusionStatus.SUCCESS, None)
assert mempool_manager.get_spendbundle(sb_name) == sb
assert mempool_manager.get_spendbundle(reordered_sb_name) is None
Expand Down Expand Up @@ -1054,7 +1054,7 @@ async def make_and_send_big_cost_sb(coin: Coin) -> None:
g1 = sk.get_g1()
sig = AugSchemeMPL.sign(sk, IDENTITY_PUZZLE_HASH, g1)
aggsig = G2Element()
for _ in range(318):
for _ in range(169):
conditions.append([ConditionOpcode.AGG_SIG_UNSAFE, g1, IDENTITY_PUZZLE_HASH])
aggsig += sig
conditions.append([ConditionOpcode.CREATE_COIN, IDENTITY_PUZZLE_HASH, coin.amount - 10_000_000])
Expand Down
1 change: 1 addition & 0 deletions chia/clvm/spend_sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ async def farm_block(
get_unspent_lineage_info_for_puzzle_hash=self.coin_store.get_unspent_lineage_info_for_puzzle_hash,
item_inclusion_filter=item_inclusion_filter,
)

if result is not None:
bundle, additions = result
generator_bundle = bundle
Expand Down
4 changes: 1 addition & 3 deletions chia/full_node/mempool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ async def pre_validate_spendbundle(
if ret.error is not None:
raise ValidationError(Err(ret.error), "pre_validate_spendbundle failed")
assert ret.conds is not None
# TODO: this cost padding is temporary, until we update the mempool's
# block creation logic to take the block overhead into account
return ret.conds.replace(cost=ret.conds.cost + 10000000)
return ret.conds.replace(cost=ret.conds.cost)

async def add_spend_bundle(
self,
Expand Down

0 comments on commit 0d66536

Please sign in to comment.