From 24ed292f0524f1bc77c317b60d7ecf265596b3dd Mon Sep 17 00:00:00 2001 From: Bitflash Date: Sat, 1 Aug 2026 12:23:31 -0300 Subject: diag: let the node say what is wrong with it (#81) * Bump to 1.2.11 One change, and it is the reason a node on Windows kept collecting peers it could not hear. FD_SETSIZE was never defined in this tree, so it defaulted to 64 and select() could watch the listen socket plus 63 peers -- everything past that stayed connected and was never read again. Windows FD_SET stops adding once its array is full and says nothing, so there was no error to notice. Because new connections go on the end of vNodes, it was always the newest connection that starved, including the ones dialed to fix connectivity. Measured on two nodes: 277 and 90 CNode objects against 93 and 90 live sockets, 316 and 355 sockets in a bound-but-never-connected state, and a status bar reporting hundreds of peers for a node really talking to thirty. 1.2.11 raises FD_SETSIZE to 1024 on Windows, caps connections at 125, drops a node stuck undeliverable after 60 seconds instead of holding it forever, stops answering a failed select() with POSIX code that has no meaning on Windows, and warns when there are more peers than select can watch. * diag: let the node say what is wrong with it Every hard problem in this project so far was found from outside the node -- sockets read over WMI, committed memory compared against a README, a grep over somebody debug.log. In each case the node knew and had no way to say so. One report, rendered identically for the GUI panel and the log: peers held vs peers actually watched by select(), blocks received and how many arrived without a parent, proof-of-work mode with the live miner thread count, and per peer the age of the last message in each direction plus anything stuck unsent. --- src/gui.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/gui.cpp') diff --git a/src/gui.cpp b/src/gui.cpp index 53cb6db..db6b69e 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -50,6 +50,7 @@ static int64 g_lastWalletRefresh = 0; static bool g_showSend = false; static bool g_showOptions = false; static bool g_showAbout = false; +static bool g_showDiagnostics = false; static bool g_needRefresh = true; static char g_sendAddr[128] = {}; @@ -310,6 +311,7 @@ static void DrawMainWindow() ImGui::EndMenu(); } if (ImGui::MenuItem("Options")) g_showOptions = true; + if (ImGui::MenuItem("Diagnostics")) g_showDiagnostics = true; if (ImGui::MenuItem("About")) g_showAbout = true; ImGui::EndMenuBar(); } @@ -815,6 +817,41 @@ static void DrawOptionsDialog() // --------------------------------------------------------------------------- // About dialog // --------------------------------------------------------------------------- +// What the node knows about itself, in the words it writes to the log. Same +// text in both places on purpose: what a user pastes into an issue is then +// exactly what a developer has already read a hundred times. +static void DrawDiagnosticsDialog() +{ + if (!g_showDiagnostics) return; + ImGui::SetNextWindowSize(ImVec2(720.0f, 460.0f), ImGuiCond_FirstUseEver); + ImGui::SetNextWindowPos(ImGui::GetMainViewport()->GetCenter(), + ImGuiCond_FirstUseEver, ImVec2(0.5f, 0.5f)); + if (ImGui::Begin("Diagnostics", &g_showDiagnostics, ImGuiWindowFlags_NoCollapse)) + { + // Rebuilt at most once a second: it walks every peer and takes their + // send locks, which is not something to do at frame rate. + static std::string strReport; + static int64 nLastBuilt = 0; + if (GetTime() != nLastBuilt) + { + nLastBuilt = GetTime(); + strReport = GetDiagnosticsText(); + } + + if (ImGui::Button("Copy to clipboard", ImVec2(160.0f, 0.0f))) + ImGui::SetClipboardText(strReport.c_str()); + ImGui::SameLine(); + ImGui::TextDisabled("The same report goes to debug.log every ten minutes."); + ImGui::Separator(); + + ImGui::BeginChild("##diagtext", ImVec2(0.0f, 0.0f), false, + ImGuiWindowFlags_HorizontalScrollbar); + ImGui::TextUnformatted(strReport.c_str()); + ImGui::EndChild(); + } + ImGui::End(); +} + static void DrawAboutDialog() { if (!g_showAbout) return; @@ -921,6 +958,7 @@ int RunGUI(int argc, char* argv[]) DrawMainWindow(); DrawSendDialog(); DrawOptionsDialog(); + DrawDiagnosticsDialog(); DrawAboutDialog(); DrawStatusBar(); -- cgit v1.2.3