Skip to content

Commit f2d9281

Browse files
arvidnAmineKhaldi
andauthored
remove unnecessary NPCResult in mempool_manager (#20022)
* remove unnecessary NPCResult in mempool_manager * review comment * Update chia/full_node/mempool_manager.py Co-authored-by: Amine Khaldi <[email protected]> --------- Co-authored-by: Amine Khaldi <[email protected]>
1 parent 31cb704 commit f2d9281

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

chia/full_node/mempool_manager.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
from chia.consensus.block_record import BlockRecordProtocol
2828
from chia.consensus.check_time_locks import check_time_locks
29-
from chia.consensus.cost_calculator import NPCResult
3029
from chia.full_node.bitcoin_fee_estimator import create_bitcoin_fee_estimator
3130
from chia.full_node.fee_estimation import FeeBlockInfo, MempoolInfo, MempoolItemInfo
3231
from chia.full_node.fee_estimator_interface import FeeEstimatorInterface
@@ -480,8 +479,6 @@ async def pre_validate_spendbundle(
480479
if bls_cache is not None:
481480
bls_cache.update(new_cache_entries)
482481

483-
ret = NPCResult(None, sbc)
484-
485482
if spend_bundle_id is None:
486483
spend_bundle_id = spend_bundle.name()
487484

@@ -490,10 +487,7 @@ async def pre_validate_spendbundle(
490487
f"pre_validate_spendbundle took {duration:0.4f} seconds "
491488
f"for {spend_bundle_id} (queue-size: {self._worker_queue_size})",
492489
)
493-
if ret.error is not None:
494-
raise ValidationError(Err(ret.error), "pre_validate_spendbundle failed")
495-
assert ret.conds is not None
496-
return ret.conds
490+
return sbc
497491

498492
async def add_spend_bundle(
499493
self,
@@ -507,14 +501,16 @@ async def add_spend_bundle(
507501
] = None,
508502
) -> SpendBundleAddInfo:
509503
"""
510-
Validates and adds to mempool a new_spend with the given NPCResult, and spend_name, and the current mempool.
511-
The mempool should be locked during this call (blockchain lock). If there are mempool conflicts, the conflicting
512-
spends might be removed (if the new spend is a superset of the previous). Otherwise, the new spend might be
504+
Validates and adds to mempool a new_spend with the given
505+
SpendBundleConditions, and spend_name, and the current mempool. The mempool
506+
should be locked during this call (blockchain lock). If there are mempool
507+
conflicts, the conflicting spends might be removed (if the new spend is
508+
a superset of the previous). Otherwise, the new spend might be
513509
added to the potential pool.
514510
515511
Args:
516512
new_spend: spend bundle to validate and add
517-
conds: result of running the clvm transaction in a fake block
513+
conds: SpendBundleConditions resulting from running the clvm in the spend bundle's coin spends
518514
spend_name: hash of the spend bundle data, passed in as an optimization
519515
520516
Returns:

chia/types/internal_mempool_item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ class InternalMempoolItem:
1414
spend_bundle: SpendBundle
1515
conds: SpendBundleConditions
1616
height_added_to_mempool: uint32
17-
# Map of coin ID to coin spend data between the bundle and its NPCResult
17+
# Map of coin ID to coin spend data between the bundle and its SpendBundleConditions
1818
bundle_coin_spends: dict[bytes32, BundleCoinSpend]

0 commit comments

Comments
 (0)