From 208153bbee88cd5824eb87af5aae07ccef545b90 Mon Sep 17 00:00:00 2001 From: satoshi Date: Sun, 26 Apr 2026 18:03:22 +0300 Subject: [PATCH] Patch ckpool: return share errors as Stratum [code, msg, null] arrays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ckpool's share-rejection response sets the "error" field to a bare JSON string ("Stale", "Above target", "Duplicate", ...). The Stratum mining v1 spec, and every miner firmware that follows it, expects that field to be a [code, message, traceback] array. AxeOS parses with cJSON_GetArrayItem after a cJSON_IsArray check, sees a string, falls back to "unknown error", and the rejection reason disappears from the dashboard. Bassin / public-pool sends the array form, which is why those rejections render as "stale" there. Patch the JSON_ERR macro in stratifier.c to wrap the existing share_errs[] string in json_pack("[isn]", ...) and add a small share_err_code() helper mapping ckpool's enum to the standard Slush stratum codes: 21 stale (SE_STALE, SE_INVALID_JOBID, SE_NTIME_INVALID) 22 duplicate (SE_DUPE) 23 low diff (SE_HIGH_DIFF) 24 unauthorized (SE_NO_USERNAME) 20 other (everything else) All 14 JSON_ERR call sites in parse_submit pick this up automatically — no other call site changes needed. Generated with git diff against the pinned upstream commit so format is correct; round-trip-tested with git apply --check. --- .../0003-share-error-as-stratum-array.patch | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ckpool/patches/0003-share-error-as-stratum-array.patch diff --git a/ckpool/patches/0003-share-error-as-stratum-array.patch b/ckpool/patches/0003-share-error-as-stratum-array.patch new file mode 100644 index 0000000..9b36a2e --- /dev/null +++ b/ckpool/patches/0003-share-error-as-stratum-array.patch @@ -0,0 +1,36 @@ +diff --git a/src/stratifier.c b/src/stratifier.c +index 8281fa0..47d0fed 100644 +--- a/src/stratifier.c ++++ b/src/stratifier.c +@@ -6004,7 +6004,30 @@ static void check_best_diff(sdata_t *sdata, user_instance_t *user,worker_instanc + stratum_send_message(sdata, client, buf); + } + +-#define JSON_ERR(err) json_string(SHARE_ERR(err)) ++/* Map ckpool's share_err enum to standard Stratum mining v1 error codes ++ * (per the Slush stratum spec). Miners like AxeOS / Bitaxe expect the ++ * "error" field on a share response to be a [code, message, traceback] ++ * array; without this they show "unknown error" because cJSON_IsArray ++ * returns false on a bare string. */ ++static inline int share_err_code(enum share_err err) ++{ ++ switch (err) { ++ case SE_STALE: ++ case SE_INVALID_JOBID: ++ case SE_NTIME_INVALID: ++ return 21; /* job not found / stale */ ++ case SE_DUPE: ++ return 22; /* duplicate share */ ++ case SE_HIGH_DIFF: ++ return 23; /* low difficulty share */ ++ case SE_NO_USERNAME: ++ return 24; /* unauthorized worker */ ++ default: ++ return 20; /* other / unknown */ ++ } ++} ++ ++#define JSON_ERR(err) json_pack("[isn]", share_err_code(err), SHARE_ERR(err)) + + /* Needs to be entered with client holding a ref count. */ + static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg,