Add share cards

This commit is contained in:
satoshi committed 2026-09-04 00:54:26 +03:00
1 parent ec42ce9b54
commit 4669bf10c0
51 files changed
+1193 -239

No files matched your search

@@ -5,15 +5,15 @@ index 7940d4fa..a856b3eb 100644
@@ -5865,6 +5865,65 @@ out_nouserwb:
return wb->coinb2bin;
}
+/* Kamado (patches/0008): highest share diff for which PoW reproduction
+ * data has been logged in this process run. Deliberately unlocked — a
+ * data has been logged in this process run. Deliberately unlocked, a
+ * race between share-processing threads can at worst emit a duplicate
+ * or out-of-order log line, which kamado-api deduplicates by diff. */
+static double best_pow_diff;
+
+/* Kamado (patches/0008): log everything needed to independently
+ * reproduce and verify the proof of work of a best share — the
+ * reproduce and verify the proof of work of a best share, the
+ * serialized 80-byte block header exactly as it was hashed, plus the
+ * assembled coinbase transaction and merkle branch hashes that
+ * reproduce the merkle root committed in that header. kamado-api
@@ -56,7 +56,7 @@ index 7940d4fa..a856b3eb 100644
+ if (likely(s)) {
+ /* Call logmsg directly rather than LOGNOTICE: the LOGMSG
+ * macro splits messages into DEFLOGBUFSIZ (512-byte) chunks,
+ * each written as a separate timestamped log line — and its
+ * each written as a separate timestamped log line, and its
+ * length arithmetic drops everything past ~3 chunks. This
+ * record is ~2.5KB of JSON that kamado-api must read back as
+ * one intact line. logmsg itself is unbounded. */
@@ -71,13 +71,13 @@ index 7940d4fa..a856b3eb 100644
@@ -5937,6 +5996,19 @@ static double submission_diff(sdata_t *sdata, const stratum_instance_t *client,
/* Calculate the diff of the share here */
ret = diff_from_target(hash);
+ /* Kamado (patches/0008): if this is the highest-diff share this
+ * process has seen, log full PoW reproduction data for the
+ * dashboard's best-share header inspector. Skip shares that will
+ * be rejected: stale ones, and those outside the ntime roll
+ * window (mirrors the check in parse_submit). Duplicates cannot
+ * trigger this — an identical share has an equal, not greater,
+ * trigger this, an identical share has an equal, not greater,
+ * diff. */
+ if (unlikely(ret > best_pow_diff && !stale &&
+ ntime32 >= wb->ntime32 && ntime32 <= wb->ntime32 + 7000)) {
@@ -87,4 +87,4 @@ index 7940d4fa..a856b3eb 100644
+
/* Test we haven't solved a block regardless of share status */
test_blocksolve(client, wb, swap, hash, ret, coinbase, cblen, nonce2, nonce, ntime32, version_mask, stale);
@@ -5,7 +5,7 @@ index a856b3eb..fcb9eb94 100644
@@ -5477,6 +5477,69 @@ static void update_solo_client(sdata_t *sdata, workbase_t *wb, const int64_t cli
stratum_add_send(sdata, json_msg, client_id, SM_UPDATE);
}
+/* Kamado (patches/0009): restore a reconnecting miner's difficulty and
+ * grant the work it already holds a difficulty grace window.
+ *
@@ -75,17 +75,17 @@ index a856b3eb..fcb9eb94 100644
@@ -5558,6 +5621,19 @@ out:
sdata_t *sdata = ckp->sdata;
workbase_t *wb;
+ /* Kamado (patches/0009): pick up where vardiff left off and
+ * arm the first-job grace window. Called before any lock is
+ * taken here — it acquires the workbase lock itself. */
+ * taken here, it acquires the workbase lock itself. */
+ resume_client_diff(ckp, sdata, client);
+
+ /* Kamado (patches/0009): mining.set_difficulty must precede
+ * the first mining.notify. Upstream sent the job first, so a
+ * miner started hashing it at whatever difficulty its firmware
+ * defaults to and its early shares came back under the
+ * difficulty we had assigned — a burst of "high diff" rejects
+ * difficulty we had assigned, a burst of "high diff" rejects
+ * from every miner on every pool restart. */
+ stratum_send_diff(sdata, client);
+
@@ -104,7 +104,7 @@ index a856b3eb..fcb9eb94 100644
@@ -6567,9 +6641,12 @@ static void update_client(const stratum_instance_t *client, const int64_t client
{
sdata_t *sdata = client->sdata;
+ /* Kamado (patches/0009): difficulty before work, so a client never
+ * starts a job without knowing the difficulty it will be judged
+ * against. Upstream sent the update first. */
@@ -113,5 +113,5 @@ index a856b3eb..fcb9eb94 100644
stratum_send_update(sdata, client_id, true);
- stratum_send_diff(sdata, client);
}
static json_params_t
+3 -3
View File
@@ -25,7 +25,7 @@ Upstream tracks `best_ever` internally in `user_instance_t` / `worker_instance_t
and zeroes `best_diff` on every block solve via `reset_bestshares()`. That
is correct: `bestdiff` is "best share in the current round". But the runtime
socket API (`userinfo()` / `workerinfo()` in `stratifier.c`) only emits
`bestdiff`, so any consumer that talks to the socket — like `kamado-api` —
`bestdiff`, so any consumer that talks to the socket, like `kamado-api`,
sees the best share reset to 0 after every block and has no all-time field
to fall back on. The on-disk `users.json` / `workers.json` persistence files
do include `bestever`, but polling those is racy and lags the socket.
@@ -46,7 +46,7 @@ backport, plus several improvements:
| `66db3aa3` | Better vardiff for bursty hashers |
| `130c755d` | Fix unlikely fopen segfault |
| `0bd3d751` | Consistent error field in mining.submit rejections |
| `988b2687` | Version 1.0 — longstanding stability bump |
| `988b2687` | Version 1.0, longstanding stability bump |
Kamado therefore starts from a CKPool that is strictly ahead of what Bassin
ships today.
@@ -57,7 +57,7 @@ Use this directory for:
1. Fixes needed before they land upstream (and only after attempting
to submit upstream first).
2. Kamado-specific behavior changes that would not be accepted upstream —
2. Kamado-specific behavior changes that would not be accepted upstream,
e.g. tighter integration hooks with `kamado-api`.
3. Temporary workarounds with a clear removal plan, documented in the
patch commit message.