Skip to content

Conversation

@samuel-asleep
Copy link
Contributor

Implements a comprehensive installer for RustChain miners supporting Linux (Ubuntu/Debian/Fedora) and macOS (Intel/Apple Silicon) with virtualenv isolation, persistent service setup, and clean uninstall.

Changes

Installer enhancements (install.sh)

  • Virtualenv isolation at ~/.rustchain/venv - dependencies install without touching system Python
  • Systemd user service (Linux) and launchd agent (macOS) for auto-start on boot with failure restart
  • --uninstall flag removes services, files, virtualenv, and configuration cleanly
  • --wallet WALLET_NAME argument for non-interactive installations
  • Post-install output includes wallet balance check commands and service management instructions

Platform support

  • Linux: x86_64, ppc64le, ppc, POWER8 with systemd service
  • macOS: Intel (x86_64), Apple Silicon (arm64), PowerPC with launchd agent

Documentation

  • Updated README.md with installation examples and service management commands
  • New INSTALL.md (371 lines) covering installation, troubleshooting, service management, and security notes

Usage

# Install with auto-generated wallet
curl -sSL https://raw.githubusercontent.com/Scottcjn/Rustchain/main/install.sh | bash

# Install with specific wallet (non-interactive)
curl -sSL https://raw.githubusercontent.com/Scottcjn/Rustchain/main/install.sh | bash -s -- --wallet my-miner

# Uninstall completely
curl -sSL https://raw.githubusercontent.com/Scottcjn/Rustchain/main/install.sh | bash -s -- --uninstall

# Manage service (Linux)
systemctl --user status rustchain-miner

# Manage service (macOS)
launchctl list | grep rustchain

Technical notes

  • Virtualenv creation uses python -m venv with fallback to virtualenv module
  • Services run as user (no root/sudo required)
  • SSL verification disabled for self-signed node certificate (documented in security notes)
  • Service logs to ~/.rustchain/miner.log

Fixes Scottcjn/rustchain-bounties#4

Copy link
Owner

@Scottcjn Scottcjn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Miner Installer with Virtualenv Isolation (PR #6)

@samuel-asleep - This is the strongest PR of the batch. Virtualenv isolation, systemd/launchd auto-start, and clean uninstall are all real improvements over the existing installer. The code is clean and well-structured.

Issues to Fix

1. All API endpoint URLs are wrong (BLOCKER)
The PR references three endpoint patterns throughout INSTALL.md, README.md, and the install.sh post-install output that don't exist on the RustChain node:

/wallet/YOUR_WALLET_NAME/balance       → 404
/wallet/YOUR_WALLET_NAME/transactions  → 404
/miner/YOUR_WALLET_NAME/stats          → 404

The actual endpoints are:

# Balance check (the only one that exists)
curl -sk "https://50.28.86.131/wallet/balance?miner_id=YOUR_WALLET_NAME"

# Active miners list
curl -sk https://50.28.86.131/api/miners

# Node health
curl -sk https://50.28.86.131/health

# Current epoch
curl -sk https://50.28.86.131/epoch

There is no transaction history endpoint and no per-miner stats endpoint. Fix all references in:

  • INSTALL.md lines 177, 183, 189 (and all other occurrences)
  • README.md lines 56, 61
  • install.sh post-install echo statements

2. config.json is created but never consumed

cat > "$INSTALL_DIR/config.json" << EOF
{
    "wallet": "$WALLET_NAME",
    "node_url": "$NODE_URL"
}
EOF

The miner uses --wallet CLI arg, not a config file. INSTALL.md tells users to edit config.json to change settings, but the miner ignores it. Either:

  • Remove config.json creation and references
  • Or have the start script read from it (parse with python -c "import json; ...")

3. No wallet name validation
Wallet names with spaces, quotes, or shell metacharacters will break the systemd service file and launchd plist since they're interpolated directly:

ExecStart=$venv_python $INSTALL_DIR/rustchain_miner.py --wallet $wallet

If wallet is my wallet or $(rm -rf ~), this breaks or worse. Add validation:

if [[ ! "$wallet_name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
    echo -e "${RED}[!] Wallet name can only contain letters, numbers, hyphens, and underscores${NC}"
    exit 1
fi

Minor Issues

4. Heredoc quoting in service files
The systemd service and launchd plist use unquoted heredocs (<< EOF), which means shell variables are expanded at creation time. This is actually correct here since you want the current values baked in, but worth a comment in the script.

5. read -r in piped context
When the script is piped from curl (curl ... | bash), stdin is the curl output, not the terminal. The read -r wallet_name and read -r setup_autostart calls will read from the pipe (which is empty/exhausted), not from the user. This means:

  • Without --wallet, the auto-generated name is always used (user can't type)
  • Auto-start prompt is always skipped

The fix: redirect reads from /dev/tty:

read -r wallet_name < /dev/tty
read -r setup_autostart < /dev/tty

What's Good

  • Virtualenv isolation is the right call - pip install --user pollutes the user's Python
  • Systemd user services (not system services) - no sudo needed
  • Launchd plist with KeepAlive and -u (unbuffered) for real logging
  • Clean uninstall removes services, files, and symlinks
  • --wallet flag for non-interactive/scripted installs
  • Fallback from python -m venv to virtualenv module
  • Good error messages with colored output
  • INSTALL.md is thorough (troubleshooting section is useful)

Fix items 1, 3, and 5, and this is mergeable. Item 2 is a nice-to-have.

@Scottcjn
Copy link
Owner

Scottcjn commented Feb 2, 2026

@samuel-asleep Here's the fix checklist:

Fix List

1. Fix all API endpoint URLs (BLOCKER)

Every curl example in INSTALL.md, README.md, and install.sh uses endpoint patterns that return 404. Replace with the actual API:

# Balance check (CORRECT)
curl -sk "https://50.28.86.131/wallet/balance?miner_id=YOUR_WALLET_NAME"

# Miners list (CORRECT)
curl -sk https://50.28.86.131/api/miners

# Node health (CORRECT)
curl -sk https://50.28.86.131/health

Remove references to /wallet/WALLET/transactions and /miner/WALLET/stats — those endpoints don't exist.

2. Add wallet name validation

Prevent shell injection via wallet names. Before using the wallet name anywhere:

if [[ ! "$wallet_name" =~ ^[a-zA-Z0-9_-]+$ ]]; then
    echo -e "${RED}[!] Wallet name must be alphanumeric (hyphens and underscores allowed)${NC}"
    exit 1
fi

3. Fix read in piped context

When installed via curl ... | bash, read can't read from the user because stdin is the pipe. Redirect from /dev/tty:

read -r wallet_name < /dev/tty
read -r setup_autostart < /dev/tty
read -r start_now < /dev/tty

4. (Optional) Remove or fix config.json

The miner doesn't read config.json — it uses --wallet CLI arg. Either remove the config.json creation and INSTALL.md references, or update start.sh to parse it.


Fix 1-3 and push. This is close to merge.

@Scottcjn
Copy link
Owner

Scottcjn commented Feb 2, 2026

@samuel-asleep Re-reviewed after your second commit. All 4 items from the original fix checklist have been addressed:

  • API endpoint URLs: All corrected to /wallet/balance?miner_id=X, /api/miners, /health, /epoch
  • Wallet name validation: Added ^[a-zA-Z0-9_-]+$ regex check
  • read in piped context: All 3 read calls now use < /dev/tty
  • config.json removed: Creation and all references removed

New Features (Nice Additions)

The second commit also added several improvements beyond the original fixes:

  • --wallet flag for non-interactive install
  • --uninstall flag for clean removal
  • virtualenv isolation (no system pollution)
  • systemd user service setup (Linux)
  • launchd agent setup (macOS)
  • Proper service management commands in output

Remaining Nits (Non-Blocking)

1. Fake example response in INSTALL.md (Minor)

Line 164-170 shows:

{
  "wallet": "my-miner-wallet",
  "balance": 12.456,
  "pending": 0.12
}

The actual /wallet/balance response format is:

{"miner_id": "my-miner-wallet", "amount_rtc": 12.456, "amount_i64": 12456000}

2. Mixed HTTP/HTTPS in README (Minor)

The "Network Verification" section now uses curl -sk https://... (correct), but the block explorer link at the bottom still uses http://50.28.86.131/explorer (no HTTPS). Not a real issue since the explorer works on both, but inconsistent.

3. No --start-now flag (Suggestion)

For fully non-interactive deployment (curl ... | bash -s -- --wallet X), the auto-start prompt still requires /dev/tty. Consider adding --auto-start flag for CI/automation use cases. Not required for this PR though.


Verdict

This is ready to merge with the documentation nit fixed. The installer now handles the full lifecycle (install → configure → service → uninstall) and works correctly in piped context.

Copy link
Owner

@Scottcjn Scottcjn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All 4 fix checklist items addressed. Installer now handles full lifecycle. Ready to merge — only remaining nit is a fake example response in INSTALL.md (wrong field names in the JSON example).

@Scottcjn
Copy link
Owner

Scottcjn commented Feb 2, 2026

@samuel-asleep Sent 5 RTC to wallet samuel-asleep for your approved PR. Check your balance:

curl -s 'https://50.28.86.131/wallet/balance?miner_id=samuel-asleep' -k

This is a welcome bonus — the full 25 RTC bounty (#4 on rustchain-bounties) pays on merge to main. If you want a different wallet name, let us know and we'll transfer.

@Scottcjn Scottcjn merged commit 1122901 into Scottcjn:main Feb 2, 2026
@samuel-asleep samuel-asleep deleted the installation-script branch February 2, 2026 19:01
Scottcjn pushed a commit that referenced this pull request Feb 2, 2026
Interactive miner dashboard for RustChain with:
- Real-time active miners table with architecture badges
- Antiquity multiplier display (2.5x for G4, 2.0x for G5)
- Balance leaderboard (top 20)
- Miner search by wallet ID
- Node health monitoring
- Auto-refresh every 30 seconds

Tech: Pure vanilla JS + Tailwind CSS CDN, no build step.
526 lines of production code.

Closes Scottcjn/rustchain-bounties#6
Scottcjn added a commit that referenced this pull request Feb 2, 2026
feat: Miner Dashboard Explorer (Bounty #6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BOUNTY] Build RustChain miner installer script (Linux + Mac)

2 participants