Skip to content

Commit b0242ee

Browse files
committed
Merge commit '27bfa7e2a31af5736c84ecadf7954adc18eb086c' into checkpoint/main_from_release_2.5.4_27bfa7e2a31af5736c84ecadf7954adc18eb086c
2 parents f1885d6 + 27bfa7e commit b0242ee

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

chia/full_node/mempool_manager.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ async def validate_spend_bundle(
575575
Optional[MempoolItem]: the item to add (to mempool or pending pool)
576576
list[bytes32]: conflicting mempool items to remove, if no Err
577577
"""
578-
start_time = time.time()
578+
start_time = time.monotonic()
579579
if self.peak is None:
580580
return Err.MEMPOOL_NOT_INITIALIZED, None, []
581581

@@ -764,14 +764,18 @@ async def validate_spend_bundle(
764764
if not can_replace(conflicts, removal_names, potential):
765765
return Err.MEMPOOL_CONFLICT, potential, []
766766

767-
duration = time.time() - start_time
767+
duration = time.monotonic() - start_time
768768

769769
log.log(
770770
logging.DEBUG if duration < 2 else logging.WARNING,
771771
f"add_spendbundle {spend_name} took {duration:0.2f} seconds. "
772772
f"Cost: {cost} ({round(100.0 * cost / self.constants.MAX_BLOCK_COST_CLVM, 3)}% of max block cost)",
773773
)
774774

775+
if duration > 2:
776+
log.warning("validating spend took too long, rejecting")
777+
return Err.INVALID_SPEND_BUNDLE, None, []
778+
775779
return None, potential, [item.name for item in conflicts]
776780

777781
def get_spendbundle(self, bundle_hash: bytes32) -> Optional[SpendBundle]:

0 commit comments

Comments
 (0)