upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbitflash-maintainer <noreply@bitflash.invalid>2026-09-02 05:31:22 +0000
committerbitflash-maintainer <noreply@bitflash.invalid>2026-09-02 05:31:22 +0000
commit2661de141e46dadfb2903bb12e72dc87c5a64375 (patch)
tree73f5492187a1da4b362463834983ad767f105306
parentae1c6a7b49d9b4f8cf7218c0baec84f348eb5ef6 (diff)
log: demote the four lines that were 90% of debug.log behind /debugrelay
A 13-hour production capture was ~71% "sending: tx", ~16% "Nostr: discovered .btf peer", ~5% "Relaying wtx", and ~43% of raw lines were CBlock/CTransaction dumps -- all already under -debug, which operators run permanently, so -debug was useless as a filter. The category mechanism gains a verbose tier: "relay" and "nostrdiscovery" are accepted only with the new /debugrelay flag (which implies /debug); everything else keeps its current gate. Demoted, with message text unchanged for anyone grepping it: net.h "sending: tx (N bytes)" (BeginMessage/EndMessage/ AbortMessage all pick the category from the command, so no orphaned "(N bytes)" fragments leak into a plain -debug log) main.cpp "Relaying wtx", "received block:" + CBlock::print, and the BitcoinMiner block dump nostr.cpp "Nostr: discovered .btf peer" -> "nostrdiscovery" Pool/worker/payout, [payout], BLOCK ORPHANED/ACCEPTED and share flow lines are untouched. Because LogPrint dedup keys on category, demoted lines also keep their burst collapse under /debugrelay. Closes #35
-rw-r--r--src/main.cpp6
-rw-r--r--src/main_gui.cpp12
-rw-r--r--src/net.h22
-rw-r--r--src/nostr.cpp2
-rw-r--r--src/util.cpp13
-rw-r--r--src/util.h4
6 files changed, 51 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7b3e555..80f5f31 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1712,7 +1712,7 @@ void CWalletTx::RelayWalletTransaction(CTxDB& txdb)
1712 uint256 hash = GetHash(); 1712 uint256 hash = GetHash();
1713 if (!txdb.ContainsTx(hash)) 1713 if (!txdb.ContainsTx(hash))
1714 { 1714 {
1715 if (LogAcceptsCategory("net")) printf("Relaying wtx %s\n", hash.ToString().substr(0,6).c_str()); 1715 if (LogAcceptsCategory("relay")) printf("Relaying wtx %s\n", hash.ToString().substr(0,6).c_str());
1716 RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this); 1716 RelayMessage(CInv(MSG_TX, hash), (CTransaction)*this);
1717 } 1717 }
1718 } 1718 }
@@ -3263,7 +3263,7 @@ bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
3263 vRecv >> *pblock; 3263 vRecv >> *pblock;
3264 3264
3265 //// debug print 3265 //// debug print
3266 if (LogAcceptsCategory("net")) { printf("received block:\n"); pblock->print(); } 3266 if (LogAcceptsCategory("relay")) { printf("received block:\n"); pblock->print(); }
3267 3267
3268 CInv inv(MSG_BLOCK, pblock->GetHash()); 3268 CInv inv(MSG_BLOCK, pblock->GetHash());
3269 pfrom->AddInventoryKnown(inv); 3269 pfrom->AddInventoryKnown(inv);
@@ -4555,7 +4555,7 @@ bool BitcoinMiner(int nThreadId)
4555 //// debug print 4555 //// debug print
4556 if (LogAcceptsCategory("net")) printf("BitcoinMiner:\n"); 4556 if (LogAcceptsCategory("net")) printf("BitcoinMiner:\n");
4557 if (LogAcceptsCategory("net")) printf("RandomX proof-of-work found \n powhash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str()); 4557 if (LogAcceptsCategory("net")) printf("RandomX proof-of-work found \n powhash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
4558 if (LogAcceptsCategory("net")) pblock->print(); 4558 if (LogAcceptsCategory("relay")) pblock->print();
4559 4559
4560 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL); 4560 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL);
4561 CRITICAL_BLOCK(cs_main) 4561 CRITICAL_BLOCK(cs_main)
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index 05f5ecf..163d78e 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -111,6 +111,7 @@ static void PrintUsage()
111 printf(" /help, -help, --help, /?\n"); 111 printf(" /help, -help, --help, /?\n");
112 printf(" /datadir=PATH\n"); 112 printf(" /datadir=PATH\n");
113 printf(" /debug\n"); 113 printf(" /debug\n");
114 printf(" /debugrelay (/debug plus per-message relay chatter and block dumps)\n");
114 printf(" /maxdebugfilesize=N (roll debug.log at N MB, default 1024; 0 = never)\n"); 115 printf(" /maxdebugfilesize=N (roll debug.log at N MB, default 1024; 0 = never)\n");
115 printf(" /gen\n"); 116 printf(" /gen\n");
116 printf(" /nogui or /daemon\n"); 117 printf(" /nogui or /daemon\n");
@@ -192,6 +193,17 @@ static void ParseStartupArguments(int argc, char* argv[])
192 if (arg(argc,argv,"/debug") || arg(argc,argv,"-debug")) 193 if (arg(argc,argv,"/debug") || arg(argc,argv,"-debug"))
193 fDebug = true; 194 fDebug = true;
194 195
196 // /debugrelay -- everything /debug shows, plus the per-message firehose
197 // ("relay" and "nostrdiscovery" categories: sending: tx, Relaying wtx,
198 // raw CBlock dumps, per-peer discovery lines). That traffic was ~90% of
199 // a 13-hour production debug.log (issue #35), so plain /debug leaves it
200 // off; the message text itself is unchanged for anyone grepping it.
201 if (arg(argc,argv,"/debugrelay") || arg(argc,argv,"-debugrelay"))
202 {
203 fDebug = true;
204 fDebugRelay = true;
205 }
206
195 // /maxdebugfilesize=N -- roll debug.log to debug.log.old once it passes 207 // /maxdebugfilesize=N -- roll debug.log to debug.log.old once it passes
196 // N MB, checked on each write. Default is 1024 (see util.cpp); 0 turns 208 // N MB, checked on each write. Default is 1024 (see util.cpp); 0 turns
197 // the check off and leaves rotation entirely to logrotate. 209 // the check off and leaves rotation entirely to logrotate.
diff --git a/src/net.h b/src/net.h
index 9f3c7e4..1aee973 100644
--- a/src/net.h
+++ b/src/net.h
@@ -802,6 +802,18 @@ public:
802 802
803 803
804 804
805 // "sending: tx (N bytes)" alone was ~71% of a 13-hour production
806 // debug.log (issue #35), so tx sends are demoted to the /debugrelay-gated
807 // "relay" category; every other command's send trace stays on "net".
808 // The line is emitted in pieces across BeginMessage/EndMessage/
809 // AbortMessage, so all three must agree on the category or orphaned
810 // "(N bytes)" fragments would leak into a plain -debug log.
811 // Valid only mid-message (nPushPos != -1).
812 const char* SendLogCategory() const
813 {
814 return strcmp(GetMessageCommand(), "tx") == 0 ? "relay" : "net";
815 }
816
805 void BeginMessage(const char* pszCommand) 817 void BeginMessage(const char* pszCommand)
806 { 818 {
807 EnterCriticalSection(&cs_vSend); 819 EnterCriticalSection(&cs_vSend);
@@ -809,17 +821,19 @@ public:
809 AbortMessage(); 821 AbortMessage();
810 nPushPos = vSend.size(); 822 nPushPos = vSend.size();
811 vSend << CMessageHeader(pszCommand, 0); 823 vSend << CMessageHeader(pszCommand, 0);
812 if (LogAcceptsCategory("net")) printf("sending: %-12s ", pszCommand); 824 if (LogAcceptsCategory(SendLogCategory())) printf("sending: %-12s ", pszCommand);
813 } 825 }
814 826
815 void AbortMessage() 827 void AbortMessage()
816 { 828 {
817 if (nPushPos == -1) 829 if (nPushPos == -1)
818 return; 830 return;
831 // Capture before nPushPos is cleared; GetMessageCommand() needs it.
832 const char* pszCategory = SendLogCategory();
819 vSend.resize(nPushPos); 833 vSend.resize(nPushPos);
820 nPushPos = -1; 834 nPushPos = -1;
821 LeaveCriticalSection(&cs_vSend); 835 LeaveCriticalSection(&cs_vSend);
822 if (LogAcceptsCategory("net")) printf("(aborted)\n"); 836 if (LogAcceptsCategory(pszCategory)) printf("(aborted)\n");
823 } 837 }
824 838
825 void EndMessage() 839 void EndMessage()
@@ -839,10 +853,10 @@ public:
839 unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader); 853 unsigned int nSize = vSend.size() - nPushPos - sizeof(CMessageHeader);
840 memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize)); 854 memcpy((char*)&vSend[nPushPos] + offsetof(CMessageHeader, nMessageSize), &nSize, sizeof(nSize));
841 855
842 if (LogAcceptsCategory("net")) printf("(%d bytes) ", nSize); 856 if (LogAcceptsCategory(SendLogCategory())) printf("(%d bytes) ", nSize);
843 //for (int i = nPushPos+sizeof(CMessageHeader); i < min(vSend.size(), nPushPos+sizeof(CMessageHeader)+20U); i++) 857 //for (int i = nPushPos+sizeof(CMessageHeader); i < min(vSend.size(), nPushPos+sizeof(CMessageHeader)+20U); i++)
844 // printf("%02x ", vSend[i] & 0xff); 858 // printf("%02x ", vSend[i] & 0xff);
845 if (LogAcceptsCategory("net")) printf("\n"); 859 if (LogAcceptsCategory(SendLogCategory())) printf("\n");
846 860
847 nPushPos = -1; 861 nPushPos = -1;
848 LeaveCriticalSection(&cs_vSend); 862 LeaveCriticalSection(&cs_vSend);
diff --git a/src/nostr.cpp b/src/nostr.cpp
index e2d839c..9bbf74e 100644
--- a/src/nostr.cpp
+++ b/src/nostr.cpp
@@ -1440,7 +1440,7 @@ static bool SeedFromRelay(CNostrKey& key, const string& relay)
1440 else if (createdAt > it->second) it->second = createdAt; // refresh 1440 else if (createdAt > it->second) it->second = createdAt; // refresh
1441 } 1441 }
1442 if (fNew && fDebug) 1442 if (fNew && fDebug)
1443 LogPrint("nostr", "Nostr: discovered .btf peer %s\n", peerAddr.c_str()); 1443 LogPrint("nostrdiscovery", "Nostr: discovered .btf peer %s\n", peerAddr.c_str());
1444 if (++nPeers > 500) break; 1444 if (++nPeers > 500) break;
1445 } 1445 }
1446 else if (type == "EOSE") 1446 else if (type == "EOSE")
diff --git a/src/util.cpp b/src/util.cpp
index 52cda84..a5a4e80 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -7,6 +7,7 @@
7 7
8 8
9bool fDebug = false; 9bool fDebug = false;
10bool fDebugRelay = false;
10 11
11// In-process cap for debug.log, in bytes. Default matches the 1G trigger of 12// In-process cap for debug.log, in bytes. Default matches the 1G trigger of
12// the shipped logrotate policy so a long-running node stays bounded even 13// the shipped logrotate policy so a long-running node stays bounded even
@@ -31,10 +32,22 @@ static bool LogCategoryDefaultOn(const char* category)
31 strcmp(category, "payout") == 0; 32 strcmp(category, "payout") == 0;
32} 33}
33 34
35// Categories so noisy they drown out everything else even under -debug:
36// per-message send traces, wallet relay rebroadcasts, raw CBlock dumps and
37// per-address discovery lines made up ~90% of a 13-hour production capture
38// (issue #35). They need /debugrelay, not merely /debug.
39static bool LogCategoryVerboseOnly(const char* category)
40{
41 return strcmp(category, "relay") == 0 ||
42 strcmp(category, "nostrdiscovery") == 0;
43}
44
34bool LogAcceptsCategory(const char* category) 45bool LogAcceptsCategory(const char* category)
35{ 46{
36 if (LogCategoryDefaultOn(category)) 47 if (LogCategoryDefaultOn(category))
37 return true; 48 return true;
49 if (LogCategoryVerboseOnly(category))
50 return fDebugRelay;
38 return fDebug; 51 return fDebug;
39} 52}
40 53
diff --git a/src/util.h b/src/util.h
index f2ea23f..c47b8a7 100644
--- a/src/util.h
+++ b/src/util.h
@@ -87,6 +87,10 @@ inline T& REF(const T& val)
87 87
88extern bool fDebug; 88extern bool fDebug;
89 89
90// /debugrelay: the per-message firehose ("relay" and "nostrdiscovery"
91// categories) that even -debug keeps off. See LogAcceptsCategory().
92extern bool fDebugRelay;
93
90// debug.log is rolled to debug.log.old once it grows past this many bytes 94// debug.log is rolled to debug.log.old once it grows past this many bytes
91// (set from -maxdebugfilesize, in MB; 0 disables the check). See the roll 95// (set from -maxdebugfilesize, in MB; 0 disables the check). See the roll
92// site in OutputDebugStringF() below. 96// site in OutputDebugStringF() below.