Wire ckpool to real ZMQ endpoint and enable blockpoll

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.
This commit is contained in:
satoshi
2026-04-23 01:10:31 +03:00
parent 04a8e2d4dc
commit dc33bb7694
+15 -5
View File
@@ -67,10 +67,21 @@ export POOL_BTCADDRESS="${SELFTEST_ADDRESS}"
# SOCKET_DIR is ephemeral — sockets are re-created on each start. # SOCKET_DIR is ephemeral — sockets are re-created on each start.
export LOGDIR=/root/.ckpool/logs export LOGDIR=/root/.ckpool/logs
export SOCKET_DIR=/run/ckpool export SOCKET_DIR=/run/ckpool
export BITCOIN_NOTIFY=true
# ckpool itself doesn't use ZMQ in this build — zmqblock is stripped # ckpool has TWO independent new-block detection paths. Wire up both
# from the rendered conf below. kamado-api subscribes separately. # so we're never blind to a tip change (every second of stale work
export ZMQ_BLOCK="" # 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 BLOCKPOLL_MS=100
export UPDATE_INTERVAL_S=30 export UPDATE_INTERVAL_S=30
mkdir -p "${LOGDIR}" "${SOCKET_DIR}" /etc/ckpool mkdir -p "${LOGDIR}" "${SOCKET_DIR}" /etc/ckpool
@@ -98,7 +109,6 @@ sed \
-e "s|\${LOGDIR}|${LOGDIR}|g" \ -e "s|\${LOGDIR}|${LOGDIR}|g" \
-e "s|\${ZMQ_BLOCK}|${ZMQ_BLOCK}|g" \ -e "s|\${ZMQ_BLOCK}|${ZMQ_BLOCK}|g" \
"${TEMPLATE}" > "${CONF}" "${TEMPLATE}" > "${CONF}"
sed -i '/"zmqblock":/d' "${CONF}"
echo "kamado-entrypoint: starting ckpool (solo, ${BITCOIND_VARIANT}) on port ${STRATUM_PORT}" echo "kamado-entrypoint: starting ckpool (solo, ${BITCOIND_VARIANT}) on port ${STRATUM_PORT}"
/usr/local/bin/ckpool --btcsolo --config "${CONF}" --sockdir "${SOCKET_DIR}" --log-shares & /usr/local/bin/ckpool --btcsolo --config "${CONF}" --sockdir "${SOCKET_DIR}" --log-shares &