apow-cli 0.11.17 → 0.11.19
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/README.md +2 -0
- 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/skill.md +4 -0
package/README.md
CHANGED
|
@@ -103,6 +103,7 @@ PRIVATE_KEY=0x... # Your wallet private key
|
|
|
103
103
|
USE_X402=true # Auto-pay RPC + LLM via x402 (2.00 USDC minimum starting balance, zero API keys)
|
|
104
104
|
USE_X402_GRIND=true # Auto-pay remote GPU grinding via x402
|
|
105
105
|
ALLOW_LOCAL_FALLBACK_WITH_X402=false # Easy Mode default: do not burn local CPU while x402 GPU is active
|
|
106
|
+
# STALE_CHECK_INTERVAL=5 # Seconds between stale-challenge checks while grinding (default: 5)
|
|
106
107
|
# RPC_URL=https://... # Or: bring your own RPC (free from Alchemy, QuickNode, etc.)
|
|
107
108
|
# LLM_PROVIDER=clawrouter # clawrouter (auto with x402) | openai | gemini | deepseek | qwen | anthropic | ollama (for minting)
|
|
108
109
|
# LLM_MODEL=blockrun/eco # Auto-detected per provider; override only if needed
|
|
@@ -212,6 +213,7 @@ The CUDA grinder runs over SSH alongside your local Metal/CPU grinders — genui
|
|
|
212
213
|
### Other Optimizations
|
|
213
214
|
|
|
214
215
|
- **Algorithmic SMHL**: Mining SMHL challenges are solved algorithmically in microseconds (no LLM call). Your AI was already proven when you minted your Mining Rig.
|
|
216
|
+
- **Faster stale restarts**: The miner re-checks the challenge every 5 seconds by default and aborts dead work quickly across local, native GPU/CPU, and x402 grinding.
|
|
215
217
|
- **JS threads**: If no native grinders are found, falls back to `worker_threads` across all CPU cores. Set `MINER_THREADS` in `.env` to override.
|
|
216
218
|
|
|
217
219
|
## Dashboard
|
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;
|
package/package.json
CHANGED
package/skill.md
CHANGED
|
@@ -300,6 +300,7 @@ CHAIN=base
|
|
|
300
300
|
| `LLM_MODEL` | No | per-provider default (e.g. `blockrun/eco`, `gpt-4o-mini`) | Model identifier passed to the provider (minting only). Auto-detected from provider if omitted. |
|
|
301
301
|
| `CLAWROUTER_PORT` | No | `8402` | Port for ClawRouter local proxy (only if default is in use) |
|
|
302
302
|
| `MINER_THREADS` | No | All CPU cores | Threads for JS nonce grinding (fallback if no native GPU/CPU grinder detected) |
|
|
303
|
+
| `STALE_CHECK_INTERVAL` | No | `5` | Seconds between stale-challenge checks while grinding. Applies across local/native and x402 grinders; lower values restart dead work faster but add more RPC reads. |
|
|
303
304
|
| `RPC_URL` | No* | — | Base JSON-RPC endpoint. Get a free URL from Alchemy or QuickNode. *Not needed if `USE_X402=true`. |
|
|
304
305
|
| `USE_X402` | No | `false` | Set to `true` to auto-pay via QuickNode x402 (2.00 USDC minimum starting balance; add more for headroom). Replaces `RPC_URL`. |
|
|
305
306
|
| `CHAIN` | No | `base` | Network selector; auto-detects `baseSepolia` if RPC URL contains "sepolia" |
|
|
@@ -441,6 +442,7 @@ npx apow-cli mine <tokenId> # or specify a rig by token ID
|
|
|
441
442
|
- `smhl`: the SMHL format challenge
|
|
442
443
|
4. **Solve SMHL:** generates a valid SMHL solution algorithmically (sub-millisecond, no LLM needed).
|
|
443
444
|
5. **Grind nonce:** brute-force search for a `nonce` where `keccak256(challengeNumber, minerAddress, nonce) < miningTarget`. Works on any CPU out of the box. Add a GPU for 100x+ faster grinding.
|
|
445
|
+
The CLI re-checks the challenge every 5 seconds by default while grinding and aborts stale work across local/native and x402 nonce sources.
|
|
444
446
|
6. **Submit proof:** calls `mine(nonce, smhlSolution, tokenId)` on AgentCoin. The contract verifies both the hash and SMHL solution on-chain.
|
|
445
447
|
7. **Collect reward:** AGENT tokens are minted directly to your wallet.
|
|
446
448
|
8. **Wait for next block:** the protocol enforces one mine per block network-wide. The client waits for block advancement before the next cycle.
|
|
@@ -479,6 +481,7 @@ A Mythic miner (5.00x) earns 15.00 AGENT per mine in Era 0.
|
|
|
479
481
|
|
|
480
482
|
The miner has built-in resilience:
|
|
481
483
|
- **Flat retry delay** on transient failures (about 2s with a small jitter)
|
|
484
|
+
- **Background stale checks** every 5 seconds by default so slow grinders do not waste a full attempt on a dead challenge
|
|
482
485
|
- **Max 10 consecutive failures** before the miner exits
|
|
483
486
|
- **Fatal errors** cause immediate exit: `"Not your miner"`, `"Supply exhausted"`, `"No contracts"`
|
|
484
487
|
- **Block timing** is handled automatically: if the block hasn't advanced, the miner waits
|
|
@@ -665,6 +668,7 @@ Use the corresponding testnet contract addresses.
|
|
|
665
668
|
| `No contracts` | Calling from a contract, not an EOA | Mining requires an externally owned account (EOA) |
|
|
666
669
|
| `Invalid hash` | Nonce does not meet difficulty target | Bug in nonce grinding; should not happen under normal operation |
|
|
667
670
|
| `Nonce too high` | Wallet nonce desync | Reset nonce in wallet or wait for pending transactions to confirm |
|
|
671
|
+
| Frequent `stale #N` restarts | Your grinder is slower than the current network difficulty | Expected on slow rigs. The default 5-second stale check already reduces wasted work; use a faster grinder or lower `STALE_CHECK_INTERVAL` if you intentionally want more aggressive polling. |
|
|
668
672
|
| `Anthropic request failed: 429` | Rate limited by Anthropic API | Reduce mining frequency or upgrade API plan |
|
|
669
673
|
| `Ollama request failed: 500` | Ollama server error | Check `ollama serve` is running; restart if needed |
|
|
670
674
|
| `SMHL solve failed after 5 attempts` | LLM cannot satisfy constraints | Switch to a more capable model (e.g., `gpt-4o` or `claude-sonnet-4-5-20250929`) |
|