@@ -575,7 +575,7 @@ async def validate_spend_bundle(
575
575
Optional[MempoolItem]: the item to add (to mempool or pending pool)
576
576
list[bytes32]: conflicting mempool items to remove, if no Err
577
577
"""
578
- start_time = time .time ()
578
+ start_time = time .monotonic ()
579
579
if self .peak is None :
580
580
return Err .MEMPOOL_NOT_INITIALIZED , None , []
581
581
@@ -764,14 +764,18 @@ async def validate_spend_bundle(
764
764
if not can_replace (conflicts , removal_names , potential ):
765
765
return Err .MEMPOOL_CONFLICT , potential , []
766
766
767
- duration = time .time () - start_time
767
+ duration = time .monotonic () - start_time
768
768
769
769
log .log (
770
770
logging .DEBUG if duration < 2 else logging .WARNING ,
771
771
f"add_spendbundle { spend_name } took { duration :0.2f} seconds. "
772
772
f"Cost: { cost } ({ round (100.0 * cost / self .constants .MAX_BLOCK_COST_CLVM , 3 )} % of max block cost)" ,
773
773
)
774
774
775
+ if duration > 2 :
776
+ log .warning ("validating spend took too long, rejecting" )
777
+ return Err .INVALID_SPEND_BUNDLE , None , []
778
+
775
779
return None , potential , [item .name for item in conflicts ]
776
780
777
781
def get_spendbundle (self , bundle_hash : bytes32 ) -> Optional [SpendBundle ]:
0 commit comments