Merge ckpool upstream changes #593

Merged
paratoxic merged 19 commits from ckpool-upstream-merge into master 2026-08-17 20:52:08 +00:00
Owner
No description provided.
Replaces the tree that was forked from upstream c067457e (2025-06-01) with
upstream master as of cdfa79ee (2026-08-06), 229 commits later. Local
modifications are re-applied in following commits.

SV2 is left in tree but defaults to off in configure; re-enabling needs the
src/secp256k1 submodule, which is not vendored here. Upstream's own
--disable-sv2 build is broken because check_listen_port_clashes() and
listen_host_is_wildcard() are defined inside #ifdef HAVE_SV2 but called
unconditionally, so both are moved above the guard.

libpq detection moves from AC_SEARCH_LIBS to PKG_CHECK_MODULES so that only
the ckpool binary links it rather than every target.
Mechanical reformat of the imported upstream tree with .clang-format, so the
functional changes in the next commit show up as a readable diff rather than
being buried in whitespace.

Matches the CI check in .forgejo/workflows/ci.yaml, which excludes sha2.c,
sha2.h and uthash.h. Note the justfile lint recipe does not exclude those
three, so running it reformats files CI never verifies.
Ports the fork's changes onto the new upstream base. Upstream moved ckpool_t
to a single global and replaced jansson with yyjson, so most of this is a
rewrite against the new APIs rather than a merge.

Features restored:
 - PostgreSQL share/block/user logging, rewritten for yyjson. Statements are
   prepared once per connection and executed with bound parameters.
 - Coinbase pays a fixed COIN to the generation output with the remainder to
   the pool address.
 - Lightning addresses parsed from btcaddress.worker.lightningid@domain and
   reported as lnurl in the sharelog and database.
 - --log-shares (database), --log-shares-file, --log-txns, --signet.

Fixes to those changes, found while auditing them against the old tree:
 - The coinbase remainder was computed as an unsigned coinbasevalue - COIN
   with no lower bound, so any template worth under 1 BTC wrapped to ~1.8e19
   satoshi. Templates at or below COIN now pay a single output. Verified on
   regtest at 0.78125 BTC subsidy.
 - The output count byte was hardcoded to 2 + insert_witness while the second
   output was only serialised when donation > 0, so omitting the donation
   config produced a malformed coinbase. The count now follows what is
   actually serialised.
 - The libpq conninfo string, which holds the database password, was logged at
   LOGDEBUG. The database config is now read without echoing values.
 - --log-shares with a missing or partial database config left the conninfo
   NULL and faulted inside libpq. It is now refused at startup.
 - generate_user leaked several allocations per mining.authorize, compared
   secondaryuserid by pointer rather than value, and replaced it unlocked
   while the share path read it. Rewritten to parse in place, compare with
   strcmp, and swap under the instance lock its readers take.
 - db_log_share read wb->height after put_workbase released the workbase. The
   height is now captured while the reference is held.
 - PGconn and the PQ calls sat outside HAVE_LIBPQ, so the file did not build
   without libpq. All of it is now guarded, with stubs for the other case.

Upstream's regtest detection is kept, since it drives BIP34 height
serialisation; only the payout address is overridden.

bin/run_tests compiled every file in ckpool/test with bare gcc, which broke on
upstream's automake-based tests. It now runs the standalone tests directly and
defers the rest to make check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
configure leaves confdefs.h and conftest.c behind when an AC_CHECK_HEADER
probe aborts, which the libpq fallback path can trigger.
ckpool: reformat with hermit's clang-format
Some checks failed
CI / ckpool (pull_request) Failing after 34s
CI / lint (pull_request) Successful in 2m10s
CI / test-linux (pull_request) Has been cancelled
b6ef87b159
The earlier formatting commit used clang-format 20 from the hermit cache.
The activated hermit environment resolves clang-format to 15.0.7, which
formats six vendored upstream files differently. Reformatted with the
version 'just lint' actually runs so the tree is stable under it.

Only vendored files change: sv2_jd.c, sv2_jdc.c, utlist.h, yyjson.c,
yyjson.h, yyjson_util.h.
hermit: drop clang for isolated clang-format
Some checks failed
CI / ckpool (pull_request) Failing after 30s
CI / lint (pull_request) Successful in 1m30s
CI / test-linux (pull_request) Successful in 5m21s
9cbf3bd8ba
Left behind under ipc/mining when configure detects capnp-rpc.
ci: run lint through hermit's pinned clang-format
Some checks failed
CI / ckpool (pull_request) Failing after 11s
CI / lint (pull_request) Successful in 1m38s
CI / test-linux (pull_request) Failing after 5m35s
2283e7cf76
CI installed clang-format from apt, which is currently 21.x, while just lint
uses the hermit pinned 20.1.0. The two disagree on vendored yyjson.c (a
declaration following an attribute and an #endif), so a tree that was clean
locally failed CI.

Both workflows now call 'just lint-check', and the lint recipes invoke
./bin/clang-format explicitly, so CI and a developer checkout always use the
same binary. The hermit shims bootstrap without activation, so no setup step
is needed.

The file list lives in one place in the justfile instead of being duplicated,
differently, in three. The GitHub workflow had drifted: it never excluded
uthash.h, which fails formatting under any version, and both workflows still
excluded the jansson-2.14 directory that no longer exists.

Vendored third party sources are now excluded outright: sha2, uthash, utlist
and yyjson. They are not ours to restyle, reformatting them complicates
upstream merges, and it is these large macro heavy files that disagree between
clang-format versions. With them excluded the tree passes under 20 and 21
alike, so the fix does not depend on the pin holding.
parabit force-pushed ckpool-upstream-merge from 2283e7cf76
Some checks failed
CI / ckpool (pull_request) Failing after 11s
CI / lint (pull_request) Successful in 1m38s
CI / test-linux (pull_request) Failing after 5m35s
to 351cc163c3
Some checks failed
CI / ckpool (pull_request) Failing after 20s
CI / lint (pull_request) Successful in 1m44s
CI / test-linux (pull_request) Successful in 5m39s
2026-08-06 19:35:46 +00:00
Compare
ci: pin clang-format version for ci
Some checks failed
CI / ckpool (pull_request) Failing after 8s
CI / lint (pull_request) Successful in 1m21s
CI / test-linux (pull_request) Failing after 5m22s
8d1b130d16
parabit force-pushed ckpool-upstream-merge from 8d1b130d16
Some checks failed
CI / ckpool (pull_request) Failing after 8s
CI / lint (pull_request) Successful in 1m21s
CI / test-linux (pull_request) Failing after 5m22s
to 0cdc8bb527
Some checks failed
CI / ckpool (pull_request) Successful in 9s
CI / lint (pull_request) Successful in 1m18s
CI / test-linux (pull_request) Has been cancelled
2026-08-06 20:38:22 +00:00
Compare
Merge branch 'master' into ckpool-upstream-merge
Some checks failed
CI / ckpool (pull_request) Successful in 12s
CI / lint (pull_request) Successful in 1m17s
CI / test-linux (pull_request) Failing after 4m32s
760ebe6b9b
Merge remote-tracking branch 'origin/ckpool-upstream-merge' into ckpool-upstream-merge
Some checks failed
CI / ckpool (pull_request) Successful in 13s
CI / lint (pull_request) Successful in 1m37s
CI / test-linux (pull_request) Failing after 5m28s
4d3896e719
fixup: no postgresql superuser
Some checks failed
CI / ckpool (pull_request) Successful in 13s
CI / lint (pull_request) Successful in 1m29s
CI / test-linux (pull_request) Failing after 5m12s
ee3b162e54
parabit left a comment

Notes

Notes
ckpool/AUTHORS Outdated
@ -2,4 +2,1 @@
Core project lead, maintainer, author of ckpool and libckpool.
14BMjogz69qe8hk9thyzbmR5pg34mVKB1e
Andrew Smith <kan0i {at} kano-kun [dot] net>
Author
Owner

Dropped an author?

Dropped an author?
parabit marked this conversation as resolved
@ -308,6 +331,9 @@ the health of the bitcoin network.
for a client to alter and is expressed as an hex string. Eg "00fff000"
Default is "1fffe000".
"dropidle" : Drop clients which have been idle for this duration in seconds,
Author
Owner

Finally a clean way to deal with the user growth

Finally a clean way to deal with the user growth
parabit marked this conversation as resolved
@ -333,2 +359,4 @@
only. Requires use of matched bitcoind -zmqpubhashblock option.
Default: tcp://127.0.0.1:28332
"ipcmining" : Optional path to Bitcoin Core's mining IPC unix socket. In pool
Author
Owner

Do we want to move to IPC?

Do we want to move to IPC?
parabit marked this conversation as resolved
@ -0,0 +1,13 @@
image: alpine/git:latest
Author
Owner

Going to drop these as we don't use bitbucket and already have github mirroring in forgejo

Going to drop these as we don't use bitbucket and already have github mirroring in forgejo
parabit marked this conversation as resolved
@ -0,0 +5,4 @@
namespace capnp {
namespace schemas {
static const ::capnp::_::AlignedData<59> b_b3be4b8949350369 = {
Author
Owner

Uhh, what is this random binary blob.. It exists in upstream, will validate.

Uhh, what is this random binary blob.. It exists in upstream, will validate.
parabit marked this conversation as resolved
fixup: highdiff port settings
All checks were successful
CI / ckpool (pull_request) Successful in 25s
CI / lint (pull_request) Successful in 2m36s
CI / test-linux (pull_request) Successful in 6m34s
1464391a6e
fixup: add capnp pin by building from source
All checks were successful
CI / ckpool (pull_request) Successful in 13s
CI / lint (pull_request) Successful in 1m27s
CI / test-linux (pull_request) Successful in 4m58s
2f4152197a
Merge branch 'master' into ckpool-upstream-merge
All checks were successful
CI / ckpool (pull_request) Successful in 18s
CI / lint (pull_request) Successful in 2m30s
CI / test-linux (pull_request) Successful in 9m56s
58439b19ef
paratoxic merged commit 6dfe5b3474 into master 2026-08-17 20:52:08 +00:00
paratoxic deleted branch ckpool-upstream-merge 2026-08-17 20:52:09 +00:00
Sign in to join this conversation.
No description provided.