fix(miner): keep an updated miner, don't re-extract the bundled one

Builds that embed xmrig (Windows release) re-extracted the bundled miner
whenever its size differed from the file on disk. An "Update miner..."
install always differs, so the next start silently put the bundled build
back while settings still showed the updated version.

- The bundled miner is now placed only when it is missing, like the node
  binaries (kXmrigRefreshOnSizeMismatch = false in the provision table).
  Params and asmap still follow the bundled size.
- Behaviour change: a wallet upgrade no longer refreshes a miner the user
  never updated; "Update miner..." is the way to get a newer build.
- The uncalled needsXmrigExtraction() is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 13:22:00 -05:00
co-authored by Claude Opus 5.5
parent 81733f5603
commit ae66b54694
3 changed files with 25 additions and 24 deletions
+17
View File
@@ -3559,6 +3559,22 @@ void testResourceNeedsWrite()
removeTree(dir);
}
// C120: the bundled miner is placed only when missing, so an "Update miner..." install of a different size is
// never overwritten by the bundled copy on the next start.
void testXmrigProvisionPolicy()
{
using dragonx::resources::kXmrigRefreshOnSizeMismatch;
using dragonx::resources::resourceNeedsWrite;
EXPECT_TRUE(!kXmrigRefreshOnSizeMismatch);
const fs::path dir = makeTempDir();
const std::string f = (dir / "xmrig.exe").string();
const std::string missing = (dir / "missing-xmrig.exe").string();
{ std::ofstream(f, std::ios::binary) << "12345"; }
EXPECT_TRUE(!resourceNeedsWrite(10, kXmrigRefreshOnSizeMismatch, f)); // present, different size: kept
EXPECT_TRUE(resourceNeedsWrite(10, kXmrigRefreshOnSizeMismatch, missing)); // missing: placed
removeTree(dir);
}
// ── C222: bootstrap preflight (util/bootstrap.h) ──
// Writes a zip with miniz. level 0 stores members uncompressed, so a test can corrupt member data in place.
static bool writeBootstrapTestZip(const fs::path& zipPath,
@@ -16982,6 +16998,7 @@ int main()
testVerifySaplingParams();
testStartupProvisionState();
testResourceNeedsWrite();
testXmrigProvisionPolicy();
testBootstrapSpaceSufficient();
testBootstrapPlanArchive();
#ifndef _WIN32