Skip to content

coordinator: a duplicate rig id from two sources blocks control; moved hardware is an info event (#4182) - #4646

Draft
pithead-developer[bot] wants to merge 8 commits into
developfrom
agent/4182-coordinator-a-duplicate-identity-fault-f
Draft

pithead-developer[bot] wants to merge 8 commits into
developfrom
agent/4182-coordinator-a-duplicate-identity-fault-f

Conversation

@pithead-developer

@pithead-developer pithead-developer Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What's the problem

Part of #4182

Two machines booted from copies of one stick share a name, token and rig id, and nothing noticed: the dashboard showed them as ordinary rows and the control verbs dialed whichever host the name matched. #4182 requires a duplicate-identity fault that blocks control and update for that record until the operator re-keys one copy, and a moved-hardware info event that blocks nothing.

How I fixed it

  • How a clone actually appears. xmrig-proxy 6.26.0 groups worker rows by rig id: Workers::add keys each connection by rigId(true) (rig id, else login) under the default workers mode RigID, and Worker::add(ip) on an existing worker only bumps connections and overwrites the row IP — so two clones arrive as ONE proxy row whose IP is whichever connection joined last, and the same name at two IPs as two rows never occurs (ApiRouter.cpp getWorkers, Workers.cpp add/nameByMiner, Worker.h add). Detection therefore runs on the per-connection listing that same pinned release serves: GET /1/miners (ApiRouter::getMiners, format [id, ip, tx, rx, state, diff, user, password, rig_id, agent]).
  • service/workers/worker_identity_poll.py observes two channels each poll: every connected online row's feed rig id (the edited-login clone shape), and every (key, machine IP) pair /1/miners reports, where the key is the stratum rig-id else the login and is mapped to the feed rig id through the live row's worker name (the feed rig_id and the stratum rig-id are separate RigForge settings, the stratum one unset by default; a +suffix login falls back to its bare name only when no row carries the exact name). /1/miners is not fetched while no online row carries a feed id — a merged clone row now raises the fault from its two connections, while several stratum threads from one machine (one IP) never do. _parse_proxy_miners is length- and type-checked, and a failed /1/miners fetch adds no sources, so a flaky read can only let the fault decay, never clear it early. A source address is keyed with the port stripped exactly as the SSRF probe guard tolerates it (the proxy/stratum occasionally report ip:port), so one machine never appears as two sources, and the connection leg reuses the credential the row leg resolved for an id so the two legs never reset each other's source history.
  • service/workers/worker_identity.py holds the in-memory tracker keyed by rig id → live source addresses; ≥2 within IDENTITY_WINDOW_S (three poll intervals) is the fault, it decays when a source goes quiet, and it resets when the endpoint's derived read credential changes (a re-key through adopt/re-adopt). mark_duplicates sets duplicate_identity on the worker rows.
  • The tracker also keeps the last display-hint fingerprint per (rig id, credential, address) and the per-rig moved clock in two bounded LRU maps (4096 entries) that the window sweep never clears, so a stick that comes back after being powered off for longer than the window still raises the moved event, and its one-per-hour limit holds.
  • One address serving the same id with changed display hints, however long the gap between the answers, writes one rig-identity / moved-hardware / info row to the existing audit log (at most one per rig id per hour) and blocks nothing.
  • control_service.submit_worker_apply and submit_worker_upgrade stamp duplicate_identity on the spooled intent while the worker is faulted (the same carry-the-flag pattern as appliance). control_worker_apply and control_worker_upgrade in lib/pithead/46-control-worker-ops.sh refuse it after resolving the target and before the dial budget or any dial, naming the duplicate identity and the cure. The fault state is duplicate_identity on the worker rows, for Coordinator: Upgrade rig and Remove rig drive the RigForge API and revoke a removed rig #4016's Update all; that verb is not built here.
  • docs/workers.md gained the clone / moved stick / dead stick section — the clone row now reads as it really looks: one merged proxy row whose IP is whichever copy spoke last, the id answering from two machine addresses.
  • Shortcut: the fault is held in memory and stamped when an intent is spooled; upgrade when Coordinator: Upgrade rig and Remove rig drive the RigForge API and revoke a removed rig #4016 needs a persisted fault (a restart re-raises it within one window, and an intent queued before the fault is not re-checked).
  • Shortcut: two different rigs that share one pool login and set no stratum rig-id reach the proxy as one worker and are indistinguishable from a clone; the docs tell the operator to give each its own user or rig-id.
  • Shortcut: the current dashboard UI is not touched (it is deleted at the 2.1.0 cutover); the flag is on the worker rows only.

Here is the proof

  • Same id from two distinct sources raises the fault within the code-named window and decays when one goes quiet: test_two_simulated_sources_raise_and_decay (two rows, one feed id), test_a_merged_clone_row_raises_from_its_connections and test_the_fault_decays_when_one_copy_stops_answering (the merged-row shape, fed the pinned proxy's own /1/miners payload), test_two_connections_from_one_machine_are_not_a_fault (stratum threads are not clones)
  • Control verbs refuse before dialing, naming the cure: tests/stack/control/test-control-status-vocabulary.sh (dial budget open, no dial logged; the unflagged apply dials the stub)
  • Same id with different hints from one source is an info event, no fault: test_same_id_different_hints_from_one_source_is_an_info_event, test_moved_hardware_events_are_rate_limited_per_rig_id
  • Re-key clears the fault with both copies staying online: test_rekeying_one_copy_clears_the_fault holds two live connections and an adopted entry with host; re-adopting one copy under a new rig id and token leaves both rows online, and the old id is no longer faulted — no copy is dropped from the poll to make it pass
  • Parser pins the real payload: TestParseProxyMiners (rig id, else login; malformed rows dropped), test_get_miners pins the endpoint
  • Address forms shared across the two channels: test_a_row_ip_with_a_port_is_the_same_source_as_the_bare_ip, test_the_same_machine_with_two_ephemeral_ports_is_not_a_fault, test_the_fault_survives_a_failed_miners_fetch (both legs carry one credential per id)
  • Real default shape (stratum rig-id unset, login only), a +suffix login, suffix-separated rows kept apart, another login not attributed: test_a_default_clone_pair_with_no_stratum_rig_id_raises_from_the_login, test_a_login_suffix_still_maps_to_the_worker, test_rows_that_differ_only_by_a_login_suffix_stay_separate, test_connections_under_another_login_are_not_attributed
  • Moved event after a gap longer than the window, bounded memory, and no miners fetch without a feed id: test_a_stick_moved_after_a_quiet_gap_is_still_an_info_event, test_a_second_move_after_the_rate_limit_and_a_gap_is_recorded, test_a_fingerprint_change_after_the_window_is_moved, test_remembered_fingerprints_are_bounded, test_the_moved_clock_map_is_bounded, test_no_miners_fetch_without_a_feed_id; test_the_fault_survives_a_failed_miners_fetch now makes get_miners raise
  • Docs state the three situations and the shared-token Remove-rig effect

Red-without-the-fix: with only the /1/miners leg removed from observe_poll, test_a_merged_clone_row_raises_from_its_connections, test_the_fault_decays_when_one_copy_stops_answering and test_rekeying_one_copy_clears_the_fault FAIL; on the previous head test_a_row_ip_with_a_port_is_the_same_source_as_the_bare_ip, test_the_same_machine_with_two_ephemeral_ports_is_not_a_fault and test_the_fault_survives_a_failed_miners_fetch FAIL; at this round's head the new gap, login-mapping, bound and fetch-skip tests FAIL with the two source files reverted to ab02c1f0 and pass with them; the full module is green.

Local, on this Mac (corroboration only; GitHub CI is the tier-1 evidence):

  • pytest tests/service tests/web tests/client in dashboard/: exit 0; ruff check and ruff format --check: clean.
  • make lint-file-budget (entry for lib/pithead/49-control-request-loop.sh removed because the hunk's comment deletion dropped it below target) and make lint-pithead-build: pass; no ceiling raised.
  • The new shell rows ran with stub ip and curl under the repo's untrusted-macOS flag: 12 pass, 0 fail. With the gate call disabled in the built pithead, 5 of the new rows fail.

Bench evidence, tier4-e2e (phases rigforge,rigforge-control) on the head before this round's dashboard-only commits (ab02c1f0; this round touches no shell, compose or control-path file, so tiers 1 to 3 on the new head are its proof). An earlier attempt, 4780, errored at reserve in one second on a bench lending zero rigs for this repo/tier (0 rows executed, an environment refusal). The fleet has no cloned stick, so it shows the refusal path deploys and the normal path still dials, not a live clone.

bench-ci job 4836@ab02c1f0a3d2fed21240573512ccbc2c3564e772 · pithead · tier4-e2e

  • options: {"phases": ["rigforge", "rigforge-control"]}
  • status: completed · conclusion: success · exit 0 · 28m 58s
  • baseline verified: yes · rig restored: yes
  • node guard: not recorded · no comparison recorded
  • steps: checkout success · reserve success · preflight success · run success · collect success · restore success · cleanup success
  • host audit: clean
  • rows: 190 pass · 0 fail · 12 skip (by-design 4, missing 8)
    Generated by bench-ci evidence 4836@ab02c1f0a3d2fed21240573512ccbc2c3564e772; re-run it to check.

Ponytail pass: cut a persisted fault table, a UI view-model field and a second proxy poll (the identity poll fetches /1/miners itself — data_service is at its recorded ceiling and this keeps the fetch beside its consumer); kept the tracker caps because the listing is unauthenticated miner input.

pithead-developer[bot] and others added 3 commits November 28, 2026 08:09
…d hardware is an info event (#4182)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…budget-open shell proof, docs wording

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pithead-developer pithead-developer Bot added this to the v2.0.7 milestone Nov 28, 2026
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pithead-developer pithead-developer Bot added stage/bench-testing its issue waits on a queued or running tier-4 bench job stage/in-progress stage/in-review a reviewer session is on it now and removed stage/in-progress stage/bench-testing its issue waits on a queued or running tier-4 bench job labels Nov 28, 2026
@pithead-reviewer

Copy link
Copy Markdown
Contributor

FAIL

What I investigated

Review details are in the private record because they contain sensitive information.

Reviewed head: 865c7b7c82ca04fc44c3e283867ec0c8114fbd3e.

What are the gaps

  • The worker must address the findings in the private review record.

pithead-developer[bot] and others added 2 commits November 29, 2026 16:11
…row hides (#4182)

xmrig-proxy 6.26.0 groups worker rows by rig id (Workers::add keyed by
rigId(true), default workers mode RigID), so two cloned machines arrive as ONE
row whose IP is whichever connection spoke last; the same-name rows the first
cut detected on never occur. Detect instead on the proxy's per-connection
/1/miners listing (ApiRouter::getMiners), keyed by rig id with the stratum
user as fallback, observing each (id, ip) pair only when the id is a live
feed id. A merged clone row now raises the fault from its two connections,
two connections from one machine never do, and the re-key proof keeps both
copies online through an adopted entry's host. Drop the stale allowlist
comment the request-key edit left in the hunk.

Co-Authored-By: Claude Code <noreply@anthropic.com>
…ial per id

The proxy and stratum occasionally report an "ip:port" form for a worker
address, so a healthy machine could present its row address and its
connection address as two sources, and a re-login's new ephemeral port
looked like a new machine. Strip the port from a source key exactly as
the SSRF probe guard does, and let the connection leg reuse the
credential the row leg resolved for an id so the two legs never reset
each other's source history. Annotate the fail-soft miners fetch return
channel, as the collapsed-return gate requires.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@pithead-developer pithead-developer Bot added stage/bench-testing its issue waits on a queued or running tier-4 bench job stage/in-progress stage/needs-review green or pending CI, no reviewer verdict on the head yet stage/in-review a reviewer session is on it now and removed stage/in-progress stage/bench-testing its issue waits on a queued or running tier-4 bench job labels Nov 29, 2026
@pithead-developer pithead-developer Bot removed the stage/needs-review green or pending CI, no reviewer verdict on the head yet label Dec 4, 2026
@pithead-reviewer

Copy link
Copy Markdown
Contributor

FAIL

What I investigated

Review details are in the private record because they contain sensitive information.

Reviewed head: ab02c1f0a3d2fed21240573512ccbc2c3564e772.

What are the gaps

  • The worker must address the findings in the private review record.

Models: claude-opus-5-5 (reviewer); claude-sonnet-5-5 x3 (angles)
The review ran on Claude: Codex credits exhausted, benched for now.

pithead-developer[bot] and others added 2 commits December 4, 2026 10:49
…nd remembers fingerprints across the window (#4182)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…d-login limit (#4182)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@pithead-developer

Copy link
Copy Markdown
Contributor Author

Blocked on #4677. The required check Build image (tor) fails at head 00c7827, and the cause is in develop, not in this diff. build/tor/Dockerfile pins tor=0.4.9.17-r0, but Alpine now carries only tor-0.4.9.18-r0, so apk add stops with unable to select packages … breaks: world[tor=0.4.9.17-r0]. origin/develop has the same pin, and this PR touches nothing under build/tor/.

Finished on this head: all of round 2's findings are fixed (F4646-1, -6, -7, -8, -9). The other 41 checks pass. Two are still in progress, one was cancelled (the macOS soak self-test) and two are skipped.

To clear it: the tor bump (draft PR #4683, or the bot branch #4677 names) has to land on develop and #4677 has to close. After that, merge develop into this branch and rerun the checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stage/blocked its issue waits on another issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants