fix(miner): run service installs unbuffered#5711
Conversation
6e41c80 to
a8cd3ec
Compare
|
Follow-up added in commit The previous summary command used curl -sk '$NODE_URL/wallet/balance?miner_id=$WALLET_NAME' | python3 -m json.toolRe-ran validation after the update: bash -n setup.sh
bash -n scripts/install.sh
git diff --checkAll passed. |
|
Reviewed the service-install changes. What I checked:
No blocking issues found in this diff. |
a8cd3ec to
1546b92
Compare
|
Second follow-up added in commit While checking the service templates, I noticed they set The PR now passes the configured wallet explicitly in both installer paths:
Validation after this update: bash -n setup.sh
bash -n scripts/install.sh
git diff --checkAll passed. |
| echo "" | ||
| echo -e " ${BOLD}Check your balance:${NC}" | ||
| echo -e " curl -sk '$NODE_URL/wallet/$WALLET_NAME' | python3 -m json.tool" | ||
| echo -e " curl -sk '$NODE_URL/wallet/balance?miner_id=$WALLET_NAME' | python3 -m json.tool" |
There was a problem hiding this comment.
This hint now uses $WALLET_NAME as the miner_id, but the Linux miner still treats those as different identifiers. --wallet is passed into LocalMiner(..., wallet=args.wallet) and then sent as miner / miner_pubkey; the miner_id fields in attestation/enrollment are derived separately via _miner_id_from_hw(self.hw_info). LocalMiner.check_balance() also still queries /balance/{self.wallet}.
That means this summary command can show a zero or misleading balance for a correctly configured service install, because it asks /wallet/balance for miner_id=<wallet name> rather than the hardware-derived miner id or the legacy wallet/pubkey path. I would either keep the hint aligned with the miner's current lookup (/balance/$WALLET_NAME) or update the miner/server plumbing so the setup wallet name is actually the miner_id everywhere.
siteportco
left a comment
There was a problem hiding this comment.
Focused review pass completed.
Validation run locally:
C:\Program Files\Git\bin\bash.exe -n setup.shpassed.C:\Program Files\Git\bin\bash.exe -n scripts/install.shpassed.git diff --check origin/main...HEADpassed.python -m py_compile miners/linux/rustchain_linux_miner.pypassed.
The -u / PYTHONUNBUFFERED=1 service changes look syntactically sound, and passing --wallet fixes the service path no longer falling back to _gen_wallet(). I left one inline concern on the new balance-check hint because the current Linux miner still treats wallet and hardware-derived miner_id as separate values, so /wallet/balance?miner_id=$WALLET_NAME may mislead users even though the service itself starts with the intended wallet.
TJCurnutte
left a comment
There was a problem hiding this comment.
Reviewed current head 1546b92c2d5b6d0df26b99ac3b46187ff5ac24d7.
The service-launch changes are tight and match the miner CLI behavior: generated systemd/launchd commands now run Python unbuffered and pass the configured wallet explicitly instead of relying on environment variables that the Linux miner does not consume as its wallet source.
Validation performed:
git diff --check origin/main...HEAD -- scripts/install.sh setup.sh
bash -n scripts/install.sh
bash -n setup.sh
python3 -B -m pytest -q tests/test_setup_sh_downloads.py tests/test_scripts_installer_downloads.py --tb=shortResults:
bash -n passed for scripts/install.sh and setup.sh
5 passed, 1 warning in 0.07s
Additional static/source checks:
scripts/install.sh: PYTHONUNBUFFERED=1 present, `-u` present, `--wallet` present, downloads rustchain_linux_miner.py
setup.sh: PYTHONUNBUFFERED=1 present, `-u` present, `--wallet` present, downloads rustchain_linux_miner.py
miners/linux/rustchain_linux_miner.py: argparse defines `--wallet` and passes `wallet=args.wallet` into LocalMiner
node/rustchain_v2_integrated_v2.2.1_rip200.py: `/wallet/balance` route exists
I also probed the documented balance URL over TLS:
curl -sS -m 10 -o /tmp/rustchain-balance-probe.json -w 'http=%{http_code} ssl=%{ssl_verify_result}\n' 'https://rustchain.org/wallet/balance?miner_id=review-probe'
http=200 ssl=0
{"amount_i64":0,"amount_rtc":0.0,"miner_id":"review-probe"}
Approved.
jaxint
left a comment
There was a problem hiding this comment.
LGTM! Great work on this PR. 🚀
BossChaos
left a comment
There was a problem hiding this comment.
Code Review — Run Service Installs Unbuffered
✅ Strengths
- Correct fix:
PYTHONUNBUFFERED=1and-uflag ensure logs appear in real-time - Updates both systemd and launchd configurations
- Also fixes missing
--walletargument in systemd ExecStart
⚠️ Issues
1. Critical Bug Fix
The original systemd config was missing --wallet ${wallet}, meaning the miner would start without a wallet! This is a critical bug that would cause the miner to fail.
2. Good Consistency
Both Linux (systemd) and macOS (launchd) configs are updated with the same fix.
📋 Summary
Important bug fix. The missing --wallet argument was a real issue. Suggested: 8-10 RTC.
|
I rechecked the latest follow-up. Passing the configured wallet into the service command is the right fix, and shell syntax validation passes for both installer scripts. One remaining issue: the summary balance command currently changed to: curl -sk "$NODE_URL/balance/$WALLET_NAME" | python3 -m json.toolOn the live node shape, that URL returns 404 for the wallet address form, while the documented route works: So I would keep the service curl -sk "$NODE_URL/wallet/balance?miner_id=$WALLET_NAME" | python3 -m json.toolVerification run: |
Summary
Fixes #5709.
Detached miner services redirect stdout/stderr to log files, but the generated systemd/launchd commands did not run Python in unbuffered mode. That can leave
miner.logempty for a long time even while the miner is alive, attesting, enrolling, or sleeping between balance checks.This patch updates both installer paths that generate service definitions:
setup.shExecStartnow usespython -uPYTHONUNBUFFERED=1ProgramArgumentsinclude-uPYTHONUNBUFFERED=1python -uscripts/install.shExecStartnow usespython -uPYTHONUNBUFFERED=1ProgramArgumentsinclude-uPYTHONUNBUFFERED=1Validation
All passed.
Local evidence behind the bug
On a detached macOS run, the miner process had stdout/stderr redirected to
~/.clawrtc/miner.logand~/.clawrtc/miner.err, but both files stayed size 0 after more than an hour. A one-shot unbuffered probe using the same miner script and wallet printed the expected lifecycle and reached enrollment:The fix makes service-launched miners behave like that unbuffered probe from the start.
Payout
RTC wallet / miner ID:
RTC219810c1e939b0f1a8887a5528949da0e5c97b78