@@ -588,7 +588,7 @@ async def validate_spend_bundle(
588
588
Optional[MempoolItem]: the item to add (to mempool or pending pool)
589
589
list[bytes32]: conflicting mempool items to remove, if no Err
590
590
"""
591
- start_time = time .time ()
591
+ start_time = time .monotonic ()
592
592
if self .peak is None :
593
593
return Err .MEMPOOL_NOT_INITIALIZED , None , []
594
594
@@ -778,14 +778,18 @@ async def validate_spend_bundle(
778
778
if not can_replace (conflicts , removal_names , potential ):
779
779
return Err .MEMPOOL_CONFLICT , potential , []
780
780
781
- duration = time .time () - start_time
781
+ duration = time .monotonic () - start_time
782
782
783
783
log .log (
784
784
logging .DEBUG if duration < 2 else logging .WARNING ,
785
785
f"add_spendbundle { spend_name } took { duration :0.2f} seconds. "
786
786
f"Cost: { cost } ({ round (100.0 * cost / self .constants .MAX_BLOCK_COST_CLVM , 3 )} % of max block cost)" ,
787
787
)
788
788
789
+ if duration > 2 :
790
+ log .warning ("validating spend took too long, rejecting" )
791
+ return Err .INVALID_SPEND_BUNDLE , None , []
792
+
789
793
return None , potential , [item .name for item in conflicts ]
790
794
791
795
def get_spendbundle (self , bundle_hash : bytes32 ) -> Optional [SpendBundle ]:
0 commit comments