apow-cli 0.11.17 → 0.11.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.js +9 -2
- package/dist/grinder-native.js +17 -4
- package/dist/miner.js +4 -4
- package/package.json +1 -1
package/dist/config.js
CHANGED
|
@@ -22,6 +22,9 @@ const DEFAULT_OLLAMA_URL = "http://127.0.0.1:11434";
|
|
|
22
22
|
const DEFAULT_CHAIN_NAME = "base";
|
|
23
23
|
const DEFAULT_MINING_AGENT_ADDRESS = "0xB7caD3ca5F2BD8aEC2Eb67d6E8D448099B3bC03D";
|
|
24
24
|
const DEFAULT_AGENT_COIN_ADDRESS = "0x12577CF0D8a07363224D6909c54C056A183e13b3";
|
|
25
|
+
const DEFAULT_STALE_CHECK_INTERVAL_MS = 5_000;
|
|
26
|
+
const MIN_STALE_CHECK_INTERVAL_MS = 1_000;
|
|
27
|
+
const MAX_STALE_CHECK_INTERVAL_MS = 60_000;
|
|
25
28
|
const EXPENSIVE_MODELS = ["gpt-4o", "gpt-4", "claude-3-opus", "claude-3-5-sonnet"];
|
|
26
29
|
const CHEAP_OVERRIDES = ["gpt-4o-mini", "gpt-4-mini"];
|
|
27
30
|
function normalizeProvider(value, useX402) {
|
|
@@ -90,9 +93,13 @@ function resolveLlmApiKey(provider) {
|
|
|
90
93
|
}
|
|
91
94
|
function resolveStaleCheckIntervalMs() {
|
|
92
95
|
if (process.env.STALE_CHECK_INTERVAL) {
|
|
93
|
-
|
|
96
|
+
const seconds = parseInt(process.env.STALE_CHECK_INTERVAL, 10);
|
|
97
|
+
if (Number.isFinite(seconds) && seconds > 0) {
|
|
98
|
+
const intervalMs = seconds * 1000;
|
|
99
|
+
return Math.min(MAX_STALE_CHECK_INTERVAL_MS, Math.max(MIN_STALE_CHECK_INTERVAL_MS, intervalMs));
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
|
-
return
|
|
102
|
+
return DEFAULT_STALE_CHECK_INTERVAL_MS;
|
|
96
103
|
}
|
|
97
104
|
function buildConfig() {
|
|
98
105
|
const chainName = resolveChainName();
|
package/dist/grinder-native.js
CHANGED
|
@@ -128,12 +128,25 @@ async function grindNonceNative(challengeNumber, target, minerAddress, info, sig
|
|
|
128
128
|
const [s, ns] = process.hrtime(start);
|
|
129
129
|
return s + ns / 1_000_000_000;
|
|
130
130
|
}
|
|
131
|
+
function terminateProcess(proc) {
|
|
132
|
+
try {
|
|
133
|
+
proc.kill("SIGTERM");
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
if (proc.exitCode === null && proc.signalCode === null) {
|
|
140
|
+
try {
|
|
141
|
+
proc.kill("SIGKILL");
|
|
142
|
+
}
|
|
143
|
+
catch { }
|
|
144
|
+
}
|
|
145
|
+
}, 250);
|
|
146
|
+
}
|
|
131
147
|
function cleanup() {
|
|
132
148
|
for (const proc of processes) {
|
|
133
|
-
|
|
134
|
-
proc.kill("SIGTERM");
|
|
135
|
-
}
|
|
136
|
-
catch { }
|
|
149
|
+
terminateProcess(proc);
|
|
137
150
|
}
|
|
138
151
|
if (info.remoteGpu) {
|
|
139
152
|
try {
|
package/dist/miner.js
CHANGED
|
@@ -369,7 +369,7 @@ async function startMining(tokenId) {
|
|
|
369
369
|
if (estimatedSeconds > 300) {
|
|
370
370
|
console.log("");
|
|
371
371
|
ui.warn(`Your grinder (~${formatRate(estHashrate)}) is far too slow for current difficulty.`);
|
|
372
|
-
console.log(` Expected time per mine: ~${formatTime(estimatedSeconds)} (
|
|
372
|
+
console.log(` Expected time per mine: ~${formatTime(estimatedSeconds)} (CLI stale-check interval: ${staleCheckSeconds}s).`);
|
|
373
373
|
console.log("");
|
|
374
374
|
console.log(` Fix options:`);
|
|
375
375
|
console.log(` 1. Run ${ui.cyan("apow build-grinders")} for 100x faster local mining (~500 MH/s)`);
|
|
@@ -385,7 +385,7 @@ async function startMining(tokenId) {
|
|
|
385
385
|
else if (estimatedSeconds > staleCheckSeconds) {
|
|
386
386
|
console.log("");
|
|
387
387
|
ui.warn(`Your grinder (~${formatRate(estHashrate)}) is too slow for current difficulty.`);
|
|
388
|
-
console.log(` Expected time per mine: ~${formatTime(estimatedSeconds)} (
|
|
388
|
+
console.log(` Expected time per mine: ~${formatTime(estimatedSeconds)} (CLI stale-check interval: ${staleCheckSeconds}s).`);
|
|
389
389
|
console.log("");
|
|
390
390
|
console.log(` Fix options:`);
|
|
391
391
|
console.log(` 1. Run ${ui.cyan("apow build-grinders")} for 100x faster local mining (~500 MH/s)`);
|
|
@@ -449,7 +449,7 @@ async function startMining(tokenId) {
|
|
|
449
449
|
// local CPU while a remote GPU grind is already in flight.
|
|
450
450
|
// Abort and re-fetch challenge periodically to avoid grinding a dead
|
|
451
451
|
// nonce after another miner wins the block. Configurable via
|
|
452
|
-
// STALE_CHECK_INTERVAL env var (seconds, default
|
|
452
|
+
// STALE_CHECK_INTERVAL env var (seconds, default 5).
|
|
453
453
|
const staleCheckMs = config_1.config.staleCheckIntervalMs;
|
|
454
454
|
let grind = null;
|
|
455
455
|
let staleRestarts = 0;
|
|
@@ -603,7 +603,7 @@ async function startMining(tokenId) {
|
|
|
603
603
|
console.log(` ${ui.dim("SMHL re-solved, grinding fresh challenge...")}`);
|
|
604
604
|
if (staleRestarts >= 3 && staleRestarts % 3 === 0) {
|
|
605
605
|
ui.warn(`Challenge has gone stale ${staleRestarts} times — grinder may be too slow for current difficulty.`);
|
|
606
|
-
ui.warn(`Tip:
|
|
606
|
+
ui.warn(`Tip: decrease STALE_CHECK_INTERVAL below ${staleCheckMs / 1000}s for faster restarts, or use a faster grinder.`);
|
|
607
607
|
}
|
|
608
608
|
grind = null; // loop again
|
|
609
609
|
continue;
|