From 66d726482bd31337fe6c444f60a7c90ad4310ea3 Mon Sep 17 00:00:00 2001 From: mblowes Date: Thu, 3 Sep 2026 22:37:14 +1000 Subject: [PATCH 1/2] Startup ping uses the long-poll client (enforcer GBT > 10s) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a backend without getblockchaininfo (the CUSF enforcer) bitcoind_ping() falls back to a full getblocktemplate. The general-purpose client has a 10s timeout and a live alphanet template is now ~4.4 MB and takes 10.5–13.5s to come back, so the pool exits 3 at startup with "bitcoind ping failed: curl: Timeout was reached" and a relaunch loop flaps until a template happens to arrive fast (seen on d68f8da on 2026-08-31 23:55 and on this branch on 2026-09-03 12:31 on freebanktest). The tip watcher already fetches every template through the 90s long-poll client; the ping now uses the same one. Also free btc_lp on the ping's failure path. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01BufjPUcrUtoG7E4tf61j3n (cherry picked from commit 67cd9f21e1ca48763ed238824222075ade18339f) --- src/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index d14ec91..941d207 100644 --- a/src/main.c +++ b/src/main.c @@ -953,11 +953,21 @@ int main(int argc, char **argv) { /* The ping is a getblockchaininfo sanity check. Some block-template * backends that accept unauthenticated JSON-RPC don't implement it, so * skip the ping when no credentials are configured — the initial - * getblocktemplate below still validates connectivity. */ + * getblocktemplate below still validates connectivity. + * + * It goes through the long-poll client, not the 10s general-purpose one: + * on a backend without getblockchaininfo (the CUSF enforcer) the ping + * falls back to a full getblocktemplate, and that response is a multi-MB + * template that takes longer than 10s once the mempool fills (10.5–13.5s + * measured live on alphanet). With the short client the pool exits 3 at + * startup — "bitcoind ping failed: curl: Timeout was reached" — and a + * relaunch loop just flaps until a template happens to come back fast. + * The tip watcher already fetches every template with this client. */ if (cfg.bitcoind_user[0] != '\0' || cfg.bitcoind_pass[0] != '\0') { - if (bitcoind_ping(&btc, err, sizeof err) < 0) { + if (bitcoind_ping(&btc_lp, err, sizeof err) < 0) { fprintf(stderr, "bitcoind ping failed: %s\n", err); bitcoind_client_free(&btc); + bitcoind_client_free(&btc_lp); return 3; } LOG_INFO("bitcoind ping ok"); From d093a28dd6796fa113eabbafbe9c6b629e51bc08 Mon Sep 17 00:00:00 2001 From: mblowes Date: Thu, 3 Sep 2026 22:39:17 +1000 Subject: [PATCH 2/2] Initial GBT uses the long-poll client too Same flap as the previous commit, one step later: after the ping passes, the first getblocktemplate went through the 10s client and exited 5 ("initial GBT failed: curl: Timeout was reached") on a 14s live template. Fetch it with the 90s long-poll client the tip watcher uses. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01BufjPUcrUtoG7E4tf61j3n (cherry picked from commit 6f4a22602e7e9e412b173dd07664c9acf3356d7b) --- src/main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 941d207..8137848 100644 --- a/src/main.c +++ b/src/main.c @@ -1066,9 +1066,11 @@ int main(int argc, char **argv) { bcast = NULL; } - /* Initial template + job. */ + /* Initial template + job. Same client as the ping and the tip watcher: + * a live template can take longer than the 10s general-purpose client + * allows (see the ping above), and exiting 5 here is the same flap. */ bitcoind_template_t *tmpl = NULL; - if (bitcoind_get_block_template(&btc, &tmpl, err, sizeof err) < 0) { + if (bitcoind_get_block_template(&btc_lp, &tmpl, err, sizeof err) < 0) { fprintf(stderr, "initial GBT failed: %s\n", err); store_close(store); bitcoind_client_free(&btc);