Use the long-poll client for the startup ping and initial GBT (slow/large templates) - #75
Open
mblowes wants to merge 2 commits into
Open
Use the long-poll client for the startup ping and initial GBT (slow/large templates)#75mblowes wants to merge 2 commits into
mblowes wants to merge 2 commits into
Conversation
Collaborator
|
Hi @mblowes thank you for your collaboration. Can you check why some tests are failing ? |
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BufjPUcrUtoG7E4tf61j3n (cherry picked from commit 67cd9f2)
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BufjPUcrUtoG7E4tf61j3n
(cherry picked from commit 6f4a226)
mblowes
force-pushed
the
up-longpoll-pr
branch
from
September 8, 2026 23:39
2441f52 to
d093a28
Compare
Author
|
Thanks @rsantacroce. Those two checks were failing because the branch was based on an older main; I've rebased onto current main. The change is unrelated to the integration/payout paths — it only routes the startup ping and initial getblocktemplate through the existing long-poll client. Build and unit tests pass locally, CI should be green now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On a block-template backend whose
getblocktemplateis slow to respond,simplepoolcan exit at startup and flap in a relaunch loop.The general-purpose curl client has a 10 s timeout. Two startup calls use it:
bitcoind_ping()skipsgetblockchaininfo(some backends don't implement it) and falls back to a fullgetblocktemplate. The CUSFbip300301_enforceris exactly such a backend.A live template is now multi-megabyte and, once the mempool fills, takes longer than 10 s to return — measured 10.5–13.5 s against alphanet through the enforcer. So the pool exits 3 (
bitcoind ping failed: curl: Timeout was reached) or exits 5 (initial GBT failed: …), and a supervisor relaunch loop just flaps until a template happens to come back fast.Fix
Route those two startup calls through the long-poll client (
btc_lp, ~90 s timeout) — the same client the tip watcher already uses for every template. No behaviour change for fast backends; it only removes the 10 s ceiling on the two startup fetches. 16-line change tosrc/main.c, plus a missingbitcoind_client_free(&btc_lp)on the ping error path.Found running against the enforcer's GBT server; the enforcer is where the slow, large templates come from.