Repository navigation
fix(windows-miner): surface the node diagnostic and stop hot-retrying rejected headers in the packaged miner (#7368) - #8648
Conversation
…ected headers in the packaged miner The copy compiled into RustChainMiner.exe (installer/src/rustchain_windows_miner.py) kept the pre-Scottcjn#7368 behavior: submit_header returned a bare False, so the node reason was discarded and _mine_loop resubmitted the same rejected slot every poll. Terminal rejections now mark the slot handled and log the server body verbatim; temporary failures get bounded exponential backoff (10s base, 300s cap). Adds regression tests for the packaged copy.
|
Welcome to RustChain! Thanks for your first pull request. Before we review, please make sure:
Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150) A maintainer will review your PR soon. Thanks for contributing! |
Fresh verification — 2026-11-09 (no code change since opening; head is still
|
What Changed
miners/windows/installer/src/rustchain_windows_miner.pyis the copy thatinstaller/build_miner.pyandRustChainMiner.speccompile into the shipped Windows executable. It still carried the pre-#7368 behavior even though the standaloneminers/windows/rustchain_windows_miner.pywas fixed:submit_header()returned a bareFalse, so the node's rejection body was thrown away;_mine_loop()resubmitted the same rejected lottery slot on every poll (every 10 s for the whole eligibility window) — an endless silent retry loop;--headlessprinted only[share] submitted=N accepted=M FAIL, and the failure event carried no reason at all.This PR applies the same design the standalone miner already uses, to the packaged copy:
last_header_erroris built with the file's existing_response_diagnostic()helper (HTTP <status>pluscode=/error=/message=, orbody=<first 240 chars>for non-JSON), and a new_format_headless_event()prints it verbatim in headless mode (same line shape as the standalone miner)./lottery/eligibilityis recorded in_last_submitted_sloton success and on terminal rejection;_header_submission_due(slot)gates the loop, so a rejected slot is never resubmitted.class=terminal no_retryand no further POST goes out for that slot.What the miner sends is untouched — same URL,
json=header,timeout=5,verify=TLS_VERIFY. Only how it handles the answer changes.Reproduction against a real node (not mocked)
Both copies (pre-fix from
upstream/main, post-fix from this branch) were driven through their real_mine_loopagainst https://rustchain.org in Dockerpython:3.11-bookworm, walletRTC02811ff5e2bb4bb4b95eee44c5429cd9525496e7, live lottery slot49030for the whole window. Header POSTs are genuine HTTPS requests; the rejection text is the node's own bytes — the node answers this unsigned legacy payload withHTTP 400 {"error":"missing fields","ok":false}.Two seams, both disclosed: eligibility keeps the live node call and the live slot but forces
eligible=true(the public node answersnot_attestedfor this test wallet), andtime.sleepis shortened from the real 10 s poll to 2 s so the transcript is readable — retry scheduling still uses real wall-clock time.Reading of it: pre-fix, a node rejection produced four POSTs (
08:07:56 / :59 / 08:08:01 / 08:08:04) and the reason never reached the operator. Post-fix there is exactly one POST (08:08:07) for slot 49030, the node's ownmissing fieldsbody on the log line, and nothing resent for that slot. The connection-refused case shows the opposite classification: pre-fix 8 POSTs at ~2.4 s spacing, post-fix 2 POSTs with a growing gap (retry_in=10.6s, thenretry_in=15.9s).Acceptance criteria (bounty #16252)
https://rustchain.org, live slot, node's own 400 body) — not only mocks; 6 hermetic regression tests complement it.Testing / Evidence
Docker
python:3.11-bookwormon the Linux runner, fresh clone of this branch:On the actual target platform (Windows, Python 3.12.5):
pytest -qover the same files → 24 passed,ruff check --select E9,F63,F7,F82clean.New file
tests/test_windows_installer_headless_rejected_header_retry.py(6 tests) covers: terminal rejection marks the slot handled and keeps the diagnostic; 403 terminal vs 408/429/500/503 retryable; connection failure backs off 10 s → 20 s and never exceeds the 300 s cap; success clears retry state;_mine_loopissues exactly one POST across three eligible polls; the headless line carries the diagnostic plus its retry class.BCOS Checklist (Required For Non-Doc PRs)
# SPDX-License-Identifier: MIT) at the top of the new test file.Closes #7368
Bounty: Scottcjn/rustchain-bounties#16252 — 12 RTC
RTC wallet for payout:
RTC6m7xQJ9Fj8sE2vD1gYp4tN3uW8zK5rB