From dc33bb7694bbb8cc279050ce6d84e879595ecdaa Mon Sep 17 00:00:00 2001 From: satoshi Date: Thu, 23 Apr 2026 01:10:31 +0300 Subject: [PATCH] Wire ckpool to real ZMQ endpoint and enable blockpoll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With BITCOIN_NOTIFY=true, ckpool's generator_getbest short-circuits to GETBEST_NOTIFY (generator.c:902) and the blockupdate loop sleeps 5s doing nothing (stratifier.c:4695). It then expects ZMQ to push new-tip events — but our ZMQ_BLOCK was empty and ckpool defaults to tcp://127.0.0.1:28332 (ckpool.c:1795), which has nothing listening inside this container. Net effect: ckpool was blind to tip changes, so miners kept hashing the stale work until the next 30s update_interval finally pulled a new template. Observed was a 16-second gap between bitcoind's UpdateTip log line and ckpool's subsequent CreateNewBlock call — that's pure wasted hashrate. Fix both paths: - BITCOIN_NOTIFY=false so the blockpoll thread actually polls getbestblockhash every BLOCKPOLL_MS (100ms). - ZMQ_BLOCK=tcp://${BITCOIN_RPC_HOST}:28332 so the zmqnotify thread subscribes to bitcoind's real hashblock publisher. Whichever path sees the new tip first triggers update_base(); both are safe to run concurrently. - Drop the sed line that was stripping zmqblock from the rendered conf — we now want it in there. --- docker_entrypoint.sh | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/docker_entrypoint.sh b/docker_entrypoint.sh index 9deb5a6..6b6c297 100755 --- a/docker_entrypoint.sh +++ b/docker_entrypoint.sh @@ -67,10 +67,21 @@ export POOL_BTCADDRESS="${SELFTEST_ADDRESS}" # SOCKET_DIR is ephemeral — sockets are re-created on each start. export LOGDIR=/root/.ckpool/logs export SOCKET_DIR=/run/ckpool -export BITCOIN_NOTIFY=true -# ckpool itself doesn't use ZMQ in this build — zmqblock is stripped -# from the rendered conf below. kamado-api subscribes separately. -export ZMQ_BLOCK="" + +# ckpool has TWO independent new-block detection paths. Wire up both +# so we're never blind to a tip change (every second of stale work +# in solo mode is hashrate burned on a dead block). +# +# 1. Blockpoll thread: polls bitcoind's getbestblockhash every +# BLOCKPOLL_MS. This only runs when notify=false — with +# notify=true the thread sleeps 5s and returns immediately. +# So keep notify=false. +# 2. ZMQ hashblock subscriber: instant push notifications from +# bitcoind. ckpool defaults zmqblock to tcp://127.0.0.1:28332 +# which is useless in this container, so point it at the real +# endpoint explicitly. +export BITCOIN_NOTIFY=false +export ZMQ_BLOCK="tcp://${BITCOIN_RPC_HOST}:28332" export BLOCKPOLL_MS=100 export UPDATE_INTERVAL_S=30 mkdir -p "${LOGDIR}" "${SOCKET_DIR}" /etc/ckpool @@ -98,7 +109,6 @@ sed \ -e "s|\${LOGDIR}|${LOGDIR}|g" \ -e "s|\${ZMQ_BLOCK}|${ZMQ_BLOCK}|g" \ "${TEMPLATE}" > "${CONF}" -sed -i '/"zmqblock":/d' "${CONF}" echo "kamado-entrypoint: starting ckpool (solo, ${BITCOIND_VARIANT}) on port ${STRATUM_PORT}" /usr/local/bin/ckpool --btcsolo --config "${CONF}" --sockdir "${SOCKET_DIR}" --log-shares &