@@ -588,7 +588,7 @@ async def validate_spend_bundle(
588588 Optional[MempoolItem]: the item to add (to mempool or pending pool)
589589 list[bytes32]: conflicting mempool items to remove, if no Err
590590 """
591- start_time = time .time ()
591+ start_time = time .monotonic ()
592592 if self .peak is None :
593593 return Err .MEMPOOL_NOT_INITIALIZED , None , []
594594
@@ -778,14 +778,18 @@ async def validate_spend_bundle(
778778 if not can_replace (conflicts , removal_names , potential ):
779779 return Err .MEMPOOL_CONFLICT , potential , []
780780
781- duration = time .time () - start_time
781+ duration = time .monotonic () - start_time
782782
783783 log .log (
784784 logging .DEBUG if duration < 2 else logging .WARNING ,
785785 f"add_spendbundle { spend_name } took { duration :0.2f} seconds. "
786786 f"Cost: { cost } ({ round (100.0 * cost / self .constants .MAX_BLOCK_COST_CLVM , 3 )} % of max block cost)" ,
787787 )
788788
789+ if duration > 2 :
790+ log .warning ("validating spend took too long, rejecting" )
791+ return Err .INVALID_SPEND_BUNDLE , None , []
792+
789793 return None , potential , [item .name for item in conflicts ]
790794
791795 def get_spendbundle (self , bundle_hash : bytes32 ) -> Optional [SpendBundle ]:
0 commit comments