Skip to content

Commit 7a643c6

Browse files
authored
add a time-out of adding more transactions to blocks (#19134)
1 parent ee11750 commit 7a643c6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

chia/full_node/full_node_api.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,10 +878,17 @@ async def declare_proof_of_space(
878878
# when the hard fork activates, block generators are
879879
# allowed to be serialized with the improved CLVM
880880
# serialization format, supporting back-references
881+
start_time = time.monotonic()
881882
if peak.height >= self.full_node.constants.HARD_FORK_HEIGHT:
882883
block_generator = simple_solution_generator_backrefs(spend_bundle)
883884
else:
884885
block_generator = simple_solution_generator(spend_bundle)
886+
end_time = time.monotonic()
887+
duration = end_time - start_time
888+
self.log.log(
889+
logging.INFO if duration < 1 else logging.WARNING,
890+
f"serializing block generator took {duration:0.2f} seconds",
891+
)
885892

886893
def get_plot_sig(to_sign: bytes32, _extra: G1Element) -> G2Element:
887894
if to_sign == request.challenge_chain_sp:

chia/full_node/mempool.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,11 @@ async def create_bundle_from_mempool_items(
501501
name = bytes32(row[0])
502502
fee = int(row[1])
503503
item = self._items[name]
504+
505+
current_time = monotonic()
506+
if current_time - bundle_creation_start > 1:
507+
log.info(f"exiting early, already spent {current_time - bundle_creation_start:0.2f} s")
508+
break
504509
if not item_inclusion_filter(name):
505510
continue
506511
try:

0 commit comments

Comments
 (0)