Skip to content

Commit

Permalink
add a feature to log spend bundles being added to the mempool
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Dec 18, 2024
1 parent ccd6f13 commit 70f576f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions chia/full_node/full_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -2743,6 +2743,15 @@ async def add_transaction(
self.mempool_manager.remove_seen(spend_name)
raise

if self.config.get("log_mempool", False):
try:
mempool_dir = path_from_root(self.root_path, "mempool-log") / f"{self.blockchain.get_peak_height()}"
mempool_dir.mkdir(parents=True, exist_ok=True)
with open(mempool_dir / f"{spend_name}.bundle", "wb+") as f:
f.write(bytes(transaction))
except Exception:
self.log.exception(f"Failed to log mempool item: {spend_name}")

async with self.blockchain.priority_mutex.acquire(priority=BlockchainMutexPriority.low):
if self.mempool_manager.get_spendbundle(spend_name) is not None:
self.mempool_manager.remove_seen(spend_name)
Expand Down
4 changes: 4 additions & 0 deletions chia/util/initial-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,10 @@ full_node:

enable_memory_profiler: False

# this is a debug/auditing facility that saves all spend bundles added to the
# mempool, organized by peak height at the time
log_mempool: false

# this is a debug and profiling facility that logs all SQLite commands to a
# separate log file (under logging/sql.log).
log_sqlite_cmds: False
Expand Down

0 comments on commit 70f576f

Please sign in to comment.