Files
KamadoPool/ckpool/patches/0003-share-error-as-stratum-array.patch
T
satoshi 208153bbee Patch ckpool: return share errors as Stratum [code, msg, null] arrays
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.
2026-04-26 18:03:22 +03:00

37 lines
1.3 KiB
Diff

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,