Repository navigation
Description
What's the problem
RigForge is a Bash script (rigforge.sh, about 6.3k lines), about 700 lines of Bash helpers under util/, and two small Python-stdlib servers (the read-only sister API and the control receiver, 522 lines together). Python 3 and jq are runtime dependencies on every rig. rigforge.sh alone has roughly 190 lines that mention jq. A systemd timer starts rigforge.sh api-refresh every 15 seconds, and each tick loads the whole script. How many processes a tick spawns is unmeasured.
Superseded 2026-11-17: the owner changed the target language to Rust and the release to v1.20.0. The tracker comment below holds the current ground rules and child issues; Go-specific text in this body is historical.
Scope:
- In: CLI verbs, the shell helpers, the sister API, the control receiver, the refresh tick.
- Out: XMRig and its build, the Pithead image build, Pithead and the dashboard, the deprecated macOS paths, the real-hardware e2e scripts (they stay as oracle and are not ported).
- Unchanged and covered by the existing tests: the privilege boundary of the root units, bearer derivation (including constant-time compare), and the control-writable key list.
What it impacts
- Rig operators and the Pithead appliance. Per RigForge docs (how-it-works, appliance mode), the image carries a RigForge tree and re-runs
setupon every boot. Two wire contracts are pinned by committed fixtures intests/contract/v1/: the sister API feed and the control receiverGET /statusvocabulary. - systemd units. The api-refresh, control-apply, control-upgrade, autotune and watchdog templates hard-code
$SCRIPT_DIR/rigforge.shinExecStart. msr-apply runs as anExecStartPrein the xmrig unit. The script path is a compatibility surface. - Remote upgrade. It checks out a tag and runs the new tree's
rigforge.sh upgrade. A Go binary needs a build or distribution step. Unknown: whether the image would carry a Go toolchain or accept a prebuilt binary. Pithead must confirm. - Repo gates: shellcheck and shfmt (
make lint) and the kcov coverage floor assume Bash. The file-budget ratchet (docs/dev/file-budget.tsv) covers only listed files, so how it treats Go is inferred and undecided. - Related open work: Route RigForge's own upgrade and install fetches through a configured Tor SOCKS endpoint, with no clearnet fallback #668 (route upgrade and install fetches over Tor), Validate baked RigForge versus clean stock XMRig before quoting 2.0 launch performance #580 (baked vs stock performance), Run the RigForge install-to-uninstall e2e on a fresh Ubuntu 24.04 KVM guest #663 (Ubuntu KVM e2e).
How I found it
Observed unless marked inferred.
- Owner request on 2026-11-09 (UTC) to do "the same golang migration" on RigForge, modelled on pithead#3811.
- Inventory of RigForge
developat 5bf1bd8. Counts come fromwc -l rigforge.sh util/*.sh util/*.pyandgrep -c jq rigforge.sh. The timer cadence isOnCalendar=*:*:0/15in the api-refresh template. That each tick "re-runs the whole script" is inferred from the unit'sExecStart. - No existing Go-port issue found by keyword search of the tracker (go, golang, rewrite, binary size, startup).
- Pithead port, as of 2026-11-08 on the local branch
go-port/3811: strangler style, verb by verb, switchPITHEAD_IMPL=go|bash, existing suites unchanged as oracle, a parity ledger, benchmark as a separate track. About 107 commits, 36.5k non-test Go lines, 32.8k Go test lines. No PR yet. Its ledger claims no performance benefit. - Unknown, not measured: cost of one refresh tick, how much of a port would be native logic versus thin wrappers, whether the image can take a prebuilt binary, whether any outside component calls
rigforge.shthrough a path-named privilege rule. This repo ships none (inferred from a repo search).
How important is it
Low priority. Nothing is broken and no release depends on it. The benefit is uncertain and the cost is large. It should not block or be rushed ahead of product fixes or the Tor fetch work in #668.
Acceptance criteria
- Baseline before any port: CPU time, peak memory and process-spawn count for one api-refresh tick, and wall time for
status,doctor --jsonandapply --dry-run. Run on a KVM guest and on a rig-class host (described without names). Use N repeated runs, report median and spread, and state warm or cold. The script that produced the numbers is committed with the raw results. - A control arm: the cheapest change to the current code that targets the hot spot found by profiling the tick (for example fewer jq spawns), so gains from a fix are not credited to Go.
-
RIGFORGE_IMPL=go|bash, default bash. Unported verbs run the Bash path with the same argv, streams and exit status. An unknown value or missing binary is an error, never a silent fallback. - The existing suites run unchanged:
tests/run.sh, thetest-*.shregressions, the Python tests, and the contract fixtures byte-compared. All pass in bash mode. Every suite that can run against Go passes unchanged underRIGFORGE_IMPL=go. No existing test is ported, rewritten, weakened or deleted. Go unit tests and extra paired parity cases are supplementary. - Tests that source
rigforge.shand call its functions cannot exercise a Go binary. Each is listed in the ledger as Bash-only with the reason. - A parity ledger (
docs/dev/go-port/PARITY.md) lists every verb and component as native, hybrid or Bash fallback, with evidence. It states whether python3 and jq remain runtime dependencies and why. - The sister API feed and the control receiver
GET /statusvocabulary are byte-identical to the v1 fixtures.doctor --jsonIDs and shape still passtests/test-doctor-json.sh. A change to either needs a v2 fixture and a paired Pithead change. The receiver gets the same parity treatment as the API. The control-writable key list and the allowlist-subset guard intests/run.shstill hold. - Entry path: a test greps the unit templates and the repo for
rigforge.shreferences, and$SCRIPT_DIR/rigforge.sh <verb>still resolves for every verb they name, directly or through a shim. - A linked Pithead issue confirms the image can carry a prebuilt binary at a pinned RigForge tag, before any default flip. Remote upgrade is exercised from a tag that contains the binary. The issue records how the binary is integrity-checked once fetched over the Tor path in Route RigForge's own upgrade and install fetches through a configured Tor SOCKS endpoint, with no clearnet fallback #668. — Covered by rigforge#710 (paired placeholder) and p2pool-starter-stack/pithead#4212 (appliance delivery).
- Gates: the Go version is pinned in CI and the Makefile. The file-budget check has a stated rule for Go files. The shim passes shellcheck and shfmt. Go source passes
gofmtandgo vet. The kcov floor is shown before and after, and any lowering is justified in the PR. Go coverage usesgo test -coverwith a floor recorded in the repo.make checkor its equivalent runs both suites. - E2E: lanes that exist when the PR is raised (the Ubuntu KVM lane from Run the RigForge install-to-uninstall e2e on a fresh Ubuntu 24.04 KVM guest #663,
make e2e-real,make e2e-pithead) pass under both modes. Lanes that do not exist are listed in the ledger as not run, with the reason. The PR states which real-rig gates the owner runs, since they need hardware. - A final old-versus-new benchmark with the same method as the baseline, covering the tick, the two servers and the verbs. Results are reported as measured, including a null or negative result. The owner decides what saving justifies flipping the default, and that bar is written down before the final run.
- A pull request is raised for owner review only when the above is done.
Possible solutions
Options, not conclusions.
- Strangler port as in pithead#3811: a launcher or shim at
$SCRIPT_DIR/rigforge.shthat selects Go or Bash byRIGFORGE_IMPL. First slice: the two Python servers (low risk, tested over HTTP and by fixture). Then pure-logic helpers (config parse and validation, writable-key allowlist, revision digest, derived bearer, doctor JSON assembly). Then the refresh tick. Thensetup,apply,upgrade,status, and tune, if the benchmark supports it. - Port only the servers and the refresh tick as one static Go binary and leave the rest in Bash, if the measurement shows the gain is there.
- Packaging: static Go binaries (linux amd64 and arm64) built at release time and shipped in the bundle, or built on the rig at setup. The first needs no compiler on a read-only image but needs the Pithead image to accept a binary. Unknown.
- Sequencing with Route RigForge's own upgrade and install fetches through a configured Tor SOCKS endpoint, with no clearnet fallback #668: land Tor-routed fetch in shell first and port it later, or build it into the Go path. Open question for the owner. Going after Route RigForge's own upgrade and install fetches through a configured Tor SOCKS endpoint, with no clearnet fallback #668 avoids porting the fetch code twice.
Related: p2pool-starter-stack/pithead#3811 (model and owner ruling), #668, #580, #663.
rigforge#710 (paired Pithead issue for appliance binary delivery), p2pool-starter-stack/pithead#4212 (appliance updater delivery).
Activity
[-]Port RigForge to Go behind an implementation switch, with the existing suites as the parity oracle and a benchmark[/-][+]Port RigForge to Rust behind an implementation switch, with the existing suites as the parity oracle and a benchmark[/+]pithead-developer commentedon Nov 17, 2026
Owner request (2026-11-17): migrate RigForge's scripts and APIs to a compiled language, then "or actually let's make it rust". The target is Rust, not Go.
Ground rules (from the old body and the Pithead go-port rulings, pithead#3811):
bash "$SCRIPT"invocations) are listed as Bash-only in docs/dev/rust-port/PARITY.md with the reason, unless a hybrid helper subcommand lets them reach Rust.rigforge.sh <verb>with no environment, so the selection must persist for systemd units (a rendered Environment= line or a config key), not only an env var; Add the RIGFORGE_IMPL dispatcher, unit-level selection, parity CI job and ledger #706 defines it.Owner 2026-11-17: target release v1.20.0.
Child issues, in order:
Switch and parity rule: RIGFORGE_IMPL defaults to bash. An unknown value or a missing binary is an error, never a silent fallback. A verb not yet native runs the Bash path with the same argv, streams and exit status. Nothing flips to rust by default until (a)
RIGFORGE_IMPL=rust make test-suiteand the bash-mode run both pass unchanged at the same head, (b) the contract fixtures byte-match, (c) Pithead confirms the image carries the binary and remote upgrade was exercised from a tag containing it, and (d) the final benchmark meets the owner's pre-written threshold. Removal of Bash and Python is a separate PR after the flip has run on the benches.pithead-developer commentedon Nov 17, 2026
Owner rulings, 2026-11-17 (after the child issues were filed):
Shipping order after the groundwork (#704, #705, #706, #707, #708, #709, #731 and the appliance route):
upgrade --checkThen Record ledger disposition for tune, autotune, bench, stress, bios, shared-host and macOS paths #726, Run the final old-vs-new benchmark and the default-flip decision #727, Remove replaced Bash and Python after the flip has soaked on the benches #728 and Update documentation for the Rust implementation #729.
pithead-developer commentedon Nov 17, 2026
Owner, 2026-11-17: DIY installs also get a Homebrew route beside apt: #732. DIY routes are apt (#731), Homebrew (#732) and the release zip (#708).
pithead-developer commentedon Nov 17, 2026
Owner support policy and packaging pattern, 2026-11-17:
Formula/rigforge.rbgenerated at release (Offer a Homebrew install route for DIY RigForge installs #732), and its own signed APT feed on GitHub Pages (Package RigForge as a .deb for DIY installs and publish it through the project APT repository #731), so neither waits for another repository. The signing key, the fingerprint variable and enabling Pages are owner actions.pithead-developer commentedon Nov 24, 2026
Owner direction, 24 November 2026, for the refresh tick: take the cheap steps first and measure (#818, then #847), then decide on the compiled tick (#717). Language by size and risk: a small, simple component may be C if it is tested properly; anything large is Rust. #704 and #717 now wait for #847.
pithead-developer commentedon Nov 24, 2026
Owner decision, 24 November 2026 (replaces the note above from the same day): build the compiled refresh now.
Order of work: #705, #706, #704 (script and results committed), the parts of #714 and #716 that the refresh needs, then #717. The rest of the shipping order is unchanged, and so are the ground rules: the default stays
bash, no existing file undertests/changes, small pull requests ontodevelop.The measured comparison is on #847. One correction to the child issues, found while preparing #705: the Makefile has no
checktarget. The targets that play that role aretest(lint plus the suite),lint-allandci.docs: name criterion 3b in the owed section per the owner's split